1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _WRTWW8_HXX 25 #define _WRTWW8_HXX 26 27 #include <tools/solar.h> // UINTXX 28 #include <tools/gen.hxx> 29 #ifndef _SVSTDARR_HXX 30 #define _SVSTDARR_ULONGS 31 #include <svl/svstdarr.hxx> 32 #endif 33 #include <editeng/editdata.hxx> 34 35 #include <map> 36 #include <vector> 37 38 #include <shellio.hxx> 39 #include <wrt_fn.hxx> 40 #include <filter/msfilter/msocximex.hxx> 41 42 #include "ww8struc.hxx" 43 #include "ww8scan.hxx" 44 #include "fields.hxx" 45 #include "types.hxx" 46 #include "writerhelper.hxx" 47 #include "../inc/msfilter.hxx" 48 #include <expfld.hxx> 49 50 #include <vcl/graph.hxx> 51 class SvxBrushItem; 52 53 // einige Forward Deklarationen 54 namespace msfilter 55 { 56 class MSCodec_Std97; 57 } 58 59 class WW8SwAttrIter; 60 class AttributeOutputBase; 61 class DocxAttributeOutput; 62 class RtfAttributeOutput; 63 class BitmapPalette; 64 class SwEscherEx; 65 class DateTime; 66 class Font; 67 class MSWordExportBase; 68 class SdrObject; 69 class SfxItemSet; 70 class SvStream; 71 class SvxBorderLine; 72 class SvxFontItem; 73 class SvxBoxItem; 74 class SwAttrSet; 75 class SwCharFmt; 76 class SwCntntNode; 77 class SwField; 78 class SwFmt; 79 class SwFmtCntnt; 80 class SwFmtFtn; 81 class SwFrmFmt; 82 class SwGrfNode; 83 class SwModify; 84 class SwNumFmt; 85 class SwNumRule; 86 class SwNumRuleTbl; 87 class SwPageDesc; 88 class SwFmtPageDesc; 89 class SwOLENode; 90 class SwPostItField; 91 class SwRedlineData; 92 class SwSection; 93 class SwSectionFmt; 94 class SwSectionNode; 95 class SwTableNode; 96 class SwTOXType; 97 class SwTxtAttr; 98 class SwTxtFmtColl; 99 class SwTxtNode; 100 class SwWW8WrGrf; 101 class SwWW8Writer; 102 class MSWordStyles; 103 class WW8AttributeOutput; 104 class WW8Bytes; 105 class WW8Export; 106 class MSWordAttrIter; 107 class WW8_WrFkp; 108 class WW8_WrPlc0; 109 class WW8_WrPlc1; 110 class WW8_WrPlcFld; 111 class WW8_WrMagicTable; 112 class WW8_WrPlcFtnEdn; 113 class WW8_WrPlcPn; 114 class WW8_WrPlcAnnotations; 115 class MSWordSections; 116 class WW8_WrPlcTxtBoxes; 117 class WW8_WrPct; // Verwaltung 118 class WW8_WrPcPtrs; 119 class WW8_WrtBookmarks; 120 class WW8_WrtRedlineAuthor; 121 class SvxMSExportOLEObjects; 122 class SwMSConvertControls; 123 class WW8OleMaps; 124 class SvStorageRef; 125 struct WW8_PdAttrDesc; 126 class SvxBrushItem; 127 128 #include "WW8TableInfo.hxx" 129 130 #define GRF_MAGIC_1 0x12 // 3 magic Bytes fuer PicLocFc-Attribute 131 #define GRF_MAGIC_2 0x34 132 #define GRF_MAGIC_3 0x56 133 #define GRF_MAGIC_321 0x563412L 134 135 #define OLE_PREVIEW_AS_EMF //If we want to export ole2 previews as emf in ww8+ 136 137 typedef sal_uInt8 FieldFlags; 138 namespace nsFieldFlags // for InsertField- Method 139 { 140 const FieldFlags WRITEFIELD_START = 0x01; 141 const FieldFlags WRITEFIELD_CMD_START = 0x02; 142 const FieldFlags WRITEFIELD_CMD_END = 0x04; 143 const FieldFlags WRITEFIELD_END = 0x10; 144 const FieldFlags WRITEFIELD_CLOSE = 0x20; 145 const FieldFlags WRITEFIELD_ALL = 0xFF; 146 } 147 148 enum TxtTypes //enums for TextTypes 149 { 150 TXT_MAINTEXT = 0, /*TXT_FTNEDN = 1,*/ TXT_HDFT = 2, TXT_FTN = 3, 151 TXT_EDN = 4, TXT_ATN = 5, TXT_TXTBOX = 6, TXT_HFTXTBOX= 7 152 }; 153 154 SV_DECL_VARARR( WW8Bytes, sal_uInt8, 128, 128 ) 155 156 struct WW8_SepInfo 157 { 158 const SwPageDesc* pPageDesc; 159 const SwSectionFmt* pSectionFmt; 160 const SwNode* pPDNd; 161 const SwTxtNode* pNumNd; 162 sal_uLong nLnNumRestartNo; 163 sal_uInt16 nPgRestartNo; 164 WW8_SepInfoWW8_SepInfo165 WW8_SepInfo() 166 : pPageDesc(0), pSectionFmt(0), pPDNd(0), pNumNd(0), nLnNumRestartNo(0), nPgRestartNo(0) 167 168 {} 169 WW8_SepInfoWW8_SepInfo170 WW8_SepInfo( const SwPageDesc* pPD, const SwSectionFmt* pFmt, 171 sal_uLong nLnRestart, sal_uInt16 nPgRestart = 0, const SwNode* pNd = NULL ) 172 : pPageDesc( pPD ), pSectionFmt( pFmt ), pPDNd( pNd ), pNumNd( 0 ), 173 nLnNumRestartNo( nLnRestart ), nPgRestartNo( nPgRestart ) 174 {} 175 176 bool IsProtected() const; 177 }; 178 179 SV_DECL_VARARR( WW8_WrSepInfoPtrs, WW8_SepInfo, 4, 4 ) 180 181 /// Class to collect and output the sections/headers/footers. 182 // Plc fuer PageDescs -> Sepx ( Section Extensions ) 183 class MSWordSections 184 { 185 protected: 186 bool mbDocumentIsProtected; 187 WW8_WrSepInfoPtrs aSects; // PTRARR von SwPageDesc und SwSectionFmt 188 189 void CheckForFacinPg( WW8Export& rWrt ) const; 190 void WriteOlst( WW8Export& rWrt, const WW8_SepInfo& rSectionInfo ); 191 void NeedsDocumentProtected(const WW8_SepInfo &rInfo); 192 193 //No copy, no assign 194 MSWordSections( const MSWordSections& ); 195 MSWordSections& operator=( const MSWordSections& ); 196 public: 197 MSWordSections( MSWordExportBase& rExport ); 198 virtual ~MSWordSections(); 199 200 virtual bool HeaderFooterWritten(); 201 202 void AppendSection( const SwPageDesc* pPd, 203 const SwSectionFmt* pSectionFmt = 0, 204 sal_uLong nLnNumRestartNo = 0 ); 205 void AppendSection( const SwFmtPageDesc& rPd, 206 const SwNode& rNd, 207 const SwSectionFmt* pSectionFmt, 208 sal_uLong nLnNumRestartNo ); 209 void SetNum( const SwTxtNode* pNumNd ); 210 211 /// Number of columns based on the most recent WW8_SepInfo. 212 sal_uInt16 CurrentNumberOfColumns( const SwDoc &rDoc ) const; 213 214 /// Number of columns of the provided WW8_SepInfo. 215 sal_uInt16 NumberOfColumns( const SwDoc &rDoc, const WW8_SepInfo& rInfo ) const; 216 DocumentIsProtected() const217 bool DocumentIsProtected() const { return mbDocumentIsProtected; } 218 219 /// The most recent WW8_SepInfo. 220 const WW8_SepInfo* CurrentSectionInfo(); 221 222 static void SetHeaderFlag( sal_uInt8& rHeadFootFlags, const SwFmt& rFmt, 223 sal_uInt8 nFlag ); 224 static void SetFooterFlag( sal_uInt8& rHeadFootFlags, const SwFmt& rFmt, 225 sal_uInt8 nFlag ); 226 227 /// Should we output borders? 228 static int HasBorderItem( const SwFmt& rFmt ); 229 }; 230 231 class WW8_WrPlcSepx : public MSWordSections 232 { 233 SvULongs aCps; // PTRARR von CPs 234 ::std::vector< ::boost::shared_ptr<WW8_PdAttrDesc> > m_SectionAttributes; 235 // HACK to prevent adding sections in endnotes 236 bool m_bHeaderFooterWritten; 237 WW8_WrPlc0* pTxtPos; // Pos der einzelnen Header / Footer 238 239 // No copy, no assign 240 WW8_WrPlcSepx( const WW8_WrPlcSepx& ); 241 WW8_WrPlcSepx& operator=( const WW8_WrPlcSepx& ); 242 243 public: 244 WW8_WrPlcSepx( MSWordExportBase& rExport ); 245 ~WW8_WrPlcSepx(); 246 247 virtual bool HeaderFooterWritten(); // override 248 249 void AppendSep( WW8_CP nStartCp, 250 const SwPageDesc* pPd, 251 const SwSectionFmt* pSectionFmt = 0, 252 sal_uLong nLnNumRestartNo = 0 ); 253 void AppendSep( WW8_CP nStartCp, const SwFmtPageDesc& rPd, 254 const SwNode& rNd, 255 const SwSectionFmt* pSectionFmt, 256 sal_uLong nLnNumRestartNo ); Finish(WW8_CP nEndCp)257 void Finish( WW8_CP nEndCp ) { aCps.Insert( nEndCp, aCps.Count() ); } 258 259 bool WriteKFTxt( WW8Export& rWrt ); 260 void WriteSepx( SvStream& rStrm ) const; 261 void WritePlcSed( WW8Export& rWrt ) const; 262 void WritePlcHdd( WW8Export& rWrt ) const; 263 264 private: 265 void WriteFtnEndTxt( WW8Export& rWrt, sal_uLong nCpStt ); 266 public: 267 void OutHeaderFooter(WW8Export& rWrt, bool bHeader, 268 const SwFmt& rFmt, sal_uLong& rCpPos, sal_uInt8 nHFFlags, sal_uInt8 nFlag, sal_uInt8 nBreakCode); 269 }; 270 271 //-------------------------------------------------------------------------- 272 // class WW8_WrPct zum Aufbau der Piece-Table 273 //-------------------------------------------------------------------------- 274 class WW8_WrPct 275 { 276 WW8_WrPcPtrs* pPcts; 277 WW8_FC nOldFc; 278 bool bIsUni; 279 public: 280 WW8_WrPct(WW8_FC nStartFc, bool bSaveUniCode); 281 ~WW8_WrPct(); 282 void AppendPc(WW8_FC nStartFc, bool bIsUnicode); 283 void WritePc( WW8Export& rWrt ); 284 void SetParaBreak(); IsUnicode() const285 bool IsUnicode() const { return bIsUni; } 286 WW8_CP Fc2Cp( sal_uLong nFc ) const; 287 }; 288 289 /// Collects and outputs fonts. 290 class wwFont 291 { 292 //In some future land the stream could be converted to a nice stream interface 293 //and we could have harmony 294 private: 295 sal_uInt8 maWW8_FFN[6]; 296 String msFamilyNm; 297 String msAltNm; 298 bool mbAlt; 299 bool mbWrtWW8; 300 FontPitch mePitch; 301 FontFamily meFamily; 302 rtl_TextEncoding meChrSet; 303 public: 304 wwFont( const String &rFamilyName, FontPitch ePitch, FontFamily eFamily, 305 rtl_TextEncoding eChrSet, bool bWrtWW8 ); 306 bool Write( SvStream *pTableStram ) const; 307 #ifdef DOCX 308 void WriteDocx( const DocxAttributeOutput* rAttrOutput ) const; 309 #endif 310 void WriteRtf( const RtfAttributeOutput* rAttrOutput ) const; GetFamilyName() const311 rtl::OUString GetFamilyName() const { return rtl::OUString( msFamilyNm ); } 312 friend bool operator < (const wwFont &r1, const wwFont &r2); 313 }; 314 315 class wwFontHelper 316 { 317 private: 318 /// Keep track of fonts that need to be exported. 319 ::std::map<wwFont, sal_uInt16> maFonts; 320 bool mbWrtWW8; 321 322 /// Convert from fast insertion map to linear vector in the order that we want to write. 323 ::std::vector< const wwFont* > AsVector() const; 324 325 public: wwFontHelper()326 wwFontHelper() : mbWrtWW8(false), bLoadAllFonts(false) {} 327 /// rDoc used only to get the initial standard font(s) in use. 328 void InitFontTable(bool bWrtWW8, const SwDoc& rDoc); 329 sal_uInt16 GetId(const Font& rFont); 330 sal_uInt16 GetId(const SvxFontItem& rFont); 331 sal_uInt16 GetId(const wwFont& rFont); 332 void WriteFontTable( SvStream *pTableStream, WW8Fib& pFib ); 333 #ifdef DOCX 334 void WriteFontTable( const DocxAttributeOutput& rAttrOutput ); 335 #endif 336 void WriteFontTable( const RtfAttributeOutput& rAttrOutput ); 337 338 /// If true, all fonts are loaded before processing the document. 339 sal_uInt8 bLoadAllFonts: 1; 340 }; 341 342 class DrawObj 343 { 344 public: 345 WW8_CP mnCp; // CP-Pos der Verweise 346 sal_uInt32 mnShapeId; // ShapeId for the SwFrmFmts 347 sw::Frame maCntnt; // the frame itself 348 Point maParentPos; // Points 349 sal_Int32 mnThick; // Border Thicknesses 350 short mnDirection; // If BiDi or not 351 unsigned int mnHdFtIndex; // 0 for main text, +1 for each subsequent 352 // msword hd/ft 353 DrawObj(const sw::Frame & rCntnt,WW8_CP nCp,Point aParentPos,short nDir,unsigned int nHdFtIndex)354 DrawObj(const sw::Frame &rCntnt, WW8_CP nCp, Point aParentPos, short nDir, 355 unsigned int nHdFtIndex) 356 : mnCp(nCp), mnShapeId(0), maCntnt(rCntnt), maParentPos(aParentPos), 357 mnThick(0), mnDirection(nDir), mnHdFtIndex(nHdFtIndex) {} 358 void SetShapeDetails(sal_uInt32 nId, sal_Int32 nThick); 359 DrawObj& operator=(const DrawObj &rOther); 360 }; 361 362 typedef std::vector<DrawObj> DrawObjVector; 363 typedef DrawObjVector::iterator DrawObjIter; 364 typedef DrawObjVector::const_iterator cDrawObjIter; 365 366 typedef std::vector<DrawObj *> DrawObjPointerVector; 367 typedef DrawObjPointerVector::iterator DrawObjPointerIter; 368 369 class PlcDrawObj // PC for DrawObjects and Text-/OLE-/GRF-Boxes 370 { 371 private: 372 DrawObjVector maDrawObjs; // vector of drawobjs 373 protected: 374 virtual void RegisterWithFib(WW8Fib &rFib, sal_uInt32 nStart, 375 sal_uInt32 nLen) const = 0; 376 virtual WW8_CP GetCpOffset(const WW8Fib &rFib) const = 0; 377 public: PlcDrawObj()378 PlcDrawObj() {} 379 void WritePlc( WW8Export& rWrt ) const; 380 bool Append( WW8Export&, WW8_CP nCp, const sw::Frame& rFmt, 381 const Point& rNdTopLeft ); size()382 int size() { return maDrawObjs.size(); }; GetObjArr()383 DrawObjVector &GetObjArr() { return maDrawObjs; } 384 virtual ~PlcDrawObj(); 385 private: 386 //No copying 387 PlcDrawObj(const PlcDrawObj&); 388 PlcDrawObj& operator=(const PlcDrawObj&); 389 }; 390 391 class MainTxtPlcDrawObj : public PlcDrawObj 392 { 393 public: MainTxtPlcDrawObj()394 MainTxtPlcDrawObj() {} 395 private: 396 virtual void RegisterWithFib(WW8Fib &rFib, sal_uInt32 nStart, 397 sal_uInt32 nLen) const; 398 virtual WW8_CP GetCpOffset(const WW8Fib &) const; 399 private: 400 //No copying 401 MainTxtPlcDrawObj(const MainTxtPlcDrawObj&); 402 MainTxtPlcDrawObj& operator=(const MainTxtPlcDrawObj&); 403 }; 404 405 class HdFtPlcDrawObj : public PlcDrawObj 406 { 407 public: HdFtPlcDrawObj()408 HdFtPlcDrawObj() {} 409 private: 410 virtual void RegisterWithFib(WW8Fib &rFib, sal_uInt32 nStart, 411 sal_uInt32 nLen) const; 412 virtual WW8_CP GetCpOffset(const WW8Fib &rFib) const; 413 private: 414 //No copying 415 HdFtPlcDrawObj(const HdFtPlcDrawObj&); 416 HdFtPlcDrawObj& operator=(const HdFtPlcDrawObj&); 417 }; 418 419 typedef ::std::pair<String, sal_uLong> aPair; 420 typedef std::vector<aPair> SwImplBookmarks; 421 typedef std::vector<aPair>::iterator SwImplBookmarksIter; 422 423 class WW8_WrtRedlineAuthor : public sw::util::WrtRedlineAuthor 424 { 425 public: 426 virtual void Write(Writer &rWrt); 427 }; 428 429 /** Structure that is used to save some of the WW8Export/DocxExport data. 430 431 It is used to be able to recurse inside of the WW8Export/DocxExport (eg. 432 for the needs of the tables) - you need to tall WriteText() from there with 433 new values of PaM etc. 434 435 It must contain all the stuff that might be saved either in WW8Export or in 436 DocxExport, because it makes no sense to do it abstract, and specialize it 437 for each of the cases. If you implement other *Export, just add the needed 438 members here, and store them in the appropriate SaveData() method. 439 */ 440 struct MSWordSaveData 441 { 442 Point* pOldFlyOffset; 443 RndStdIds eOldAnchorType; 444 WW8Bytes* pOOld; ///< WW8Export only 445 WW8Bytes* mpTableAtOld; ///< WW8Export only: Additional buffer for the output of the tables 446 sal_uInt16 mnTableStdAtLenOld; ///< WW8Export only: Standard length of mpTableAt 447 SwPaM* pOldPam, *pOldEnd; 448 const sw::Frame* pOldFlyFmt; 449 const SwPageDesc* pOldPageDesc; 450 451 sal_uInt8 bOldWriteAll : 1; ///< WW8Export only 452 sal_uInt8 bOldOutTable : 1; 453 sal_uInt8 bOldIsInTable: 1; 454 sal_uInt8 bOldFlyFrmAttrs : 1; 455 sal_uInt8 bOldStartTOX : 1; 456 sal_uInt8 bOldInWriteTOX : 1; 457 // bOutPageDesc muss nicht gesichert werden, da es nur nicht waehrend der 458 // Ausgabe von Spezial-Texten veraendert wird. 459 }; 460 461 /// Base class for WW8Export and DocxExport 462 class MSWordExportBase 463 { 464 public: 465 wwFontHelper maFontHelper; 466 std::vector<sal_uLong> maChapterFieldLocs; 467 typedef std::vector<sal_uLong>::const_iterator mycCFIter; 468 String aMainStg; 469 SvPtrarr aTOXArr; 470 const SfxItemSet* pISet; // fuer Doppel-Attribute 471 WW8_WrPct* pPiece; // Pointer auf Piece-Table 472 SwNumRuleTbl* pUsedNumTbl; // alle used NumRules 473 const SwTxtNode *mpTopNodeOfHdFtPage; ///< Top node of host page when in hd/ft 474 std::map< sal_uInt16, sal_uInt16 > aRuleDuplicates; //map to Duplicated numrules 475 std::stack< xub_StrLen > m_aCurrentCharPropStarts; ///< To remember the position in a run. 476 WW8_WrtBookmarks* pBkmks; 477 WW8_WrtRedlineAuthor* pRedlAuthors; 478 BitmapPalette* pBmpPal; 479 boost::shared_ptr<NfKeywordTable> pKeyMap; 480 SvxMSExportOLEObjects* pOLEExp; 481 SwMSConvertControls* pOCXExp; 482 WW8OleMaps* pOleMap; 483 ww8::WW8TableInfo::Pointer_t mpTableInfo; 484 485 sal_uInt16 nCharFmtStart; 486 sal_uInt16 nFmtCollStart; 487 sal_uInt16 nStyleBeforeFly; ///< Style-Nummer des Nodes, 488 ///< in/an dem ein Fly verankert ist 489 sal_uInt16 nLastFmtId; ///< Style of last TxtNode in normal range 490 sal_uInt16 nUniqueList; ///< current number for creating unique list names 491 unsigned int mnHdFtIndex; 492 493 sal_uInt16 mnRedlineMode; ///< Remember the original redline mode 494 495 public: 496 /* implicit bookmark vector containing pairs of node indexes and bookmark names */ 497 SwImplBookmarks maImplicitBookmarks; 498 sw::Frames maFrames; // The floating frames in this document 499 const SwPageDesc *pAktPageDesc; 500 WW8_WrPlcPn* pPapPlc; 501 WW8_WrPlcPn* pChpPlc; 502 MSWordAttrIter* pChpIter; 503 MSWordStyles* pStyles; 504 WW8_WrPlcAnnotations* pAtn; 505 WW8_WrPlcTxtBoxes *pTxtBxs, *pHFTxtBxs; 506 507 const sw::Frame *mpParentFrame; //If set we are exporting content inside 508 //a frame, e.g. a graphic node 509 510 Point* pFlyOffset; // zur Justierung eines im Writer als 511 RndStdIds eNewAnchorType; // Zeichen gebundenen Flys, der im WW 512 // Absatzgebunden wird. 513 514 WW8_WrPlcFld* pFldMain; // Felder im Haupttext 515 WW8_WrPlcFld* pFldHdFt; // Felder in Header/Footer 516 WW8_WrPlcFld* pFldFtn; // Felder in FootNotes 517 WW8_WrPlcFld* pFldEdn; // Felder in EndNotes 518 WW8_WrPlcFld* pFldAtn; // Felder in Annotations 519 WW8_WrPlcFld* pFldTxtBxs; // fields in textboxes 520 WW8_WrPlcFld* pFldHFTxtBxs; // fields in header/footer textboxes 521 WW8_WrMagicTable *pMagicTable; // keeps track of table cell positions, and 522 // marks those that contain graphics, 523 // which is required to make word display 524 // graphics inside tables 525 SwWW8WrGrf* pGrf; 526 const SwAttrSet* pStyAttr; // StyleAttr fuer Tabulatoren 527 const SwModify* pOutFmtNode; // write Format or Node 528 const SwFmt *pCurrentStyle; // iff bStyDef=true, then this store the current style 529 530 MainTxtPlcDrawObj *pSdrObjs; // Draw-/Fly-Objects 531 HdFtPlcDrawObj *pHFSdrObjs; // Draw-/Fly-Objects in header or footer 532 533 SwEscherEx* pEscher; // escher export class 534 // --> OD 2007-04-19 #i43447# - removed 535 // SwTwips nFlyWidth, nFlyHeight; // Fuer Anpassung Graphic 536 // <-- 537 538 sal_uInt8 nTxtTyp; 539 540 sal_uInt8 bStyDef : 1; // wird Style geschrieben ? 541 sal_uInt8 bBreakBefore : 1; // Breaks werden 2mal ausgegeben 542 sal_uInt8 bOutKF : 1; // Kopf/Fusstexte werden ausgegeben 543 sal_uInt8 bOutFlyFrmAttrs : 1; // Rahmen-Attr von Flys werden ausgegeben 544 sal_uInt8 bOutPageDescs : 1; ///< PageDescs (section properties) are being written 545 sal_uInt8 bOutFirstPage : 1; // write Attrset of FirstPageDesc 546 sal_uInt8 bOutTable : 1; // Tabelle wird ausgegeben 547 // ( wird zB bei Flys in Tabelle zurueckgesetzt ) 548 sal_uInt8 bOutGrf : 1; // Grafik wird ausgegeben 549 sal_uInt8 bInWriteEscher : 1; // in write textboxes 550 sal_uInt8 bStartTOX : 1; // true: a TOX is startet 551 sal_uInt8 bInWriteTOX : 1; // true: all content are in a TOX 552 sal_uInt8 bFtnAtTxtEnd : 1; // true: all FTN at Textend 553 sal_uInt8 bEndAtTxtEnd : 1; // true: all END at Textend 554 sal_uInt8 bHasHdr : 1; 555 sal_uInt8 bHasFtr : 1; 556 sal_uInt8 bSubstituteBullets : 1; // true: SubstituteBullet() gets called 557 558 bool mbExportModeRTF; 559 bool mbOutOutlineOnly; // export outline nodes, only (send outline to clipboard/presentation) 560 561 SwDoc *pDoc; 562 SwPaM *pCurPam, *pOrigPam; 563 564 /// Stack to remember the nesting (see MSWordSaveData for more) 565 ::std::stack< MSWordSaveData > maSaveData; 566 567 /// Used to split the runs according to the bookmarks start and ends 568 typedef std::vector< ::sw::mark::IMark* > IMarkVector; 569 IMarkVector m_rSortedMarksStart; 570 IMarkVector m_rSortedMarksEnd; 571 572 public: 573 /// The main function to export the document. 574 void ExportDocument( bool bWriteAll ); 575 576 /// Iterate through the nodes and call the appropriate OutputNode() on them. 577 void WriteText(); 578 579 /// Return whether currently exported node is in table. 580 bool IsInTable() const; 581 582 /// Set the pCurPam appropriately and call WriteText(). 583 /// 584 /// Used to export paragraphs in footnotes/endnotes/etc. 585 void WriteSpecialText( sal_uLong nStart, sal_uLong nEnd, sal_uInt8 nTTyp ); 586 587 /// Export the pool items to attributes (through an attribute output class). 588 void ExportPoolItemsToCHP( sw::PoolItems &rItems, sal_uInt16 nScript ); 589 590 /// Return the numeric id of the numbering rule 591 sal_uInt16 GetId( const SwNumRule& rNumRule ); 592 593 /// Return the numeric id of the style. 594 sal_uInt16 GetId( const SwTxtFmtColl& rColl ) const; 595 596 /// Return the numeric id of the style. 597 sal_uInt16 GetId( const SwCharFmt& rFmt ) const; 598 599 sal_uInt16 GetId( const SwTOXType& rTOXType ); 600 601 const SfxPoolItem& GetItem( sal_uInt16 nWhich ) const; 602 603 /// Find the reference. 604 bool HasRefToObject( sal_uInt16 nTyp, const String* pName, sal_uInt16 nSeqNo ); 605 606 /// Find the bookmark name. 607 String GetBookmarkName( sal_uInt16 nTyp, const String* pName, sal_uInt16 nSeqNo ); 608 609 /// Add a bookmark converted to a Word name. 610 void AppendWordBookmark( const String& rName ); 611 612 /// Use OutputItem() on an item set according to the parameters. 613 void OutputItemSet( const SfxItemSet& rSet, bool bPapFmt, bool bChpFmt, sal_uInt16 nScript, bool bExportParentItemSet ); 614 615 short GetDefaultFrameDirection( ) const; 616 617 /// Right to left? 618 short TrueFrameDirection( const SwFrmFmt& rFlyFmt ) const; 619 620 /// Right to left? 621 short GetCurrentPageDirection() const; 622 623 /// In case of numbering restart. 624 625 /// List is set to restart at a particular value so for export make a 626 /// completely new list based on this one and export that instead, 627 /// which duplicates words behaviour in this respect. 628 sal_uInt16 DuplicateNumRule( const SwNumRule *pRule, sal_uInt8 nLevel, sal_uInt16 nVal ); 629 630 /// Access to the attribute output class. 631 virtual AttributeOutputBase& AttrOutput() const = 0; 632 633 /// Access to the sections/headers/footres. 634 virtual MSWordSections& Sections() const = 0; 635 636 /// Hack, unfortunately necessary at some places for now. 637 /// FIXME remove it when possible. 638 virtual bool HackIsWW8OrHigher() const = 0; 639 640 /// Guess the script (asian/western). 641 /// 642 /// Sadly word does not have two different sizes for asian font size and 643 /// western font size, it has two different fonts, but not sizes, so we 644 /// have to use our guess as to the script used and disable the export of 645 /// one type. The same occurs for font weight and posture (bold and 646 /// italic). 647 /// 648 /// In addition WW7- has only one character language identifier while WW8+ 649 /// has two 650 virtual bool CollapseScriptsforWordOk( sal_uInt16 nScript, sal_uInt16 nWhich ) = 0; 651 652 virtual void AppendBookmarks( const SwTxtNode& rNd, xub_StrLen nAktPos, xub_StrLen nLen ) = 0; 653 654 virtual void AppendBookmark( const rtl::OUString& rName, bool bSkip = false ) = 0; 655 //For i120928,add this interface to export graphic of bullet 656 virtual void ExportGrfBullet(const SwTxtNode& rNd) = 0; 657 658 // FIXME probably a hack... 659 virtual void WriteCR( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner = ww8::WW8TableNodeInfoInner::Pointer_t() ) = 0; 660 661 // FIXME definitely a hack, must not be here - it can't do anything 662 // sensible for docx 663 virtual void WriteChar( sal_Unicode c ) = 0; 664 665 /// Output attributes. 666 void OutputFormat( const SwFmt& rFmt, bool bPapFmt, bool bChpFmt, bool bFlyFmt = false ); 667 668 /// Getter for pISet. GetCurItemSet() const669 const SfxItemSet* GetCurItemSet() const { return pISet; } 670 671 /// Setter for pISet. SetCurItemSet(const SfxItemSet * pS)672 void SetCurItemSet( const SfxItemSet* pS ) { pISet = pS; } 673 674 /// Remember some of the members so that we can recurse in WriteText(). 675 virtual void SaveData( sal_uLong nStt, sal_uLong nEnd ); 676 677 /// Restore what was saved in SaveData(). 678 virtual void RestoreData(); 679 680 /// The return value indicates, if a follow page desc is written. 681 bool OutputFollowPageDesc( const SfxItemSet* pSet, 682 const SwTxtNode* pNd ); 683 684 /// Write header/footer text. 685 void WriteHeaderFooterText( const SwFmt& rFmt, bool bHeader); 686 687 /// Format of the section. 688 const SwSectionFmt* GetSectionFormat( const SwNode& rNd ) const; 689 690 /// Line number of the section start. 691 sal_uLong GetSectionLineNo( const SfxItemSet* pSet, const SwNode& rNd ) const; 692 693 /// Start new section. 694 void OutputSectionBreaks( const SfxItemSet *pSet, const SwNode& rNd ); 695 696 /// Write section properties. 697 /// 698 /// pA is ignored for docx. 699 void SectionProperties( const WW8_SepInfo& rSectionInfo, WW8_PdAttrDesc* pA = NULL ); 700 701 /// Output the numbering table. 702 virtual void WriteNumbering() = 0; 703 704 /// Write static data of SwNumRule - LSTF 705 void NumberingDefinitions(); 706 707 /// Write all Levels for all SwNumRules - LVLF 708 void AbstractNumberingDefinitions(); 709 710 // Convert the bullet according to the font. 711 void SubstituteBullet( String& rNumStr, rtl_TextEncoding& rChrSet, 712 String& rFontName ) const; 713 714 /// No-op for the newer WW versions. OutputOlst(const SwNumRule &)715 virtual void OutputOlst( const SwNumRule& /*rRule*/ ) {} 716 717 /// Setup the pA's info. SetupSectionPositions(WW8_PdAttrDesc *)718 virtual void SetupSectionPositions( WW8_PdAttrDesc* /*pA*/ ) {} 719 720 /// Top node of host page when in header/footer. SetHdFtPageRoot(const SwTxtNode * pNd)721 void SetHdFtPageRoot( const SwTxtNode *pNd ) { mpTopNodeOfHdFtPage = pNd; } 722 723 /// Top node of host page when in header/footer. GetHdFtPageRoot() const724 const SwTxtNode *GetHdFtPageRoot() const { return mpTopNodeOfHdFtPage; } 725 726 /// Output the actual headers and footers. 727 virtual void WriteHeadersFooters( sal_uInt8 nHeadFootFlags, 728 const SwFrmFmt& rFmt, const SwFrmFmt& rLeftFmt, const SwFrmFmt& rFirstPageFmt, 729 sal_uInt8 nBreakCode) = 0; 730 731 /// Write the field 732 virtual void OutputField( const SwField* pFld, ww::eField eFldType, 733 const String& rFldCmd, sal_uInt8 nMode = nsFieldFlags::WRITEFIELD_ALL ) = 0; 734 735 /// Write the data of the form field 736 virtual void WriteFormData( const ::sw::mark::IFieldmark& rFieldmark ) = 0; 737 virtual void WriteHyperlinkData( const ::sw::mark::IFieldmark& rFieldmark ) = 0; 738 739 virtual void DoComboBox(const rtl::OUString &rName, 740 const rtl::OUString &rHelp, 741 const rtl::OUString &ToolTip, 742 const rtl::OUString &rSelected, 743 com::sun::star::uno::Sequence<rtl::OUString> &rListItems) = 0; 744 745 virtual void DoFormText(const SwInputField * pFld) = 0; 746 747 static bool NoPageBreakSection( const SfxItemSet *pSet ); 748 749 // Compute the number format for WW dates 750 bool GetNumberFmt(const SwField& rFld, String& rStr); 751 752 virtual sal_uLong ReplaceCr( sal_uInt8 nChar ) = 0; 753 754 const SfxPoolItem* HasItem( sal_uInt16 nWhich ) const; 755 756 757 protected: 758 /// Format-dependant part of the actual export. 759 virtual void ExportDocument_Impl() = 0; 760 761 /// Get the next position in the text node to output 762 virtual xub_StrLen GetNextPos( WW8SwAttrIter* pAttrIter, const SwTxtNode& rNode, xub_StrLen nAktPos ); 763 764 /// Update the information for GetNextPos(). 765 virtual void UpdatePosition( WW8SwAttrIter* pAttrIter, xub_StrLen nAktPos, xub_StrLen nEnd ); 766 767 /// Output SwTxtNode 768 void OutputTextNode( const SwTxtNode& ); 769 770 /// Output SwTableNode 771 void OutputTableNode( const SwTableNode& ); 772 773 /// Setup the chapter fields (maChapterFieldLocs). 774 void GatherChapterFields(); 775 776 void AddLinkTarget( const String& rURL ); 777 void CollectOutlineBookmarks( const SwDoc &rDoc ); 778 779 bool SetAktPageDescFromNode(const SwNode &rNd); 780 bool CntntContainsChapterField(const SwFmtCntnt &rCntnt) const; 781 bool FmtHdFtContainsChapterField(const SwFrmFmt &rFmt) const; 782 783 virtual void SectionBreaksAndFrames( const SwTxtNode& rNode ) = 0; 784 785 virtual void PrepareNewPageDesc( const SfxItemSet* pSet, 786 const SwNode& rNd, 787 const SwFmtPageDesc* pNewPgDescFmt = 0, 788 const SwPageDesc* pNewPgDesc = 0 ) = 0; 789 790 /// Return value indicates if an inherited outline numbering is suppressed. 791 virtual bool DisallowInheritingOutlineNumbering(const SwFmt &rFmt) = 0; 792 793 protected: 794 /// Output SwStartNode 795 virtual void OutputStartNode( const SwStartNode& ); 796 797 /// Output SwEndNode 798 virtual void OutputEndNode( const SwEndNode& ); 799 800 /// Output SwGrfNode 801 virtual void OutputGrfNode( const SwGrfNode& ) = 0; 802 803 /// Output SwOLENode 804 virtual void OutputOLENode( const SwOLENode& ) = 0; 805 806 /// Output SwSectionNode 807 virtual void OutputSectionNode( const SwSectionNode& ); 808 809 virtual void AppendSection( const SwPageDesc *pPageDesc, const SwSectionFmt* pFmt, sal_uLong nLnNum ) = 0; 810 811 /// Call the right (virtual) function according to the type of the item. 812 /// 813 /// One of OutputTextNode(), OutputGrfNode(), or OutputOLENode() 814 void OutputContentNode( const SwCntntNode& ); 815 816 /// Find the nearest bookmark from the current position. 817 /// 818 /// Returns false when there is no bookmark. 819 bool NearestBookmark( xub_StrLen& rNearest, const xub_StrLen nAktPos, bool bNextPositionOnly ); 820 821 void GetSortedBookmarks( const SwTxtNode& rNd, xub_StrLen nAktPos, 822 xub_StrLen nLen ); 823 824 bool GetBookmarks( 825 const SwTxtNode& rNd, 826 const xub_StrLen nStt, 827 const xub_StrLen nEnd, 828 IMarkVector& rArr ); 829 830 const NfKeywordTable & GetNfKeywordTable(); 831 832 public: 833 MSWordExportBase( SwDoc *pDocument, SwPaM *pCurrentPam, SwPaM *pOriginalPam ); 834 virtual ~MSWordExportBase(); 835 836 // TODO move as much as possible here from WW8Export! ;-) 837 838 static void CorrectTabStopInSet( SfxItemSet& rSet, sal_uInt16 nAbsLeft ); 839 840 private: 841 /// No copying. 842 MSWordExportBase( const MSWordExportBase& ); 843 /// No copying. 844 MSWordExportBase& operator=( const MSWordExportBase& ); 845 }; 846 847 /// The writer class that gets called for the WW8 filter. 848 class SwWW8Writer: public StgWriter 849 { 850 // friends to get access to m_pExport 851 // FIXME avoid that, this is probably not what we want 852 // (if yes, remove the friends, and provide here a GetExport() method) 853 friend void WW8_WrtRedlineAuthor::Write(Writer &rWrt); 854 855 bool m_bWrtWW8; 856 WW8Export *m_pExport; 857 SfxMedium *mpMedium; 858 859 public: 860 SwWW8Writer( const String& rFltName, const String& rBaseURL ); 861 virtual ~SwWW8Writer(); 862 863 virtual sal_uLong WriteStorage(); 864 virtual sal_uLong WriteMedium( SfxMedium& ); 865 866 // TODO most probably we want to be able to get these in 867 // MSExportFilterBase 868 using Writer::getIDocumentSettingAccess; 869 870 public: 871 #if 1 872 /// Prefer ww::bytes to WW8Bytes, migrate away from the other ones. 873 static void InsUInt16(ww::bytes &rO, sal_uInt16 n); 874 static void InsUInt32(ww::bytes &rO, sal_uInt32 n); 875 static void InsAsString16(ww::bytes &rO, const String& rStr); 876 static void InsAsString8(ww::bytes & O, const String& rStr, 877 rtl_TextEncoding eCodeSet); 878 #endif 879 880 static void InsUInt16( WW8Bytes& rO, sal_uInt16 ); 881 static void InsUInt32( WW8Bytes& rO, sal_uInt32 ); 882 static void InsAsString16( WW8Bytes& rO, const String& ); 883 static void InsAsString8( WW8Bytes& rO, const String& rStr, 884 rtl_TextEncoding eCodeSet ); 885 886 static sal_uLong FillUntil( SvStream& rStrm, sal_uLong nEndPos = 0 ); 887 static void FillCount( SvStream& rStrm, sal_uLong nCount ); 888 WriteShort(SvStream & rStrm,sal_Int16 nVal)889 static void WriteShort( SvStream& rStrm, sal_Int16 nVal ) { rStrm << nVal; } 890 static void WriteShort( SvStream& rStrm, sal_uLong nPos, sal_Int16 nVal ); 891 WriteLong(SvStream & rStrm,sal_Int32 nVal)892 static void WriteLong( SvStream& rStrm, sal_Int32 nVal ) { rStrm << nVal; } 893 static void WriteLong( SvStream& rStrm, sal_uLong nPos, sal_Int32 nVal ); 894 895 static void WriteString16(SvStream& rStrm, const String& rStr, 896 bool bAddZero); 897 static void WriteString8(SvStream& rStrm, const String& rStr, 898 bool bAddZero, rtl_TextEncoding eCodeSet); 899 900 static void WriteString_xstz(SvStream& rStrm, const String& rStr, bool bAddZero); 901 902 bool InitStd97CodecUpdateMedium( ::msfilter::MSCodec_Std97& rCodec ); 903 904 using StgWriter::Write; 905 virtual sal_uLong Write( SwPaM&, SfxMedium&, const String* = 0 ); 906 //Seems not an expected to provide method to access the private member GetMedia()907 SfxMedium* GetMedia(){ return mpMedium;}; 908 909 private: 910 /// No copying. 911 SwWW8Writer(const SwWW8Writer&); 912 /// No copying. 913 SwWW8Writer& operator=(const SwWW8Writer&); 914 }; 915 916 /// Exporter of the binary Word file formats. 917 class WW8Export : public MSWordExportBase 918 { 919 public: 920 WW8Bytes* pO; ///< Buffer 921 WW8Bytes* mpTableAt; ///< Additional buffer for the output of the tables 922 sal_uInt16 mnTableStdAtLen; ///< Standard length of mpTableAt 923 924 SvStream *pTableStrm, *pDataStrm; ///< Streams for WW97 Export 925 926 WW8Fib* pFib; ///< File Information Block 927 WW8Dop* pDop; ///< DOcument Properties 928 WW8_WrPlcFtnEdn *pFtn; ///< Footnotes - structure to remember them, and output 929 WW8_WrPlcFtnEdn *pEdn; ///< Endnotes - structure to remember them, and output 930 WW8_WrPlcSepx* pSepx; ///< Sections/headers/footers 931 932 sal_uInt8 bWrtWW8 : 1; ///< Write WW95 (false) or WW97 (true) file format 933 934 //For i120928,this vector is to record all the graphics of bullets 935 mutable std::vector<const Graphic*> m_vecBulletPic; 936 937 protected: 938 SwWW8Writer *m_pWriter; ///< Pointer to the writer 939 WW8AttributeOutput *m_pAttrOutput; ///< Converting attributes to stream data 940 941 private: 942 SvStorageRef xEscherStg; /// memory leak #i120098#, to hold the reference to unnamed SotStorage obj 943 944 public: 945 /// Access to the attribute output class. 946 virtual AttributeOutputBase& AttrOutput() const; 947 948 /// Access to the sections/headers/footres. 949 virtual MSWordSections& Sections() const; 950 951 /// False for WW6, true for WW8. HackIsWW8OrHigher() const952 virtual bool HackIsWW8OrHigher() const { return bWrtWW8; } 953 954 private: 955 /// Format-dependant part of the actual export. 956 virtual void ExportDocument_Impl(); 957 958 void PrepareStorage(); 959 void WriteFkpPlcUsw(); 960 void WriteMainText(); 961 void StoreDoc1(); 962 void Out_WwNumLvl( sal_uInt8 nWwLevel ); 963 void BuildAnlvBulletBase( WW8_ANLV& rAnlv, sal_uInt8*& rpCh, sal_uInt16& rCharLen, 964 const SwNumFmt& rFmt ); 965 static void BuildAnlvBase( WW8_ANLV& rAnlv, sal_uInt8*& rpCh, sal_uInt16& rCharLen, 966 const SwNumRule& rRul, const SwNumFmt& rFmt, sal_uInt8 nSwLevel ); 967 968 void Out_BorderLine(WW8Bytes& rO, const SvxBorderLine* pLine, 969 sal_uInt16 nDist, sal_uInt16 nSprmNo, bool bShadow); 970 971 /// Output the numbering table. 972 virtual void WriteNumbering(); 973 974 void OutOverrideListTab(); 975 void OutListNamesTab(); 976 977 void RestoreMacroCmds(); 978 979 void InitFontTable(); 980 981 void DoComboBox(com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> xPropSet); 982 void DoCheckBox(com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> xPropSet); 983 984 public: 985 virtual void OutputOlst( const SwNumRule& rRule ); 986 987 /// Setup the pA's info. 988 virtual void SetupSectionPositions( WW8_PdAttrDesc* pA ); 989 990 void Out_SwNumLvl( sal_uInt8 nSwLevel ); 991 void Out_NumRuleAnld( const SwNumRule& rRul, const SwNumFmt& rFmt, 992 sal_uInt8 nSwLevel ); 993 994 bool MiserableFormFieldExportHack(const SwFrmFmt& rFrmFmt); 995 GetOLEExp()996 SvxMSExportOLEObjects& GetOLEExp() { return *pOLEExp; } GetOCXExp()997 SwMSConvertControls& GetOCXExp() { return *pOCXExp; } GetOLEMap()998 WW8OleMaps& GetOLEMap() { return *pOleMap; } 999 void ExportDopTypography(WW8DopTypography &rTypo); 1000 1001 using MSWordExportBase::GetId; GetId(const SvxFontItem & rFont)1002 sal_uInt16 GetId( const SvxFontItem& rFont) 1003 { 1004 return maFontHelper.GetId(rFont); 1005 } 1006 1007 sal_uInt16 AddRedlineAuthor( sal_uInt16 nId ); 1008 1009 void WriteFtnBegin( const SwFmtFtn& rFtn, WW8Bytes* pO = 0 ); 1010 void WritePostItBegin( WW8Bytes* pO = 0 ); 1011 const SvxBrushItem* GetCurrentPageBgBrush() const; 1012 SvxBrushItem TrueFrameBgBrush(const SwFrmFmt &rFlyFmt) const; 1013 1014 /// Output all textframes anchored as character for the winword 7- format. 1015 void OutWW6FlyFrmsInCntnt( const SwTxtNode& rNd ); 1016 1017 void AppendFlyInFlys(const sw::Frame& rFrmFmt, const Point& rNdTopLeft); 1018 void WriteOutliner(const OutlinerParaObject& rOutliner, sal_uInt8 nTyp); 1019 void WriteSdrTextObj(const SdrObject& rObj, sal_uInt8 nTyp); 1020 1021 sal_uInt32 GetSdrOrdNum( const SwFrmFmt& rFmt ) const; 1022 void CreateEscher(); 1023 void WriteEscher(); 1024 1025 bool Out_SwNum(const SwTxtNode* pNd); 1026 1027 /// Write the field 1028 virtual void OutputField( const SwField* pFld, ww::eField eFldType, 1029 const String& rFldCmd, sal_uInt8 nMode = nsFieldFlags::WRITEFIELD_ALL ); 1030 1031 void StartCommentOutput( const String& rName ); 1032 void EndCommentOutput( const String& rName ); 1033 void OutGrf(const sw::Frame &rFrame); 1034 bool TestOleNeedsGraphic(const SwAttrSet& rSet, SvStorageRef xOleStg, 1035 SvStorageRef xObjStg, String &rStorageName, SwOLENode *pOLENd); 1036 1037 virtual void AppendBookmarks( const SwTxtNode& rNd, xub_StrLen nAktPos, xub_StrLen nLen ); 1038 virtual void AppendBookmark( const rtl::OUString& rName, bool bSkip = false ); 1039 1040 virtual void ExportGrfBullet(const SwTxtNode& rNd); 1041 int CollectGrfsOfBullets() const; 1042 void OutGrfBullets(const sw::Frame &rFrame); 1043 int GetGrfIndex(const SvxBrushItem& rBrush); 1044 1045 void MoveFieldMarks(sal_uLong nFrom, sal_uLong nTo); 1046 1047 void WriteAsStringTable(const ::std::vector<String>&, sal_Int32& rfcSttbf, 1048 sal_Int32& rlcbSttbf, sal_uInt16 nExtraLen = 0); 1049 1050 virtual sal_uLong ReplaceCr( sal_uInt8 nChar ); 1051 1052 virtual void WriteCR( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner = ww8::WW8TableNodeInfoInner::Pointer_t() ); 1053 void WriteChar( sal_Unicode c ); 1054 #if 0 1055 sal_uInt16 StartTableFromFrmFmt(WW8Bytes &rAt, const SwFrmFmt *pFmt, 1056 SwTwips &rPageSize); 1057 #endif 1058 1059 void OutSwString(const String&, xub_StrLen nStt, xub_StrLen nLen, 1060 bool bUnicode, rtl_TextEncoding eChrSet); 1061 Fc2Cp(sal_uLong nFc) const1062 WW8_CP Fc2Cp( sal_uLong nFc ) const { return pPiece->Fc2Cp( nFc ); } 1063 1064 // einige z.T. static halb-interne Funktions-Deklarationen 1065 OutSprmBytes(sal_uInt8 * pBytes,sal_uInt16 nSiz)1066 void OutSprmBytes( sal_uInt8* pBytes, sal_uInt16 nSiz ) 1067 { pO->Insert( pBytes, nSiz, pO->Count() ); } 1068 IsUnicode() const1069 inline bool IsUnicode() const { return pPiece->IsUnicode(); } 1070 1071 virtual void SectionBreaksAndFrames( const SwTxtNode& rNode ); 1072 1073 /// Helper method for OutputSectionBreaks() and OutputFollowPageDesc(). 1074 // OD 2007-05-29 #i76300# 1075 virtual void PrepareNewPageDesc( const SfxItemSet* pSet, 1076 const SwNode& rNd, 1077 const SwFmtPageDesc* pNewPgDescFmt = 0, 1078 const SwPageDesc* pNewPgDesc = 0 ); 1079 1080 void Out_SwFmtBox(const SvxBoxItem& rBox, bool bShadow); 1081 void Out_SwFmtTableBox( WW8Bytes& rO, const SvxBoxItem * rBox ); 1082 sal_uInt8 TransCol( const Color& rCol ); 1083 bool TransBrush(const Color& rCol, WW8_SHD& rShd); 1084 WW8_BRC TranslateBorderLine(const SvxBorderLine& pLine, 1085 sal_uInt16 nDist, bool bShadow); 1086 1087 // --> OD 2007-06-04 #i77805# 1088 // new return value indicates, if an inherited outline numbering is suppressed 1089 virtual bool DisallowInheritingOutlineNumbering(const SwFmt &rFmt); 1090 // <-- 1091 GetHdFtIndex() const1092 unsigned int GetHdFtIndex() const { return mnHdFtIndex; } SetHdFtIndex(unsigned int nHdFtIndex)1093 void SetHdFtIndex(unsigned int nHdFtIndex) { mnHdFtIndex = nHdFtIndex; } IncrementHdFtIndex()1094 void IncrementHdFtIndex() { ++mnHdFtIndex; } 1095 1096 static long GetDTTM( const DateTime& rDT ); 1097 1098 /// Convert the SVX numbering type to id 1099 static sal_uInt8 GetNumId( sal_uInt16 eNumType ); 1100 1101 /// Guess the script (asian/western). 1102 virtual bool CollapseScriptsforWordOk( sal_uInt16 nScript, sal_uInt16 nWhich ); 1103 1104 sal_uInt16 DupNumRuleWithLvlStart(const SwNumRule *pRule,sal_uInt8 nLvl,sal_uInt16 nVal); 1105 1106 SwTwips CurrentPageWidth(SwTwips &rLeft, SwTwips &rRight) const; 1107 1108 /// Nasty swap for bidi if necessary 1109 bool MiserableRTLFrmFmtHack(SwTwips &rLeft, SwTwips &rRight, 1110 const sw::Frame &rFrmFmt); 1111 InsUInt16(sal_uInt16 n)1112 void InsUInt16( sal_uInt16 n ) { SwWW8Writer::InsUInt16( *pO, n ); } InsUInt32(sal_uInt32 n)1113 void InsUInt32( sal_uInt32 n ) { SwWW8Writer::InsUInt32( *pO, n ); } InsAsString16(const String & rStr)1114 void InsAsString16( const String& rStr ) 1115 { SwWW8Writer::InsAsString16( *pO, rStr ); } InsAsString8(const String & rStr,rtl_TextEncoding eCodeSet)1116 void InsAsString8( const String& rStr, rtl_TextEncoding eCodeSet ) 1117 { SwWW8Writer::InsAsString8( *pO, rStr, eCodeSet ); } 1118 void WriteStringAsPara( const String& rTxt, sal_uInt16 nStyleId = 0 ); 1119 1120 /// Setup the exporter. 1121 WW8Export( SwWW8Writer *pWriter, 1122 SwDoc *pDocument, SwPaM *pCurrentPam, SwPaM *pOriginalPam, 1123 bool bIsWW8 ); 1124 virtual ~WW8Export(); 1125 1126 virtual void DoComboBox(const rtl::OUString &rName, 1127 const rtl::OUString &rHelp, 1128 const rtl::OUString &ToolTip, 1129 const rtl::OUString &rSelected, 1130 com::sun::star::uno::Sequence<rtl::OUString> &rListItems); 1131 1132 virtual void DoFormText(const SwInputField * pFld); 1133 1134 void GetCurrentItems(WW8Bytes &rItems) const; 1135 1136 /// Write the data of the form field 1137 virtual void WriteFormData( const ::sw::mark::IFieldmark& rFieldmark ); 1138 virtual void WriteHyperlinkData( const ::sw::mark::IFieldmark& rFieldmark ); 1139 1140 /// Fields. 1141 WW8_WrPlcFld* CurrentFieldPlc() const; 1142 GetWriter() const1143 SwWW8Writer& GetWriter() const { return *m_pWriter; } Strm() const1144 SvStream& Strm() const { return m_pWriter->Strm(); } 1145 1146 /// Remember some of the members so that we can recurse in WriteText(). 1147 virtual void SaveData( sal_uLong nStt, sal_uLong nEnd ); 1148 1149 /// Restore what was saved in SaveData(). 1150 virtual void RestoreData(); 1151 1152 /// Output the actual headers and footers. 1153 virtual void WriteHeadersFooters( sal_uInt8 nHeadFootFlags, 1154 const SwFrmFmt& rFmt, const SwFrmFmt& rLeftFmt, const SwFrmFmt& rFirstPageFmt, 1155 sal_uInt8 nBreakCode); 1156 1157 protected: 1158 /// Output SwGrfNode 1159 virtual void OutputGrfNode( const SwGrfNode& ); 1160 1161 /// Output SwOLENode 1162 virtual void OutputOLENode( const SwOLENode& ); 1163 1164 virtual void AppendSection( const SwPageDesc *pPageDesc, const SwSectionFmt* pFmt, sal_uLong nLnNum ); 1165 1166 private: 1167 /// No copying. 1168 WW8Export(const WW8Export&); 1169 /// No copying. 1170 WW8Export& operator=(const WW8Export&); 1171 }; 1172 1173 class WW8_WrPlcSubDoc // Doppel-Plc fuer Foot-/Endnotes und Postits 1174 { 1175 private: 1176 //No copying 1177 WW8_WrPlcSubDoc(const WW8_WrPlcSubDoc&); 1178 WW8_WrPlcSubDoc& operator=(const WW8_WrPlcSubDoc&); 1179 protected: 1180 SvULongs aCps; // PTRARR CP-Pos der Verweise 1181 SvPtrarr aCntnt; // PTRARR von SwFmtFtn/PostIts/.. 1182 WW8_WrPlc0* pTxtPos; // Pos der einzelnen Texte 1183 SvPtrarr aSpareFmts; //a backup for aCntnt: if there's no SdrObject, stores the fmt directly here 1184 1185 WW8_WrPlcSubDoc(); 1186 virtual ~WW8_WrPlcSubDoc(); 1187 1188 bool WriteGenericTxt( WW8Export& rWrt, sal_uInt8 nTTyp, WW8_CP& rCount ); 1189 void WriteGenericPlc( WW8Export& rWrt, sal_uInt8 nTTyp, WW8_FC& rTxtStt, 1190 sal_Int32& rTxtCnt, WW8_FC& rRefStt, sal_Int32& rRefCnt ) const; 1191 1192 virtual const SvULongs* GetShapeIdArr() const; 1193 }; 1194 1195 // Doppel-Plc fuer Footnotes/Endnotes 1196 class WW8_WrPlcFtnEdn : public WW8_WrPlcSubDoc 1197 { 1198 private: 1199 sal_uInt8 nTyp; 1200 1201 //No copying 1202 WW8_WrPlcFtnEdn(const WW8_WrPlcFtnEdn&); 1203 WW8_WrPlcFtnEdn& operator=(WW8_WrPlcFtnEdn &); 1204 public: WW8_WrPlcFtnEdn(sal_uInt8 nTTyp)1205 WW8_WrPlcFtnEdn( sal_uInt8 nTTyp ) : nTyp( nTTyp ) {} 1206 1207 bool WriteTxt( WW8Export& rWrt ); 1208 void WritePlc( WW8Export& rWrt ) const; 1209 1210 void Append( WW8_CP nCp, const SwFmtFtn& rFtn ); 1211 }; 1212 1213 struct WW8_Annotation 1214 { 1215 const OutlinerParaObject* mpRichText; 1216 String msSimpleText; 1217 String msOwner; 1218 DateTime maDateTime; 1219 WW8_Annotation(const SwPostItField* pPostIt); 1220 WW8_Annotation(const SwRedlineData* pRedline); 1221 }; 1222 1223 class WW8_WrPlcAnnotations : public WW8_WrPlcSubDoc // Doppel-Plc fuer PostIts 1224 { 1225 private: 1226 //No copying 1227 WW8_WrPlcAnnotations(const WW8_WrPlcAnnotations&); 1228 WW8_WrPlcAnnotations& operator=(WW8_WrPlcAnnotations&); 1229 std::set<const SwRedlineData*> maProcessedRedlines; 1230 public: WW8_WrPlcAnnotations()1231 WW8_WrPlcAnnotations() {} 1232 ~WW8_WrPlcAnnotations(); 1233 1234 void Append( WW8_CP nCp, const SwPostItField* pPostIt ); 1235 void Append( WW8_CP nCp, const SwRedlineData* pRedLine ); 1236 bool IsNewRedlineComment( const SwRedlineData* pRedLine ); 1237 bool WriteTxt( WW8Export& rWrt ); 1238 void WritePlc( WW8Export& rWrt ) const; 1239 }; 1240 1241 class WW8_WrPlcTxtBoxes : public WW8_WrPlcSubDoc // Doppel-Plc fuer Textboxen 1242 { // Rahmen/DrawTextboxes! 1243 private: 1244 sal_uInt8 nTyp; 1245 SvULongs aShapeIds; // VARARR of ShapeIds for the SwFrmFmts 1246 virtual const SvULongs* GetShapeIdArr() const; 1247 1248 //No copying 1249 WW8_WrPlcTxtBoxes(const WW8_WrPlcTxtBoxes&); 1250 WW8_WrPlcTxtBoxes& operator=(WW8_WrPlcTxtBoxes&); 1251 public: WW8_WrPlcTxtBoxes(sal_uInt8 nTTyp)1252 WW8_WrPlcTxtBoxes( sal_uInt8 nTTyp ) : nTyp( nTTyp ) {} 1253 1254 bool WriteTxt( WW8Export& rWrt ); 1255 void WritePlc( WW8Export& rWrt ) const; 1256 void Append( const SdrObject& rObj, sal_uInt32 nShapeId ); 1257 void Append( const SwFrmFmt* pFmt, sal_uInt32 nShapeId ); Count() const1258 sal_uInt16 Count() const { return aCntnt.Count(); } GetPos(const VoidPtr & p) const1259 sal_uInt16 GetPos( const VoidPtr& p ) const { return aCntnt.GetPos( p ); } 1260 }; 1261 1262 typedef WW8_WrFkp* WW8_FkpPtr; // Plc fuer Chpx und Papx ( incl PN-Plc ) 1263 SV_DECL_PTRARR( WW8_WrFkpPtrs, WW8_FkpPtr, 4, 4 ) 1264 1265 class WW8_WrPlcPn // Plc fuer Page Numbers 1266 { 1267 private: 1268 WW8Export& rWrt; 1269 WW8_WrFkpPtrs aFkps; // PTRARR 1270 sal_uInt16 nFkpStartPage; 1271 ePLCFT ePlc; 1272 bool bWrtWW8; // Fuer Writererkennung 1273 sal_uInt16 nMark; 1274 1275 //No copying 1276 WW8_WrPlcPn(const WW8_WrPlcPn&); 1277 WW8_WrPlcPn& operator=(const WW8_WrPlcPn&); 1278 public: 1279 WW8_WrPlcPn( WW8Export& rWrt, ePLCFT ePl, WW8_FC nStartFc ); 1280 ~WW8_WrPlcPn(); 1281 void AppendFkpEntry(WW8_FC nEndFc,short nVarLen = 0,const sal_uInt8* pSprms = 0); 1282 void WriteFkps(); 1283 void WritePlc(); 1284 sal_uInt8 *CopyLastSprms(sal_uInt8 &rLen); 1285 }; 1286 1287 // class WW8_WrPlc1 ist erstmal nur fuer Felder 1288 class WW8_WrPlc1 1289 { 1290 private: 1291 SvULongs aPos; // PTRARR von CPs 1292 sal_uInt8* pData; // Inhalte ( Strukturen ) 1293 sal_uLong nDataLen; 1294 sal_uInt16 nStructSiz; 1295 1296 //No copying 1297 WW8_WrPlc1(const WW8_WrPlc1&); 1298 WW8_WrPlc1& operator=(const WW8_WrPlc1&); 1299 protected: Count() const1300 sal_uInt16 Count() const { return aPos.Count(); } 1301 void Write( SvStream& rStrm ); 1302 WW8_CP Prev() const; 1303 public: 1304 WW8_WrPlc1( sal_uInt16 nStructSz ); 1305 ~WW8_WrPlc1(); 1306 void Append( WW8_CP nCp, const void* pData ); 1307 void Finish( sal_uLong nLastCp, sal_uLong nStartCp ); 1308 }; 1309 1310 // class WW8_WrPlcFld ist fuer Felder 1311 class WW8_WrPlcFld : public WW8_WrPlc1 1312 { 1313 private: 1314 sal_uInt8 nTxtTyp; 1315 sal_uInt16 nResults; 1316 1317 //No copying 1318 WW8_WrPlcFld(const WW8_WrPlcFld&); 1319 WW8_WrPlcFld& operator=(const WW8_WrPlcFld&); 1320 public: WW8_WrPlcFld(sal_uInt16 nStructSz,sal_uInt8 nTTyp)1321 WW8_WrPlcFld( sal_uInt16 nStructSz, sal_uInt8 nTTyp ) 1322 : WW8_WrPlc1( nStructSz ), nTxtTyp( nTTyp ), nResults(0) 1323 {} 1324 bool Write( WW8Export& rWrt ); ResultAdded()1325 void ResultAdded() { ++nResults; } ResultCount() const1326 sal_uInt16 ResultCount() const { return nResults; } 1327 }; 1328 1329 class WW8_WrMagicTable : public WW8_WrPlc1 1330 { 1331 private: 1332 //No copying 1333 WW8_WrMagicTable(const WW8_WrMagicTable&); 1334 WW8_WrMagicTable& operator=(const WW8_WrMagicTable&); 1335 public: WW8_WrMagicTable()1336 WW8_WrMagicTable() : WW8_WrPlc1( 4 ) {Append(0,0);} 1337 void Append( WW8_CP nCp, sal_uLong nData ); 1338 bool Write( WW8Export& rWrt ); 1339 }; 1340 1341 class GraphicDetails 1342 { 1343 public: 1344 sw::Frame maFly; // Umgebende FlyFrms dazu 1345 sal_uLong mnPos; // FilePos der Grafiken 1346 sal_uInt16 mnWid; // Breite der Grafiken 1347 sal_uInt16 mnHei; // Hoehe der Grafiken 1348 GraphicDetails(const sw::Frame & rFly,sal_uInt16 nWid,sal_uInt16 nHei)1349 GraphicDetails(const sw::Frame &rFly, sal_uInt16 nWid, sal_uInt16 nHei) 1350 : maFly(rFly), mnPos(0), mnWid(nWid), mnHei(nHei) 1351 {} 1352 GraphicDetails& operator=(const GraphicDetails& rOther); 1353 operator ==(const GraphicDetails & rIn) const1354 bool operator==(const GraphicDetails& rIn) const 1355 { 1356 return ( 1357 (mnWid == rIn.mnWid) && (mnHei == rIn.mnHei) && 1358 (maFly.RefersToSameFrameAs(rIn.maFly)) 1359 ); 1360 } 1361 }; 1362 1363 // class SwWW8WrGrf sammelt Grafiken und gibt sie aus 1364 class SwWW8WrGrf 1365 { 1366 private: 1367 /// for access to the variables 1368 WW8Export& rWrt; 1369 1370 std::vector<GraphicDetails> maDetails; 1371 typedef std::vector<GraphicDetails>::iterator myiter; 1372 sal_uInt16 mnIdx; // Index in File-Positionen 1373 1374 void WritePICFHeader(SvStream& rStrm, const sw::Frame &rFly, 1375 sal_uInt16 mm, sal_uInt16 nWidth, sal_uInt16 nHeight, 1376 const SwAttrSet* pAttrSet = 0); 1377 void WriteGraphicNode(SvStream& rStrm, const GraphicDetails &rItem); 1378 void WriteGrfFromGrfNode(SvStream& rStrm, const SwGrfNode &rNd, 1379 const sw::Frame &rFly, sal_uInt16 nWidth, sal_uInt16 nHeight); 1380 1381 void WritePICBulletFHeader(SvStream& rStrm, const Graphic &rGrf, sal_uInt16 mm, sal_uInt16 nWidth, sal_uInt16 nHeight); 1382 void WriteGrfForBullet(SvStream& rStrm, const Graphic &rGrf, sal_uInt16 nWidth, sal_uInt16 nHeight); 1383 1384 //No copying 1385 SwWW8WrGrf(const SwWW8WrGrf&); 1386 SwWW8WrGrf& operator=(const SwWW8WrGrf&); 1387 public: SwWW8WrGrf(WW8Export & rW)1388 SwWW8WrGrf( WW8Export& rW ) : rWrt( rW ), mnIdx( 0 ) {} 1389 void Insert(const sw::Frame &rFly); 1390 void Write(); GetFPos()1391 sal_uLong GetFPos() 1392 { return (mnIdx < maDetails.size()) ? maDetails[mnIdx++].mnPos : 0; } 1393 }; 1394 1395 /** The class MSWordAttrIter is a helper class to build the Fkp.chpx. 1396 This class may be overloaded for output the SwTxtAttrs and the 1397 EditEngineTxtAttrs. 1398 */ 1399 class MSWordAttrIter 1400 { 1401 private: 1402 MSWordAttrIter* pOld; 1403 //No copying 1404 MSWordAttrIter(const MSWordAttrIter&); 1405 MSWordAttrIter& operator=(const MSWordAttrIter&); 1406 protected: 1407 MSWordExportBase& m_rExport; 1408 public: 1409 MSWordAttrIter( MSWordExportBase& rExport ); 1410 virtual ~MSWordAttrIter(); 1411 1412 virtual const SfxPoolItem* HasTextItem( sal_uInt16 nWhich ) const = 0; 1413 virtual const SfxPoolItem& GetItem( sal_uInt16 nWhich ) const = 0; 1414 }; 1415 1416 class MSWord_SdrAttrIter : public MSWordAttrIter 1417 { 1418 private: 1419 const EditTextObject* pEditObj; 1420 const SfxItemPool* pEditPool; 1421 EECharAttribArray aTxtAtrArr; 1422 SvPtrarr aChrTxtAtrArr; 1423 SvUShorts aChrSetArr; 1424 sal_uInt16 nPara; 1425 xub_StrLen nAktSwPos; 1426 xub_StrLen nTmpSwPos; // for HasItem() 1427 rtl_TextEncoding eNdChrSet; 1428 sal_uInt16 nScript; 1429 sal_uInt8 mnTyp; 1430 1431 xub_StrLen SearchNext( xub_StrLen nStartPos ); 1432 void SetCharSet(const EECharAttrib& rTxtAttr, bool bStart); 1433 1434 //No copying 1435 MSWord_SdrAttrIter(const MSWord_SdrAttrIter&); 1436 MSWord_SdrAttrIter& operator=(const MSWord_SdrAttrIter&); 1437 public: 1438 MSWord_SdrAttrIter( MSWordExportBase& rWr, const EditTextObject& rEditObj, 1439 sal_uInt8 nType ); 1440 void NextPara( sal_uInt16 nPar ); 1441 void OutParaAttr(bool bCharAttr); 1442 void OutEEField(const SfxPoolItem& rHt); 1443 1444 bool IsTxtAttr(xub_StrLen nSwPos); 1445 NextPos()1446 void NextPos() { nAktSwPos = SearchNext( nAktSwPos + 1 ); } 1447 1448 void OutAttr( xub_StrLen nSwPos ); 1449 virtual const SfxPoolItem* HasTextItem( sal_uInt16 nWhich ) const; 1450 virtual const SfxPoolItem& GetItem( sal_uInt16 nWhich ) const; 1451 bool OutAttrWithRange(xub_StrLen nPos); WhereNext() const1452 xub_StrLen WhereNext() const { return nAktSwPos; } 1453 rtl_TextEncoding GetNextCharSet() const; GetNodeCharSet() const1454 rtl_TextEncoding GetNodeCharSet() const { return eNdChrSet; } 1455 }; 1456 1457 /// Class to collect and output the styles table. 1458 class MSWordStyles 1459 { 1460 MSWordExportBase& m_rExport; 1461 SwFmt** pFmtA; 1462 sal_uInt16 nUsedSlots; 1463 1464 /// Create the style table, called from the constructor. 1465 void BuildStylesTable(); 1466 1467 /// Get slot number during building the style table. 1468 sal_uInt16 BuildGetSlot( const SwFmt& rFmt ); 1469 1470 /// Return information about one style. 1471 void GetStyleData( SwFmt* pFmt, bool& bFmtColl, sal_uInt16& nBase, sal_uInt16& nNext ); 1472 1473 /// Outputs attributes of one style. 1474 void WriteProperties( const SwFmt* pFmt, bool bPap, sal_uInt16 nPos, bool bInsDefCharSiz ); 1475 1476 sal_uInt16 GetWWId( const SwFmt& rFmt ) const; 1477 1478 void SetStyleDefaults( const SwFmt& rFmt, bool bPap ); 1479 1480 /// Outputs one style - called (in a loop) from OutputStylesTable(). 1481 void OutputStyle( SwFmt* pFmt, sal_uInt16 nPos ); 1482 1483 // No copying 1484 MSWordStyles( const MSWordStyles& ); 1485 MSWordStyles& operator=( const MSWordStyles& ); 1486 1487 public: 1488 MSWordStyles( MSWordExportBase& rExport ); 1489 ~MSWordStyles(); 1490 1491 /// Output the styles table. 1492 void OutputStylesTable(); 1493 1494 /// Get id of the style (rFmt). 1495 sal_uInt16 GetSlot( const SwFmt& rFmt ) const; 1496 GetSwFmt()1497 SwFmt* GetSwFmt() { return (*pFmtA); } 1498 }; 1499 1500 sal_Int16 GetWordFirstLineOffset(const SwNumFmt &rFmt); 1501 //A bit of a bag on the side for now 1502 String FieldString(ww::eField eIndex); 1503 String BookmarkToWord(const String &rBookmark); 1504 1505 class WW8SHDLong 1506 { 1507 sal_uInt32 m_cvFore; 1508 sal_uInt32 m_cvBack; 1509 sal_uInt16 m_ipat; 1510 1511 public: WW8SHDLong()1512 WW8SHDLong() : m_cvFore(0), m_cvBack(0), m_ipat(0) {} ~WW8SHDLong()1513 virtual ~WW8SHDLong() {} 1514 1515 void Write(WW8Export & rExport); setCvFore(sal_uInt32 cvFore)1516 void setCvFore(sal_uInt32 cvFore) { m_cvFore = cvFore; } setCvBack(sal_uInt32 cvBack)1517 void setCvBack(sal_uInt32 cvBack) { m_cvBack = cvBack; } setIPat(sal_uInt16 ipat)1518 void setIPat(sal_uInt16 ipat) { m_ipat = ipat; } 1519 }; 1520 1521 #endif // _WRTWW8_HXX 1522 1523 /* vi:set tabstop=4 shiftwidth=4 expandtab: */ 1524