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