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 <vos/mutex.hxx> 28 #include <vcl/image.hxx> 29 #include <vcl/virdev.hxx> 30 #include <vcl/svapp.hxx> 31 #include <vcl/print.hxx> 32 #include <sfx2/viewfrm.hxx> 33 #include <sfx2/sfxbasecontroller.hxx> 34 #include <sfx2/docfile.hxx> 35 #include <sfx2/printer.hxx> 36 #include <toolkit/helper/vclunohelper.hxx> 37 #include <toolkit/awt/vclxdevice.hxx> 38 #include <cmdid.h> 39 #include <swtypes.hxx> 40 #include <wdocsh.hxx> 41 #include <wrtsh.hxx> 42 #include <view.hxx> 43 #include <pview.hxx> 44 #include <srcview.hxx> 45 #include <viewsh.hxx> 46 #include <pvprtdat.hxx> 47 #include <printdata.hxx> 48 #include <svl/stritem.hxx> 49 #include <unotxdoc.hxx> 50 #include <svl/numuno.hxx> 51 #include <fldbas.hxx> 52 #include <unotextbodyhf.hxx> 53 #include <unotextrange.hxx> 54 #include <unotextcursor.hxx> 55 #include <unosett.hxx> 56 #include <unocoll.hxx> 57 #include <unoredlines.hxx> 58 #include <unosrch.hxx> 59 #include <sfx2/dispatch.hxx> 60 #include <sfx2/request.hxx> 61 #include <sfx2/objsh.hxx> // SfxObjectShellRef <-> SV_DECL_REF(SfxObjectShell) 62 #include <unoprnms.hxx> 63 #include <unostyle.hxx> 64 #include <unodraw.hxx> 65 #include <svl/eitem.hxx> 66 #include <pagedesc.hxx> 67 #include <svtools/txtcmp.hxx> 68 #include <unocrsr.hxx> 69 #include <unofield.hxx> 70 #include <unoidx.hxx> 71 #include <unoflatpara.hxx> 72 #include <unotxvw.hxx> 73 #include <poolfmt.hxx> 74 #include <globdoc.hxx> 75 #include <viewopt.hxx> 76 #include <unochart.hxx> 77 #include <doc.hxx> 78 #include <charatr.hxx> 79 #include <svx/xmleohlp.hxx> 80 #include <globals.hrc> 81 #include <unomid.h> 82 #include <unotools/printwarningoptions.hxx> 83 #include <com/sun/star/util/SearchOptions.hpp> 84 #include <com/sun/star/lang/ServiceNotRegisteredException.hpp> 85 #include <com/sun/star/lang/DisposedException.hpp> 86 #include <com/sun/star/util/XNumberFormatsSupplier.hpp> 87 #include <com/sun/star/beans/PropertyAttribute.hpp> 88 #include <com/sun/star/beans/XFastPropertySet.hpp> 89 #include <com/sun/star/document/RedlineDisplayType.hpp> 90 #include <com/sun/star/document/XDocumentEventBroadcaster.hpp> 91 #include <com/sun/star/frame/XController.hpp> 92 #include <com/sun/star/frame/XFrame.hpp> 93 #include <com/sun/star/script/XInvocation.hpp> 94 #include <com/sun/star/reflection/XIdlClassProvider.hpp> 95 #include <sfx2/linkmgr.hxx> 96 #include <svx/unofill.hxx> 97 #include <editeng/unolingu.hxx> 98 #include <sfx2/progress.hxx> 99 #include <swmodule.hxx> 100 #include <docstat.hxx> 101 #include <modcfg.hxx> 102 #include <ndtxt.hxx> 103 #include <utlui.hrc> 104 #include <swcont.hxx> 105 #include <unodefaults.hxx> 106 #include <SwXDocumentSettings.hxx> 107 #include <doc.hxx> 108 #include <editeng/forbiddencharacterstable.hxx> 109 #include <svl/zforlist.hxx> 110 #include <drawdoc.hxx> 111 #include <SwStyleNameMapper.hxx> 112 #include <osl/file.hxx> 113 #include <comphelper/storagehelper.hxx> 114 115 116 // --> FME 2004-06-08 #i12836# enhanced pdf export 117 #include <EnhancedPDFExportHelper.hxx> 118 // <-- 119 #include <numrule.hxx> 120 121 ///////////////////////////Modified on Jun. 14th////////////////////////// 122 ///////////////////////for getDocumentLanguages/////////////////////////// 123 //--> 124 #include <editeng/langitem.hxx> 125 #include <doc.hxx> 126 #include <docary.hxx> //SwCharFmts 127 #include <i18npool/mslangid.hxx> 128 129 #include <format.hxx> 130 #include <charfmt.hxx> //SwCharFmt 131 #include <fmtcol.hxx> //SwTxtFmtColl 132 #include <unostyle.hxx> //SwAutoStyleFamily 133 #include <istyleaccess.hxx> // handling of automatic styles 134 135 #include <svl/stylepool.hxx> 136 #include <swatrset.hxx> 137 #include <view.hxx> 138 #include <srcview.hxx> 139 140 //#include <com/sun/star/i18n/ScriptType.hpp> 141 #include <svtools/langtab.hxx> 142 #include <map> 143 #include <set> 144 #include <vector> 145 146 #include <editeng/eeitem.hxx> 147 #include <editeng/editeng.hxx> 148 #include <svx/svdoutl.hxx> 149 #include <svl/languageoptions.hxx> 150 #include <svx/svdview.hxx> 151 152 // 153 //<-- 154 using namespace ::com::sun::star; 155 using namespace ::com::sun::star::text; 156 using namespace ::com::sun::star::i18n; 157 using namespace ::com::sun::star::uno; 158 using namespace ::com::sun::star::beans; 159 using namespace ::com::sun::star::lang; 160 using namespace ::com::sun::star::container; 161 using namespace ::com::sun::star::document; 162 using namespace ::com::sun::star::i18n; 163 using ::rtl::OUString; 164 using ::osl::FileBase; 165 166 /* -----------------------------17.01.01 15:43-------------------------------- 167 168 ---------------------------------------------------------------------------*/ 169 #define SW_CREATE_DASH_TABLE 0x01 170 #define SW_CREATE_GRADIENT_TABLE 0x02 171 #define SW_CREATE_HATCH_TABLE 0x03 172 #define SW_CREATE_BITMAP_TABLE 0x04 173 #define SW_CREATE_TRANSGRADIENT_TABLE 0x05 174 #define SW_CREATE_MARKER_TABLE 0x06 175 #define SW_CREATE_DRAW_DEFAULTS 0x07 176 177 178 /****************************************************************************** 179 * 180 ******************************************************************************/ 181 182 extern bool lcl_GetPostIts( IDocumentFieldsAccess* pIDFA, _SetGetExpFlds * pSrtLst ); 183 184 SwPrintUIOptions * lcl_GetPrintUIOptions( 185 SwDocShell * pDocShell, 186 const SfxViewShell * pView ) 187 { 188 if (!pDocShell) 189 return NULL; 190 191 const sal_Bool bWebDoc = NULL != dynamic_cast< const SwWebDocShell * >(pDocShell); 192 const bool bSwSrcView = NULL != dynamic_cast< const SwSrcView * >(pView); 193 const SwView * pSwView = dynamic_cast< const SwView * >(pView); 194 const bool bHasSelection = pSwView ? pSwView->HasSelection( sal_False ) : false; // check for any selection, not just text selection 195 const bool bHasPostIts = lcl_GetPostIts( pDocShell->GetDoc(), 0 ); 196 197 // get default values to use in dialog from documents SwPrintData 198 const SwPrintData &rPrintData = pDocShell->GetDoc()->getPrintData(); 199 200 return new SwPrintUIOptions( bWebDoc, bSwSrcView, bHasSelection, bHasPostIts, rPrintData ); 201 } 202 203 //////////////////////////////////////////////////////////// 204 205 206 SwTxtFmtColl *lcl_GetParaStyle(const String& rCollName, SwDoc* pDoc) 207 { 208 SwTxtFmtColl* pColl = pDoc->FindTxtFmtCollByName( rCollName ); 209 if( !pColl ) 210 { 211 sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName( rCollName, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL ); 212 if( USHRT_MAX != nId ) 213 pColl = pDoc->GetTxtCollFromPool( nId ); 214 } 215 return pColl; 216 } 217 void lcl_DisposeView( SfxViewFrame* pToClose, SwDocShell* pDocShell ) 218 { 219 // check if the view frame still exists 220 SfxViewFrame* pFound = SfxViewFrame::GetFirst( pDocShell, 221 sal_False ); 222 while(pFound) 223 { 224 if( pFound == pToClose) 225 { 226 pToClose->DoClose(); 227 break; 228 } 229 pFound = SfxViewFrame::GetNext( *pFound, 230 pDocShell, 231 sal_False ); 232 } 233 } 234 /* -----------------------------10.03.00 18:02-------------------------------- 235 236 ---------------------------------------------------------------------------*/ 237 const Sequence< sal_Int8 > & SwXTextDocument::getUnoTunnelId() 238 { 239 static Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId(); 240 return aSeq; 241 } 242 /* -----------------------------10.03.00 18:04-------------------------------- 243 244 ---------------------------------------------------------------------------*/ 245 sal_Int64 SAL_CALL SwXTextDocument::getSomething( const Sequence< sal_Int8 >& rId ) 246 throw(RuntimeException) 247 { 248 if( rId.getLength() == 16 249 && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), 250 rId.getConstArray(), 16 ) ) 251 { 252 return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >( this )); 253 } 254 255 sal_Int64 nRet = SfxBaseModel::getSomething( rId ); 256 if ( nRet ) 257 return nRet; 258 else 259 { 260 GetNumberFormatter(); 261 Any aNumTunnel = xNumFmtAgg->queryAggregation(::getCppuType((Reference<XUnoTunnel>*)0)); 262 Reference<XUnoTunnel> xNumTunnel; 263 aNumTunnel >>= xNumTunnel; 264 if(xNumTunnel.is()) 265 return xNumTunnel->getSomething(rId); 266 } 267 268 return SfxBaseModel::getSomething( rId ); 269 } 270 /* -----------------------------16.03.00 14:12-------------------------------- 271 272 ---------------------------------------------------------------------------*/ 273 Any SAL_CALL SwXTextDocument::queryInterface( const uno::Type& rType ) throw(RuntimeException) 274 { 275 Any aRet = SwXTextDocumentBaseClass::queryInterface(rType); 276 if ( !aRet.hasValue() ) 277 aRet = SfxBaseModel::queryInterface(rType); 278 if ( !aRet.hasValue() && 279 rType == ::getCppuType((Reference<lang::XMultiServiceFactory>*)0)) 280 { 281 Reference<lang::XMultiServiceFactory> xTmp = this; 282 aRet <<= xTmp; 283 } 284 285 if ( !aRet.hasValue() 286 && rType != ::getCppuType((Reference< com::sun::star::document::XDocumentEventBroadcaster>*)0) 287 && rType != ::getCppuType((Reference< com::sun::star::frame::XController>*)0) 288 && rType != ::getCppuType((Reference< com::sun::star::frame::XFrame>*)0) 289 && rType != ::getCppuType((Reference< com::sun::star::script::XInvocation>*)0) 290 && rType != ::getCppuType((Reference< com::sun::star::reflection::XIdlClassProvider>*)0) 291 && rType != ::getCppuType((Reference< com::sun::star::beans::XFastPropertySet>*)0) 292 && rType != ::getCppuType((Reference< com::sun::star::awt::XWindow>*)0)) 293 { 294 GetNumberFormatter(); 295 if(xNumFmtAgg.is()) 296 aRet = xNumFmtAgg->queryAggregation(rType); 297 } 298 return aRet; 299 } 300 /* -----------------------------16.03.00 14:12-------------------------------- 301 302 ---------------------------------------------------------------------------*/ 303 void SAL_CALL SwXTextDocument::acquire()throw() 304 { 305 SfxBaseModel::acquire(); 306 } 307 /* -----------------------------16.03.00 14:12-------------------------------- 308 309 ---------------------------------------------------------------------------*/ 310 void SAL_CALL SwXTextDocument::release()throw() 311 { 312 SfxBaseModel::release(); 313 } 314 /* -----------------------------07.12.00 11:37-------------------------------- 315 316 ---------------------------------------------------------------------------*/ 317 Reference< XAdapter > SwXTextDocument::queryAdapter( ) throw(RuntimeException) 318 { 319 return SfxBaseModel::queryAdapter(); 320 } 321 /* -----------------------------16.03.00 14:12-------------------------------- 322 323 ---------------------------------------------------------------------------*/ 324 Sequence< uno::Type > SAL_CALL SwXTextDocument::getTypes() throw(RuntimeException) 325 { 326 Sequence< uno::Type > aBaseTypes = SfxBaseModel::getTypes(); 327 Sequence< uno::Type > aTextTypes = SwXTextDocumentBaseClass::getTypes(); 328 329 Sequence< uno::Type > aNumTypes; 330 GetNumberFormatter(); 331 if(xNumFmtAgg.is()) 332 { 333 const uno::Type& rProvType = ::getCppuType((Reference <XTypeProvider>*)0); 334 Any aNumProv = xNumFmtAgg->queryAggregation(rProvType); 335 Reference<XTypeProvider> xNumProv; 336 if(aNumProv >>= xNumProv) 337 { 338 aNumTypes = xNumProv->getTypes(); 339 } 340 } 341 long nIndex = aBaseTypes.getLength(); 342 // don't forget the lang::XMultiServiceFactory 343 aBaseTypes.realloc(aBaseTypes.getLength() + aTextTypes.getLength() + aNumTypes.getLength() + 1); 344 uno::Type* pBaseTypes = aBaseTypes.getArray(); 345 const uno::Type* pTextTypes = aTextTypes.getConstArray(); 346 long nPos; 347 for(nPos = 0; nPos < aTextTypes.getLength(); nPos++) 348 { 349 pBaseTypes[nIndex++] = pTextTypes[nPos]; 350 } 351 const uno::Type* pNumTypes = aNumTypes.getConstArray(); 352 for(nPos = 0; nPos < aNumTypes.getLength(); nPos++) 353 { 354 pBaseTypes[nIndex++] = pNumTypes[nPos]; 355 } 356 pBaseTypes[nIndex++] = ::getCppuType((Reference<lang::XMultiServiceFactory>*)0); 357 return aBaseTypes; 358 } 359 /*-- 18.12.98 11:52:59--------------------------------------------------- 360 361 -----------------------------------------------------------------------*/ 362 SwXTextDocument::SwXTextDocument(SwDocShell* pShell) : 363 SfxBaseModel(pShell), 364 365 aRefreshCont ( static_cast < XTextDocument* > ( this ) ), 366 367 pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_DOCUMENT)), 368 369 pDocShell(pShell), 370 371 bObjectValid(pShell != 0), 372 373 pDrawPage(0), 374 pxXDrawPage(0), 375 376 pxXNumberingRules(0), 377 pxXFootnotes(0), 378 pxXFootnoteSettings(0), 379 pxXEndnotes(0), 380 pxXEndnoteSettings(0), 381 pxXReferenceMarks(0), 382 pxXTextFieldTypes(0), 383 pxXTextFieldMasters(0), 384 pxXTextSections(0), 385 pxXBookmarks(0), 386 pxXTextTables(0), 387 pxXTextFrames(0), 388 pxXGraphicObjects(0), 389 pxXEmbeddedObjects(0), 390 pxXStyleFamilies(0), 391 pxXAutoStyles(0), 392 pxXChapterNumbering(0), 393 pxXDocumentIndexes(0), 394 395 pxXLineNumberingProperties(0), 396 pxLinkTargetSupplier(0), 397 pxXRedlines(0), 398 m_pHiddenViewFrame(0), 399 m_pPrintUIOptions( NULL ), 400 m_pRenderData( NULL ), 401 // --> OD #i117783# 402 bApplyPagePrintSettingsFromXPagePrintable( sal_False ) 403 // <-- 404 { 405 } 406 /*-- 18.12.98 11:53:00--------------------------------------------------- 407 408 -----------------------------------------------------------------------*/ 409 SwXTextDocument::~SwXTextDocument() 410 { 411 InitNewDoc(); 412 if(xNumFmtAgg.is()) 413 { 414 Reference< XInterface > x0; 415 xNumFmtAgg->setDelegator(x0); 416 xNumFmtAgg = 0; 417 } 418 delete m_pPrintUIOptions; 419 delete m_pRenderData; 420 } 421 422 423 /*-- 18.12.98 11:55:08--------------------------------------------------- 424 425 -----------------------------------------------------------------------*/ 426 /* -----------------18.12.98 12:49------------------- 427 * 428 * --------------------------------------------------*/ 429 SwXDocumentPropertyHelper * SwXTextDocument::GetPropertyHelper () 430 { 431 if(!xPropertyHelper.is()) 432 { 433 pPropertyHelper = new SwXDocumentPropertyHelper(*pDocShell->GetDoc()); 434 xPropertyHelper = (cppu::OWeakObject*)pPropertyHelper; 435 } 436 return pPropertyHelper; 437 } 438 void SwXTextDocument::GetNumberFormatter() 439 { 440 if(IsValid()) 441 { 442 if(!xNumFmtAgg.is()) 443 { 444 if ( pDocShell->GetDoc() ) 445 { 446 SvNumberFormatsSupplierObj* pNumFmt = new SvNumberFormatsSupplierObj( 447 pDocShell->GetDoc()->GetNumberFormatter( sal_True )); 448 Reference< util::XNumberFormatsSupplier > xTmp = pNumFmt; 449 xNumFmtAgg = Reference< XAggregation >(xTmp, UNO_QUERY); 450 } 451 if(xNumFmtAgg.is()) 452 xNumFmtAgg->setDelegator((cppu::OWeakObject*)(SwXTextDocumentBaseClass*)this); 453 } 454 else 455 { 456 const uno::Type& rTunnelType = ::getCppuType((Reference <XUnoTunnel>*)0); 457 Any aNumTunnel = xNumFmtAgg->queryAggregation(rTunnelType); 458 SvNumberFormatsSupplierObj* pNumFmt = 0; 459 Reference< XUnoTunnel > xNumTunnel; 460 if(aNumTunnel >>= xNumTunnel) 461 { 462 pNumFmt = reinterpret_cast<SvNumberFormatsSupplierObj*>( 463 xNumTunnel->getSomething(SvNumberFormatsSupplierObj::getUnoTunnelId())); 464 465 } 466 DBG_ASSERT(pNumFmt, "No number formatter available"); 467 if(!pNumFmt->GetNumberFormatter()) 468 pNumFmt->SetNumberFormatter(pDocShell->GetDoc()->GetNumberFormatter( sal_True )); 469 } 470 } 471 } 472 /*-- 18.12.98 11:55:11--------------------------------------------------- 473 474 -----------------------------------------------------------------------*/ 475 Reference< XText > SwXTextDocument::getText(void) throw( RuntimeException ) 476 { 477 ::vos::OGuard aGuard(Application::GetSolarMutex()); 478 if(!IsValid()) 479 throw RuntimeException(); 480 if(!xBodyText.is()) 481 { 482 pBodyText = new SwXBodyText(pDocShell->GetDoc()); 483 xBodyText = pBodyText; 484 } 485 return xBodyText; 486 } 487 /*-- 18.12.98 11:55:11--------------------------------------------------- 488 489 -----------------------------------------------------------------------*/ 490 void SwXTextDocument::reformat(void) throw( RuntimeException ) 491 { 492 ::vos::OGuard aGuard(Application::GetSolarMutex()); 493 if(!IsValid()) 494 throw RuntimeException(); 495 } 496 /*-- 18.12.98 11:55:16--------------------------------------------------- 497 498 -----------------------------------------------------------------------*/ 499 void SwXTextDocument::lockControllers(void) throw( RuntimeException ) 500 { 501 ::vos::OGuard aGuard(Application::GetSolarMutex()); 502 if(IsValid()) 503 { 504 UnoActionContext* pContext = new UnoActionContext(pDocShell->GetDoc()); 505 aActionArr.Insert(pContext, 0); 506 } 507 else 508 throw RuntimeException(); 509 } 510 /*-- 18.12.98 11:55:16--------------------------------------------------- 511 512 -----------------------------------------------------------------------*/ 513 void SwXTextDocument::unlockControllers(void) throw( RuntimeException ) 514 { 515 ::vos::OGuard aGuard(Application::GetSolarMutex()); 516 if(aActionArr.Count()) 517 { 518 UnoActionContext* pContext = aActionArr.GetObject(0); 519 aActionArr.Remove(0); 520 delete pContext; 521 } 522 else 523 throw RuntimeException(); 524 } 525 /*-- 18.12.98 11:55:17--------------------------------------------------- 526 527 -----------------------------------------------------------------------*/ 528 sal_Bool SwXTextDocument::hasControllersLocked(void) throw( RuntimeException ) 529 { 530 ::vos::OGuard aGuard(Application::GetSolarMutex()); 531 return aActionArr.Count() > 0; 532 } 533 /*-- 18.12.98 13:12:23--------------------------------------------------- 534 535 -----------------------------------------------------------------------*/ 536 Reference< frame::XController > SwXTextDocument::getCurrentController(void) throw( RuntimeException ) 537 { 538 return SfxBaseModel::getCurrentController(); 539 } 540 /*-- 18.12.98 13:12:24--------------------------------------------------- 541 542 -----------------------------------------------------------------------*/ 543 void SwXTextDocument::setCurrentController(const Reference< frame::XController > & xController) 544 throw( NoSuchElementException, RuntimeException ) 545 { 546 SfxBaseModel::setCurrentController(xController); 547 } 548 /* -----------------27.01.99 11:48------------------- 549 * 550 * --------------------------------------------------*/ 551 Reference< XInterface > SwXTextDocument::getCurrentSelection() throw( RuntimeException ) 552 { 553 ::vos::OGuard aGuard(Application::GetSolarMutex()); 554 Reference< XInterface > xRef; 555 if(IsValid()) 556 { 557 558 const TypeId aTypeId = TYPE(SwView); 559 SwView* pView = (SwView*)SfxViewShell::GetFirst(&aTypeId); 560 while(pView && pView->GetObjectShell() != pDocShell) 561 { 562 pView = (SwView*)SfxViewShell::GetNext(*pView, &aTypeId); 563 } 564 if(pView) 565 { 566 Any aRef = pView->GetUNOObject()->getSelection(); 567 aRef >>= xRef; 568 } 569 } 570 return xRef; 571 } 572 573 /*-- 18.12.98 13:12:24--------------------------------------------------- 574 575 -----------------------------------------------------------------------*/ 576 sal_Bool SwXTextDocument::attachResource(const OUString& aURL, const Sequence< beans::PropertyValue >& aArgs) 577 throw( RuntimeException ) 578 { 579 return SfxBaseModel::attachResource(aURL, aArgs); 580 } 581 /*-- 18.12.98 13:12:24--------------------------------------------------- 582 583 -----------------------------------------------------------------------*/ 584 OUString SwXTextDocument::getURL(void) throw( RuntimeException ) 585 { 586 return SfxBaseModel::getURL(); 587 } 588 /*-- 18.12.98 13:12:24--------------------------------------------------- 589 590 -----------------------------------------------------------------------*/ 591 Sequence< beans::PropertyValue > SwXTextDocument::getArgs(void) throw( RuntimeException ) 592 { 593 return SfxBaseModel::getArgs(); 594 } 595 /*-- 18.12.98 13:12:24--------------------------------------------------- 596 597 -----------------------------------------------------------------------*/ 598 void SwXTextDocument::connectController(const Reference< frame::XController > & xController) throw( RuntimeException ) 599 { 600 SfxBaseModel::connectController(xController); 601 } 602 /*-- 18.12.98 13:12:25--------------------------------------------------- 603 604 -----------------------------------------------------------------------*/ 605 void SwXTextDocument::disconnectController(const Reference< frame::XController > & xController) throw( RuntimeException ) 606 { 607 SfxBaseModel::disconnectController(xController); 608 } 609 /*-- 18.12.98 13:12:25--------------------------------------------------- 610 611 -----------------------------------------------------------------------*/ 612 void SwXTextDocument::dispose(void) throw( RuntimeException ) 613 { 614 SfxBaseModel::dispose(); 615 } 616 /*-- 10.05.2005 14:14:39--------------------------------------------------- 617 618 -----------------------------------------------------------------------*/ 619 void SwXTextDocument::close( sal_Bool bDeliverOwnership ) throw( util::CloseVetoException, RuntimeException ) 620 { 621 if(IsValid() && m_pHiddenViewFrame) 622 lcl_DisposeView( m_pHiddenViewFrame, pDocShell); 623 SfxBaseModel::close(bDeliverOwnership); 624 } 625 /*-- 18.12.98 13:12:25--------------------------------------------------- 626 627 -----------------------------------------------------------------------*/ 628 void SwXTextDocument::addEventListener(const Reference< lang::XEventListener > & aListener) throw( RuntimeException ) 629 { 630 SfxBaseModel::addEventListener(aListener); 631 } 632 /*-- 18.12.98 13:12:26--------------------------------------------------- 633 634 -----------------------------------------------------------------------*/ 635 void SwXTextDocument::removeEventListener(const Reference< lang::XEventListener > & aListener) throw( RuntimeException ) 636 { 637 SfxBaseModel::removeEventListener(aListener); 638 } 639 640 /*-- 18.12.98 11:55:19--------------------------------------------------- 641 642 -----------------------------------------------------------------------*/ 643 Reference< XPropertySet > SwXTextDocument::getLineNumberingProperties(void) 644 throw( RuntimeException ) 645 { 646 ::vos::OGuard aGuard(Application::GetSolarMutex()); 647 if(IsValid()) 648 { 649 if(!pxXLineNumberingProperties) 650 { 651 pxXLineNumberingProperties = new Reference<XPropertySet>; 652 (*pxXLineNumberingProperties) = new SwXLineNumberingProperties(pDocShell->GetDoc()); 653 } 654 } 655 else 656 throw RuntimeException(); 657 return *pxXLineNumberingProperties; 658 } 659 /*-- 18.12.98 11:55:20--------------------------------------------------- 660 661 -----------------------------------------------------------------------*/ 662 Reference< XIndexReplace > SwXTextDocument::getChapterNumberingRules(void) 663 throw( RuntimeException ) 664 { 665 ::vos::OGuard aGuard(Application::GetSolarMutex()); 666 if(!IsValid()) 667 throw RuntimeException(); 668 if(!pxXChapterNumbering) 669 { 670 pxXChapterNumbering = new Reference< XIndexReplace > ; 671 *pxXChapterNumbering = new SwXChapterNumbering(*pDocShell); 672 } 673 return *pxXChapterNumbering; 674 } 675 676 Reference< XIndexAccess > SwXTextDocument::getNumberingRules(void) throw( RuntimeException ) 677 { 678 ::vos::OGuard aGuard(Application::GetSolarMutex()); 679 if(!IsValid()) 680 throw RuntimeException(); 681 if(!pxXNumberingRules ) 682 { 683 ((SwXTextDocument*)this)->pxXNumberingRules = new Reference< XIndexAccess > ; 684 *pxXNumberingRules = new SwXNumberingRulesCollection( pDocShell->GetDoc() ); 685 } 686 return *pxXNumberingRules; 687 } 688 689 /*-- 18.12.98 11:55:21--------------------------------------------------- 690 691 -----------------------------------------------------------------------*/ 692 Reference< XIndexAccess > SwXTextDocument::getFootnotes(void) throw( RuntimeException ) 693 { 694 ::vos::OGuard aGuard(Application::GetSolarMutex()); 695 if(!IsValid()) 696 throw RuntimeException(); 697 if(!pxXFootnotes) 698 { 699 ((SwXTextDocument*)this)->pxXFootnotes = new Reference< XIndexAccess > ; 700 *pxXFootnotes = new SwXFootnotes(sal_False, pDocShell->GetDoc()); 701 } 702 return *pxXFootnotes; 703 } 704 /*-- 18.12.98 11:55:21--------------------------------------------------- 705 706 -----------------------------------------------------------------------*/ 707 Reference< XPropertySet > SAL_CALL 708 SwXTextDocument::getFootnoteSettings(void) throw( RuntimeException ) 709 { 710 ::vos::OGuard aGuard(Application::GetSolarMutex()); 711 if(!IsValid()) 712 throw RuntimeException(); 713 if(!pxXFootnoteSettings) 714 { 715 ((SwXTextDocument*)this)->pxXFootnoteSettings = new Reference< XPropertySet > ; 716 *pxXFootnoteSettings = new SwXFootnoteProperties(pDocShell->GetDoc()); 717 } 718 return *pxXFootnoteSettings; 719 } 720 /*-- 18.12.98 11:55:21--------------------------------------------------- 721 722 -----------------------------------------------------------------------*/ 723 Reference< XIndexAccess > SwXTextDocument::getEndnotes(void) throw( RuntimeException ) 724 { 725 ::vos::OGuard aGuard(Application::GetSolarMutex()); 726 if(!IsValid()) 727 throw RuntimeException(); 728 if(!pxXEndnotes) 729 { 730 ((SwXTextDocument*)this)->pxXEndnotes = new Reference< XIndexAccess > ; 731 *pxXEndnotes = new SwXFootnotes(sal_True, pDocShell->GetDoc()); 732 } 733 return *pxXEndnotes; 734 } 735 /*-- 18.12.98 11:55:22--------------------------------------------------- 736 737 -----------------------------------------------------------------------*/ 738 Reference< XPropertySet > SwXTextDocument::getEndnoteSettings(void) throw( RuntimeException ) 739 { 740 ::vos::OGuard aGuard(Application::GetSolarMutex()); 741 if(!IsValid()) 742 throw RuntimeException(); 743 if(!pxXEndnoteSettings) 744 { 745 ((SwXTextDocument*)this)->pxXEndnoteSettings = new Reference< XPropertySet > ; 746 *pxXEndnoteSettings = new SwXEndnoteProperties(pDocShell->GetDoc()); 747 } 748 return *pxXEndnoteSettings; 749 } 750 /*-- 18.12.98 11:55:22--------------------------------------------------- 751 752 -----------------------------------------------------------------------*/ 753 Reference< util::XReplaceDescriptor > SwXTextDocument::createReplaceDescriptor(void) 754 throw( RuntimeException ) 755 { 756 ::vos::OGuard aGuard(Application::GetSolarMutex()); 757 Reference< util::XReplaceDescriptor > xRet = new SwXTextSearch; 758 return xRet; 759 } 760 /* -----------------26.02.99 15:52------------------- 761 * 762 * --------------------------------------------------*/ 763 SwUnoCrsr* SwXTextDocument::CreateCursorForSearch(Reference< XTextCursor > & xCrsr) 764 { 765 getText(); 766 XText *const pText = xBodyText.get(); 767 SwXBodyText* pBText = (SwXBodyText*)pText; 768 SwXTextCursor *const pXTextCursor = pBText->CreateTextCursor(true); 769 xCrsr.set( static_cast<text::XWordCursor*>(pXTextCursor) ); 770 771 SwUnoCrsr *const pUnoCrsr = pXTextCursor->GetCursor(); 772 pUnoCrsr->SetRemainInSection(sal_False); 773 return pUnoCrsr; 774 } 775 776 /*-- 18.12.98 11:55:22--------------------------------------------------- 777 778 -----------------------------------------------------------------------*/ 779 sal_Int32 SwXTextDocument::replaceAll(const Reference< util::XSearchDescriptor > & xDesc) 780 throw( RuntimeException ) 781 { 782 ::vos::OGuard aGuard(Application::GetSolarMutex()); 783 Reference< XUnoTunnel > xDescTunnel(xDesc, UNO_QUERY); 784 if(!IsValid() || !xDescTunnel.is() || !xDescTunnel->getSomething(SwXTextSearch::getUnoTunnelId())) 785 throw RuntimeException(); 786 787 Reference< XTextCursor > xCrsr; 788 SwUnoCrsr* pUnoCrsr = CreateCursorForSearch(xCrsr); 789 790 const SwXTextSearch* pSearch = reinterpret_cast<const SwXTextSearch*>( 791 xDescTunnel->getSomething(SwXTextSearch::getUnoTunnelId())); 792 793 int eRanges(FND_IN_BODY|FND_IN_SELALL); 794 795 util::SearchOptions aSearchOpt; 796 pSearch->FillSearchOptions( aSearchOpt ); 797 798 SwDocPositions eStart = pSearch->bBack ? DOCPOS_END : DOCPOS_START; 799 SwDocPositions eEnd = pSearch->bBack ? DOCPOS_START : DOCPOS_END; 800 801 // Suche soll ueberall stattfinden 802 pUnoCrsr->SetRemainInSection(sal_False); 803 sal_uInt32 nResult; 804 UnoActionContext aContext(pDocShell->GetDoc()); 805 //try attribute search first 806 if(pSearch->HasSearchAttributes()||pSearch->HasReplaceAttributes()) 807 { 808 SfxItemSet aSearch(pDocShell->GetDoc()->GetAttrPool(), 809 RES_CHRATR_BEGIN, RES_CHRATR_END-1, 810 RES_PARATR_BEGIN, RES_PARATR_END-1, 811 RES_FRMATR_BEGIN, RES_FRMATR_END-1, 812 0); 813 SfxItemSet aReplace(pDocShell->GetDoc()->GetAttrPool(), 814 RES_CHRATR_BEGIN, RES_CHRATR_END-1, 815 RES_PARATR_BEGIN, RES_PARATR_END-1, 816 RES_FRMATR_BEGIN, RES_FRMATR_END-1, 817 0); 818 pSearch->FillSearchItemSet(aSearch); 819 pSearch->FillReplaceItemSet(aReplace); 820 sal_Bool bCancel; 821 nResult = (sal_Int32)pUnoCrsr->Find( aSearch, !pSearch->bStyles, 822 eStart, eEnd, bCancel, 823 (FindRanges)eRanges, 824 pSearch->sSearchText.Len() ? &aSearchOpt : 0, 825 &aReplace ); 826 } 827 else if(pSearch->bStyles) 828 { 829 SwTxtFmtColl *pSearchColl = lcl_GetParaStyle(pSearch->sSearchText, pUnoCrsr->GetDoc()); 830 SwTxtFmtColl *pReplaceColl = lcl_GetParaStyle(pSearch->sReplaceText, pUnoCrsr->GetDoc());; 831 832 sal_Bool bCancel; 833 nResult = pUnoCrsr->Find( *pSearchColl, 834 eStart, eEnd, bCancel, 835 (FindRanges)eRanges, pReplaceColl ); 836 837 } 838 else 839 { 840 //todo/mba: assuming that notes should be omitted 841 sal_Bool bSearchInNotes = sal_False; 842 sal_Bool bCancel; 843 nResult = pUnoCrsr->Find( aSearchOpt, bSearchInNotes, 844 eStart, eEnd, bCancel, 845 (FindRanges)eRanges, 846 sal_True ); 847 } 848 return (sal_Int32)nResult; 849 850 } 851 /*-- 18.12.98 11:55:22--------------------------------------------------- 852 853 -----------------------------------------------------------------------*/ 854 Reference< util::XSearchDescriptor > SwXTextDocument::createSearchDescriptor(void) 855 throw( RuntimeException ) 856 { 857 ::vos::OGuard aGuard(Application::GetSolarMutex()); 858 Reference< util::XSearchDescriptor > xRet = new SwXTextSearch; 859 return xRet; 860 861 } 862 /* -----------------26.02.99 16:08------------------- 863 * wird fuer findAll/First/Next verwendet 864 * --------------------------------------------------*/ 865 SwUnoCrsr* SwXTextDocument::FindAny(const Reference< util::XSearchDescriptor > & xDesc, 866 Reference< XTextCursor > & xCrsr, sal_Bool bAll, 867 sal_Int32& nResult, 868 Reference< XInterface > xLastResult) 869 { 870 Reference< XUnoTunnel > xDescTunnel(xDesc, UNO_QUERY); 871 if(!IsValid() || !xDescTunnel.is() || !xDescTunnel->getSomething(SwXTextSearch::getUnoTunnelId())) 872 return 0; 873 874 SwUnoCrsr* pUnoCrsr = CreateCursorForSearch(xCrsr); 875 const SwXTextSearch* pSearch = reinterpret_cast<const SwXTextSearch*>( 876 xDescTunnel->getSomething(SwXTextSearch::getUnoTunnelId())); 877 878 sal_Bool bParentInExtra = sal_False; 879 if(xLastResult.is()) 880 { 881 Reference<XUnoTunnel> xCursorTunnel( xLastResult, UNO_QUERY); 882 OTextCursorHelper* pPosCrsr = 0; 883 if(xCursorTunnel.is()) 884 { 885 pPosCrsr = reinterpret_cast<OTextCursorHelper*>(xCursorTunnel->getSomething( 886 OTextCursorHelper::getUnoTunnelId())); 887 } 888 SwPaM* pCrsr = pPosCrsr ? pPosCrsr->GetPaM() : 0; 889 if(pCrsr) 890 { 891 *pUnoCrsr->GetPoint() = *pCrsr->End(); 892 pUnoCrsr->DeleteMark(); 893 } 894 else 895 { 896 SwXTextRange* pRange = 0; 897 if(xCursorTunnel.is()) 898 { 899 pRange = reinterpret_cast<SwXTextRange*>(xCursorTunnel->getSomething( 900 SwXTextRange::getUnoTunnelId())); 901 } 902 if(!pRange) 903 return 0; 904 pRange->GetPositions(*pUnoCrsr); 905 if(pUnoCrsr->HasMark()) 906 { 907 if(*pUnoCrsr->GetPoint() < *pUnoCrsr->GetMark()) 908 pUnoCrsr->Exchange(); 909 pUnoCrsr->DeleteMark(); 910 } 911 } 912 const SwNode* pRangeNode = pUnoCrsr->GetNode(); 913 bParentInExtra = pRangeNode->FindFlyStartNode() || 914 pRangeNode->FindFootnoteStartNode() || 915 pRangeNode->FindHeaderStartNode() || 916 pRangeNode->FindFooterStartNode() ; 917 } 918 919 util::SearchOptions aSearchOpt; 920 pSearch->FillSearchOptions( aSearchOpt ); 921 922 /* 923 * folgende Kombinationen sind erlaubt: 924 * - suche einen im Body: -> FND_IN_BODY 925 * - suche alle im Body: -> FND_IN_BODYONLY | FND_IN_SELALL 926 * - suche in Selectionen: einen / alle -> FND_IN_SEL [ | FND_IN_SELALL ] 927 * - suche im nicht Body: einen / alle -> FND_IN_OTHER [ | FND_IN_SELALL ] 928 * - suche ueberall alle: -> FND_IN_SELALL 929 */ 930 int eRanges(FND_IN_BODY); 931 if(bParentInExtra) 932 eRanges = FND_IN_OTHER; 933 if(bAll) //immer - ueberall? 934 eRanges = FND_IN_SELALL; 935 SwDocPositions eStart = !bAll ? DOCPOS_CURR : pSearch->bBack ? DOCPOS_END : DOCPOS_START; 936 SwDocPositions eEnd = pSearch->bBack ? DOCPOS_START : DOCPOS_END; 937 938 nResult = 0; 939 sal_uInt16 nSearchProc = 0; 940 while(nSearchProc < 2) 941 { 942 //try attribute search first 943 if(pSearch->HasSearchAttributes()) 944 { 945 SfxItemSet aSearch(pDocShell->GetDoc()->GetAttrPool(), 946 RES_CHRATR_BEGIN, RES_CHRATR_END-1, 947 RES_PARATR_BEGIN, RES_PARATR_END-1, 948 RES_FRMATR_BEGIN, RES_FRMATR_END-1, 949 RES_TXTATR_INETFMT, RES_TXTATR_CHARFMT, 950 0); 951 pSearch->FillSearchItemSet(aSearch); 952 sal_Bool bCancel; 953 nResult = (sal_Int32)pUnoCrsr->Find( aSearch, !pSearch->bStyles, 954 eStart, eEnd, bCancel, 955 (FindRanges)eRanges, 956 pSearch->sSearchText.Len() ? &aSearchOpt : 0, 957 0 ); 958 } 959 else if(pSearch->bStyles) 960 { 961 SwTxtFmtColl *pSearchColl = lcl_GetParaStyle(pSearch->sSearchText, pUnoCrsr->GetDoc()); 962 //pSearch->sReplaceText 963 SwTxtFmtColl *pReplaceColl = 0; 964 sal_Bool bCancel; 965 nResult = (sal_Int32)pUnoCrsr->Find( *pSearchColl, 966 eStart, eEnd, bCancel, 967 (FindRanges)eRanges, pReplaceColl ); 968 } 969 else 970 { 971 //todo/mba: assuming that notes should be omitted 972 sal_Bool bSearchInNotes = sal_False; 973 sal_Bool bCancel; 974 nResult = (sal_Int32)pUnoCrsr->Find( aSearchOpt, bSearchInNotes, 975 eStart, eEnd, bCancel, 976 (FindRanges)eRanges, 977 /*int bReplace =*/sal_False ); 978 } 979 nSearchProc++; 980 if(nResult || (eRanges&(FND_IN_SELALL|FND_IN_OTHER))) 981 break; 982 //second step - find in other 983 eRanges = FND_IN_OTHER; 984 } 985 return pUnoCrsr; 986 } 987 /*-- 18.12.98 11:55:23--------------------------------------------------- 988 989 -----------------------------------------------------------------------*/ 990 Reference< XIndexAccess > 991 SwXTextDocument::findAll(const Reference< util::XSearchDescriptor > & xDesc) 992 throw( RuntimeException ) 993 { 994 ::vos::OGuard aGuard(Application::GetSolarMutex()); 995 Reference< XInterface > xTmp; 996 sal_Int32 nResult = 0; 997 Reference< XTextCursor > xCrsr; 998 SwUnoCrsr* pResultCrsr = FindAny(xDesc, xCrsr, sal_True, nResult, xTmp); 999 if(!pResultCrsr) 1000 throw RuntimeException(); 1001 Reference< XIndexAccess > xRet; 1002 xRet = new SwXTextRanges( (nResult) ? pResultCrsr : 0 ); 1003 delete pResultCrsr; 1004 return xRet; 1005 } 1006 /*-- 18.12.98 11:55:23--------------------------------------------------- 1007 1008 -----------------------------------------------------------------------*/ 1009 Reference< XInterface > SwXTextDocument::findFirst(const Reference< util::XSearchDescriptor > & xDesc) 1010 throw( RuntimeException ) 1011 { 1012 ::vos::OGuard aGuard(Application::GetSolarMutex()); 1013 Reference< XInterface > xTmp; 1014 sal_Int32 nResult = 0; 1015 Reference< XTextCursor > xCrsr; 1016 SwUnoCrsr* pResultCrsr = FindAny(xDesc, xCrsr, sal_False, nResult, xTmp); 1017 if(!pResultCrsr) 1018 throw RuntimeException(); 1019 Reference< XInterface > xRet; 1020 if(nResult) 1021 { 1022 const uno::Reference< text::XText > xParent = 1023 ::sw::CreateParentXText(*pDocShell->GetDoc(), 1024 *pResultCrsr->GetPoint()); 1025 xRet = *new SwXTextCursor(xParent, *pResultCrsr); 1026 delete pResultCrsr; 1027 } 1028 return xRet; 1029 } 1030 /*-- 18.12.98 11:55:24--------------------------------------------------- 1031 1032 -----------------------------------------------------------------------*/ 1033 Reference< XInterface > SwXTextDocument::findNext(const Reference< XInterface > & xStartAt, 1034 const Reference< util::XSearchDescriptor > & xDesc) 1035 throw( RuntimeException ) 1036 { 1037 ::vos::OGuard aGuard(Application::GetSolarMutex()); 1038 Reference< XInterface > xTmp; 1039 sal_Int32 nResult = 0; 1040 Reference< XTextCursor > xCrsr; 1041 if(!xStartAt.is()) 1042 throw RuntimeException(); 1043 SwUnoCrsr* pResultCrsr = FindAny(xDesc, xCrsr, sal_False, nResult, xStartAt); 1044 if(!pResultCrsr) 1045 throw RuntimeException(); 1046 Reference< XInterface > xRet; 1047 if(nResult) 1048 { 1049 const uno::Reference< text::XText > xParent = 1050 ::sw::CreateParentXText(*pDocShell->GetDoc(), 1051 *pResultCrsr->GetPoint()); 1052 1053 xRet = *new SwXTextCursor(xParent, *pResultCrsr); 1054 delete pResultCrsr; 1055 } 1056 return xRet; 1057 } 1058 /*-- 18.12.98 11:55:24--------------------------------------------------- 1059 1060 -----------------------------------------------------------------------*/ 1061 Sequence< beans::PropertyValue > SwXTextDocument::getPagePrintSettings(void) 1062 throw( RuntimeException ) 1063 { 1064 ::vos::OGuard aGuard(Application::GetSolarMutex()); 1065 Sequence< beans::PropertyValue > aSeq(9); 1066 if(IsValid()) 1067 { 1068 beans::PropertyValue* pArray = aSeq.getArray(); 1069 SwPagePreViewPrtData aData; 1070 const SwPagePreViewPrtData* pData = pDocShell->GetDoc()->GetPreViewPrtData(); 1071 if(pData) 1072 aData = *pData; 1073 Any aVal; 1074 aVal <<= (sal_Int16)aData.GetRow(); 1075 pArray[0] = beans::PropertyValue(C2U("PageRows"), -1, aVal, PropertyState_DIRECT_VALUE); 1076 aVal <<= (sal_Int16)aData.GetCol(); 1077 pArray[1] = beans::PropertyValue(C2U("PageColumns"), -1, aVal, PropertyState_DIRECT_VALUE); 1078 aVal <<= (sal_Int32)TWIP_TO_MM100_UNSIGNED(aData.GetLeftSpace()); 1079 pArray[2] = beans::PropertyValue(C2U("LeftMargin"), -1, aVal, PropertyState_DIRECT_VALUE); 1080 aVal <<= (sal_Int32)TWIP_TO_MM100_UNSIGNED(aData.GetRightSpace()); 1081 pArray[3] = beans::PropertyValue(C2U("RightMargin"), -1, aVal, PropertyState_DIRECT_VALUE); 1082 aVal <<= (sal_Int32)TWIP_TO_MM100_UNSIGNED(aData.GetTopSpace()); 1083 pArray[4] = beans::PropertyValue(C2U("TopMargin"), -1, aVal, PropertyState_DIRECT_VALUE); 1084 aVal <<= (sal_Int32)TWIP_TO_MM100_UNSIGNED(aData.GetBottomSpace()); 1085 pArray[5] = beans::PropertyValue(C2U("BottomMargin"), -1, aVal, PropertyState_DIRECT_VALUE); 1086 aVal <<= (sal_Int32)TWIP_TO_MM100_UNSIGNED(aData.GetHorzSpace()); 1087 pArray[6] = beans::PropertyValue(C2U("HoriMargin"), -1, aVal, PropertyState_DIRECT_VALUE); 1088 aVal <<= (sal_Int32)TWIP_TO_MM100_UNSIGNED(aData.GetVertSpace()); 1089 pArray[7] = beans::PropertyValue(C2U("VertMargin"), -1, aVal, PropertyState_DIRECT_VALUE); 1090 sal_Bool bTemp = aData.GetLandscape(); 1091 aVal.setValue(&bTemp, ::getCppuBooleanType()); 1092 pArray[8] = beans::PropertyValue(C2U("IsLandscape"), -1, aVal, PropertyState_DIRECT_VALUE); 1093 } 1094 else 1095 throw RuntimeException(); 1096 return aSeq; 1097 } 1098 /* -----------------24.02.99 10:57------------------- 1099 * 1100 * --------------------------------------------------*/ 1101 sal_uInt32 lcl_Any_To_ULONG(const Any& rValue, sal_Bool& bException) 1102 { 1103 bException = sal_False; 1104 TypeClass eType = rValue.getValueType().getTypeClass(); 1105 1106 sal_uInt32 nRet = 0; 1107 if( eType == TypeClass_UNSIGNED_LONG ) 1108 rValue >>= nRet; 1109 else 1110 { 1111 sal_Int32 nVal=0; 1112 bException = !(rValue >>= nVal); 1113 if( !bException ) 1114 nRet = (sal_uInt32)nVal; 1115 } 1116 1117 return nRet; 1118 } 1119 /*-- 09.06.2004 12:18:10--------------------------------------------------- 1120 1121 -----------------------------------------------------------------------*/ 1122 String lcl_CreateOutlineString( sal_uInt16 nIndex, 1123 const SwOutlineNodes& rOutlineNodes, const SwNumRule* pOutlRule) 1124 { 1125 String sEntry; 1126 const SwTxtNode * pTxtNd = rOutlineNodes[ nIndex ]->GetTxtNode(); 1127 SwNumberTree::tNumberVector aNumVector = pTxtNd->GetNumberVector(); 1128 if( pOutlRule && pTxtNd->GetNumRule()) 1129 for( sal_Int8 nLevel = 0; 1130 nLevel <= pTxtNd->GetActualListLevel(); 1131 nLevel++ ) 1132 { 1133 long nVal = aNumVector[nLevel]; 1134 nVal ++; 1135 nVal -= pOutlRule->Get(nLevel).GetStart(); 1136 sEntry += String::CreateFromInt32( nVal ); 1137 sEntry += '.'; 1138 } 1139 sEntry += rOutlineNodes[ nIndex ]-> 1140 GetTxtNode()->GetExpandTxt( 0, STRING_LEN, sal_False ); 1141 return sEntry; 1142 } 1143 /*-- 18.12.98 11:55:25--------------------------------------------------- 1144 1145 -----------------------------------------------------------------------*/ 1146 void SwXTextDocument::setPagePrintSettings(const Sequence< beans::PropertyValue >& aSettings) 1147 throw( RuntimeException ) 1148 { 1149 ::vos::OGuard aGuard(Application::GetSolarMutex()); 1150 if(IsValid()) 1151 { 1152 SwPagePreViewPrtData aData; 1153 //falls nur einige Properties kommen, dann die akt. Einstellungen benutzen 1154 const SwPagePreViewPrtData* pData = pDocShell->GetDoc()->GetPreViewPrtData(); 1155 if(pData) 1156 aData = *pData; 1157 const beans::PropertyValue* pProperties = aSettings.getConstArray(); 1158 int nCount = aSettings.getLength(); 1159 for(int i = 0; i < nCount; i++) 1160 { 1161 String sName = pProperties[i].Name; 1162 const Any& rVal = pProperties[i].Value; 1163 sal_Bool bException; 1164 sal_uInt32 nVal = lcl_Any_To_ULONG(rVal, bException); 1165 if( COMPARE_EQUAL == sName.CompareToAscii("PageRows" ) ) 1166 { 1167 if(!nVal || nVal > 0xff) 1168 throw RuntimeException(); 1169 aData.SetRow((sal_uInt8)nVal); 1170 } 1171 else if(COMPARE_EQUAL == sName.CompareToAscii("PageColumns")) 1172 { 1173 if(!nVal || nVal > 0xff) 1174 throw RuntimeException(); 1175 aData.SetCol((sal_uInt8)nVal); 1176 } 1177 else if(COMPARE_EQUAL == sName.CompareToAscii("LeftMargin")) 1178 { 1179 aData.SetLeftSpace(MM100_TO_TWIP_UNSIGNED(nVal)); 1180 } 1181 else if(COMPARE_EQUAL == sName.CompareToAscii("RightMargin")) 1182 { 1183 aData.SetRightSpace(MM100_TO_TWIP_UNSIGNED(nVal)); 1184 } 1185 else if(COMPARE_EQUAL == sName.CompareToAscii("TopMargin")) 1186 { 1187 aData.SetTopSpace(MM100_TO_TWIP_UNSIGNED(nVal)); 1188 } 1189 else if(COMPARE_EQUAL == sName.CompareToAscii("BottomMargin")) 1190 { 1191 aData.SetBottomSpace(MM100_TO_TWIP_UNSIGNED(nVal)); 1192 } 1193 else if(COMPARE_EQUAL == sName.CompareToAscii("HoriMargin")) 1194 { 1195 aData.SetHorzSpace(MM100_TO_TWIP_UNSIGNED(nVal)); 1196 } 1197 else if(COMPARE_EQUAL == sName.CompareToAscii("VertMargin")) 1198 { 1199 aData.SetVertSpace(MM100_TO_TWIP_UNSIGNED(nVal)); 1200 } 1201 else if(COMPARE_EQUAL == sName.CompareToAscii("IsLandscape")) 1202 { 1203 bException = (::getBooleanCppuType() != rVal.getValueType()); 1204 aData.SetLandscape(*(sal_Bool*)rVal.getValue()); 1205 } 1206 else 1207 bException = sal_True; 1208 if(bException) 1209 throw RuntimeException(); 1210 } 1211 pDocShell->GetDoc()->SetPreViewPrtData(&aData); 1212 } 1213 else 1214 throw RuntimeException(); 1215 } 1216 /*-- 18.12.98 11:55:25--------------------------------------------------- 1217 1218 -----------------------------------------------------------------------*/ 1219 void SwXTextDocument::printPages(const Sequence< beans::PropertyValue >& xOptions) 1220 throw( IllegalArgumentException, RuntimeException ) 1221 { 1222 ::vos::OGuard aGuard(Application::GetSolarMutex()); 1223 if(IsValid()) 1224 { 1225 SfxViewFrame* pFrame = SfxViewFrame::LoadHiddenDocument( *pDocShell, 7 ); 1226 SfxRequest aReq(FN_PRINT_PAGEPREVIEW, SFX_CALLMODE_SYNCHRON, 1227 pDocShell->GetDoc()->GetAttrPool()); 1228 aReq.AppendItem(SfxBoolItem(FN_PRINT_PAGEPREVIEW, sal_True)); 1229 1230 OUString sFileName( C2U(SW_PROP_NAME_STR(UNO_NAME_FILE_NAME))); 1231 OUString sCopyCount(C2U(SW_PROP_NAME_STR(UNO_NAME_COPY_COUNT))); 1232 OUString sCollate(C2U(SW_PROP_NAME_STR(UNO_NAME_COLLATE))); 1233 OUString sSort(C2U(SW_PROP_NAME_STR(UNO_NAME_SORT))); 1234 OUString sPages(C2U(SW_PROP_NAME_STR(UNO_NAME_PAGES))); 1235 1236 for ( int n = 0; n < xOptions.getLength(); ++n ) 1237 { 1238 // get Property-Value from options 1239 const beans::PropertyValue &rProp = xOptions.getConstArray()[n]; 1240 Any aValue( rProp.Value ); 1241 1242 // FileName-Property? 1243 if ( rProp.Name == sFileName ) 1244 { 1245 OUString sFileURL; 1246 if ( (rProp.Value >>= sFileURL ) ) 1247 { 1248 // Convert the File URL into a system dependant path, as the SalPrinter expects 1249 OUString sSystemPath; 1250 FileBase::getSystemPathFromFileURL ( sFileURL, sSystemPath ); 1251 aReq.AppendItem(SfxStringItem( SID_FILE_NAME, sSystemPath ) ); 1252 } 1253 else if ( rProp.Value.getValueType() != ::getVoidCppuType() ) 1254 throw IllegalArgumentException(); 1255 } 1256 1257 // CopyCount-Property 1258 else if ( rProp.Name == sCopyCount ) 1259 { 1260 sal_Int32 nCopies = 0; 1261 aValue >>= nCopies; 1262 aReq.AppendItem(SfxInt16Item( SID_PRINT_COPIES, (sal_Int16)nCopies ) ); 1263 } 1264 1265 // Collate-Property 1266 else if ( rProp.Name == sCollate ) 1267 { 1268 if ( rProp.Value.getValueType() == ::getBooleanCppuType()) 1269 1270 aReq.AppendItem(SfxBoolItem( SID_PRINT_COLLATE, *(sal_Bool*)rProp.Value.getValue() ) ); 1271 else 1272 throw IllegalArgumentException(); 1273 } 1274 1275 // Sort-Property 1276 else if ( rProp.Name == sSort ) 1277 { 1278 if ( rProp.Value.getValueType() == ::getBooleanCppuType() ) 1279 aReq.AppendItem(SfxBoolItem( SID_PRINT_SORT, *(sal_Bool*)rProp.Value.getValue() ) ); 1280 else 1281 throw IllegalArgumentException(); 1282 } 1283 1284 // Pages-Property 1285 else if ( rProp.Name == sPages ) 1286 { 1287 OUString sTmp; 1288 if ( rProp.Value >>= sTmp ) 1289 aReq.AppendItem( SfxStringItem( SID_PRINT_PAGES, sTmp ) ); 1290 else 1291 throw IllegalArgumentException(); 1292 } 1293 } 1294 1295 // --> OD #i117783# 1296 bApplyPagePrintSettingsFromXPagePrintable = sal_True; 1297 // <-- 1298 pFrame->GetViewShell()->ExecuteSlot(aReq); 1299 // Frame schliessen 1300 pFrame->DoClose(); 1301 1302 } 1303 else 1304 throw RuntimeException(); 1305 } 1306 /*-- 18.12.98 11:55:25--------------------------------------------------- 1307 1308 -----------------------------------------------------------------------*/ 1309 Reference< XNameAccess > SwXTextDocument::getReferenceMarks(void) 1310 throw( RuntimeException ) 1311 { 1312 ::vos::OGuard aGuard(Application::GetSolarMutex()); 1313 if(!IsValid()) 1314 throw RuntimeException(); 1315 if(!pxXReferenceMarks) 1316 { 1317 ((SwXTextDocument*)this)->pxXReferenceMarks = new Reference< XNameAccess > ; 1318 *pxXReferenceMarks = new SwXReferenceMarks(pDocShell->GetDoc()); 1319 } 1320 return *pxXReferenceMarks; 1321 } 1322 /* -----------------21.12.98 10:20------------------- 1323 * 1324 * --------------------------------------------------*/ 1325 Reference< XEnumerationAccess > SwXTextDocument::getTextFields(void) throw( RuntimeException ) 1326 { 1327 ::vos::OGuard aGuard(Application::GetSolarMutex()); 1328 if(!IsValid()) 1329 throw RuntimeException(); 1330 if(!pxXTextFieldTypes) 1331 { 1332 ((SwXTextDocument*)this)->pxXTextFieldTypes = new Reference< XEnumerationAccess > ; 1333 *pxXTextFieldTypes = new SwXTextFieldTypes(pDocShell->GetDoc()); 1334 } 1335 return *pxXTextFieldTypes; 1336 } 1337 /*-- 21.12.98 10:21:12--------------------------------------------------- 1338 1339 -----------------------------------------------------------------------*/ 1340 Reference< XNameAccess > SwXTextDocument::getTextFieldMasters(void) 1341 throw( RuntimeException ) 1342 { 1343 ::vos::OGuard aGuard(Application::GetSolarMutex()); 1344 if(!IsValid()) 1345 throw RuntimeException(); 1346 if(!pxXTextFieldMasters) 1347 { 1348 ((SwXTextDocument*)this)->pxXTextFieldMasters = new Reference< XNameAccess > ; 1349 *pxXTextFieldMasters = new SwXTextFieldMasters(pDocShell->GetDoc()); 1350 } 1351 return *pxXTextFieldMasters; 1352 } 1353 /*-- 21.12.98 10:21:12--------------------------------------------------- 1354 1355 -----------------------------------------------------------------------*/ 1356 Reference< XNameAccess > SwXTextDocument::getEmbeddedObjects(void) throw( RuntimeException ) 1357 { 1358 ::vos::OGuard aGuard(Application::GetSolarMutex()); 1359 if(!IsValid()) 1360 throw RuntimeException(); 1361 if(!pxXEmbeddedObjects) 1362 { 1363 ((SwXTextDocument*)this)->pxXEmbeddedObjects = new Reference< XNameAccess > ; 1364 *pxXEmbeddedObjects = new SwXTextEmbeddedObjects(pDocShell->GetDoc()); 1365 } 1366 return *pxXEmbeddedObjects; 1367 } 1368 /*-- 21.12.98 10:21:13--------------------------------------------------- 1369 1370 -----------------------------------------------------------------------*/ 1371 Reference< XNameAccess > SwXTextDocument::getBookmarks(void) throw( RuntimeException ) 1372 { 1373 ::vos::OGuard aGuard(Application::GetSolarMutex()); 1374 if(!IsValid()) 1375 throw RuntimeException(); 1376 if(!pxXBookmarks) 1377 { 1378 ((SwXTextDocument*)this)->pxXBookmarks = new Reference< XNameAccess > ; 1379 *pxXBookmarks = new SwXBookmarks(pDocShell->GetDoc()); 1380 } 1381 return *pxXBookmarks; 1382 } 1383 /*-- 21.12.98 10:21:13--------------------------------------------------- 1384 1385 -----------------------------------------------------------------------*/ 1386 Reference< XNameAccess > SwXTextDocument::getTextSections(void) throw( RuntimeException ) 1387 { 1388 ::vos::OGuard aGuard(Application::GetSolarMutex()); 1389 if(!IsValid()) 1390 throw RuntimeException(); 1391 if(!pxXTextSections) 1392 { 1393 ((SwXTextDocument*)this)->pxXTextSections = new Reference< XNameAccess > ; 1394 *pxXTextSections = new SwXTextSections(pDocShell->GetDoc()); 1395 } 1396 return *pxXTextSections; 1397 } 1398 /*-- 21.12.98 10:21:13--------------------------------------------------- 1399 1400 -----------------------------------------------------------------------*/ 1401 Reference< XNameAccess > SwXTextDocument::getTextTables(void) throw( RuntimeException ) 1402 { 1403 ::vos::OGuard aGuard(Application::GetSolarMutex()); 1404 if(!IsValid()) 1405 throw RuntimeException(); 1406 if(!pxXTextTables) 1407 { 1408 ((SwXTextDocument*)this)->pxXTextTables = new Reference< XNameAccess > ; 1409 *pxXTextTables = new SwXTextTables(pDocShell->GetDoc()); 1410 } 1411 return *pxXTextTables; 1412 } 1413 /*-- 21.12.98 10:21:13--------------------------------------------------- 1414 1415 -----------------------------------------------------------------------*/ 1416 Reference< XNameAccess > SwXTextDocument::getGraphicObjects(void) throw( RuntimeException ) 1417 { 1418 ::vos::OGuard aGuard(Application::GetSolarMutex()); 1419 if(!IsValid()) 1420 throw RuntimeException(); 1421 if(!pxXGraphicObjects) 1422 { 1423 ((SwXTextDocument*)this)->pxXGraphicObjects = new Reference< XNameAccess > ; 1424 *pxXGraphicObjects = new SwXTextGraphicObjects(pDocShell->GetDoc()); 1425 } 1426 return *pxXGraphicObjects; 1427 } 1428 /*-- 21.12.98 10:21:14--------------------------------------------------- 1429 1430 -----------------------------------------------------------------------*/ 1431 Reference< XNameAccess > SwXTextDocument::getTextFrames(void) throw( RuntimeException ) 1432 { 1433 ::vos::OGuard aGuard(Application::GetSolarMutex()); 1434 if(!IsValid()) 1435 throw RuntimeException(); 1436 if(!pxXTextFrames) 1437 { 1438 ((SwXTextDocument*)this)->pxXTextFrames = new Reference< XNameAccess > ; 1439 *pxXTextFrames = new SwXTextFrames(pDocShell->GetDoc()); 1440 } 1441 return *pxXTextFrames; 1442 } 1443 /* -----------------21.12.98 10:56------------------- 1444 * 1445 * --------------------------------------------------*/ 1446 Reference< XNameAccess > SwXTextDocument::getStyleFamilies(void) throw( RuntimeException ) 1447 { 1448 ::vos::OGuard aGuard(Application::GetSolarMutex()); 1449 if(!IsValid()) 1450 throw RuntimeException(); 1451 if(!pxXStyleFamilies) 1452 { 1453 ((SwXTextDocument*)this)->pxXStyleFamilies = new Reference< XNameAccess > ; 1454 *pxXStyleFamilies = new SwXStyleFamilies(*pDocShell); 1455 } 1456 return *pxXStyleFamilies; 1457 } 1458 /*-- 19.05.06 10:15:22--------------------------------------------------- 1459 1460 -----------------------------------------------------------------------*/ 1461 uno::Reference< style::XAutoStyles > SwXTextDocument::getAutoStyles( ) 1462 throw (uno::RuntimeException) 1463 { 1464 ::vos::OGuard aGuard(Application::GetSolarMutex()); 1465 if(!IsValid()) 1466 throw RuntimeException(); 1467 if(!pxXAutoStyles) 1468 { 1469 pxXAutoStyles = new Reference< style::XAutoStyles > ; 1470 *pxXAutoStyles = new SwXAutoStyles(*pDocShell); 1471 } 1472 return *pxXAutoStyles; 1473 1474 } 1475 /*-- 22.01.99 10:18:03--------------------------------------------------- 1476 1477 -----------------------------------------------------------------------*/ 1478 Reference< drawing::XDrawPage > SwXTextDocument::getDrawPage(void) throw( RuntimeException ) 1479 { 1480 ::vos::OGuard aGuard(Application::GetSolarMutex()); 1481 if(!IsValid()) 1482 throw RuntimeException(); 1483 if(!pxXDrawPage) 1484 { 1485 // simplified this creation, keeping original below as reference 1486 // for the case that it did something by purpose 1487 ((SwXTextDocument*)this)->pDrawPage = new SwXDrawPage(pDocShell->GetDoc()); 1488 ((SwXTextDocument*)this)->pxXDrawPage = new Reference< drawing::XDrawPage >(pDrawPage); 1489 1490 //((SwXTextDocument*)this)->pxXDrawPage = new Reference< drawing::XDrawPage > ; 1491 //((SwXTextDocument*)this)->pDrawPage = new SwXDrawPage(pDocShell->GetDoc()); 1492 //Reference< drawing::XShapes > xTmp = pDrawPage; 1493 //*pxXDrawPage = Reference< drawing::XDrawPage>(xTmp, UNO_QUERY); 1494 } 1495 return *pxXDrawPage; 1496 } 1497 /* -----------------07.04.99 10:11------------------- 1498 * 1499 * --------------------------------------------------*/ 1500 SwXDrawPage* SwXTextDocument::GetDrawPage() 1501 { 1502 if(!IsValid()) 1503 return 0; 1504 if(!pDrawPage) 1505 getDrawPage(); 1506 return pDrawPage; 1507 } 1508 /*-- 18.12.98 11:55:26--------------------------------------------------- 1509 1510 -----------------------------------------------------------------------*/ 1511 void SwXTextDocument::Invalidate() 1512 { 1513 bObjectValid = sal_False; 1514 if(xNumFmtAgg.is()) 1515 { 1516 const uno::Type& rTunnelType = ::getCppuType((Reference <XUnoTunnel>*)0); 1517 Any aNumTunnel = xNumFmtAgg->queryAggregation(rTunnelType); 1518 SvNumberFormatsSupplierObj* pNumFmt = 0; 1519 Reference< XUnoTunnel > xNumTunnel; 1520 if(aNumTunnel >>= xNumTunnel) 1521 { 1522 pNumFmt = reinterpret_cast<SvNumberFormatsSupplierObj*>( 1523 xNumTunnel->getSomething(SvNumberFormatsSupplierObj::getUnoTunnelId())); 1524 pNumFmt->SetNumberFormatter(0); 1525 } 1526 DBG_ASSERT(pNumFmt, "No number formatter available"); 1527 } 1528 InitNewDoc(); 1529 pDocShell = 0; 1530 aRefreshCont.Disposing(); 1531 } 1532 /* -----------------------------13.07.00 15:59-------------------------------- 1533 1534 ---------------------------------------------------------------------------*/ 1535 void SwXTextDocument::Reactivate(SwDocShell* pNewDocShell) 1536 { 1537 if(pDocShell && pDocShell != pNewDocShell) 1538 Invalidate(); 1539 pDocShell = pNewDocShell; 1540 bObjectValid = sal_True; 1541 } 1542 /*-- 18.12.98 11:55:26--------------------------------------------------- 1543 1544 -----------------------------------------------------------------------*/ 1545 void SwXTextDocument::InitNewDoc() 1546 { 1547 // zunaechst alle Collections invalidieren, dann Referenzen loeschen und Null setzen 1548 if(pxXTextTables) 1549 { 1550 XNameAccess* pTbls = pxXTextTables->get(); 1551 ((SwXTextTables*)pTbls)->Invalidate(); 1552 delete pxXTextTables; 1553 pxXTextTables = 0; 1554 } 1555 1556 if(pxXTextFrames) 1557 { 1558 XNameAccess* pFrms = pxXTextFrames->get(); 1559 ((SwXTextFrames*)pFrms)->Invalidate(); 1560 delete pxXTextFrames; 1561 pxXTextFrames = 0; 1562 } 1563 1564 if(pxXGraphicObjects) 1565 { 1566 XNameAccess* pFrms = pxXGraphicObjects->get(); 1567 ((SwXTextGraphicObjects*)pFrms)->Invalidate(); 1568 delete pxXGraphicObjects; 1569 pxXGraphicObjects = 0; 1570 } 1571 1572 if(pxXEmbeddedObjects) 1573 { 1574 XNameAccess* pOLE = pxXEmbeddedObjects->get(); 1575 ((SwXTextEmbeddedObjects*)pOLE)->Invalidate(); 1576 delete pxXEmbeddedObjects; 1577 pxXEmbeddedObjects = 0; 1578 } 1579 1580 if(xBodyText.is()) 1581 { 1582 xBodyText = 0; 1583 pBodyText = 0; 1584 } 1585 1586 if(xNumFmtAgg.is()) 1587 { 1588 const uno::Type& rTunnelType = ::getCppuType((Reference <XUnoTunnel>*)0); 1589 Any aNumTunnel = xNumFmtAgg->queryAggregation(rTunnelType); 1590 SvNumberFormatsSupplierObj* pNumFmt = 0; 1591 Reference< XUnoTunnel > xNumTunnel; 1592 if(aNumTunnel >>= xNumTunnel) 1593 { 1594 pNumFmt = reinterpret_cast<SvNumberFormatsSupplierObj*>( 1595 xNumTunnel->getSomething(SvNumberFormatsSupplierObj::getUnoTunnelId())); 1596 1597 } 1598 DBG_ASSERT(pNumFmt, "No number formatter available"); 1599 pNumFmt->SetNumberFormatter(0); 1600 } 1601 1602 if(pxXTextFieldTypes) 1603 { 1604 XEnumerationAccess* pT = pxXTextFieldTypes->get(); 1605 ((SwXTextFieldTypes*)pT)->Invalidate(); 1606 delete pxXTextFieldTypes; 1607 pxXTextFieldTypes = 0; 1608 } 1609 1610 if(pxXTextFieldMasters) 1611 { 1612 XNameAccess* pT = pxXTextFieldMasters->get(); 1613 ((SwXTextFieldMasters*)pT)->Invalidate(); 1614 delete pxXTextFieldMasters; 1615 pxXTextFieldMasters = 0; 1616 } 1617 1618 if(pxXTextSections) 1619 { 1620 XNameAccess* pSect = pxXTextSections->get(); 1621 ((SwXTextSections*)pSect)->Invalidate(); 1622 delete pxXTextSections; 1623 pxXTextSections = 0; 1624 } 1625 1626 if(pxXDrawPage) 1627 { 1628 // --> OD 2008-07-23 #i91798#, #i91895# 1629 // dispose XDrawPage here. We are the owner and know that it is no longer in a valid condition. 1630 uno::Reference<lang::XComponent> xComp( *pxXDrawPage, uno::UNO_QUERY ); 1631 xComp->dispose(); 1632 // <-- 1633 pDrawPage->InvalidateSwDoc(); 1634 delete pxXDrawPage; 1635 pxXDrawPage = 0; 1636 } 1637 1638 if ( pxXNumberingRules ) 1639 { 1640 XIndexAccess* pNum = pxXNumberingRules->get(); 1641 ((SwXNumberingRulesCollection*)pNum)->Invalidate(); 1642 delete pxXNumberingRules; 1643 pxXNumberingRules = 0; 1644 } 1645 1646 if(pxXFootnotes) 1647 { 1648 XIndexAccess* pFtn = pxXFootnotes->get(); 1649 ((SwXFootnotes*)pFtn)->Invalidate(); 1650 delete pxXFootnotes; 1651 pxXFootnotes = 0; 1652 } 1653 1654 if(pxXEndnotes) 1655 { 1656 XIndexAccess* pFtn = pxXEndnotes->get(); 1657 ((SwXFootnotes*)pFtn)->Invalidate(); 1658 delete pxXEndnotes; 1659 pxXEndnotes = 0; 1660 } 1661 1662 if(pxXDocumentIndexes) 1663 { 1664 XIndexAccess* pIdxs = pxXDocumentIndexes->get(); 1665 ((SwXDocumentIndexes*)pIdxs)->Invalidate(); 1666 delete pxXDocumentIndexes; 1667 pxXDocumentIndexes = 0; 1668 } 1669 1670 if(pxXStyleFamilies) 1671 { 1672 XNameAccess* pStyles = pxXStyleFamilies->get(); 1673 ((SwXStyleFamilies*)pStyles)->Invalidate(); 1674 delete pxXStyleFamilies; 1675 pxXStyleFamilies = 0; 1676 } 1677 if(pxXAutoStyles) 1678 { 1679 XNameAccess* pStyles = pxXAutoStyles->get(); 1680 ((SwXAutoStyles*)pStyles)->Invalidate(); 1681 delete pxXAutoStyles; 1682 pxXAutoStyles = 0; 1683 } 1684 1685 if(pxXBookmarks) 1686 { 1687 XNameAccess* pBm = pxXBookmarks->get(); 1688 ((SwXBookmarks*)pBm)->Invalidate(); 1689 delete pxXBookmarks; 1690 pxXBookmarks = 0; 1691 } 1692 1693 if(pxXChapterNumbering) 1694 { 1695 XIndexReplace* pCh = pxXChapterNumbering->get(); 1696 ((SwXChapterNumbering*)pCh)->Invalidate(); 1697 delete pxXChapterNumbering; 1698 pxXChapterNumbering = 0; 1699 } 1700 1701 if(pxXFootnoteSettings) 1702 { 1703 XPropertySet* pFntSet = pxXFootnoteSettings->get(); 1704 ((SwXFootnoteProperties*)pFntSet)->Invalidate(); 1705 delete pxXFootnoteSettings; 1706 pxXFootnoteSettings = 0; 1707 } 1708 1709 if(pxXEndnoteSettings) 1710 { 1711 XPropertySet* pEndSet = pxXEndnoteSettings->get(); 1712 ((SwXEndnoteProperties*)pEndSet)->Invalidate(); 1713 delete pxXEndnoteSettings; 1714 pxXEndnoteSettings = 0; 1715 } 1716 1717 if(pxXLineNumberingProperties) 1718 { 1719 XPropertySet* pLine = pxXLineNumberingProperties->get(); 1720 ((SwXLineNumberingProperties*)pLine)->Invalidate(); 1721 delete pxXLineNumberingProperties; 1722 pxXLineNumberingProperties = 0; 1723 } 1724 if(pxXReferenceMarks) 1725 { 1726 XNameAccess* pMarks = pxXReferenceMarks->get(); 1727 ((SwXReferenceMarks*)pMarks)->Invalidate(); 1728 delete pxXReferenceMarks; 1729 pxXReferenceMarks = 0; 1730 } 1731 if(pxLinkTargetSupplier) 1732 { 1733 XNameAccess* pAccess = (*pxLinkTargetSupplier).get(); 1734 ((SwXLinkTargetSupplier*)pAccess)->Invalidate(); 1735 delete pxLinkTargetSupplier; 1736 pxLinkTargetSupplier = 0; 1737 } 1738 if(pxXRedlines) 1739 { 1740 XEnumerationAccess* pMarks = pxXRedlines->get(); 1741 ((SwXRedlines*)pMarks)->Invalidate(); 1742 delete pxXRedlines; 1743 pxXRedlines = 0; 1744 } 1745 if(xPropertyHelper.is()) 1746 { 1747 pPropertyHelper->Invalidate(); 1748 xPropertyHelper = 0; 1749 pPropertyHelper = 0; 1750 } 1751 } 1752 1753 /*-- 11.03.99 11:51:40--------------------------------------------------- 1754 1755 -----------------------------------------------------------------------*/ 1756 #define COM_SUN_STAR__DRAWING_LENGTH 13 1757 Reference< XInterface > SwXTextDocument::createInstance(const OUString& rServiceName) 1758 throw( Exception, RuntimeException ) 1759 { 1760 ::vos::OGuard aGuard(Application::GetSolarMutex()); 1761 if(!IsValid()) 1762 throw RuntimeException(); 1763 Reference< XInterface > xRet; 1764 sal_uInt16 nType = SwXServiceProvider::GetProviderType(rServiceName); 1765 if(nType != SW_SERVICE_INVALID) 1766 { 1767 xRet = SwXServiceProvider::MakeInstance(nType, pDocShell->GetDoc()); 1768 } 1769 else 1770 { 1771 if( rServiceName.compareToAscii( "com.sun.star.", 13 ) == 0 ) 1772 { 1773 sal_Int32 nIndex = COM_SUN_STAR__DRAWING_LENGTH; 1774 OUString sCategory = rServiceName.getToken( 0, '.', nIndex ); 1775 sal_Bool bShape = sCategory == C2U("drawing"); 1776 if( bShape || sCategory == C2U("form")) 1777 { 1778 if(bShape) 1779 { 1780 short nTable = 0; 1781 if( 0 == rServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.DashTable") ) ) 1782 nTable = SW_CREATE_DASH_TABLE; 1783 else if( 0 == rServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.GradientTable") ) ) 1784 nTable = SW_CREATE_GRADIENT_TABLE; 1785 else if( 0 == rServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.HatchTable") ) ) 1786 nTable = SW_CREATE_HATCH_TABLE; 1787 else if( 0 == rServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.BitmapTable") ) ) 1788 nTable = SW_CREATE_BITMAP_TABLE; 1789 else if( 0 == rServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.TransparencyGradientTable") ) ) 1790 nTable = SW_CREATE_TRANSGRADIENT_TABLE; 1791 else if( 0 == rServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.MarkerTable") ) ) 1792 nTable = SW_CREATE_MARKER_TABLE; 1793 else if( 0 == rServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.Defaults") ) ) 1794 nTable = SW_CREATE_DRAW_DEFAULTS; 1795 if(nTable) 1796 { 1797 xRet = GetPropertyHelper()->GetDrawTable(nTable); 1798 } 1799 } 1800 } 1801 else if (sCategory == C2U ("document") ) 1802 { 1803 if( 0 == rServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.document.Settings") ) ) 1804 xRet = Reference < XInterface > ( *new SwXDocumentSettings ( this ) ); 1805 if( 0 == rServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.document.ImportEmbeddedObjectResolver") ) ) 1806 { 1807 xRet = (::cppu::OWeakObject * )new SvXMLEmbeddedObjectHelper( *pDocShell, EMBEDDEDOBJECTHELPER_MODE_READ ); 1808 } 1809 } 1810 else if (sCategory == C2U ("text") ) 1811 { 1812 if( 0 == rServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.text.DocumentSettings") ) ) 1813 xRet = Reference < XInterface > ( *new SwXDocumentSettings ( this ) ); 1814 } 1815 else if (sCategory == C2U ("chart2") ) 1816 { 1817 if( 0 == rServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.data.DataProvider") ) ) 1818 xRet = Reference < XInterface > ( dynamic_cast< chart2::data::XDataProvider * >(pDocShell->getIDocumentChartDataProviderAccess()->GetChartDataProvider()) ); 1819 } 1820 1821 if(!xRet.is()) 1822 { 1823 //! we don't want to insert OLE2 Shapes (e.g. "com.sun.star.drawing.OLE2Shape", ...) 1824 //! like this (by creating them with the documents factory and 1825 //! adding the shapes to the draw page). 1826 //! For inserting OLE objects the proper way is to use 1827 //! "com.sun.star.text.TextEmbeddedObject"! 1828 if (rServiceName.lastIndexOf( C2U(".OLE2Shape") ) == rServiceName.getLength() - 10) 1829 throw ServiceNotRegisteredException(); // declare service to be not registered with this factory 1830 1831 // --> OD 2006-02-22 #b6382898# 1832 // the XML import is allowed to create instances of com.sun.star.drawing.OLE2Shape. 1833 // Thus, a temporary service name is introduced to make this possible. 1834 OUString aTmpServiceName( rServiceName ); 1835 if ( bShape && 1836 rServiceName.compareToAscii( "com.sun.star.drawing.temporaryForXMLImportOLE2Shape" ) == 0 ) 1837 { 1838 aTmpServiceName = OUString::createFromAscii( "com.sun.star.drawing.OLE2Shape" ); 1839 } 1840 //hier den Draw - Service suchen 1841 Reference< XInterface > xTmp = SvxFmMSFactory::createInstance(aTmpServiceName); 1842 // <-- 1843 if(bShape) 1844 { 1845 nIndex = COM_SUN_STAR__DRAWING_LENGTH; 1846 if( 0 == rServiceName.reverseCompareToAsciiL ( RTL_CONSTASCII_STRINGPARAM ( "com.sun.star.drawing.GroupShape" ) ) || 1847 0 == rServiceName.reverseCompareToAsciiL ( RTL_CONSTASCII_STRINGPARAM ( "com.sun.star.drawing.Shape3DSceneObject" ) ) ) 1848 xRet = *new SwXGroupShape( xTmp ); 1849 else 1850 xRet = *new SwXShape( xTmp ); 1851 } 1852 else 1853 xRet = xTmp; 1854 } 1855 } 1856 else 1857 throw ServiceNotRegisteredException(); 1858 } 1859 return xRet; 1860 } 1861 /*-- 11.03.99 11:51:40--------------------------------------------------- 1862 1863 -----------------------------------------------------------------------*/ 1864 Reference< XInterface > SwXTextDocument::createInstanceWithArguments( 1865 const OUString& ServiceSpecifier, 1866 const Sequence< Any >& /*Arguments*/) 1867 throw( Exception, RuntimeException ) 1868 { 1869 Reference< XInterface > xInt = createInstance(ServiceSpecifier); 1870 //die Any-Sequence dient zur Initialisierung von Objekten, die auf 1871 //Parameter zwingend angewiesen sind - bis jetzt haben wir das nicht 1872 return xInt; 1873 } 1874 /*-- 11.03.99 11:51:41--------------------------------------------------- 1875 1876 -----------------------------------------------------------------------*/ 1877 Sequence< OUString > SwXTextDocument::getAvailableServiceNames(void) 1878 throw( RuntimeException ) 1879 { 1880 static Sequence< OUString > aServices; 1881 if ( aServices.getLength() == 0 ) 1882 { 1883 Sequence< OUString > aRet = SvxFmMSFactory::getAvailableServiceNames(); 1884 OUString* pRet = aRet.getArray(); 1885 for ( sal_Int32 i = 0; i < aRet.getLength(); ++i ) 1886 { 1887 if ( pRet[i].compareToAscii( "com.sun.star.drawing.OLE2Shape" ) == 0 ) 1888 { 1889 pRet[i] = pRet[aRet.getLength() - 1]; 1890 aRet.realloc( aRet.getLength() - 1 ); // <pRet> no longer valid. 1891 break; 1892 } 1893 } 1894 Sequence< OUString > aOwn = SwXServiceProvider::GetAllServiceNames(); 1895 aServices = SvxFmMSFactory::concatServiceNames(aRet, aOwn); 1896 } 1897 1898 return aServices; 1899 } 1900 /* -----------------18.03.99 11:36------------------- 1901 * 1902 * --------------------------------------------------*/ 1903 OUString SwXTextDocument::getImplementationName(void) throw( RuntimeException ) 1904 { 1905 return C2U("SwXTextDocument"); 1906 } 1907 /* -----------------20.01.04 10:14------------------- 1908 * 1909 * --------------------------------------------------*/ 1910 sal_Bool SwXTextDocument::supportsService(const OUString& rServiceName) throw( RuntimeException ) 1911 { 1912 if ( 1913 (rServiceName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM ( "com.sun.star.document.OfficeDocument" ))) || 1914 (rServiceName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM ( "com.sun.star.text.GenericTextDocument"))) 1915 ) 1916 return sal_True; 1917 1918 sal_Bool bWebDoc = (0 != PTR_CAST(SwWebDocShell, pDocShell)); 1919 sal_Bool bGlobalDoc = (0 != PTR_CAST(SwGlobalDocShell, pDocShell)); 1920 sal_Bool bTextDoc = (!bWebDoc && !bGlobalDoc); 1921 1922 return ( 1923 (bWebDoc && rServiceName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("com.sun.star.text.WebDocument" ))) || 1924 (bGlobalDoc && rServiceName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("com.sun.star.text.GlobalDocument"))) || 1925 (bTextDoc && rServiceName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("com.sun.star.text.TextDocument" ))) 1926 ); 1927 } 1928 /* -----------------20.01.04 10:17------------------- 1929 * 1930 * --------------------------------------------------*/ 1931 Sequence< OUString > SwXTextDocument::getSupportedServiceNames(void) throw( RuntimeException ) 1932 { 1933 sal_Bool bWebDoc = (0 != PTR_CAST(SwWebDocShell, pDocShell)); 1934 sal_Bool bGlobalDoc = (0 != PTR_CAST(SwGlobalDocShell, pDocShell)); 1935 sal_Bool bTextDoc = (!bWebDoc && !bGlobalDoc); 1936 1937 Sequence< OUString > aRet (3); 1938 OUString* pArray = aRet.getArray(); 1939 1940 pArray[0] = OUString ( RTL_CONSTASCII_USTRINGPARAM ( ( "com.sun.star.document.OfficeDocument" ) ) ); 1941 pArray[1] = OUString ( RTL_CONSTASCII_USTRINGPARAM ( ( "com.sun.star.text.GenericTextDocument" ) ) ); 1942 1943 if (bTextDoc) 1944 pArray[2] = OUString ( RTL_CONSTASCII_USTRINGPARAM ( ( "com.sun.star.text.TextDocument" ) ) ); 1945 else 1946 if (bWebDoc) 1947 pArray[2] = OUString ( RTL_CONSTASCII_USTRINGPARAM ( ( "com.sun.star.text.WebDocument" ) ) ); 1948 else 1949 if (bGlobalDoc) 1950 pArray[2] = OUString ( RTL_CONSTASCII_USTRINGPARAM ( ( "com.sun.star.text.GlobalDocument" ) ) ); 1951 1952 return aRet; 1953 } 1954 /* -----------------05.05.99 12:10------------------- 1955 * 1956 * --------------------------------------------------*/ 1957 Reference< XIndexAccess > SwXTextDocument::getDocumentIndexes(void) throw( RuntimeException ) 1958 { 1959 ::vos::OGuard aGuard(Application::GetSolarMutex()); 1960 if(!IsValid()) 1961 throw RuntimeException(); 1962 if(!pxXDocumentIndexes) 1963 { 1964 ((SwXTextDocument*)this)->pxXDocumentIndexes = new Reference< XIndexAccess > ; 1965 *pxXDocumentIndexes = new SwXDocumentIndexes(pDocShell->GetDoc()); 1966 } 1967 return *pxXDocumentIndexes; 1968 } 1969 1970 /*-- 10.05.99 13:58:58--------------------------------------------------- 1971 1972 -----------------------------------------------------------------------*/ 1973 Reference< XPropertySetInfo > SwXTextDocument::getPropertySetInfo(void) throw( RuntimeException ) 1974 { 1975 static Reference< XPropertySetInfo > xRet = pPropSet->getPropertySetInfo(); 1976 return xRet; 1977 } 1978 /*-- 10.05.99 13:58:58--------------------------------------------------- 1979 1980 -----------------------------------------------------------------------*/ 1981 void SwXTextDocument::setPropertyValue(const OUString& rPropertyName, 1982 const Any& aValue) 1983 throw( UnknownPropertyException, PropertyVetoException, IllegalArgumentException, 1984 WrappedTargetException, RuntimeException) 1985 { 1986 ::vos::OGuard aGuard(Application::GetSolarMutex()); 1987 if(!IsValid()) 1988 throw RuntimeException(); 1989 const SfxItemPropertySimpleEntry* pEntry = pPropSet->getPropertyMap()->getByName( rPropertyName); 1990 1991 if(!pEntry) 1992 throw UnknownPropertyException(); 1993 if(pEntry->nFlags & PropertyAttribute::READONLY) 1994 throw PropertyVetoException(); 1995 switch(pEntry->nWID) 1996 { 1997 case WID_DOC_CHAR_COUNT : 1998 case WID_DOC_PARA_COUNT : 1999 case WID_DOC_WORD_COUNT : 2000 throw RuntimeException(); 2001 case WID_DOC_WORD_SEPARATOR : 2002 { 2003 OUString sDelim; 2004 aValue >>= sDelim; 2005 SW_MOD()->GetModuleConfig()->SetWordDelimiter(sDelim); 2006 } 2007 break; 2008 case WID_DOC_CHANGES_RECORD: 2009 case WID_DOC_CHANGES_SHOW: 2010 { 2011 sal_Bool bSet = *(sal_Bool*)aValue.getValue(); 2012 sal_uInt16 eMode = pDocShell->GetDoc()->GetRedlineMode(); 2013 if(WID_DOC_CHANGES_SHOW == pEntry->nWID) 2014 { 2015 eMode &= ~(nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE); 2016 eMode |= nsRedlineMode_t::REDLINE_SHOW_INSERT; 2017 if( bSet ) 2018 eMode |= nsRedlineMode_t::REDLINE_SHOW_DELETE; 2019 } 2020 else if(WID_DOC_CHANGES_RECORD == pEntry->nWID) 2021 { 2022 eMode = bSet ? eMode|nsRedlineMode_t::REDLINE_ON : eMode&~nsRedlineMode_t::REDLINE_ON; 2023 } 2024 pDocShell->GetDoc()->SetRedlineMode( (RedlineMode_t)(eMode )); 2025 } 2026 break; 2027 case WID_DOC_CHANGES_PASSWORD: 2028 { 2029 Sequence <sal_Int8> aNew; 2030 if(aValue >>= aNew) 2031 { 2032 SwDoc* pDoc = pDocShell->GetDoc(); 2033 pDoc->SetRedlinePassword(aNew); 2034 if(aNew.getLength()) 2035 { 2036 sal_uInt16 eMode = pDoc->GetRedlineMode(); 2037 eMode = eMode|nsRedlineMode_t::REDLINE_ON; 2038 pDoc->SetRedlineMode( (RedlineMode_t)(eMode )); 2039 } 2040 } 2041 } 2042 break; 2043 case WID_DOC_AUTO_MARK_URL : 2044 { 2045 OUString sURL; 2046 aValue >>= sURL; 2047 pDocShell->GetDoc()->SetTOIAutoMarkURL(sURL); 2048 } 2049 break; 2050 case WID_DOC_HIDE_TIPS : 2051 SW_MOD()->GetModuleConfig()->SetHideFieldTips(*(sal_Bool*)aValue.getValue()); 2052 break; 2053 case WID_DOC_REDLINE_DISPLAY: 2054 { 2055 sal_Int16 eRedMode = pDocShell->GetDoc()->GetRedlineMode(); 2056 eRedMode = eRedMode & (~nsRedlineMode_t::REDLINE_SHOW_MASK); 2057 sal_Int16 nSet = 0; 2058 aValue >>= nSet; 2059 switch(nSet) 2060 { 2061 case RedlineDisplayType::NONE: break; 2062 case RedlineDisplayType::INSERTED: eRedMode |= nsRedlineMode_t::REDLINE_SHOW_INSERT; break; 2063 case RedlineDisplayType::REMOVED: eRedMode |= nsRedlineMode_t::REDLINE_SHOW_DELETE; break; 2064 case RedlineDisplayType:: 2065 INSERTED_AND_REMOVED: eRedMode |= nsRedlineMode_t::REDLINE_SHOW_INSERT|nsRedlineMode_t::REDLINE_SHOW_DELETE; 2066 break; 2067 default: throw IllegalArgumentException(); 2068 } 2069 pDocShell->GetDoc()->SetRedlineMode(eRedMode); 2070 } 2071 break; 2072 case WID_DOC_TWO_DIGIT_YEAR: 2073 { 2074 sal_Int16 nYear = 0; 2075 aValue >>= nYear; 2076 SfxRequest aRequest ( SID_ATTR_YEAR2000, SFX_CALLMODE_SLOT, pDocShell->GetDoc()->GetAttrPool()); 2077 aRequest.AppendItem(SfxUInt16Item( SID_ATTR_YEAR2000, static_cast < sal_uInt16 > ( nYear ) ) ); 2078 pDocShell->Execute ( aRequest ); 2079 } 2080 break; 2081 case WID_DOC_AUTOMATIC_CONTROL_FOCUS: 2082 { 2083 SwDrawDocument * pDrawDoc; 2084 sal_Bool bAuto = *(sal_Bool*) aValue.getValue(); 2085 2086 if ( 0 != ( pDrawDoc = dynamic_cast< SwDrawDocument * >( pDocShell->GetDoc()->GetDrawModel() ) ) ) 2087 pDrawDoc->SetAutoControlFocus( bAuto ); 2088 else if (bAuto) 2089 { 2090 // if setting to true, and we don't have an 2091 // SdrModel, then we are changing the default and 2092 // must thus create an SdrModel, if we don't have an 2093 // SdrModel and we are leaving the default at false, 2094 // we don't need to make an SdrModel and can do nothing 2095 // --> OD 2005-08-08 #i52858# - method name changed 2096 pDrawDoc = dynamic_cast< SwDrawDocument * > (pDocShell->GetDoc()->GetOrCreateDrawModel() ); 2097 // <-- 2098 pDrawDoc->SetAutoControlFocus ( bAuto ); 2099 } 2100 } 2101 break; 2102 case WID_DOC_APPLY_FORM_DESIGN_MODE: 2103 { 2104 SwDrawDocument * pDrawDoc; 2105 sal_Bool bMode = *(sal_Bool*)aValue.getValue(); 2106 2107 if ( 0 != ( pDrawDoc = dynamic_cast< SwDrawDocument * > (pDocShell->GetDoc()->GetDrawModel() ) ) ) 2108 pDrawDoc->SetOpenInDesignMode( bMode ); 2109 else if (!bMode) 2110 { 2111 // if setting to false, and we don't have an 2112 // SdrModel, then we are changing the default and 2113 // must thus create an SdrModel, if we don't have an 2114 // SdrModel and we are leaving the default at true, 2115 // we don't need to make an SdrModel and can do 2116 // nothing 2117 // --> OD 2005-08-08 #i52858# - method name changed 2118 pDrawDoc = dynamic_cast< SwDrawDocument * > (pDocShell->GetDoc()->GetOrCreateDrawModel() ); 2119 // <-- 2120 pDrawDoc->SetOpenInDesignMode ( bMode ); 2121 } 2122 } 2123 break; 2124 // --> FME 2005-02-25 #i42634# New property to set the bInReading 2125 // flag at the document, used during binary import 2126 case WID_DOC_LOCK_UPDATES : 2127 { 2128 SwDoc* pDoc = pDocShell->GetDoc(); 2129 bool bBool (false); 2130 if( aValue >>= bBool ) 2131 pDoc->SetInReading( bBool ); 2132 } 2133 break; 2134 // <-- 2135 case WID_DOC_BUILDID: 2136 aValue >>= maBuildId; 2137 break; 2138 // --> OD 2006-03-21 #b6375613# 2139 case WID_APPLY_WORKAROUND_FOR_B6375613: 2140 { 2141 bool bApplyWorkaroundForB6375613( false ); 2142 aValue >>= bApplyWorkaroundForB6375613; 2143 pDocShell->GetDoc()->SetApplyWorkaroundForB6375613( bApplyWorkaroundForB6375613 ); 2144 } 2145 break; 2146 // <-- 2147 2148 default: 2149 { 2150 const SfxPoolItem& rItem = pDocShell->GetDoc()->GetDefault(pEntry->nWID); 2151 SfxPoolItem* pNewItem = rItem.Clone(); 2152 pNewItem->PutValue(aValue, pEntry->nMemberId); 2153 pDocShell->GetDoc()->SetDefault(*pNewItem); 2154 delete pNewItem; 2155 } 2156 } 2157 } 2158 /*-- 10.05.99 13:58:59--------------------------------------------------- 2159 2160 -----------------------------------------------------------------------*/ 2161 Any SwXTextDocument::getPropertyValue(const OUString& rPropertyName) 2162 throw( UnknownPropertyException, WrappedTargetException, RuntimeException ) 2163 { 2164 ::vos::OGuard aGuard(Application::GetSolarMutex()); 2165 if(!IsValid()) 2166 throw RuntimeException(); 2167 const SfxItemPropertySimpleEntry* pEntry = pPropSet->getPropertyMap()->getByName( rPropertyName); 2168 2169 if(!pEntry) 2170 throw UnknownPropertyException(); 2171 Any aAny; 2172 switch(pEntry->nWID) 2173 { 2174 case WID_DOC_CHAR_COUNT : 2175 case WID_DOC_PARA_COUNT : 2176 case WID_DOC_WORD_COUNT : 2177 { 2178 SwDocStat aStat(pDocShell->GetDoc()->GetDocStat()); 2179 if(aStat.bModified) 2180 pDocShell->GetDoc()->UpdateDocStat( aStat ); 2181 sal_Int32 nValue; 2182 switch(pEntry->nWID) 2183 { 2184 case WID_DOC_CHAR_COUNT :nValue = aStat.nChar;break; 2185 case WID_DOC_PARA_COUNT :nValue = aStat.nPara;break; 2186 case WID_DOC_WORD_COUNT :nValue = aStat.nWord;break; 2187 } 2188 aAny <<= nValue; 2189 } 2190 break; 2191 case WID_DOC_WORD_SEPARATOR : 2192 { 2193 aAny <<= OUString(SW_MOD()->GetDocStatWordDelim()); 2194 } 2195 break; 2196 case WID_DOC_CHANGES_RECORD: 2197 case WID_DOC_CHANGES_SHOW: 2198 { 2199 sal_uInt16 eMode = pDocShell->GetDoc()->GetRedlineMode(); 2200 sal_Bool bSet = sal_False; 2201 if(WID_DOC_CHANGES_SHOW == pEntry->nWID) 2202 { 2203 sal_uInt16 nMask = nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE; 2204 bSet = (eMode & nMask) == nMask; 2205 } 2206 else if(WID_DOC_CHANGES_RECORD == pEntry->nWID) 2207 { 2208 bSet = (eMode& nsRedlineMode_t::REDLINE_ON) != 0; 2209 } 2210 aAny.setValue(&bSet, ::getBooleanCppuType()); 2211 } 2212 break; 2213 case WID_DOC_CHANGES_PASSWORD: 2214 { 2215 SwDoc* pDoc = pDocShell->GetDoc(); 2216 aAny <<= pDoc->GetRedlinePassword(); 2217 } 2218 break; 2219 case WID_DOC_AUTO_MARK_URL : 2220 aAny <<= OUString(pDocShell->GetDoc()->GetTOIAutoMarkURL()); 2221 break; 2222 case WID_DOC_HIDE_TIPS : 2223 { 2224 sal_Bool bTemp = SW_MOD()->GetModuleConfig()->IsHideFieldTips(); 2225 aAny.setValue(&bTemp, ::getBooleanCppuType()); 2226 } 2227 break; 2228 case WID_DOC_REDLINE_DISPLAY: 2229 { 2230 sal_Int16 eRedMode = pDocShell->GetDoc()->GetRedlineMode(); 2231 eRedMode = eRedMode & nsRedlineMode_t::REDLINE_SHOW_MASK; 2232 sal_Int16 nRet = RedlineDisplayType::NONE; 2233 if(nsRedlineMode_t::REDLINE_SHOW_INSERT == eRedMode) 2234 nRet = RedlineDisplayType::INSERTED; 2235 else if(nsRedlineMode_t::REDLINE_SHOW_DELETE == eRedMode) 2236 nRet = RedlineDisplayType::REMOVED; 2237 else if(nsRedlineMode_t::REDLINE_SHOW_MASK == eRedMode) 2238 nRet = RedlineDisplayType::INSERTED_AND_REMOVED; 2239 aAny <<= nRet; 2240 } 2241 break; 2242 case WID_DOC_FORBIDDEN_CHARS: 2243 { 2244 GetPropertyHelper(); 2245 Reference<XForbiddenCharacters> xRet(xPropertyHelper, UNO_QUERY); 2246 aAny <<= xRet; 2247 } 2248 break; 2249 case WID_DOC_TWO_DIGIT_YEAR: 2250 { 2251 aAny <<= static_cast < sal_Int16 > (pDocShell->GetDoc()->GetNumberFormatter ( sal_True )->GetYear2000()); 2252 } 2253 break; 2254 case WID_DOC_AUTOMATIC_CONTROL_FOCUS: 2255 { 2256 SwDrawDocument * pDrawDoc; 2257 sal_Bool bAuto; 2258 if ( 0 != ( pDrawDoc = dynamic_cast< SwDrawDocument * > (pDocShell->GetDoc()->GetDrawModel() ) ) ) 2259 bAuto = pDrawDoc->GetAutoControlFocus(); 2260 else 2261 bAuto = sal_False; 2262 aAny.setValue(&bAuto, ::getBooleanCppuType()); 2263 } 2264 break; 2265 case WID_DOC_APPLY_FORM_DESIGN_MODE: 2266 { 2267 SwDrawDocument * pDrawDoc; 2268 sal_Bool bMode; 2269 if ( 0 != ( pDrawDoc = dynamic_cast< SwDrawDocument * > (pDocShell->GetDoc()->GetDrawModel() ) ) ) 2270 bMode = pDrawDoc->GetOpenInDesignMode(); 2271 else 2272 bMode = sal_True; 2273 aAny.setValue(&bMode, ::getBooleanCppuType()); 2274 } 2275 break; 2276 case WID_DOC_BASIC_LIBRARIES: 2277 aAny <<= pDocShell->GetBasicContainer(); 2278 break; 2279 case WID_DOC_DIALOG_LIBRARIES: 2280 aAny <<= pDocShell->GetDialogContainer(); 2281 break; 2282 case WID_DOC_RUNTIME_UID: 2283 aAny <<= getRuntimeUID(); 2284 break; 2285 case WID_DOC_LOCK_UPDATES : 2286 aAny <<= static_cast<bool>( pDocShell->GetDoc()->IsInReading() ); 2287 break; 2288 case WID_DOC_BUILDID: 2289 aAny <<= maBuildId; 2290 break; 2291 case WID_DOC_HAS_VALID_SIGNATURES: 2292 aAny <<= hasValidSignatures(); 2293 break; 2294 // --> OD 2006-03-21 #b6375613# 2295 case WID_APPLY_WORKAROUND_FOR_B6375613: 2296 { 2297 aAny <<= pDocShell->GetDoc()->ApplyWorkaroundForB6375613(); 2298 } 2299 break; 2300 // <-- 2301 2302 default: 2303 { 2304 const SfxPoolItem& rItem = pDocShell->GetDoc()->GetDefault(pEntry->nWID); 2305 rItem.QueryValue(aAny, pEntry->nMemberId); 2306 } 2307 } 2308 return aAny; 2309 } 2310 /*-- 10.05.99 13:58:59--------------------------------------------------- 2311 2312 -----------------------------------------------------------------------*/ 2313 void SwXTextDocument::addPropertyChangeListener(const OUString& /*PropertyName*/, 2314 const Reference< XPropertyChangeListener > & /*aListener*/) 2315 throw( UnknownPropertyException, WrappedTargetException, RuntimeException ) 2316 { 2317 DBG_WARNING("not implemented"); 2318 } 2319 /*-- 10.05.99 13:58:59--------------------------------------------------- 2320 2321 -----------------------------------------------------------------------*/ 2322 void SwXTextDocument::removePropertyChangeListener(const OUString& /*PropertyName*/, 2323 const Reference< XPropertyChangeListener > & /*aListener*/) 2324 throw( UnknownPropertyException, WrappedTargetException, RuntimeException ) 2325 { 2326 DBG_WARNING("not implemented"); 2327 } 2328 /*-- 10.05.99 13:59:00--------------------------------------------------- 2329 2330 -----------------------------------------------------------------------*/ 2331 void SwXTextDocument::addVetoableChangeListener(const OUString& /*PropertyName*/, 2332 const Reference< XVetoableChangeListener > & /*aListener*/) 2333 throw( UnknownPropertyException, WrappedTargetException, RuntimeException ) 2334 { 2335 DBG_WARNING("not implemented"); 2336 } 2337 /*-- 10.05.99 13:59:00--------------------------------------------------- 2338 2339 -----------------------------------------------------------------------*/ 2340 void SwXTextDocument::removeVetoableChangeListener(const OUString& /*PropertyName*/, 2341 const Reference< XVetoableChangeListener > & /*aListener*/) 2342 throw( UnknownPropertyException, WrappedTargetException, RuntimeException ) 2343 { 2344 DBG_WARNING("not implemented"); 2345 } 2346 /* -----------------25.10.99 10:42------------------- 2347 2348 --------------------------------------------------*/ 2349 Reference< XNameAccess > SwXTextDocument::getLinks(void) throw( RuntimeException ) 2350 { 2351 if(!pxLinkTargetSupplier) 2352 { 2353 pxLinkTargetSupplier = new Reference< XNameAccess > ; 2354 (*pxLinkTargetSupplier) = new SwXLinkTargetSupplier(*(SwXTextDocument*)this); 2355 } 2356 return (*pxLinkTargetSupplier); 2357 } 2358 /* -----------------------------11.01.01 15:01-------------------------------- 2359 2360 ---------------------------------------------------------------------------*/ 2361 Reference< XEnumerationAccess > SwXTextDocument::getRedlines( ) throw(RuntimeException) 2362 { 2363 if(!pxXRedlines) 2364 { 2365 pxXRedlines = new Reference< XEnumerationAccess > ; 2366 (*pxXRedlines) = new SwXRedlines(pDocShell->GetDoc()); 2367 } 2368 return *pxXRedlines; 2369 } 2370 /*-- 21.02.00 08:41:06--------------------------------------------------- 2371 2372 -----------------------------------------------------------------------*/ 2373 void SwXTextDocument::refresh(void) throw( RuntimeException ) 2374 { 2375 ::vos::OGuard aGuard(Application::GetSolarMutex()); 2376 if(!IsValid()) 2377 throw RuntimeException(); 2378 ViewShell *pViewShell = pDocShell->GetWrtShell(); 2379 notifyRefreshListeners(); 2380 if(pViewShell) 2381 pViewShell->CalcLayout(); 2382 } 2383 /*-- 21.02.00 08:41:06--------------------------------------------------- 2384 2385 -----------------------------------------------------------------------*/ 2386 void SwXTextDocument::addRefreshListener(const Reference< util::XRefreshListener > & l) 2387 throw( RuntimeException ) 2388 { 2389 ::vos::OGuard aGuard(Application::GetSolarMutex()); 2390 if ( !IsValid() ) 2391 throw RuntimeException(); 2392 aRefreshCont.AddListener ( reinterpret_cast < const Reference < lang::XEventListener > &> ( l )); 2393 } 2394 /*-- 21.02.00 08:41:07--------------------------------------------------- 2395 2396 -----------------------------------------------------------------------*/ 2397 void SwXTextDocument::removeRefreshListener(const Reference< util::XRefreshListener > & l) 2398 throw( RuntimeException ) 2399 { 2400 ::vos::OGuard aGuard(Application::GetSolarMutex()); 2401 if ( !IsValid() || !aRefreshCont.RemoveListener ( reinterpret_cast < const Reference < lang::XEventListener > &> ( l ) ) ) 2402 throw RuntimeException(); 2403 } 2404 /* -----------------------------26.02.01 12:22-------------------------------- 2405 2406 ---------------------------------------------------------------------------*/ 2407 void SwXTextDocument::updateLinks( ) throw(RuntimeException) 2408 { 2409 ::vos::OGuard aGuard(Application::GetSolarMutex()); 2410 if(!IsValid()) 2411 throw RuntimeException(); 2412 SwDoc* pDoc = pDocShell->GetDoc(); 2413 sfx2::LinkManager& rLnkMan = pDoc->GetLinkManager(); 2414 if( rLnkMan.GetLinks().Count() ) 2415 { 2416 UnoActionContext aAction(pDoc); 2417 rLnkMan.UpdateAllLinks( sal_False, sal_False, sal_True ); 2418 } 2419 } 2420 //XPropertyState 2421 PropertyState SAL_CALL SwXTextDocument::getPropertyState( const OUString& rPropertyName ) 2422 throw (UnknownPropertyException, RuntimeException) 2423 { 2424 ::vos::OGuard aGuard(Application::GetSolarMutex()); 2425 PropertyState eRet = PropertyState_DIRECT_VALUE; 2426 if(!IsValid()) 2427 throw RuntimeException(); 2428 const SfxItemPropertySimpleEntry* pEntry = pPropSet->getPropertyMap()->getByName( rPropertyName); 2429 2430 if(!pEntry) 2431 throw UnknownPropertyException(); 2432 Any aAny; 2433 switch(pEntry->nWID) 2434 { 2435 case 0:default:break; 2436 } 2437 return eRet; 2438 } 2439 Sequence< PropertyState > SAL_CALL SwXTextDocument::getPropertyStates( const Sequence< OUString >& rPropertyNames ) 2440 throw (UnknownPropertyException, RuntimeException) 2441 { 2442 const sal_Int32 nCount = rPropertyNames.getLength(); 2443 const OUString * pNames = rPropertyNames.getConstArray(); 2444 Sequence < PropertyState > aRet ( nCount ); 2445 PropertyState *pState = aRet.getArray(); 2446 2447 for ( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++) 2448 pState[nIndex] = getPropertyState( pNames[nIndex] ); 2449 2450 return aRet; 2451 } 2452 void SAL_CALL SwXTextDocument::setPropertyToDefault( const OUString& rPropertyName ) 2453 throw (UnknownPropertyException, RuntimeException) 2454 { 2455 ::vos::OGuard aGuard(Application::GetSolarMutex()); 2456 if(!IsValid()) 2457 throw RuntimeException(); 2458 const SfxItemPropertySimpleEntry* pEntry = pPropSet->getPropertyMap()->getByName( rPropertyName); 2459 if(!pEntry) 2460 throw UnknownPropertyException(); 2461 switch(pEntry->nWID) 2462 { 2463 case 0:default:break; 2464 } 2465 } 2466 Any SAL_CALL SwXTextDocument::getPropertyDefault( const OUString& rPropertyName ) 2467 throw (UnknownPropertyException, WrappedTargetException, RuntimeException) 2468 { 2469 ::vos::OGuard aGuard(Application::GetSolarMutex()); 2470 if(!IsValid()) 2471 throw RuntimeException(); 2472 const SfxItemPropertySimpleEntry* pEntry = pPropSet->getPropertyMap()->getByName( rPropertyName); 2473 if(!pEntry) 2474 throw UnknownPropertyException(); 2475 Any aAny; 2476 switch(pEntry->nWID) 2477 { 2478 case 0:default:break; 2479 } 2480 return aAny; 2481 } 2482 2483 static OutputDevice * lcl_GetOutputDevice( const SwPrintUIOptions &rPrintUIOptions ) 2484 { 2485 OutputDevice *pOut = 0; 2486 2487 uno::Any aAny( rPrintUIOptions.getValue( C2U( "RenderDevice" ) )); 2488 uno::Reference< awt::XDevice > xRenderDevice; 2489 aAny >>= xRenderDevice; 2490 if (xRenderDevice.is()) 2491 { 2492 VCLXDevice* pDevice = VCLXDevice::GetImplementation( xRenderDevice ); 2493 pOut = pDevice ? pDevice->GetOutputDevice() : 0; 2494 } 2495 2496 return pOut; 2497 } 2498 2499 2500 static bool lcl_SeqHasProperty( 2501 const uno::Sequence< beans::PropertyValue >& rOptions, 2502 const sal_Char *pPropName ) 2503 { 2504 bool bRes = false; 2505 const sal_Int32 nLen = rOptions.getLength(); 2506 const beans::PropertyValue *pProps = rOptions.getConstArray(); 2507 for (sal_Int32 i = 0; i < nLen && !bRes; ++i) 2508 { 2509 if (pProps[i].Name.equalsAscii( pPropName )) 2510 bRes = true; 2511 } 2512 return bRes; 2513 } 2514 2515 2516 SfxViewShell * SwXTextDocument::GetRenderView( 2517 bool &rbIsSwSrcView, 2518 const uno::Sequence< beans::PropertyValue >& rOptions, 2519 bool bIsPDFExport ) 2520 { 2521 // get view shell to use 2522 SfxViewShell *pView = 0; 2523 if (bIsPDFExport) 2524 pView = GuessViewShell( rbIsSwSrcView ); 2525 else 2526 { 2527 uno::Any aTmp; 2528 const sal_Int32 nLen = rOptions.getLength(); 2529 const beans::PropertyValue *pProps = rOptions.getConstArray(); 2530 for (sal_Int32 i = 0; i < nLen; ++i) 2531 { 2532 if (pProps[i].Name.equalsAscii( "View" )) 2533 { 2534 aTmp = pProps[i].Value; 2535 break; 2536 } 2537 } 2538 2539 uno::Reference< frame::XController > xController; 2540 if (aTmp >>= xController) 2541 { 2542 DBG_ASSERT( xController.is(), "controller is empty!" ); 2543 pView = GuessViewShell( rbIsSwSrcView, xController ); 2544 } 2545 } 2546 return pView; 2547 } 2548 2549 2550 /* 2551 * GetRenderDoc: 2552 * returns the document to be rendered, usually this will be the 'regular' 2553 * document but in case of PDF export of (multi-)selection it will 2554 * be a temporary document that gets created if not already done. 2555 * The rpView variable will be set (if not already done) to the used 2556 * SfxViewShell. 2557 */ 2558 2559 SwDoc * SwXTextDocument::GetRenderDoc( 2560 SfxViewShell *&rpView, 2561 const uno::Any& rSelection, 2562 bool bIsPDFExport ) 2563 { 2564 SwDoc *pDoc = 0; 2565 2566 uno::Reference< frame::XModel > xModel; 2567 rSelection >>= xModel; 2568 if (xModel == pDocShell->GetModel()) 2569 pDoc = pDocShell->GetDoc(); 2570 else 2571 { 2572 DBG_ASSERT( !xModel.is(), "unexpected model found" ); 2573 2574 if (rSelection.hasValue()) // is anything selected ? 2575 { 2576 // this part should only be called when a temporary document needs to be created, 2577 // for example for PDF export or printing of (multi-)selection only. 2578 2579 bool bIsSwSrcView = false; 2580 if (!rpView) 2581 { 2582 (void) bIsPDFExport; 2583 // aside from maybe PDF export the view should always have been provided! 2584 DBG_ASSERT( bIsPDFExport, "view is missing, guessing one..." ); 2585 2586 rpView = GuessViewShell( bIsSwSrcView ); 2587 } 2588 DBG_ASSERT( rpView, "ViewShell missing" ); 2589 // the view shell should be SwView for documents PDF export. 2590 // for the page preview no selection should be possible 2591 // (the export dialog does not allow for this option) 2592 const TypeId aSwViewTypeId = TYPE(SwView); 2593 if (rpView && rpView->IsA(aSwViewTypeId)) 2594 { 2595 SfxObjectShellLock xDocSh(((SwView*)rpView)->GetOrCreateTmpSelectionDoc()); 2596 if (xDocSh.Is()) 2597 { 2598 pDoc = ((SwDocShell*)&xDocSh)->GetDoc(); 2599 rpView = pDoc->GetDocShell()->GetView(); 2600 } 2601 } 2602 else 2603 { 2604 DBG_ERROR( "unexpected ViewShell" ); 2605 } 2606 } 2607 } 2608 return pDoc; 2609 } 2610 2611 /* -----------------------------23.08.02 16:00-------------------------------- 2612 2613 ---------------------------------------------------------------------------*/ 2614 2615 static void lcl_SavePrintUIOptionsToDocumentPrintData( 2616 SwDoc &rDoc, 2617 const SwPrintUIOptions &rPrintUIOptions, 2618 bool bIsPDFEXport ) 2619 { 2620 SwPrintData aDocPrintData( rDoc.getPrintData() ); 2621 2622 aDocPrintData.SetPrintGraphic( rPrintUIOptions.IsPrintGraphics() ); 2623 aDocPrintData.SetPrintTable( rPrintUIOptions.IsPrintTables() ); 2624 aDocPrintData.SetPrintDraw( rPrintUIOptions.IsPrintDrawings() ); 2625 aDocPrintData.SetPrintControl( rPrintUIOptions.IsPrintFormControls() ); 2626 aDocPrintData.SetPrintLeftPage( rPrintUIOptions.IsPrintLeftPages() ); 2627 aDocPrintData.SetPrintRightPage( rPrintUIOptions.IsPrintRightPages() ); 2628 aDocPrintData.SetPrintReverse( rPrintUIOptions.IsPrintReverse() ); 2629 aDocPrintData.SetPaperFromSetup( rPrintUIOptions.IsPaperFromSetup() ); 2630 aDocPrintData.SetPrintEmptyPages( rPrintUIOptions.IsPrintEmptyPages( bIsPDFEXport ) ); 2631 aDocPrintData.SetPrintPostIts( rPrintUIOptions.GetPrintPostItsType() ); 2632 aDocPrintData.SetPrintProspect( rPrintUIOptions.IsPrintProspect() ); 2633 aDocPrintData.SetPrintProspect_RTL( rPrintUIOptions.IsPrintProspectRTL() ); 2634 aDocPrintData.SetPrintPageBackground( rPrintUIOptions.IsPrintPageBackground() ); 2635 aDocPrintData.SetPrintBlackFont( rPrintUIOptions.IsPrintWithBlackTextColor() ); 2636 // aDocPrintData.SetPrintSingleJobs( b ); handled by File/Print dialog itself 2637 // arDocPrintData.SetFaxName( s ); n/a in File/Print dialog 2638 aDocPrintData.SetPrintHiddenText( rPrintUIOptions.IsPrintHiddenText() ); 2639 aDocPrintData.SetPrintTextPlaceholder( rPrintUIOptions.IsPrintTextPlaceholders() ); 2640 2641 rDoc.setPrintData( aDocPrintData ); 2642 } 2643 2644 2645 sal_Int32 SAL_CALL SwXTextDocument::getRendererCount( 2646 const uno::Any& rSelection, 2647 const uno::Sequence< beans::PropertyValue >& rxOptions ) 2648 throw (IllegalArgumentException, RuntimeException) 2649 { 2650 ::vos::OGuard aGuard(Application::GetSolarMutex()); 2651 if(!IsValid()) 2652 throw RuntimeException(); 2653 2654 const bool bIsPDFExport = !lcl_SeqHasProperty( rxOptions, "IsPrinter" ); 2655 bool bIsSwSrcView = false; 2656 SfxViewShell *pView = GetRenderView( bIsSwSrcView, rxOptions, bIsPDFExport ); 2657 2658 if (!bIsSwSrcView && !m_pRenderData) 2659 m_pRenderData = new SwRenderData; 2660 if (!m_pPrintUIOptions) 2661 m_pPrintUIOptions = lcl_GetPrintUIOptions( pDocShell, pView ); 2662 bool bFormat = m_pPrintUIOptions->processPropertiesAndCheckFormat( rxOptions ); 2663 // const bool bIsSkipEmptyPages = !m_pPrintUIOptions->IsPrintEmptyPages( bIsPDFExport ); 2664 2665 SwDoc *pDoc = GetRenderDoc( pView, rSelection, bIsPDFExport ); 2666 DBG_ASSERT( pDoc && pView, "doc or view shell missing!" ); 2667 if (!pDoc || !pView) 2668 return 0; 2669 2670 // save current UI options from the print dialog for the next call to that dialog 2671 lcl_SavePrintUIOptionsToDocumentPrintData( *pDoc, *m_pPrintUIOptions, bIsPDFExport ); 2672 2673 sal_Int32 nRet = 0; 2674 if (bIsSwSrcView) 2675 { 2676 SwSrcView *pSwSrcView = dynamic_cast< SwSrcView * >(pView); 2677 OutputDevice *pOutDev = lcl_GetOutputDevice( *m_pPrintUIOptions ); 2678 nRet = pSwSrcView->PrintSource( pOutDev, 1 /* dummy */, true /* get page count only */ ); 2679 } 2680 else 2681 { 2682 SwDocShell *pRenderDocShell = pDoc->GetDocShell(); 2683 2684 // TODO/mba: we really need a generic way to get the ViewShell! 2685 ViewShell* pViewShell = 0; 2686 SwView* pSwView = PTR_CAST(SwView, pView); 2687 if ( pSwView ) 2688 { 2689 pViewShell = pSwView->GetWrtShellPtr(); 2690 } 2691 else 2692 { 2693 if ( bIsPDFExport && bFormat ) 2694 { 2695 //create a hidden view to be able to export as PDF also in print preview 2696 //pView and pSwView are not changed intentionally! 2697 m_pHiddenViewFrame = SfxViewFrame::LoadHiddenDocument( *pRenderDocShell, 2 ); 2698 pViewShell = ((SwView*)m_pHiddenViewFrame->GetViewShell())->GetWrtShellPtr(); 2699 } 2700 else 2701 pViewShell = ((SwPagePreView*)pView)->GetViewShell(); 2702 } 2703 2704 if (!pViewShell || !pViewShell->GetLayout()) 2705 return 0; 2706 2707 if (bFormat) 2708 { 2709 // #i38289 2710 if( pViewShell->GetViewOptions()->getBrowseMode() ) 2711 { 2712 SwViewOption aOpt( *pViewShell->GetViewOptions() ); 2713 aOpt.setBrowseMode( false ); 2714 pViewShell->ApplyViewOptions( aOpt ); 2715 pSwView->RecheckBrowseMode(); 2716 } 2717 2718 // reformating the document for printing will show the changes in the view 2719 // which is likely to produce many unwanted and not nice to view actions. 2720 // We don't want that! Thus we disable updating of the view. 2721 pViewShell->StartAction(); 2722 2723 if (pSwView) 2724 { 2725 if (m_pRenderData && m_pRenderData->NeedNewViewOptionAdjust( *pViewShell ) ) 2726 m_pRenderData->ViewOptionAdjustStop(); 2727 if (m_pRenderData && !m_pRenderData->IsViewOptionAdjust()) 2728 m_pRenderData->ViewOptionAdjustStart( *pViewShell, *pViewShell->GetViewOptions() ); 2729 } 2730 2731 m_pRenderData->SetSwPrtOptions( new SwPrintData ); 2732 m_pRenderData->MakeSwPrtOptions( m_pRenderData->GetSwPrtOptionsRef(), pRenderDocShell, 2733 m_pPrintUIOptions, m_pRenderData, bIsPDFExport ); 2734 2735 if (pSwView) 2736 { 2737 // PDF export should not make use of the SwPrtOptions 2738 const SwPrintData *pPrtOptions = (bIsPDFExport) 2739 ? NULL : m_pRenderData->GetSwPrtOptions(); 2740 m_pRenderData->ViewOptionAdjust( pPrtOptions ); 2741 } 2742 2743 // since printing now also use the API for PDF export this option 2744 // should be set for printing as well ... 2745 pViewShell->SetPDFExportOption( sal_True ); 2746 bool bOrigStatus = pRenderDocShell->IsEnableSetModified(); 2747 // check configuration: shall update of printing information in DocInfo set the document to "modified"? 2748 bool bStateChanged = false; 2749 if ( bOrigStatus && !SvtPrintWarningOptions().IsModifyDocumentOnPrintingAllowed() ) 2750 { 2751 pRenderDocShell->EnableSetModified( sal_False ); 2752 bStateChanged = true; 2753 } 2754 2755 // --> FME 2005-05-23 #122919# Force field update before PDF export: 2756 pViewShell->ViewShell::UpdateFlds(sal_True); 2757 // <-- 2758 if( bStateChanged ) 2759 pRenderDocShell->EnableSetModified( sal_True ); 2760 2761 // there is some redundancy between those two function calls, but right now 2762 // there is no time to sort this out. 2763 //TODO: check what exatly needs to be done and make just one function for that 2764 pViewShell->CalcLayout(); 2765 pViewShell->CalcPagesForPrint( pViewShell->GetPageCount() ); 2766 2767 pViewShell->SetPDFExportOption( sal_False ); 2768 2769 // enable view again 2770 pViewShell->EndAction(); 2771 } 2772 2773 const sal_Int32 nPageCount = pViewShell->GetPageCount(); 2774 2775 // 2776 // get number of pages to be rendered 2777 // 2778 const bool bPrintProspect = m_pPrintUIOptions->getBoolValue( "PrintProspect", false ); 2779 if (bPrintProspect) 2780 { 2781 pDoc->CalculatePagePairsForProspectPrinting( *pViewShell->GetLayout(), *m_pRenderData, *m_pPrintUIOptions, nPageCount ); 2782 nRet = m_pRenderData->GetPagePairsForProspectPrinting().size(); 2783 } 2784 else 2785 { 2786 if ( m_pRenderData->HasPostItData() ) 2787 { 2788 m_pRenderData->DeletePostItData(); 2789 } 2790 const sal_Int16 nPostItMode = (sal_Int16) m_pPrintUIOptions->getIntValue( "PrintAnnotationMode", 0 ); 2791 if (nPostItMode != POSTITS_NONE) 2792 { 2793 OutputDevice *pOutDev = lcl_GetOutputDevice( *m_pPrintUIOptions ); 2794 m_pRenderData->CreatePostItData( pDoc, pViewShell->GetViewOptions(), pOutDev ); 2795 } 2796 2797 // get set of valid document pages (according to the current settings) 2798 // and their start frames 2799 pDoc->CalculatePagesForPrinting( *pViewShell->GetLayout(), *m_pRenderData, *m_pPrintUIOptions, bIsPDFExport, nPageCount ); 2800 2801 if (nPostItMode != POSTITS_NONE) 2802 { 2803 pDoc->UpdatePagesForPrintingWithPostItData( *m_pRenderData, 2804 *m_pPrintUIOptions, bIsPDFExport, nPageCount ); 2805 } 2806 2807 nRet = m_pRenderData->GetPagesToPrint().size(); 2808 } 2809 } 2810 DBG_ASSERT( nRet >= 0, "negative number of pages???" ); 2811 2812 return nRet; 2813 } 2814 /* -----------------------------23.08.02 16:00-------------------------------- 2815 2816 ---------------------------------------------------------------------------*/ 2817 uno::Sequence< beans::PropertyValue > SAL_CALL SwXTextDocument::getRenderer( 2818 sal_Int32 nRenderer, 2819 const uno::Any& rSelection, 2820 const uno::Sequence< beans::PropertyValue >& rxOptions ) 2821 throw (IllegalArgumentException, RuntimeException) 2822 { 2823 ::vos::OGuard aGuard(Application::GetSolarMutex()); 2824 if(!IsValid()) 2825 throw RuntimeException(); 2826 2827 const bool bIsPDFExport = !lcl_SeqHasProperty( rxOptions, "IsPrinter" ); 2828 bool bIsSwSrcView = false; 2829 SfxViewShell *pView = GetRenderView( bIsSwSrcView, rxOptions, bIsPDFExport ); 2830 2831 // m_pRenderData should NOT be created here! 2832 // That should only be done in getRendererCount. If this function is called before 2833 // getRendererCount was called then the caller will probably just retrieve the extra UI options 2834 // and is not interested in getting valid information about the other data that would 2835 // otherwise be provided here! 2836 // if( ! m_pRenderData ) 2837 // m_pRenderData = new SwRenderData; 2838 if (!m_pPrintUIOptions) 2839 m_pPrintUIOptions = lcl_GetPrintUIOptions( pDocShell, pView ); 2840 m_pPrintUIOptions->processProperties( rxOptions ); 2841 const bool bPrintProspect = m_pPrintUIOptions->getBoolValue( "PrintProspect", false ); 2842 const bool bIsSkipEmptyPages = !m_pPrintUIOptions->IsPrintEmptyPages( bIsPDFExport ); 2843 const bool bPrintPaperFromSetup = m_pPrintUIOptions->getBoolValue( "PrintPaperFromSetup", false ); 2844 2845 SwDoc *pDoc = GetRenderDoc( pView, rSelection, bIsPDFExport ); 2846 DBG_ASSERT( pDoc && pView, "doc or view shell missing!" ); 2847 if (!pDoc || !pView) 2848 return uno::Sequence< beans::PropertyValue >(); 2849 2850 // due to #110067# (document page count changes sometimes during 2851 // PDF export/printing) we can not check for the upper bound properly. 2852 // Thus instead of throwing the exception we silently return. 2853 if (0 > nRenderer) 2854 throw IllegalArgumentException(); 2855 2856 // TODO/mba: we really need a generic way to get the ViewShell! 2857 ViewShell* pVwSh = 0; 2858 SwView* pSwView = PTR_CAST(SwView, pView); 2859 if ( pSwView ) 2860 pVwSh = pSwView->GetWrtShellPtr(); 2861 else 2862 pVwSh = ((SwPagePreView*)pView)->GetViewShell(); 2863 2864 sal_Int32 nMaxRenderer = 0; 2865 if (!bIsSwSrcView && m_pRenderData) 2866 { 2867 DBG_ASSERT( m_pRenderData, "m_pRenderData missing!!" ); 2868 nMaxRenderer = bPrintProspect? 2869 m_pRenderData->GetPagePairsForProspectPrinting().size() - 1 : 2870 m_pRenderData->GetPagesToPrint().size() - 1; 2871 } 2872 // since SwSrcView::PrintSource is a poor implementation to get the number of pages to print 2873 // we obmit checking of the upper bound in this case. 2874 if (!bIsSwSrcView && m_pRenderData && nRenderer > nMaxRenderer) 2875 return uno::Sequence< beans::PropertyValue >(); 2876 2877 uno::Sequence< beans::PropertyValue > aRenderer; 2878 if (m_pRenderData) 2879 { 2880 // --> TL, OD 2010-09-07 #i114210# 2881 // determine the correct page number from the renderer index 2882 // --> OD 2010-10-01 #i114875 2883 // consider brochure print 2884 const sal_uInt16 nPage = bPrintProspect 2885 ? nRenderer + 1 2886 : m_pRenderData->GetPagesToPrint()[ nRenderer ]; 2887 // <-- 2888 2889 // get paper tray to use ... 2890 sal_Int32 nPrinterPaperTray = -1; 2891 if (! bPrintPaperFromSetup) 2892 { 2893 // ... from individual page style (see the page tab in Format/Page dialog) 2894 const std::map< sal_Int32, sal_Int32 > &rPaperTrays = m_pRenderData->GetPrinterPaperTrays(); 2895 std::map< sal_Int32, sal_Int32 >::const_iterator aIt( rPaperTrays.find( nPage ) ); 2896 if (aIt != rPaperTrays.end()) 2897 nPrinterPaperTray = aIt->second; 2898 } 2899 2900 awt::Size aPageSize; 2901 awt::Size aPreferredPageSize; 2902 Size aTmpSize; 2903 if (bIsSwSrcView || bPrintProspect) 2904 { 2905 // for printing of HTML source code and prospect printing we should use 2906 // the printers paper size since 2907 // a) HTML source view has no page size 2908 // b) prospect printing has a different page size from the documents page 2909 // since two document pages will get rendered on one printer page 2910 2911 // since PageIncludesNonprintableArea will be set to true we can return the 2912 // printers paper size here. 2913 // Sometimes 'getRenderer' is only called to get "ExtraPrintUIOptions", in this 2914 // case we won't get an OutputDevice here, but then the caller also has no need 2915 // for the correct PageSisze right now... 2916 Printer *pPrinter = dynamic_cast< Printer * >(lcl_GetOutputDevice( *m_pPrintUIOptions )); 2917 if (pPrinter) 2918 { 2919 // HTML source view and prospect adapt to the printer's paper size 2920 aTmpSize = pPrinter->GetPaperSize(); 2921 aTmpSize = pPrinter->LogicToLogic( aTmpSize, 2922 pPrinter->GetMapMode(), MapMode( MAP_100TH_MM )); 2923 aPageSize = awt::Size( aTmpSize.Width(), aTmpSize.Height() ); 2924 #if 0 2925 // #i115048# it seems users didn't like getting double the formatted page size 2926 // revert to "old" behavior scaling to the current paper size of the printer 2927 if (bPrintProspect) 2928 { 2929 // we just state what output size we would need 2930 // which may cause vcl to set that page size on the printer 2931 // (if available and not overriden by the user) 2932 aTmpSize = pVwSh->GetPageSize( nPage, bIsSkipEmptyPages ); 2933 aPreferredPageSize = awt::Size ( TWIP_TO_MM100( 2 * aTmpSize.Width() ), 2934 TWIP_TO_MM100( aTmpSize.Height() )); 2935 } 2936 #else 2937 if( bPrintProspect ) 2938 { 2939 // just switch to an appropriate portrait/landscape format 2940 // FIXME: brochure printing with landscape pages puts the 2941 // pages next to each other, so landscape is currently always 2942 // the better choice 2943 if( aPageSize.Width < aPageSize.Height ) 2944 { 2945 aPreferredPageSize.Width = aPageSize.Height; 2946 aPreferredPageSize.Height = aPageSize.Width; 2947 } 2948 } 2949 #endif 2950 } 2951 } 2952 else 2953 { 2954 aTmpSize = pVwSh->GetPageSize( nPage, bIsSkipEmptyPages ); 2955 aPageSize = awt::Size ( TWIP_TO_MM100( aTmpSize.Width() ), 2956 TWIP_TO_MM100( aTmpSize.Height() )); 2957 } 2958 2959 sal_Int32 nLen = 2; 2960 aRenderer.realloc(2); 2961 aRenderer[0].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "PageSize" ) ); 2962 aRenderer[0].Value <<= aPageSize; 2963 aRenderer[1].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "PageIncludesNonprintableArea" ) ); 2964 aRenderer[1].Value <<= sal_True; 2965 if (aPreferredPageSize.Width && aPreferredPageSize.Height) 2966 { 2967 ++nLen; 2968 aRenderer.realloc( nLen ); 2969 aRenderer[ nLen - 1 ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "PreferredPageSize" ) ); 2970 aRenderer[ nLen - 1 ].Value <<= aPreferredPageSize; 2971 } 2972 if (nPrinterPaperTray >= 0) 2973 { 2974 ++nLen; 2975 aRenderer.realloc( nLen ); 2976 aRenderer[ nLen - 1 ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "PrinterPaperTray" ) ); 2977 aRenderer[ nLen - 1 ].Value <<= nPrinterPaperTray; 2978 } 2979 } 2980 2981 // --> OD #i117783# 2982 if ( bApplyPagePrintSettingsFromXPagePrintable ) 2983 { 2984 const SwPagePreViewPrtData* pPagePrintSettings = 2985 pDocShell->GetDoc()->GetPreViewPrtData(); 2986 if ( pPagePrintSettings && 2987 ( pPagePrintSettings->GetRow() > 1 || 2988 pPagePrintSettings->GetCol() > 1 ) ) 2989 { 2990 // extend render data by page print settings attributes 2991 sal_Int32 nLen = aRenderer.getLength(); 2992 const sal_Int32 nRenderDataIdxStart = nLen; 2993 nLen += 9; 2994 aRenderer.realloc( nLen ); 2995 // put page print settings attribute into render data 2996 const sal_Int32 nRow = pPagePrintSettings->GetRow(); 2997 aRenderer[ nRenderDataIdxStart + 0 ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "NUpRows" ) ); 2998 aRenderer[ nRenderDataIdxStart + 0 ].Value <<= ( nRow > 1 ? nRow : 1 ); 2999 const sal_Int32 nCol = pPagePrintSettings->GetCol(); 3000 aRenderer[ nRenderDataIdxStart + 1 ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "NUpColumns" ) ); 3001 aRenderer[ nRenderDataIdxStart + 1 ].Value <<= ( nCol > 1 ? nCol : 1 ); 3002 aRenderer[ nRenderDataIdxStart + 2 ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "NUpPageMarginLeft" ) ); 3003 aRenderer[ nRenderDataIdxStart + 2 ].Value <<= pPagePrintSettings->GetLeftSpace(); 3004 aRenderer[ nRenderDataIdxStart + 3 ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "NUpPageMarginRight" ) ); 3005 aRenderer[ nRenderDataIdxStart + 3 ].Value <<= pPagePrintSettings->GetRightSpace(); 3006 aRenderer[ nRenderDataIdxStart + 4 ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "NUpPageMarginTop" ) ); 3007 aRenderer[ nRenderDataIdxStart + 4 ].Value <<= pPagePrintSettings->GetTopSpace(); 3008 aRenderer[ nRenderDataIdxStart + 5 ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "NUpPageMarginBottom" ) ); 3009 aRenderer[ nRenderDataIdxStart + 5 ].Value <<= pPagePrintSettings->GetBottomSpace(); 3010 aRenderer[ nRenderDataIdxStart + 6 ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "NUpHorizontalSpacing" ) ); 3011 aRenderer[ nRenderDataIdxStart + 6 ].Value <<= pPagePrintSettings->GetHorzSpace(); 3012 aRenderer[ nRenderDataIdxStart + 7 ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "NUpVerticalSpacing" ) ); 3013 aRenderer[ nRenderDataIdxStart + 7 ].Value <<= pPagePrintSettings->GetVertSpace(); 3014 { 3015 Printer* pPrinter = pDocShell->GetDoc()->getPrinter( false ); 3016 if ( pPrinter ) 3017 { 3018 awt::Size aNewPageSize; 3019 const Size aPageSize = pPrinter->PixelToLogic( pPrinter->GetPaperSizePixel(), MapMode( MAP_100TH_MM ) ); 3020 aNewPageSize = awt::Size( aPageSize.Width(), aPageSize.Height() ); 3021 if ( ( pPagePrintSettings->GetLandscape() && 3022 aPageSize.Width() < aPageSize.Height() ) || 3023 ( !pPagePrintSettings->GetLandscape() && 3024 aPageSize.Width() > aPageSize.Height() ) ) 3025 { 3026 aNewPageSize = awt::Size( aPageSize.Height(), aPageSize.Width() ); 3027 } 3028 aRenderer[ nRenderDataIdxStart + 8 ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "NUpPaperSize" ) ); 3029 aRenderer[ nRenderDataIdxStart + 8 ].Value <<= aNewPageSize; 3030 } 3031 } 3032 } 3033 3034 bApplyPagePrintSettingsFromXPagePrintable = sal_False; 3035 } 3036 // <-- 3037 3038 m_pPrintUIOptions->appendPrintUIOptions( aRenderer ); 3039 3040 return aRenderer; 3041 } 3042 /* -----------------------------28.10.02 16:00-------------------------------- 3043 3044 ---------------------------------------------------------------------------*/ 3045 SfxViewShell * SwXTextDocument::GuessViewShell( 3046 /* out */ bool &rbIsSwSrcView, 3047 const uno::Reference< css::frame::XController > xController ) 3048 { 3049 // #130810# SfxViewShell::Current() / SfxViewShell::GetObjectShell() 3050 // must not be used (see comment from MBA) 3051 // 3052 SfxViewShell *pView = 0; 3053 SwView *pSwView = 0; 3054 SwPagePreView *pSwPagePreView = 0; 3055 SwSrcView *pSwSrcView = 0; 3056 SfxViewFrame *pFrame = SfxViewFrame::GetFirst( pDocShell, sal_False ); 3057 3058 // look for the view shell with the same controller in use, 3059 // otherwise look for a suitable view, preferably a SwView, 3060 // if that one is not found use a SwPagePreView if found. 3061 while (pFrame) 3062 { 3063 pView = pFrame->GetViewShell(); 3064 pSwView = dynamic_cast< SwView * >(pView); 3065 pSwSrcView = dynamic_cast< SwSrcView * >(pView); 3066 if (!pSwPagePreView) 3067 pSwPagePreView = dynamic_cast< SwPagePreView * >(pView); 3068 if (xController.is()) 3069 { 3070 if (pView && pView->GetController() == xController) 3071 break; 3072 } 3073 else if (pSwView || pSwSrcView) 3074 break; 3075 pFrame = SfxViewFrame::GetNext( *pFrame, pDocShell, sal_False ); 3076 } 3077 3078 DBG_ASSERT( pSwView || pSwPagePreView || pSwSrcView, "failed to get view shell" ); 3079 if (pView) 3080 rbIsSwSrcView = pSwSrcView != 0; 3081 return pView; 3082 // return pSwView ? dynamic_cast< SfxViewShell * >(pSwView) : 3083 // (pSwSrcView ? dynamic_cast< SfxViewShell * >(pSwSrcView) : 3084 // dynamic_cast< SfxViewShell * >(pSwPagePreView) ); 3085 } 3086 3087 3088 void SAL_CALL SwXTextDocument::render( 3089 sal_Int32 nRenderer, 3090 const uno::Any& rSelection, 3091 const uno::Sequence< beans::PropertyValue >& rxOptions ) 3092 throw (IllegalArgumentException, RuntimeException) 3093 { 3094 ::vos::OGuard aGuard(Application::GetSolarMutex()); 3095 if(!IsValid()) 3096 throw RuntimeException(); 3097 3098 // due to #110067# (document page count changes sometimes during 3099 // PDF export/printing) we can not check for the upper bound properly. 3100 // Thus instead of throwing the exception we silently return. 3101 if (0 > nRenderer) 3102 throw IllegalArgumentException(); 3103 3104 const bool bIsPDFExport = !lcl_SeqHasProperty( rxOptions, "IsPrinter" ); 3105 bool bIsSwSrcView = false; 3106 SfxViewShell *pView = GetRenderView( bIsSwSrcView, rxOptions, bIsPDFExport ); 3107 3108 DBG_ASSERT( m_pRenderData, "data should have been created already in getRendererCount..." ); 3109 DBG_ASSERT( m_pPrintUIOptions, "data should have been created already in getRendererCount..." ); 3110 if (!bIsSwSrcView && !m_pRenderData) 3111 m_pRenderData = new SwRenderData; 3112 if (!m_pPrintUIOptions) 3113 m_pPrintUIOptions = lcl_GetPrintUIOptions( pDocShell, pView ); 3114 m_pPrintUIOptions->processProperties( rxOptions ); 3115 const bool bPrintProspect = m_pPrintUIOptions->getBoolValue( "PrintProspect", false ); 3116 const bool bLastPage = m_pPrintUIOptions->getBoolValue( "IsLastPage", sal_False ); 3117 3118 SwDoc *pDoc = GetRenderDoc( pView, rSelection, bIsPDFExport ); 3119 DBG_ASSERT( pDoc && pView, "doc or view shell missing!" ); 3120 if (pDoc && pView) 3121 { 3122 sal_Int32 nMaxRenderer = 0; 3123 if (!bIsSwSrcView) 3124 { 3125 DBG_ASSERT( m_pRenderData, "m_pRenderData missing!!" ); 3126 nMaxRenderer = bPrintProspect? 3127 m_pRenderData->GetPagePairsForProspectPrinting().size() - 1 : 3128 m_pRenderData->GetPagesToPrint().size() - 1; 3129 } 3130 // since SwSrcView::PrintSource is a poor implementation to get the number of pages to print 3131 // we obmit checking of the upper bound in this case. 3132 if (bIsSwSrcView || nRenderer <= nMaxRenderer) 3133 { 3134 if (bIsSwSrcView) 3135 { 3136 SwSrcView *pSwSrcView = dynamic_cast< SwSrcView * >(pView); 3137 OutputDevice *pOutDev = lcl_GetOutputDevice( *m_pPrintUIOptions ); 3138 pSwSrcView->PrintSource( pOutDev, nRenderer + 1, false ); 3139 } 3140 else 3141 { 3142 // the view shell should be SwView for documents PDF export 3143 // or SwPagePreView for PDF export of the page preview 3144 //!! (check for SwView first as in GuessViewShell) !! 3145 DBG_ASSERT( pView, "!! view missing !!" ); 3146 const TypeId aSwViewTypeId = TYPE(SwView); 3147 ViewShell* pVwSh = 0; 3148 if (pView) 3149 { 3150 // TODO/mba: we really need a generic way to get the ViewShell! 3151 SwView* pSwView = PTR_CAST(SwView, pView); 3152 if ( pSwView ) 3153 pVwSh = pSwView->GetWrtShellPtr(); 3154 else 3155 pVwSh = ((SwPagePreView*)pView)->GetViewShell(); 3156 } 3157 3158 // get output device to use 3159 OutputDevice * pOut = lcl_GetOutputDevice( *m_pPrintUIOptions ); 3160 3161 if(pVwSh && pOut && m_pRenderData->HasSwPrtOptions()) 3162 { 3163 const rtl::OUString aPageRange = m_pPrintUIOptions->getStringValue( "PageRange", OUString() ); 3164 const bool bFirstPage = m_pPrintUIOptions->getBoolValue( "IsFirstPage", sal_False ); 3165 bool bIsSkipEmptyPages = !m_pPrintUIOptions->IsPrintEmptyPages( bIsPDFExport ); 3166 3167 DBG_ASSERT(( pView->IsA(aSwViewTypeId) && m_pRenderData->IsViewOptionAdjust()) 3168 || (!pView->IsA(aSwViewTypeId) && !m_pRenderData->IsViewOptionAdjust()), 3169 "SwView / SwViewOptionAdjust_Impl availability mismatch" ); 3170 3171 // since printing now also use the API for PDF export this option 3172 // should be set for printing as well ... 3173 pVwSh->SetPDFExportOption( sal_True ); 3174 3175 // --> FME 2004-06-08 #i12836# enhanced pdf export 3176 // 3177 // First, we have to export hyperlinks, notes, and outline to pdf. 3178 // During this process, additional information required for tagging 3179 // the pdf file are collected, which are evaulated during painting. 3180 // 3181 SwWrtShell* pWrtShell = pView->IsA(aSwViewTypeId) ? 3182 ((SwView*)pView)->GetWrtShellPtr() : 3183 0; 3184 3185 if (bIsPDFExport && bFirstPage && pWrtShell) 3186 { 3187 SwEnhancedPDFExportHelper aHelper( *pWrtShell, *pOut, aPageRange, bIsSkipEmptyPages, sal_False ); 3188 } 3189 // <-- 3190 3191 SwPrintData const& rSwPrtOptions = 3192 *m_pRenderData->GetSwPrtOptions(); 3193 if (bPrintProspect) 3194 pVwSh->PrintProspect( pOut, rSwPrtOptions, nRenderer ); 3195 else // normal printing and PDF export 3196 pVwSh->PrintOrPDFExport( pOut, rSwPrtOptions, nRenderer ); 3197 3198 // --> FME 2004-10-08 #i35176# 3199 // 3200 // After printing the last page, we take care for the links coming 3201 // from the EditEngine. The links are generated during the painting 3202 // process, but the destinations are still missing. 3203 // 3204 if (bIsPDFExport && bLastPage && pWrtShell) 3205 { 3206 SwEnhancedPDFExportHelper aHelper( *pWrtShell, *pOut, aPageRange, bIsSkipEmptyPages, sal_True ); 3207 } 3208 // <-- 3209 3210 pVwSh->SetPDFExportOption( sal_False ); 3211 3212 // last page to be rendered? (not necessarily the last page of the document) 3213 // -> do clean-up of data 3214 if (bLastPage) 3215 { 3216 // #i96167# haggai: delete ViewOptionsAdjust here because it makes use 3217 // of the shell, which might get destroyed in lcl_DisposeView! 3218 if (m_pRenderData && m_pRenderData->IsViewOptionAdjust()) 3219 m_pRenderData->ViewOptionAdjustStop(); 3220 3221 if (m_pRenderData && m_pRenderData->HasPostItData()) 3222 m_pRenderData->DeletePostItData(); 3223 if (m_pHiddenViewFrame) 3224 { 3225 lcl_DisposeView( m_pHiddenViewFrame, pDocShell ); 3226 m_pHiddenViewFrame = 0; 3227 3228 // prevent crash described in #i108805 3229 SwDocShell *pRenderDocShell = pDoc->GetDocShell(); 3230 SfxItemSet *pSet = pRenderDocShell->GetMedium()->GetItemSet(); 3231 pSet->Put( SfxBoolItem( SID_HIDDEN, sal_False ) ); 3232 3233 } 3234 } 3235 } 3236 } 3237 } 3238 } 3239 if( bLastPage ) 3240 { 3241 delete m_pRenderData; m_pRenderData = NULL; 3242 delete m_pPrintUIOptions; m_pPrintUIOptions = NULL; 3243 } 3244 } 3245 /* -----------------------------03.10.04 ------------------------------------- 3246 3247 ---------------------------------------------------------------------------*/ 3248 // xforms::XFormsSupplier 3249 Reference<XNameContainer> SAL_CALL SwXTextDocument::getXForms() 3250 throw( RuntimeException ) 3251 { 3252 if ( !pDocShell ) 3253 throw DisposedException( ::rtl::OUString(), static_cast< XTextDocument* >( this ) ); 3254 SwDoc* pDoc = pDocShell->GetDoc(); 3255 return pDoc->getXForms(); 3256 } 3257 3258 /* -----------------------------25.09.07 ------------------------------------- 3259 3260 ---------------------------------------------------------------------------*/ 3261 uno::Reference< text::XFlatParagraphIterator > SAL_CALL SwXTextDocument::getFlatParagraphIterator(::sal_Int32 nTextMarkupType, sal_Bool bAutomatic) 3262 throw ( uno::RuntimeException ) 3263 { 3264 return new SwXFlatParagraphIterator( *pDocShell->GetDoc(), nTextMarkupType, bAutomatic ); 3265 } 3266 /*-- 07.05.2009 09:21:12--------------------------------------------------- 3267 3268 -----------------------------------------------------------------------*/ 3269 uno::Reference< util::XCloneable > SwXTextDocument::createClone( ) throw (uno::RuntimeException) 3270 { 3271 ::vos::OGuard aGuard(Application::GetSolarMutex()); 3272 if(!IsValid()) 3273 throw RuntimeException(); 3274 3275 // create a new document - hidden - copy the storage and return it 3276 // SfxObjectShellRef is used here, since the model should control object lifetime after creation 3277 // and thus SfxObjectShellLock is not allowed here 3278 // the model holds reference to the shell, so the shell will not destructed at the end of method 3279 SfxObjectShellRef pShell = pDocShell->GetDoc()->CreateCopy(false); 3280 uno::Reference< frame::XModel > xNewModel = pShell->GetModel(); 3281 uno::Reference< embed::XStorage > xNewStorage = ::comphelper::OStorageHelper::GetTemporaryStorage( ); 3282 uno::Sequence< beans::PropertyValue > aTempMediaDescriptor; 3283 storeToStorage( xNewStorage, aTempMediaDescriptor ); 3284 uno::Reference< document::XStorageBasedDocument > xStorageDoc( xNewModel, uno::UNO_QUERY ); 3285 xStorageDoc->loadFromStorage( xNewStorage, aTempMediaDescriptor ); 3286 return uno::Reference< util::XCloneable >( xNewModel, UNO_QUERY ); 3287 } 3288 /* -----------------------------20.06.00 09:54-------------------------------- 3289 3290 ---------------------------------------------------------------------------*/ 3291 void * SAL_CALL SwXTextDocument::operator new( size_t t) throw() 3292 { 3293 return SwXTextDocumentBaseClass::operator new(t); 3294 } 3295 /* -----------------------------20.06.00 09:54-------------------------------- 3296 3297 ---------------------------------------------------------------------------*/ 3298 void SAL_CALL SwXTextDocument::operator delete( void * p) throw() 3299 { 3300 SwXTextDocumentBaseClass::operator delete(p); 3301 } 3302 3303 3304 /*--------------------------------------------------- 3305 retrieve languages already used in current document 3306 -----------------------------------------------------*/ 3307 uno::Sequence< lang::Locale > SAL_CALL SwXTextDocument::getDocumentLanguages( 3308 ::sal_Int16 nScriptTypes, 3309 ::sal_Int16 nMaxCount ) 3310 throw (lang::IllegalArgumentException, uno::RuntimeException) 3311 { 3312 ::vos::OGuard aGuard(Application::GetSolarMutex()); 3313 3314 // possible canonical values for nScriptTypes 3315 // any bit wise combination is allowed 3316 const sal_Int16 nLatin = 0x001; 3317 const sal_Int16 nAsian = 0x002; 3318 const sal_Int16 nComplex = 0x004; 3319 3320 // script types for which to get the languages 3321 const bool bLatin = 0 != (nScriptTypes & nLatin); 3322 const bool bAsian = 0 != (nScriptTypes & nAsian); 3323 const bool bComplex = 0 != (nScriptTypes & nComplex); 3324 3325 if (nScriptTypes < nLatin || nScriptTypes > (nLatin | nAsian | nComplex)) 3326 throw IllegalArgumentException(::rtl::OUString::createFromAscii("nScriptTypes ranges from 1 to 7!"), Reference< XInterface >(), 1); 3327 if (!pDocShell) 3328 throw DisposedException(); 3329 SwDoc* pDoc = pDocShell->GetDoc(); 3330 3331 // avoid duplicate values 3332 std::set< LanguageType > aAllLangs; 3333 3334 //USER STYLES 3335 3336 const SwCharFmts *pFmts = pDoc->GetCharFmts(); 3337 for(sal_uInt16 i = 0; i < pFmts->Count(); ++i) 3338 { 3339 const SwAttrSet &rAttrSet = (*pFmts)[i]->GetAttrSet(); 3340 LanguageType nLang = LANGUAGE_DONTKNOW; 3341 if (bLatin) 3342 { 3343 nLang = rAttrSet.GetLanguage( sal_False ).GetLanguage(); 3344 if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM) 3345 aAllLangs.insert( nLang ); 3346 } 3347 if (bAsian) 3348 { 3349 nLang = rAttrSet.GetCJKLanguage( sal_False ).GetLanguage(); 3350 if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM) 3351 aAllLangs.insert( nLang ); 3352 } 3353 if (bComplex) 3354 { 3355 nLang = rAttrSet.GetCTLLanguage( sal_False ).GetLanguage(); 3356 if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM) 3357 aAllLangs.insert( nLang ); 3358 } 3359 } 3360 3361 const SwTxtFmtColls *pColls = pDoc->GetTxtFmtColls(); 3362 for (sal_uInt16 i = 0; i < pColls->Count(); ++i) 3363 { 3364 const SwAttrSet &rAttrSet = (*pColls)[i]->GetAttrSet(); 3365 LanguageType nLang = LANGUAGE_DONTKNOW;; 3366 if (bLatin) 3367 { 3368 nLang = rAttrSet.GetLanguage( sal_False ).GetLanguage(); 3369 if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM) 3370 aAllLangs.insert( nLang ); 3371 } 3372 if (bAsian) 3373 { 3374 nLang = rAttrSet.GetCJKLanguage( sal_False ).GetLanguage(); 3375 if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM) 3376 aAllLangs.insert( nLang ); 3377 } 3378 if (bComplex) 3379 { 3380 nLang = rAttrSet.GetCTLLanguage( sal_False ).GetLanguage(); 3381 if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM) 3382 aAllLangs.insert( nLang ); 3383 } 3384 } 3385 3386 //AUTO STYLES 3387 const IStyleAccess::SwAutoStyleFamily aFam[2] = 3388 { 3389 IStyleAccess::AUTO_STYLE_CHAR, 3390 IStyleAccess::AUTO_STYLE_PARA 3391 }; 3392 for (sal_uInt16 i = 0; i < 2; ++i) 3393 { 3394 std::vector< SfxItemSet_Pointer_t > rStyles; 3395 pDoc->GetIStyleAccess().getAllStyles(rStyles, aFam[i]); 3396 while (!rStyles.empty()) 3397 { 3398 SfxItemSet_Pointer_t pStyle = rStyles.back(); 3399 rStyles.pop_back(); 3400 const SfxItemSet *pSet = dynamic_cast< const SfxItemSet * >(pStyle.get()); 3401 3402 LanguageType nLang = LANGUAGE_DONTKNOW; 3403 if (bLatin) 3404 { 3405 nLang = dynamic_cast< const SvxLanguageItem & >(pSet->Get( RES_CHRATR_LANGUAGE, sal_False )).GetLanguage(); 3406 if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM) 3407 aAllLangs.insert( nLang ); 3408 } 3409 if (bAsian) 3410 { 3411 nLang = dynamic_cast< const SvxLanguageItem & >(pSet->Get( RES_CHRATR_CJK_LANGUAGE, sal_False )).GetLanguage(); 3412 if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM) 3413 aAllLangs.insert( nLang ); 3414 } 3415 if (bComplex) 3416 { 3417 nLang = dynamic_cast< const SvxLanguageItem & >(pSet->Get( RES_CHRATR_CTL_LANGUAGE, sal_False )).GetLanguage(); 3418 if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM) 3419 aAllLangs.insert( nLang ); 3420 } 3421 } 3422 } 3423 3424 //TODO/mba: it's a strange concept that a view is needed to retrieve core data 3425 SwWrtShell *pWrtSh = pDocShell->GetWrtShell(); 3426 SdrView *pSdrView = pWrtSh->GetDrawView(); 3427 3428 if( pSdrView ) 3429 { 3430 SdrOutliner* pOutliner = pSdrView->GetTextEditOutliner(); 3431 if(pOutliner) 3432 { 3433 EditEngine& rEditEng = (EditEngine&)pOutliner->GetEditEngine(); 3434 sal_uLong nParCount = pOutliner->GetParagraphCount(); 3435 for (sal_uLong nPar=0; nPar<nParCount; nPar++) 3436 { 3437 //every paragraph 3438 SvUShorts aPortions; 3439 rEditEng.GetPortions( (sal_uInt16)nPar, aPortions ); 3440 3441 for ( sal_uInt16 nPos = aPortions.Count(); nPos; ) 3442 { 3443 //every position 3444 --nPos; 3445 sal_uInt16 nEnd = aPortions.GetObject( nPos ); 3446 sal_uInt16 nStart = nPos ? aPortions.GetObject( nPos - 1 ) : 0; 3447 ESelection aSelection( (sal_uInt16)nPar, nStart, (sal_uInt16)nPar, nEnd ); 3448 SfxItemSet aAttr = rEditEng.GetAttribs( aSelection ); 3449 3450 LanguageType nLang = LANGUAGE_DONTKNOW; 3451 if (bLatin) 3452 { 3453 nLang = dynamic_cast< const SvxLanguageItem & >(aAttr.Get( EE_CHAR_LANGUAGE, sal_False )).GetLanguage(); 3454 if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM) 3455 aAllLangs.insert( nLang ); 3456 } 3457 if (bAsian) 3458 { 3459 nLang = dynamic_cast< const SvxLanguageItem & >(aAttr.Get( EE_CHAR_LANGUAGE_CJK, sal_False )).GetLanguage(); 3460 if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM) 3461 aAllLangs.insert( nLang ); 3462 } 3463 if (bComplex) 3464 { 3465 nLang = dynamic_cast< const SvxLanguageItem & >(aAttr.Get( EE_CHAR_LANGUAGE_CTL, sal_False )).GetLanguage(); 3466 if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM) 3467 aAllLangs.insert( nLang ); 3468 } 3469 } 3470 } 3471 } 3472 } 3473 // less than nMaxCount languages 3474 if (nMaxCount > static_cast< sal_Int16 >( aAllLangs.size() )) 3475 nMaxCount = static_cast< sal_Int16 >( aAllLangs.size() ); 3476 3477 // build return value 3478 sal_Int32 nCount = 0; 3479 uno::Sequence< lang::Locale > aLanguages( nMaxCount ); 3480 lang::Locale* pLanguage = aLanguages.getArray(); 3481 if (nMaxCount > 0) 3482 { 3483 const SvtLanguageTable aLangTab; 3484 for (std::set< LanguageType >::const_iterator it = aAllLangs.begin(); it != aAllLangs.end(); ++it) 3485 { 3486 if (nCount >= nMaxCount) 3487 break; 3488 if (LANGUAGE_NONE != *it) 3489 { 3490 MsLangId::convertLanguageToLocale( *it, pLanguage[nCount] ); 3491 pLanguage[nCount].Language = aLangTab.GetString( *it ); 3492 nCount += 1; 3493 } 3494 } 3495 } 3496 3497 return aLanguages; 3498 } 3499 3500 /* -----------------25.10.99 11:06------------------- 3501 3502 --------------------------------------------------*/ 3503 SwXLinkTargetSupplier::SwXLinkTargetSupplier(SwXTextDocument& rxDoc) : 3504 pxDoc(&rxDoc) 3505 { 3506 sTables = String(SW_RES(STR_CONTENT_TYPE_TABLE)); 3507 sFrames = String(SW_RES(STR_CONTENT_TYPE_FRAME)); 3508 sGraphics = String(SW_RES(STR_CONTENT_TYPE_GRAPHIC)); 3509 sOLEs = String(SW_RES(STR_CONTENT_TYPE_OLE)); 3510 sSections = String(SW_RES(STR_CONTENT_TYPE_REGION)); 3511 sOutlines = String(SW_RES(STR_CONTENT_TYPE_OUTLINE)); 3512 sBookmarks = String(SW_RES(STR_CONTENT_TYPE_BOOKMARK)); 3513 } 3514 /* -----------------25.10.99 11:11------------------- 3515 3516 --------------------------------------------------*/ 3517 SwXLinkTargetSupplier::~SwXLinkTargetSupplier() 3518 { 3519 } 3520 3521 /*-- 25.10.99 11:12:45--------------------------------------------------- 3522 3523 -----------------------------------------------------------------------*/ 3524 Any SwXLinkTargetSupplier::getByName(const OUString& rName) 3525 throw( NoSuchElementException, WrappedTargetException, RuntimeException ) 3526 { 3527 Any aRet; 3528 if(!pxDoc) 3529 throw RuntimeException(); 3530 String sToCompare(rName); 3531 String sSuffix('|'); 3532 if(sToCompare == sTables) 3533 { 3534 sSuffix += UniString::CreateFromAscii(pMarkToTable); 3535 3536 Reference< XNameAccess > xTbls = new SwXLinkNameAccessWrapper( 3537 pxDoc->getTextTables(), sToCompare, sSuffix ); 3538 Reference< XPropertySet > xRet(xTbls, UNO_QUERY); 3539 aRet.setValue(&xRet, ::getCppuType((Reference<XPropertySet>*)0)); 3540 } 3541 else if(sToCompare == sFrames) 3542 { 3543 sSuffix += UniString::CreateFromAscii(pMarkToFrame); 3544 Reference< XNameAccess > xTbls = new SwXLinkNameAccessWrapper( 3545 pxDoc->getTextFrames(), sToCompare, sSuffix ); 3546 Reference< XPropertySet > xRet(xTbls, UNO_QUERY); 3547 aRet.setValue(&xRet, ::getCppuType((Reference< XPropertySet>*)0)); 3548 } 3549 else if(sToCompare == sSections) 3550 { 3551 sSuffix += UniString::CreateFromAscii(pMarkToRegion); 3552 Reference< XNameAccess > xTbls = new SwXLinkNameAccessWrapper( 3553 pxDoc->getTextSections(), sToCompare, sSuffix ); 3554 Reference< XPropertySet > xRet(xTbls, UNO_QUERY); 3555 aRet.setValue(&xRet, ::getCppuType((Reference< XPropertySet>*)0)); 3556 } 3557 /* else if(sToCompare == ) 3558 { 3559 sSuffix += UniString::CreateFromAscii(pMarkToText); 3560 Reference< XNameAccess > xTbls = new SwXLinkNameAccessWrapper( 3561 pxDoc->, sSuffix ); 3562 Reference< XPropertySet > xRet(xTbls, UNO_QUERY); 3563 aRet.setValue(&xRet, ::getCppuType((const XPropertySet*)0)); 3564 }*/ 3565 else if(sToCompare == sGraphics) 3566 { 3567 sSuffix += UniString::CreateFromAscii(pMarkToGraphic); 3568 Reference< XNameAccess > xTbls = new SwXLinkNameAccessWrapper( 3569 pxDoc->getGraphicObjects(), sToCompare, sSuffix ); 3570 Reference< XPropertySet > xRet(xTbls, UNO_QUERY); 3571 aRet.setValue(&xRet, ::getCppuType((Reference< XPropertySet>*)0)); 3572 } 3573 else if(sToCompare == sOLEs) 3574 { 3575 sSuffix += UniString::CreateFromAscii(pMarkToOLE); 3576 Reference< XNameAccess > xTbls = new SwXLinkNameAccessWrapper( 3577 pxDoc->getEmbeddedObjects(), sToCompare, sSuffix ); 3578 Reference< XPropertySet > xRet(xTbls, UNO_QUERY); 3579 aRet.setValue(&xRet, ::getCppuType((Reference< XPropertySet>*)0)); 3580 } 3581 else if(sToCompare == sOutlines) 3582 { 3583 sSuffix += UniString::CreateFromAscii(pMarkToOutline); 3584 Reference< XNameAccess > xTbls = new SwXLinkNameAccessWrapper( 3585 *pxDoc, sToCompare, sSuffix ); 3586 Reference< XPropertySet > xRet(xTbls, UNO_QUERY); 3587 aRet.setValue(&xRet, ::getCppuType((Reference< XPropertySet>*)0)); 3588 } 3589 else if(sToCompare == sBookmarks) 3590 { 3591 sSuffix.Erase(); 3592 Reference< XNameAccess > xBkms = new SwXLinkNameAccessWrapper( 3593 pxDoc->getBookmarks(), sToCompare, sSuffix ); 3594 Reference< XPropertySet > xRet(xBkms, UNO_QUERY); 3595 aRet.setValue(&xRet, ::getCppuType((Reference< XPropertySet>*)0)); 3596 } 3597 else 3598 throw NoSuchElementException(); 3599 return aRet; 3600 } 3601 /*-- 25.10.99 11:12:46--------------------------------------------------- 3602 3603 -----------------------------------------------------------------------*/ 3604 Sequence< OUString > SwXLinkTargetSupplier::getElementNames(void) 3605 throw( RuntimeException ) 3606 { 3607 Sequence< OUString > aRet(7); 3608 OUString* pNames = aRet.getArray(); 3609 pNames[0] = sTables; 3610 pNames[1] = sFrames ; 3611 pNames[2] = sGraphics; 3612 pNames[3] = sOLEs ; 3613 pNames[4] = sSections; 3614 pNames[5] = sOutlines; 3615 pNames[6] = sBookmarks; 3616 return aRet; 3617 } 3618 /*-- 25.10.99 11:12:46--------------------------------------------------- 3619 3620 -----------------------------------------------------------------------*/ 3621 sal_Bool SwXLinkTargetSupplier::hasByName(const OUString& rName) 3622 throw( RuntimeException ) 3623 { 3624 String sToCompare(rName); 3625 if( sToCompare == sTables || 3626 sToCompare == sFrames || 3627 sToCompare == sGraphics|| 3628 sToCompare == sOLEs || 3629 sToCompare == sSections || 3630 sToCompare == sOutlines || 3631 sToCompare == sBookmarks ) 3632 return sal_True; 3633 return sal_False; 3634 } 3635 /*-- 25.10.99 11:12:47--------------------------------------------------- 3636 3637 -----------------------------------------------------------------------*/ 3638 uno::Type SwXLinkTargetSupplier::getElementType(void) 3639 throw( RuntimeException ) 3640 { 3641 return ::getCppuType((Reference< XPropertySet>*)0); 3642 3643 } 3644 /*-- 25.10.99 11:12:47--------------------------------------------------- 3645 3646 -----------------------------------------------------------------------*/ 3647 sal_Bool SwXLinkTargetSupplier::hasElements(void) throw( RuntimeException ) 3648 { 3649 return 0 != pxDoc; 3650 } 3651 /*-- 25.10.99 11:12:47--------------------------------------------------- 3652 3653 -----------------------------------------------------------------------*/ 3654 OUString SwXLinkTargetSupplier::getImplementationName(void) throw( RuntimeException ) 3655 { 3656 return C2U("SwXLinkTargetSupplier"); 3657 } 3658 /*-- 25.10.99 11:12:48--------------------------------------------------- 3659 3660 -----------------------------------------------------------------------*/ 3661 sal_Bool SwXLinkTargetSupplier::supportsService(const OUString& rServiceName) 3662 throw( RuntimeException ) 3663 { 3664 return (rServiceName == C2U("com.sun.star.document.LinkTargets")); 3665 } 3666 /*-- 25.10.99 11:12:48--------------------------------------------------- 3667 3668 -----------------------------------------------------------------------*/ 3669 Sequence< OUString > SwXLinkTargetSupplier::getSupportedServiceNames(void) 3670 throw( RuntimeException ) 3671 { 3672 Sequence< OUString > aRet(1); 3673 OUString* pNames = aRet.getArray(); 3674 pNames[0] = C2U("com.sun.star.document.LinkTargets"); 3675 return aRet; 3676 } 3677 3678 /*-- 26.10.99 09:16:23--------------------------------------------------- 3679 3680 -----------------------------------------------------------------------*/ 3681 SwXLinkNameAccessWrapper::SwXLinkNameAccessWrapper( 3682 Reference< XNameAccess > xAccess, const String& rLinkDisplayName, String sSuffix ) : 3683 xRealAccess(xAccess), 3684 pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_LINK_TARGET)), 3685 sLinkSuffix(sSuffix), 3686 sLinkDisplayName(rLinkDisplayName), 3687 pxDoc(0) 3688 { 3689 } 3690 /* -----------------26.10.99 14:17------------------- 3691 3692 --------------------------------------------------*/ 3693 SwXLinkNameAccessWrapper::SwXLinkNameAccessWrapper(SwXTextDocument& rxDoc, 3694 const String& rLinkDisplayName, String sSuffix) : 3695 pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_LINK_TARGET)), 3696 sLinkSuffix(sSuffix), 3697 sLinkDisplayName(rLinkDisplayName), 3698 xDoc(&rxDoc), 3699 pxDoc(&rxDoc) 3700 { 3701 } 3702 /*-- 26.10.99 09:16:23--------------------------------------------------- 3703 3704 -----------------------------------------------------------------------*/ 3705 SwXLinkNameAccessWrapper::~SwXLinkNameAccessWrapper() 3706 { 3707 } 3708 /*-- 26.10.99 09:16:24--------------------------------------------------- 3709 3710 -----------------------------------------------------------------------*/ 3711 Any SwXLinkNameAccessWrapper::getByName(const OUString& rName) 3712 throw( NoSuchElementException, WrappedTargetException, RuntimeException ) 3713 { 3714 Any aRet; 3715 sal_Bool bFound = sal_False; 3716 //cut link extension and call the real NameAccess 3717 String sParam = rName; 3718 String sSuffix(sLinkSuffix); 3719 if(sParam.Len() > sSuffix.Len() ) 3720 { 3721 String sCmp = sParam.Copy(sParam.Len() - sSuffix.Len(), 3722 sSuffix.Len()); 3723 if(sCmp == sSuffix) 3724 { 3725 if(pxDoc) 3726 { 3727 sParam = sParam.Copy(0, sParam.Len() - sSuffix.Len()); 3728 if(!pxDoc->GetDocShell()) 3729 throw RuntimeException(); 3730 SwDoc* pDoc = pxDoc->GetDocShell()->GetDoc(); 3731 sal_uInt16 nOutlineCount = pDoc->GetNodes().GetOutLineNds().Count(); 3732 3733 for (sal_uInt16 i = 0; i < nOutlineCount && !bFound; ++i) 3734 { 3735 const SwOutlineNodes& rOutlineNodes = pDoc->GetNodes().GetOutLineNds(); 3736 const SwNumRule* pOutlRule = pDoc->GetOutlineNumRule(); 3737 if(sParam == 3738 lcl_CreateOutlineString(i, rOutlineNodes, pOutlRule)) 3739 { 3740 Reference< XPropertySet > xOutline = new SwXOutlineTarget(sParam); 3741 aRet.setValue(&xOutline, ::getCppuType((Reference<XPropertySet>*)0)); 3742 bFound = sal_True; 3743 } 3744 } 3745 } 3746 else 3747 { 3748 aRet = xRealAccess->getByName(sParam.Copy(0, sParam.Len() - sSuffix.Len())); 3749 Reference< XInterface > xInt; 3750 if(!(aRet >>= xInt)) 3751 throw RuntimeException(); 3752 Reference< XPropertySet > xProp(xInt, UNO_QUERY); 3753 aRet <<= xProp; 3754 bFound = sal_True; 3755 } 3756 } 3757 } 3758 if(!bFound) 3759 throw NoSuchElementException(); 3760 return aRet; 3761 } 3762 /*-- 26.10.99 09:16:24--------------------------------------------------- 3763 3764 -----------------------------------------------------------------------*/ 3765 Sequence< OUString > SwXLinkNameAccessWrapper::getElementNames(void) 3766 throw( RuntimeException ) 3767 { 3768 Sequence< OUString > aRet; 3769 if(pxDoc) 3770 { 3771 if(!pxDoc->GetDocShell()) 3772 throw RuntimeException(); 3773 3774 SwDoc* pDoc = pxDoc->GetDocShell()->GetDoc(); 3775 const SwOutlineNodes& rOutlineNodes = pDoc->GetNodes().GetOutLineNds(); 3776 sal_uInt16 nOutlineCount = rOutlineNodes.Count(); 3777 aRet.realloc(nOutlineCount); 3778 OUString* pResArr = aRet.getArray(); 3779 String sSuffix('|'); 3780 sSuffix += UniString::CreateFromAscii(pMarkToOutline); 3781 const SwNumRule* pOutlRule = pDoc->GetOutlineNumRule(); 3782 for (sal_uInt16 i = 0; i < nOutlineCount; ++i) 3783 { 3784 String sEntry = lcl_CreateOutlineString(i, rOutlineNodes, pOutlRule); 3785 sEntry += sSuffix; 3786 pResArr[i] = sEntry; 3787 } 3788 } 3789 else 3790 { 3791 Sequence< OUString > aOrg = xRealAccess->getElementNames(); 3792 const OUString* pOrgArr = aOrg.getConstArray(); 3793 aRet.realloc(aOrg.getLength()); 3794 OUString* pResArr = aRet.getArray(); 3795 for(long i = 0; i < aOrg.getLength(); i++) 3796 { 3797 pResArr[i] = pOrgArr[i] + sLinkSuffix; 3798 } 3799 } 3800 return aRet; 3801 } 3802 /*-- 26.10.99 09:16:25--------------------------------------------------- 3803 3804 -----------------------------------------------------------------------*/ 3805 sal_Bool SwXLinkNameAccessWrapper::hasByName(const OUString& rName) 3806 throw( RuntimeException ) 3807 { 3808 sal_Bool bRet = sal_False; 3809 String sParam(rName); 3810 if(sParam.Len() > sLinkSuffix.Len() ) 3811 { 3812 String sCmp = sParam.Copy(sParam.Len() - sLinkSuffix.Len(), 3813 sLinkSuffix.Len()); 3814 if(sCmp == sLinkSuffix) 3815 { 3816 sParam = sParam.Copy(0, sParam.Len() - sLinkSuffix.Len()); 3817 if(pxDoc) 3818 { 3819 if(!pxDoc->GetDocShell()) 3820 throw RuntimeException(); 3821 SwDoc* pDoc = pxDoc->GetDocShell()->GetDoc(); 3822 sal_uInt16 nOutlineCount = pDoc->GetNodes().GetOutLineNds().Count(); 3823 3824 for (sal_uInt16 i = 0; i < nOutlineCount && !bRet; ++i) 3825 { 3826 const SwOutlineNodes& rOutlineNodes = pDoc->GetNodes().GetOutLineNds(); 3827 const SwNumRule* pOutlRule = pDoc->GetOutlineNumRule(); 3828 if(sParam == 3829 lcl_CreateOutlineString(i, rOutlineNodes, pOutlRule)) 3830 { 3831 bRet = sal_True; 3832 } 3833 } 3834 } 3835 else 3836 { 3837 bRet = xRealAccess->hasByName(sParam); 3838 } 3839 } 3840 } 3841 return bRet; 3842 } 3843 /*-- 26.10.99 09:16:25--------------------------------------------------- 3844 3845 -----------------------------------------------------------------------*/ 3846 uno::Type SwXLinkNameAccessWrapper::getElementType(void) 3847 throw( RuntimeException ) 3848 { 3849 return ::getCppuType((Reference<XPropertySet>*)0); 3850 } 3851 /*-- 26.10.99 09:16:25--------------------------------------------------- 3852 3853 -----------------------------------------------------------------------*/ 3854 sal_Bool SwXLinkNameAccessWrapper::hasElements(void) throw( RuntimeException ) 3855 { 3856 sal_Bool bRet = sal_False; 3857 if(pxDoc) 3858 { 3859 DBG_ERROR("not implemented"); 3860 } 3861 else 3862 { 3863 bRet = xRealAccess->hasElements(); 3864 } 3865 return bRet; 3866 } 3867 /*-- 26.10.99 09:16:26--------------------------------------------------- 3868 3869 -----------------------------------------------------------------------*/ 3870 Reference< XPropertySetInfo > SwXLinkNameAccessWrapper::getPropertySetInfo(void) 3871 throw( RuntimeException ) 3872 { 3873 static Reference< XPropertySetInfo > xRet = pPropSet->getPropertySetInfo(); 3874 return xRet; 3875 } 3876 /*-- 26.10.99 09:16:26--------------------------------------------------- 3877 3878 -----------------------------------------------------------------------*/ 3879 void SwXLinkNameAccessWrapper::setPropertyValue( 3880 const OUString& , const Any& ) 3881 throw( UnknownPropertyException, 3882 PropertyVetoException, 3883 IllegalArgumentException, 3884 WrappedTargetException, 3885 RuntimeException) 3886 { 3887 throw UnknownPropertyException(); 3888 } 3889 /* -----------------------------08.12.99 11:10-------------------------------- 3890 3891 ---------------------------------------------------------------------------*/ 3892 Any lcl_GetDisplayBitmap(String sLinkSuffix) 3893 { 3894 Any aRet; 3895 if(sLinkSuffix.Len()) 3896 sLinkSuffix.Erase(0, 1); 3897 sal_uInt16 nImgId = USHRT_MAX; 3898 3899 if(COMPARE_EQUAL == sLinkSuffix.CompareToAscii(pMarkToOutline)) 3900 nImgId = CONTENT_TYPE_OUTLINE; 3901 else if(COMPARE_EQUAL == sLinkSuffix.CompareToAscii(pMarkToTable)) 3902 nImgId = CONTENT_TYPE_TABLE; 3903 else if(COMPARE_EQUAL == sLinkSuffix.CompareToAscii(pMarkToFrame)) 3904 nImgId = CONTENT_TYPE_FRAME; 3905 else if(COMPARE_EQUAL == sLinkSuffix.CompareToAscii(pMarkToGraphic)) 3906 nImgId = CONTENT_TYPE_GRAPHIC; 3907 // else if(== sLinkSuffix) 3908 // nImgId = CONTENT_TYPE_BOOKMARK; 3909 else if(COMPARE_EQUAL == sLinkSuffix.CompareToAscii(pMarkToRegion)) 3910 nImgId = CONTENT_TYPE_REGION; 3911 else if(COMPARE_EQUAL == sLinkSuffix.CompareToAscii(pMarkToOLE)) 3912 nImgId = CONTENT_TYPE_OLE; 3913 else if(!sLinkSuffix.Len()) 3914 nImgId = CONTENT_TYPE_BOOKMARK; 3915 if(USHRT_MAX != nImgId) 3916 { 3917 nImgId += 20000; 3918 sal_Bool bHighContrast = Application::GetSettings().GetStyleSettings().GetHighContrastMode(); 3919 ImageList aEntryImages( SW_RES(bHighContrast ? IMG_NAVI_ENTRYBMPH : IMG_NAVI_ENTRYBMP) ); 3920 const Image& rImage = aEntryImages.GetImage( nImgId ); 3921 Bitmap aBitmap( rImage.GetBitmapEx().GetBitmap() ); 3922 Reference<awt::XBitmap> xBmp = VCLUnoHelper::CreateBitmap( aBitmap ); 3923 aRet.setValue( &xBmp, ::getCppuType((Reference<awt::XBitmap>*)0) ); 3924 } 3925 return aRet; 3926 } 3927 /*-- 26.10.99 09:16:27--------------------------------------------------- 3928 3929 -----------------------------------------------------------------------*/ 3930 Any SwXLinkNameAccessWrapper::getPropertyValue(const OUString& rPropertyName) 3931 throw( UnknownPropertyException, WrappedTargetException, RuntimeException ) 3932 { 3933 Any aRet; 3934 if( rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_LINK_DISPLAY_NAME))) 3935 { 3936 aRet <<= OUString(sLinkDisplayName); 3937 } 3938 else if( rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_LINK_DISPLAY_BITMAP))) 3939 { 3940 aRet = lcl_GetDisplayBitmap(sLinkSuffix); 3941 } 3942 else 3943 throw UnknownPropertyException(); 3944 return aRet; 3945 } 3946 /*-- 26.10.99 09:16:27--------------------------------------------------- 3947 3948 -----------------------------------------------------------------------*/ 3949 void SwXLinkNameAccessWrapper::addPropertyChangeListener( 3950 const OUString& /*PropertyName*/, const Reference< XPropertyChangeListener > & /*aListener*/) 3951 throw( UnknownPropertyException, WrappedTargetException, RuntimeException ) 3952 {} 3953 /*-- 26.10.99 09:16:28--------------------------------------------------- 3954 3955 -----------------------------------------------------------------------*/ 3956 void SwXLinkNameAccessWrapper::removePropertyChangeListener( 3957 const OUString& /*PropertyName*/, const Reference< XPropertyChangeListener > & /*aListener*/) 3958 throw( UnknownPropertyException, WrappedTargetException, RuntimeException ) 3959 {} 3960 /*-- 26.10.99 09:16:28--------------------------------------------------- 3961 3962 -----------------------------------------------------------------------*/ 3963 void SwXLinkNameAccessWrapper::addVetoableChangeListener( 3964 const OUString& /*PropertyName*/, const Reference< XVetoableChangeListener > & /*aListener*/) 3965 throw( UnknownPropertyException, WrappedTargetException, RuntimeException ) 3966 {} 3967 /*-- 26.10.99 09:16:29--------------------------------------------------- 3968 3969 -----------------------------------------------------------------------*/ 3970 void SwXLinkNameAccessWrapper::removeVetoableChangeListener( 3971 const OUString& /*PropertyName*/, const Reference< XVetoableChangeListener > & /*aListener*/) 3972 throw( UnknownPropertyException, WrappedTargetException, RuntimeException ) 3973 {} 3974 /*-- 26.10.99 09:16:32--------------------------------------------------- 3975 3976 3977 -----------------------------------------------------------------------*/ 3978 Reference< XNameAccess > SwXLinkNameAccessWrapper::getLinks(void) 3979 throw( RuntimeException ) 3980 { 3981 return (SwXLinkNameAccessWrapper*)this; 3982 } 3983 3984 /*-- 26.10.99 09:21:48--------------------------------------------------- 3985 3986 -----------------------------------------------------------------------*/ 3987 OUString SwXLinkNameAccessWrapper::getImplementationName(void) throw( RuntimeException ) 3988 { 3989 return C2U("SwXLinkNameAccessWrapper"); 3990 } 3991 /*-- 26.10.99 09:21:48--------------------------------------------------- 3992 3993 -----------------------------------------------------------------------*/ 3994 sal_Bool SwXLinkNameAccessWrapper::supportsService(const OUString& rServiceName) 3995 throw( RuntimeException ) 3996 { 3997 return (rServiceName == C2U("com.sun.star.document.LinkTargets")); 3998 } 3999 /*-- 26.10.99 09:21:48--------------------------------------------------- 4000 4001 -----------------------------------------------------------------------*/ 4002 Sequence< OUString > SwXLinkNameAccessWrapper::getSupportedServiceNames(void) 4003 throw( RuntimeException ) 4004 { 4005 Sequence< OUString > aRet(1); 4006 OUString* pNames = aRet.getArray(); 4007 pNames[0] = C2U("com.sun.star.document.LinkTargets"); 4008 return aRet; 4009 } 4010 /* -----------------26.10.99 15:50------------------- 4011 4012 --------------------------------------------------*/ 4013 SwXOutlineTarget::SwXOutlineTarget(const String& rOutlineText) : 4014 pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_LINK_TARGET)), 4015 sOutlineText(rOutlineText) 4016 { 4017 } 4018 /*-- 26.10.99 15:51:45--------------------------------------------------- 4019 4020 -----------------------------------------------------------------------*/ 4021 SwXOutlineTarget::~SwXOutlineTarget() 4022 { 4023 } 4024 /*-- 26.10.99 15:51:46--------------------------------------------------- 4025 4026 -----------------------------------------------------------------------*/ 4027 Reference< XPropertySetInfo > SwXOutlineTarget::getPropertySetInfo(void) throw( RuntimeException ) 4028 { 4029 static Reference< XPropertySetInfo > xRet = pPropSet->getPropertySetInfo(); 4030 return xRet; 4031 } 4032 /*-- 26.10.99 15:51:46--------------------------------------------------- 4033 4034 -----------------------------------------------------------------------*/ 4035 void SwXOutlineTarget::setPropertyValue( 4036 const OUString& /*PropertyName*/, const Any& /*aValue*/) 4037 throw( UnknownPropertyException, PropertyVetoException, 4038 IllegalArgumentException, WrappedTargetException, RuntimeException) 4039 { 4040 throw UnknownPropertyException(); 4041 } 4042 /*-- 26.10.99 15:51:46--------------------------------------------------- 4043 4044 -----------------------------------------------------------------------*/ 4045 Any SwXOutlineTarget::getPropertyValue(const OUString& rPropertyName) 4046 throw( UnknownPropertyException, WrappedTargetException, RuntimeException ) 4047 { 4048 Any aRet; 4049 if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_LINK_DISPLAY_NAME))) 4050 aRet <<= OUString(sOutlineText); 4051 else 4052 throw UnknownPropertyException(); 4053 return aRet; 4054 } 4055 /*-- 26.10.99 15:51:46--------------------------------------------------- 4056 4057 -----------------------------------------------------------------------*/ 4058 void SwXOutlineTarget::addPropertyChangeListener( 4059 const OUString& /*PropertyName*/, const Reference< XPropertyChangeListener > & /*aListener*/) 4060 throw( UnknownPropertyException, WrappedTargetException, RuntimeException ) 4061 { 4062 } 4063 /*-- 26.10.99 15:51:47--------------------------------------------------- 4064 4065 -----------------------------------------------------------------------*/ 4066 void SwXOutlineTarget::removePropertyChangeListener( 4067 const OUString& /*PropertyName*/, const Reference< XPropertyChangeListener > & /*aListener*/) 4068 throw( UnknownPropertyException, WrappedTargetException, RuntimeException ) 4069 { 4070 } 4071 /*-- 26.10.99 15:51:47--------------------------------------------------- 4072 4073 -----------------------------------------------------------------------*/ 4074 void SwXOutlineTarget::addVetoableChangeListener( 4075 const OUString& /*PropertyName*/, const Reference< XVetoableChangeListener > & /*aListener*/) 4076 throw( UnknownPropertyException, WrappedTargetException, RuntimeException ) 4077 { 4078 } 4079 /*-- 26.10.99 15:51:47--------------------------------------------------- 4080 4081 -----------------------------------------------------------------------*/ 4082 void SwXOutlineTarget::removeVetoableChangeListener( 4083 const OUString& /*PropertyName*/, const Reference< XVetoableChangeListener > & /*aListener*/) 4084 throw( UnknownPropertyException, WrappedTargetException, RuntimeException ) 4085 { 4086 } 4087 /* -----------------03.05.99 12:28------------------- 4088 * 4089 * --------------------------------------------------*/ 4090 OUString SwXOutlineTarget::getImplementationName(void) throw( RuntimeException ) 4091 { 4092 return C2U("SwXOutlineTarget"); 4093 } 4094 /* -----------------03.05.99 12:28------------------- 4095 * 4096 * --------------------------------------------------*/ 4097 sal_Bool SwXOutlineTarget::supportsService(const OUString& ServiceName) throw( RuntimeException ) 4098 { 4099 return C2U("com.sun.star.document.LinkTarget") == ServiceName; 4100 } 4101 /* -----------------03.05.99 12:28------------------- 4102 * 4103 * --------------------------------------------------*/ 4104 Sequence< OUString > SwXOutlineTarget::getSupportedServiceNames(void) throw( RuntimeException ) 4105 { 4106 Sequence < OUString > aRet(1); 4107 OUString* pArray = aRet.getArray(); 4108 pArray[0] = C2U("com.sun.star.document.LinkTarget"); 4109 4110 return aRet; 4111 } 4112 /* -----------------------------17.01.01 16:06-------------------------------- 4113 4114 ---------------------------------------------------------------------------*/ 4115 SwXDocumentPropertyHelper::SwXDocumentPropertyHelper(SwDoc& rDoc) : 4116 SvxUnoForbiddenCharsTable ( rDoc.getForbiddenCharacterTable() ) 4117 ,m_pDoc(&rDoc) 4118 { 4119 } 4120 /* -----------------------------17.01.01 16:06-------------------------------- 4121 4122 ---------------------------------------------------------------------------*/ 4123 SwXDocumentPropertyHelper::~SwXDocumentPropertyHelper() 4124 { 4125 } 4126 /* -----------------------------17.01.01 16:06-------------------------------- 4127 4128 ---------------------------------------------------------------------------*/ 4129 Reference<XInterface> SwXDocumentPropertyHelper::GetDrawTable(short nWhich) 4130 { 4131 Reference<XInterface> xRet; 4132 if(m_pDoc) 4133 { 4134 switch(nWhich) 4135 { 4136 // --> OD 2005-08-08 #i52858# 4137 // assure that Draw model is created, if it doesn't exist. 4138 case SW_CREATE_DASH_TABLE : 4139 if(!xDashTable.is()) 4140 xDashTable = SvxUnoDashTable_createInstance( m_pDoc->GetOrCreateDrawModel() ); 4141 xRet = xDashTable; 4142 break; 4143 case SW_CREATE_GRADIENT_TABLE : 4144 if(!xGradientTable.is()) 4145 xGradientTable = SvxUnoGradientTable_createInstance( m_pDoc->GetOrCreateDrawModel() ); 4146 xRet = xGradientTable; 4147 break; 4148 case SW_CREATE_HATCH_TABLE : 4149 if(!xHatchTable.is()) 4150 xHatchTable = SvxUnoHatchTable_createInstance( m_pDoc->GetOrCreateDrawModel() ); 4151 xRet = xHatchTable; 4152 break; 4153 case SW_CREATE_BITMAP_TABLE : 4154 if(!xBitmapTable.is()) 4155 xBitmapTable = SvxUnoBitmapTable_createInstance( m_pDoc->GetOrCreateDrawModel() ); 4156 xRet = xBitmapTable; 4157 break; 4158 case SW_CREATE_TRANSGRADIENT_TABLE: 4159 if(!xTransGradientTable.is()) 4160 xTransGradientTable = SvxUnoTransGradientTable_createInstance( m_pDoc->GetOrCreateDrawModel() ); 4161 xRet = xTransGradientTable; 4162 break; 4163 case SW_CREATE_MARKER_TABLE : 4164 if(!xMarkerTable.is()) 4165 xMarkerTable = SvxUnoMarkerTable_createInstance( m_pDoc->GetOrCreateDrawModel() ); 4166 xRet = xMarkerTable; 4167 break; 4168 // <-- 4169 case SW_CREATE_DRAW_DEFAULTS: 4170 if(!xDrawDefaults.is()) 4171 xDrawDefaults = (cppu::OWeakObject*)new SwSvxUnoDrawPool(m_pDoc); 4172 xRet = xDrawDefaults; 4173 break; 4174 #ifdef DBG_UTIL 4175 default: DBG_ERROR("which table?"); 4176 #endif 4177 } 4178 } 4179 return xRet; 4180 } 4181 4182 void SwXDocumentPropertyHelper::Invalidate() 4183 { 4184 xDashTable = 0; 4185 xGradientTable = 0; 4186 xHatchTable = 0; 4187 xBitmapTable = 0; 4188 xTransGradientTable = 0; 4189 xMarkerTable = 0; 4190 xDrawDefaults = 0; 4191 m_pDoc = 0; 4192 SvxUnoForbiddenCharsTable::mxForbiddenChars.unbind(); 4193 } 4194 /* -----------------13.08.2003 12:43----------------- 4195 4196 --------------------------------------------------*/ 4197 void SwXDocumentPropertyHelper::onChange() 4198 { 4199 if(m_pDoc) 4200 m_pDoc->SetModified(); 4201 } 4202 4203 4204 /*****************************************************************************/ 4205 4206 SwViewOptionAdjust_Impl::SwViewOptionAdjust_Impl( ViewShell& rSh, const SwViewOption &rViewOptions ) : 4207 m_rShell( rSh ), 4208 m_aOldViewOptions( rViewOptions ) 4209 { 4210 } 4211 4212 4213 SwViewOptionAdjust_Impl::~SwViewOptionAdjust_Impl() 4214 { 4215 m_rShell.ApplyViewOptions( m_aOldViewOptions ); 4216 } 4217 4218 4219 void 4220 SwViewOptionAdjust_Impl::AdjustViewOptions(SwPrintData const*const pPrtOptions) 4221 { 4222 // to avoid unnecessary reformatting the view options related to the content 4223 // below should only change if necessary, that is if respective content is present 4224 const bool bContainsHiddenChars = m_rShell.GetDoc()->ContainsHiddenChars(); 4225 const SwFieldType* pFldType = m_rShell.GetDoc()->GetSysFldType( RES_HIDDENTXTFLD ); 4226 const bool bContainsHiddenFields = pFldType && pFldType->GetDepends(); 4227 pFldType = m_rShell.GetDoc()->GetSysFldType( RES_HIDDENPARAFLD ); 4228 const bool bContainsHiddenParagraphs = pFldType && pFldType->GetDepends(); 4229 pFldType = m_rShell.GetDoc()->GetSysFldType( RES_JUMPEDITFLD ); 4230 const bool bContainsPlaceHolders = pFldType && pFldType->GetDepends(); 4231 const bool bContainsFields = m_rShell.IsAnyFieldInDoc(); 4232 4233 SwViewOption aRenderViewOptions( m_aOldViewOptions ); 4234 4235 // disable anything in the view that should not be printed (or exported to PDF) by default 4236 // (see also dialog "Tools/Options - StarOffice Writer - Formatting Aids" 4237 // in section "Display of ...") 4238 aRenderViewOptions.SetParagraph( sal_False ); // paragraph end 4239 aRenderViewOptions.SetSoftHyph( sal_False ); // aka custom hyphens 4240 aRenderViewOptions.SetBlank( sal_False ); // spaces 4241 aRenderViewOptions.SetHardBlank( sal_False ); // non-breaking spaces 4242 aRenderViewOptions.SetTab( sal_False ); // tabs 4243 aRenderViewOptions.SetLineBreak( sal_False ); // breaks (type 1) 4244 aRenderViewOptions.SetPageBreak( sal_False ); // breaks (type 2) 4245 aRenderViewOptions.SetColumnBreak( sal_False ); // breaks (type 3) 4246 sal_Bool bVal = pPrtOptions? pPrtOptions->bPrintHiddenText : sal_False; 4247 if (bContainsHiddenChars) 4248 aRenderViewOptions.SetShowHiddenChar( bVal ); // hidden text 4249 if (bContainsHiddenFields) 4250 aRenderViewOptions.SetShowHiddenField( bVal ); 4251 if (bContainsHiddenParagraphs) 4252 aRenderViewOptions.SetShowHiddenPara( bVal ); 4253 4254 if (bContainsPlaceHolders) 4255 { 4256 // should always be printed in PDF export! 4257 bVal = pPrtOptions ? pPrtOptions->bPrintTextPlaceholder : sal_True; 4258 aRenderViewOptions.SetShowPlaceHolderFields( bVal ); 4259 } 4260 4261 if (bContainsFields) 4262 aRenderViewOptions.SetFldName( sal_False ); 4263 4264 // we need to set this flag in order to get to see the visible effect of 4265 // some of the above settings (needed for correct rendering) 4266 aRenderViewOptions.SetViewMetaChars( sal_True ); 4267 4268 if (m_aOldViewOptions != aRenderViewOptions) // check if reformatting is necessary 4269 { 4270 aRenderViewOptions.SetPrinting( pPrtOptions != NULL ); 4271 m_rShell.ApplyViewOptions( aRenderViewOptions ); 4272 } 4273 } 4274 4275 4276 /*****************************************************************************/ 4277 4278 4279