/src/libreoffice/include/sfx2/sfxhtml.hxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
5 | | * This Source Code Form is subject to the terms of the Mozilla Public |
6 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
7 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
11 | | * Licensed to the Apache Software Foundation (ASF) under one or more |
12 | | * contributor license agreements. See the NOTICE file distributed |
13 | | * with this work for additional information regarding copyright |
14 | | * ownership. The ASF licenses this file to you under the Apache |
15 | | * License, Version 2.0 (the "License"); you may not use this file |
16 | | * except in compliance with the License. You may obtain a copy of |
17 | | * the License at http://www.apache.org/licenses/LICENSE-2.0 . |
18 | | */ |
19 | | |
20 | | #pragma once |
21 | | |
22 | | #include <sal/config.h> |
23 | | #include <sfx2/dllapi.h> |
24 | | #include <sal/types.h> |
25 | | #include <i18nlangtag/lang.h> |
26 | | #include <svtools/parhtml.hxx> |
27 | | #include <svl/macitem.hxx> |
28 | | #include <memory> |
29 | | |
30 | | |
31 | | class ImageMap; |
32 | | class SfxMedium; |
33 | | class SvNumberFormatter; |
34 | | |
35 | | class SFX2_DLLPUBLIC SfxHTMLParser : public HTMLParser |
36 | | { |
37 | | OUString aScriptType; |
38 | | |
39 | | SfxMedium* pMedium; |
40 | | std::unique_ptr<SfxMedium> pDLMedium; // Medium for Download Files |
41 | | |
42 | | ScriptType eScriptType; |
43 | | |
44 | | SAL_DLLPRIVATE void GetScriptType_Impl( SvKeyValueIterator* ); |
45 | | |
46 | | protected: |
47 | | |
48 | | SfxHTMLParser( SvStream& rStream, bool bNewDoc, SfxMedium *pMedium ); |
49 | | |
50 | | virtual ~SfxHTMLParser() override; |
51 | | |
52 | | public: |
53 | | // Read the options of an image map |
54 | | // <MAP>: sal_True = Image-Map has a name |
55 | | // <AREA>: sal_True = Image-Map has now one vcl::Region more |
56 | | static bool ParseMapOptions(ImageMap* pImageMap, const HTMLOptions& rOptions); |
57 | | bool ParseMapOptions(ImageMap * pImageMap) |
58 | 2.15k | { return ParseMapOptions(pImageMap, GetOptions()); } |
59 | | static bool ParseAreaOptions(ImageMap * pImageMap, std::u16string_view rBaseURL, |
60 | | const HTMLOptions& rOptions, |
61 | | SvMacroItemId nEventMouseOver, |
62 | | SvMacroItemId nEventMouseOut ); |
63 | | inline bool ParseAreaOptions(ImageMap * pImageMap, std::u16string_view rBaseURL, |
64 | | SvMacroItemId nEventMouseOver, |
65 | | SvMacroItemId nEventMouseOut); |
66 | | |
67 | | // <TD SDVAL="..." SDNUM="..."> |
68 | | static double GetTableDataOptionsValNum( sal_uInt32& nNumForm, |
69 | | LanguageType& eNumLang, const OUString& aValStr, |
70 | | std::u16string_view aNumStr, SvNumberFormatter& rFormatter ); |
71 | | |
72 | | protected: |
73 | | // Start a file download. This is done asynchronously or synchronously. |
74 | | // In the synchronous case, the parser is in the working state after |
75 | | // it has been called. The read file can then be picked up directly with |
76 | | // FinishFileDownload. In the asynchronous case, the parser is in the |
77 | | // pending state after it hs been called. The parser then has to leave |
78 | | // over the Continue (without Reschedule!). If the file is loaded, |
79 | | // a Continue is called with passed on token. The file can then be picked |
80 | | // up by FinishFileDownload. To cancel the download should a shell be |
81 | | // left. It can only exist a single download at the same time, For every |
82 | | // started download FinishFileDownload must be called. |
83 | | void StartFileDownload(const OUString& rURL); |
84 | | |
85 | | // End of an asynchronous file download. Returns TRUE if the download |
86 | | // was successful. The read file is then passed into String. |
87 | | bool FinishFileDownload( OUString& rStr ); |
88 | | |
89 | | // Returns TRUE if a file was downloaded and if FileDownloadFinished |
90 | | // has not yet been called |
91 | 0 | bool ShouldFinishFileDownload() const { return pDLMedium != nullptr; } |
92 | | |
93 | 36.5k | SfxMedium *GetMedium() { return pMedium; } |
94 | 0 | const SfxMedium *GetMedium() const { return pMedium; } |
95 | | |
96 | | // Default (without iterator) is JavaScript |
97 | | ScriptType GetScriptType( SvKeyValueIterator* ) const; |
98 | | const OUString& GetScriptTypeString( SvKeyValueIterator* ) const; |
99 | | }; |
100 | | |
101 | | inline bool SfxHTMLParser::ParseAreaOptions(ImageMap * pImageMap, std::u16string_view rBaseURL, |
102 | | SvMacroItemId nEventMouseOver, |
103 | | SvMacroItemId nEventMouseOut) |
104 | 2.66k | { |
105 | 2.66k | return ParseAreaOptions( pImageMap, rBaseURL, GetOptions(), |
106 | 2.66k | nEventMouseOver, nEventMouseOut ); |
107 | 2.66k | } |
108 | | |
109 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |