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