LibreOffice Module sfx2 (master) 1
sfxhtml.hxx
Go to the documentation of this file.
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#ifndef INCLUDED_SFX2_SFXHTML_HXX
21#define INCLUDED_SFX2_SFXHTML_HXX
22
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>
29#include <memory>
30
31
32class ImageMap;
33class SfxMedium;
35
37{
38 OUString aScriptType;
39
41 std::unique_ptr<SfxMedium> pDLMedium; // Medium for Download Files
42
44
45 SAL_DLLPRIVATE void GetScriptType_Impl( SvKeyValueIterator* );
46
47protected:
48
49 SfxHTMLParser( SvStream& rStream, bool bNewDoc, SfxMedium *pMedium );
50
51 virtual ~SfxHTMLParser() override;
52
53public:
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);
67
68 // <TD SDVAL="..." SDNUM="...">
69 static double GetTableDataOptionsValNum( sal_uInt32& nNumForm,
70 LanguageType& eNumLang, const OUString& aValStr,
71 std::u16string_view aNumStr, SvNumberFormatter& rFormatter );
72
73protected:
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);
85
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 );
89
90 // Returns TRUE if a file was downloaded and if FileDownloadFinished
91 // has not yet been called
92 bool ShouldFinishFileDownload() const { return pDLMedium != nullptr; }
93
94 SfxMedium *GetMedium() { return pMedium; }
95 const SfxMedium *GetMedium() const { return pMedium; }
96
97 // Default (without iterator) is JavaScript
98 ScriptType GetScriptType( SvKeyValueIterator* ) const;
99 const OUString& GetScriptTypeString( SvKeyValueIterator* ) const;
100};
101
102inline bool SfxHTMLParser::ParseAreaOptions(ImageMap * pImageMap, std::u16string_view rBaseURL,
103 SvMacroItemId nEventMouseOver,
104 SvMacroItemId nEventMouseOut)
105{
106 return ParseAreaOptions( pImageMap, rBaseURL, GetOptions(),
107 nEventMouseOver, nEventMouseOut );
108}
109
110
111#endif
112
113/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const HTMLOptions & GetOptions(HtmlOptionId const *pNoConvertToken=nullptr)
SfxMedium * pMedium
Definition: sfxhtml.hxx:40
static bool ParseAreaOptions(ImageMap *pImageMap, std::u16string_view rBaseURL, const HTMLOptions &rOptions, SvMacroItemId nEventMouseOver, SvMacroItemId nEventMouseOut)
Definition: sfxhtml.cxx:102
std::unique_ptr< SfxMedium > pDLMedium
Definition: sfxhtml.hxx:41
SfxMedium * GetMedium()
Definition: sfxhtml.hxx:94
bool ShouldFinishFileDownload() const
Definition: sfxhtml.hxx:92
const SfxMedium * GetMedium() const
Definition: sfxhtml.hxx:95
bool ParseMapOptions(ImageMap *pImageMap)
Definition: sfxhtml.hxx:58
OUString aScriptType
Definition: sfxhtml.hxx:38
ScriptType eScriptType
Definition: sfxhtml.hxx:43
#define SFX2_DLLPUBLIC
Definition: dllapi.h:29
SvMacroItemId
these values get stored in streams in a 16-bit value
Definition: event.hxx:41
ScriptType
::std::vector< HTMLOption > HTMLOptions