1*353d8f4dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*353d8f4dSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*353d8f4dSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*353d8f4dSAndrew Rist * distributed with this work for additional information
6*353d8f4dSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*353d8f4dSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*353d8f4dSAndrew Rist * "License"); you may not use this file except in compliance
9*353d8f4dSAndrew Rist * with the License. You may obtain a copy of the License at
10*353d8f4dSAndrew Rist *
11*353d8f4dSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*353d8f4dSAndrew Rist *
13*353d8f4dSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*353d8f4dSAndrew Rist * software distributed under the License is distributed on an
15*353d8f4dSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*353d8f4dSAndrew Rist * KIND, either express or implied. See the License for the
17*353d8f4dSAndrew Rist * specific language governing permissions and limitations
18*353d8f4dSAndrew Rist * under the License.
19*353d8f4dSAndrew Rist *
20*353d8f4dSAndrew Rist *************************************************************/
21*353d8f4dSAndrew Rist
22*353d8f4dSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir #ifndef _SFXHTML_HXX
25cdf0e10cSrcweir #define _SFXHTML_HXX
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include "sal/config.h"
28cdf0e10cSrcweir #include "sfx2/dllapi.h"
29cdf0e10cSrcweir #include "sal/types.h"
30cdf0e10cSrcweir #include <i18npool/lang.h>
31cdf0e10cSrcweir #include <svtools/parhtml.hxx>
32cdf0e10cSrcweir #include <svl/macitem.hxx>
33cdf0e10cSrcweir
34cdf0e10cSrcweir
35cdf0e10cSrcweir class ImageMap;
36cdf0e10cSrcweir class SfxMedium;
37cdf0e10cSrcweir class SfxObjectShell;
38cdf0e10cSrcweir
39cdf0e10cSrcweir class SFX2_DLLPUBLIC SfxHTMLParser : public HTMLParser
40cdf0e10cSrcweir {
41cdf0e10cSrcweir DECL_DLLPRIVATE_STATIC_LINK( SfxHTMLParser, FileDownloadDone, void* );
42cdf0e10cSrcweir
43cdf0e10cSrcweir String aScriptType;
44cdf0e10cSrcweir
45cdf0e10cSrcweir SfxMedium* pMedium;
46cdf0e10cSrcweir SfxMedium *pDLMedium; // Medium fuer Download von Files
47cdf0e10cSrcweir
48cdf0e10cSrcweir sal_uInt16 nMetaTags; // Anzahl der bisher gelesenen Meta-Tags
49cdf0e10cSrcweir ScriptType eScriptType;
50cdf0e10cSrcweir
51cdf0e10cSrcweir SAL_DLLPRIVATE void GetScriptType_Impl( SvKeyValueIterator* );
52cdf0e10cSrcweir
53cdf0e10cSrcweir protected:
54cdf0e10cSrcweir
55cdf0e10cSrcweir SfxHTMLParser( SvStream& rStream, sal_Bool bNewDoc=sal_True, SfxMedium *pMedium=0 );
56cdf0e10cSrcweir
57cdf0e10cSrcweir virtual ~SfxHTMLParser();
58cdf0e10cSrcweir
59cdf0e10cSrcweir public:
60cdf0e10cSrcweir // Lesen der Optionen einer Image-Map
61cdf0e10cSrcweir // <MAP>: sal_True = Image-Map hat einen Namen
62cdf0e10cSrcweir // <AREA>: sal_True = Image-Map hat jetzt einen Bereich mehr
63cdf0e10cSrcweir static sal_Bool ParseMapOptions(ImageMap * pImageMap,
64cdf0e10cSrcweir const HTMLOptions * pOptions );
ParseMapOptions(ImageMap * pImageMap)65cdf0e10cSrcweir sal_Bool ParseMapOptions(ImageMap * pImageMap)
66cdf0e10cSrcweir { return ParseMapOptions(pImageMap, GetOptions()); }
67cdf0e10cSrcweir static sal_Bool ParseAreaOptions(ImageMap * pImageMap, const String& rBaseURL,
68cdf0e10cSrcweir const HTMLOptions * pOptions,
69cdf0e10cSrcweir sal_uInt16 nEventMouseOver = 0,
70cdf0e10cSrcweir sal_uInt16 nEventMouseOut = 0 );
71cdf0e10cSrcweir inline sal_Bool ParseAreaOptions(ImageMap * pImageMap, const String& rBaseURL,
72cdf0e10cSrcweir sal_uInt16 nEventMouseOver = 0,
73cdf0e10cSrcweir sal_uInt16 nEventMouseOut = 0);
74cdf0e10cSrcweir
75cdf0e10cSrcweir // <TD SDVAL="..." SDNUM="...">
76cdf0e10cSrcweir static double GetTableDataOptionsValNum( sal_uInt32& nNumForm,
77cdf0e10cSrcweir LanguageType& eNumLang, const String& aValStr,
78cdf0e10cSrcweir const String& aNumStr, SvNumberFormatter& rFormatter );
79cdf0e10cSrcweir
80cdf0e10cSrcweir protected:
81cdf0e10cSrcweir
82cdf0e10cSrcweir // Start eines File-Downloads. Dieser erfolgt synchron oder asynchron.
83cdf0e10cSrcweir // Im synchronen Fall befindet sich der Parser nach dem Aufruf im
84cdf0e10cSrcweir // Working-Zustand. Die gelesene Datei kann dann direkt mit
85cdf0e10cSrcweir // FinishFileDownload abgeholt werden.
86cdf0e10cSrcweir // Im asynchronen Fall befindet sich der Parser nach dem Aufruf im
87cdf0e10cSrcweir // Pending-Zustand. Der Parser muss dann ueber das Continue verlassen
88cdf0e10cSrcweir // werden (ohne Reschedule!). Wenn die Datei geladen ist, wird
89cdf0e10cSrcweir // ein Continue mit dem uebergebenen Token aufgerufen. Die Datei kann
90cdf0e10cSrcweir // dann wiederum mit FinishFileDownload abgeholt werden.
91cdf0e10cSrcweir // Zum Abbrechen des Dwonloads sollte eine Shell uebergeben werden.
92cdf0e10cSrcweir // Es kann nur ein einziger Download gleichzeitig existieren. Fuer jeden
93cdf0e10cSrcweir // gestarteten Download muss FinshFileDownload aufgerufen werden.
94cdf0e10cSrcweir void StartFileDownload( const String& rURL, int nToken,
95cdf0e10cSrcweir SfxObjectShell *pSh=0 );
96cdf0e10cSrcweir
97cdf0e10cSrcweir // Ermittelnd des MIME-Types eines zuvor downloadeten Files. Kann nur
98cdf0e10cSrcweir // unmittelbar vor FinishFileDownload aufgerufen werden, nie aber
99cdf0e10cSrcweir // danach.
100cdf0e10cSrcweir
101cdf0e10cSrcweir sal_Bool GetFileDownloadMIME( String& rMime );
102cdf0e10cSrcweir
103cdf0e10cSrcweir // Beenden eines asynchronen File-Downloads. Gibt sal_True zurueck, wenn
104cdf0e10cSrcweir // der Download geklappt hat. Das gelesene File befindet sich dann in
105cdf0e10cSrcweir // dem uebergeben String.
106cdf0e10cSrcweir sal_Bool FinishFileDownload( String& rStr );
107cdf0e10cSrcweir
108cdf0e10cSrcweir // Gibt sal_True zurueck, wenn ein File downloaded wurde und
109cdf0e10cSrcweir // FileDownloadFinished noch nicht gerufen wurde.
ShouldFinishFileDownload() const110cdf0e10cSrcweir sal_Bool ShouldFinishFileDownload() const { return pDLMedium != 0; }
111cdf0e10cSrcweir
GetMedium()112cdf0e10cSrcweir SfxMedium *GetMedium() { return pMedium; }
GetMedium() const113cdf0e10cSrcweir const SfxMedium *GetMedium() const { return pMedium; }
114cdf0e10cSrcweir
115cdf0e10cSrcweir // Default (auch ohne Iterator) ist JavaScript
116cdf0e10cSrcweir ScriptType GetScriptType( SvKeyValueIterator* ) const;
117cdf0e10cSrcweir const String& GetScriptTypeString( SvKeyValueIterator* ) const;
118cdf0e10cSrcweir };
119cdf0e10cSrcweir
ParseAreaOptions(ImageMap * pImageMap,const String & rBaseURL,sal_uInt16 nEventMouseOver,sal_uInt16 nEventMouseOut)120cdf0e10cSrcweir inline sal_Bool SfxHTMLParser::ParseAreaOptions(ImageMap * pImageMap, const String& rBaseURL,
121cdf0e10cSrcweir sal_uInt16 nEventMouseOver,
122cdf0e10cSrcweir sal_uInt16 nEventMouseOut)
123cdf0e10cSrcweir {
124cdf0e10cSrcweir return ParseAreaOptions( pImageMap, rBaseURL, GetOptions(),
125cdf0e10cSrcweir nEventMouseOver, nEventMouseOut );
126cdf0e10cSrcweir }
127cdf0e10cSrcweir
128cdf0e10cSrcweir
129cdf0e10cSrcweir #endif
130