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