diff options
author | Thomas Lange [tl] <tl@openoffice.org> | 2010-11-26 10:52:38 +0100 |
---|---|---|
committer | Thomas Lange [tl] <tl@openoffice.org> | 2010-11-26 10:52:38 +0100 |
commit | ae258d52e5cd263d8c3bab7cd99fff6b01d66282 (patch) | |
tree | fddd61f51a11a2d40fb0c8bd5f2a9cbc9352b2fa | |
parent | c14698e486fd63529c9d363b5103a9a9c10baec2 (diff) |
cws tl84: #i115373# getPrintData refactoring
-rwxr-xr-x | sw/inc/IDocumentDeviceAccess.hxx | 2 | ||||
-rw-r--r-- | sw/inc/doc.hxx | 2 | ||||
-rw-r--r-- | sw/inc/prtopt.hxx (renamed from sw/source/ui/inc/prtopt.hxx) | 0 | ||||
-rw-r--r-- | sw/source/core/doc/doc.cxx | 22 | ||||
-rw-r--r-- | sw/source/core/view/pagepreviewlayout.cxx | 3 | ||||
-rw-r--r-- | sw/source/ui/app/appopt.cxx | 4 | ||||
-rw-r--r-- | sw/source/ui/envelp/mailmrge.cxx | 5 | ||||
-rw-r--r-- | sw/source/ui/uiview/viewprt.cxx | 6 | ||||
-rw-r--r-- | sw/source/ui/uno/SwXDocumentSettings.cxx | 6 | ||||
-rw-r--r-- | sw/source/ui/uno/unomailmerge.cxx | 5 | ||||
-rw-r--r-- | sw/source/ui/uno/unomod.cxx | 16 | ||||
-rw-r--r-- | sw/source/ui/uno/unotxdoc.cxx | 52 |
12 files changed, 51 insertions, 72 deletions
diff --git a/sw/inc/IDocumentDeviceAccess.hxx b/sw/inc/IDocumentDeviceAccess.hxx index 55e8ecfda5..9f3760dcce 100755 --- a/sw/inc/IDocumentDeviceAccess.hxx +++ b/sw/inc/IDocumentDeviceAccess.hxx @@ -129,7 +129,7 @@ @returns the current PrintData */ - virtual SwPrintData* getPrintData() const = 0; + virtual const SwPrintData & getPrintData() const = 0; /** Sets the PrintData diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index fdfd07dfe5..385f858d84 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -770,7 +770,7 @@ public: virtual void setReferenceDeviceType(/*[in]*/ bool bNewVirtual,/*[in]*/ bool bNewHiRes ); virtual const JobSetup* getJobsetup() const; virtual void setJobsetup(/*[in]*/ const JobSetup& rJobSetup ); - virtual SwPrintData* getPrintData() const; + virtual const SwPrintData & getPrintData() const; virtual void setPrintData(/*[in]*/ const SwPrintData& rPrtData); /** IDocumentMarkAccess diff --git a/sw/source/ui/inc/prtopt.hxx b/sw/inc/prtopt.hxx index c46e93a138..c46e93a138 100644 --- a/sw/source/ui/inc/prtopt.hxx +++ b/sw/inc/prtopt.hxx diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index 00f4b9e446..27186cd9a8 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -112,15 +112,15 @@ #include <viewsh.hxx> #include <shellres.hxx> #include <txtfrm.hxx> +#include <wdocsh.hxx> // SwWebDocShell +#include <prtopt.hxx> // SwPrintOptions #include <vector> #include <map> #include <osl/diagnose.h> #include <osl/interlck.h> -#ifdef FUTURE_VBA #include <vbahelper/vbaaccesshelper.hxx> -#endif /* @@@MAINTAINABILITY-HORROR@@@ Probably unwanted dependency on SwDocShell @@ -628,11 +628,23 @@ void SwDoc::setJobsetup(/*[in]*/ const JobSetup &rJobSetup ) PrtDataChanged(); } -SwPrintData* SwDoc::getPrintData() const +const SwPrintData & SwDoc::getPrintData() const { if(!pPrtData) - ((SwDoc*)this)->pPrtData = new SwPrintData; - return pPrtData; + { + SwPrintData *pThisPrtData = const_cast< SwDoc * >(this)->pPrtData; + pThisPrtData = new SwPrintData; + + // SwPrintData should be initialized from the configuration, + // the respective config item is implememted by SwPrintOptions which + // is also derived from SwPrintData + const SwDocShell *pDocSh = GetDocShell(); + DBG_ASSERT( pDocSh, "pDocSh is 0, can't determine if this is a WebDoc or not" ); + bool bWeb = 0 != dynamic_cast< const SwWebDocShell * >(pDocSh); + SwPrintOptions aPrintOptions( bWeb ); + *pThisPrtData = aPrintOptions; + } + return *pPrtData; } void SwDoc::setPrintData(/*[in]*/ const SwPrintData& rPrtData ) diff --git a/sw/source/core/view/pagepreviewlayout.cxx b/sw/source/core/view/pagepreviewlayout.cxx index 2ad35fadaa..51057d0987 100644 --- a/sw/source/core/view/pagepreviewlayout.cxx +++ b/sw/source/core/view/pagepreviewlayout.cxx @@ -71,8 +71,7 @@ SwPagePreviewLayout::SwPagePreviewLayout( ViewShell& _rParentViewShell, mbBookPreview = false; mbBookPreviewModeToggled = false; - const SwPrintData* pPrintData = mrParentViewShell.getIDocumentDeviceAccess()->getPrintData(); - mbPrintEmptyPages = pPrintData ? pPrintData->IsPrintEmptyPages() : true; + mbPrintEmptyPages = mrParentViewShell.getIDocumentDeviceAccess()->getPrintData().IsPrintEmptyPages(); } void SwPagePreviewLayout::_Clear() diff --git a/sw/source/ui/app/appopt.cxx b/sw/source/ui/app/appopt.cxx index a248ac8aff..c16a59d9a3 100644 --- a/sw/source/ui/app/appopt.cxx +++ b/sw/source/ui/app/appopt.cxx @@ -264,8 +264,8 @@ SfxItemSet* SwModule::CreateItemSet( USHORT nId ) /*-----------------01.02.97 13.02------------------- Optionen fuer PrintTabPage --------------------------------------------------*/ - SwPrintData* pOpt = pAppView ? - pAppView->GetWrtShell().getIDocumentDeviceAccess()->getPrintData() : + const SwPrintData* pOpt = pAppView ? + &pAppView->GetWrtShell().getIDocumentDeviceAccess()->getPrintData() : 0; if(!pOpt) diff --git a/sw/source/ui/envelp/mailmrge.cxx b/sw/source/ui/envelp/mailmrge.cxx index 76595d5543..21c1e16f99 100644 --- a/sw/source/ui/envelp/mailmrge.cxx +++ b/sw/source/ui/envelp/mailmrge.cxx @@ -804,11 +804,8 @@ bool SwMailMergeDlg::ExecQryShell() } } } - SwPrintData aPrtData = *SW_MOD()->GetPrtOptions(FALSE); IDocumentDeviceAccess* pIDDA = rSh.getIDocumentDeviceAccess(); - SwPrintData* pShellPrintData = pIDDA->getPrintData(); - if(pShellPrintData) - aPrtData = *pShellPrintData; + SwPrintData aPrtData( pIDDA->getPrintData() ); aPrtData.SetPrintSingleJobs(aSingleJobsCB.IsChecked()); pIDDA->setPrintData(aPrtData); diff --git a/sw/source/ui/uiview/viewprt.cxx b/sw/source/ui/uiview/viewprt.cxx index 45e9272250..d9f74ddaed 100644 --- a/sw/source/ui/uiview/viewprt.cxx +++ b/sw/source/ui/uiview/viewprt.cxx @@ -338,12 +338,8 @@ SfxTabPage* CreatePrintOptionsPage( Window *pParent, void SetAppPrintOptions( ViewShell* pSh, BOOL bWeb ) { - SwPrintData aPrtData = *SW_MOD()->GetPrtOptions(bWeb); const IDocumentDeviceAccess* pIDDA = pSh->getIDocumentDeviceAccess(); - SwPrintData* pShellPrintData = pIDDA->getPrintData(); - - if(pShellPrintData) - aPrtData = *pShellPrintData; + SwPrintData aPrtData = pIDDA->getPrintData(); if( pIDDA->getPrinter( false ) ) { diff --git a/sw/source/ui/uno/SwXDocumentSettings.cxx b/sw/source/ui/uno/SwXDocumentSettings.cxx index 36b7d7afd6..f86250b536 100644 --- a/sw/source/ui/uno/SwXDocumentSettings.cxx +++ b/sw/source/ui/uno/SwXDocumentSettings.cxx @@ -700,11 +700,7 @@ void SwXDocumentSettings::_postSetValues () // #i86352# the printer is also used as container for options by sfx // when setting a printer it should have decent default options SfxItemSet aOptions( mpPrinter->GetOptions() ); - SwPrintData aPrtData; - if( mpDoc->getPrintData() ) - aPrtData = *mpDoc->getPrintData(); - else - aPrtData = *SW_MOD()->GetPrtOptions(false); + SwPrintData aPrtData( mpDoc->getPrintData() ); SwAddPrinterItem aAddPrinterItem (FN_PARAM_ADDPRINTER, aPrtData); aOptions.Put(aAddPrinterItem); mpPrinter->SetOptions( aOptions ); diff --git a/sw/source/ui/uno/unomailmerge.cxx b/sw/source/ui/uno/unomailmerge.cxx index 08c720d0b3..59c3f68c30 100644 --- a/sw/source/ui/uno/unomailmerge.cxx +++ b/sw/source/ui/uno/unomailmerge.cxx @@ -711,11 +711,8 @@ uno::Any SAL_CALL SwXMailMerge::execute( uno::Reference< mail::XMailService > xInService; if (MailMergeType::PRINTER == nCurOutputType) { - SwPrintData aPrtData = *SW_MOD()->GetPrtOptions( FALSE ); IDocumentDeviceAccess* pIDDA = rSh.getIDocumentDeviceAccess(); - SwPrintData* pShellPrintData = pIDDA->getPrintData(); - if (pShellPrintData) - aPrtData = *pShellPrintData; + SwPrintData aPrtData( pIDDA->getPrintData() ); aPrtData.SetPrintSingleJobs( bCurSinglePrintJobs ); pIDDA->setPrintData( aPrtData ); // #i25686# printing should not be done asynchronously to prevent dangling offices diff --git a/sw/source/ui/uno/unomod.cxx b/sw/source/ui/uno/unomod.cxx index f5da10cb6f..ffd11f0bf9 100644 --- a/sw/source/ui/uno/unomod.cxx +++ b/sw/source/ui/uno/unomod.cxx @@ -340,13 +340,7 @@ void SwXPrintSettings::_preSetValues () { if (!mpDoc) throw IllegalArgumentException (); - if ( !mpDoc->getPrintData() ) - { - mpPrtOpt = new SwPrintData; - mpDoc->setPrintData ( *mpPrtOpt ); - delete mpPrtOpt; - } - mpPrtOpt = mpDoc->getPrintData(); + mpPrtOpt = const_cast< SwPrintData * >(&mpDoc->getPrintData()); } break; } @@ -502,13 +496,7 @@ void SwXPrintSettings::_preGetValues () { if (!mpDoc) throw IllegalArgumentException (); - if ( !mpDoc->getPrintData() ) - { - mpPrtOpt = new SwPrintData; - mpDoc->setPrintData ( *mpPrtOpt ); - delete mpPrtOpt; - } - mpPrtOpt = mpDoc->getPrintData(); + mpPrtOpt = const_cast< SwPrintData * >(&mpDoc->getPrintData()); } break; } diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index 7752e74d28..d99a818443 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -198,10 +198,9 @@ SwPrintUIOptions * lcl_GetPrintUIOptions( const bool bHasPostIts = lcl_GetPostIts( pDocShell->GetDoc(), 0 ); // get default values to use in dialog from documents SwPrintData - const SwPrintData *pPrintData = pDocShell->GetDoc()->getPrintData(); - DBG_ASSERT( pPrintData, "failed to get SwPrintData from document" ); + const SwPrintData &rPrintData = pDocShell->GetDoc()->getPrintData(); - return new SwPrintUIOptions( bWebDoc, bSwSrcView, bHasSelection, bHasPostIts, *pPrintData ); + return new SwPrintUIOptions( bWebDoc, bSwSrcView, bHasSelection, bHasPostIts, rPrintData ); } //////////////////////////////////////////////////////////// @@ -2616,33 +2615,28 @@ static void lcl_SavePrintUIOptionsToDocumentPrintData( const SwPrintUIOptions &rPrintUIOptions, bool bIsPDFEXport ) { - if (!rDoc.getPrintData()) - { - SwPrintData *pTmpData = new SwPrintData; - rDoc.setPrintData ( *pTmpData ); - delete pTmpData; // setPrintData does make its own copy! - } - - SwPrintData *pDocPrintData = rDoc.getPrintData(); + SwPrintData aDocPrintData( rDoc.getPrintData() ); - pDocPrintData->SetPrintGraphic( rPrintUIOptions.IsPrintGraphics() ); - pDocPrintData->SetPrintTable( rPrintUIOptions.IsPrintTables() ); - pDocPrintData->SetPrintDraw( rPrintUIOptions.IsPrintDrawings() ); - pDocPrintData->SetPrintControl( rPrintUIOptions.IsPrintFormControls() ); - pDocPrintData->SetPrintLeftPage( rPrintUIOptions.IsPrintLeftPages() ); - pDocPrintData->SetPrintRightPage( rPrintUIOptions.IsPrintRightPages() ); - pDocPrintData->SetPrintReverse( rPrintUIOptions.IsPrintReverse() ); - pDocPrintData->SetPaperFromSetup( rPrintUIOptions.IsPaperFromSetup() ); - pDocPrintData->SetPrintEmptyPages( rPrintUIOptions.IsPrintEmptyPages( bIsPDFEXport ) ); - pDocPrintData->SetPrintPostIts( rPrintUIOptions.GetPrintPostItsType() ); - pDocPrintData->SetPrintProspect( rPrintUIOptions.IsPrintProspect() ); - pDocPrintData->SetPrintProspect_RTL( rPrintUIOptions.IsPrintProspectRTL() ); - pDocPrintData->SetPrintPageBackground( rPrintUIOptions.IsPrintPageBackground() ); - pDocPrintData->SetPrintBlackFont( rPrintUIOptions.IsPrintWithBlackTextColor() ); - // pDocPrintData->SetPrintSingleJobs( b ); handled by File/Print dialog itself - // pDocPrintData->SetFaxName( s ); n/a in File/Print dialog - pDocPrintData->SetPrintHiddenText( rPrintUIOptions.IsPrintHiddenText() ); - pDocPrintData->SetPrintTextPlaceholder( rPrintUIOptions.IsPrintTextPlaceholders() ); + aDocPrintData.SetPrintGraphic( rPrintUIOptions.IsPrintGraphics() ); + aDocPrintData.SetPrintTable( rPrintUIOptions.IsPrintTables() ); + aDocPrintData.SetPrintDraw( rPrintUIOptions.IsPrintDrawings() ); + aDocPrintData.SetPrintControl( rPrintUIOptions.IsPrintFormControls() ); + aDocPrintData.SetPrintLeftPage( rPrintUIOptions.IsPrintLeftPages() ); + aDocPrintData.SetPrintRightPage( rPrintUIOptions.IsPrintRightPages() ); + aDocPrintData.SetPrintReverse( rPrintUIOptions.IsPrintReverse() ); + aDocPrintData.SetPaperFromSetup( rPrintUIOptions.IsPaperFromSetup() ); + aDocPrintData.SetPrintEmptyPages( rPrintUIOptions.IsPrintEmptyPages( bIsPDFEXport ) ); + aDocPrintData.SetPrintPostIts( rPrintUIOptions.GetPrintPostItsType() ); + aDocPrintData.SetPrintProspect( rPrintUIOptions.IsPrintProspect() ); + aDocPrintData.SetPrintProspect_RTL( rPrintUIOptions.IsPrintProspectRTL() ); + aDocPrintData.SetPrintPageBackground( rPrintUIOptions.IsPrintPageBackground() ); + aDocPrintData.SetPrintBlackFont( rPrintUIOptions.IsPrintWithBlackTextColor() ); + // aDocPrintData.SetPrintSingleJobs( b ); handled by File/Print dialog itself + // arDocPrintData.SetFaxName( s ); n/a in File/Print dialog + aDocPrintData.SetPrintHiddenText( rPrintUIOptions.IsPrintHiddenText() ); + aDocPrintData.SetPrintTextPlaceholder( rPrintUIOptions.IsPrintTextPlaceholders() ); + + rDoc.setPrintData( aDocPrintData ); } |