Line data Source code
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 : #ifndef _SWHTML_HXX
20 : #define _SWHTML_HXX
21 :
22 : #include <sfx2/sfxhtml.hxx>
23 : #include <svl/macitem.hxx>
24 : #include <editeng/svxenum.hxx>
25 : #include <fmtornt.hxx>
26 : #include <com/sun/star/drawing/XShape.hpp>
27 : #include <com/sun/star/form/XFormComponent.hpp>
28 : #include <pam.hxx>
29 :
30 : #include "calbck.hxx"
31 : #include "htmlvsh.hxx"
32 :
33 : class SfxMedium;
34 : class SfxViewFrame;
35 : class SdrObject;
36 : class SvxMacroTableDtor;
37 : class SwDoc;
38 : class SwPaM;
39 : class ViewShell;
40 : class SwStartNode;
41 : class SwFmtColl;
42 : class SwField;
43 : class SwHTMLForm_Impl;
44 : class SwApplet_Impl;
45 : struct SwHTMLFootEndNote_Impl;
46 : class HTMLTableCnts;
47 : struct SwPendingStack;
48 : class SvxCSS1PropertyInfo;
49 :
50 : #define HTML_PARSPACE (MM50)
51 : #define HTML_CJK_PARSPACE (MM50/2)
52 : #define HTML_CTL_PARSPACE (MM50/2)
53 :
54 : #define HTML_DFLT_IMG_WIDTH (MM50*4)
55 : #define HTML_DFLT_IMG_HEIGHT (MM50*2)
56 :
57 : // ein par Sachen, die man oefter mal braucht
58 : extern HTMLOptionEnum aHTMLPAlignTable[];
59 : extern HTMLOptionEnum aHTMLImgHAlignTable[];
60 : extern HTMLOptionEnum aHTMLImgVAlignTable[];
61 :
62 :
63 : // der Attribut Stack:
64 :
65 : class _HTMLAttr;
66 : typedef std::deque<_HTMLAttr *> _HTMLAttrs;
67 :
68 : class _HTMLAttr
69 : {
70 : friend class SwHTMLParser;
71 : friend class _CellSaveStruct;
72 :
73 : SwNodeIndex nSttPara, nEndPara;
74 : xub_StrLen nSttCntnt, nEndCntnt;
75 : sal_Bool bInsAtStart : 1;
76 : sal_Bool bLikePara : 1; // Attribut ueber dem gesamten Absatz setzen
77 : sal_Bool bValid : 1; // ist das Attribut gueltig?
78 :
79 : SfxPoolItem* pItem;
80 : sal_uInt16 nCount; // Anzahl noch zu schliessender Attrs mit einem Wert
81 : _HTMLAttr *pNext; // noch zu schliessene Attrs mit unterschiedl. Werten
82 : _HTMLAttr *pPrev; // bereits geschlossene aber noch nicht gesetze Attrs
83 : _HTMLAttr **ppHead; // der Listenkopf
84 :
85 : _HTMLAttr( const SwPosition& rPos, const SfxPoolItem& rItem,
86 : _HTMLAttr **pHd=0 );
87 :
88 : _HTMLAttr( const _HTMLAttr &rAttr, const SwNodeIndex &rEndPara,
89 : xub_StrLen nEndCnt, _HTMLAttr **pHd );
90 :
91 : public:
92 :
93 : ~_HTMLAttr();
94 :
95 : _HTMLAttr *Clone( const SwNodeIndex& rEndPara, xub_StrLen nEndCnt ) const;
96 : void Reset( const SwNodeIndex& rSttPara, xub_StrLen nSttCnt,
97 : _HTMLAttr **pHd );
98 : inline void SetStart( const SwPosition& rPos );
99 :
100 0 : sal_uInt32 GetSttParaIdx() const { return nSttPara.GetIndex(); }
101 0 : sal_uInt32 GetEndParaIdx() const { return nEndPara.GetIndex(); }
102 :
103 0 : const SwNodeIndex& GetSttPara() const { return nSttPara; }
104 0 : const SwNodeIndex& GetEndPara() const { return nEndPara; }
105 :
106 0 : xub_StrLen GetSttCnt() const { return nSttCntnt; }
107 0 : xub_StrLen GetEndCnt() const { return nEndCntnt; }
108 :
109 0 : sal_Bool IsLikePara() const { return bLikePara; }
110 0 : void SetLikePara( sal_Bool bPara=sal_True ) { bLikePara = bPara; }
111 :
112 0 : SfxPoolItem& GetItem() { return *pItem; }
113 0 : const SfxPoolItem& GetItem() const { return *pItem; }
114 :
115 0 : _HTMLAttr *GetNext() const { return pNext; }
116 0 : void InsertNext( _HTMLAttr *pNxt ) { pNext = pNxt; }
117 :
118 0 : _HTMLAttr *GetPrev() const { return pPrev; }
119 : void InsertPrev( _HTMLAttr *pPrv );
120 0 : void ClearPrev() { pPrev = 0; }
121 :
122 0 : void SetHead( _HTMLAttr **ppHd ) { ppHead = ppHd; }
123 :
124 : // Beim Setzen von Attributen aus Vorlagen kann es passieren,
125 : // dass Attribute doch nicht mehr gesetzt werden sollen. Die zu loeschen
126 : // waere sehr aufwendig, da man nicht so genau weiss, wo sie eingekettet
127 : // sind. Sie werden deshalb einfach invalidiert und erst beim naechsten
128 : // _SetAttr() geloescht.
129 0 : void Invalidate() { bValid = sal_False; }
130 : sal_Bool IsValid() const { return bValid; }
131 : };
132 :
133 : // Tabelle der Attribute: Hier ist die Reihenfolge wichtig: Die Attribute
134 : // vorne in der Tabelle werden in EndAllAttrs auch zuerst gesetzt.
135 : struct _HTMLAttrTable
136 : {
137 : _HTMLAttr
138 : *pKeep, // ::com::sun::star::frame::Frame-Attribure
139 : *pBox,
140 : *pBrush,
141 : *pBreak,
142 : *pPageDesc,
143 :
144 : *pLRSpace, // Absatz-Attribute
145 : *pULSpace,
146 : *pLineSpacing,
147 : *pAdjust,
148 : *pDropCap,
149 : *pSplit,
150 : *pWidows,
151 : *pOrphans,
152 : *pDirection,
153 :
154 : *pCharFmts, // Text-Attribute
155 : *pINetFmt,
156 :
157 : *pBold, // Zeichen-Attribute
158 : *pBoldCJK,
159 : *pBoldCTL,
160 : *pItalic,
161 : *pItalicCJK,
162 : *pItalicCTL,
163 : *pStrike,
164 : *pUnderline,
165 : *pBlink,
166 : *pFont,
167 : *pFontCJK,
168 : *pFontCTL,
169 : *pFontHeight,
170 : *pFontHeightCJK,
171 : *pFontHeightCTL,
172 : *pFontColor,
173 : *pEscapement,
174 : *pCaseMap,
175 : *pKerning, // (nur fuer SPACER)
176 : *pCharBrush, // Zeichen-Hintergrund
177 : *pLanguage,
178 : *pLanguageCJK,
179 : *pLanguageCTL
180 : ;
181 : };
182 :
183 : class _HTMLAttrContext_SaveDoc;
184 :
185 : enum SwHTMLAppendMode {
186 : AM_NORMAL, // keine Absatz-Abstand-Behandlung
187 : AM_NOSPACE, // Abstand hart auf 0cm setzen
188 : AM_SPACE, // Abstand hart auf 0.5cm setzen
189 : AM_SOFTNOSPACE, // Abstand nicht setzen aber 0cm merken
190 : AM_NONE // gar kein Append
191 : };
192 :
193 : class _HTMLAttrContext
194 : {
195 : _HTMLAttrs aAttrs; // die in dem Kontext gestarteten Attribute
196 :
197 : String aClass; // die Klasse des Kontexts
198 :
199 : _HTMLAttrContext_SaveDoc *pSaveDocContext;
200 : SfxItemSet *pFrmItemSet;
201 :
202 : sal_uInt16 nToken; // das Token, zu dem der Kontext gehoehrt
203 :
204 : sal_uInt16 nTxtFmtColl; // eine in dem Kontext begonnene Vorlage oder 0
205 :
206 : sal_uInt16 nLeftMargin; // ein veraenderter linker Rand
207 : sal_uInt16 nRightMargin; // ein veraenderter rechter Rand
208 : sal_uInt16 nFirstLineIndent; // ein veraenderter Erstzeilen-Einzug
209 :
210 : sal_uInt16 nUpperSpace;
211 : sal_uInt16 nLowerSpace;
212 :
213 : SwHTMLAppendMode eAppend;
214 :
215 : sal_Bool bLRSpaceChanged : 1;// linker/rechtr Rand, Einzug veraendert?
216 : sal_Bool bULSpaceChanged : 1;// oberer/unterer Rand veraendert?
217 : sal_Bool bDfltTxtFmtColl : 1;// nTxtFmtColl ist nur ein default
218 : sal_Bool bSpansSection : 1; // Der Kontext spannt eine SwSection auf
219 : sal_Bool bPopStack : 1; // Oberhalb liegende Stack-Elemente entf.
220 : sal_Bool bFinishPREListingXMP : 1;
221 : sal_Bool bRestartPRE : 1;
222 : sal_Bool bRestartXMP : 1;
223 : sal_Bool bRestartListing : 1;
224 :
225 : public:
226 : void ClearSaveDocContext();
227 :
228 0 : _HTMLAttrContext( sal_uInt16 nTokn, sal_uInt16 nPoolId, const String& rClass,
229 : sal_Bool bDfltColl=sal_False ) :
230 : aClass( rClass ),
231 : pSaveDocContext( 0 ),
232 : pFrmItemSet( 0 ),
233 : nToken( nTokn ),
234 : nTxtFmtColl( nPoolId ),
235 : nLeftMargin( 0 ),
236 : nRightMargin( 0 ),
237 : nFirstLineIndent( 0 ),
238 : nUpperSpace( 0 ),
239 : nLowerSpace( 0 ),
240 : eAppend( AM_NONE ),
241 : bLRSpaceChanged( sal_False ),
242 : bULSpaceChanged( sal_False ),
243 : bDfltTxtFmtColl( bDfltColl ),
244 : bSpansSection( sal_False ),
245 : bPopStack( sal_False ),
246 : bFinishPREListingXMP( sal_False ),
247 : bRestartPRE( sal_False ),
248 : bRestartXMP( sal_False ),
249 0 : bRestartListing( sal_False )
250 0 : {}
251 :
252 0 : _HTMLAttrContext( sal_uInt16 nTokn ) :
253 : pSaveDocContext( 0 ),
254 : pFrmItemSet( 0 ),
255 : nToken( nTokn ),
256 : nTxtFmtColl( 0 ),
257 : nLeftMargin( 0 ),
258 : nRightMargin( 0 ),
259 : nFirstLineIndent( 0 ),
260 : nUpperSpace( 0 ),
261 : nLowerSpace( 0 ),
262 : eAppend( AM_NONE ),
263 : bLRSpaceChanged( sal_False ),
264 : bULSpaceChanged( sal_False ),
265 : bDfltTxtFmtColl( sal_False ),
266 : bSpansSection( sal_False ),
267 : bPopStack( sal_False ),
268 : bFinishPREListingXMP( sal_False ),
269 : bRestartPRE( sal_False ),
270 : bRestartXMP( sal_False ),
271 0 : bRestartListing( sal_False )
272 0 : {}
273 :
274 0 : ~_HTMLAttrContext() { ClearSaveDocContext(); delete pFrmItemSet; }
275 :
276 0 : sal_uInt16 GetToken() const { return nToken; }
277 :
278 0 : sal_uInt16 GetTxtFmtColl() const { return bDfltTxtFmtColl ? 0 : nTxtFmtColl; }
279 0 : sal_uInt16 GetDfltTxtFmtColl() const { return bDfltTxtFmtColl ? nTxtFmtColl : 0; }
280 :
281 0 : const String& GetClass() const { return aClass; }
282 :
283 : inline void SetMargins( sal_uInt16 nLeft, sal_uInt16 nRight, short nIndent );
284 :
285 0 : inline sal_Bool IsLRSpaceChanged() const { return bLRSpaceChanged; }
286 : inline void GetMargins( sal_uInt16& nLeft, sal_uInt16& nRight,
287 : short &nIndent ) const;
288 :
289 : inline void SetULSpace( sal_uInt16 nUpper, sal_uInt16 nLower );
290 0 : inline sal_Bool IsULSpaceChanged() const { return bULSpaceChanged; }
291 : inline void GetULSpace( sal_uInt16& rUpper, sal_uInt16& rLower ) const;
292 :
293 0 : sal_Bool HasAttrs() const { return !aAttrs.empty(); }
294 : const _HTMLAttrs& GetAttrs() const { return aAttrs; }
295 0 : _HTMLAttrs& GetAttrs() { return aAttrs; }
296 :
297 0 : void SetSpansSection( sal_Bool bSet ) { bSpansSection = bSet; }
298 0 : sal_Bool GetSpansSection() const { return bSpansSection; }
299 :
300 0 : void SetPopStack( sal_Bool bSet ) { bPopStack = bSet; }
301 0 : sal_Bool GetPopStack() const { return bPopStack; }
302 :
303 0 : sal_Bool HasSaveDocContext() const { return pSaveDocContext!=0; }
304 : _HTMLAttrContext_SaveDoc *GetSaveDocContext( sal_Bool bCreate=sal_False );
305 :
306 0 : const SfxItemSet *GetFrmItemSet() const { return pFrmItemSet; }
307 : SfxItemSet *GetFrmItemSet( SwDoc *pCreateDoc );
308 :
309 0 : void SetFinishPREListingXMP( sal_Bool bSet ) { bFinishPREListingXMP = bSet; }
310 0 : sal_Bool IsFinishPREListingXMP() const { return bFinishPREListingXMP; }
311 :
312 0 : void SetRestartPRE( sal_Bool bSet ) { bRestartPRE = bSet; }
313 0 : sal_Bool IsRestartPRE() const { return bRestartPRE; }
314 :
315 0 : void SetRestartXMP( sal_Bool bSet ) { bRestartXMP = bSet; }
316 0 : sal_Bool IsRestartXMP() const { return bRestartXMP; }
317 :
318 0 : void SetRestartListing( sal_Bool bSet ) { bRestartListing = bSet; }
319 0 : sal_Bool IsRestartListing() const { return bRestartListing; }
320 :
321 0 : void SetAppendMode( SwHTMLAppendMode eMode=AM_NORMAL ) { eAppend = eMode; }
322 0 : SwHTMLAppendMode GetAppendMode() const { return eAppend; }
323 : };
324 :
325 : typedef std::vector<_HTMLAttrContext *> _HTMLAttrContexts;
326 :
327 : class HTMLTable;
328 : class SwCSS1Parser;
329 : class SwHTMLNumRuleInfo;
330 :
331 : typedef boost::ptr_vector<ImageMap> ImageMaps;
332 : typedef std::vector<SwFrmFmt *> SwHTMLFrmFmts;
333 :
334 : #define HTML_CNTXT_PROTECT_STACK 0x0001
335 : #define HTML_CNTXT_STRIP_PARA 0x0002
336 : #define HTML_CNTXT_KEEP_NUMRULE 0x0004
337 : #define HTML_CNTXT_HEADER_DIST 0x0008
338 : #define HTML_CNTXT_FOOTER_DIST 0x0010
339 : #define HTML_CNTXT_KEEP_ATTRS 0x0020
340 :
341 : #define CONTEXT_FLAGS_ABSPOS \
342 : (HTML_CNTXT_PROTECT_STACK | \
343 : HTML_CNTXT_STRIP_PARA)
344 :
345 : #define HTML_FF_BOX 0x0001
346 : #define HTML_FF_BACKGROUND 0x0002
347 : #define HTML_FF_PADDING 0x0004
348 : #define HTML_FF_DIRECTION 0x0008
349 :
350 : class SwHTMLParser : public SfxHTMLParser, public SwClient
351 : {
352 : friend class _SectionSaveStruct;
353 : friend class _CellSaveStruct;
354 : friend class _CaptionSaveStruct;
355 :
356 : String aPathToFile;
357 : String sBaseURL;
358 : String sSaveBaseURL;
359 : String aBasicLib;
360 : String aBasicModule;
361 : String aScriptSource; // Inhalt des aktuellen Script-Blocks
362 : String aScriptType; // Type des gelesenen Scripts (StarBasic/VB/JAVA)
363 : String aScriptURL; // URL eines Scripts
364 : String aStyleSource; // Inhalt des aktuellen Style-Sheets
365 : String aContents; // Text des akteullen Marquee, Feldes etc.
366 : String sTitle;
367 : String aUnknownToken; // ein gestartetes unbekanntes Token
368 : String aBulletGrfs[MAXLEVEL];
369 : String sJmpMark;
370 :
371 : std::vector<sal_uInt16> aBaseFontStack; // Stack fuer <BASEFONT>
372 : // Bit 0-2: Fontgroesse (1-7)
373 : std::vector<sal_uInt16> aFontStack; // Stack fuer <FONT>, <BIG>, <SMALL>
374 : // Bit 0-2: Fontgroesse (1-7)
375 : // Bit 15: Fontfarbe wurde gesetzt
376 :
377 : _HTMLAttrs aSetAttrTab;// "geschlossene", noch nicht gesetzte Attr.
378 : _HTMLAttrs aParaAttrs; // vorlauefige Absatz-Attribute
379 : _HTMLAttrTable aAttrTab; // "offene" Attribute
380 : _HTMLAttrContexts aContexts;// der aktuelle Attribut/Token-Kontext
381 : SwHTMLFrmFmts aMoveFlyFrms;// Fly-Frames, the anchor is moved
382 : std::deque<xub_StrLen> aMoveFlyCnts;// and the Content-Positions
383 :
384 : SwApplet_Impl *pAppletImpl; // das aktuelle Applet
385 :
386 : SwCSS1Parser *pCSS1Parser; // der Style-Sheet-Parser
387 : SwHTMLNumRuleInfo *pNumRuleInfo;
388 : SwPendingStack *pPendStack;
389 :
390 : SwDoc *pDoc;
391 : SwPaM *pPam; // SwPosition duerfte doch reichen, oder ??
392 : ViewShell *pActionViewShell; // ViewShell, an der das StartAction
393 : // gerufen wurde.
394 : SwNodeIndex *pSttNdIdx;
395 :
396 : HTMLTable *pTable; // die aktuelle "auesserste" Tabelle
397 : SwHTMLForm_Impl *pFormImpl;// die aktuelle Form
398 : SdrObject *pMarquee; // aktuelles Marquee
399 : SwField *pField; // aktuelles Feld
400 : ImageMap *pImageMap; // aktuelle Image-Map
401 : ImageMaps *pImageMaps;// alle gelesenen Image-Maps
402 : SwHTMLFootEndNote_Impl *pFootEndNoteImpl;
403 :
404 : Size aHTMLPageSize; // die Seitengroesse der HTML-Vorlage
405 :
406 : sal_uInt32 aFontHeights[7]; // die Font-Hoehen 1-7
407 : sal_uInt32 nScriptStartLineNr; // Zeilennummer eines Script-Blocks
408 : sal_uLong nEventId;
409 :
410 : sal_uInt16 nBaseFontStMin; //
411 : sal_uInt16 nFontStMin; //
412 : sal_uInt16 nDefListDeep; //
413 : sal_uInt16 nFontStHeadStart; // Elemente im Font-Stack bei <Hn>
414 : sal_uInt16 nSBModuleCnt; // Zaehler fuer Basic-Module
415 : sal_uInt16 nMissingImgMaps; // Wie viele Image-Maps fehlen noch?
416 : size_t nParaCnt;
417 : sal_uInt16 nContextStMin; // Untergrenze fuer PopContext
418 : sal_uInt16 nContextStAttrMin; // Untergrenze fuer Attributierung
419 : sal_uInt16 nSelectEntryCnt; // Anzahl der Eintraege der akt. Listbox
420 : sal_uInt16 nOpenParaToken; // ein geoeffnetes Absatz-Element
421 :
422 : enum JumpToMarks { JUMPTO_NONE, JUMPTO_MARK, JUMPTO_TABLE, JUMPTO_FRAME,
423 : JUMPTO_REGION, JUMPTO_GRAPHIC } eJumpTo;
424 :
425 : #ifdef DBG_UTIL
426 : sal_uInt16 m_nContinue; // depth of Continue calls
427 : #endif
428 :
429 : SvxAdjust eParaAdjust; // Ausrichtung des aktuellen Absatz
430 : HTMLScriptLanguage eScriptLang; // die aktuelle Script-Language
431 :
432 : sal_Bool bOldIsHTMLMode : 1; // War's mal ein HTML-Dokument?
433 :
434 : sal_Bool bDocInitalized : 1; // Dokument bzw. Shell wurden initialisiert
435 : // Flag um doppeltes init durch Rekursion
436 : // zu verhindern.
437 : sal_Bool bViewCreated : 1; // die View wurde schon erzeugt (asynchron)
438 : sal_Bool bSetCrsr : 1; // Crsr wieder auf den Anfang setzen
439 : sal_Bool bSetModEnabled : 1;
440 :
441 : sal_Bool bInFloatingFrame : 1; // Wir sind in einen Floating ::com::sun::star::frame::Frame
442 : sal_Bool bInField : 1;
443 : sal_Bool bKeepUnknown : 1; // unbekannte/nicht unterstuetze Tokens beh.
444 : // 8
445 : sal_Bool bCallNextToken : 1; // In Tabellen: NextToken in jedem Fall rufen
446 : sal_Bool bIgnoreRawData : 1; // Inhalt eines Scripts/Styles ignorieren.
447 : sal_Bool bLBEntrySelected : 1; // Ist der aktuelle Listbox-Eintrag selekt.
448 : sal_Bool bTAIgnoreNewPara : 1; // naechstes LF in TextArea ignorieren?
449 : sal_Bool bFixMarqueeWidth : 1; // Groesse einer Laufschrift anpassen?
450 : sal_Bool bFixMarqueeHeight : 1;
451 :
452 : sal_Bool bUpperSpace : 1; // obererer Absatz-Abstand wird benoetigt
453 : sal_Bool bNoParSpace : 1;
454 : // 16
455 :
456 : sal_Bool bAnyStarBasic : 1; // gibt es ueberhaupt ein StarBasic-Modul
457 : sal_Bool bInNoEmbed : 1; // Wir sind in einem NOEMBED-Bereich
458 :
459 : sal_Bool bInTitle : 1; // Wir sind im Titel
460 :
461 : sal_Bool bChkJumpMark : 1; // springe ggfs. zu einem vorgegebenem Mark
462 : sal_Bool bUpdateDocStat : 1;
463 : sal_Bool bFixSelectWidth : 1; // Breite eines Selects neu setzen?
464 : sal_Bool bFixSelectHeight : 1; // Breite eines Selects neu setzen?
465 : sal_Bool bTextArea : 1;
466 : // 24
467 : sal_Bool bSelect : 1;
468 : sal_Bool bInFootEndNoteAnchor : 1;
469 : sal_Bool bInFootEndNoteSymbol : 1;
470 : sal_Bool bIgnoreHTMLComments : 1;
471 : sal_Bool bRemoveHidden : 1; // the filter implementation might set the hidden flag
472 :
473 : /// the names corresponding to the DOCINFO field subtypes INFO[1-4]
474 : ::rtl::OUString m_InfoNames[4];
475 :
476 : SfxViewFrame* pTempViewFrame;
477 :
478 : void DeleteFormImpl();
479 :
480 : void DocumentDetected();
481 : void Show();
482 : void ShowStatline();
483 : ViewShell *CallStartAction( ViewShell *pVSh = 0, sal_Bool bChkPtr = sal_True );
484 : ViewShell *CallEndAction( sal_Bool bChkAction = sal_False, sal_Bool bChkPtr = sal_True );
485 : ViewShell *CheckActionViewShell();
486 :
487 : DECL_LINK( AsyncCallback, void* );
488 :
489 : // Attribute am Dok setzen
490 : void _SetAttr( sal_Bool bChkEnd, sal_Bool bBeforeTable, _HTMLAttrs *pPostIts );
491 0 : inline void SetAttr( sal_Bool bChkEnd = sal_True, sal_Bool bBeforeTable = sal_False,
492 : _HTMLAttrs *pPostIts = 0 )
493 : {
494 0 : if( !aSetAttrTab.empty() || !aMoveFlyFrms.empty() )
495 0 : _SetAttr( bChkEnd, bBeforeTable, pPostIts );
496 0 : }
497 :
498 : _HTMLAttr **GetAttrTabEntry( sal_uInt16 nWhich );
499 :
500 : // Einen neuen Textknoten an PaM-Position anlegen
501 : sal_Bool AppendTxtNode( SwHTMLAppendMode eMode=AM_NORMAL, sal_Bool bUpdateNum=sal_True );
502 : void AddParSpace();
503 :
504 : // Ein Attribut beginnen/beenden
505 : // ppDepAttr gibt einen Attribut-Tabellen-Eintrag an, dessen Attribute
506 : // gesetzt sein muessen, bevor das Attribut beendet werden darf
507 : void NewAttr( _HTMLAttr **ppAttr, const SfxPoolItem& rItem );
508 : void EndAttr( _HTMLAttr *pAttr, _HTMLAttr **ppDepAttr=0,
509 : sal_Bool bChkEmpty=sal_True );
510 : void DeleteAttr( _HTMLAttr* pAttr );
511 :
512 : void EndContextAttrs( _HTMLAttrContext *pContext, sal_Bool bRemove=sal_False );
513 : void SaveAttrTab( _HTMLAttrTable& rNewAttrTab );
514 : void SplitAttrTab( const SwPosition& rNewPos );
515 : void SplitAttrTab( _HTMLAttrTable& rNewAttrTab, sal_Bool bMoveEndBack = sal_True );
516 : void RestoreAttrTab( const _HTMLAttrTable& rNewAttrTab,
517 : sal_Bool bSetNewStart = sal_False );
518 : void InsertAttr( const SfxPoolItem& rItem, sal_Bool bLikePara = sal_False,
519 : sal_Bool bInsAtStart=sal_False );
520 : void InsertAttrs( _HTMLAttrs& rAttrs );
521 :
522 : sal_Bool DoPositioning( SfxItemSet &rItemSet,
523 : SvxCSS1PropertyInfo &rPropInfo,
524 : _HTMLAttrContext *pContext );
525 : sal_Bool CreateContainer( const String& rClass, SfxItemSet &rItemSet,
526 : SvxCSS1PropertyInfo &rPropInfo,
527 : _HTMLAttrContext *pContext );
528 : sal_Bool EndSection( sal_Bool bLFStripped=sal_False );
529 :
530 : void InsertAttrs( SfxItemSet &rItemSet, SvxCSS1PropertyInfo &rPropInfo,
531 : _HTMLAttrContext *pContext, sal_Bool bCharLvl=sal_False );
532 : void InsertAttr( _HTMLAttr **ppAttr, const SfxPoolItem & rItem,
533 : _HTMLAttrContext *pCntxt );
534 : void SplitPREListingXMP( _HTMLAttrContext *pCntxt );
535 : void FixHeaderFooterDistance( sal_Bool bHeader, const SwPosition *pOldPos );
536 :
537 : void EndContext( _HTMLAttrContext *pContext );
538 : void ClearContext( _HTMLAttrContext *pContext );
539 :
540 : const SwFmtColl *GetCurrFmtColl() const;
541 :
542 : SwTwips GetCurrentBrowseWidth();
543 :
544 0 : SwHTMLNumRuleInfo& GetNumInfo() { return *pNumRuleInfo; }
545 : // add parameter <bCountedInList>
546 : void SetNodeNum( sal_uInt8 nLevel, bool bCountedInList );
547 :
548 : // Verwalten von Absatz-Vorlagen
549 :
550 : // die Vorlagen auf dem Stack bzw. deren Attribute setzen
551 : void SetTxtCollAttrs( _HTMLAttrContext *pContext = 0 );
552 :
553 : void InsertParaAttrs( const SfxItemSet& rItemSet );
554 :
555 : // Verwalten des Attribut-Kontexts
556 :
557 : // aktuellen Kontext merken
558 : inline void PushContext( _HTMLAttrContext *pCntxt );
559 :
560 : // den obersten/spezifizierten Kontext holen, aber nicht ausserhalb
561 : // des Kontexts mit Token nLimit suchen. Wenn bRemove gesetzt ist,
562 : // wird er entfernt
563 : _HTMLAttrContext *PopContext( sal_uInt16 nToken=0, sal_uInt16 nLimit=0,
564 : sal_Bool bRemove=sal_True );
565 : inline const _HTMLAttrContext *GetTopContext() const;
566 :
567 : sal_Bool GetMarginsFromContext( sal_uInt16 &nLeft, sal_uInt16 &nRight, short& nIndent,
568 : sal_Bool bIgnoreCurrent=sal_False ) const;
569 : sal_Bool GetMarginsFromContextWithNumBul( sal_uInt16 &nLeft, sal_uInt16 &nRight,
570 : short& nIndent ) const;
571 : void GetULSpaceFromContext( sal_uInt16 &rUpper, sal_uInt16 &rLower ) const;
572 :
573 :
574 : void MovePageDescAttrs( SwNode *pSrcNd, sal_uLong nDestIdx, sal_Bool bFmtBreak );
575 :
576 : // Behandlung von Tags auf Absatz-Ebene
577 :
578 : // <P> und <H1> bis <H6>
579 : void NewPara();
580 : void EndPara( sal_Bool bReal = sal_False );
581 : void NewHeading( int nToken );
582 : void EndHeading();
583 :
584 : // <ADDRESS>, <BLOCKQUOTE> und <PRE>
585 : void NewTxtFmtColl( int nToken, sal_uInt16 nPoolId );
586 : void EndTxtFmtColl( int nToken );
587 :
588 : // <DIV> und <CENTER>
589 : void NewDivision( int nToken );
590 : void EndDivision( int nToken );
591 :
592 : // Fly-Frames einfuegen/verlassen
593 : void InsertFlyFrame( const SfxItemSet& rItemSet, _HTMLAttrContext *pCntxt,
594 : const String& rId, sal_uInt16 nFlags );
595 :
596 : void SaveDocContext( _HTMLAttrContext *pCntxt, sal_uInt16 nFlags,
597 : const SwPosition *pNewPos );
598 : void RestoreDocContext( _HTMLAttrContext *pCntxt );
599 :
600 : // alle durch <DIV> aufgespannten Bereiche verlassen
601 : sal_Bool EndSections( sal_Bool bLFStripped );
602 :
603 : // <MULTICOL>
604 : void NewMultiCol();
605 : void EndMultiCol();
606 :
607 : // <MARQUEE>
608 : void NewMarquee( HTMLTable *pCurTable=0 );
609 : void EndMarquee();
610 : void InsertMarqueeText();
611 :
612 : // Behandluung von Listen
613 :
614 : // Numerierungs <OL> und Aufzaehlungs-Listen <UL> mit <LI>
615 : void NewNumBulList( int nToken );
616 : void EndNumBulList( int nToken=0 );
617 : void NewNumBulListItem( int nToken );
618 : void EndNumBulListItem( int nToken=0, sal_Bool bSetColl=sal_True,
619 : sal_Bool bLastPara=sal_False );
620 :
621 : // Definitions-Listen <DL> mit <DD>, <DT>
622 : void NewDefList();
623 : void EndDefList();
624 : void NewDefListItem( int nToken );
625 : void EndDefListItem( int nToken=0, sal_Bool bSetColl=sal_True,
626 : sal_Bool bLastPara=sal_False );
627 :
628 :
629 : // Behandlung von Tags auf Zeichen-Ebene
630 :
631 : // Tags wie <B>, <I> etc behandeln, die ein bestimmtes Attribut
632 : // an und ausschalten, oder die wie SPAN nur Attribute aus Styles holen
633 : void NewStdAttr( int nToken );
634 : void NewStdAttr( int nToken,
635 : _HTMLAttr **ppAttr, const SfxPoolItem & rItem,
636 : _HTMLAttr **ppAttr2=0, const SfxPoolItem *pItem2=0,
637 : _HTMLAttr **ppAttr3=0, const SfxPoolItem *pItem3=0 );
638 : void EndTag( int nToken );
639 :
640 : // Font-Attribute behandeln
641 : void NewBasefontAttr(); // fuer <BASEFONT>
642 : void EndBasefontAttr();
643 : void NewFontAttr( int nToken ); // fuer <FONT>, <BIG> und <SMALL>
644 : void EndFontAttr( int nToken );
645 :
646 : // Tags, die durch Zeichenvorlagen realisiert werden
647 : void NewCharFmt( int nToken );
648 :
649 : // <SDFIELD>
650 : public:
651 : static sal_uInt16 GetNumType( const String& rStr, sal_uInt16 eDfltType );
652 : private:
653 : void NewField();
654 : void EndField();
655 : void InsertFieldText();
656 :
657 : // <SPACER>
658 : void InsertSpacer();
659 :
660 : // Einfuegen von Grafiken, Plugins und Applets
661 :
662 : // Image-Maps suchen und mit Grafik-Nodes verbinden
663 : ImageMap *FindImageMap( const String& rURL ) const;
664 : void ConnectImageMaps();
665 :
666 : // Verankerung eines Fly-Frames bestimmen und entsprechende Attribute
667 : // in den Attrset setzen (htmlgrin.cxx)
668 : void SetAnchorAndAdjustment( sal_Int16 eVertOri,
669 : sal_Int16 eHoriOri,
670 : const SfxItemSet &rItemSet,
671 : const SvxCSS1PropertyInfo &rPropInfo,
672 : SfxItemSet& rFrmSet );
673 : void SetAnchorAndAdjustment( sal_Int16 eVertOri,
674 : sal_Int16 eHoriOri,
675 : SfxItemSet& rFrmSet,
676 : sal_Bool bDontAppend=sal_False );
677 : void SetAnchorAndAdjustment( const SfxItemSet &rItemSet,
678 : const SvxCSS1PropertyInfo &rPropInfo,
679 : SfxItemSet &rFrmItemSet );
680 :
681 : void SetFrmFmtAttrs( SfxItemSet &rItemSet, SvxCSS1PropertyInfo &rPropInfo,
682 : sal_uInt16 nFlags, SfxItemSet &rFrmItemSet );
683 :
684 : // Frames anlegen und Auto-gebundene Rahmen registrieren
685 : void RegisterFlyFrm( SwFrmFmt *pFlyFrm );
686 :
687 : // Die Groesse des Fly-Frames an die Vorgaben und Gegebenheiten anpassen
688 : // (nicht fuer Grafiken, deshalb htmlplug.cxx)
689 : void SetFixSize( const Size& rPixSize, const Size& rTwipDfltSize,
690 : sal_Bool bPrcWidth, sal_Bool bPrcHeight,
691 : SfxItemSet &rItemSet, SvxCSS1PropertyInfo &rPropInfo,
692 : SfxItemSet& rFlyItemSet );
693 : void SetVarSize( SfxItemSet &rItemSet, SvxCSS1PropertyInfo &rPropInfo,
694 : SfxItemSet& rFlyItemSet, SwTwips nDfltWidth=MINLAY,
695 : sal_uInt8 nDltPrcWidth=0 );
696 : void SetSpace( const Size& rPixSpace, SfxItemSet &rItemSet,
697 : SvxCSS1PropertyInfo &rPropInfo, SfxItemSet& rFlyItemSet );
698 :
699 : sal_uInt16 IncGrfsThatResizeTable();
700 :
701 : void GetDefaultScriptType( ScriptType& rType,
702 : String& rTypeStr ) const;
703 :
704 : // die eigentlichen Einfuege-Methoden fuer <IMG>, <EMBED> und <APPLET>
705 : // und <PARAM>
706 : void InsertImage(); // htmlgrin.cxx
707 : void InsertEmbed(); // htmlplug.cxx
708 :
709 : #ifdef SOLAR_JAVA
710 : void NewObject(); // htmlplug.cxx
711 : #endif
712 : void EndObject(); // CommandLine mit Applet verkn. (htmlplug.cxx)
713 : #ifdef SOLAR_JAVA
714 : void InsertApplet(); // htmlplug.cxx
715 : #endif
716 : void EndApplet(); // CommandLine mit Applet verkn. (htmlplug.cxx)
717 : void InsertParam(); // htmlplug.cxx
718 :
719 : void InsertFloatingFrame();
720 0 : void EndFloatingFrame() { bInFloatingFrame = sal_False; }
721 :
722 : // <BODY>-Tag auswerten: Hintergrund-Grafiken und -Farben setzen (htmlgrin.cxx)
723 : void InsertBodyOptions();
724 :
725 :
726 : // Einfuegen von Links und ::com::sun::star::text::Bookmarks (htmlgrin.cxx)
727 :
728 : // <A>-Tag auswerten: einen Link bzw. eine ::com::sun::star::text::Bookmark einfuegen
729 : void NewAnchor();
730 : void EndAnchor();
731 :
732 : // eine ::com::sun::star::text::Bookmark einfuegen
733 : void InsertBookmark( const String& rName );
734 :
735 :
736 : void InsertCommentText( const sal_Char *pTag = 0 );
737 : void InsertComment( const String& rName, const sal_Char *pTag = 0 );
738 :
739 : // sind im aktuellen Absatz ::com::sun::star::text::Bookmarks vorhanden?
740 : sal_Bool HasCurrentParaBookmarks( sal_Bool bIgnoreStack=sal_False ) const;
741 :
742 :
743 : // Einfuegen von Script/Basic-Elementen
744 :
745 : // das zueletzt gelsene Basic-Modul parsen (htmlbas.cxx)
746 : void NewScript();
747 : void EndScript();
748 :
749 : void AddScriptSource();
750 :
751 : // ein Event in die SFX-Konfiguation eintragen (htmlbas.cxx)
752 : void InsertBasicDocEvent( rtl::OUString aEventName, const String& rName,
753 : ScriptType eScrType, const String& rScrType );
754 :
755 : // ein Event an ein VC-Control anhaengen (htmlform.cxx)
756 : void InsertBasicCtrlEvent( sal_uInt16 nEvent, const String& rName );
757 :
758 : // Inserting styles
759 :
760 : // <STYLE>
761 : void NewStyle();
762 : void EndStyle();
763 :
764 : inline sal_Bool HasStyleOptions( const String &rStyle, const String &rId,
765 : const String &rClass, const String *pLang=0,
766 : const String *pDir=0 );
767 : sal_Bool ParseStyleOptions( const String &rStyle, const String &rId,
768 : const String &rClass, SfxItemSet &rItemSet,
769 : SvxCSS1PropertyInfo &rPropInfo,
770 : const String *pLang=0, const String *pDir=0 );
771 :
772 :
773 : // Inserting Controls and ::com::sun::star::form::Forms (htmlform.cxx)
774 :
775 : // Insert draw object into document
776 : void InsertDrawObject( SdrObject* pNewDrawObj, const Size& rSpace,
777 : sal_Int16 eVertOri,
778 : sal_Int16 eHoriOri,
779 : SfxItemSet& rCSS1ItemSet,
780 : SvxCSS1PropertyInfo& rCSS1PropInfo,
781 : sal_Bool bHidden=sal_False );
782 : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > InsertControl( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormComponent > & rFormComp,
783 : const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & rFCompPropSet,
784 : const Size& rSize,
785 : sal_Int16 eVertOri,
786 : sal_Int16 eHoriOri,
787 : SfxItemSet& rCSS1ItemSet,
788 : SvxCSS1PropertyInfo& rCSS1PropInfo,
789 : const SvxMacroTableDtor& rMacroTbl,
790 : const std::vector<String>& rUnoMacroTbl,
791 : const std::vector<String>& rUnoMacroParamTbl,
792 : sal_Bool bSetPropSet = sal_True,
793 : sal_Bool bHidden = sal_False );
794 : void SetControlSize( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > & rShape, const Size& rTextSz,
795 : sal_Bool bMinWidth, sal_Bool bMinHeight );
796 : void SetPendingControlSize();
797 :
798 : public:
799 : void ResizeDrawObject( SdrObject* pObj, SwTwips nWidth );
800 : private:
801 : void RegisterDrawObjectToTable( HTMLTable *pCurTable, SdrObject* pObj,
802 : sal_uInt8 nWidth );
803 :
804 : void NewForm( sal_Bool bAppend=sal_True );
805 : void EndForm( sal_Bool bAppend=sal_True );
806 :
807 : // Insert methods for <INPUT>, <TEXTAREA> und <SELECT>
808 : void InsertInput();
809 :
810 : void NewTextArea();
811 : void InsertTextAreaText( sal_uInt16 nToken );
812 : void EndTextArea();
813 :
814 : void NewSelect();
815 : void InsertSelectOption();
816 : void InsertSelectText();
817 : void EndSelect();
818 :
819 : // Inserting tables (htmltab.cxx)
820 : public:
821 :
822 : // Insert box content after the given node
823 : const SwStartNode *InsertTableSection( const SwStartNode *pPrevStNd );
824 :
825 : // Insert box content at the end of the table containing the PaM
826 : // and move the PaM into the cell
827 : const SwStartNode *InsertTableSection( sal_uInt16 nPoolId );
828 :
829 : // Insert methods for various table tags
830 : HTMLTableCnts *InsertTableContents( sal_Bool bHead );
831 :
832 : private:
833 : // Create a section for the temporary storage of the table caption
834 : SwStartNode *InsertTempTableCaptionSection();
835 :
836 : void BuildTableCell( HTMLTable *pTable, sal_Bool bReadOptions, sal_Bool bHead );
837 : void BuildTableRow( HTMLTable *pTable, sal_Bool bReadOptions,
838 : SvxAdjust eGrpAdjust, sal_Int16 eVertOri );
839 : void BuildTableSection( HTMLTable *pTable, sal_Bool bReadOptions, sal_Bool bHead );
840 : void BuildTableColGroup( HTMLTable *pTable, sal_Bool bReadOptions );
841 : void BuildTableCaption( HTMLTable *pTable );
842 : HTMLTable *BuildTable( SvxAdjust eCellAdjust,
843 : sal_Bool bIsParentHead = sal_False,
844 : sal_Bool bHasParentSection=sal_True,
845 : sal_Bool bIsInMulticol = sal_False,
846 : sal_Bool bHasToFlow = sal_False );
847 :
848 :
849 : // misc ...
850 :
851 : void ParseMoreMetaOptions();
852 :
853 : sal_Bool FileDownload( const String& rURL, String& rStr );
854 : void InsertLink();
855 :
856 : void InsertIDOption();
857 : void InsertLineBreak();
858 : void InsertHorzRule();
859 :
860 : void FillEndNoteInfo( const String& rContent );
861 : void FillFootNoteInfo( const String& rContent );
862 : void InsertFootEndNote( const String& rName, sal_Bool bEndNote, sal_Bool bFixed );
863 : void FinishFootEndNote();
864 : void InsertFootEndNoteText();
865 : SwNodeIndex *GetFootEndNoteSection( const String& rName );
866 : void DeleteFootEndNoteImpl();
867 :
868 : xub_StrLen StripTrailingLF();
869 :
870 : // Remove empty paragraph at the PaM position
871 : void StripTrailingPara();
872 :
873 : // Are there fly frames in the current paragraph?
874 : sal_Bool HasCurrentParaFlys( sal_Bool bNoSurroundOnly = sal_False,
875 : sal_Bool bSurroundOnly = sal_False ) const;
876 :
877 : public: // used in tables
878 :
879 : // Create brush item (with new) or 0
880 : SvxBrushItem* CreateBrushItem( const Color *pColor,
881 : const String &rImageURL,
882 : const String &rStyle,
883 : const String &rId,
884 : const String &rClass );
885 :
886 : protected:
887 : // Executed for each token recognized by CallParser
888 : virtual void NextToken( int nToken );
889 : virtual ~SwHTMLParser();
890 :
891 : // If the document is removed, remove the parser as well
892 : virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew );
893 :
894 : virtual void AddMetaUserDefined( ::rtl::OUString const & i_rMetaName );
895 :
896 : public:
897 :
898 : SwHTMLParser( SwDoc* pD, const SwPaM& rCrsr, SvStream& rIn,
899 : const String& rFileName,
900 : const String& rBaseURL,
901 : int bReadNewDoc = sal_True,
902 : SfxMedium* pMed = 0, sal_Bool bReadUTF8 = sal_False,
903 : sal_Bool bIgnoreHTMLComments = sal_False );
904 :
905 : virtual SvParserState CallParser();
906 :
907 :
908 : sal_uInt16 ToTwips( sal_uInt16 nPixel ) const;
909 :
910 : // for reading asynchronously from SvStream
911 : virtual void Continue( int nToken );
912 :
913 : virtual bool ParseMetaOptions( const ::com::sun::star::uno::Reference<
914 : ::com::sun::star::document::XDocumentProperties>&,
915 : SvKeyValueIterator* );
916 : };
917 :
918 :
919 0 : struct SwPendingStackData
920 : {
921 0 : virtual ~SwPendingStackData() {}
922 : };
923 :
924 : struct SwPendingStack
925 : {
926 : int nToken;
927 : SwPendingStackData* pData;
928 : SwPendingStack* pNext;
929 :
930 0 : SwPendingStack( int nTkn, SwPendingStack* pNxt )
931 0 : : nToken( nTkn ), pData( 0 ), pNext( pNxt )
932 0 : {}
933 : };
934 :
935 0 : inline void _HTMLAttr::SetStart( const SwPosition& rPos )
936 : {
937 0 : nSttPara = rPos.nNode;
938 0 : nSttCntnt = rPos.nContent.GetIndex();
939 0 : nEndPara = nSttPara;
940 0 : nEndCntnt = nSttCntnt;
941 0 : }
942 :
943 0 : inline void _HTMLAttrContext::SetMargins( sal_uInt16 nLeft, sal_uInt16 nRight,
944 : short nIndent )
945 : {
946 0 : nLeftMargin = nLeft;
947 0 : nRightMargin = nRight;
948 0 : nFirstLineIndent = nIndent;
949 0 : bLRSpaceChanged = sal_True;
950 0 : }
951 :
952 0 : inline void _HTMLAttrContext::GetMargins( sal_uInt16& nLeft,
953 : sal_uInt16& nRight,
954 : short& nIndent ) const
955 : {
956 0 : if( bLRSpaceChanged )
957 : {
958 0 : nLeft = nLeftMargin;
959 0 : nRight = nRightMargin;
960 0 : nIndent = nFirstLineIndent;
961 : }
962 0 : }
963 :
964 0 : inline void _HTMLAttrContext::SetULSpace( sal_uInt16 nUpper, sal_uInt16 nLower )
965 : {
966 0 : nUpperSpace = nUpper;
967 0 : nLowerSpace = nLower;
968 0 : bULSpaceChanged = sal_True;
969 0 : }
970 :
971 0 : inline void _HTMLAttrContext::GetULSpace( sal_uInt16& rUpper,
972 : sal_uInt16& rLower ) const
973 : {
974 0 : if( bULSpaceChanged )
975 : {
976 0 : rUpper = nUpperSpace;
977 0 : rLower = nLowerSpace;
978 : }
979 0 : }
980 :
981 0 : inline sal_Bool SwHTMLParser::HasStyleOptions( const String &rStyle,
982 : const String &rId,
983 : const String &rClass,
984 : const String *pLang,
985 : const String *pDir )
986 : {
987 0 : return rStyle.Len() || rId.Len() || rClass.Len() ||
988 0 : (pLang && pLang->Len()) || (pDir && pDir->Len());
989 : }
990 :
991 : inline const _HTMLAttrContext *SwHTMLParser::GetTopContext() const
992 : {
993 : return aContexts.size() > nContextStMin
994 : ? aContexts.back() : 0;
995 : }
996 :
997 0 : inline void SwHTMLParser::PushContext( _HTMLAttrContext *pCntxt )
998 : {
999 0 : aContexts.push_back( pCntxt );
1000 0 : }
1001 :
1002 :
1003 : #endif
1004 :
1005 :
1006 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|