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