1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SFX2_SFXHTML_HXX
21 #define INCLUDED_SFX2_SFXHTML_HXX
23 #include <sal/config.h>
24 #include <sfx2/dllapi.h>
25 #include <sal/types.h>
26 #include <i18nlangtag/lang.h>
27 #include <svtools/parhtml.hxx>
28 #include <svl/macitem.hxx>
34 class SvNumberFormatter
;
36 class SFX2_DLLPUBLIC SfxHTMLParser
: public HTMLParser
41 std::unique_ptr
<SfxMedium
> pDLMedium
; // Medium for Download Files
43 ScriptType eScriptType
;
45 SAL_DLLPRIVATE
void GetScriptType_Impl( SvKeyValueIterator
* );
49 SfxHTMLParser( SvStream
& rStream
, bool bNewDoc
, SfxMedium
*pMedium
);
51 virtual ~SfxHTMLParser() override
;
54 // Read the options of an image map
55 // <MAP>: sal_True = Image-Map has a name
56 // <AREA>: sal_True = Image-Map has now one vcl::Region more
57 static bool ParseMapOptions(ImageMap
* pImageMap
, const HTMLOptions
& rOptions
);
58 bool ParseMapOptions(ImageMap
* pImageMap
)
59 { return ParseMapOptions(pImageMap
, GetOptions()); }
60 static bool ParseAreaOptions(ImageMap
* pImageMap
, std::u16string_view rBaseURL
,
61 const HTMLOptions
& rOptions
,
62 SvMacroItemId nEventMouseOver
,
63 SvMacroItemId nEventMouseOut
);
64 inline bool ParseAreaOptions(ImageMap
* pImageMap
, std::u16string_view rBaseURL
,
65 SvMacroItemId nEventMouseOver
,
66 SvMacroItemId nEventMouseOut
);
68 // <TD SDVAL="..." SDNUM="...">
69 static double GetTableDataOptionsValNum( sal_uInt32
& nNumForm
,
70 LanguageType
& eNumLang
, const OUString
& aValStr
,
71 std::u16string_view aNumStr
, SvNumberFormatter
& rFormatter
);
74 // Start a file download. This is done asynchronously or synchronously.
75 // In the synchronous case, the parser is in the working state after
76 // it has been called. The read file can then be picked up directly with
77 // FinishFileDownload. In the asynchronous case, the parser is in the
78 // pending state after it hs been called. The parser then has to leave
79 // over the Continue (without Reschedule!). If the file is loaded,
80 // a Continue is called with passed on token. The file can then be picked
81 // up by FinishFileDownload. To cancel the download should a shell be
82 // left. It can only exist a single download at the same time, For every
83 // started download FinishFileDownload must be called.
84 void StartFileDownload(const OUString
& rURL
);
86 // End of an asynchronous file download. Returns TRUE if the download
87 // was successful. The read file is then passed into String.
88 bool FinishFileDownload( OUString
& rStr
);
90 // Returns TRUE if a file was downloaded and if FileDownloadFinished
91 // has not yet been called
92 bool ShouldFinishFileDownload() const { return pDLMedium
!= nullptr; }
94 SfxMedium
*GetMedium() { return pMedium
; }
95 const SfxMedium
*GetMedium() const { return pMedium
; }
97 // Default (without iterator) is JavaScript
98 ScriptType
GetScriptType( SvKeyValueIterator
* ) const;
99 const OUString
& GetScriptTypeString( SvKeyValueIterator
* ) const;
102 inline bool SfxHTMLParser::ParseAreaOptions(ImageMap
* pImageMap
, std::u16string_view rBaseURL
,
103 SvMacroItemId nEventMouseOver
,
104 SvMacroItemId nEventMouseOut
)
106 return ParseAreaOptions( pImageMap
, rBaseURL
, GetOptions(),
107 nEventMouseOver
, nEventMouseOut
);
113 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */