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 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_sw.hxx" 26 27 #include <doc.hxx> 28 #include <UndoManager.hxx> 29 #include <hintids.hxx> 30 31 #include <tools/shl.hxx> 32 #include <tools/globname.hxx> 33 #include <svx/svxids.hrc> 34 #include <com/sun/star/i18n/WordType.hdl> 35 #include <com/sun/star/i18n/ForbiddenCharacters.hdl> 36 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 37 #include <com/sun/star/beans/NamedValue.hpp> 38 #include <com/sun/star/beans/XPropertySet.hpp> 39 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> 40 #include <com/sun/star/document/XDocumentProperties.hpp> 41 #include <comphelper/processfactory.hxx> 42 #include <tools/urlobj.hxx> 43 #include <tools/poly.hxx> 44 #include <tools/multisel.hxx> 45 #include <rtl/ustring.hxx> 46 #include <vcl/virdev.hxx> 47 #include <svl/itemiter.hxx> 48 #include <svl/poolitem.hxx> 49 #include <unotools/syslocale.hxx> 50 #include <sfx2/printer.hxx> 51 #include <editeng/keepitem.hxx> 52 #include <editeng/cscoitem.hxx> 53 #include <editeng/brkitem.hxx> 54 #include <sfx2/linkmgr.hxx> 55 #include <editeng/forbiddencharacterstable.hxx> 56 #include <svx/svdmodel.hxx> 57 #include <editeng/pbinitem.hxx> 58 #include <unotools/charclass.hxx> 59 #include <unotools/localedatawrapper.hxx> 60 61 #include <swatrset.hxx> 62 #include <swmodule.hxx> 63 #include <fmtpdsc.hxx> 64 #include <fmtanchr.hxx> 65 #include <fmtrfmrk.hxx> 66 #include <fmtinfmt.hxx> 67 #include <fmtfld.hxx> 68 #include <txtfld.hxx> 69 #include <dbfld.hxx> 70 #include <txtinet.hxx> 71 #include <txtrfmrk.hxx> 72 #include <frmatr.hxx> 73 #include <linkenum.hxx> 74 #include <errhdl.hxx> 75 #include <pagefrm.hxx> 76 #include <rootfrm.hxx> 77 #include <swtable.hxx> 78 #include <pam.hxx> 79 #include <ndtxt.hxx> 80 #include <swundo.hxx> // fuer die UndoIds 81 #include <UndoCore.hxx> 82 #include <UndoInsert.hxx> 83 #include <UndoSplitMove.hxx> 84 #include <UndoTable.hxx> 85 #include <pagedesc.hxx> //DTor 86 #include <breakit.hxx> 87 #include <ndole.hxx> 88 #include <ndgrf.hxx> 89 #include <rolbck.hxx> // Undo-Attr 90 #include <doctxm.hxx> // fuer die Verzeichnisse 91 #include <grfatr.hxx> 92 #include <poolfmt.hxx> // PoolVorlagen-Id's 93 #include <mvsave.hxx> // fuer Server-Funktionalitaet 94 #include <SwGrammarMarkUp.hxx> 95 #include <scriptinfo.hxx> 96 #include <acorrect.hxx> // Autokorrektur 97 #include <mdiexp.hxx> // Statusanzeige 98 #include <docstat.hxx> 99 #include <docary.hxx> 100 #include <redline.hxx> 101 #include <fldupde.hxx> 102 #include <swbaslnk.hxx> 103 #include <printdata.hxx> 104 #include <cmdid.h> // fuer den dflt - Printer in SetJob 105 #include <statstr.hrc> // StatLine-String 106 #include <comcore.hrc> 107 #include <SwUndoTOXChange.hxx> 108 #include <SwUndoFmt.hxx> 109 #include <unocrsr.hxx> 110 #include <docsh.hxx> 111 #include <viewopt.hxx> 112 #include <docfld.hxx> // _SetGetExpFld 113 #include <docufld.hxx> // SwPostItField 114 #include <viewsh.hxx> 115 #include <shellres.hxx> 116 #include <txtfrm.hxx> 117 #include <attrhint.hxx> 118 119 #include <wdocsh.hxx> // SwWebDocShell 120 #include <prtopt.hxx> // SwPrintOptions 121 122 #include <vector> 123 #include <map> 124 125 #include <osl/diagnose.h> 126 #include <osl/interlck.h> 127 #include <vbahelper/vbaaccesshelper.hxx> 128 129 #include "switerator.hxx" 130 131 /* @@@MAINTAINABILITY-HORROR@@@ 132 Probably unwanted dependency on SwDocShell 133 */ 134 // --> OD 2005-08-29 #125370# 135 #include <layouter.hxx> 136 // <-- 137 138 using namespace ::com::sun::star; 139 using ::rtl::OUString; 140 141 142 // Seiten-Deskriptoren 143 SV_IMPL_PTRARR(SwPageDescs,SwPageDescPtr); 144 // Verzeichnisse 145 SV_IMPL_PTRARR( SwTOXTypes, SwTOXTypePtr ) 146 // FeldTypen 147 SV_IMPL_PTRARR( SwFldTypes, SwFldTypePtr) 148 149 /** IInterface 150 */ 151 sal_Int32 SwDoc::acquire() 152 { 153 OSL_ASSERT(mReferenceCount >= 0 && "Negative reference count detected! This is a sign for unbalanced acquire/release calls."); 154 return osl_incrementInterlockedCount(&mReferenceCount); 155 } 156 157 sal_Int32 SwDoc::release() 158 { 159 OSL_PRECOND(mReferenceCount >= 1, "Object is already released! Releasing it again leads to a negative reference count."); 160 return osl_decrementInterlockedCount(&mReferenceCount); 161 } 162 163 sal_Int32 SwDoc::getReferenceCount() const 164 { 165 OSL_ASSERT(mReferenceCount >= 0 && "Negative reference count detected! This is a sign for unbalanced acquire/release calls."); 166 return mReferenceCount; 167 } 168 169 /** IDocumentSettingAccess 170 */ 171 bool SwDoc::get(/*[in]*/ DocumentSettingId id) const 172 { 173 switch (id) 174 { 175 // COMPATIBILITY FLAGS START 176 case PARA_SPACE_MAX: return mbParaSpaceMax; //(n8Dummy1 & DUMMY_PARASPACEMAX); 177 case PARA_SPACE_MAX_AT_PAGES: return mbParaSpaceMaxAtPages; //(n8Dummy1 & DUMMY_PARASPACEMAX_AT_PAGES); 178 case TAB_COMPAT: return mbTabCompat; //(n8Dummy1 & DUMMY_TAB_COMPAT); 179 case ADD_FLY_OFFSETS: return mbAddFlyOffsets; //(n8Dummy2 & DUMMY_ADD_FLY_OFFSETS); 180 case ADD_EXT_LEADING: return mbAddExternalLeading; //(n8Dummy2 & DUMMY_ADD_EXTERNAL_LEADING); 181 case USE_VIRTUAL_DEVICE: return mbUseVirtualDevice; //(n8Dummy1 & DUMMY_USE_VIRTUAL_DEVICE); 182 case USE_HIRES_VIRTUAL_DEVICE: return mbUseHiResolutionVirtualDevice; //(n8Dummy2 & DUMMY_USE_HIRES_VIR_DEV); 183 case OLD_NUMBERING: return mbOldNumbering; 184 case OLD_LINE_SPACING: return mbOldLineSpacing; 185 case ADD_PARA_SPACING_TO_TABLE_CELLS: return mbAddParaSpacingToTableCells; 186 case USE_FORMER_OBJECT_POS: return mbUseFormerObjectPos; 187 case USE_FORMER_TEXT_WRAPPING: return mbUseFormerTextWrapping; 188 case CONSIDER_WRAP_ON_OBJECT_POSITION: return mbConsiderWrapOnObjPos; 189 case DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK: return mbDoNotJustifyLinesWithManualBreak; 190 case IGNORE_FIRST_LINE_INDENT_IN_NUMBERING: return mbIgnoreFirstLineIndentInNumbering; 191 case OUTLINE_LEVEL_YIELDS_OUTLINE_RULE: return mbOutlineLevelYieldsOutlineRule; 192 case TABLE_ROW_KEEP: return mbTableRowKeep; 193 case IGNORE_TABS_AND_BLANKS_FOR_LINE_CALCULATION: return mbIgnoreTabsAndBlanksForLineCalculation; 194 case DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE: return mbDoNotCaptureDrawObjsOnPage; 195 // --> OD 2006-08-25 #i68949# 196 case CLIP_AS_CHARACTER_ANCHORED_WRITER_FLY_FRAME: return mbClipAsCharacterAnchoredWriterFlyFrames; 197 // <-- 198 case UNIX_FORCE_ZERO_EXT_LEADING: return mbUnixForceZeroExtLeading; 199 case USE_OLD_PRINTER_METRICS: return mbOldPrinterMetrics; 200 case TABS_RELATIVE_TO_INDENT : return mbTabRelativeToIndent; 201 case PROTECT_FORM: return mbProtectForm; 202 // --> OD 2008-06-05 #i89181# 203 case TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST: return mbTabAtLeftIndentForParagraphsInList; 204 // <-- 205 // COMPATIBILITY FLAGS END 206 207 case BROWSE_MODE: return mbLastBrowseMode; // Attention: normally the ViewShell has to be asked! 208 case HTML_MODE: return mbHTMLMode; 209 case GLOBAL_DOCUMENT: return mbIsGlobalDoc; 210 case GLOBAL_DOCUMENT_SAVE_LINKS: return mbGlblDocSaveLinks; 211 case LABEL_DOCUMENT: return mbIsLabelDoc; 212 case PURGE_OLE: return mbPurgeOLE; 213 case KERN_ASIAN_PUNCTUATION: return mbKernAsianPunctuation; 214 case DO_NOT_RESET_PARA_ATTRS_FOR_NUM_FONT: return mbDoNotResetParaAttrsForNumFont; 215 case MATH_BASELINE_ALIGNMENT: return mbMathBaselineAlignment; 216 default: 217 ASSERT(false, "Invalid setting id"); 218 } 219 return false; 220 } 221 222 void SwDoc::set(/*[in]*/ DocumentSettingId id, /*[in]*/ bool value) 223 { 224 switch (id) 225 { 226 // COMPATIBILITY FLAGS START 227 case PARA_SPACE_MAX: 228 mbParaSpaceMax = value; 229 break; 230 case PARA_SPACE_MAX_AT_PAGES: 231 mbParaSpaceMaxAtPages = value; 232 break; 233 case TAB_COMPAT: 234 mbTabCompat = value; 235 break; 236 case ADD_FLY_OFFSETS: 237 mbAddFlyOffsets = value; 238 break; 239 case ADD_EXT_LEADING: 240 mbAddExternalLeading = value; 241 break; 242 case USE_VIRTUAL_DEVICE: 243 mbUseVirtualDevice = value; 244 break; 245 case USE_HIRES_VIRTUAL_DEVICE: 246 mbUseHiResolutionVirtualDevice = value; 247 break; 248 case OLD_NUMBERING: 249 if (mbOldNumbering != value) 250 { 251 mbOldNumbering = value; 252 253 const SwNumRuleTbl& rNmTbl = GetNumRuleTbl(); 254 for( sal_uInt16 n = 0; n < rNmTbl.Count(); ++n ) 255 rNmTbl[n]->SetInvalidRule(sal_True); 256 257 UpdateNumRule(); 258 259 if (pOutlineRule) 260 { 261 pOutlineRule->Validate(); 262 // --> OD 2005-10-21 - counting of phantoms depends on <IsOldNumbering()> 263 pOutlineRule->SetCountPhantoms( !mbOldNumbering ); 264 // <-- 265 } 266 } 267 break; 268 case OLD_LINE_SPACING: 269 mbOldLineSpacing = value; 270 break; 271 case ADD_PARA_SPACING_TO_TABLE_CELLS: 272 mbAddParaSpacingToTableCells = value; 273 break; 274 case USE_FORMER_OBJECT_POS: 275 mbUseFormerObjectPos = value; 276 break; 277 case USE_FORMER_TEXT_WRAPPING: 278 mbUseFormerTextWrapping = value; 279 break; 280 case CONSIDER_WRAP_ON_OBJECT_POSITION: 281 mbConsiderWrapOnObjPos = value; 282 break; 283 case DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK: 284 mbDoNotJustifyLinesWithManualBreak = value; 285 break; 286 case IGNORE_FIRST_LINE_INDENT_IN_NUMBERING: 287 mbIgnoreFirstLineIndentInNumbering = value; 288 break; 289 290 case OUTLINE_LEVEL_YIELDS_OUTLINE_RULE: 291 mbOutlineLevelYieldsOutlineRule = value; 292 break; 293 294 case TABLE_ROW_KEEP: 295 mbTableRowKeep = value; 296 break; 297 298 case IGNORE_TABS_AND_BLANKS_FOR_LINE_CALCULATION: 299 mbIgnoreTabsAndBlanksForLineCalculation = value; 300 break; 301 302 case DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE: 303 mbDoNotCaptureDrawObjsOnPage = value; 304 break; 305 306 // --> OD 2006-08-25 #i68949# 307 case CLIP_AS_CHARACTER_ANCHORED_WRITER_FLY_FRAME: 308 mbClipAsCharacterAnchoredWriterFlyFrames = value; 309 break; 310 // <-- 311 case UNIX_FORCE_ZERO_EXT_LEADING: 312 mbUnixForceZeroExtLeading = value; 313 break; 314 case PROTECT_FORM: 315 mbProtectForm = value; 316 break; 317 318 case USE_OLD_PRINTER_METRICS: 319 mbOldPrinterMetrics = value; 320 break; 321 case TABS_RELATIVE_TO_INDENT: 322 mbTabRelativeToIndent = value; 323 break; 324 // --> OD 2008-06-05 #i89181# 325 case TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST: 326 mbTabAtLeftIndentForParagraphsInList = value; 327 break; 328 // <-- 329 // COMPATIBILITY FLAGS END 330 331 case BROWSE_MODE: //can be used temporary (load/save) when no ViewShell is avaiable 332 mbLastBrowseMode = value; 333 break; 334 case HTML_MODE: 335 mbHTMLMode = value; 336 break; 337 case GLOBAL_DOCUMENT: 338 mbIsGlobalDoc = value; 339 break; 340 case GLOBAL_DOCUMENT_SAVE_LINKS: 341 mbGlblDocSaveLinks = value; 342 break; 343 case LABEL_DOCUMENT: 344 mbIsLabelDoc = value; 345 break; 346 case PURGE_OLE: 347 mbPurgeOLE = value; 348 break; 349 case KERN_ASIAN_PUNCTUATION: 350 mbKernAsianPunctuation = value; 351 break; 352 case DO_NOT_RESET_PARA_ATTRS_FOR_NUM_FONT: 353 mbDoNotResetParaAttrsForNumFont = value; 354 break; 355 case MATH_BASELINE_ALIGNMENT: 356 mbMathBaselineAlignment = value; 357 break; 358 default: 359 ASSERT(false, "Invalid setting id"); 360 } 361 } 362 363 const i18n::ForbiddenCharacters* 364 SwDoc::getForbiddenCharacters(/*[in]*/ sal_uInt16 nLang, /*[in]*/ bool bLocaleData ) const 365 { 366 const i18n::ForbiddenCharacters* pRet = 0; 367 if( xForbiddenCharsTable.isValid() ) 368 pRet = xForbiddenCharsTable->GetForbiddenCharacters( nLang, sal_False ); 369 if( bLocaleData && !pRet && pBreakIt ) 370 pRet = &pBreakIt->GetForbidden( (LanguageType)nLang ); 371 return pRet; 372 } 373 374 void SwDoc::setForbiddenCharacters(/*[in]*/ sal_uInt16 nLang, 375 /*[in]*/ const com::sun::star::i18n::ForbiddenCharacters& rFChars ) 376 { 377 if( !xForbiddenCharsTable.isValid() ) 378 { 379 uno::Reference< 380 lang::XMultiServiceFactory > xMSF = 381 ::comphelper::getProcessServiceFactory(); 382 xForbiddenCharsTable = new SvxForbiddenCharactersTable( xMSF ); 383 } 384 xForbiddenCharsTable->SetForbiddenCharacters( nLang, rFChars ); 385 if( pDrawModel ) 386 { 387 pDrawModel->SetForbiddenCharsTable( xForbiddenCharsTable ); 388 if( !mbInReading ) 389 pDrawModel->ReformatAllTextObjects(); 390 } 391 392 SwRootFrm* pTmpRoot = GetCurrentLayout(); 393 if( pTmpRoot && !mbInReading ) 394 { 395 pTmpRoot->StartAllAction(); 396 std::set<SwRootFrm*> aAllLayouts = GetAllLayouts(); 397 std::for_each( aAllLayouts.begin(), aAllLayouts.end(), std::bind2nd(std::mem_fun(&SwRootFrm::InvalidateAllCntnt), INV_SIZE)); 398 pTmpRoot->EndAllAction(); 399 }//swmod 080310 400 SetModified(); 401 } 402 403 vos::ORef<SvxForbiddenCharactersTable>& SwDoc::getForbiddenCharacterTable() 404 { 405 if( !xForbiddenCharsTable.isValid() ) 406 { 407 uno::Reference< 408 lang::XMultiServiceFactory > xMSF = 409 ::comphelper::getProcessServiceFactory(); 410 xForbiddenCharsTable = new SvxForbiddenCharactersTable( xMSF ); 411 } 412 return xForbiddenCharsTable; 413 } 414 415 const vos::ORef<SvxForbiddenCharactersTable>& SwDoc::getForbiddenCharacterTable() const 416 { 417 return xForbiddenCharsTable; 418 } 419 420 sal_uInt16 SwDoc::getLinkUpdateMode( /*[in]*/bool bGlobalSettings ) const 421 { 422 sal_uInt16 nRet = nLinkUpdMode; 423 if( bGlobalSettings && GLOBALSETTING == nRet ) 424 nRet = SW_MOD()->GetLinkUpdMode(get(IDocumentSettingAccess::HTML_MODE)); 425 return nRet; 426 } 427 428 void SwDoc::setLinkUpdateMode( /*[in]*/sal_uInt16 eMode ) 429 { 430 nLinkUpdMode = eMode; 431 } 432 433 SwFldUpdateFlags SwDoc::getFieldUpdateFlags( /*[in]*/bool bGlobalSettings ) const 434 { 435 SwFldUpdateFlags eRet = eFldUpdMode; 436 if( bGlobalSettings && AUTOUPD_GLOBALSETTING == eRet ) 437 eRet = SW_MOD()->GetFldUpdateFlags(get(IDocumentSettingAccess::HTML_MODE)); 438 return eRet; 439 } 440 441 void SwDoc::setFieldUpdateFlags(/*[in]*/SwFldUpdateFlags eMode ) 442 { 443 eFldUpdMode = eMode; 444 } 445 446 SwCharCompressType SwDoc::getCharacterCompressionType() const 447 { 448 return eChrCmprType; 449 } 450 451 void SwDoc::setCharacterCompressionType( /*[in]*/SwCharCompressType n ) 452 { 453 if( eChrCmprType != n ) 454 { 455 eChrCmprType = n; 456 if( pDrawModel ) 457 { 458 pDrawModel->SetCharCompressType( static_cast<sal_uInt16>(n) ); 459 if( !mbInReading ) 460 pDrawModel->ReformatAllTextObjects(); 461 } 462 463 SwRootFrm* pTmpRoot = GetCurrentLayout(); 464 if( pTmpRoot && !mbInReading ) 465 { 466 pTmpRoot->StartAllAction(); 467 std::set<SwRootFrm*> aAllLayouts = GetAllLayouts(); 468 std::for_each( aAllLayouts.begin(), aAllLayouts.end(), std::bind2nd(std::mem_fun(&SwRootFrm::InvalidateAllCntnt), INV_SIZE)); 469 pTmpRoot->EndAllAction(); 470 }//swmod 080310 471 SetModified(); 472 } 473 } 474 475 /** IDocumentDeviceAccess 476 */ 477 SfxPrinter* SwDoc::getPrinter(/*[in]*/ bool bCreate ) const 478 { 479 SfxPrinter* pRet = 0; 480 if ( !bCreate || pPrt ) 481 pRet = pPrt; 482 else 483 pRet = &CreatePrinter_(); 484 485 return pRet; 486 } 487 488 void SwDoc::setPrinter(/*[in]*/ SfxPrinter *pP,/*[in]*/ bool bDeleteOld,/*[in]*/ bool bCallPrtDataChanged ) 489 { 490 if ( pP != pPrt ) 491 { 492 if ( bDeleteOld ) 493 delete pPrt; 494 pPrt = pP; 495 496 // our printer should always use TWIP. Don't rely on this being set in ViewShell::InitPrt, there 497 // are situations where this isn't called. 498 // #i108712# / 2010-02-26 / frank.schoenheit@sun.com 499 if ( pPrt ) 500 { 501 MapMode aMapMode( pPrt->GetMapMode() ); 502 aMapMode.SetMapUnit( MAP_TWIP ); 503 pPrt->SetMapMode( aMapMode ); 504 } 505 506 if ( pDrawModel && !get( IDocumentSettingAccess::USE_VIRTUAL_DEVICE ) ) 507 pDrawModel->SetRefDevice( pPrt ); 508 } 509 510 if ( bCallPrtDataChanged && 511 // --> FME 2005-01-21 #i41075# Do not call PrtDataChanged() if we do not 512 // use the printer for formatting: 513 !get(IDocumentSettingAccess::USE_VIRTUAL_DEVICE) ) 514 // <-- 515 PrtDataChanged(); 516 } 517 518 VirtualDevice* SwDoc::getVirtualDevice(/*[in]*/ bool bCreate ) const 519 { 520 VirtualDevice* pRet = 0; 521 if ( !bCreate || pVirDev ) 522 pRet = pVirDev; 523 else 524 pRet = &CreateVirtualDevice_(); 525 526 return pRet; 527 } 528 529 void SwDoc::setVirtualDevice(/*[in]*/ VirtualDevice* pVd,/*[in]*/ bool bDeleteOld, /*[in]*/ bool ) 530 { 531 if ( pVirDev != pVd ) 532 { 533 if ( bDeleteOld ) 534 delete pVirDev; 535 pVirDev = pVd; 536 537 if ( pDrawModel && get( IDocumentSettingAccess::USE_VIRTUAL_DEVICE ) ) 538 pDrawModel->SetRefDevice( pVirDev ); 539 } 540 } 541 542 OutputDevice* SwDoc::getReferenceDevice(/*[in]*/ bool bCreate ) const 543 { 544 OutputDevice* pRet = 0; 545 if ( !get(IDocumentSettingAccess::USE_VIRTUAL_DEVICE) ) 546 { 547 pRet = getPrinter( bCreate ); 548 549 if ( bCreate && !pPrt->IsValid() ) 550 { 551 pRet = getVirtualDevice( sal_True ); 552 } 553 } 554 else 555 { 556 pRet = getVirtualDevice( bCreate ); 557 } 558 559 return pRet; 560 } 561 562 void SwDoc::setReferenceDeviceType(/*[in]*/ bool bNewVirtual,/*[in]*/ bool bNewHiRes ) 563 { 564 if ( get(IDocumentSettingAccess::USE_VIRTUAL_DEVICE) != bNewVirtual || 565 get(IDocumentSettingAccess::USE_HIRES_VIRTUAL_DEVICE) != bNewHiRes ) 566 { 567 if ( bNewVirtual ) 568 { 569 VirtualDevice* pMyVirDev = getVirtualDevice( true ); 570 if ( !bNewHiRes ) 571 pMyVirDev->SetReferenceDevice( VirtualDevice::REFDEV_MODE06 ); 572 else 573 pMyVirDev->SetReferenceDevice( VirtualDevice::REFDEV_MODE_MSO1 ); 574 575 if( pDrawModel ) 576 pDrawModel->SetRefDevice( pMyVirDev ); 577 } 578 else 579 { 580 // --> FME 2005-01-21 #i41075# 581 // We have to take care that a printer exists before calling 582 // PrtDataChanged() in order to prevent that PrtDataChanged() 583 // triggers this funny situation: 584 // getReferenceDevice()->getPrinter()->CreatePrinter_() 585 // ->setPrinter()-> PrtDataChanged() 586 SfxPrinter* pPrinter = getPrinter( true ); 587 // <-- 588 if( pDrawModel ) 589 pDrawModel->SetRefDevice( pPrinter ); 590 } 591 592 set(IDocumentSettingAccess::USE_VIRTUAL_DEVICE, bNewVirtual ); 593 set(IDocumentSettingAccess::USE_HIRES_VIRTUAL_DEVICE, bNewHiRes ); 594 PrtDataChanged(); 595 SetModified(); 596 } 597 } 598 599 const JobSetup* SwDoc::getJobsetup() const 600 { 601 return pPrt ? &pPrt->GetJobSetup() : 0; 602 } 603 604 void SwDoc::setJobsetup(/*[in]*/ const JobSetup &rJobSetup ) 605 { 606 sal_Bool bCheckPageDescs = 0 == pPrt; 607 sal_Bool bDataChanged = sal_False; 608 609 if ( pPrt ) 610 { 611 if ( pPrt->GetName() == rJobSetup.GetPrinterName() ) 612 { 613 if ( pPrt->GetJobSetup() != rJobSetup ) 614 { 615 pPrt->SetJobSetup( rJobSetup ); 616 bDataChanged = sal_True; 617 } 618 } 619 else 620 delete pPrt, pPrt = 0; 621 } 622 623 if( !pPrt ) 624 { 625 //Das ItemSet wird vom Sfx geloescht! 626 SfxItemSet *pSet = new SfxItemSet( GetAttrPool(), 627 FN_PARAM_ADDPRINTER, FN_PARAM_ADDPRINTER, 628 SID_HTML_MODE, SID_HTML_MODE, 629 SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN, 630 SID_PRINTER_CHANGESTODOC, SID_PRINTER_CHANGESTODOC, 631 0 ); 632 SfxPrinter *p = new SfxPrinter( pSet, rJobSetup ); 633 if ( bCheckPageDescs ) 634 setPrinter( p, true, true ); 635 else 636 { 637 pPrt = p; 638 bDataChanged = sal_True; 639 } 640 } 641 if ( bDataChanged && !get(IDocumentSettingAccess::USE_VIRTUAL_DEVICE) ) 642 PrtDataChanged(); 643 } 644 645 const SwPrintData & SwDoc::getPrintData() const 646 { 647 if(!pPrtData) 648 { 649 SwDoc * pThis = const_cast< SwDoc * >(this); 650 pThis->pPrtData = new SwPrintData; 651 652 // SwPrintData should be initialized from the configuration, 653 // the respective config item is implememted by SwPrintOptions which 654 // is also derived from SwPrintData 655 const SwDocShell *pDocSh = GetDocShell(); 656 DBG_ASSERT( pDocSh, "pDocSh is 0, can't determine if this is a WebDoc or not" ); 657 bool bWeb = 0 != dynamic_cast< const SwWebDocShell * >(pDocSh); 658 SwPrintOptions aPrintOptions( bWeb ); 659 *pThis->pPrtData = aPrintOptions; 660 } 661 return *pPrtData; 662 } 663 664 void SwDoc::setPrintData(/*[in]*/ const SwPrintData& rPrtData ) 665 { 666 if(!pPrtData) 667 pPrtData = new SwPrintData; 668 *pPrtData = rPrtData; 669 } 670 671 /** Implementations the next Interface here 672 */ 673 674 /* 675 * Dokumenteditieren (Doc-SS) zum Fuellen des Dokuments 676 * durch den RTF Parser und fuer die EditShell. 677 */ 678 void SwDoc::ChgDBData(const SwDBData& rNewData) 679 { 680 if( rNewData != aDBData ) 681 { 682 aDBData = rNewData; 683 SetModified(); 684 } 685 GetSysFldType(RES_DBNAMEFLD)->UpdateFlds(); 686 } 687 688 bool SwDoc::SplitNode( const SwPosition &rPos, bool bChkTableStart ) 689 { 690 SwCntntNode *pNode = rPos.nNode.GetNode().GetCntntNode(); 691 if(0 == pNode) 692 return false; 693 694 { 695 // Bug 26675: DataChanged vorm loeschen verschicken, dann bekommt 696 // man noch mit, welche Objecte sich im Bereich befinden. 697 // Danach koennen sie vor/hinter der Position befinden. 698 SwDataChanged aTmp( this, rPos, 0 ); 699 } 700 701 SwUndoSplitNode* pUndo = 0; 702 if (GetIDocumentUndoRedo().DoesUndo()) 703 { 704 GetIDocumentUndoRedo().ClearRedo(); 705 // einfuegen vom Undo-Object, z.Z. nur beim TextNode 706 if( pNode->IsTxtNode() ) 707 { 708 pUndo = new SwUndoSplitNode( this, rPos, bChkTableStart ); 709 GetIDocumentUndoRedo().AppendUndo(pUndo); 710 } 711 } 712 713 //JP 28.01.97: Sonderfall fuer SplitNode am Tabellenanfang: 714 // steht die am Doc/Fly/Footer/..-Anfang oder direkt 715 // hinter einer Tabelle, dann fuege davor 716 // einen Absatz ein 717 if( bChkTableStart && !rPos.nContent.GetIndex() && pNode->IsTxtNode() ) 718 { 719 sal_uLong nPrevPos = rPos.nNode.GetIndex() - 1; 720 const SwTableNode* pTblNd; 721 const SwNode* pNd = GetNodes()[ nPrevPos ]; 722 if( pNd->IsStartNode() && 723 SwTableBoxStartNode == ((SwStartNode*)pNd)->GetStartNodeType() && 724 0 != ( pTblNd = GetNodes()[ --nPrevPos ]->GetTableNode() ) && 725 ((( pNd = GetNodes()[ --nPrevPos ])->IsStartNode() && 726 SwTableBoxStartNode != ((SwStartNode*)pNd)->GetStartNodeType() ) 727 || ( pNd->IsEndNode() && pNd->StartOfSectionNode()->IsTableNode() ) 728 || pNd->IsCntntNode() )) 729 { 730 if( pNd->IsCntntNode() ) 731 { 732 //JP 30.04.99 Bug 65660: 733 // ausserhalb des normalen BodyBereiches gibt es keine 734 // Seitenumbrueche, also ist das hier kein gueltige 735 // Bedingung fuers einfuegen eines Absatzes 736 if( nPrevPos < GetNodes().GetEndOfExtras().GetIndex() ) 737 pNd = 0; 738 else 739 { 740 // Dann nur, wenn die Tabelle Umbrueche traegt! 741 const SwFrmFmt* pFrmFmt = pTblNd->GetTable().GetFrmFmt(); 742 if( SFX_ITEM_SET != pFrmFmt->GetItemState(RES_PAGEDESC, sal_False) && 743 SFX_ITEM_SET != pFrmFmt->GetItemState( RES_BREAK, sal_False ) ) 744 pNd = 0; 745 } 746 } 747 748 if( pNd ) 749 { 750 SwTxtNode* pTxtNd = GetNodes().MakeTxtNode( 751 SwNodeIndex( *pTblNd ), 752 GetTxtCollFromPool( RES_POOLCOLL_TEXT )); 753 if( pTxtNd ) 754 { 755 ((SwPosition&)rPos).nNode = pTblNd->GetIndex()-1; 756 ((SwPosition&)rPos).nContent.Assign( pTxtNd, 0 ); 757 758 // nur im BodyBereich den SeitenUmbruch/-Vorlage umhaengem 759 if( nPrevPos > GetNodes().GetEndOfExtras().GetIndex() ) 760 { 761 SwFrmFmt* pFrmFmt = pTblNd->GetTable().GetFrmFmt(); 762 const SfxPoolItem *pItem; 763 if( SFX_ITEM_SET == pFrmFmt->GetItemState( RES_PAGEDESC, 764 sal_False, &pItem ) ) 765 { 766 pTxtNd->SetAttr( *pItem ); 767 pFrmFmt->ResetFmtAttr( RES_PAGEDESC ); 768 } 769 if( SFX_ITEM_SET == pFrmFmt->GetItemState( RES_BREAK, 770 sal_False, &pItem ) ) 771 { 772 pTxtNd->SetAttr( *pItem ); 773 pFrmFmt->ResetFmtAttr( RES_BREAK ); 774 } 775 } 776 777 if( pUndo ) 778 pUndo->SetTblFlag(); 779 SetModified(); 780 return true; 781 } 782 } 783 } 784 } 785 786 SvULongs aBkmkArr( 15, 15 ); 787 _SaveCntntIdx( this, rPos.nNode.GetIndex(), rPos.nContent.GetIndex(), 788 aBkmkArr, SAVEFLY_SPLIT ); 789 // FIXME: only SwTxtNode has a valid implementation of SplitCntntNode! 790 ASSERT(pNode->IsTxtNode(), "splitting non-text node?"); 791 pNode = pNode->SplitCntntNode( rPos ); 792 if (pNode) 793 { 794 // verschiebe noch alle Bookmarks/TOXMarks/FlyAtCnt 795 if( aBkmkArr.Count() ) 796 _RestoreCntntIdx( this, aBkmkArr, rPos.nNode.GetIndex()-1, 0, sal_True ); 797 798 if( IsRedlineOn() || (!IsIgnoreRedline() && pRedlineTbl->Count() )) 799 { 800 SwPaM aPam( rPos ); 801 aPam.SetMark(); 802 aPam.Move( fnMoveBackward ); 803 if( IsRedlineOn() ) 804 AppendRedline( new SwRedline( nsRedlineType_t::REDLINE_INSERT, aPam ), true); 805 else 806 SplitRedline( aPam ); 807 } 808 } 809 810 SetModified(); 811 return true; 812 } 813 814 bool SwDoc::AppendTxtNode( SwPosition& rPos ) 815 { 816 // create new node before EndOfContent 817 SwTxtNode * pCurNode = rPos.nNode.GetNode().GetTxtNode(); 818 if( !pCurNode ) 819 { 820 // dann kann ja einer angelegt werden! 821 SwNodeIndex aIdx( rPos.nNode, 1 ); 822 pCurNode = GetNodes().MakeTxtNode( aIdx, 823 GetTxtCollFromPool( RES_POOLCOLL_STANDARD )); 824 } 825 else 826 pCurNode = (SwTxtNode*)pCurNode->AppendNode( rPos ); 827 828 rPos.nNode++; 829 rPos.nContent.Assign( pCurNode, 0 ); 830 831 if (GetIDocumentUndoRedo().DoesUndo()) 832 { 833 GetIDocumentUndoRedo().AppendUndo( new SwUndoInsert( rPos.nNode ) ); 834 } 835 836 if( IsRedlineOn() || (!IsIgnoreRedline() && pRedlineTbl->Count() )) 837 { 838 SwPaM aPam( rPos ); 839 aPam.SetMark(); 840 aPam.Move( fnMoveBackward ); 841 if( IsRedlineOn() ) 842 AppendRedline( new SwRedline( nsRedlineType_t::REDLINE_INSERT, aPam ), true); 843 else 844 SplitRedline( aPam ); 845 } 846 847 SetModified(); 848 return sal_True; 849 } 850 851 bool SwDoc::InsertString( const SwPaM &rRg, const String &rStr, 852 const enum InsertFlags nInsertMode ) 853 { 854 if (GetIDocumentUndoRedo().DoesUndo()) 855 { 856 GetIDocumentUndoRedo().ClearRedo(); // AppendUndo not always called! 857 } 858 859 const SwPosition& rPos = *rRg.GetPoint(); 860 861 if( pACEWord ) // Aufnahme in die Autokorrektur 862 { 863 if( 1 == rStr.Len() && pACEWord->IsDeleted() ) 864 { 865 pACEWord->CheckChar( rPos, rStr.GetChar( 0 ) ); 866 } 867 delete pACEWord, pACEWord = 0; 868 } 869 870 SwTxtNode *const pNode = rPos.nNode.GetNode().GetTxtNode(); 871 if(!pNode) 872 { 873 return false; 874 } 875 876 SwDataChanged aTmp( rRg, 0 ); 877 878 if (!GetIDocumentUndoRedo().DoesUndo() || 879 !GetIDocumentUndoRedo().DoesGroupUndo()) 880 { 881 pNode->InsertText( rStr, rPos.nContent, nInsertMode ); 882 883 if (GetIDocumentUndoRedo().DoesUndo()) 884 { 885 SwUndoInsert * const pUndo( new SwUndoInsert( 886 rPos.nNode, rPos.nContent.GetIndex(), rStr.Len(), nInsertMode)); 887 GetIDocumentUndoRedo().AppendUndo(pUndo); 888 } 889 } 890 else 891 { // ist Undo und Gruppierung eingeschaltet, ist alles anders ! 892 SwUndoInsert * pUndo = NULL; // #111827# 893 894 // don't group the start if hints at the start should be expanded 895 if (!(nInsertMode & IDocumentContentOperations::INS_FORCEHINTEXPAND)) 896 // -> #111827# 897 { 898 SwUndo *const pLastUndo = GetUndoManager().GetLastUndo(); 899 SwUndoInsert *const pUndoInsert( 900 dynamic_cast<SwUndoInsert *>(pLastUndo) ); 901 if (pUndoInsert && pUndoInsert->CanGrouping(rPos)) 902 { 903 pUndo = pUndoInsert; 904 } 905 } 906 // <- #111827# 907 908 CharClass const& rCC = GetAppCharClass(); 909 xub_StrLen nInsPos = rPos.nContent.GetIndex(); 910 911 if (!pUndo) 912 { 913 pUndo = new SwUndoInsert( rPos.nNode, nInsPos, 0, nInsertMode, 914 !rCC.isLetterNumeric( rStr, 0 ) ); 915 GetIDocumentUndoRedo().AppendUndo( pUndo ); 916 } 917 918 pNode->InsertText( rStr, rPos.nContent, nInsertMode ); 919 920 for( xub_StrLen i = 0; i < rStr.Len(); ++i ) 921 { 922 nInsPos++; 923 // wenn CanGrouping() sal_True returnt, ist schon alles erledigt 924 if( !pUndo->CanGrouping( rStr.GetChar( i ) )) 925 { 926 pUndo = new SwUndoInsert( rPos.nNode, nInsPos, 1, nInsertMode, 927 !rCC.isLetterNumeric( rStr, i ) ); 928 GetIDocumentUndoRedo().AppendUndo( pUndo ); 929 } 930 } 931 } 932 933 if( IsRedlineOn() || (!IsIgnoreRedline() && pRedlineTbl->Count() )) 934 { 935 SwPaM aPam( rPos.nNode, aTmp.GetCntnt(), 936 rPos.nNode, rPos.nContent.GetIndex()); 937 if( IsRedlineOn() ) 938 { 939 AppendRedline( 940 new SwRedline( nsRedlineType_t::REDLINE_INSERT, aPam ), true); 941 } 942 else 943 { 944 SplitRedline( aPam ); 945 } 946 } 947 948 SetModified(); 949 return true; 950 } 951 952 SwFlyFrmFmt* SwDoc::_InsNoTxtNode( const SwPosition& rPos, SwNoTxtNode* pNode, 953 const SfxItemSet* pFlyAttrSet, 954 const SfxItemSet* pGrfAttrSet, 955 SwFrmFmt* pFrmFmt) 956 { 957 SwFlyFrmFmt *pFmt = 0; 958 if( pNode ) 959 { 960 pFmt = _MakeFlySection( rPos, *pNode, FLY_AT_PARA, 961 pFlyAttrSet, pFrmFmt ); 962 if( pGrfAttrSet ) 963 pNode->SetAttr( *pGrfAttrSet ); 964 } 965 return pFmt; 966 } 967 968 SwFlyFrmFmt* SwDoc::Insert( const SwPaM &rRg, 969 const String& rGrfName, 970 const String& rFltName, 971 const Graphic* pGraphic, 972 const SfxItemSet* pFlyAttrSet, 973 const SfxItemSet* pGrfAttrSet, 974 SwFrmFmt* pFrmFmt ) 975 { 976 if( !pFrmFmt ) 977 pFrmFmt = GetFrmFmtFromPool( RES_POOLFRM_GRAPHIC ); 978 return _InsNoTxtNode( *rRg.GetPoint(), GetNodes().MakeGrfNode( 979 SwNodeIndex( GetNodes().GetEndOfAutotext() ), 980 rGrfName, rFltName, pGraphic, 981 pDfltGrfFmtColl ), 982 pFlyAttrSet, pGrfAttrSet, pFrmFmt ); 983 } 984 SwFlyFrmFmt* SwDoc::Insert( const SwPaM &rRg, const GraphicObject& rGrfObj, 985 const SfxItemSet* pFlyAttrSet, 986 const SfxItemSet* pGrfAttrSet, 987 SwFrmFmt* pFrmFmt ) 988 { 989 if( !pFrmFmt ) 990 pFrmFmt = GetFrmFmtFromPool( RES_POOLFRM_GRAPHIC ); 991 return _InsNoTxtNode( *rRg.GetPoint(), GetNodes().MakeGrfNode( 992 SwNodeIndex( GetNodes().GetEndOfAutotext() ), 993 rGrfObj, pDfltGrfFmtColl ), 994 pFlyAttrSet, pGrfAttrSet, pFrmFmt ); 995 } 996 997 SwFlyFrmFmt* SwDoc::Insert(const SwPaM &rRg, const svt::EmbeddedObjectRef& xObj, 998 const SfxItemSet* pFlyAttrSet, 999 const SfxItemSet* pGrfAttrSet, 1000 SwFrmFmt* pFrmFmt ) 1001 { 1002 if( !pFrmFmt ) 1003 { 1004 sal_uInt16 nId = RES_POOLFRM_OLE; 1005 SvGlobalName aClassName( xObj->getClassID() ); 1006 if (SotExchange::IsMath(aClassName)) 1007 nId = RES_POOLFRM_FORMEL; 1008 1009 pFrmFmt = GetFrmFmtFromPool( nId ); 1010 } 1011 return _InsNoTxtNode( *rRg.GetPoint(), GetNodes().MakeOLENode( 1012 SwNodeIndex( GetNodes().GetEndOfAutotext() ), 1013 xObj, 1014 pDfltGrfFmtColl ), 1015 pFlyAttrSet, pGrfAttrSet, 1016 pFrmFmt ); 1017 } 1018 1019 SwFlyFrmFmt* SwDoc::InsertOLE(const SwPaM &rRg, const String& rObjName, 1020 sal_Int64 nAspect, 1021 const SfxItemSet* pFlyAttrSet, 1022 const SfxItemSet* pGrfAttrSet, 1023 SwFrmFmt* pFrmFmt ) 1024 { 1025 if( !pFrmFmt ) 1026 pFrmFmt = GetFrmFmtFromPool( RES_POOLFRM_OLE ); 1027 1028 return _InsNoTxtNode( *rRg.GetPoint(), 1029 GetNodes().MakeOLENode( 1030 SwNodeIndex( GetNodes().GetEndOfAutotext() ), 1031 rObjName, 1032 nAspect, 1033 pDfltGrfFmtColl, 1034 0 ), 1035 pFlyAttrSet, pGrfAttrSet, 1036 pFrmFmt ); 1037 } 1038 1039 /************************************************************************* 1040 |* SwDoc::GetFldType() 1041 |* Beschreibung: liefert den am Doc eingerichteten Feldtypen zurueck 1042 *************************************************************************/ 1043 1044 SwFieldType *SwDoc::GetSysFldType( const sal_uInt16 eWhich ) const 1045 { 1046 for( sal_uInt16 i = 0; i < INIT_FLDTYPES; ++i ) 1047 if( eWhich == (*pFldTypes)[i]->Which() ) 1048 return (*pFldTypes)[i]; 1049 return 0; 1050 } 1051 /************************************************************************* 1052 * void SetDocStat( const SwDocStat& rStat ); 1053 *************************************************************************/ 1054 1055 void SwDoc::SetDocStat( const SwDocStat& rStat ) 1056 { 1057 *pDocStat = rStat; 1058 } 1059 1060 const SwDocStat& SwDoc::GetDocStat() const 1061 { 1062 return *pDocStat; 1063 } 1064 1065 /*************************************************************************/ 1066 1067 1068 struct _PostItFld : public _SetGetExpFld 1069 { 1070 _PostItFld( const SwNodeIndex& rNdIdx, const SwTxtFld* pFld, const SwIndex* pIdx = 0 ) 1071 : _SetGetExpFld( rNdIdx, pFld, pIdx ) {} 1072 1073 sal_uInt16 GetPageNo( const StringRangeEnumerator &rRangeEnum, 1074 const std::set< sal_Int32 > &rPossiblePages, 1075 sal_uInt16& rVirtPgNo, sal_uInt16& rLineNo ); 1076 1077 SwPostItField* GetPostIt() const 1078 { 1079 return (SwPostItField*) GetFld()->GetFld().GetFld(); 1080 } 1081 }; 1082 1083 1084 sal_uInt16 _PostItFld::GetPageNo( 1085 const StringRangeEnumerator &rRangeEnum, 1086 const std::set< sal_Int32 > &rPossiblePages, 1087 /* out */ sal_uInt16& rVirtPgNo, /* out */ sal_uInt16& rLineNo ) 1088 { 1089 //Problem: Wenn ein PostItFld in einem Node steht, der von mehr als 1090 //einer Layout-Instanz repraesentiert wird, steht die Frage im Raum, 1091 //ob das PostIt nur ein- oder n-mal gedruck werden soll. 1092 //Wahrscheinlich nur einmal, als Seitennummer soll hier keine Zufaellige 1093 //sondern die des ersten Auftretens des PostIts innerhalb des selektierten 1094 //Bereichs ermittelt werden. 1095 rVirtPgNo = 0; 1096 sal_uInt16 nPos = GetCntnt(); 1097 SwIterator<SwTxtFrm,SwTxtNode> aIter( GetFld()->GetTxtNode() ); 1098 for( SwTxtFrm* pFrm = aIter.First(); pFrm; pFrm = aIter.Next() ) 1099 { 1100 if( pFrm->GetOfst() > nPos || 1101 (pFrm->HasFollow() && pFrm->GetFollow()->GetOfst() <= nPos) ) 1102 continue; 1103 sal_uInt16 nPgNo = pFrm->GetPhyPageNum(); 1104 if( rRangeEnum.hasValue( nPgNo, &rPossiblePages )) 1105 { 1106 rLineNo = (sal_uInt16)(pFrm->GetLineCount( nPos ) + 1107 pFrm->GetAllLines() - pFrm->GetThisLines()); 1108 rVirtPgNo = pFrm->GetVirtPageNum(); 1109 return nPgNo; 1110 } 1111 } 1112 return 0; 1113 } 1114 1115 1116 bool lcl_GetPostIts( 1117 IDocumentFieldsAccess* pIDFA, 1118 _SetGetExpFlds * pSrtLst ) 1119 { 1120 bool bHasPostIts = false; 1121 1122 SwFieldType* pFldType = pIDFA->GetSysFldType( RES_POSTITFLD ); 1123 DBG_ASSERT( pFldType, "kein PostItType ? "); 1124 1125 if( pFldType->GetDepends() ) 1126 { 1127 // Modify-Object gefunden, trage alle Felder ins Array ein 1128 SwIterator<SwFmtFld,SwFieldType> aIter( *pFldType ); 1129 const SwTxtFld* pTxtFld; 1130 for( SwFmtFld* pFld = aIter.First(); pFld; pFld = aIter.Next() ) 1131 { 1132 if( 0 != ( pTxtFld = pFld->GetTxtFld() ) && 1133 pTxtFld->GetTxtNode().GetNodes().IsDocNodes() ) 1134 { 1135 bHasPostIts = true; 1136 if (pSrtLst) 1137 { 1138 SwNodeIndex aIdx( pTxtFld->GetTxtNode() ); 1139 _PostItFld* pNew = new _PostItFld( aIdx, pTxtFld ); 1140 pSrtLst->Insert( pNew ); 1141 } 1142 else 1143 break; // we just wanted to check for the existence of postits ... 1144 } 1145 } 1146 } 1147 1148 return bHasPostIts; 1149 } 1150 1151 1152 static void lcl_FormatPostIt( 1153 IDocumentContentOperations* pIDCO, 1154 SwPaM& aPam, 1155 SwPostItField* pField, 1156 bool bNewPage, bool bIsFirstPostIt, 1157 sal_uInt16 nPageNo, sal_uInt16 nLineNo ) 1158 { 1159 static char __READONLY_DATA sTmp[] = " : "; 1160 1161 DBG_ASSERT( ViewShell::GetShellRes(), "missing ShellRes" ); 1162 1163 if (bNewPage) 1164 { 1165 pIDCO->InsertPoolItem( aPam, SvxFmtBreakItem( SVX_BREAK_PAGE_AFTER, RES_BREAK ), 0 ); 1166 pIDCO->SplitNode( *aPam.GetPoint(), false ); 1167 } 1168 else if (!bIsFirstPostIt) 1169 { 1170 // add an empty line between different notes 1171 pIDCO->SplitNode( *aPam.GetPoint(), false ); 1172 pIDCO->SplitNode( *aPam.GetPoint(), false ); 1173 } 1174 1175 String aStr( ViewShell::GetShellRes()->aPostItPage ); 1176 aStr.AppendAscii(sTmp); 1177 1178 aStr += XubString::CreateFromInt32( nPageNo ); 1179 aStr += ' '; 1180 if( nLineNo ) 1181 { 1182 aStr += ViewShell::GetShellRes()->aPostItLine; 1183 aStr.AppendAscii(sTmp); 1184 aStr += XubString::CreateFromInt32( nLineNo ); 1185 aStr += ' '; 1186 } 1187 aStr += ViewShell::GetShellRes()->aPostItAuthor; 1188 aStr.AppendAscii(sTmp); 1189 aStr += pField->GetPar1(); 1190 aStr += ' '; 1191 SvtSysLocale aSysLocale; 1192 aStr += /*(LocaleDataWrapper&)*/aSysLocale.GetLocaleData().getDate( pField->GetDate() ); 1193 pIDCO->InsertString( aPam, aStr ); 1194 1195 pIDCO->SplitNode( *aPam.GetPoint(), false ); 1196 aStr = pField->GetPar2(); 1197 #if defined( WNT ) || defined( PM2 ) 1198 // Bei Windows und Co alle CR rausschmeissen 1199 aStr.EraseAllChars( '\r' ); 1200 #endif 1201 pIDCO->InsertString( aPam, aStr ); 1202 } 1203 1204 1205 // provide the paper tray to use according to the page style in use, 1206 // but do that only if the respective item is NOT just the default item 1207 static sal_Int32 lcl_GetPaperBin( const SwPageFrm *pStartFrm ) 1208 { 1209 sal_Int32 nRes = -1; 1210 1211 const SwFrmFmt &rFmt = pStartFrm->GetPageDesc()->GetMaster(); 1212 const SfxPoolItem *pItem = NULL; 1213 SfxItemState eState = rFmt.GetItemState( RES_PAPER_BIN, sal_False, &pItem ); 1214 const SvxPaperBinItem *pPaperBinItem = dynamic_cast< const SvxPaperBinItem * >(pItem); 1215 if (eState > SFX_ITEM_DEFAULT && pPaperBinItem) 1216 nRes = pPaperBinItem->GetValue(); 1217 1218 return nRes; 1219 } 1220 1221 1222 void SwDoc::CalculatePagesForPrinting( 1223 const SwRootFrm& rLayout, 1224 /* out */ SwRenderData &rData, 1225 const SwPrintUIOptions &rOptions, 1226 bool bIsPDFExport, 1227 sal_Int32 nDocPageCount ) 1228 { 1229 const sal_Int32 nContent = rOptions.getIntValue( "PrintContent", 0 ); 1230 const bool bPrintSelection = nContent == 2; 1231 1232 // properties to take into account when calcualting the set of pages 1233 // (PDF export UI does not allow for selecting left or right pages only) 1234 bool bPrintLeftPages = bIsPDFExport ? true : rOptions.IsPrintLeftPages(); 1235 bool bPrintRightPages = bIsPDFExport ? true : rOptions.IsPrintRightPages(); 1236 // #i103700# printing selections should not allow for automatic inserting empty pages 1237 bool bPrintEmptyPages = bPrintSelection ? false : rOptions.IsPrintEmptyPages( bIsPDFExport ); 1238 1239 Range aPages( 1, nDocPageCount ); 1240 1241 MultiSelection aMulti( aPages ); 1242 aMulti.SetTotalRange( Range( 0, RANGE_MAX ) ); 1243 aMulti.Select( aPages ); 1244 1245 const SwPageFrm *pStPage = dynamic_cast<const SwPageFrm*>( rLayout.Lower() ); 1246 const SwFrm *pEndPage = pStPage; 1247 1248 sal_uInt16 nFirstPageNo = 0; 1249 sal_uInt16 nLastPageNo = 0; 1250 sal_uInt16 nPageNo = 1; 1251 1252 for( sal_uInt16 i = 1; i <= (sal_uInt16)aPages.Max(); ++i ) 1253 { 1254 if( i < (sal_uInt16)aPages.Min() ) 1255 { 1256 if( !pStPage->GetNext() ) 1257 break; 1258 pStPage = (SwPageFrm*)pStPage->GetNext(); 1259 pEndPage= pStPage; 1260 } 1261 else if( i == (sal_uInt16)aPages.Min() ) 1262 { 1263 nFirstPageNo = i; 1264 nLastPageNo = nFirstPageNo; 1265 if( !pStPage->GetNext() || (i == (sal_uInt16)aPages.Max()) ) 1266 break; 1267 pEndPage = pStPage->GetNext(); 1268 } 1269 else if( i > (sal_uInt16)aPages.Min() ) 1270 { 1271 nLastPageNo = i; 1272 if( !pEndPage->GetNext() || (i == (sal_uInt16)aPages.Max()) ) 1273 break; 1274 pEndPage = pEndPage->GetNext(); 1275 } 1276 } 1277 1278 DBG_ASSERT( nFirstPageNo, "first page not found! Should not happen!" ); 1279 if (nFirstPageNo) 1280 { 1281 // HACK: Hier muss von der MultiSelection noch eine akzeptable Moeglichkeit 1282 // geschaffen werden, alle Seiten von Seite x an zu deselektieren. 1283 // Z.B. durch SetTotalRange .... 1284 1285 // aMulti.Select( Range( nLastPageNo+1, SELECTION_MAX ), sal_False ); 1286 MultiSelection aTmpMulti( Range( 1, nLastPageNo ) ); 1287 long nTmpIdx = aMulti.FirstSelected(); 1288 static long nEndOfSelection = SFX_ENDOFSELECTION; 1289 while ( nEndOfSelection != nTmpIdx && nTmpIdx <= long(nLastPageNo) ) 1290 { 1291 aTmpMulti.Select( nTmpIdx ); 1292 nTmpIdx = aMulti.NextSelected(); 1293 } 1294 aMulti = aTmpMulti; 1295 // Ende des HACKs 1296 1297 nPageNo = nFirstPageNo; 1298 1299 std::map< sal_Int32, sal_Int32 > &rPrinterPaperTrays = rData.GetPrinterPaperTrays(); 1300 std::set< sal_Int32 > &rValidPages = rData.GetValidPagesSet(); 1301 std::map< sal_Int32, const SwPageFrm * > &rValidStartFrms = rData.GetValidStartFrames(); 1302 rValidPages.clear(); 1303 rValidStartFrms.clear(); 1304 while ( pStPage ) 1305 { 1306 const sal_Bool bRightPg = pStPage->OnRightPage(); 1307 if ( aMulti.IsSelected( nPageNo ) && 1308 ( (bRightPg && bPrintRightPages) || 1309 (!bRightPg && bPrintLeftPages) ) ) 1310 { 1311 // --> FME 2005-12-12 #b6354161# Feature - Print empty pages 1312 if ( bPrintEmptyPages || pStPage->Frm().Height() ) 1313 // <-- 1314 { 1315 rValidPages.insert( nPageNo ); 1316 rValidStartFrms[ nPageNo ] = pStPage; 1317 1318 rPrinterPaperTrays[ nPageNo ] = lcl_GetPaperBin( pStPage ); 1319 } 1320 } 1321 1322 if ( pStPage == pEndPage ) 1323 { 1324 pStPage = 0; 1325 } 1326 else 1327 { ++nPageNo; 1328 pStPage = (SwPageFrm*)pStPage->GetNext(); 1329 } 1330 } 1331 } 1332 1333 1334 // 1335 // now that we have identified the valid pages for printing according 1336 // to the print settings we need to get the PageRange to use and 1337 // use both results to get the actual pages to be printed 1338 // (post-it settings need to be taken into account later on!) 1339 // 1340 1341 // get PageRange value to use 1342 OUString aPageRange; 1343 // --> PL, OD #i116085# - adjusting fix for i113919 1344 // if (bIsPDFExport) 1345 // { 1346 // aPageRange = rOptions.getStringValue( "PageRange", OUString() ); 1347 // } 1348 // else 1349 if ( !bIsPDFExport ) 1350 // <-- 1351 { 1352 // PageContent : 1353 // 0 -> print all pages (default if aPageRange is empty) 1354 // 1 -> print range according to PageRange 1355 // 2 -> print selection 1356 if (1 == nContent) 1357 aPageRange = rOptions.getStringValue( "PageRange", OUString() ); 1358 if (2 == nContent) 1359 { 1360 // note that printing selections is actually implemented by copying 1361 // the selection to a new temporary document and printing all of that one. 1362 // Thus for Writer "PrintContent" must never be 2. 1363 // See SwXTextDocument::GetRenderDoc for evaluating if a selection is to be 1364 // printed and for creating the temporary document. 1365 } 1366 1367 // please note 1368 } 1369 if (aPageRange.getLength() == 0) // empty string -> print all 1370 { 1371 // set page range to print to 'all pages' 1372 aPageRange = OUString::valueOf( (sal_Int32)1 ); 1373 aPageRange += OUString::valueOf( (sal_Unicode)'-'); 1374 aPageRange += OUString::valueOf( nDocPageCount ); 1375 } 1376 rData.SetPageRange( aPageRange ); 1377 1378 // get vector of pages to print according to PageRange and valid pages set from above 1379 // (result may be an empty vector, for example if the range string is not correct) 1380 StringRangeEnumerator::getRangesFromString( 1381 aPageRange, rData.GetPagesToPrint(), 1382 1, nDocPageCount, 0, &rData.GetValidPagesSet() ); 1383 } 1384 1385 1386 void SwDoc::UpdatePagesForPrintingWithPostItData( 1387 /* out */ SwRenderData &rData, 1388 const SwPrintUIOptions &rOptions, 1389 bool /*bIsPDFExport*/, 1390 sal_Int32 nDocPageCount ) 1391 { 1392 1393 sal_Int16 nPostItMode = (sal_Int16) rOptions.getIntValue( "PrintAnnotationMode", 0 ); 1394 DBG_ASSERT(nPostItMode == POSTITS_NONE || rData.HasPostItData(), 1395 "print post-its without post-it data?" ); 1396 const sal_uInt16 nPostItCount = rData.HasPostItData() ? rData.m_pPostItFields->Count() : 0; 1397 if (nPostItMode != POSTITS_NONE && nPostItCount > 0) 1398 { 1399 SET_CURR_SHELL( rData.m_pPostItShell ); 1400 1401 // clear document and move to end of it 1402 SwPaM aPam( rData.m_pPostItDoc->GetNodes().GetEndOfContent() ); 1403 aPam.Move( fnMoveBackward, fnGoDoc ); 1404 aPam.SetMark(); 1405 aPam.Move( fnMoveForward, fnGoDoc ); 1406 rData.m_pPostItDoc->DeleteRange( aPam ); 1407 1408 const StringRangeEnumerator aRangeEnum( rData.GetPageRange(), 1, nDocPageCount, 0 ); 1409 1410 // For mode POSTITS_ENDPAGE: 1411 // maps a physical page number to the page number in post-it document that holds 1412 // the first post-it for that physical page . Needed to relate the correct start frames 1413 // from the post-it doc to the physical page of the document 1414 std::map< sal_Int32, sal_Int32 > aPostItLastStartPageNum; 1415 1416 // add all post-its on valid pages within the the page range to the 1417 // temporary post-it document. 1418 // Since the array of post-it fileds is sorted by page and line number we will 1419 // already get them in the correct order 1420 sal_uInt16 nVirtPg = 0, nLineNo = 0, nLastPageNum = 0, nPhyPageNum = 0; 1421 bool bIsFirstPostIt = true; 1422 for (sal_uInt16 i = 0; i < nPostItCount; ++i) 1423 { 1424 _PostItFld& rPostIt = (_PostItFld&)*(*rData.m_pPostItFields)[ i ]; 1425 nLastPageNum = nPhyPageNum; 1426 nPhyPageNum = rPostIt.GetPageNo( 1427 aRangeEnum, rData.GetValidPagesSet(), nVirtPg, nLineNo ); 1428 if (nPhyPageNum) 1429 { 1430 // need to insert a page break? 1431 // In POSTITS_ENDPAGE mode for each document page the following 1432 // post-it page needs to start on a new page 1433 const bool bNewPage = nPostItMode == POSTITS_ENDPAGE && 1434 !bIsFirstPostIt && nPhyPageNum != nLastPageNum; 1435 1436 lcl_FormatPostIt( rData.m_pPostItShell->GetDoc(), aPam, 1437 rPostIt.GetPostIt(), bNewPage, bIsFirstPostIt, nVirtPg, nLineNo ); 1438 bIsFirstPostIt = false; 1439 1440 if (nPostItMode == POSTITS_ENDPAGE) 1441 { 1442 // get the correct number of current pages for the post-it document 1443 rData.m_pPostItShell->CalcLayout(); 1444 const sal_Int32 nPages = rData.m_pPostItShell->GetPageCount(); 1445 aPostItLastStartPageNum[ nPhyPageNum ] = nPages; 1446 } 1447 } 1448 } 1449 1450 // format post-it doc to get correct number of pages 1451 rData.m_pPostItShell->CalcLayout(); 1452 const sal_Int32 nPostItDocPageCount = rData.m_pPostItShell->GetPageCount(); 1453 1454 if (nPostItMode == POSTITS_ONLY || nPostItMode == POSTITS_ENDDOC) 1455 { 1456 // now add those post-it pages to the vector of pages to print 1457 // or replace them if only post-its should be printed 1458 1459 rData.GetPostItStartFrames().clear(); 1460 if (nPostItMode == POSTITS_ENDDOC) 1461 { 1462 // set all values up to number of pages to print currently known to NULL, 1463 // meaning none of the pages currently in the vector is from the 1464 // post-it document, they are the documents pages. 1465 rData.GetPostItStartFrames().resize( rData.GetPagesToPrint().size() ); 1466 } 1467 else if (nPostItMode == POSTITS_ONLY) 1468 { 1469 // no document page to be printed 1470 rData.GetPagesToPrint().clear(); 1471 } 1472 1473 // now we just need to add the post-it pages to be printed to the end 1474 // of the vector of pages to print and keep the GetValidStartFrames 1475 // data conform with it 1476 sal_Int32 nPageNum = 0; 1477 const SwPageFrm * pPageFrm = (SwPageFrm*)rData.m_pPostItShell->GetLayout()->Lower(); 1478 while( pPageFrm && nPageNum < nPostItDocPageCount ) 1479 { 1480 DBG_ASSERT( pPageFrm, "Empty page frame. How are we going to print this?" ); 1481 ++nPageNum; 1482 rData.GetPagesToPrint().push_back( 0 ); // a page number of 0 indicates this page is from the post-it doc 1483 DBG_ASSERT( pPageFrm, "pPageFrm is NULL!" ); 1484 rData.GetPostItStartFrames().push_back( pPageFrm ); 1485 pPageFrm = (SwPageFrm*)pPageFrm->GetNext(); 1486 } 1487 DBG_ASSERT( nPageNum == nPostItDocPageCount, "unexpected number of pages" ); 1488 } 1489 else if (nPostItMode == POSTITS_ENDPAGE) 1490 { 1491 // the next step is to find all the start frames from the post-it 1492 // document that should be printed for a given physical page of the document 1493 std::map< sal_Int32, std::vector< const SwPageFrm * > > aPhysPageToPostItFrames; 1494 1495 // ... thus, first collect all post-it doc start frames in a vector 1496 sal_Int32 nPostItPageNum = 0; 1497 std::vector< const SwPageFrm * > aAllPostItStartFrames; 1498 const SwPageFrm * pPageFrm = (SwPageFrm*)rData.m_pPostItShell->GetLayout()->Lower(); 1499 while( pPageFrm && sal_Int32(aAllPostItStartFrames.size()) < nPostItDocPageCount ) 1500 { 1501 DBG_ASSERT( pPageFrm, "Empty page frame. How are we going to print this?" ); 1502 ++nPostItPageNum; 1503 aAllPostItStartFrames.push_back( pPageFrm ); 1504 pPageFrm = (SwPageFrm*)pPageFrm->GetNext(); 1505 } 1506 DBG_ASSERT( sal_Int32(aAllPostItStartFrames.size()) == nPostItDocPageCount, 1507 "unexpected number of frames; does not match number of pages" ); 1508 1509 // get a map that holds all post-it frames to be printed for a 1510 // given physical page from the document 1511 sal_Int32 nLastStartPageNum = 0; 1512 std::map< sal_Int32, sal_Int32 >::const_iterator aIt; 1513 for (aIt = aPostItLastStartPageNum.begin(); aIt != aPostItLastStartPageNum.end(); ++aIt) 1514 { 1515 const sal_Int32 nFrames = aIt->second - nLastStartPageNum; 1516 const sal_Int32 nFirstStartPageNum = aIt == aPostItLastStartPageNum.begin() ? 1517 1 : aIt->second - nFrames + 1; 1518 DBG_ASSERT( 1 <= nFirstStartPageNum && nFirstStartPageNum <= nPostItDocPageCount, 1519 "page number for first frame out of range" ); 1520 std::vector< const SwPageFrm * > aStartFrames; 1521 for (sal_Int32 i = 0; i < nFrames; ++i) 1522 { 1523 const sal_Int32 nIdx = nFirstStartPageNum - 1 + i; // -1 because lowest page num is 1 1524 DBG_ASSERT( 0 <= nIdx && nIdx < sal_Int32(aAllPostItStartFrames.size()), 1525 "index out of range" ); 1526 aStartFrames.push_back( aAllPostItStartFrames[ nIdx ] ); 1527 } 1528 aPhysPageToPostItFrames[ aIt->first /* phys page num */ ] = aStartFrames; 1529 nLastStartPageNum = aIt->second; 1530 } 1531 1532 1533 // ok, now that aPhysPageToPostItFrames can give the start frames for all 1534 // post-it pages to be printed we need to merge those at the correct 1535 // position into the GetPagesToPrint vector and build and maintain the 1536 // GetValidStartFrames vector as well. 1537 // Since inserting a larger number of entries in the middle of a vector 1538 // isn't that efficient we will create new vectors by copying the required data 1539 std::vector< sal_Int32 > aTmpPagesToPrint; 1540 std::vector< const SwPageFrm * > aTmpPostItStartFrames; 1541 const size_t nNum = rData.GetPagesToPrint().size(); 1542 for (size_t i = 0 ; i < nNum; ++i) 1543 { 1544 // add the physical page to print from the document 1545 const sal_Int32 nPhysPage = rData.GetPagesToPrint()[i]; 1546 aTmpPagesToPrint.push_back( nPhysPage ); 1547 aTmpPostItStartFrames.push_back( NULL ); 1548 1549 // add the post-it document pages to print, i.e those 1550 // post-it pages that have the data for the above physical page 1551 const std::vector< const SwPageFrm * > &rPostItFrames = aPhysPageToPostItFrames[ nPhysPage ]; 1552 const size_t nPostItFrames = rPostItFrames.size(); 1553 for (size_t k = 0; k < nPostItFrames; ++k) 1554 { 1555 aTmpPagesToPrint.push_back( 0 ); 1556 aTmpPostItStartFrames.push_back( rPostItFrames[k] ); 1557 } 1558 } 1559 1560 // finally we need to assign those vectors to the resulting ones. 1561 // swapping the data should be more efficient than assigning since 1562 // we won't need the temporary vectors anymore 1563 rData.GetPagesToPrint().swap( aTmpPagesToPrint ); 1564 rData.GetPostItStartFrames().swap( aTmpPostItStartFrames ); 1565 } 1566 } 1567 } 1568 1569 1570 void SwDoc::CalculatePagePairsForProspectPrinting( 1571 const SwRootFrm& rLayout, 1572 /* out */ SwRenderData &rData, 1573 const SwPrintUIOptions &rOptions, 1574 sal_Int32 nDocPageCount ) 1575 { 1576 std::map< sal_Int32, sal_Int32 > &rPrinterPaperTrays = rData.GetPrinterPaperTrays(); 1577 std::set< sal_Int32 > &rValidPagesSet = rData.GetValidPagesSet(); 1578 std::map< sal_Int32, const SwPageFrm * > &rValidStartFrms = rData.GetValidStartFrames(); 1579 std::vector< std::pair< sal_Int32, sal_Int32 > > &rPagePairs = rData.GetPagePairsForProspectPrinting(); 1580 1581 rPagePairs.clear(); 1582 rValidPagesSet.clear(); 1583 rValidStartFrms.clear(); 1584 1585 rtl::OUString aPageRange = rOptions.getStringValue( "PageRange", rtl::OUString() ); 1586 // PageContent : 1587 // 0 -> print all pages (default if aPageRange is empty) 1588 // 1 -> print range according to PageRange 1589 // 2 -> print selection 1590 const sal_Int32 nContent = rOptions.getIntValue( "PrintContent", 0 ); 1591 if (0 == nContent) 1592 { 1593 // set page range to print to 'all pages' 1594 aPageRange = OUString::valueOf( (sal_Int32)1 ); 1595 aPageRange += OUString::valueOf( (sal_Unicode)'-'); 1596 aPageRange += OUString::valueOf( nDocPageCount ); 1597 } 1598 StringRangeEnumerator aRange( aPageRange, 1, nDocPageCount, 0 ); 1599 1600 if ( aRange.size() <= 0) 1601 return; 1602 1603 const SwPageFrm *pStPage = dynamic_cast<const SwPageFrm*>( rLayout.Lower() ); 1604 sal_Int32 i = 0; 1605 for ( i = 1; pStPage && i < nDocPageCount; ++i ) 1606 pStPage = (SwPageFrm*)pStPage->GetNext(); 1607 if ( !pStPage ) // dann wars das 1608 return; 1609 1610 // currently for prospect printing all pages are valid to be printed 1611 // thus we add them all to the respective map and set for later use 1612 sal_Int32 nPageNum = 0; 1613 const SwPageFrm *pPageFrm = dynamic_cast<const SwPageFrm*>( rLayout.Lower() ); 1614 while( pPageFrm && nPageNum < nDocPageCount ) 1615 { 1616 DBG_ASSERT( pPageFrm, "Empty page frame. How are we going to print this?" ); 1617 ++nPageNum; 1618 rValidPagesSet.insert( nPageNum ); 1619 rValidStartFrms[ nPageNum ] = pPageFrm; 1620 pPageFrm = (SwPageFrm*)pPageFrm->GetNext(); 1621 1622 rPrinterPaperTrays[ nPageNum ] = lcl_GetPaperBin( pStPage ); 1623 } 1624 DBG_ASSERT( nPageNum == nDocPageCount, "unexpected number of pages" ); 1625 1626 // properties to take into account when calcualting the set of pages 1627 // Note: here bPrintLeftPages and bPrintRightPages refer to the (virtual) resulting pages 1628 // of the prospect! 1629 bool bPrintLeftPages = rOptions.IsPrintLeftPages(); 1630 bool bPrintRightPages = rOptions.IsPrintRightPages(); 1631 bool bPrintProspectRTL = rOptions.getIntValue( "PrintProspectRTL", 0 ) ? true : false; 1632 1633 // get pages for prospect printing according to the 'PageRange' 1634 // (duplicates and any order allowed!) 1635 std::vector< sal_Int32 > aPagesToPrint; 1636 StringRangeEnumerator::getRangesFromString( 1637 aPageRange, aPagesToPrint, 1, nDocPageCount, 0 ); 1638 1639 // now fill the vector for calculating the page pairs with the start frames 1640 // from the above obtained vector 1641 std::vector< const SwPageFrm * > aVec; 1642 for ( i = 0; i < sal_Int32(aPagesToPrint.size()); ++i) 1643 { 1644 const sal_Int32 nPage = aPagesToPrint[i]; 1645 const SwPageFrm *pFrm = rValidStartFrms[ nPage ]; 1646 aVec.push_back( pFrm ); 1647 } 1648 1649 // just one page is special ... 1650 if ( 1 == aVec.size() ) 1651 aVec.insert( aVec.begin() + 1, 0 ); // insert a second empty page 1652 else 1653 { 1654 // now extend the number of pages to fit a multiple of 4 1655 // (4 'normal' pages are needed for a single prospect paper 1656 // with back and front) 1657 while( aVec.size() & 3 ) 1658 aVec.push_back( 0 ); 1659 } 1660 1661 // dann sorge mal dafuer, das alle Seiten in der richtigen 1662 // Reihenfolge stehen: 1663 sal_uInt16 nSPg = 0, nEPg = aVec.size(), nStep = 1; 1664 if ( 0 == (nEPg & 1 )) // ungerade gibt es nicht! 1665 --nEPg; 1666 1667 if ( !bPrintLeftPages ) 1668 ++nStep; 1669 else if ( !bPrintRightPages ) 1670 { 1671 ++nStep; 1672 ++nSPg, --nEPg; 1673 } 1674 1675 // the number of 'virtual' pages to be printed 1676 sal_Int32 nCntPage = (( nEPg - nSPg ) / ( 2 * nStep )) + 1; 1677 1678 for ( sal_uInt16 nPrintCount = 0; nSPg < nEPg && 1679 nPrintCount < nCntPage; ++nPrintCount ) 1680 { 1681 pStPage = aVec[ nSPg ]; 1682 const SwPageFrm* pNxtPage = nEPg < aVec.size() ? aVec[ nEPg ] : 0; 1683 1684 short nRtlOfs = bPrintProspectRTL ? 1 : 0; 1685 if ( 0 == (( nSPg + nRtlOfs) & 1 ) ) // switch for odd number in LTR, even number in RTL 1686 { 1687 const SwPageFrm* pTmp = pStPage; 1688 pStPage = pNxtPage; 1689 pNxtPage = pTmp; 1690 } 1691 1692 sal_Int32 nFirst = -1, nSecond = -1; 1693 for ( int nC = 0; nC < 2; ++nC ) 1694 { 1695 sal_Int32 nPage = -1; 1696 if ( pStPage ) 1697 nPage = pStPage->GetPhyPageNum(); 1698 if (nC == 0) 1699 nFirst = nPage; 1700 else 1701 nSecond = nPage; 1702 1703 pStPage = pNxtPage; 1704 } 1705 rPagePairs.push_back( std::pair< sal_Int32, sal_Int32 >(nFirst, nSecond) ); 1706 1707 nSPg = nSPg + nStep; 1708 nEPg = nEPg - nStep; 1709 } 1710 DBG_ASSERT( size_t(nCntPage) == rPagePairs.size(), "size mismatch for number of page pairs" ); 1711 1712 // luckily prospect printing does not make use of post-its so far, 1713 // thus we are done here. 1714 } 1715 1716 /************************************************************************* 1717 * void UpdateDocStat( const SwDocStat& rStat ); 1718 *************************************************************************/ 1719 1720 void SwDoc::UpdateDocStat( SwDocStat& rStat ) 1721 { 1722 if( rStat.bModified ) 1723 { 1724 rStat.Reset(); 1725 rStat.nPara = 0; // Default ist auf 1 !! 1726 SwNode* pNd; 1727 1728 for( sal_uLong i = GetNodes().Count(); i; ) 1729 { 1730 switch( ( pNd = GetNodes()[ --i ])->GetNodeType() ) 1731 { 1732 case ND_TEXTNODE: 1733 ((SwTxtNode*)pNd)->CountWords( rStat, 0, ((SwTxtNode*)pNd)->GetTxt().Len() ); 1734 break; 1735 case ND_TABLENODE: ++rStat.nTbl; break; 1736 case ND_GRFNODE: ++rStat.nGrf; break; 1737 case ND_OLENODE: ++rStat.nOLE; break; 1738 case ND_SECTIONNODE: break; 1739 } 1740 } 1741 1742 // #i93174#: notes contain paragraphs that are not nodes 1743 { 1744 SwFieldType * const pPostits( GetSysFldType(RES_POSTITFLD) ); 1745 SwIterator<SwFmtFld,SwFieldType> aIter( *pPostits ); 1746 for( SwFmtFld* pFmtFld = aIter.First(); pFmtFld; pFmtFld = aIter.Next() ) 1747 { 1748 if (pFmtFld->IsFldInDoc()) 1749 { 1750 SwPostItField const * const pField( 1751 static_cast<SwPostItField const*>(pFmtFld->GetFld())); 1752 rStat.nAllPara += pField->GetNumberOfParagraphs(); 1753 } 1754 } 1755 } 1756 1757 rStat.nPage = GetCurrentLayout() ? GetCurrentLayout()->GetPageNum() : 0; //swmod 080218 1758 rStat.bModified = sal_False; 1759 SetDocStat( rStat ); 1760 1761 com::sun::star::uno::Sequence < com::sun::star::beans::NamedValue > aStat( rStat.nPage ? 7 : 6); 1762 sal_Int32 n=0; 1763 aStat[n].Name = ::rtl::OUString::createFromAscii("TableCount"); 1764 aStat[n++].Value <<= (sal_Int32)rStat.nTbl; 1765 aStat[n].Name = ::rtl::OUString::createFromAscii("ImageCount"); 1766 aStat[n++].Value <<= (sal_Int32)rStat.nGrf; 1767 aStat[n].Name = ::rtl::OUString::createFromAscii("ObjectCount"); 1768 aStat[n++].Value <<= (sal_Int32)rStat.nOLE; 1769 if ( rStat.nPage ) 1770 { 1771 aStat[n].Name = ::rtl::OUString::createFromAscii("PageCount"); 1772 aStat[n++].Value <<= (sal_Int32)rStat.nPage; 1773 } 1774 aStat[n].Name = ::rtl::OUString::createFromAscii("ParagraphCount"); 1775 aStat[n++].Value <<= (sal_Int32)rStat.nPara; 1776 aStat[n].Name = ::rtl::OUString::createFromAscii("WordCount"); 1777 aStat[n++].Value <<= (sal_Int32)rStat.nWord; 1778 aStat[n].Name = ::rtl::OUString::createFromAscii("CharacterCount"); 1779 aStat[n++].Value <<= (sal_Int32)rStat.nChar; 1780 1781 // For e.g. autotext documents there is no pSwgInfo (#i79945) 1782 SfxObjectShell * const pObjShell( GetDocShell() ); 1783 if (pObjShell) 1784 { 1785 const uno::Reference<document::XDocumentPropertiesSupplier> xDPS( 1786 pObjShell->GetModel(), uno::UNO_QUERY_THROW); 1787 const uno::Reference<document::XDocumentProperties> xDocProps( 1788 xDPS->getDocumentProperties()); 1789 // #i96786#: do not set modified flag when updating statistics 1790 const bool bDocWasModified( IsModified() ); 1791 const ModifyBlocker_Impl b(pObjShell); 1792 xDocProps->setDocumentStatistics(aStat); 1793 if (!bDocWasModified) 1794 { 1795 ResetModified(); 1796 } 1797 } 1798 1799 // event. Stat. Felder Updaten 1800 SwFieldType *pType = GetSysFldType(RES_DOCSTATFLD); 1801 pType->UpdateFlds(); 1802 } 1803 } 1804 1805 1806 // Dokument - Info 1807 1808 void SwDoc::DocInfoChgd( ) 1809 { 1810 GetSysFldType( RES_DOCINFOFLD )->UpdateFlds(); 1811 GetSysFldType( RES_TEMPLNAMEFLD )->UpdateFlds(); 1812 SetModified(); 1813 } 1814 1815 // returne zum Namen die im Doc gesetzte Referenz 1816 const SwFmtRefMark* SwDoc::GetRefMark( const String& rName ) const 1817 { 1818 const SfxPoolItem* pItem; 1819 sal_uInt32 nMaxItems = GetAttrPool().GetItemCount2( RES_TXTATR_REFMARK ); 1820 for( sal_uInt32 n = 0; n < nMaxItems; ++n ) 1821 { 1822 if( 0 == (pItem = GetAttrPool().GetItem2( RES_TXTATR_REFMARK, n ) )) 1823 continue; 1824 1825 const SwFmtRefMark* pFmtRef = (SwFmtRefMark*)pItem; 1826 const SwTxtRefMark* pTxtRef = pFmtRef->GetTxtRefMark(); 1827 if( pTxtRef && &pTxtRef->GetTxtNode().GetNodes() == &GetNodes() && 1828 rName.Equals( pFmtRef->GetRefName() ) ) 1829 return pFmtRef; 1830 } 1831 return 0; 1832 } 1833 1834 // returne die RefMark per Index - fuer Uno 1835 const SwFmtRefMark* SwDoc::GetRefMark( sal_uInt16 nIndex ) const 1836 { 1837 const SfxPoolItem* pItem; 1838 const SwTxtRefMark* pTxtRef; 1839 const SwFmtRefMark* pRet = 0; 1840 1841 sal_uInt32 nMaxItems = GetAttrPool().GetItemCount2( RES_TXTATR_REFMARK ); 1842 sal_uInt32 nCount = 0; 1843 for( sal_uInt32 n = 0; n < nMaxItems; ++n ) 1844 if( 0 != (pItem = GetAttrPool().GetItem2( RES_TXTATR_REFMARK, n )) && 1845 0 != (pTxtRef = ((SwFmtRefMark*)pItem)->GetTxtRefMark()) && 1846 &pTxtRef->GetTxtNode().GetNodes() == &GetNodes() ) 1847 { 1848 if(nCount == nIndex) 1849 { 1850 pRet = (SwFmtRefMark*)pItem; 1851 break; 1852 } 1853 nCount++; 1854 } 1855 return pRet; 1856 } 1857 1858 // returne die Namen aller im Doc gesetzten Referenzen 1859 //JP 24.06.96: Ist der ArrayPointer 0 dann returne nur, ob im Doc. eine 1860 // RefMark gesetzt ist 1861 // OS 25.06.96: ab jetzt wird immer die Anzahl der Referenzen returnt 1862 sal_uInt16 SwDoc::GetRefMarks( SvStringsDtor* pNames ) const 1863 { 1864 const SfxPoolItem* pItem; 1865 const SwTxtRefMark* pTxtRef; 1866 1867 sal_uInt32 nMaxItems = GetAttrPool().GetItemCount2( RES_TXTATR_REFMARK ); 1868 sal_uInt32 nCount = 0; 1869 for( sal_uInt32 n = 0; n < nMaxItems; ++n ) 1870 if( 0 != (pItem = GetAttrPool().GetItem2( RES_TXTATR_REFMARK, n )) && 1871 0 != (pTxtRef = ((SwFmtRefMark*)pItem)->GetTxtRefMark()) && 1872 &pTxtRef->GetTxtNode().GetNodes() == &GetNodes() ) 1873 { 1874 if( pNames ) 1875 { 1876 String* pTmp = new String( ((SwFmtRefMark*)pItem)->GetRefName() ); 1877 pNames->Insert( pTmp, nCount ); 1878 } 1879 nCount ++; 1880 } 1881 1882 return nCount; 1883 } 1884 1885 bool SwDoc::IsLoaded() const 1886 { 1887 return mbLoaded; 1888 } 1889 1890 bool SwDoc::IsUpdateExpFld() const 1891 { 1892 return mbUpdateExpFld; 1893 } 1894 1895 bool SwDoc::IsNewDoc() const 1896 { 1897 return mbNewDoc; 1898 } 1899 1900 bool SwDoc::IsPageNums() const 1901 { 1902 return mbPageNums; 1903 } 1904 1905 void SwDoc::SetPageNums(bool b) 1906 { 1907 mbPageNums = b; 1908 } 1909 1910 void SwDoc::SetNewDoc(bool b) 1911 { 1912 mbNewDoc = b; 1913 } 1914 1915 void SwDoc::SetUpdateExpFldStat(bool b) 1916 { 1917 mbUpdateExpFld = b; 1918 } 1919 1920 void SwDoc::SetLoaded(bool b) 1921 { 1922 mbLoaded = b; 1923 } 1924 1925 bool SwDoc::IsModified() const 1926 { 1927 return mbModified; 1928 } 1929 1930 void SwDoc::SetModified() 1931 { 1932 // --> OD 2005-08-29 #125370# 1933 SwLayouter::ClearMovedFwdFrms( *this ); 1934 SwLayouter::ClearObjsTmpConsiderWrapInfluence( *this ); 1935 SwLayouter::ClearFrmsNotToWrap( *this ); 1936 // <-- 1937 // --> OD 2006-05-10 #i65250# 1938 SwLayouter::ClearMoveBwdLayoutInfo( *this ); 1939 // <-- 1940 // dem Link wird der Status returnt, wie die Flags waren und werden 1941 // Bit 0: -> alter Zustand 1942 // Bit 1: -> neuer Zustand 1943 long nCall = mbModified ? 3 : 2; 1944 mbModified = sal_True; 1945 pDocStat->bModified = sal_True; 1946 if( aOle2Link.IsSet() ) 1947 { 1948 mbInCallModified = sal_True; 1949 aOle2Link.Call( (void*)nCall ); 1950 mbInCallModified = sal_False; 1951 } 1952 1953 if( pACEWord && !pACEWord->IsDeleted() ) 1954 delete pACEWord, pACEWord = 0; 1955 } 1956 1957 void SwDoc::ResetModified() 1958 { 1959 // dem Link wird der Status returnt, wie die Flags waren und werden 1960 // Bit 0: -> alter Zustand 1961 // Bit 1: -> neuer Zustand 1962 long nCall = mbModified ? 1 : 0; 1963 mbModified = sal_False; 1964 // If there is already a document statistic, we assume that 1965 // it is correct. In this case we reset the modified flag. 1966 if ( 0 != pDocStat->nChar ) 1967 pDocStat->bModified = sal_False; 1968 GetIDocumentUndoRedo().SetUndoNoModifiedPosition(); 1969 if( nCall && aOle2Link.IsSet() ) 1970 { 1971 mbInCallModified = sal_True; 1972 aOle2Link.Call( (void*)nCall ); 1973 mbInCallModified = sal_False; 1974 } 1975 } 1976 1977 1978 void SwDoc::ReRead( SwPaM& rPam, const String& rGrfName, 1979 const String& rFltName, const Graphic* pGraphic, 1980 const GraphicObject* pGrafObj ) 1981 { 1982 SwGrfNode *pGrfNd; 1983 if( ( !rPam.HasMark() 1984 || rPam.GetPoint()->nNode.GetIndex() == rPam.GetMark()->nNode.GetIndex() ) 1985 && 0 != ( pGrfNd = rPam.GetPoint()->nNode.GetNode().GetGrfNode() ) ) 1986 { 1987 if (GetIDocumentUndoRedo().DoesUndo()) 1988 { 1989 GetIDocumentUndoRedo().AppendUndo(new SwUndoReRead(rPam, *pGrfNd)); 1990 } 1991 1992 // Weil nicht bekannt ist, ob sich die Grafik spiegeln laesst, 1993 // immer das SpiegelungsAttribut zuruecksetzen 1994 if( RES_MIRROR_GRAPH_DONT != pGrfNd->GetSwAttrSet(). 1995 GetMirrorGrf().GetValue() ) 1996 pGrfNd->SetAttr( SwMirrorGrf() ); 1997 1998 pGrfNd->ReRead( rGrfName, rFltName, pGraphic, pGrafObj, sal_True ); 1999 SetModified(); 2000 } 2001 } 2002 2003 sal_Bool lcl_SpellAndGrammarAgain( const SwNodePtr& rpNd, void* pArgs ) 2004 { 2005 SwTxtNode *pTxtNode = (SwTxtNode*)rpNd->GetTxtNode(); 2006 sal_Bool bOnlyWrong = *(sal_Bool*)pArgs; 2007 if( pTxtNode ) 2008 { 2009 if( bOnlyWrong ) 2010 { 2011 if( pTxtNode->GetWrong() && 2012 pTxtNode->GetWrong()->InvalidateWrong() ) 2013 pTxtNode->SetWrongDirty( true ); 2014 if( pTxtNode->GetGrammarCheck() && 2015 pTxtNode->GetGrammarCheck()->InvalidateWrong() ) 2016 pTxtNode->SetGrammarCheckDirty( true ); 2017 } 2018 else 2019 { 2020 pTxtNode->SetWrongDirty( true ); 2021 if( pTxtNode->GetWrong() ) 2022 pTxtNode->GetWrong()->SetInvalid( 0, STRING_LEN ); 2023 pTxtNode->SetGrammarCheckDirty( true ); 2024 if( pTxtNode->GetGrammarCheck() ) 2025 pTxtNode->GetGrammarCheck()->SetInvalid( 0, STRING_LEN ); 2026 } 2027 } 2028 return sal_True; 2029 } 2030 2031 sal_Bool lcl_CheckSmartTagsAgain( const SwNodePtr& rpNd, void* ) 2032 { 2033 SwTxtNode *pTxtNode = (SwTxtNode*)rpNd->GetTxtNode(); 2034 // sal_Bool bOnlyWrong = *(sal_Bool*)pArgs; 2035 if( pTxtNode ) 2036 { 2037 pTxtNode->SetSmartTagDirty( true ); 2038 if( pTxtNode->GetSmartTags() ) 2039 { 2040 // if ( bOnlyWrong ) // only some smart tag types have been enabled or disabled 2041 // pTxtNode->GetSmartTags()->SetInvalid( 0, STRING_LEN ); 2042 // else // smart tags all have been enabled or disabled 2043 pTxtNode->SetSmartTags( NULL ); 2044 } 2045 } 2046 return sal_True; 2047 } 2048 2049 2050 /************************************************************************* 2051 * SwDoc::SpellItAgainSam( sal_Bool bInvalid, sal_Bool bOnlyWrong ) 2052 * 2053 * stoesst das Spelling im Idle-Handler wieder an. 2054 * Wird bInvalid als sal_True uebergeben, so werden zusaetzlich die WrongListen 2055 * an allen Nodes invalidiert und auf allen Seiten das SpellInvalid-Flag 2056 * gesetzt. 2057 * Mit bOnlyWrong kann man dann steuern, ob nur die Bereiche mit falschen 2058 * Woertern oder die kompletten Bereiche neu ueberprueft werden muessen. 2059 ************************************************************************/ 2060 2061 void SwDoc::SpellItAgainSam( sal_Bool bInvalid, sal_Bool bOnlyWrong, sal_Bool bSmartTags ) 2062 { 2063 std::set<SwRootFrm*> aAllLayouts = GetAllLayouts();//swmod 080307 2064 ASSERT( GetCurrentLayout(), "SpellAgain: Where's my RootFrm?" ); 2065 if( bInvalid ) 2066 { 2067 std::for_each( aAllLayouts.begin(), aAllLayouts.end(),std::bind2nd(std::mem_fun(&SwRootFrm::AllInvalidateSmartTagsOrSpelling),bSmartTags));//swmod 080305 2068 std::for_each( aAllLayouts.begin(), aAllLayouts.end(),std::bind2nd(std::mem_fun(&SwRootFrm::SetNeedGrammarCheck), true) ); 2069 if ( bSmartTags ) 2070 GetNodes().ForEach( lcl_CheckSmartTagsAgain, &bOnlyWrong ); 2071 GetNodes().ForEach( lcl_SpellAndGrammarAgain, &bOnlyWrong ); 2072 } 2073 2074 std::for_each( aAllLayouts.begin(), aAllLayouts.end(),std::mem_fun(&SwRootFrm::SetIdleFlags));//swmod 080307 2075 } 2076 2077 void SwDoc::InvalidateAutoCompleteFlag() 2078 { 2079 SwRootFrm* pTmpRoot = GetCurrentLayout(); 2080 if( pTmpRoot ) 2081 { 2082 std::set<SwRootFrm*> aAllLayouts = GetAllLayouts(); 2083 std::for_each( aAllLayouts.begin(), aAllLayouts.end(),std::mem_fun(&SwRootFrm::AllInvalidateAutoCompleteWords));//swmod 080305 2084 for( sal_uLong nNd = 1, nCnt = GetNodes().Count(); nNd < nCnt; ++nNd ) 2085 { 2086 SwTxtNode* pTxtNode = GetNodes()[ nNd ]->GetTxtNode(); 2087 if ( pTxtNode ) pTxtNode->SetAutoCompleteWordDirty( true ); 2088 } 2089 2090 std::for_each( aAllLayouts.begin(), aAllLayouts.end(),std::mem_fun(&SwRootFrm::SetIdleFlags));//swmod 080228 2091 } //swmod 080219 2092 } 2093 2094 const SwFmtINetFmt* SwDoc::FindINetAttr( const String& rName ) const 2095 { 2096 const SwFmtINetFmt* pItem; 2097 const SwTxtINetFmt* pTxtAttr; 2098 const SwTxtNode* pTxtNd; 2099 sal_uInt32 n, nMaxItems = GetAttrPool().GetItemCount2( RES_TXTATR_INETFMT ); 2100 for( n = 0; n < nMaxItems; ++n ) 2101 if( 0 != (pItem = (SwFmtINetFmt*)GetAttrPool().GetItem2( 2102 RES_TXTATR_INETFMT, n ) ) && 2103 pItem->GetName().Equals( rName ) && 2104 0 != ( pTxtAttr = pItem->GetTxtINetFmt()) && 2105 0 != ( pTxtNd = pTxtAttr->GetpTxtNode() ) && 2106 &pTxtNd->GetNodes() == &GetNodes() ) 2107 { 2108 return pItem; 2109 } 2110 2111 return 0; 2112 } 2113 2114 void SwDoc::Summary( SwDoc* pExtDoc, sal_uInt8 nLevel, sal_uInt8 nPara, sal_Bool bImpress ) 2115 { 2116 const SwOutlineNodes& rOutNds = GetNodes().GetOutLineNds(); 2117 if( pExtDoc && rOutNds.Count() ) 2118 { 2119 sal_uInt16 i; 2120 ::StartProgress( STR_STATSTR_SUMMARY, 0, rOutNds.Count(), GetDocShell() ); 2121 SwNodeIndex aEndOfDoc( pExtDoc->GetNodes().GetEndOfContent(), -1 ); 2122 for( i = 0; i < rOutNds.Count(); ++i ) 2123 { 2124 ::SetProgressState( i, GetDocShell() ); 2125 const sal_uLong nIndex = rOutNds[ i ]->GetIndex(); 2126 //sal_uInt8 nLvl = ((SwTxtNode*)GetNodes()[ nIndex ])->GetTxtColl()//#outline level,zhaojianwei 2127 // ->GetOutlineLevel(); 2128 const int nLvl = ((SwTxtNode*)GetNodes()[ nIndex ])->GetAttrOutlineLevel()-1;//<-end,zhaojianwei 2129 if( nLvl > nLevel ) 2130 continue; 2131 sal_uInt16 nEndOfs = 1; 2132 sal_uInt8 nWish = nPara; 2133 sal_uLong nNextOutNd = i + 1 < rOutNds.Count() ? 2134 rOutNds[ i + 1 ]->GetIndex() : GetNodes().Count(); 2135 sal_Bool bKeep = sal_False; 2136 while( ( nWish || bKeep ) && nIndex + nEndOfs < nNextOutNd && 2137 GetNodes()[ nIndex + nEndOfs ]->IsTxtNode() ) 2138 { 2139 SwTxtNode* pTxtNode = (SwTxtNode*)GetNodes()[ nIndex+nEndOfs ]; 2140 if( pTxtNode->GetTxt().Len() && nWish ) 2141 --nWish; 2142 bKeep = pTxtNode->GetSwAttrSet().GetKeep().GetValue(); 2143 ++nEndOfs; 2144 } 2145 2146 SwNodeRange aRange( *rOutNds[ i ], 0, *rOutNds[ i ], nEndOfs ); 2147 GetNodes()._Copy( aRange, aEndOfDoc ); 2148 } 2149 const SwTxtFmtColls *pColl = pExtDoc->GetTxtFmtColls(); 2150 for( i = 0; i < pColl->Count(); ++i ) 2151 (*pColl)[ i ]->ResetFmtAttr( RES_PAGEDESC, RES_BREAK ); 2152 SwNodeIndex aIndx( pExtDoc->GetNodes().GetEndOfExtras() ); 2153 ++aEndOfDoc; 2154 while( aIndx < aEndOfDoc ) 2155 { 2156 SwNode *pNode; 2157 sal_Bool bDelete = sal_False; 2158 if( (pNode = &aIndx.GetNode())->IsTxtNode() ) 2159 { 2160 SwTxtNode *pNd = (SwTxtNode*)pNode; 2161 if( pNd->HasSwAttrSet() ) 2162 pNd->ResetAttr( RES_PAGEDESC, RES_BREAK ); 2163 if( bImpress ) 2164 { 2165 SwTxtFmtColl* pMyColl = pNd->GetTxtColl(); 2166 //sal_uInt16 nHeadLine = static_cast<sal_uInt16>(pMyColl->GetOutlineLevel()==NO_NUMBERING ?//#outlinelevel,zhaojianwei 2167 const sal_uInt16 nHeadLine = static_cast<sal_uInt16>( 2168 !pMyColl->IsAssignedToListLevelOfOutlineStyle() //<-end,zhaojianwei 2169 ? RES_POOLCOLL_HEADLINE2 2170 : RES_POOLCOLL_HEADLINE1 ); 2171 pMyColl = pExtDoc->GetTxtCollFromPool( nHeadLine ); 2172 pNd->ChgFmtColl( pMyColl ); 2173 } 2174 if( !pNd->Len() && 2175 pNd->StartOfSectionIndex()+2 < pNd->EndOfSectionIndex() ) 2176 { 2177 bDelete = sal_True; 2178 pExtDoc->GetNodes().Delete( aIndx ); 2179 } 2180 } 2181 if( !bDelete ) 2182 ++aIndx; 2183 } 2184 ::EndProgress( GetDocShell() ); 2185 } 2186 } 2187 2188 // loesche den nicht sichtbaren Content aus dem Document, wie z.B.: 2189 // versteckte Bereiche, versteckte Absaetze 2190 bool SwDoc::RemoveInvisibleContent() 2191 { 2192 sal_Bool bRet = sal_False; 2193 GetIDocumentUndoRedo().StartUndo( UNDO_UI_DELETE_INVISIBLECNTNT, NULL ); 2194 2195 { 2196 SwTxtNode* pTxtNd; 2197 SwIterator<SwFmtFld,SwFieldType> aIter( *GetSysFldType( RES_HIDDENPARAFLD ) ); 2198 for( SwFmtFld* pFmtFld = aIter.First(); pFmtFld; pFmtFld = aIter.Next() ) 2199 { 2200 if( pFmtFld->GetTxtFld() && 2201 0 != ( pTxtNd = (SwTxtNode*)pFmtFld->GetTxtFld()->GetpTxtNode() ) && 2202 pTxtNd->GetpSwpHints() && pTxtNd->HasHiddenParaField() && 2203 &pTxtNd->GetNodes() == &GetNodes() ) 2204 { 2205 bRet = sal_True; 2206 SwPaM aPam( *pTxtNd, 0, *pTxtNd, pTxtNd->GetTxt().Len() ); 2207 2208 // Remove hidden paragraph or delete contents: 2209 // Delete contents if 2210 // 1. removing the paragraph would result in an empty section or 2211 // 2. if the paragraph is the last paragraph in the section and 2212 // there is no paragraph in front of the paragraph: 2213 if ( ( 2 == pTxtNd->EndOfSectionIndex() - pTxtNd->StartOfSectionIndex() ) || 2214 ( 1 == pTxtNd->EndOfSectionIndex() - pTxtNd->GetIndex() && 2215 !GetNodes()[ pTxtNd->GetIndex() - 1 ]->GetTxtNode() ) ) 2216 { 2217 DeleteRange( aPam ); 2218 } 2219 else 2220 { 2221 aPam.DeleteMark(); 2222 DelFullPara( aPam ); 2223 } 2224 } 2225 } 2226 } 2227 2228 // 2229 // Remove any hidden paragraph (hidden text attribute) 2230 // 2231 for( sal_uLong n = GetNodes().Count(); n; ) 2232 { 2233 SwTxtNode* pTxtNd = GetNodes()[ --n ]->GetTxtNode(); 2234 if ( pTxtNd ) 2235 { 2236 bool bRemoved = false; 2237 SwPaM aPam( *pTxtNd, 0, *pTxtNd, pTxtNd->GetTxt().Len() ); 2238 if ( pTxtNd->HasHiddenCharAttribute( true ) ) 2239 { 2240 bRemoved = sal_True; 2241 bRet = sal_True; 2242 2243 // Remove hidden paragraph or delete contents: 2244 // Delete contents if 2245 // 1. removing the paragraph would result in an empty section or 2246 // 2. if the paragraph is the last paragraph in the section and 2247 // there is no paragraph in front of the paragraph: 2248 2249 if ( ( 2 == pTxtNd->EndOfSectionIndex() - pTxtNd->StartOfSectionIndex() ) || 2250 ( 1 == pTxtNd->EndOfSectionIndex() - pTxtNd->GetIndex() && 2251 !GetNodes()[ pTxtNd->GetIndex() - 1 ]->GetTxtNode() ) ) 2252 { 2253 DeleteRange( aPam ); 2254 } 2255 else 2256 { 2257 aPam.DeleteMark(); 2258 DelFullPara( aPam ); 2259 } 2260 } 2261 else if ( pTxtNd->HasHiddenCharAttribute( false ) ) 2262 { 2263 bRemoved = sal_True; 2264 bRet = sal_True; 2265 SwScriptInfo::DeleteHiddenRanges( *pTxtNd ); 2266 } 2267 2268 // --> FME 2006-01-11 #120473# 2269 // Footnotes/Frames may have been removed, therefore we have 2270 // to reset n: 2271 if ( bRemoved ) 2272 n = aPam.GetPoint()->nNode.GetIndex(); 2273 // <-- 2274 } 2275 } 2276 2277 { 2278 // dann noch alle versteckten Bereiche loeschen/leeren 2279 SwSectionFmts aSectFmts; 2280 SwSectionFmts& rSectFmts = GetSections(); 2281 sal_uInt16 n; 2282 2283 for( n = rSectFmts.Count(); n; ) 2284 { 2285 SwSectionFmt* pSectFmt = rSectFmts[ --n ]; 2286 // don't add sections in Undo/Redo 2287 if( !pSectFmt->IsInNodesArr()) 2288 continue; 2289 SwSection* pSect = pSectFmt->GetSection(); 2290 if( pSect->CalcHiddenFlag() ) 2291 { 2292 SwSection* pParent = pSect, *pTmp; 2293 while( 0 != (pTmp = pParent->GetParent() )) 2294 { 2295 if( pTmp->IsHiddenFlag() ) 2296 pSect = pTmp; 2297 pParent = pTmp; 2298 } 2299 2300 if( USHRT_MAX == aSectFmts.GetPos( pSect->GetFmt() ) ) 2301 aSectFmts.Insert( pSect->GetFmt(), 0 ); 2302 } 2303 if( pSect->GetCondition().Len() ) 2304 { 2305 SwSectionData aSectionData( *pSect ); 2306 aSectionData.SetCondition( aEmptyStr ); 2307 aSectionData.SetHidden( false ); 2308 UpdateSection( n, aSectionData ); 2309 } 2310 } 2311 2312 if( 0 != ( n = aSectFmts.Count() )) 2313 { 2314 while( n ) 2315 { 2316 SwSectionFmt* pSectFmt = aSectFmts[ --n ]; 2317 SwSectionNode* pSectNd = pSectFmt->GetSectionNode(); 2318 if( pSectNd ) 2319 { 2320 bRet = sal_True; 2321 SwPaM aPam( *pSectNd ); 2322 2323 if( pSectNd->StartOfSectionNode()->StartOfSectionIndex() == 2324 pSectNd->GetIndex() - 1 && 2325 pSectNd->StartOfSectionNode()->EndOfSectionIndex() == 2326 pSectNd->EndOfSectionIndex() + 1 ) 2327 { 2328 // nur den Inhalt loeschen 2329 SwCntntNode* pCNd = GetNodes().GoNext( 2330 &aPam.GetPoint()->nNode ); 2331 aPam.GetPoint()->nContent.Assign( pCNd, 0 ); 2332 aPam.SetMark(); 2333 aPam.GetPoint()->nNode = *pSectNd->EndOfSectionNode(); 2334 pCNd = GetNodes().GoPrevious( 2335 &aPam.GetPoint()->nNode ); 2336 aPam.GetPoint()->nContent.Assign( pCNd, pCNd->Len() ); 2337 2338 DeleteRange( aPam ); 2339 } 2340 else 2341 { 2342 // die gesamte Section loeschen 2343 aPam.SetMark(); 2344 aPam.GetPoint()->nNode = *pSectNd->EndOfSectionNode(); 2345 DelFullPara( aPam ); 2346 } 2347 2348 } 2349 } 2350 aSectFmts.Remove( 0, aSectFmts.Count() ); 2351 } 2352 } 2353 2354 if( bRet ) 2355 SetModified(); 2356 GetIDocumentUndoRedo().EndUndo( UNDO_UI_DELETE_INVISIBLECNTNT, NULL ); 2357 return bRet; 2358 } 2359 /*-- 25.08.2010 14:18:12--------------------------------------------------- 2360 2361 -----------------------------------------------------------------------*/ 2362 bool SwDoc::HasInvisibleContent() const 2363 { 2364 sal_Bool bRet = sal_False; 2365 2366 SwClientIter aIter( *GetSysFldType( RES_HIDDENPARAFLD ) ); 2367 if( aIter.First( TYPE( SwFmtFld ) ) ) 2368 bRet = sal_True; 2369 2370 // 2371 // Search for any hidden paragraph (hidden text attribute) 2372 // 2373 if( ! bRet ) 2374 { 2375 for( sal_uLong n = GetNodes().Count(); !bRet && (n > 0); ) 2376 { 2377 SwTxtNode* pTxtNd = GetNodes()[ --n ]->GetTxtNode(); 2378 if ( pTxtNd ) 2379 { 2380 SwPaM aPam( *pTxtNd, 0, *pTxtNd, pTxtNd->GetTxt().Len() ); 2381 if( pTxtNd->HasHiddenCharAttribute( true ) || ( pTxtNd->HasHiddenCharAttribute( false ) ) ) 2382 { 2383 bRet = sal_True; 2384 } 2385 } 2386 } 2387 } 2388 2389 if( ! bRet ) 2390 { 2391 const SwSectionFmts& rSectFmts = GetSections(); 2392 sal_uInt16 n; 2393 2394 for( n = rSectFmts.Count(); !bRet && (n > 0); ) 2395 { 2396 SwSectionFmt* pSectFmt = rSectFmts[ --n ]; 2397 // don't add sections in Undo/Redo 2398 if( !pSectFmt->IsInNodesArr()) 2399 continue; 2400 SwSection* pSect = pSectFmt->GetSection(); 2401 if( pSect->IsHidden() ) 2402 bRet = sal_True; 2403 } 2404 } 2405 return bRet; 2406 } 2407 2408 bool SwDoc::RestoreInvisibleContent() 2409 { 2410 bool bRet = false; 2411 SwUndoId nLastUndoId(UNDO_EMPTY); 2412 if (GetIDocumentUndoRedo().GetLastUndoInfo(0, & nLastUndoId) 2413 && (UNDO_UI_DELETE_INVISIBLECNTNT == nLastUndoId)) 2414 { 2415 GetIDocumentUndoRedo().Undo(); 2416 GetIDocumentUndoRedo().ClearRedo(); 2417 bRet = true; 2418 } 2419 return bRet; 2420 } 2421 2422 /*-- 11.06.2004 08:34:04--------------------------------------------------- 2423 2424 -----------------------------------------------------------------------*/ 2425 sal_Bool SwDoc::ConvertFieldsToText() 2426 { 2427 sal_Bool bRet = sal_False; 2428 LockExpFlds(); 2429 GetIDocumentUndoRedo().StartUndo( UNDO_UI_REPLACE, NULL ); 2430 2431 const SwFldTypes* pMyFldTypes = GetFldTypes(); 2432 sal_uInt16 nCount = pMyFldTypes->Count(); 2433 //go backward, field types are removed 2434 for(sal_uInt16 nType = nCount; nType > 0; --nType) 2435 { 2436 const SwFieldType *pCurType = pMyFldTypes->GetObject(nType - 1); 2437 2438 if ( RES_POSTITFLD == pCurType->Which() ) 2439 continue; 2440 2441 SwIterator<SwFmtFld,SwFieldType> aIter( *pCurType ); 2442 ::std::vector<const SwFmtFld*> aFieldFmts; 2443 for( SwFmtFld* pCurFldFmt = aIter.First(); pCurFldFmt; pCurFldFmt = aIter.Next() ) 2444 aFieldFmts.push_back(pCurFldFmt); 2445 2446 ::std::vector<const SwFmtFld*>::iterator aBegin = aFieldFmts.begin(); 2447 ::std::vector<const SwFmtFld*>::iterator aEnd = aFieldFmts.end(); 2448 while(aBegin != aEnd) 2449 { 2450 const SwTxtFld *pTxtFld = (*aBegin)->GetTxtFld(); 2451 // skip fields that are currently not in the document 2452 // e.g. fields in undo or redo array 2453 2454 sal_Bool bSkip = !pTxtFld || 2455 !pTxtFld->GetpTxtNode()->GetNodes().IsDocNodes(); 2456 2457 if (!bSkip) 2458 { 2459 sal_Bool bInHeaderFooter = IsInHeaderFooter(SwNodeIndex(*pTxtFld->GetpTxtNode())); 2460 const SwFmtFld& rFmtFld = pTxtFld->GetFld(); 2461 const SwField* pField = rFmtFld.GetFld(); 2462 2463 //#i55595# some fields have to be excluded in headers/footers 2464 sal_uInt16 nWhich = pField->GetTyp()->Which(); 2465 if(!bInHeaderFooter || 2466 (nWhich != RES_PAGENUMBERFLD && 2467 nWhich != RES_CHAPTERFLD && 2468 nWhich != RES_GETEXPFLD&& 2469 nWhich != RES_SETEXPFLD&& 2470 nWhich != RES_INPUTFLD&& 2471 nWhich != RES_REFPAGEGETFLD&& 2472 nWhich != RES_REFPAGESETFLD)) 2473 { 2474 String sText = pField->ExpandField(true); 2475 //database fields should not convert their command into text 2476 if( RES_DBFLD == pCurType->Which() && !static_cast<const SwDBField*>(pField)->IsInitialized()) 2477 sText.Erase(); 2478 2479 //now remove the field and insert the string 2480 SwPaM aPam1(*pTxtFld->GetpTxtNode(), *pTxtFld->GetStart()); 2481 aPam1.Move(); 2482 //insert first to keep the field's attributes 2483 InsertString( aPam1, sText ); 2484 SwPaM aPam2(*pTxtFld->GetpTxtNode(), *pTxtFld->GetStart()); 2485 aPam2.SetMark(); 2486 aPam2.Move(); 2487 DeleteAndJoin(aPam2);//remove the field 2488 } 2489 } 2490 ++aBegin; 2491 } 2492 } 2493 2494 if( bRet ) 2495 SetModified(); 2496 GetIDocumentUndoRedo().EndUndo( UNDO_UI_REPLACE, NULL ); 2497 UnlockExpFlds(); 2498 return bRet; 2499 2500 } 2501 2502 bool SwDoc::IsVisibleLinks() const 2503 { 2504 return mbVisibleLinks; 2505 } 2506 2507 void SwDoc::SetVisibleLinks(bool bFlag) 2508 { 2509 mbVisibleLinks = bFlag; 2510 } 2511 2512 sfx2::LinkManager& SwDoc::GetLinkManager() 2513 { 2514 return *pLinkMgr; 2515 } 2516 2517 const sfx2::LinkManager& SwDoc::GetLinkManager() const 2518 { 2519 return *pLinkMgr; 2520 } 2521 2522 void SwDoc::SetLinksUpdated(const bool bNewLinksUpdated) 2523 { 2524 mbLinksUpdated = bNewLinksUpdated; 2525 } 2526 2527 bool SwDoc::LinksUpdated() const 2528 { 2529 return mbLinksUpdated; 2530 } 2531 2532 // embedded alle lokalen Links (Bereiche/Grafiken) 2533 ::sfx2::SvBaseLink* lcl_FindNextRemovableLink( const ::sfx2::SvBaseLinks& rLinks, sfx2::LinkManager& rLnkMgr ) 2534 { 2535 for( sal_uInt16 n = 0; n < rLinks.Count(); ++n ) 2536 { 2537 ::sfx2::SvBaseLink* pLnk = &(*rLinks[ n ]); 2538 if( pLnk && 2539 ( OBJECT_CLIENT_GRF == pLnk->GetObjType() || 2540 OBJECT_CLIENT_FILE == pLnk->GetObjType() ) && 2541 pLnk->ISA( SwBaseLink ) ) 2542 { 2543 ::sfx2::SvBaseLinkRef xLink = pLnk; 2544 2545 String sFName; 2546 rLnkMgr.GetDisplayNames( xLink, 0, &sFName, 0, 0 ); 2547 2548 INetURLObject aURL( sFName ); 2549 if( INET_PROT_FILE == aURL.GetProtocol() || 2550 INET_PROT_CID == aURL.GetProtocol() ) 2551 return pLnk; 2552 } 2553 } 2554 return 0; 2555 } 2556 bool SwDoc::EmbedAllLinks() 2557 { 2558 sal_Bool bRet = sal_False; 2559 sfx2::LinkManager& rLnkMgr = GetLinkManager(); 2560 const ::sfx2::SvBaseLinks& rLinks = rLnkMgr.GetLinks(); 2561 if( rLinks.Count() ) 2562 { 2563 ::sw::UndoGuard const undoGuard(GetIDocumentUndoRedo()); 2564 2565 ::sfx2::SvBaseLink* pLnk = 0; 2566 while( 0 != (pLnk = lcl_FindNextRemovableLink( rLinks, rLnkMgr ) ) ) 2567 { 2568 ::sfx2::SvBaseLinkRef xLink = pLnk; 2569 // dem Link sagen, das er aufgeloest wird! 2570 xLink->Closed(); 2571 2572 // falls einer vergessen hat sich auszutragen 2573 if( xLink.Is() ) 2574 rLnkMgr.Remove( xLink ); 2575 2576 bRet = sal_True; 2577 } 2578 2579 GetIDocumentUndoRedo().DelAllUndoObj(); 2580 SetModified(); 2581 } 2582 return bRet; 2583 } 2584 2585 /*-------------------------------------------------------------------- 2586 Beschreibung: 2587 --------------------------------------------------------------------*/ 2588 2589 sal_Bool SwDoc::IsInsTblFormatNum() const 2590 { 2591 return SW_MOD()->IsInsTblFormatNum(get(IDocumentSettingAccess::HTML_MODE)); 2592 } 2593 2594 sal_Bool SwDoc::IsInsTblChangeNumFormat() const 2595 { 2596 return SW_MOD()->IsInsTblChangeNumFormat(get(IDocumentSettingAccess::HTML_MODE)); 2597 } 2598 2599 /*-------------------------------------------------------------------- 2600 Beschreibung: 2601 --------------------------------------------------------------------*/ 2602 2603 sal_Bool SwDoc::IsInsTblAlignNum() const 2604 { 2605 return SW_MOD()->IsInsTblAlignNum(get(IDocumentSettingAccess::HTML_MODE)); 2606 } 2607 2608 // setze das InsertDB als Tabelle Undo auf: 2609 void SwDoc::AppendUndoForInsertFromDB( const SwPaM& rPam, sal_Bool bIsTable ) 2610 { 2611 if( bIsTable ) 2612 { 2613 const SwTableNode* pTblNd = rPam.GetPoint()->nNode.GetNode().FindTableNode(); 2614 if( pTblNd ) 2615 { 2616 SwUndoCpyTbl* pUndo = new SwUndoCpyTbl; 2617 pUndo->SetTableSttIdx( pTblNd->GetIndex() ); 2618 GetIDocumentUndoRedo().AppendUndo( pUndo ); 2619 } 2620 } 2621 else if( rPam.HasMark() ) 2622 { 2623 SwUndoCpyDoc* pUndo = new SwUndoCpyDoc( rPam ); 2624 pUndo->SetInsertRange( rPam, sal_False ); 2625 GetIDocumentUndoRedo().AppendUndo( pUndo ); 2626 } 2627 } 2628 2629 void SwDoc::ChgTOX(SwTOXBase & rTOX, const SwTOXBase & rNew) 2630 { 2631 if (GetIDocumentUndoRedo().DoesUndo()) 2632 { 2633 GetIDocumentUndoRedo().DelAllUndoObj(); 2634 2635 SwUndo * pUndo = new SwUndoTOXChange(&rTOX, rNew); 2636 2637 GetIDocumentUndoRedo().AppendUndo(pUndo); 2638 } 2639 2640 rTOX = rNew; 2641 2642 if (rTOX.ISA(SwTOXBaseSection)) 2643 { 2644 static_cast<SwTOXBaseSection &>(rTOX).Update(); 2645 static_cast<SwTOXBaseSection &>(rTOX).UpdatePageNum(); 2646 } 2647 } 2648 2649 // #111827# 2650 String SwDoc::GetPaMDescr(const SwPaM & rPam) const 2651 { 2652 String aResult; 2653 bool bOK = false; 2654 2655 if (rPam.GetNode(sal_True) == rPam.GetNode(sal_False)) 2656 { 2657 SwTxtNode * pTxtNode = rPam.GetNode(sal_True)->GetTxtNode(); 2658 2659 if (0 != pTxtNode) 2660 { 2661 xub_StrLen nStart = rPam.Start()->nContent.GetIndex(); 2662 xub_StrLen nEnd = rPam.End()->nContent.GetIndex(); 2663 2664 aResult += String(SW_RES(STR_START_QUOTE)); 2665 aResult += ShortenString(pTxtNode->GetTxt(). 2666 Copy(nStart, nEnd - nStart), 2667 nUndoStringLength, 2668 String(SW_RES(STR_LDOTS))); 2669 aResult += String(SW_RES(STR_END_QUOTE)); 2670 2671 bOK = true; 2672 } 2673 } 2674 else if (0 != rPam.GetNode(sal_True)) 2675 { 2676 if (0 != rPam.GetNode(sal_False)) 2677 aResult += String(SW_RES(STR_PARAGRAPHS)); 2678 2679 bOK = true; 2680 } 2681 2682 if (! bOK) 2683 aResult += String("??", RTL_TEXTENCODING_ASCII_US); 2684 2685 return aResult; 2686 } 2687 2688 // -> #111840# 2689 SwField * SwDoc::GetField(const SwPosition & rPos) 2690 { 2691 SwTxtFld * const pAttr = GetTxtFld(rPos); 2692 2693 return (pAttr) ? const_cast<SwField *>( pAttr->GetFld().GetFld() ) : 0; 2694 } 2695 2696 SwTxtFld * SwDoc::GetTxtFld(const SwPosition & rPos) 2697 { 2698 SwTxtNode * const pNode = rPos.nNode.GetNode().GetTxtNode(); 2699 2700 return (pNode) 2701 ? static_cast<SwTxtFld*>( pNode->GetTxtAttrForCharAt( 2702 rPos.nContent.GetIndex(), RES_TXTATR_FIELD) ) 2703 : 0; 2704 } 2705 // <- #111840# 2706 2707 bool SwDoc::ContainsHiddenChars() const 2708 { 2709 for( sal_uLong n = GetNodes().Count(); n; ) 2710 { 2711 SwNode* pNd = GetNodes()[ --n ]; 2712 if ( ND_TEXTNODE == pNd->GetNodeType() && 2713 ((SwTxtNode*)pNd)->HasHiddenCharAttribute( false ) ) 2714 return true; 2715 } 2716 2717 return false; 2718 } 2719 2720 SwUnoCrsr* SwDoc::CreateUnoCrsr( const SwPosition& rPos, sal_Bool bTblCrsr ) 2721 { 2722 SwUnoCrsr* pNew; 2723 if( bTblCrsr ) 2724 pNew = new SwUnoTableCrsr( rPos ); 2725 else 2726 pNew = new SwUnoCrsr( rPos ); 2727 2728 pUnoCrsrTbl->Insert( pNew, pUnoCrsrTbl->Count() ); 2729 return pNew; 2730 } 2731 2732 void SwDoc::ChkCondColls() 2733 { 2734 for (sal_uInt16 n = 0; n < pTxtFmtCollTbl->Count(); n++) 2735 { 2736 SwTxtFmtColl *pColl = (*pTxtFmtCollTbl)[n]; 2737 if (RES_CONDTXTFMTCOLL == pColl->Which()) 2738 pColl->CallSwClientNotify( SwAttrHint(RES_CONDTXTFMTCOLL) ); 2739 } 2740 } 2741 2742 #ifdef FUTURE_VBA 2743 uno::Reference< script::vba::XVBAEventProcessor > 2744 SwDoc::GetVbaEventProcessor() 2745 { 2746 if( !mxVbaEvents.is() && pDocShell && ooo::vba::isAlienWordDoc( *pDocShell ) ) 2747 { 2748 try 2749 { 2750 uno::Reference< frame::XModel > xModel( pDocShell->GetModel(), uno::UNO_SET_THROW ); 2751 uno::Sequence< uno::Any > aArgs(1); 2752 aArgs[0] <<= xModel; 2753 mxVbaEvents.set( ooo::vba::createVBAUnoAPIServiceWithArgs( pDocShell, "com.sun.star.script.vba.VBATextEventProcessor" , aArgs ), uno::UNO_QUERY_THROW ); 2754 } 2755 catch( uno::Exception& ) 2756 { 2757 } 2758 } 2759 return mxVbaEvents; 2760 } 2761 #endif 2762 2763 void SwDoc::setExternalData(::sw::tExternalDataType eType, 2764 ::sw::tExternalDataPointer pPayload) 2765 { 2766 m_externalData[eType] = pPayload; 2767 } 2768 2769 ::sw::tExternalDataPointer SwDoc::getExternalData(::sw::tExternalDataType eType) 2770 { 2771 return m_externalData[eType]; 2772 } 2773