From 313505000dd5252b55a106733df5eecb53c3a548 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Fri, 3 Apr 2009 14:47:31 +0000 Subject: #i92516# preparations for new print UI --- sw/inc/globals.hrc | 1 + sw/inc/unotxdoc.hxx | 3 + sw/source/ui/config/optdlg.src | 31 ++++++ sw/source/ui/uno/unotxdoc.cxx | 245 ++++++++++++++++++++++++++++++++++++++++- 4 files changed, 279 insertions(+), 1 deletion(-) (limited to 'sw') diff --git a/sw/inc/globals.hrc b/sw/inc/globals.hrc index 0dc7f4e06be0..390b243cde03 100644 --- a/sw/inc/globals.hrc +++ b/sw/inc/globals.hrc @@ -54,6 +54,7 @@ #define STR_DOC_STAT (RC_GLOBALS_BEGIN + 10) #define STR_PAGE (RC_GLOBALS_BEGIN + 14) +#define STR_PRINTOPTUI (RC_GLOBALS_BEGIN + 15) //EventStrings diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx index 7c0f8af1b072..a5d840c1ac2b 100644 --- a/sw/inc/unotxdoc.hxx +++ b/sw/inc/unotxdoc.hxx @@ -123,6 +123,7 @@ class SwXDrawPage; class SwUnoCrsr; class SwXDocumentPropertyHelper; class SfxViewFrame; +class SwPrintUIOptions; typedef UnoActionContext* UnoActionContextPtr; SV_DECL_PTRARR(ActionContextArr, UnoActionContextPtr, 4, 4) @@ -216,6 +217,8 @@ class SwXTextDocument : public SwXTextDocumentBaseClass, ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> xPropertyHelper; SwXDocumentPropertyHelper* pPropertyHelper; + SwPrintUIOptions* m_pPrintUIOptions; + void GetBodyText(); void GetNumberFormatter(); diff --git a/sw/source/ui/config/optdlg.src b/sw/source/ui/config/optdlg.src index 763e5e82d62e..343d4daa389a 100644 --- a/sw/source/ui/config/optdlg.src +++ b/sw/source/ui/config/optdlg.src @@ -935,3 +935,34 @@ TabPage TP_OPTSHDWCRSR }; }; + +StringArray STR_PRINTOPTUI +{ + ItemList [en-US] = + { + < "Contents"; >; + < "~Graphics"; >; + < "~Tables"; >; + < "Dra~wings"; >; + < "Control~s"; >; + < "Ba~ckground"; >; + < "Print blac~k"; >; + < "Hidden te~xt"; >; + < "Text ~placeholder"; >; + < "~Notes"; >; + < "None"; >; + < "Notes only"; >; + < " at end of document"; >; + < " at end of page"; >; + < "Page settings"; >; + < "~Left pages"; >; + < "~Right pages"; >; + < "Re~versed"; >; + < "Broch~ure"; >; + < "Right to Left"; >; + < "Other"; >; + < "Print ~automatically inserted blank pages"; >; + < "~Paper tray from printer settings"; >; + }; +}; + diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index 9479350620b3..a4dffcd966aa 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -79,6 +79,7 @@ #include #include #include +#include #include #include @@ -174,6 +175,232 @@ using ::osl::FileBase; /****************************************************************************** * ******************************************************************************/ + +class SwPrintUIOptions +{ + ResStringArray m_aLocalizedStrings; + + Any getUIControlOpt( const rtl::OUString& i_rTitle, + const rtl::OUString& i_rType, + const PropertyValue* i_pVal = NULL, + const Sequence< rtl::OUString >* i_pChoices = NULL, + const rtl::OUString* i_pDependsOnName = NULL, + sal_Int32 i_nDependsOnEntry = -1 + ); + + Any getUIControlOpt( const rtl::OUString& i_rTitle, + const rtl::OUString& i_rProperty, + sal_Bool i_bValue, + const rtl::OUString* i_pDependsOnName = NULL, + sal_Int32 i_nDependsOnEntry = -1 + ); + + Any getUIControlOpt( const rtl::OUString& i_rTitle, + const rtl::OUString& i_rType, + const rtl::OUString& i_rProperty, + const Sequence< rtl::OUString >& i_rChoices, + sal_Int32 i_nValue, + const rtl::OUString* i_pDependsOnName = NULL, + sal_Int32 i_nDependsOnEntry = -1 + ); +public: + SwPrintUIOptions(); + + void addPrintUIOptions( uno::Sequence< beans::PropertyValue >& io_rProps ); +}; + +SwPrintUIOptions::SwPrintUIOptions() +: m_aLocalizedStrings( SW_RES( STR_PRINTOPTUI ) ) +{ +} + +Any SwPrintUIOptions::getUIControlOpt( const rtl::OUString& i_rTitle, + const rtl::OUString& i_rType, + const PropertyValue* i_pVal, + const Sequence< rtl::OUString >* i_pChoices, + const rtl::OUString* i_pDependsOnName, + sal_Int32 i_nDependsOnEntry + ) +{ + Sequence< PropertyValue > aCtrl(6); + sal_Int32 nUsed = 0; + if( i_rTitle.getLength() ) + { + aCtrl[nUsed ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "Text" ) ); + aCtrl[nUsed++].Value = makeAny( i_rTitle ); + } + aCtrl[nUsed ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "ControlType" ) ); + aCtrl[nUsed++].Value = makeAny( i_rType ); + if( i_pVal ) + { + aCtrl[nUsed ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "Property" ) ); + aCtrl[nUsed++].Value = makeAny( *i_pVal ); + } + if( i_pChoices ) + { + aCtrl[nUsed ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "Choices" ) ); + aCtrl[nUsed++].Value = makeAny( *i_pChoices ); + } + if( i_pDependsOnName ) + { + aCtrl[nUsed ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "DependsOnName" ) ); + aCtrl[nUsed++].Value = makeAny( *i_pDependsOnName ); + if( i_nDependsOnEntry != -1 ) + { + aCtrl[nUsed ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "DependsOnEntry" ) ); + aCtrl[nUsed++].Value = makeAny( i_nDependsOnEntry ); + } + } + aCtrl.realloc( nUsed ); + return makeAny( aCtrl ); +} + +Any SwPrintUIOptions::getUIControlOpt( const rtl::OUString& i_rTitle, + const rtl::OUString& i_rProperty, + sal_Bool i_bValue, + const rtl::OUString* i_pDependsOnName, + sal_Int32 i_nDependsOnEntry ) +{ + PropertyValue aVal; + aVal.Name = i_rProperty; + aVal.Value = makeAny( i_bValue ); + return getUIControlOpt( i_rTitle, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Bool" ) ), &aVal, NULL, i_pDependsOnName, i_nDependsOnEntry ); +} + +Any SwPrintUIOptions::getUIControlOpt( const rtl::OUString& i_rTitle, + const rtl::OUString& i_rType, + const rtl::OUString& i_rProperty, + const Sequence< rtl::OUString >& i_rChoices, + sal_Int32 i_nValue, + const rtl::OUString* i_pDependsOnName, + sal_Int32 i_nDependsOnEntry ) +{ + PropertyValue aVal; + aVal.Name = i_rProperty; + aVal.Value = makeAny( i_nValue ); + return getUIControlOpt( i_rTitle, i_rType, &aVal, &i_rChoices, i_pDependsOnName, i_nDependsOnEntry ); +} + + +void SwPrintUIOptions::addPrintUIOptions( uno::Sequence< beans::PropertyValue >& io_rProps ) +{ + // create sequence of print UI options + uno::Sequence< beans::PropertyValue > aUIOptions( 19 ); + + DBG_ASSERT( m_aLocalizedStrings.Count() >= 23, "resource incomplete" ); + if( m_aLocalizedStrings.Count() < 23 ) // bad resource ? + return; + + // create Section for Contents (results in an extra tab page in dialog) + aUIOptions[0].Value = getUIControlOpt( m_aLocalizedStrings.GetString( 0 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Group" ) ) ); + + // create a bool option for graphics + aUIOptions[1].Value = getUIControlOpt( m_aLocalizedStrings.GetString( 1 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintGraphics" ) ), + sal_True ); + // create a bool option for tables + aUIOptions[2].Value = getUIControlOpt( m_aLocalizedStrings.GetString( 2 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintTables" ) ), + sal_True ); + + // create a bool option for drawings + aUIOptions[3].Value = getUIControlOpt( m_aLocalizedStrings.GetString( 3 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDrawings" ) ), + sal_True ); + + // create a bool option for controls + aUIOptions[4].Value = getUIControlOpt( m_aLocalizedStrings.GetString( 4 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintControls" ) ), + sal_True ); + + // create a bool option for background + aUIOptions[5].Value = getUIControlOpt( m_aLocalizedStrings.GetString( 5 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintBackground" ) ), + sal_True ); + + // create a bool option for black + aUIOptions[6].Value = getUIControlOpt( m_aLocalizedStrings.GetString( 6 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintBlack" ) ), + sal_False ); + + // create a bool option for hidden text + aUIOptions[7].Value = getUIControlOpt( m_aLocalizedStrings.GetString( 7 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintHiddenText" ) ), + sal_False ); + + // create a bool option for place holder + aUIOptions[8].Value = getUIControlOpt( m_aLocalizedStrings.GetString( 8 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintPlaceholder" ) ), + sal_False ); + + // create a list box for notes content + Sequence< rtl::OUString > aChoices( 4 ); + aChoices[0] = m_aLocalizedStrings.GetString( 10 ); + aChoices[1] = m_aLocalizedStrings.GetString( 11 ); + aChoices[2] = m_aLocalizedStrings.GetString( 12 ); + aChoices[3] = m_aLocalizedStrings.GetString( 13 ); + aUIOptions[9].Value = getUIControlOpt( m_aLocalizedStrings.GetString( 9 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "List" ) ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintNotes" ) ), + aChoices, + 0 + ); + + // create Section for Page settings (results in an extra tab page in dialog) + aUIOptions[10].Value = getUIControlOpt( m_aLocalizedStrings.GetString( 14 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Group" ) ) ); + + // create a bool option for left pages + aUIOptions[11].Value = getUIControlOpt( m_aLocalizedStrings.GetString( 15 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintLeftPages" ) ), + sal_True ); + + // create a bool option for right pages + aUIOptions[12].Value = getUIControlOpt( m_aLocalizedStrings.GetString( 16 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintRightPages" ) ), + sal_True ); + + // create a bool option for reversed order (solve in vcl ?) + aUIOptions[13].Value = getUIControlOpt( m_aLocalizedStrings.GetString( 17 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintReverseOrder" ) ), + sal_False ); + + // create a bool option for brochure + OUString aBrochurePropertyName( RTL_CONSTASCII_USTRINGPARAM( "PrintBrochure" ) ); + aUIOptions[14].Value = getUIControlOpt( m_aLocalizedStrings.GetString( 18 ), + aBrochurePropertyName, + sal_False ); + + // create a bool option for brochure RTL dependent on brochure + aUIOptions[15].Value = getUIControlOpt( m_aLocalizedStrings.GetString( 19 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintBrochureRTL" ) ), + sal_False, + &aBrochurePropertyName + ); + + // create subgroup for misc options + aUIOptions[16].Value = getUIControlOpt( m_aLocalizedStrings.GetString( 20 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Subgroup" ) ) ); + + // create a bool option for blank pages + aUIOptions[17].Value = getUIControlOpt( m_aLocalizedStrings.GetString( 21 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintEmptyPages" ) ), + sal_True ); + + // create a bool option for paper tray + aUIOptions[18].Value = getUIControlOpt( m_aLocalizedStrings.GetString( 22 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PaperTray" ) ), + sal_False ); + + sal_Int32 nLen = io_rProps.getLength(); + io_rProps.realloc( nLen+1 ); + io_rProps[nLen].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ExtraPrintUIOptions" ) ); + io_rProps[nLen].Value = uno::makeAny( aUIOptions ); +} + + + SwTxtFmtColl *lcl_GetParaStyle(const String& rCollName, SwDoc* pDoc) { SwTxtFmtColl* pColl = pDoc->FindTxtFmtCollByName( rCollName ); @@ -360,7 +587,8 @@ SwXTextDocument::SwXTextDocument(SwDocShell* pShell) : pxXLineNumberingProperties(0), pxLinkTargetSupplier(0), pxXRedlines(0), - m_pHiddenViewFrame(0) + m_pHiddenViewFrame(0), + m_pPrintUIOptions( NULL ) { } /*-- 18.12.98 11:53:00--------------------------------------------------- @@ -375,6 +603,7 @@ SwXTextDocument::~SwXTextDocument() xNumFmtAgg->setDelegator(x0); xNumFmtAgg = 0; } + delete m_pPrintUIOptions; } @@ -2604,6 +2833,10 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount( ::vos::OGuard aGuard(Application::GetSolarMutex()); if(!IsValid()) throw RuntimeException(); + + if( ! m_pPrintUIOptions ) + m_pPrintUIOptions = new SwPrintUIOptions(); + SfxViewShell *pView = 0; SwDoc *pDoc = GetRenderDoc( pView, rSelection ); if (!pDoc) @@ -2650,6 +2883,10 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SwXTextDocument::getRenderer( ::vos::OGuard aGuard(Application::GetSolarMutex()); if(!IsValid()) throw RuntimeException(); + + if( ! m_pPrintUIOptions ) + m_pPrintUIOptions = new SwPrintUIOptions(); + SfxViewShell *pView = 0; SwDoc *pDoc = GetRenderDoc( pView, rSelection ); if (!pDoc) @@ -2679,6 +2916,8 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SwXTextDocument::getRenderer( rValue.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "PageSize" ) ); rValue.Value <<= aPageSize; + m_pPrintUIOptions->addPrintUIOptions( aRenderer ); + return aRenderer; } /* -----------------------------28.10.02 16:00-------------------------------- @@ -2719,6 +2958,10 @@ void SAL_CALL SwXTextDocument::render( ::vos::OGuard aGuard(Application::GetSolarMutex()); if(!IsValid()) throw RuntimeException(); + + if( ! m_pPrintUIOptions ) + m_pPrintUIOptions = new SwPrintUIOptions(); + SfxViewShell *pView = GuessViewShell(); SwDoc *pDoc = GetRenderDoc( pView, rSelection ); if (!pDoc || !pView) -- cgit From 1777b5a68513f7cbfaa239acf16bcc76a49b448c Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Wed, 15 Apr 2009 19:11:23 +0000 Subject: #i92516# vcl helper for new print ui options --- sw/source/ui/uno/unotxdoc.cxx | 242 ++++++++++++------------------------------ 1 file changed, 69 insertions(+), 173 deletions(-) (limited to 'sw') diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index a4dffcd966aa..a4701db19285 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -36,6 +36,7 @@ #include #include #include +#include #include #ifndef _TOOLKIT_UNOHLP_HXX #include @@ -176,227 +177,122 @@ using ::osl::FileBase; * ******************************************************************************/ -class SwPrintUIOptions -{ - ResStringArray m_aLocalizedStrings; - - Any getUIControlOpt( const rtl::OUString& i_rTitle, - const rtl::OUString& i_rType, - const PropertyValue* i_pVal = NULL, - const Sequence< rtl::OUString >* i_pChoices = NULL, - const rtl::OUString* i_pDependsOnName = NULL, - sal_Int32 i_nDependsOnEntry = -1 - ); - - Any getUIControlOpt( const rtl::OUString& i_rTitle, - const rtl::OUString& i_rProperty, - sal_Bool i_bValue, - const rtl::OUString* i_pDependsOnName = NULL, - sal_Int32 i_nDependsOnEntry = -1 - ); - - Any getUIControlOpt( const rtl::OUString& i_rTitle, - const rtl::OUString& i_rType, - const rtl::OUString& i_rProperty, - const Sequence< rtl::OUString >& i_rChoices, - sal_Int32 i_nValue, - const rtl::OUString* i_pDependsOnName = NULL, - sal_Int32 i_nDependsOnEntry = -1 - ); +class SwPrintUIOptions : public vcl::PrinterOptionsHelper +{ public: SwPrintUIOptions(); - - void addPrintUIOptions( uno::Sequence< beans::PropertyValue >& io_rProps ); }; SwPrintUIOptions::SwPrintUIOptions() -: m_aLocalizedStrings( SW_RES( STR_PRINTOPTUI ) ) -{ -} - -Any SwPrintUIOptions::getUIControlOpt( const rtl::OUString& i_rTitle, - const rtl::OUString& i_rType, - const PropertyValue* i_pVal, - const Sequence< rtl::OUString >* i_pChoices, - const rtl::OUString* i_pDependsOnName, - sal_Int32 i_nDependsOnEntry - ) -{ - Sequence< PropertyValue > aCtrl(6); - sal_Int32 nUsed = 0; - if( i_rTitle.getLength() ) - { - aCtrl[nUsed ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "Text" ) ); - aCtrl[nUsed++].Value = makeAny( i_rTitle ); - } - aCtrl[nUsed ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "ControlType" ) ); - aCtrl[nUsed++].Value = makeAny( i_rType ); - if( i_pVal ) - { - aCtrl[nUsed ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "Property" ) ); - aCtrl[nUsed++].Value = makeAny( *i_pVal ); - } - if( i_pChoices ) - { - aCtrl[nUsed ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "Choices" ) ); - aCtrl[nUsed++].Value = makeAny( *i_pChoices ); - } - if( i_pDependsOnName ) - { - aCtrl[nUsed ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "DependsOnName" ) ); - aCtrl[nUsed++].Value = makeAny( *i_pDependsOnName ); - if( i_nDependsOnEntry != -1 ) - { - aCtrl[nUsed ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "DependsOnEntry" ) ); - aCtrl[nUsed++].Value = makeAny( i_nDependsOnEntry ); - } - } - aCtrl.realloc( nUsed ); - return makeAny( aCtrl ); -} - -Any SwPrintUIOptions::getUIControlOpt( const rtl::OUString& i_rTitle, - const rtl::OUString& i_rProperty, - sal_Bool i_bValue, - const rtl::OUString* i_pDependsOnName, - sal_Int32 i_nDependsOnEntry ) { - PropertyValue aVal; - aVal.Name = i_rProperty; - aVal.Value = makeAny( i_bValue ); - return getUIControlOpt( i_rTitle, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Bool" ) ), &aVal, NULL, i_pDependsOnName, i_nDependsOnEntry ); -} - -Any SwPrintUIOptions::getUIControlOpt( const rtl::OUString& i_rTitle, - const rtl::OUString& i_rType, - const rtl::OUString& i_rProperty, - const Sequence< rtl::OUString >& i_rChoices, - sal_Int32 i_nValue, - const rtl::OUString* i_pDependsOnName, - sal_Int32 i_nDependsOnEntry ) -{ - PropertyValue aVal; - aVal.Name = i_rProperty; - aVal.Value = makeAny( i_nValue ); - return getUIControlOpt( i_rTitle, i_rType, &aVal, &i_rChoices, i_pDependsOnName, i_nDependsOnEntry ); -} + ResStringArray aLocalizedStrings( SW_RES( STR_PRINTOPTUI ) ); + DBG_ASSERT( aLocalizedStrings.Count() >= 23, "resource incomplete" ); + if( aLocalizedStrings.Count() < 23 ) // bad resource ? + return; -void SwPrintUIOptions::addPrintUIOptions( uno::Sequence< beans::PropertyValue >& io_rProps ) -{ // create sequence of print UI options - uno::Sequence< beans::PropertyValue > aUIOptions( 19 ); - - DBG_ASSERT( m_aLocalizedStrings.Count() >= 23, "resource incomplete" ); - if( m_aLocalizedStrings.Count() < 23 ) // bad resource ? - return; + m_aUIProperties.realloc( 19 ); // create Section for Contents (results in an extra tab page in dialog) - aUIOptions[0].Value = getUIControlOpt( m_aLocalizedStrings.GetString( 0 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Group" ) ) ); + m_aUIProperties[0].Value = getGroupControlOpt( aLocalizedStrings.GetString( 0 ) ); // create a bool option for graphics - aUIOptions[1].Value = getUIControlOpt( m_aLocalizedStrings.GetString( 1 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintGraphics" ) ), - sal_True ); + m_aUIProperties[1].Value = getBoolControlOpt( aLocalizedStrings.GetString( 1 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintGraphics" ) ), + sal_True ); // create a bool option for tables - aUIOptions[2].Value = getUIControlOpt( m_aLocalizedStrings.GetString( 2 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintTables" ) ), - sal_True ); + m_aUIProperties[2].Value = getBoolControlOpt( aLocalizedStrings.GetString( 2 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintTables" ) ), + sal_True ); // create a bool option for drawings - aUIOptions[3].Value = getUIControlOpt( m_aLocalizedStrings.GetString( 3 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDrawings" ) ), - sal_True ); + m_aUIProperties[3].Value = getBoolControlOpt( aLocalizedStrings.GetString( 3 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDrawings" ) ), + sal_True ); // create a bool option for controls - aUIOptions[4].Value = getUIControlOpt( m_aLocalizedStrings.GetString( 4 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintControls" ) ), - sal_True ); + m_aUIProperties[4].Value = getBoolControlOpt( aLocalizedStrings.GetString( 4 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintControls" ) ), + sal_True ); // create a bool option for background - aUIOptions[5].Value = getUIControlOpt( m_aLocalizedStrings.GetString( 5 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintBackground" ) ), - sal_True ); + m_aUIProperties[5].Value = getBoolControlOpt( aLocalizedStrings.GetString( 5 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintBackground" ) ), + sal_True ); // create a bool option for black - aUIOptions[6].Value = getUIControlOpt( m_aLocalizedStrings.GetString( 6 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintBlack" ) ), - sal_False ); + m_aUIProperties[6].Value = getBoolControlOpt( aLocalizedStrings.GetString( 6 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintBlack" ) ), + sal_False ); // create a bool option for hidden text - aUIOptions[7].Value = getUIControlOpt( m_aLocalizedStrings.GetString( 7 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintHiddenText" ) ), - sal_False ); + m_aUIProperties[7].Value = getBoolControlOpt( aLocalizedStrings.GetString( 7 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintHiddenText" ) ), + sal_False ); // create a bool option for place holder - aUIOptions[8].Value = getUIControlOpt( m_aLocalizedStrings.GetString( 8 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintPlaceholder" ) ), - sal_False ); + m_aUIProperties[8].Value = getBoolControlOpt( aLocalizedStrings.GetString( 8 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintPlaceholder" ) ), + sal_False ); // create a list box for notes content Sequence< rtl::OUString > aChoices( 4 ); - aChoices[0] = m_aLocalizedStrings.GetString( 10 ); - aChoices[1] = m_aLocalizedStrings.GetString( 11 ); - aChoices[2] = m_aLocalizedStrings.GetString( 12 ); - aChoices[3] = m_aLocalizedStrings.GetString( 13 ); - aUIOptions[9].Value = getUIControlOpt( m_aLocalizedStrings.GetString( 9 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "List" ) ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintNotes" ) ), - aChoices, - 0 - ); + aChoices[0] = aLocalizedStrings.GetString( 10 ); + aChoices[1] = aLocalizedStrings.GetString( 11 ); + aChoices[2] = aLocalizedStrings.GetString( 12 ); + aChoices[3] = aLocalizedStrings.GetString( 13 ); + m_aUIProperties[9].Value = getChoiceControlOpt( aLocalizedStrings.GetString( 9 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintNotes" ) ), + aChoices, + 0, + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "List" ) ) + ); // create Section for Page settings (results in an extra tab page in dialog) - aUIOptions[10].Value = getUIControlOpt( m_aLocalizedStrings.GetString( 14 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Group" ) ) ); + m_aUIProperties[10].Value = getGroupControlOpt( aLocalizedStrings.GetString( 14 ) ); // create a bool option for left pages - aUIOptions[11].Value = getUIControlOpt( m_aLocalizedStrings.GetString( 15 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintLeftPages" ) ), - sal_True ); + m_aUIProperties[11].Value = getBoolControlOpt( aLocalizedStrings.GetString( 15 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintLeftPages" ) ), + sal_True ); // create a bool option for right pages - aUIOptions[12].Value = getUIControlOpt( m_aLocalizedStrings.GetString( 16 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintRightPages" ) ), - sal_True ); + m_aUIProperties[12].Value = getBoolControlOpt( aLocalizedStrings.GetString( 16 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintRightPages" ) ), + sal_True ); // create a bool option for reversed order (solve in vcl ?) - aUIOptions[13].Value = getUIControlOpt( m_aLocalizedStrings.GetString( 17 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintReverseOrder" ) ), - sal_False ); + m_aUIProperties[13].Value = getBoolControlOpt( aLocalizedStrings.GetString( 17 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintReverseOrder" ) ), + sal_False ); // create a bool option for brochure OUString aBrochurePropertyName( RTL_CONSTASCII_USTRINGPARAM( "PrintBrochure" ) ); - aUIOptions[14].Value = getUIControlOpt( m_aLocalizedStrings.GetString( 18 ), - aBrochurePropertyName, - sal_False ); + m_aUIProperties[14].Value = getBoolControlOpt( aLocalizedStrings.GetString( 18 ), + aBrochurePropertyName, + sal_False ); // create a bool option for brochure RTL dependent on brochure - aUIOptions[15].Value = getUIControlOpt( m_aLocalizedStrings.GetString( 19 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintBrochureRTL" ) ), - sal_False, - &aBrochurePropertyName - ); + m_aUIProperties[15].Value = getBoolControlOpt( aLocalizedStrings.GetString( 19 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintBrochureRTL" ) ), + sal_False, + &aBrochurePropertyName + ); // create subgroup for misc options - aUIOptions[16].Value = getUIControlOpt( m_aLocalizedStrings.GetString( 20 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Subgroup" ) ) ); + m_aUIProperties[16].Value = getSubgroupControlOpt( aLocalizedStrings.GetString( 20 ) ); // create a bool option for blank pages - aUIOptions[17].Value = getUIControlOpt( m_aLocalizedStrings.GetString( 21 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintEmptyPages" ) ), - sal_True ); + m_aUIProperties[17].Value = getBoolControlOpt( aLocalizedStrings.GetString( 21 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintEmptyPages" ) ), + sal_True ); // create a bool option for paper tray - aUIOptions[18].Value = getUIControlOpt( m_aLocalizedStrings.GetString( 22 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PaperTray" ) ), - sal_False ); + m_aUIProperties[18].Value = getBoolControlOpt( aLocalizedStrings.GetString( 22 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PaperTray" ) ), + sal_False ); - sal_Int32 nLen = io_rProps.getLength(); - io_rProps.realloc( nLen+1 ); - io_rProps[nLen].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ExtraPrintUIOptions" ) ); - io_rProps[nLen].Value = uno::makeAny( aUIOptions ); } @@ -2916,7 +2812,7 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SwXTextDocument::getRenderer( rValue.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "PageSize" ) ); rValue.Value <<= aPageSize; - m_pPrintUIOptions->addPrintUIOptions( aRenderer ); + m_pPrintUIOptions->appendPrintUIOptions( aRenderer ); return aRenderer; } -- cgit From fa4ca9fdb46b8436d50ae6a6de91cfc0fc0f6c8c Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Mon, 20 Apr 2009 16:57:13 +0000 Subject: CWS-TOOLING: rebase CWS printerpullpages to trunk@270723 (milestone: DEV300:m46) --- sw/inc/fmtcol.hxx | 2 +- sw/source/core/doc/fmtcol.cxx | 24 ++++++++++++++++++++- sw/source/core/text/EnhancedPDFExportHelper.cxx | 9 +++++--- sw/source/core/text/atrstck.cxx | 9 +++++--- sw/source/core/unocore/unocrsrhelper.cxx | 12 +++++++---- sw/source/filter/html/htmlatr.cxx | 2 +- sw/source/filter/rtf/swparrtf.cxx | 2 ++ sw/source/filter/rtf/wrtrtf.cxx | 4 ++-- sw/source/filter/ww8/wrtww8.cxx | 4 +++- sw/source/filter/ww8/ww8par.cxx | 2 +- sw/source/ui/frmdlg/column.cxx | 2 +- sw/source/ui/misc/outline.cxx | 28 ------------------------- 12 files changed, 54 insertions(+), 46 deletions(-) (limited to 'sw') diff --git a/sw/inc/fmtcol.hxx b/sw/inc/fmtcol.hxx index 7dcb6720d593..d06a64cf9bfd 100644 --- a/sw/inc/fmtcol.hxx +++ b/sw/inc/fmtcol.hxx @@ -116,7 +116,7 @@ public: void SetAttrOutlineLevel( int ); int GetAttrOutlineLevel() const; int GetAssignedOutlineStyleLevel() const; - inline const bool IsAssignedToListLevelOfOutlineStyle() const + inline bool IsAssignedToListLevelOfOutlineStyle() const { return mbAssignedToOutlineStyle; } diff --git a/sw/source/core/doc/fmtcol.cxx b/sw/source/core/doc/fmtcol.cxx index 83ef29ab1d1e..6ee49a81b4b7 100644 --- a/sw/source/core/doc/fmtcol.cxx +++ b/sw/source/core/doc/fmtcol.cxx @@ -683,9 +683,31 @@ int SwTxtFmtColl::GetAssignedOutlineStyleLevel() const void SwTxtFmtColl::AssignToListLevelOfOutlineStyle(const int nAssignedListLevel) { - mbAssignedToOutlineStyle = true; SetAttrOutlineLevel(nAssignedListLevel+1); + + // --> OD 2009-03-18 #i100277# + SwClientIter aIter( *this ); + SwTxtFmtColl* pDerivedTxtFmtColl = + dynamic_cast(aIter.First( TYPE( SwTxtFmtColl ) )); + while ( pDerivedTxtFmtColl != 0 ) + { + if ( !pDerivedTxtFmtColl->IsAssignedToListLevelOfOutlineStyle() ) + { + if ( pDerivedTxtFmtColl->GetItemState( RES_PARATR_NUMRULE, FALSE ) == SFX_ITEM_DEFAULT ) + { + SwNumRuleItem aItem(aEmptyStr); + pDerivedTxtFmtColl->SetFmtAttr( aItem ); + } + if ( pDerivedTxtFmtColl->GetItemState( RES_PARATR_OUTLINELEVEL, FALSE ) == SFX_ITEM_DEFAULT ) + { + pDerivedTxtFmtColl->SetAttrOutlineLevel( 0 ); + } + } + + pDerivedTxtFmtColl = dynamic_cast(aIter.Next()); + } + // <-- } void SwTxtFmtColl::DeleteAssignmentToListLevelOfOutlineStyle() diff --git a/sw/source/core/text/EnhancedPDFExportHelper.cxx b/sw/source/core/text/EnhancedPDFExportHelper.cxx index 2dae454614e4..4b9e9ec73cfe 100644 --- a/sw/source/core/text/EnhancedPDFExportHelper.cxx +++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx @@ -676,8 +676,8 @@ void SwTaggedPDFHelper::SetAttributes( vcl::PDFWriter::StructElement eType ) const SwAttrSet& aSet = static_cast(pFrm)->GetTxtNode()->GetSwAttrSet(); const SvxAdjust nAdjust = aSet.GetAdjust().GetAdjust(); if ( SVX_ADJUST_BLOCK == nAdjust || SVX_ADJUST_CENTER == nAdjust || - ( pFrm->IsRightToLeft() && SVX_ADJUST_LEFT == nAdjust || - !pFrm->IsRightToLeft() && SVX_ADJUST_RIGHT == nAdjust ) ) + ( (pFrm->IsRightToLeft() && SVX_ADJUST_LEFT == nAdjust) || + (!pFrm->IsRightToLeft() && SVX_ADJUST_RIGHT == nAdjust) ) ) { eVal = SVX_ADJUST_BLOCK == nAdjust ? vcl::PDFWriter::Justify : @@ -2191,7 +2191,10 @@ void SwEnhancedPDFExportHelper::MakeHeaderFooterLinks( vcl::PDFExtOutDevData& rP SwRect aHFLinkRect( rLinkRect ); aHFLinkRect.Pos() = pPageFrm->Frm().Pos() + aOffset; - if ( aHFLinkRect != rLinkRect ) + // #i97135# the gcc_x64 optimizer gets aHFLinkRect != rLinkRect wrong + // fool it by comparing the position only (the width and height are the + // same anyway) + if ( aHFLinkRect.Pos() != rLinkRect.Pos() ) { // Link PageNum const sal_Int32 nHFLinkPageNum = CalcOutputPageNum( aHFLinkRect ); diff --git a/sw/source/core/text/atrstck.cxx b/sw/source/core/text/atrstck.cxx index 383791c8a671..eb4148264931 100644 --- a/sw/source/core/text/atrstck.cxx +++ b/sw/source/core/text/atrstck.cxx @@ -270,8 +270,11 @@ bool lcl_ChgHyperLinkColor( const SwTxtAttr& rAttr, // attribute, instead we take the colors from the view options: // if ( pShell->GetWin() && - ( ((SwTxtINetFmt&)rAttr).IsVisited() && SwViewOption::IsVisitedLinks() || - !((SwTxtINetFmt&)rAttr).IsVisited() && SwViewOption::IsLinks() ) ) + ( + (((SwTxtINetFmt&)rAttr).IsVisited() && SwViewOption::IsVisitedLinks()) || + (!((SwTxtINetFmt&)rAttr).IsVisited() && SwViewOption::IsLinks()) + ) + ) { if ( pColor ) { @@ -749,7 +752,7 @@ void SwAttrHandler::FontChg(const SfxPoolItem& rItem, SwFont& rFnt, sal_Bool bPu pDefaultArray[ nStackPos ]; if( (mpShell && !mpShell->GetWin()) || - pTmpItem && !static_cast(pTmpItem)->GetValue() ) + (pTmpItem && !static_cast(pTmpItem)->GetValue()) ) { rFnt.SetUnderline( ((SvxUnderlineItem&)rItem).GetLineStyle() ); rFnt.SetUnderColor( ((SvxUnderlineItem&)rItem).GetColor() ); diff --git a/sw/source/core/unocore/unocrsrhelper.cxx b/sw/source/core/unocore/unocrsrhelper.cxx index d2485a585605..08f61b1341c0 100644 --- a/sw/source/core/unocore/unocrsrhelper.cxx +++ b/sw/source/core/unocore/unocrsrhelper.cxx @@ -630,10 +630,14 @@ void setNumberingProperty(const Any& rValue, SwPaM& rPam) } } //jetzt nochmal fuer Fonts - if(pBulletFontNames[i] != SwXNumberingRules::GetInvalidStyle() && - ((pBulletFontNames[i].Len() && !aFmt.GetBulletFont()) || - pBulletFontNames[i].Len() && - aFmt.GetBulletFont()->GetName() != pBulletFontNames[i] )) + if( + pBulletFontNames[i] != SwXNumberingRules::GetInvalidStyle() && + ( + (pBulletFontNames[i].Len() && !aFmt.GetBulletFont()) || + (pBulletFontNames[i].Len() && + aFmt.GetBulletFont()->GetName() != pBulletFontNames[i]) + ) + ) { const SvxFontListItem* pFontListItem = (const SvxFontListItem* )pDoc->GetDocShell() diff --git a/sw/source/filter/html/htmlatr.cxx b/sw/source/filter/html/htmlatr.cxx index 74c3c30c71c2..030409c1e955 100644 --- a/sw/source/filter/html/htmlatr.cxx +++ b/sw/source/filter/html/htmlatr.cxx @@ -460,7 +460,7 @@ SwHTMLFmtInfo::SwHTMLFmtInfo( const SwFmt *pF, SwDoc *pDoc, SwDoc *pTemplate, }; sal_uInt16 nRef = 0; - sal_uInt16 aSets[2]; + sal_uInt16 aSets[2] = {0,0}; switch( nCSS1Script ) { case CSS1_OUTMODE_WESTERN: diff --git a/sw/source/filter/rtf/swparrtf.cxx b/sw/source/filter/rtf/swparrtf.cxx index ed32aeb9d361..fd9b8511b906 100644 --- a/sw/source/filter/rtf/swparrtf.cxx +++ b/sw/source/filter/rtf/swparrtf.cxx @@ -4004,11 +4004,13 @@ SwTxtFmtColl* SwRTFParser::MakeColl(const String& rName, USHORT nPos, } if (!rbCollExist) + { //pColl->SetOutlineLevel( nOutlineLevel ); //#outline level,removed by zhaojianwei if(nOutlineLevel < MAXLEVEL) //->add by zhaojianwei pColl->AssignToListLevelOfOutlineStyle( nOutlineLevel ); else pColl->DeleteAssignmentToListLevelOfOutlineStyle(); //<-end,zhaojianwei + } return pColl; } diff --git a/sw/source/filter/rtf/wrtrtf.cxx b/sw/source/filter/rtf/wrtrtf.cxx index d0dc00deb276..84eb60cf3847 100644 --- a/sw/source/filter/rtf/wrtrtf.cxx +++ b/sw/source/filter/rtf/wrtrtf.cxx @@ -1683,8 +1683,8 @@ void SwRTFWriter::CheckEndNodeForSection( const SwNode& rNd ) // wer bestimmt den nachsten?? SwNodeIndex aIdx( rNd, 1 ); pSectNd = aIdx.GetNode().GetSectionNode(); - if( !( ( pSectNd || aIdx.GetNode().IsEndNode() && - 0 != ( pSectNd = aIdx.GetNode().StartOfSectionNode()->GetSectionNode() )) + if( !( ( pSectNd || (aIdx.GetNode().IsEndNode() && + 0 != ( pSectNd = aIdx.GetNode().StartOfSectionNode()->GetSectionNode() )) ) /*&& CONTENT_SECTION == pSectNd->GetSection().GetType()*/ )) { // wer bestimmt denn nun den neuen Abschnitt? diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx index f8e783a02188..0f5372b1f7a0 100644 --- a/sw/source/filter/ww8/wrtww8.cxx +++ b/sw/source/filter/ww8/wrtww8.cxx @@ -2155,7 +2155,7 @@ void SwWW8Writer::OutWW8TableDefinition } } - SwTwips nSz = nTblOffset; + SwTwips nSz = 0; sal_uInt32 n = 0; InsUInt16(nTblOffset); @@ -2168,6 +2168,8 @@ void SwWW8Writer::OutWW8TableDefinition if (bRelBoxSize) nCalc = (nCalc * nPageSize) / nTblSz; + nCalc += nTblOffset; + InsUInt16(static_cast(nCalc)); } diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index d8769159afc1..e93c3339bc73 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -3436,7 +3436,7 @@ void wwSectionManager::InsertSegments() bool bThisAndNextAreCompatible = (aNext != aEnd) ? ((aIter->GetPageWidth() == aNext->GetPageWidth()) && (aIter->GetPageHeight() == aNext->GetPageHeight()) && (aIter->IsLandScape() == aNext->IsLandScape())) : true; - if ((aNext != aEnd && aNext->IsContinous() && bThisAndNextAreCompatible || bProtected)) + if ((aNext != aEnd && aNext->IsContinous() && bThisAndNextAreCompatible) || bProtected) { bIgnoreCols = true; if ((aIter->NoCols() > 1) || bProtected) diff --git a/sw/source/ui/frmdlg/column.cxx b/sw/source/ui/frmdlg/column.cxx index d96a072d6893..03dd5fa36fdd 100644 --- a/sw/source/ui/frmdlg/column.cxx +++ b/sw/source/ui/frmdlg/column.cxx @@ -1244,7 +1244,7 @@ void SwColumnPage::ActivatePage(const SfxItemSet& rSet) } BOOL bPercent; // im Rahmenformat nur relative Angaben - if ( bFormat || rSize.GetWidthPercent() && rSize.GetWidthPercent() != 0xff) + if ( bFormat || (rSize.GetWidthPercent() && rSize.GetWidthPercent() != 0xff) ) { // Wert fuer 100% setzen aEd1.SetRefValue(nTotalWish); diff --git a/sw/source/ui/misc/outline.cxx b/sw/source/ui/misc/outline.cxx index 57d652463a95..9fd448fcb210 100644 --- a/sw/source/ui/misc/outline.cxx +++ b/sw/source/ui/misc/outline.cxx @@ -532,34 +532,6 @@ short SwOutlineTabDialog::Ok() } } - //#outline level,add by zhaojianwei - /* When a paragraph style is assigned to a list level of the outline style, - the outline level attribute and the list style attribute of its existing - child paragraph styles have to be set to 0 respectively "".*/ - nCount = rWrtSh.GetTxtFmtCollCount(); - for( i = 0; i < nCount; ++i ) - { - SwTxtFmtColl &rTxtColl = rWrtSh.GetTxtFmtColl(i); - if( !rTxtColl.IsDefault() ) - { - SwTxtFmtColl *pDerFrom = ( SwTxtFmtColl* )rTxtColl.DerivedFrom(); - if( pDerFrom->IsAssignedToListLevelOfOutlineStyle()) - { - if(rTxtColl.GetItemState( RES_PARATR_NUMRULE, FALSE ) == SFX_ITEM_DEFAULT ) - { - SwNumRuleItem aItem(aEmptyStr); - rTxtColl.SetFmtAttr( aItem ); - } - if(rTxtColl.GetItemState( RES_PARATR_OUTLINELEVEL, FALSE ) == SFX_ITEM_DEFAULT ) - { - int nOutlineLevel = 0;; - rTxtColl.SetAttrOutlineLevel( nOutlineLevel ); - } - } - } - } - //<-end,zhaojianwei - rWrtSh.SetOutlineNumRule( *pNumRule); // --> OD 2006-12-11 #130443# -- cgit From e2b86cdb5cb692e338c9a1be2b47fd6f4687737a Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Fri, 24 Apr 2009 11:05:37 +0000 Subject: #i101242# do not reformat all the time --- sw/source/ui/uno/unotxdoc.cxx | 44 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 8 deletions(-) (limited to 'sw') diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index a4701db19285..dfd925b1edce 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -179,11 +179,16 @@ using ::osl::FileBase; class SwPrintUIOptions : public vcl::PrinterOptionsHelper { + OutputDevice* mpLast; public: SwPrintUIOptions(); + + bool processPropertiesAndCheckFormat( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& i_rNewProp ); + }; -SwPrintUIOptions::SwPrintUIOptions() +SwPrintUIOptions::SwPrintUIOptions() : + mpLast( NULL ) { ResStringArray aLocalizedStrings( SW_RES( STR_PRINTOPTUI ) ); @@ -295,7 +300,26 @@ SwPrintUIOptions::SwPrintUIOptions() } +bool SwPrintUIOptions::processPropertiesAndCheckFormat( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& i_rNewProp ) +{ + bool bChanged = processProperties( i_rNewProp ); + uno::Reference< awt::XDevice > xRenderDevice; + Any aVal( getValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "RenderDevice" ) ) ) ); + aVal >>= xRenderDevice; + + OutputDevice* pOut = 0; + if (xRenderDevice.is()) + { + VCLXDevice* pDevice = VCLXDevice::GetImplementation( xRenderDevice ); + pOut = pDevice ? pDevice->GetOutputDevice() : 0; + } + bChanged = bChanged || (pOut != mpLast); + if( pOut ) + mpLast = pOut; + + return bChanged; +} SwTxtFmtColl *lcl_GetParaStyle(const String& rCollName, SwDoc* pDoc) { @@ -2723,7 +2747,7 @@ SwDoc * SwXTextDocument::GetRenderDoc( SfxViewShell *&rpView, const uno::Any& rS ---------------------------------------------------------------------------*/ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount( const uno::Any& rSelection, - const uno::Sequence< beans::PropertyValue >& /*rxOptions*/ ) + const uno::Sequence< beans::PropertyValue >& rxOptions ) throw (IllegalArgumentException, RuntimeException) { ::vos::OGuard aGuard(Application::GetSolarMutex()); @@ -2732,6 +2756,7 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount( if( ! m_pPrintUIOptions ) m_pPrintUIOptions = new SwPrintUIOptions(); + bool bFormat = m_pPrintUIOptions->processPropertiesAndCheckFormat( rxOptions ); SfxViewShell *pView = 0; SwDoc *pDoc = GetRenderDoc( pView, rSelection ); @@ -2757,12 +2782,15 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount( } SwViewOptionAdjust_Impl aAdjust(*pWrtShell); - pWrtShell->SetPDFExportOption( sal_True ); - // --> FME 2005-05-23 #122919# Force field update before PDF export: - pWrtShell->ViewShell::UpdateFlds(TRUE); - // <-- - pWrtShell->CalcLayout(); - pWrtShell->SetPDFExportOption( sal_False ); + if( bFormat ) + { + pWrtShell->SetPDFExportOption( sal_True ); + // --> FME 2005-05-23 #122919# Force field update before PDF export: + pWrtShell->ViewShell::UpdateFlds(TRUE); + // <-- + pWrtShell->CalcLayout(); + pWrtShell->SetPDFExportOption( sal_False ); + } nRet = pDoc->GetPageCount(); return nRet; -- cgit From 60d5a8c08854fd722858975a4c1636a01904f216 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Fri, 24 Apr 2009 13:14:33 +0000 Subject: #i101242# release options helper on last page --- sw/source/ui/uno/unotxdoc.cxx | 3 +++ 1 file changed, 3 insertions(+) (limited to 'sw') diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index dfd925b1edce..0e3907c51e5b 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -3000,6 +3000,9 @@ void SAL_CALL SwXTextDocument::render( lcl_DisposeView( m_pHiddenViewFrame, pDocShell ); m_pHiddenViewFrame = 0; } + + if( bLastPage ) + delete m_pPrintUIOptions, m_pPrintUIOptions = NULL; } } /* -----------------------------03.10.04 ------------------------------------- -- cgit From 0c03078f953a79ace1e9feae55cd827785ae0591 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Mon, 27 Apr 2009 16:16:26 +0000 Subject: #i92516# HelpTexts for new print UI --- sw/source/ui/config/optdlg.src | 16 ++++++++++ sw/source/ui/uno/unotxdoc.cxx | 67 +++++++++++++++++++++++++++--------------- 2 files changed, 59 insertions(+), 24 deletions(-) (limited to 'sw') diff --git a/sw/source/ui/config/optdlg.src b/sw/source/ui/config/optdlg.src index 343d4daa389a..067c4b445676 100644 --- a/sw/source/ui/config/optdlg.src +++ b/sw/source/ui/config/optdlg.src @@ -942,27 +942,43 @@ StringArray STR_PRINTOPTUI { < "Contents"; >; < "~Graphics"; >; + < "Specifies whether the graphics of your text document are printed"; >; < "~Tables"; >; + < "Specifies whether the tables of the text document are printed"; >; < "Dra~wings"; >; + < "Specifies whether graphics created with %PRODUCTNAME drawing functions are printed."; >; < "Control~s"; >; + < "Specifies whether the form control fields of the text document are printed"; >; < "Ba~ckground"; >; + < "Specifies whether to include colors and objects that are inserted to the background of the page (Format - Page - Background) in the printed document."; >; < "Print blac~k"; >; + < "Specifies whether to always print text in black."; >; < "Hidden te~xt"; >; + < "Enable this option to print text that is marked as hidden."; >; < "Text ~placeholder"; >; + < "Enable this option to print text placeholders. Disable this option to leave the text placeholders blank in the printout."; >; < "~Notes"; >; + < "Specify where to print notes (if any)."; >; < "None"; >; < "Notes only"; >; < " at end of document"; >; < " at end of page"; >; < "Page settings"; >; < "~Left pages"; >; + < "Specifies whether to print all left pages of the document."; >; < "~Right pages"; >; + < "Specifies whether to print all right pages of the document."; >; < "Re~versed"; >; + < "Specifies whether to reverse the printing order."; >; < "Broch~ure"; >; + < "Select the Brochure option to print the document in brochure format."; >; < "Right to Left"; >; + < "Check to print the pages of the brochure in the correct order for a right-to-left script."; >; < "Other"; >; < "Print ~automatically inserted blank pages"; >; + < "If this option is enabled automatically inserted blank pages are printed. This is best if you are printing double-sided. For example, in a book, a \"chapter\" paragraph style has been set to always start with an odd numbered page. If the previous chapter ends on an odd page, %PRODUCTNAME inserts an even numbered blank page. This option controls whether to print that even numbered page or not"; >; < "~Paper tray from printer settings"; >; + < "For printers with multiple trays this option specifies whether the paper tray used is specified by the system settings of the printer."; >; }; }; diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index 0e3907c51e5b..d938b5df55ff 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -192,62 +192,74 @@ SwPrintUIOptions::SwPrintUIOptions() : { ResStringArray aLocalizedStrings( SW_RES( STR_PRINTOPTUI ) ); - DBG_ASSERT( aLocalizedStrings.Count() >= 23, "resource incomplete" ); - if( aLocalizedStrings.Count() < 23 ) // bad resource ? + DBG_ASSERT( aLocalizedStrings.Count() >= 39, "resource incomplete" ); + if( aLocalizedStrings.Count() < 39 ) // bad resource ? return; // create sequence of print UI options m_aUIProperties.realloc( 19 ); // create Section for Contents (results in an extra tab page in dialog) - m_aUIProperties[0].Value = getGroupControlOpt( aLocalizedStrings.GetString( 0 ) ); + m_aUIProperties[0].Value = getGroupControlOpt( aLocalizedStrings.GetString( 0 ), rtl::OUString() ); // create a bool option for graphics m_aUIProperties[1].Value = getBoolControlOpt( aLocalizedStrings.GetString( 1 ), + aLocalizedStrings.GetString( 2 ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintGraphics" ) ), sal_True ); // create a bool option for tables - m_aUIProperties[2].Value = getBoolControlOpt( aLocalizedStrings.GetString( 2 ), + m_aUIProperties[2].Value = getBoolControlOpt( aLocalizedStrings.GetString( 3 ), + aLocalizedStrings.GetString( 4 ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintTables" ) ), sal_True ); // create a bool option for drawings - m_aUIProperties[3].Value = getBoolControlOpt( aLocalizedStrings.GetString( 3 ), + m_aUIProperties[3].Value = getBoolControlOpt( aLocalizedStrings.GetString( 5 ), + aLocalizedStrings.GetString( 6 ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDrawings" ) ), sal_True ); // create a bool option for controls - m_aUIProperties[4].Value = getBoolControlOpt( aLocalizedStrings.GetString( 4 ), + m_aUIProperties[4].Value = getBoolControlOpt( aLocalizedStrings.GetString( 7 ), + aLocalizedStrings.GetString( 8 ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintControls" ) ), sal_True ); // create a bool option for background - m_aUIProperties[5].Value = getBoolControlOpt( aLocalizedStrings.GetString( 5 ), + m_aUIProperties[5].Value = getBoolControlOpt( aLocalizedStrings.GetString( 9 ), + aLocalizedStrings.GetString( 10 ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintBackground" ) ), sal_True ); // create a bool option for black - m_aUIProperties[6].Value = getBoolControlOpt( aLocalizedStrings.GetString( 6 ), + m_aUIProperties[6].Value = getBoolControlOpt( aLocalizedStrings.GetString( 11 ), + aLocalizedStrings.GetString( 12 ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintBlack" ) ), sal_False ); // create a bool option for hidden text - m_aUIProperties[7].Value = getBoolControlOpt( aLocalizedStrings.GetString( 7 ), + m_aUIProperties[7].Value = getBoolControlOpt( aLocalizedStrings.GetString( 13 ), + aLocalizedStrings.GetString( 14 ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintHiddenText" ) ), sal_False ); // create a bool option for place holder - m_aUIProperties[8].Value = getBoolControlOpt( aLocalizedStrings.GetString( 8 ), + m_aUIProperties[8].Value = getBoolControlOpt( aLocalizedStrings.GetString( 15 ), + aLocalizedStrings.GetString( 16 ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintPlaceholder" ) ), sal_False ); // create a list box for notes content Sequence< rtl::OUString > aChoices( 4 ); - aChoices[0] = aLocalizedStrings.GetString( 10 ); - aChoices[1] = aLocalizedStrings.GetString( 11 ); - aChoices[2] = aLocalizedStrings.GetString( 12 ); - aChoices[3] = aLocalizedStrings.GetString( 13 ); - m_aUIProperties[9].Value = getChoiceControlOpt( aLocalizedStrings.GetString( 9 ), + aChoices[0] = aLocalizedStrings.GetString( 19 ); + aChoices[1] = aLocalizedStrings.GetString( 20 ); + aChoices[2] = aLocalizedStrings.GetString( 21 ); + aChoices[3] = aLocalizedStrings.GetString( 22 ); + Sequence< rtl::OUString > aHelpText( 2 ); + aHelpText[0] = aLocalizedStrings.GetString( 18 ); + aHelpText[1] = aLocalizedStrings.GetString( 18 ); + m_aUIProperties[9].Value = getChoiceControlOpt( aLocalizedStrings.GetString( 17 ), + aHelpText, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintNotes" ) ), aChoices, 0, @@ -255,46 +267,53 @@ SwPrintUIOptions::SwPrintUIOptions() : ); // create Section for Page settings (results in an extra tab page in dialog) - m_aUIProperties[10].Value = getGroupControlOpt( aLocalizedStrings.GetString( 14 ) ); + m_aUIProperties[10].Value = getGroupControlOpt( aLocalizedStrings.GetString( 23 ), rtl::OUString() ); // create a bool option for left pages - m_aUIProperties[11].Value = getBoolControlOpt( aLocalizedStrings.GetString( 15 ), + m_aUIProperties[11].Value = getBoolControlOpt( aLocalizedStrings.GetString( 24 ), + aLocalizedStrings.GetString( 25 ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintLeftPages" ) ), sal_True ); // create a bool option for right pages - m_aUIProperties[12].Value = getBoolControlOpt( aLocalizedStrings.GetString( 16 ), + m_aUIProperties[12].Value = getBoolControlOpt( aLocalizedStrings.GetString( 26 ), + aLocalizedStrings.GetString( 27 ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintRightPages" ) ), sal_True ); // create a bool option for reversed order (solve in vcl ?) - m_aUIProperties[13].Value = getBoolControlOpt( aLocalizedStrings.GetString( 17 ), + m_aUIProperties[13].Value = getBoolControlOpt( aLocalizedStrings.GetString( 28 ), + aLocalizedStrings.GetString( 29 ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintReverseOrder" ) ), sal_False ); // create a bool option for brochure OUString aBrochurePropertyName( RTL_CONSTASCII_USTRINGPARAM( "PrintBrochure" ) ); - m_aUIProperties[14].Value = getBoolControlOpt( aLocalizedStrings.GetString( 18 ), + m_aUIProperties[14].Value = getBoolControlOpt( aLocalizedStrings.GetString( 30 ), + aLocalizedStrings.GetString( 31 ), aBrochurePropertyName, sal_False ); // create a bool option for brochure RTL dependent on brochure - m_aUIProperties[15].Value = getBoolControlOpt( aLocalizedStrings.GetString( 19 ), + m_aUIProperties[15].Value = getBoolControlOpt( aLocalizedStrings.GetString( 32 ), + aLocalizedStrings.GetString( 33 ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintBrochureRTL" ) ), sal_False, &aBrochurePropertyName ); // create subgroup for misc options - m_aUIProperties[16].Value = getSubgroupControlOpt( aLocalizedStrings.GetString( 20 ) ); + m_aUIProperties[16].Value = getSubgroupControlOpt( aLocalizedStrings.GetString( 34 ), rtl::OUString() ); // create a bool option for blank pages - m_aUIProperties[17].Value = getBoolControlOpt( aLocalizedStrings.GetString( 21 ), + m_aUIProperties[17].Value = getBoolControlOpt( aLocalizedStrings.GetString( 35 ), + aLocalizedStrings.GetString( 36 ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintEmptyPages" ) ), sal_True ); // create a bool option for paper tray - m_aUIProperties[18].Value = getBoolControlOpt( aLocalizedStrings.GetString( 22 ), + m_aUIProperties[18].Value = getBoolControlOpt( aLocalizedStrings.GetString( 37 ), + aLocalizedStrings.GetString( 38 ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PaperTray" ) ), sal_False ); -- cgit From 44014e3a043f1b8fc3a5ed6a5e29a8fb0a6f3969 Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Wed, 13 May 2009 11:30:08 +0000 Subject: #i101242# new print UI dialog in sw --- sw/source/ui/uno/unotxdoc.cxx | 118 +++++++++++++++++++++++++++--------------- 1 file changed, 75 insertions(+), 43 deletions(-) (limited to 'sw') diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index d938b5df55ff..dbb549e1e037 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -38,16 +38,12 @@ #include #include #include -#ifndef _TOOLKIT_UNOHLP_HXX #include -#endif #include #include #include #include -#ifndef _SRCVIEW_HXX #include -#endif #include #include #include @@ -81,14 +77,13 @@ #include #include #include +#include #include #include #include #include -#ifndef _COM_SUN_STAR_BEANS_PropertyAttribute_HPP_ #include -#endif #include #include #include @@ -96,13 +91,9 @@ #include #include #include -#ifndef _MODOPT_HXX // #include -#endif #include -#ifndef _UTLUI_HRC #include -#endif #include #include #include @@ -181,13 +172,13 @@ class SwPrintUIOptions : public vcl::PrinterOptionsHelper { OutputDevice* mpLast; public: - SwPrintUIOptions(); + SwPrintUIOptions( BOOL bWeb ); bool processPropertiesAndCheckFormat( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& i_rNewProp ); }; -SwPrintUIOptions::SwPrintUIOptions() : +SwPrintUIOptions::SwPrintUIOptions( BOOL bWeb ) : mpLast( NULL ) { ResStringArray aLocalizedStrings( SW_RES( STR_PRINTOPTUI ) ); @@ -197,57 +188,66 @@ SwPrintUIOptions::SwPrintUIOptions() : return; // create sequence of print UI options - m_aUIProperties.realloc( 19 ); + // (5 options are not available for Writer-Web) + const int nNumProps = bWeb? 14 : 19; + m_aUIProperties.realloc( nNumProps ); + int nIdx = 0; // create Section for Contents (results in an extra tab page in dialog) - m_aUIProperties[0].Value = getGroupControlOpt( aLocalizedStrings.GetString( 0 ), rtl::OUString() ); + m_aUIProperties[ nIdx++ ].Value = getGroupControlOpt( aLocalizedStrings.GetString( 0 ), rtl::OUString() ); // create a bool option for graphics - m_aUIProperties[1].Value = getBoolControlOpt( aLocalizedStrings.GetString( 1 ), + m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 1 ), aLocalizedStrings.GetString( 2 ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintGraphics" ) ), sal_True ); // create a bool option for tables - m_aUIProperties[2].Value = getBoolControlOpt( aLocalizedStrings.GetString( 3 ), + m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 3 ), aLocalizedStrings.GetString( 4 ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintTables" ) ), sal_True ); - // create a bool option for drawings - m_aUIProperties[3].Value = getBoolControlOpt( aLocalizedStrings.GetString( 5 ), + if (!bWeb) + { + // create a bool option for drawings + m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 5 ), aLocalizedStrings.GetString( 6 ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDrawings" ) ), sal_True ); + } // create a bool option for controls - m_aUIProperties[4].Value = getBoolControlOpt( aLocalizedStrings.GetString( 7 ), + m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 7 ), aLocalizedStrings.GetString( 8 ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintControls" ) ), sal_True ); // create a bool option for background - m_aUIProperties[5].Value = getBoolControlOpt( aLocalizedStrings.GetString( 9 ), + m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 9 ), aLocalizedStrings.GetString( 10 ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintBackground" ) ), sal_True ); // create a bool option for black - m_aUIProperties[6].Value = getBoolControlOpt( aLocalizedStrings.GetString( 11 ), + m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 11 ), aLocalizedStrings.GetString( 12 ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintBlack" ) ), sal_False ); - // create a bool option for hidden text - m_aUIProperties[7].Value = getBoolControlOpt( aLocalizedStrings.GetString( 13 ), + if (!bWeb) + { + // create a bool option for hidden text + m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 13 ), aLocalizedStrings.GetString( 14 ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintHiddenText" ) ), sal_False ); - // create a bool option for place holder - m_aUIProperties[8].Value = getBoolControlOpt( aLocalizedStrings.GetString( 15 ), + // create a bool option for place holder + m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 15 ), aLocalizedStrings.GetString( 16 ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintPlaceholder" ) ), sal_False ); + } // create a list box for notes content Sequence< rtl::OUString > aChoices( 4 ); @@ -258,7 +258,7 @@ SwPrintUIOptions::SwPrintUIOptions() : Sequence< rtl::OUString > aHelpText( 2 ); aHelpText[0] = aLocalizedStrings.GetString( 18 ); aHelpText[1] = aLocalizedStrings.GetString( 18 ); - m_aUIProperties[9].Value = getChoiceControlOpt( aLocalizedStrings.GetString( 17 ), + m_aUIProperties[ nIdx++ ].Value = getChoiceControlOpt( aLocalizedStrings.GetString( 17 ), aHelpText, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintNotes" ) ), aChoices, @@ -267,35 +267,38 @@ SwPrintUIOptions::SwPrintUIOptions() : ); // create Section for Page settings (results in an extra tab page in dialog) - m_aUIProperties[10].Value = getGroupControlOpt( aLocalizedStrings.GetString( 23 ), rtl::OUString() ); + m_aUIProperties[ nIdx++ ].Value = getGroupControlOpt( aLocalizedStrings.GetString( 23 ), rtl::OUString() ); - // create a bool option for left pages - m_aUIProperties[11].Value = getBoolControlOpt( aLocalizedStrings.GetString( 24 ), + if (!bWeb) + { + // create a bool option for left pages + m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 24 ), aLocalizedStrings.GetString( 25 ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintLeftPages" ) ), sal_True ); - // create a bool option for right pages - m_aUIProperties[12].Value = getBoolControlOpt( aLocalizedStrings.GetString( 26 ), + // create a bool option for right pages + m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 26 ), aLocalizedStrings.GetString( 27 ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintRightPages" ) ), sal_True ); + } // create a bool option for reversed order (solve in vcl ?) - m_aUIProperties[13].Value = getBoolControlOpt( aLocalizedStrings.GetString( 28 ), + m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 28 ), aLocalizedStrings.GetString( 29 ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintReverseOrder" ) ), sal_False ); // create a bool option for brochure OUString aBrochurePropertyName( RTL_CONSTASCII_USTRINGPARAM( "PrintBrochure" ) ); - m_aUIProperties[14].Value = getBoolControlOpt( aLocalizedStrings.GetString( 30 ), + m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 30 ), aLocalizedStrings.GetString( 31 ), aBrochurePropertyName, sal_False ); // create a bool option for brochure RTL dependent on brochure - m_aUIProperties[15].Value = getBoolControlOpt( aLocalizedStrings.GetString( 32 ), + m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 32 ), aLocalizedStrings.GetString( 33 ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintBrochureRTL" ) ), sal_False, @@ -303,20 +306,21 @@ SwPrintUIOptions::SwPrintUIOptions() : ); // create subgroup for misc options - m_aUIProperties[16].Value = getSubgroupControlOpt( aLocalizedStrings.GetString( 34 ), rtl::OUString() ); + m_aUIProperties[ nIdx++ ].Value = getSubgroupControlOpt( aLocalizedStrings.GetString( 34 ), rtl::OUString() ); // create a bool option for blank pages - m_aUIProperties[17].Value = getBoolControlOpt( aLocalizedStrings.GetString( 35 ), + m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 35 ), aLocalizedStrings.GetString( 36 ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintEmptyPages" ) ), sal_True ); // create a bool option for paper tray - m_aUIProperties[18].Value = getBoolControlOpt( aLocalizedStrings.GetString( 37 ), + m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 37 ), aLocalizedStrings.GetString( 38 ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PaperTray" ) ), sal_False ); + DBG_ASSERT( nIdx == nNumProps, "number of added properties is not as expected" ); } bool SwPrintUIOptions::processPropertiesAndCheckFormat( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& i_rNewProp ) @@ -2774,7 +2778,10 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount( throw RuntimeException(); if( ! m_pPrintUIOptions ) - m_pPrintUIOptions = new SwPrintUIOptions(); + { + const BOOL bWebDoc = (0 != PTR_CAST(SwWebDocShell, pDocShell)); + m_pPrintUIOptions = new SwPrintUIOptions( bWebDoc ); + } bool bFormat = m_pPrintUIOptions->processPropertiesAndCheckFormat( rxOptions ); SfxViewShell *pView = 0; @@ -2828,7 +2835,10 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SwXTextDocument::getRenderer( throw RuntimeException(); if( ! m_pPrintUIOptions ) - m_pPrintUIOptions = new SwPrintUIOptions(); + { + const BOOL bWebDoc = (0 != PTR_CAST(SwWebDocShell, pDocShell)); + m_pPrintUIOptions = new SwPrintUIOptions( bWebDoc ); + } SfxViewShell *pView = 0; SwDoc *pDoc = GetRenderDoc( pView, rSelection ); @@ -2902,9 +2912,6 @@ void SAL_CALL SwXTextDocument::render( if(!IsValid()) throw RuntimeException(); - if( ! m_pPrintUIOptions ) - m_pPrintUIOptions = new SwPrintUIOptions(); - SfxViewShell *pView = GuessViewShell(); SwDoc *pDoc = GetRenderDoc( pView, rSelection ); if (!pDoc || !pView) @@ -2955,11 +2962,35 @@ void SAL_CALL SwXTextDocument::render( if(pVwSh && pOut) { + if (!m_pPrintUIOptions) + { + const BOOL bWebDoc = (0 != PTR_CAST(SwWebDocShell, pDocShell)); + m_pPrintUIOptions = new SwPrintUIOptions( bWebDoc ); + } + m_pPrintUIOptions->processProperties( rxOptions ); + SwPrtOptions aOptions( C2U("PDF export") ); + // get print options to use from provided properties const TypeId aSwWebDocShellTypeId = TYPE(SwWebDocShell); BOOL bWeb = pDocShell->IsA( aSwWebDocShellTypeId ); SwView::MakeOptions( NULL, aOptions, NULL, NULL, bWeb, NULL, NULL ); + aOptions.bPrintGraphic = m_pPrintUIOptions->getBoolValue( C2U( "PrintGraphics" ), aOptions.bPrintGraphic ); + aOptions.bPrintTable = m_pPrintUIOptions->getBoolValue( C2U( "PrintTables" ), aOptions.bPrintTable ); + aOptions.bPrintDraw = m_pPrintUIOptions->getBoolValue( C2U( "PrintDrawings" ), aOptions.bPrintDraw ); + aOptions.bPrintControl = m_pPrintUIOptions->getBoolValue( C2U( "PrintControls" ), aOptions.bPrintControl ); + aOptions.bPrintLeftPage = m_pPrintUIOptions->getBoolValue( C2U( "PrintLeftPages" ), aOptions.bPrintLeftPage ); + aOptions.bPrintRightPage = m_pPrintUIOptions->getBoolValue( C2U( "PrintRightPages" ), aOptions.bPrintRightPage ); + aOptions.bPrintPageBackground = m_pPrintUIOptions->getBoolValue( C2U( "PrintBackground" ), aOptions.bPrintPageBackground ); + aOptions.bPrintEmptyPages = m_pPrintUIOptions->getBoolValue( C2U( "PrintEmptyPages" ), aOptions.bPrintEmptyPages ); + aOptions.bPrintReverse = m_pPrintUIOptions->getBoolValue( C2U( "PrintReverseOrder" ), aOptions.bPrintReverse ); + aOptions.bPrintProspect = m_pPrintUIOptions->getBoolValue( C2U( "PrintBrochure" ), aOptions.bPrintProspect ); + aOptions.bPrintProspect_RTL = m_pPrintUIOptions->getBoolValue( C2U( "PrintBrochureRTL" ), aOptions.bPrintProspect_RTL ); + aOptions.bPrintBlackFont = m_pPrintUIOptions->getBoolValue( C2U( "PrintBlack" ), aOptions.bPrintBlackFont ); + aOptions.bPrintHiddenText = m_pPrintUIOptions->getBoolValue( C2U( "PrintHiddenText" ), aOptions.bPrintHiddenText ); + aOptions.bPrintTextPlaceholder = m_pPrintUIOptions->getBoolValue( C2U( "PrintPlaceholder" ), aOptions.bPrintTextPlaceholder ); + aOptions.bPaperFromSetup = m_pPrintUIOptions->getBoolValue( C2U( "PaperTray" ), aOptions.bPaperFromSetup ); + aOptions.nPrintPostIts = static_cast< sal_Int16 >(m_pPrintUIOptions->getIntValue( C2U( "PrintNotes" ), aOptions.nPrintPostIts )); Range aPageRange( nRenderer+1, nRenderer+1 ); MultiSelection aPage( aPageRange ); @@ -2971,7 +3002,8 @@ void SAL_CALL SwXTextDocument::render( //! document is created that contains only the selects parts, //! and thus that document is to printed in whole the, //! aOptions.bPrintSelection parameter will be false. - aOptions.bPrintSelection = FALSE; + if (!m_pPrintUIOptions->getBoolValue( C2U( "IsPrinter" ), sal_False ) ) // PDF export? + aOptions.bPrintSelection = FALSE; SwViewOptionAdjust_Impl* pViewOptionAdjust = pView->IsA(aSwViewTypeId) ? new SwViewOptionAdjust_Impl(*((SwView*)pView)->GetWrtShellPtr()) : 0; -- cgit From 0f58a76df8f043959eb3de957514e8bdf57eeed9 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Fri, 22 May 2009 10:55:14 +0000 Subject: #i92516# print range needs to be app specific --- sw/source/ui/config/optdlg.src | 7 +++++++ sw/source/ui/uno/unotxdoc.cxx | 33 ++++++++++++++++++++++++++++++--- 2 files changed, 37 insertions(+), 3 deletions(-) (limited to 'sw') diff --git a/sw/source/ui/config/optdlg.src b/sw/source/ui/config/optdlg.src index 067c4b445676..16d1c57b13ad 100644 --- a/sw/source/ui/config/optdlg.src +++ b/sw/source/ui/config/optdlg.src @@ -979,6 +979,13 @@ StringArray STR_PRINTOPTUI < "If this option is enabled automatically inserted blank pages are printed. This is best if you are printing double-sided. For example, in a book, a \"chapter\" paragraph style has been set to always start with an odd numbered page. If the previous chapter ends on an odd page, %PRODUCTNAME inserts an even numbered blank page. This option controls whether to print that even numbered page or not"; >; < "~Paper tray from printer settings"; >; < "For printers with multiple trays this option specifies whether the paper tray used is specified by the system settings of the printer."; >; + < "Print Range"; >; + < "~All pages"; >; + < "Print all pages of the document."; >; + < "~Pages"; >; + < "Print a range of pages of the document."; >; + < "~Selection"; >; + < "Print only the currently selected content."; >; }; }; diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index dbb549e1e037..ab866e8d0194 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -183,13 +183,13 @@ SwPrintUIOptions::SwPrintUIOptions( BOOL bWeb ) : { ResStringArray aLocalizedStrings( SW_RES( STR_PRINTOPTUI ) ); - DBG_ASSERT( aLocalizedStrings.Count() >= 39, "resource incomplete" ); - if( aLocalizedStrings.Count() < 39 ) // bad resource ? + DBG_ASSERT( aLocalizedStrings.Count() >= 46, "resource incomplete" ); + if( aLocalizedStrings.Count() < 46 ) // bad resource ? return; // create sequence of print UI options // (5 options are not available for Writer-Web) - const int nNumProps = bWeb? 14 : 19; + const int nNumProps = bWeb? 17 : 22; m_aUIProperties.realloc( nNumProps ); int nIdx = 0; @@ -320,6 +320,33 @@ SwPrintUIOptions::SwPrintUIOptions( BOOL bWeb ) : rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PaperTray" ) ), sal_False ); + // print range selection + m_aUIProperties[nIdx++].Value = getSubgroupControlOpt( rtl::OUString( aLocalizedStrings.GetString( 39 ) ), rtl::OUString(), true, true ); + + // create a choice for the content to create + rtl::OUString aPrintRangeName( RTL_CONSTASCII_USTRINGPARAM( "PrintContent" ) ); + aChoices.realloc( 3 ); + aHelpText.realloc( 3 ); + aChoices[0] = aLocalizedStrings.GetString( 40 ); + aHelpText[0] = aLocalizedStrings.GetString( 41 ); + aChoices[1] = aLocalizedStrings.GetString( 42 ); + aHelpText[1] = aLocalizedStrings.GetString( 43 ); + aChoices[2] = aLocalizedStrings.GetString( 44 ); + aHelpText[2] = aLocalizedStrings.GetString( 45 ); + m_aUIProperties[nIdx++].Value = getChoiceControlOpt( rtl::OUString(), + aHelpText, + aPrintRangeName, + aChoices, + 0 ); + // create a an Edit dependent on "Pages" selected + m_aUIProperties[nIdx++].Value = getEditControlOpt( rtl::OUString(), + rtl::OUString(), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PageRange" ) ), + rtl::OUString(), + &aPrintRangeName, 1 + ); + + DBG_ASSERT( nIdx == nNumProps, "number of added properties is not as expected" ); } -- cgit From 7103e2b01f89fe217949cc20929dab00d277d44f Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Wed, 27 May 2009 17:41:13 +0000 Subject: print range changes, dependency UI --- sw/source/ui/uno/unotxdoc.cxx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'sw') diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index ab866e8d0194..0b5113611302 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -302,7 +302,9 @@ SwPrintUIOptions::SwPrintUIOptions( BOOL bWeb ) : aLocalizedStrings.GetString( 33 ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintBrochureRTL" ) ), sal_False, - &aBrochurePropertyName + &aBrochurePropertyName, + -1, + sal_True ); // create subgroup for misc options @@ -343,7 +345,7 @@ SwPrintUIOptions::SwPrintUIOptions( BOOL bWeb ) : rtl::OUString(), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PageRange" ) ), rtl::OUString(), - &aPrintRangeName, 1 + &aPrintRangeName, 1, sal_True ); -- cgit From a309b83c67d0d6cafa1471e901d37f2c3725c4b3 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Thu, 28 May 2009 16:52:32 +0000 Subject: #i96402# SetDuplexMode --- sw/source/core/view/vprint.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sw') diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index 740b06b39f7e..188ab5f78f78 100644 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -1373,7 +1373,7 @@ BOOL ViewShell::Prt( SwPrtOptions& rOptions, SfxProgress* pProgress, // we are have an odd page count in collation/duplex // mode and there are still some copies to print: if ( pPrt && ( 1 == ( nPagesPrinted % 2 ) ) && - DUPLEX_ON == pPrt->GetDuplexMode() && + ( DUPLEX_SHORTEDGE == pPrt->GetDuplexMode() || DUPLEX_LONGEDGE == pPrt->GetDuplexMode() ) && nCnt + 1 < nCopyCnt ) { pPrt->StartPage(); -- cgit From 5322b2a0c94772961310dc646a237df18cd20e6e Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Thu, 4 Jun 2009 08:23:53 +0000 Subject: #i101242# new print dialog UI --- sw/inc/unotxdoc.hxx | 2 +- sw/inc/viewsh.hxx | 11 +-- sw/source/core/doc/docdesc.cxx | 1 + sw/source/core/view/vnew.cxx | 8 +- sw/source/core/view/vprint.cxx | 190 +++++++++++++++++++++++----------------- sw/source/ui/app/docst.cxx | 1 + sw/source/ui/dbui/dbmgr.cxx | 4 +- sw/source/ui/uiview/pview.cxx | 2 +- sw/source/ui/uiview/viewprt.cxx | 2 +- sw/source/ui/uno/unotxdoc.cxx | 109 ++++++++++++++--------- 10 files changed, 199 insertions(+), 131 deletions(-) (limited to 'sw') diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx index a5d840c1ac2b..77369c7a4840 100644 --- a/sw/inc/unotxdoc.hxx +++ b/sw/inc/unotxdoc.hxx @@ -224,7 +224,7 @@ class SwXTextDocument : public SwXTextDocumentBaseClass, // used for XRenderable implementation SfxViewShell * GuessViewShell(); - SwDoc * GetRenderDoc( SfxViewShell *&rpView, const ::com::sun::star::uno::Any& rSelection ); + SwDoc * GetRenderDoc( SfxViewShell *&rpView, const ::com::sun::star::uno::Any& rSelection, bool bIsPDFExport ); rtl::OUString maBuildId; diff --git a/sw/inc/viewsh.hxx b/sw/inc/viewsh.hxx index d73db5d79e0b..e531485bd6ad 100644 --- a/sw/inc/viewsh.hxx +++ b/sw/inc/viewsh.hxx @@ -39,6 +39,7 @@ #include #include #include +#include namespace com { namespace sun { namespace star { namespace accessibility { class XAccessible; } } } } @@ -210,7 +211,7 @@ public: //Nach Druckerwechsel, vom Doc //pPDFOut != NULL is used for PDF export. - void InitPrt( SfxPrinter * , OutputDevice *pPDFOut = NULL ); + void InitPrt( /*TLPDF Printer * ,*/ OutputDevice *pOutDev /* = NULL */ ); //Klammerung von zusammengehoerenden Aktionen. inline void StartAction(); @@ -362,16 +363,16 @@ public: void ChgAllPageSize( Size &rSz ); //Druckauftrag abwickeln. - // pPDFOut != Null is: do PDF Export (no printing!) - sal_Bool Prt( SwPrtOptions& rOptions, SfxProgress* pProgress, - OutputDevice* pPDFOut = NULL ); + // bIsPDFExport == true is: do PDF Export (no printing!) + sal_Bool Prt( OutputDevice* pOutDev, SwPrtOptions& rOptions, SfxProgress* pProgress, + bool bIsPDFExport = false ); //"Drucken" fuer OLE 2.0 static void PrtOle2( SwDoc *pDoc, const SwViewOption *pOpt, SwPrtOptions& rOptions, OutputDevice* pOleOut, const Rectangle& rRect ); // creates temporary doc with selected text for PDF export - SwDoc * CreatePrtDoc( SfxPrinter* pPrt, SfxObjectShellRef& ); + SwDoc * CreatePrtDoc( /*Printer* pPrt,*/ SfxObjectShellRef& ); SwDoc * FillPrtDoc( SwDoc* pPrtDoc, const SfxPrinter* pPrt ); //Wird intern fuer die Shell gerufen die Druckt. Formatiert die Seiten. diff --git a/sw/source/core/doc/docdesc.cxx b/sw/source/core/doc/docdesc.cxx index 736447dad6b2..ed8ac98e6cec 100644 --- a/sw/source/core/doc/docdesc.cxx +++ b/sw/source/core/doc/docdesc.cxx @@ -39,6 +39,7 @@ #include "svx/frmdiritem.hxx" #include #include +#include #include #include #include diff --git a/sw/source/core/view/vnew.cxx b/sw/source/core/view/vnew.cxx index a270c6f78492..8a89691eec06 100644 --- a/sw/source/core/view/vnew.cxx +++ b/sw/source/core/view/vnew.cxx @@ -108,6 +108,8 @@ void ViewShell::Init( const SwViewOption *pNewOpt ) // --> FME 2007-11-06 #i82967# OutputDevice* pPDFOut = 0; +// TLPDF if ( pOut && pOut->GetPDFWriter() ) +// TLPDF pPDFOut = pOut; if ( pOut && pOut->GetPDFWriter() ) pPDFOut = pOut; // <-- @@ -119,8 +121,10 @@ void ViewShell::Init( const SwViewOption *pNewOpt ) const bool bCreatePrinter = !bBrowseMode && !pIDSA->get(IDocumentSettingAccess::USE_VIRTUAL_DEVICE); SfxPrinter* pPrinter = getIDocumentDeviceAccess()->getPrinter( bCreatePrinter ); - if( pPrinter ) - InitPrt( pPrinter, pPDFOut ); +// TLPDF if( pPrinter ) +// TLPDF InitPrt( pPrinter, pPDFOut ); + if( pPDFOut ) + InitPrt( pPDFOut ); // <-- // --> FME 2005-03-16 #i44963# Good occasion to check if page sizes in diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index 188ab5f78f78..ba9f7ceee657 100644 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -232,9 +232,10 @@ void SetSwVisArea( ViewShell *pSh, const SwRect &rRect, BOOL bPDFExport ) aPt += pSh->aPrtOffst; aPt.X() = -aPt.X(); aPt.Y() = -aPt.Y(); - OutputDevice *pOut = bPDFExport ? - pSh->GetOut() : - pSh->getIDocumentDeviceAccess()->getPrinter( false ); +// TLPDF OutputDevice *pOut = bPDFExport ? +// TLPDF pSh->GetOut() : +// TLPDF pSh->getIDocumentDeviceAccess()->getPrinter( false ); + OutputDevice *pOut = pSh->GetOut(); MapMode aMapMode( pOut->GetMapMode() ); aMapMode.SetOrigin( aPt ); @@ -518,23 +519,24 @@ void lcl_PrintPostItsEndPage( ViewShell* pPrtShell, } /****************************************************************************** - * Methode : void ViewShell::InitPrt( SfxPrinter *pNew, OutputDevice *pPDFOut ) + * Methode : void ViewShell::InitPrt( Printer *pNew, OutputDevice *pPDFOut ) * Beschreibung: * Erstellt : OK 07.11.94 10:22 * Aenderung : ******************************************************************************/ -void ViewShell::InitPrt( SfxPrinter *pPrt, OutputDevice *pPDFOut ) +void ViewShell::InitPrt( /*Printer *pPrt,*/ OutputDevice *pOutDev ) /* TLPDF */ { //Fuer den Printer merken wir uns einen negativen Offset, der //genau dem Offset de OutputSize entspricht. Das ist notwendig, //weil unser Ursprung der linken ober Ecke der physikalischen //Seite ist, die Ausgaben (SV) aber den Outputoffset als Urstprung //betrachten. - OutputDevice *pTmpDev = pPDFOut ? pPDFOut : (OutputDevice *) pPrt; + OutputDevice *pTmpDev = pOutDev; // TLPDF pPDFOut ? pPDFOut : (OutputDevice *) pPrt; if ( pTmpDev ) { - aPrtOffst = pPrt ? pPrt->GetPageOffset() : Point(); +// TLPDRF aPrtOffst = pPrt ? pPrt->GetPageOffset() : Point(); + aPrtOffst = Point(); aPrtOffst += pTmpDev->GetMapMode().GetOrigin(); MapMode aMapMode( pTmpDev->GetMapMode() ); @@ -745,7 +747,7 @@ void ViewShell::CalcPagesForPrint( USHORT nMax, SfxProgress* pProgress, /******************************************************************************/ -SwDoc * ViewShell::CreatePrtDoc( SfxPrinter* pPrt, SfxObjectShellRef &rDocShellRef) +SwDoc * ViewShell::CreatePrtDoc( /*Printer* pPrt,*/ SfxObjectShellRef &rDocShellRef) // TLPDF { ASSERT( this->IsA( TYPE(SwFEShell) ),"ViewShell::Prt for FEShell only"); SwFEShell* pFESh = (SwFEShell*)this; @@ -755,10 +757,11 @@ SwDoc * ViewShell::CreatePrtDoc( SfxPrinter* pPrt, SfxObjectShellRef &rDocShellR pPrtDoc->SetRefForDocShell( (SfxObjectShellRef*)&(long&)rDocShellRef ); pPrtDoc->LockExpFlds(); +/* TLPDF // Der Drucker wird uebernommen if (pPrt) pPrtDoc->setPrinter( pPrt, true, true ); - +*/ const SfxPoolItem* pCpyItem; const SfxItemPool& rPool = GetAttrPool(); for( USHORT nWh = POOLATTR_BEGIN; nWh < POOLATTR_END; ++nWh ) @@ -831,6 +834,7 @@ SwDoc * ViewShell::CreatePrtDoc( SfxPrinter* pPrt, SfxObjectShellRef &rDocShellR } return pPrtDoc; } + SwDoc * ViewShell::FillPrtDoc( SwDoc *pPrtDoc, const SfxPrinter* pPrt) { ASSERT( this->IsA( TYPE(SwFEShell) ),"ViewShell::Prt for FEShell only"); @@ -922,22 +926,23 @@ SwDoc * ViewShell::FillPrtDoc( SwDoc *pPrtDoc, const SfxPrinter* pPrt) } /****************************************************************************** - * Methode : void ViewShell::Prt( const SwPrtOptions& rOptions, - * SfxProgress* pProgress, - * OutputDevice* pPDFOut ) + * Methode : void ViewShell::Prt * Beschreibung: * Erstellt : OK 04.11.94 15:33 * Aenderung : MA 10. May. 95 ******************************************************************************/ -BOOL ViewShell::Prt( SwPrtOptions& rOptions, SfxProgress* pProgress, - OutputDevice* pPDFOut ) +BOOL ViewShell::Prt( + OutputDevice* pOutDev, + SwPrtOptions& rOptions, + SfxProgress* pProgress, + bool bIsPDFExport ) { //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! //Immer die Druckroutine in viewpg.cxx (fuer Seitenvorschau) mitpflegen!! //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - ASSERT( pPDFOut || pProgress, "Printing without progress bar!" ) + ASSERT( bIsPDFExport || pProgress, "Printing without progress bar!" ) BOOL bStartJob = FALSE; @@ -961,31 +966,31 @@ BOOL ViewShell::Prt( SwPrtOptions& rOptions, SfxProgress* pProgress, ASSERT( aPages.Min() <= aPages.Max(), "MinSeite groesser MaxSeite." ); - SfxPrinter* pPrt = 0; //!! will be 0 for PDF export !! - if (pPDFOut) - pPDFOut->Push(); + Printer* pPrt = 0; //!! will be 0 for PDF export !! /*TLPDF*/ + if (bIsPDFExport) + pOutDev->Push(); else { - // wenn kein Drucker vorhanden ist, wird nicht gedruckt - pPrt = getIDocumentDeviceAccess()->getPrinter( false ); - if( !pPrt || !pPrt->GetName().Len() ) +#ifdef TL_NOT_NOW /*TLPDF*/ +// pOutDev = dynamic_cast< Printer* >(pOutDev); + DBG_ASSERT( pOutDev, "printer missing" ); + if( !pOutDev || !pOutDev->GetName().Len() ) { ASSERT( FALSE, "Drucken ohne Drucker?" ); return bStartJob; } - if( !rOptions.GetJobName().Len() && !pPrt->IsJobActive() ) + if( !rOptions.GetJobName().Len() && !pOutDev->IsJobActive() ) return bStartJob; +#endif // TL_NOT_NOW /*TLPDF*/ } // Einstellungen am Drucker merken - SwPrtOptSave aPrtSave( pPrt ); - - OutputDevice *pPrtOrPDFOut = pPDFOut ? pPDFOut : (OutputDevice *) pPrt; +// SwPrtOptSave aPrtSave( pOutDev ); /*TLPDF ???*/ // eine neue Shell fuer den Printer erzeugen ViewShell *pShell; - SwDoc *pPrtDoc; + SwDoc *pOutDevDoc; //!! muss warum auch immer hier in diesem scope existieren !! //!! (h?ngt mit OLE Objekten im Dokument zusammen.) @@ -999,18 +1004,26 @@ BOOL ViewShell::Prt( SwPrtOptions& rOptions, SfxProgress* pProgress, // to be created that often here in the 'then' part. if ( bSelection ) { - pPrtDoc = CreatePrtDoc( pPrt, aDocShellRef ); + pOutDevDoc = CreatePrtDoc( /*TLPDF pOutDev,*/ aDocShellRef ); // eine ViewShell darauf - OutputDevice *pTmpDev = pPDFOut ? pPDFOut : 0; - pShell = new ViewShell( *pPrtDoc, 0, pOpt, pTmpDev ); - pPrtDoc->SetRefForDocShell( 0 ); +// TLPDF OutputDevice *pTmpDev = bIsPDFExport ? pOutDev : 0; +// TLPDF pShell = new ViewShell( *pOutDevDoc, 0, pOpt, pTmpDev ); + pShell = new ViewShell( *pOutDevDoc, 0, pOpt, pOutDev ); + pOutDevDoc->SetRefForDocShell( 0 ); } else { - pPrtDoc = GetDoc(); - OutputDevice *pTmpDev = pPDFOut ? pPDFOut : 0; - pShell = new ViewShell( *this, 0, pTmpDev ); + pOutDevDoc = GetDoc(); +// TLPDF OutputDevice *pTmpDev = bIsPDFExport ? pOutDev : 0; +// TLPDF pShell = new ViewShell( *this, 0, pTmpDev ); + pShell = new ViewShell( *this, 0, pOutDev ); + } + SdrView *pDrawView = pShell->GetDrawView(); + if (pDrawView) + { + pDrawView->SetBufferedOutputAllowed( false ); // TLPDF + pDrawView->SetBufferedOverlayAllowed( false ); // TLPDF } { //Zusaetzlicher Scope, damit die CurrShell vor dem zerstoeren der @@ -1018,11 +1031,13 @@ BOOL ViewShell::Prt( SwPrtOptions& rOptions, SfxProgress* pProgress, SET_CURR_SHELL( pShell ); +#ifdef TL_NOT_NOW /*TLPDF*/ if ( pProgress ) { - Link aLnk = LINK(pShell->Imp(), SwViewImp, SetStopPrt); + Link aLnk = LINK(pShell->Imp(), SwViewImp, SetStopOutDev); ((SfxPrintProgress *)pProgress)->SetCancelHdl(aLnk); } +#endif // TL_NOT_NOW /*TLPDF*/ //JP 01.02.99: das ReadOnly Flag wird NIE mitkopiert; Bug 61335 if( pOpt->IsReadonly() ) @@ -1064,12 +1079,14 @@ BOOL ViewShell::Prt( SwPrtOptions& rOptions, SfxProgress* pProgress, // --> FME 2004-06-21 #i9684# For performance reasons, we do not update // the fields during pdf export. // #i56195# prevent update of fields (for mail merge) - if ( !pPDFOut && rOptions.bUpdateFieldsInPrinting ) + if ( !bIsPDFExport && rOptions.bUpdateFieldsInPrinting ) // <-- pShell->UpdateFlds(TRUE); - if( !pShell->Imp()->IsStopPrt() && - ( pPDFOut || rOptions.GetJobName().Len() || pPrt->IsJobActive()) ) +// TLPDF if( !pShell->Imp()->IsStopOutDev() && +// TLPDF ( bIsPDFExport || rOptions.GetJobName().Len() || pOutDev->IsJobActive()) ) + if( /*!pShell->Imp()->IsStopOutDev() && */ + ( bIsPDFExport || rOptions.GetJobName().Len() /*TLPDF|| pOutDev->IsJobActive()*/) ) { BOOL bStop = FALSE; int nJobStartError = JOBSET_ERR_DEFAULT; @@ -1087,25 +1104,26 @@ BOOL ViewShell::Prt( SwPrtOptions& rOptions, SfxProgress* pProgress, USHORT nFirstPageNo = 0; USHORT nLastPageNo = 0; USHORT nPageNo = 1; - - if (pPrt) +#ifdef TL_NOT_NOW /*TLPDF*/ + if (pOutDev) { if( rOptions.IsPrintSingleJobs() && sJobName.Len() && ( bStartJob || rOptions.bJobStartet ) ) { - pPrt->EndJob(); + pOutDev->EndJob(); bStartJob = FALSE; rOptions.bJobStartet = TRUE; // Reschedule statt Yield, da Yield keine Events abarbeitet // und es sonst eine Endlosschleife gibt. - while( pPrt->IsPrinting() && pProgress ) + while( pOutDev->IsPrinting() && pProgress ) pProgress->Reschedule(); sJobName = rOptions.MakeNextJobName(); nJobStartError = JOBSET_ERR_DEFAULT; } } +#endif //TL_NOT_NOW /*TLPDF*/ for( USHORT i = 1; i <= (USHORT)aPages.Max(); ++i ) { @@ -1183,8 +1201,10 @@ BOOL ViewShell::Prt( SwPrtOptions& rOptions, SfxProgress* pProgress, { lcl_GetPostIts( pDoc, aPostItFields ); pPostItDoc = new SwDoc; - if (pPrt) - pPostItDoc->setPrinter( pPrt, true, true ); +/* TLPDF + if (pOutDev) + pPostItDoc->setPrinter( pOutDev, true, true ); +*/ pPostItShell = new ViewShell( *pPostItDoc, 0, pShell->GetViewOptions() ); // Wenn PostIts am Dokumentenende gedruckt werden sollen, @@ -1205,13 +1225,15 @@ BOOL ViewShell::Prt( SwPrtOptions& rOptions, SfxProgress* pProgress, BOOL bSetPaperSz = FALSE; BOOL bSetPaperBin = FALSE; BOOL bSetPrt = FALSE; - if (pPrt) + if (pOutDev) { - bSetOrient = pPrt->HasSupport( SUPPORT_SET_ORIENTATION ); - bSetPaperSz = pPrt->HasSupport( SUPPORT_SET_PAPERSIZE ); +#ifdef TL_NOT_NOW /*TLPDF*/ + bSetOrient = pOutDev->HasSupport( SUPPORT_SET_ORIENTATION ); + bSetPaperSz = pOutDev->HasSupport( SUPPORT_SET_PAPERSIZE ); bSetPaperBin = !rOptions.bPaperFromSetup && - pPrt->HasSupport( SUPPORT_SET_PAPERBIN ); + pOutDev->HasSupport( SUPPORT_SET_PAPERBIN ); bSetPrt = bSetOrient || bSetPaperSz || bSetPaperBin; +#endif // TL_NOT_NOW /*TLPDF*/ } if ( rOptions.nPrintPostIts != POSTITS_ONLY ) @@ -1231,28 +1253,30 @@ BOOL ViewShell::Prt( SwPrtOptions& rOptions, SfxProgress* pProgress, if ( pProgress ) pProgress->Reschedule(); - if (pPrt) +#ifdef TL_NOT_NOW /*TLPDF*/ + if (pOutDev) { if ( JOBSET_ERR_ERROR == nJobStartError || - ( !pPrt->IsJobActive() && ( !sJobName.Len() || bStartJob ) ) || - pShell->Imp()->IsStopPrt() ) + ( !pOutDev->IsJobActive() && ( !sJobName.Len() || bStartJob ) ) || + pShell->Imp()->IsStopOutDev() ) { bStop = TRUE; break; } } +#endif // TL_NOT_NOW /*TLPDF*/ - ::SetSwVisArea( pShell, pStPage->Frm(), 0 != pPDFOut ); + ::SetSwVisArea( pShell, pStPage->Frm(), bIsPDFExport ); // wenn wir einen Umschlag drucken wird ein Offset beachtet if( pStPage->GetFmt()->GetPoolFmtId() == RES_POOLPAGE_JAKET ) { - aOldMapMode = pPrtOrPDFOut->GetMapMode(); - Point aNewOrigin = pPrtOrPDFOut->GetMapMode().GetOrigin(); + aOldMapMode = pOutDev->GetMapMode(); + Point aNewOrigin = pOutDev->GetMapMode().GetOrigin(); aNewOrigin += rOptions.aOffset; - MapMode aTmp( pPrtOrPDFOut->GetMapMode() ); + MapMode aTmp( pOutDev->GetMapMode() ); aTmp.SetOrigin( aNewOrigin ); - pPrtOrPDFOut->SetMapMode( aTmp ); + pOutDev->SetMapMode( aTmp ); } const BOOL bRightPg = pStPage->OnRightPage(); @@ -1271,22 +1295,27 @@ BOOL ViewShell::Prt( SwPrtOptions& rOptions, SfxProgress* pProgress, const BOOL bLandScp = rFormatPage.GetPageDesc()->GetLandscape(); +#ifdef TL_NOT_NOW /*TLPDF*/ if( bSetPaperBin ) // Schacht einstellen. - pPrt->SetPaperBin( rFormatPage.GetFmt()-> + pOutDev->SetPaperBin( rFormatPage.GetFmt()-> GetPaperBin().GetValue() ); +#endif // TL_NOT_NOW /*TLPDF*/ if (bSetOrient ) { +#ifdef TL_NOT_NOW /*TLPDF*/ // Orientation einstellen: Breiter als Hoch // -> Landscape, sonst -> Portrait. if( bLandScp ) - pPrt->SetOrientation(ORIENTATION_LANDSCAPE); + pOutDev->SetOrientation(ORIENTATION_LANDSCAPE); else - pPrt->SetOrientation(ORIENTATION_PORTRAIT); + pOutDev->SetOrientation(ORIENTATION_PORTRAIT); +#endif // TL_NOT_NOW /*TLPDF*/ } if (bSetPaperSz ) { +#ifdef TL_NOT_NOW /*TLPDF*/ Size aSize = pStPage->Frm().SSize(); if ( bLandScp && bSetOrient ) { @@ -1299,9 +1328,10 @@ BOOL ViewShell::Prt( SwPrtOptions& rOptions, SfxProgress* pProgress, } Paper ePaper = SvxPaperInfo::GetSvPaper(aSize,MAP_TWIP,TRUE); if ( PAPER_USER == ePaper ) - pPrt->SetPaperSizeUser( aSize ); + pOutDev->SetPaperSizeUser( aSize ); else - pPrt->SetPaper( ePaper ); + pOutDev->SetPaper( ePaper ); +#endif // TL_NOT_NOW /*TLPDF*/ } } } @@ -1323,33 +1353,36 @@ BOOL ViewShell::Prt( SwPrtOptions& rOptions, SfxProgress* pProgress, if( !bStartJob && JOBSET_ERR_DEFAULT == nJobStartError && sJobName.Len() ) { - if( pPrt && !pPrt->IsJobActive() ) +#ifdef TL_NOT_NOW /*TLPDF*/ + if( pOutDev && !pOutDev->IsJobActive() ) { - bStartJob = pPrt->StartJob( sJobName ); + bStartJob = pOutDev->StartJob( sJobName ); if( !bStartJob ) { nJobStartError = JOBSET_ERR_ERROR; continue; } } +#endif // TL_NOT_NOW /*TLPDF*/ - pShell->InitPrt( pPrt, pPDFOut ); +// TLPDF pShell->InitPrt( pOutDev, bIsPDFExport ? pOutDev : 0 ); + pShell->InitPrt( pOutDev ); - ::SetSwVisArea( pShell, pStPage->Frm(), 0 != pPDFOut ); + ::SetSwVisArea( pShell, pStPage->Frm(), TRUE /*bIsPDFExport*/ ); // TLPDF nJobStartError = JOBSET_ERR_ISSTARTET; } // --> FME 2005-12-12 #b6354161# Feature - Print empty pages if ( rOptions.bPrintEmptyPages || pStPage->Frm().Height() ) // <-- { - if (pPrt) - pPrt->StartPage(); +// TLPDF if (pOutDev) +// TLPDF pOutDev->StartPage(); pStPage->GetUpper()->Paint( pStPage->Frm() ); ++nPagesPrinted; - if (pPrt) - pPrt->EndPage(); +// TLPDF if (pOutDev) +// TLPDF pOutDev->EndPage(); } SwPaintQueue::Repaint(); @@ -1365,10 +1398,11 @@ BOOL ViewShell::Prt( SwPrtOptions& rOptions, SfxProgress* pProgress, // den eventl. fuer Umschlaege modifizierte OutDevOffset wieder // zuruecksetzen. if( pStPage->GetFmt()->GetPoolFmtId() == RES_POOLPAGE_JAKET ) - pPrtOrPDFOut->SetMapMode( aOldMapMode ); + pOutDev->SetMapMode( aOldMapMode ); if ( pStPage == pEndPage ) { +#ifdef TL_NOT_NOW /*TLPDF*/ // --> FME 2005-01-05 #110536# Print emtpy page if // we are have an odd page count in collation/duplex // mode and there are still some copies to print: @@ -1376,11 +1410,11 @@ BOOL ViewShell::Prt( SwPrtOptions& rOptions, SfxProgress* pProgress, ( DUPLEX_SHORTEDGE == pPrt->GetDuplexMode() || DUPLEX_LONGEDGE == pPrt->GetDuplexMode() ) && nCnt + 1 < nCopyCnt ) { - pPrt->StartPage(); - pPrt->EndPage(); + pOutDev->StartPage(); + pOutDev->EndPage(); } // <-- - +#endif // TL_NOT_NOW /*TLPDF*/ pStPage = 0; } else if ( rOptions.bPrintReverse ) @@ -1425,15 +1459,15 @@ BOOL ViewShell::Prt( SwPrtOptions& rOptions, SfxProgress* pProgress, if (bSelection ) { // damit das Dokument nicht den Drucker mit ins Grab nimmt - pPrtDoc->setPrinter( 0, false, false ); + pOutDevDoc->setPrinter( 0, false, false ); - if ( !pPrtDoc->release() ) - delete pPrtDoc; + if ( !pOutDevDoc->release() ) + delete pOutDevDoc; } - // restore settings of OutputDevicef - if (pPDFOut) - pPDFOut->Pop(); + // restore settings of OutputDevice + if (bIsPDFExport) + pOutDev->Pop(); return bStartJob; } diff --git a/sw/source/ui/app/docst.cxx b/sw/source/ui/app/docst.cxx index cd98bb0cb554..9d624c2f5179 100644 --- a/sw/source/ui/app/docst.cxx +++ b/sw/source/ui/app/docst.cxx @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/ui/dbui/dbmgr.cxx b/sw/source/ui/dbui/dbmgr.cxx index bf6bef6959b3..17d2ad5ef31d 100644 --- a/sw/source/ui/dbui/dbmgr.cxx +++ b/sw/source/ui/dbui/dbmgr.cxx @@ -988,7 +988,7 @@ BOOL SwNewDBMgr::MergePrint( SwView& rView, bRet = TRUE; } } - else if( pSh->Prt( rOpt, &rProgress ) ) + else if( pSh->Prt( pPrt, rOpt, &rProgress ) ) /* TLPDF */ bRet = TRUE; bMergeLock = FALSE; @@ -1145,7 +1145,7 @@ BOOL SwNewDBMgr::MergePrintDocuments( SwView& rView, bRet = TRUE; } } - else if( pSh->Prt( rOpt, &rProgress ) ) + else if( pSh->Prt( pPrt, rOpt, &rProgress ) ) /* TLPDF */ bRet = TRUE; bMergeLock = FALSE; diff --git a/sw/source/ui/uiview/pview.cxx b/sw/source/ui/uiview/pview.cxx index 7c12f537761e..a9b36d255a23 100644 --- a/sw/source/ui/uiview/pview.cxx +++ b/sw/source/ui/uiview/pview.cxx @@ -2470,7 +2470,7 @@ USHORT SwPagePreView::Print( SfxProgress &rProgress, BOOL bIsAPI, PrintDialog * if( bPrtPros ) pSh->PrintProspect( aOpts, rProgress, bPrtPros_RTL ); else - pSh->Prt( aOpts, &rProgress ); + pSh->Prt( pPrinter, aOpts, &rProgress ); /*TLPDF*/ } else { diff --git a/sw/source/ui/uiview/viewprt.cxx b/sw/source/ui/uiview/viewprt.cxx index 6d219e71ab30..38e931b73826 100644 --- a/sw/source/ui/uiview/viewprt.cxx +++ b/sw/source/ui/uiview/viewprt.cxx @@ -392,7 +392,7 @@ ErrCode SwView::DoPrint( SfxPrinter *pPrinter, PrintDialog *pDlg, BOOL bSilent, pSh->PrintProspect( aOpts, *pProgress, bPrtPros_RTL ); } else - bStartJob = pSh->Prt( aOpts, pProgress ); + bStartJob = pSh->Prt( pPrinter, aOpts, pProgress ); /*TLPDF*/ if ( bBrowse ) { diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index 0b5113611302..f482c2436b0c 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -308,7 +309,7 @@ SwPrintUIOptions::SwPrintUIOptions( BOOL bWeb ) : ); // create subgroup for misc options - m_aUIProperties[ nIdx++ ].Value = getSubgroupControlOpt( aLocalizedStrings.GetString( 34 ), rtl::OUString() ); + m_aUIProperties[ nIdx++ ].Value = getSubgroupControlOpt( rtl::OUString( aLocalizedStrings.GetString( 34 ) ), rtl::OUString() ); // create a bool option for blank pages m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 35 ), @@ -2758,8 +2759,9 @@ SwViewOptionAdjust_Impl::~SwViewOptionAdjust_Impl() * SfxViewShell. */ -SwDoc * SwXTextDocument::GetRenderDoc( SfxViewShell *&rpView, const uno::Any& rSelection ) +SwDoc * SwXTextDocument::GetRenderDoc( SfxViewShell *&rpView, const uno::Any& rSelection, bool bIsPDFExport ) { + (void) bIsPDFExport; SwDoc *pDoc = 0; uno::Reference< frame::XModel > xModel; @@ -2768,6 +2770,11 @@ SwDoc * SwXTextDocument::GetRenderDoc( SfxViewShell *&rpView, const uno::Any& rS pDoc = pDocShell->GetDoc(); else { + // important check since GuessViewShell below should only get called for PDF export. + // Otherwise the View should be obtained from the "View" property passed on in the + // calls to the XRenderable functions. + DBG_ASSERT( bIsPDFExport, "code should have been called for PDF export only..." ); + // used for PDF export of (multi-)selection if (rSelection.hasValue()) // is anything selected ? { @@ -2812,18 +2819,19 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount( m_pPrintUIOptions = new SwPrintUIOptions( bWebDoc ); } bool bFormat = m_pPrintUIOptions->processPropertiesAndCheckFormat( rxOptions ); + const bool bIsPDFExport = !m_pPrintUIOptions->hasProperty( "IsPrinter" ); SfxViewShell *pView = 0; - SwDoc *pDoc = GetRenderDoc( pView, rSelection ); + SwDoc *pDoc = GetRenderDoc( pView, rSelection, bIsPDFExport ); if (!pDoc) throw RuntimeException(); SwDocShell *pRenderDocShell = pDoc->GetDocShell(); - // #i38289 - if(pDoc->get(IDocumentSettingAccess::BROWSE_MODE)) - { - pRenderDocShell->ToggleBrowserMode(false,NULL); - } + // #i38289 + if(pDoc->get(IDocumentSettingAccess::BROWSE_MODE) /*TLPDF for printing as well?*/) + { + pRenderDocShell->ToggleBrowserMode(false,NULL); + } SwWrtShell *pWrtShell = pRenderDocShell->GetWrtShell(); @@ -2839,12 +2847,16 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount( SwViewOptionAdjust_Impl aAdjust(*pWrtShell); if( bFormat ) { - pWrtShell->SetPDFExportOption( sal_True ); + if (bIsPDFExport) + pWrtShell->SetPDFExportOption( sal_True ); + // --> FME 2005-05-23 #122919# Force field update before PDF export: pWrtShell->ViewShell::UpdateFlds(TRUE); // <-- pWrtShell->CalcLayout(); - pWrtShell->SetPDFExportOption( sal_False ); + + if (bIsPDFExport) + pWrtShell->SetPDFExportOption( sal_False ); } nRet = pDoc->GetPageCount(); @@ -2868,9 +2880,11 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SwXTextDocument::getRenderer( const BOOL bWebDoc = (0 != PTR_CAST(SwWebDocShell, pDocShell)); m_pPrintUIOptions = new SwPrintUIOptions( bWebDoc ); } + m_pPrintUIOptions->processProperties( rxOptions ); + const bool bIsPDFExport = !m_pPrintUIOptions->hasProperty( "IsPrinter" ); SfxViewShell *pView = 0; - SwDoc *pDoc = GetRenderDoc( pView, rSelection ); + SwDoc *pDoc = GetRenderDoc( pView, rSelection, bIsPDFExport ); if (!pDoc) throw RuntimeException(); @@ -2882,13 +2896,7 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SwXTextDocument::getRenderer( if (nRenderer >= pDoc->GetPageCount()) return uno::Sequence< beans::PropertyValue >(); - bool bSkipEmptyPages = false; - for( sal_Int32 nProperty = 0, nPropertyCount = rxOptions.getLength(); nProperty < nPropertyCount; ++nProperty ) - { - if( rxOptions[ nProperty ].Name == OUString( RTL_CONSTASCII_USTRINGPARAM( "IsSkipEmptyPages" ) ) ) - rxOptions[ nProperty].Value >>= bSkipEmptyPages; - } - + bool bSkipEmptyPages = m_pPrintUIOptions->getBoolValue( "IsSkipEmptyPages", sal_False ); Size aPgSize( pDoc->GetPageSize( sal_uInt16(nRenderer + 1), bSkipEmptyPages ) ); awt::Size aPageSize( TWIP_TO_MM100( aPgSize.Width() ), @@ -2941,8 +2949,31 @@ void SAL_CALL SwXTextDocument::render( if(!IsValid()) throw RuntimeException(); - SfxViewShell *pView = GuessViewShell(); - SwDoc *pDoc = GetRenderDoc( pView, rSelection ); + if (!m_pPrintUIOptions) + { + const BOOL bWebDoc = (0 != PTR_CAST(SwWebDocShell, pDocShell)); + m_pPrintUIOptions = new SwPrintUIOptions( bWebDoc ); + } + m_pPrintUIOptions->processProperties( rxOptions ); + const bool bIsPDFExport = !m_pPrintUIOptions->hasProperty( "IsPrinter" ); + + // get view shell to use + SfxViewShell *pView = 0; + if (bIsPDFExport) + pView = GuessViewShell(); + else + { + uno::Any aTmp( m_pPrintUIOptions->getValue( C2U("View") ) ); + uno::Reference< frame::XController > xController; + if (aTmp >>= xController) + { + const SfxBaseController *pController = dynamic_cast< const SfxBaseController * >( xController.get() ); + pView = pController ? pController->GetViewShell_Impl() : 0; + } + } + + SwDoc *pDoc = GetRenderDoc( pView, rSelection, bIsPDFExport ); + if (!pDoc || !pView) throw RuntimeException(); @@ -2967,7 +2998,6 @@ void SAL_CALL SwXTextDocument::render( bool bLastPage = false; rtl::OUString aPages; bool bSkipEmptyPages = false; - for( sal_Int32 nProperty = 0, nPropertyCount = rxOptions.getLength(); nProperty < nPropertyCount; ++nProperty ) { if( rxOptions[ nProperty ].Name == OUString( RTL_CONSTASCII_USTRINGPARAM( "RenderDevice" ) ) ) @@ -2991,13 +3021,6 @@ void SAL_CALL SwXTextDocument::render( if(pVwSh && pOut) { - if (!m_pPrintUIOptions) - { - const BOOL bWebDoc = (0 != PTR_CAST(SwWebDocShell, pDocShell)); - m_pPrintUIOptions = new SwPrintUIOptions( bWebDoc ); - } - m_pPrintUIOptions->processProperties( rxOptions ); - SwPrtOptions aOptions( C2U("PDF export") ); // get print options to use from provided properties @@ -3031,14 +3054,14 @@ void SAL_CALL SwXTextDocument::render( //! document is created that contains only the selects parts, //! and thus that document is to printed in whole the, //! aOptions.bPrintSelection parameter will be false. - if (!m_pPrintUIOptions->getBoolValue( C2U( "IsPrinter" ), sal_False ) ) // PDF export? + if (bIsPDFExport) aOptions.bPrintSelection = FALSE; SwViewOptionAdjust_Impl* pViewOptionAdjust = pView->IsA(aSwViewTypeId) ? new SwViewOptionAdjust_Impl(*((SwView*)pView)->GetWrtShellPtr()) : 0; - - pVwSh->SetPDFExportOption( sal_True ); + if (bIsPDFExport) + pVwSh->SetPDFExportOption( sal_True ); // --> FME 2004-06-08 #i12836# enhanced pdf export // @@ -3050,13 +3073,14 @@ void SAL_CALL SwXTextDocument::render( ((SwView*)pView)->GetWrtShellPtr() : 0; - if ( bFirstPage && pWrtShell ) + if (bIsPDFExport && bFirstPage && pWrtShell) /*TLPDF*/ { SwEnhancedPDFExportHelper aHelper( *pWrtShell, *pOut, aPages, bSkipEmptyPages, sal_False ); } // <-- - pVwSh->Prt( aOptions, 0, pOut ); + OutputDevice *pOldDev = pVwSh->GetOut(); // TLPDF + pVwSh->Prt( pOut, aOptions, 0, bIsPDFExport ); // --> FME 2004-10-08 #i35176# // @@ -3064,25 +3088,28 @@ void SAL_CALL SwXTextDocument::render( // from the EditEngine. The links are generated during the painting // process, but the destinations are still missing. // - if ( bLastPage && pWrtShell ) + if (bIsPDFExport && bLastPage && pWrtShell) /*TLPDF*/ { SwEnhancedPDFExportHelper aHelper( *pWrtShell, *pOut, aPages, bSkipEmptyPages, sal_True ); } // <-- - pVwSh->SetPDFExportOption( sal_False ); + if (bIsPDFExport) + pVwSh->SetPDFExportOption( sal_False ); + // #i96167# haggai: delete pViewOptionsAdjust here because it makes use // of the shell, which might get destroyed in lcl_DisposeView! delete pViewOptionAdjust; - if( bLastPage && m_pHiddenViewFrame) + if (bLastPage) { - lcl_DisposeView( m_pHiddenViewFrame, pDocShell ); - m_pHiddenViewFrame = 0; - } - - if( bLastPage ) + if (m_pHiddenViewFrame) + { + lcl_DisposeView( m_pHiddenViewFrame, pDocShell ); + m_pHiddenViewFrame = 0; + } delete m_pPrintUIOptions, m_pPrintUIOptions = NULL; + } } } /* -----------------------------03.10.04 ------------------------------------- -- cgit From 73220d96bca7cb760051144a5ea731119287d9f1 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Thu, 4 Jun 2009 09:53:01 +0000 Subject: removed warnings --- sw/source/core/view/vnew.cxx | 6 +++--- sw/source/core/view/vprint.cxx | 6 +++++- sw/source/ui/uno/unotxdoc.cxx | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) (limited to 'sw') diff --git a/sw/source/core/view/vnew.cxx b/sw/source/core/view/vnew.cxx index 8a89691eec06..f5a132284021 100644 --- a/sw/source/core/view/vnew.cxx +++ b/sw/source/core/view/vnew.cxx @@ -118,9 +118,9 @@ void ViewShell::Init( const SwViewOption *pNewOpt ) // Only setup the printer if we need one: const IDocumentSettingAccess* pIDSA = getIDocumentSettingAccess(); const bool bBrowseMode = pIDSA->get(IDocumentSettingAccess::BROWSE_MODE); - const bool bCreatePrinter = !bBrowseMode && - !pIDSA->get(IDocumentSettingAccess::USE_VIRTUAL_DEVICE); - SfxPrinter* pPrinter = getIDocumentDeviceAccess()->getPrinter( bCreatePrinter ); +// TLPDF const bool bCreatePrinter = !bBrowseMode && +// TLPDF !pIDSA->get(IDocumentSettingAccess::USE_VIRTUAL_DEVICE); +// TLPDF SfxPrinter* pPrinter = getIDocumentDeviceAccess()->getPrinter( bCreatePrinter ); // TLPDF if( pPrinter ) // TLPDF InitPrt( pPrinter, pPDFOut ); if( pPDFOut ) diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index ba9f7ceee657..e04e898d17c2 100644 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -966,7 +966,9 @@ BOOL ViewShell::Prt( ASSERT( aPages.Min() <= aPages.Max(), "MinSeite groesser MaxSeite." ); +#ifdef TL_NOT_NOW /*TLPDF*/ Printer* pPrt = 0; //!! will be 0 for PDF export !! /*TLPDF*/ +#endif // TL_NOT_NOW /*TLPDF*/ if (bIsPDFExport) pOutDev->Push(); else @@ -1223,7 +1225,9 @@ BOOL ViewShell::Prt( const SwPageDesc *pLastPageDesc = NULL; BOOL bSetOrient = FALSE; BOOL bSetPaperSz = FALSE; +#ifdef TL_NOT_NOW /*TLPDF*/ BOOL bSetPaperBin = FALSE; +#endif // TL_NOT_NOW /*TLPDF*/ BOOL bSetPrt = FALSE; if (pOutDev) { @@ -1293,9 +1297,9 @@ BOOL ViewShell::Prt( { pLastPageDesc = rFormatPage.GetPageDesc(); +#ifdef TL_NOT_NOW /*TLPDF*/ const BOOL bLandScp = rFormatPage.GetPageDesc()->GetLandscape(); -#ifdef TL_NOT_NOW /*TLPDF*/ if( bSetPaperBin ) // Schacht einstellen. pOutDev->SetPaperBin( rFormatPage.GetFmt()-> GetPaperBin().GetValue() ); diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index f482c2436b0c..6cf2f20d7503 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -3079,7 +3079,7 @@ void SAL_CALL SwXTextDocument::render( } // <-- - OutputDevice *pOldDev = pVwSh->GetOut(); // TLPDF + // TLPDF OutputDevice *pOldDev = pVwSh->GetOut(); // TLPDF pVwSh->Prt( pOut, aOptions, 0, bIsPDFExport ); // --> FME 2004-10-08 #i35176# -- cgit From c8bc5be2dca2dbe7e9cba1c9027f2c97076e8374 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Thu, 11 Jun 2009 17:26:10 +0000 Subject: make compile again, needs adaption ? --- sw/source/core/view/viewpg.cxx | 19 +++++++++++++++++-- sw/source/core/view/vprint.cxx | 10 +++++++++- sw/source/ui/dbui/dbmgr.cxx | 8 +++++++- sw/source/ui/uiview/srcview.cxx | 7 ++++++- sw/source/ui/uiview/viewprt.cxx | 7 ++++++- 5 files changed, 45 insertions(+), 6 deletions(-) (limited to 'sw') diff --git a/sw/source/core/view/viewpg.cxx b/sw/source/core/view/viewpg.cxx index cad53470e95b..7051b58aa1dd 100644 --- a/sw/source/core/view/viewpg.cxx +++ b/sw/source/core/view/viewpg.cxx @@ -150,7 +150,9 @@ void ViewShell::PrintPreViewPage( SwPrtOptions& rOptions, if( rOptions.IsPrintSingleJobs() && rOptions.GetJobName().Len() && ( bStartJob || rOptions.bJobStartet ) ) { +#ifdef TL_NOT_NOW /*TLPDF*/ pPrt->EndJob(); +#endif rOptions.bJobStartet = TRUE; // Reschedule statt Yield, da Yield keine Events abarbeitet @@ -159,7 +161,9 @@ void ViewShell::PrintPreViewPage( SwPrtOptions& rOptions, rProgress.Reschedule(); rOptions.MakeNextJobName(); - bStartJob = pPrt->StartJob( rOptions.GetJobName() ); +#ifdef TL_NOT_NOW /*TLPDF*/ + // bStartJob = pPrt->StartJob( rOptions.GetJobName() ); +#endif } const SwPageFrm *pStPage = (SwPageFrm*)GetLayout()->Lower(); @@ -340,7 +344,9 @@ void ViewShell::PrintPreViewPage( SwPrtOptions& rOptions, // dann kann das drucken losgehen rProgress.SetState( nPrintCount++, nSelCount ); +#ifdef TL_NOT_NOW /*TLPDF*/ pPrt->StartPage(); +#endif Point aCalcPt; SwPageFrm** ppTmpPg = aPageArr; @@ -401,7 +407,9 @@ void ViewShell::PrintPreViewPage( SwPrtOptions& rOptions, } aCalcPt.Y() += nVOffs + nPageHeight; } +#ifdef TL_NOT_NOW /*TLPDF*/ pPrt->EndPage(); +#endif SwPaintQueue::Repaint(); memset( aPageArr, 0, sizeof( SwPageFrm* ) * nPages ); @@ -569,7 +577,9 @@ void ViewShell::PrintProspect( SwPrtOptions& rOptions, if( rOptions.IsPrintSingleJobs() && rOptions.GetJobName().Len() && ( bStartJob || rOptions.bJobStartet ) ) { +#ifdef TL_NOT_NOW /*TLPDF*/ pPrt->EndJob(); +#endif rOptions.bJobStartet = TRUE; // Reschedule statt Yield, da Yield keine Events abarbeitet @@ -578,7 +588,8 @@ void ViewShell::PrintProspect( SwPrtOptions& rOptions, rProgress.Reschedule(); rOptions.MakeNextJobName(); - bStartJob = pPrt->StartJob( rOptions.GetJobName() ); + DBG_ERROR( "StartJob does not exist anymore" ); + // bStartJob = pPrt->StartJob( rOptions.GetJobName() ); } // dann sorge mal dafuer, das alle Seiten in der richtigen @@ -714,7 +725,9 @@ void ViewShell::PrintProspect( SwPrtOptions& rOptions, bStartJob = TRUE; rProgress.SetState( nPrintCount, nCntPage ); +#ifdef TL_NOT_NOW /*TLPDF*/ pPrt->StartPage(); +#endif Point aSttPt; for( int nC = 0; nC < 2; ++nC ) @@ -736,7 +749,9 @@ void ViewShell::PrintProspect( SwPrtOptions& rOptions, aSttPt.X() += aTmpPrtSize.Width() / 2; } +#ifdef TL_NOT_NOW /*TLPDF*/ pPrt->EndPage(); +#endif SwPaintQueue::Repaint(); nSPg = nSPg + nStep; nEPg = nEPg - nStep; diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index e04e898d17c2..e31da015f01f 100644 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -381,6 +381,7 @@ void lcl_FormatPostIt( IDocumentContentOperations* pIDCO, SwPaM& aPam, SwPostItF void lcl_PrintPostIts( ViewShell* pPrtShell, const XubString& rJobName, BOOL& rStartJob, int& rJobStartError, BOOL bReverse) { +#ifdef TL_NOT_NOW /*TLPDF*/ // Formatieren und Ausdrucken pPrtShell->CalcLayout(); @@ -427,6 +428,13 @@ void lcl_PrintPostIts( ViewShell* pPrtShell, const XubString& rJobName, pPrn->EndPage(); pPage = bReverse ? pPage->GetPrev() : pPage->GetNext(); } + #else + (void)pPrtShell; + (void)rJobName; + (void)rStartJob; + (void)rJobStartError; + (void)bReverse; + #endif } /****************************************************************************** @@ -934,7 +942,7 @@ SwDoc * ViewShell::FillPrtDoc( SwDoc *pPrtDoc, const SfxPrinter* pPrt) BOOL ViewShell::Prt( - OutputDevice* pOutDev, + OutputDevice* pOutDev, SwPrtOptions& rOptions, SfxProgress* pProgress, bool bIsPDFExport ) diff --git a/sw/source/ui/dbui/dbmgr.cxx b/sw/source/ui/dbui/dbmgr.cxx index d123dec5e0dd..f64d0e0b4512 100644 --- a/sw/source/ui/dbui/dbmgr.cxx +++ b/sw/source/ui/dbui/dbmgr.cxx @@ -976,12 +976,14 @@ BOOL SwNewDBMgr::MergePrint( SwView& rView, bMergeLock = TRUE; if(rOpt.IsPrintProspect()) { +#ifdef TL_NOT_NOW /*TLPDF*/ if( ! pPrt->IsJobActive() ) { pPrt->SetJobValue( String( RTL_CONSTASCII_USTRINGPARAM( "IsQuickJob" ) ), String( RTL_CONSTASCII_USTRINGPARAM( "true" ) ) ); pPrt->StartJob( rOpt.GetJobName() ); } +#endif if( pPrt->IsJobActive() ) { pSh->PrintProspect( rOpt, rProgress, rOpt.IsPrintProspect_RTL() ); @@ -1139,7 +1141,11 @@ BOOL SwNewDBMgr::MergePrintDocuments( SwView& rView, bMergeLock = TRUE; if(rOpt.IsPrintProspect()) { - if( pPrt->IsJobActive() || pPrt->StartJob( rOpt.GetJobName() )) + if( pPrt->IsJobActive() +#ifdef TL_NOT_NOW /*TLPDF*/ + || pPrt->StartJob( rOpt.GetJobName() ) +#endif + ) { pSh->PrintProspect( rOpt, rProgress, rOpt.IsPrintProspect_RTL() ); bRet = TRUE; diff --git a/sw/source/ui/uiview/srcview.cxx b/sw/source/ui/uiview/srcview.cxx index 7898e4db1cb2..72a99e79240e 100644 --- a/sw/source/ui/uiview/srcview.cxx +++ b/sw/source/ui/uiview/srcview.cxx @@ -753,8 +753,9 @@ USHORT SwSrcView::SetPrinter(SfxPrinter* pNew, USHORT nDiffFlags, bool ) Beschreibung: --------------------------------------------------------------------*/ -ErrCode SwSrcView::DoPrint( SfxPrinter *pPrinter, PrintDialog *pDlg, BOOL bSilent, BOOL bIsAPI ) +ErrCode SwSrcView::DoPrint( SfxPrinter */*pPrinter*/, PrintDialog */*pDlg*/, BOOL /*bSilent*/, BOOL /*bIsAPI*/ ) { + #if 0 SfxPrintProgress *pProgress = new SfxPrintProgress( this, !bSilent ); SfxPrinter *pDocPrinter = GetPrinter(TRUE); if ( !pPrinter ) @@ -845,6 +846,10 @@ ErrCode SwSrcView::DoPrint( SfxPrinter *pPrinter, PrintDialog *pDlg, BOOL bSilen pProgress->DeleteOnEndPrint(); pPrinter->EndJob(); return pPrinter->GetError(); + #else + DBG_ERROR( "dead code" ); + return ERRCODE_IO_NOTSUPPORTED; + #endif } /*-------------------------------------------------------------------- diff --git a/sw/source/ui/uiview/viewprt.cxx b/sw/source/ui/uiview/viewprt.cxx index 38e931b73826..23f952b5bcf1 100644 --- a/sw/source/ui/uiview/viewprt.cxx +++ b/sw/source/ui/uiview/viewprt.cxx @@ -174,8 +174,9 @@ USHORT __EXPORT SwView::SetPrinter(SfxPrinter* pNew, USHORT nDiffFlags, bool ) Beschreibung: --------------------------------------------------------------------*/ -ErrCode SwView::DoPrint( SfxPrinter *pPrinter, PrintDialog *pDlg, BOOL bSilent, BOOL bIsAPI ) +ErrCode SwView::DoPrint( SfxPrinter */*pPrinter*/, PrintDialog */*pDlg*/, BOOL /*bSilent*/, BOOL /*bIsAPI*/ ) { + #if 0 // First test SwWrtShell* pSh = &GetWrtShell(); SwNewDBMgr* pMgr = pSh->GetNewDBMgr(); @@ -434,6 +435,10 @@ ErrCode SwView::DoPrint( SfxPrinter *pPrinter, PrintDialog *pDlg, BOOL bSilent, pProgress->DeleteOnEndPrint(); pPrinter->EndJob(); return pPrinter->GetError(); + #else + DBG_ERROR( "dead code" ); + return ERRCODE_IO_NOTSUPPORTED; + #endif } -- cgit From 3269764069d16788c2534655e7900bf5606d6aa7 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Fri, 12 Jun 2009 15:22:27 +0000 Subject: #i92516# remove old StartPage/EndPage API --- sw/source/ui/dbui/dbmgr.cxx | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'sw') diff --git a/sw/source/ui/dbui/dbmgr.cxx b/sw/source/ui/dbui/dbmgr.cxx index f64d0e0b4512..0f7c203195be 100644 --- a/sw/source/ui/dbui/dbmgr.cxx +++ b/sw/source/ui/dbui/dbmgr.cxx @@ -904,9 +904,11 @@ BOOL SwNewDBMgr::MergePrint( SwView& rView, pModOpt->SetSinglePrintJob(rOpt.IsPrintSingleJobs()); SfxPrinter *pPrt = pSh->getIDocumentDeviceAccess()->getPrinter( false ); +#ifdef TL_NOT_NOW /*TLPDF*/ Link aSfxSaveLnk = pPrt->GetEndPrintHdl(); if( rOpt.IsPrintSingleJobs() ) pPrt->SetEndPrintHdl( Link() ); +#endif BOOL bUserBreak = FALSE, bRet = FALSE; @@ -1009,6 +1011,7 @@ BOOL SwNewDBMgr::MergePrint( SwView& rView, nEndRow = pImpl->pMergeData ? pImpl->pMergeData->xResultSet->getRow() : 0; } while( bSynchronizedDoc && (nStartRow != nEndRow)? ExistsNextRecord() : ToNextMergeRecord()); +#ifdef TL_NOT_NOW /*TLPDF*/ if( rOpt.IsPrintSingleJobs() ) { SfxPrinter* pTmpPrinter = pSh->getIDocumentDeviceAccess()->getPrinter( true ); @@ -1016,6 +1019,7 @@ BOOL SwNewDBMgr::MergePrint( SwView& rView, if ( !bUserBreak && !pTmpPrinter->IsJobActive() ) //Schon zu spaet? aSfxSaveLnk.Call( pTmpPrinter ); } +#endif rOpt.nMergeCnt = 0; rOpt.nMergeAct = 0; @@ -1048,9 +1052,11 @@ BOOL SwNewDBMgr::MergePrintDocuments( SwView& rView, rOpt.SetPrintSingleJobs( sal_True ); SfxPrinter *pPrt = pSh->getIDocumentDeviceAccess()->getPrinter( false ); +#ifdef TL_NOT_NOW /*TLPDF*/ Link aSfxSaveLnk = pPrt->GetEndPrintHdl(); if( rOpt.IsPrintSingleJobs() ) pPrt->SetEndPrintHdl( Link() ); +#endif BOOL bUserBreak = FALSE, bRet = FALSE; @@ -1168,6 +1174,7 @@ BOOL SwNewDBMgr::MergePrintDocuments( SwView& rView, } } +#ifdef TL_NOT_NOW /*TLPDF*/ if( rOpt.IsPrintSingleJobs() ) { SfxPrinter* pTmpPrinter = pSh->getIDocumentDeviceAccess()->getPrinter( true ); @@ -1175,6 +1182,7 @@ BOOL SwNewDBMgr::MergePrintDocuments( SwView& rView, if ( !bUserBreak && !pTmpPrinter->IsJobActive() ) //Schon zu spaet? aSfxSaveLnk.Call( pTmpPrinter ); } +#endif rOpt.nMergeCnt = 0; rOpt.nMergeAct = 0; -- cgit From f3cbe8e3d4097f79b33db3a9678ad475385ec425 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Mon, 15 Jun 2009 08:53:01 +0000 Subject: remove a warning --- sw/source/ui/uiview/viewprt.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sw') diff --git a/sw/source/ui/uiview/viewprt.cxx b/sw/source/ui/uiview/viewprt.cxx index 23f952b5bcf1..a6faae1894da 100644 --- a/sw/source/ui/uiview/viewprt.cxx +++ b/sw/source/ui/uiview/viewprt.cxx @@ -174,7 +174,7 @@ USHORT __EXPORT SwView::SetPrinter(SfxPrinter* pNew, USHORT nDiffFlags, bool ) Beschreibung: --------------------------------------------------------------------*/ -ErrCode SwView::DoPrint( SfxPrinter */*pPrinter*/, PrintDialog */*pDlg*/, BOOL /*bSilent*/, BOOL /*bIsAPI*/ ) +ErrCode SwView::DoPrint( SfxPrinter* /*pPrinter*/, PrintDialog* /*pDlg*/, BOOL /*bSilent*/, BOOL /*bIsAPI*/ ) { #if 0 // First test -- cgit From ed4721887cd14279f5de473fac41ba8b9df12a7d Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Mon, 15 Jun 2009 18:03:16 +0000 Subject: solve a warning --- sw/source/ui/uiview/srcview.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sw') diff --git a/sw/source/ui/uiview/srcview.cxx b/sw/source/ui/uiview/srcview.cxx index 72a99e79240e..fdbfb6a8309b 100644 --- a/sw/source/ui/uiview/srcview.cxx +++ b/sw/source/ui/uiview/srcview.cxx @@ -753,7 +753,7 @@ USHORT SwSrcView::SetPrinter(SfxPrinter* pNew, USHORT nDiffFlags, bool ) Beschreibung: --------------------------------------------------------------------*/ -ErrCode SwSrcView::DoPrint( SfxPrinter */*pPrinter*/, PrintDialog */*pDlg*/, BOOL /*bSilent*/, BOOL /*bIsAPI*/ ) +ErrCode SwSrcView::DoPrint( SfxPrinter * /*pPrinter*/, PrintDialog * /*pDlg*/, BOOL /*bSilent*/, BOOL /*bIsAPI*/ ) { #if 0 SfxPrintProgress *pProgress = new SfxPrintProgress( this, !bSilent ); -- cgit From 2d2f137008a6f2599acd43f59f8b169075fa6f11 Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Tue, 16 Jun 2009 10:00:34 +0000 Subject: #i101242# build problems fixed; XUNoTunnel added to SwXTextView --- sw/inc/dbgoutsw.hxx | 4 ++-- sw/source/ui/inc/unotxvw.hxx | 6 ++++++ sw/source/ui/uno/unotxdoc.cxx | 12 ++++++++++-- sw/source/ui/uno/unotxvw.cxx | 25 +++++++++++++++++++++++++ 4 files changed, 43 insertions(+), 4 deletions(-) (limited to 'sw') diff --git a/sw/inc/dbgoutsw.hxx b/sw/inc/dbgoutsw.hxx index 329c81b7fb38..26dc49d1fa27 100644 --- a/sw/inc/dbgoutsw.hxx +++ b/sw/inc/dbgoutsw.hxx @@ -118,7 +118,7 @@ const char * dbg_out(const std::hash_map & rMap) { return dbg_out(lcl_dbg_out(rMap)); } -const char * dbg_out(const SwFormToken & rToken); -const char * dbg_out(const SwFormTokens & rTokens); +SW_DLLPUBLIC const char * dbg_out(const SwFormToken & rToken); +SW_DLLPUBLIC const char * dbg_out(const SwFormTokens & rTokens); #endif // DEBUG #endif // __DBGOUTSW_HXX diff --git a/sw/source/ui/inc/unotxvw.hxx b/sw/source/ui/inc/unotxvw.hxx index 4db18720cf87..794371499186 100644 --- a/sw/source/ui/inc/unotxvw.hxx +++ b/sw/source/ui/inc/unotxvw.hxx @@ -72,6 +72,7 @@ class SwXTextView : public ::com::sun::star::view::XViewSettingsSupplier, public ::com::sun::star::beans::XPropertySet, public ::com::sun::star::datatransfer::XTransferableSupplier, + public ::com::sun::star::lang::XUnoTunnel, public SfxBaseController { SelectionChangeListenerArr aSelChangedListeners; @@ -152,6 +153,11 @@ public: virtual ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > SAL_CALL getTransferable( ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL insertTransferable( const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& xTrans ) throw (::com::sun::star::datatransfer::UnsupportedFlavorException, ::com::sun::star::uno::RuntimeException); + // XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); + + static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId(); + void NotifySelChanged(); void NotifyDBChanged(); diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index e1218b9c8d9e..a71f1f9f8a27 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -70,6 +70,7 @@ #include #include #include +#include #include #include #include @@ -2962,8 +2963,15 @@ void SAL_CALL SwXTextDocument::render( uno::Reference< frame::XController > xController; if (aTmp >>= xController) { - const SfxBaseController *pController = dynamic_cast< const SfxBaseController * >( xController.get() ); - pView = pController ? pController->GetViewShell_Impl() : 0; + uno::Reference< lang::XUnoTunnel > xTunnel( xController, uno::UNO_QUERY ); + if (xTunnel.is()) + { + SwXTextView *pTextView = reinterpret_cast< SwXTextView * >( + sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething( SwXTextView::getUnoTunnelId()) )); + if (pTextView) + pView = pTextView->GetView(); + } + } } diff --git a/sw/source/ui/uno/unotxvw.cxx b/sw/source/ui/uno/unotxvw.cxx index eaba514a6e6a..2f3bb43fcb78 100644 --- a/sw/source/ui/uno/unotxvw.cxx +++ b/sw/source/ui/uno/unotxvw.cxx @@ -295,6 +295,11 @@ uno::Any SAL_CALL SwXTextView::queryInterface( const uno::Type& aType ) uno::Reference xRet = this; aRet.setValue(&xRet, aType); } + else if(aType == ::getCppuType((uno::Reference*)0)) + { + uno::Reference xRet = this; + aRet.setValue(&xRet, aType); + } else aRet = SfxBaseController::queryInterface(aType); return aRet; @@ -2216,5 +2221,25 @@ void SAL_CALL SwXTextView::insertTransferable( const uno::Reference< datatransfe } } } + +const uno::Sequence< sal_Int8 > & SwXTextView::getUnoTunnelId() +{ + static uno::Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId(); + return aSeq; +} + +sal_Int64 SAL_CALL SwXTextView::getSomething( + const uno::Sequence< sal_Int8 >& rId ) +throw(uno::RuntimeException) +{ + if( rId.getLength() == 16 + && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), + rId.getConstArray(), 16 ) ) + { + return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >( this )); + } + return 0; +} + // ----------------------------------------------------------------------------- -- cgit From 6f62d05aa6ab5d3517ba94ccfabef1072e00e534 Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Thu, 9 Jul 2009 08:21:58 +0000 Subject: #i101242# new print UI dialog --- sw/source/core/view/vprint.cxx | 126 +++++++++++++++++++---------------- sw/source/ui/uno/unotxdoc.cxx | 146 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 217 insertions(+), 55 deletions(-) (limited to 'sw') diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index e31da015f01f..9d8fd79c139c 100644 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -381,7 +381,7 @@ void lcl_FormatPostIt( IDocumentContentOperations* pIDCO, SwPaM& aPam, SwPostItF void lcl_PrintPostIts( ViewShell* pPrtShell, const XubString& rJobName, BOOL& rStartJob, int& rJobStartError, BOOL bReverse) { -#ifdef TL_NOT_NOW /*TLPDF*/ +#ifdef TL_NOT_NOW /* TLPDF ??? */ // Formatieren und Ausdrucken pPrtShell->CalcLayout(); @@ -944,13 +944,13 @@ SwDoc * ViewShell::FillPrtDoc( SwDoc *pPrtDoc, const SfxPrinter* pPrt) BOOL ViewShell::Prt( OutputDevice* pOutDev, SwPrtOptions& rOptions, - SfxProgress* pProgress, + SfxProgress* pProgress, /* TLPDF superfluous ??? */ bool bIsPDFExport ) { //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! //Immer die Druckroutine in viewpg.cxx (fuer Seitenvorschau) mitpflegen!! //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - ASSERT( bIsPDFExport || pProgress, "Printing without progress bar!" ) +// TLPDF ASSERT( bIsPDFExport || pProgress, "Printing without progress bar!" ) BOOL bStartJob = FALSE; @@ -960,6 +960,7 @@ BOOL ViewShell::Prt( //! rOptions.bPrintSelection parameter will be false. BOOL bSelection = rOptions.bPrintSelection; +// TLPDF: this one should hold just one page now. Thus clean-up should be possible MultiSelection aMulti( rOptions.aMulti ); if ( !aMulti.GetSelectCount() ) @@ -974,6 +975,10 @@ BOOL ViewShell::Prt( ASSERT( aPages.Min() <= aPages.Max(), "MinSeite groesser MaxSeite." ); +// TLPDF + ASSERT( aPages.Min() == aPages.Max(), "Min page should be equal to Max page now" ); /* TL PDF */ +// TLPDF TODO: clean-up aPage.Min/Max which should be identical now + #ifdef TL_NOT_NOW /*TLPDF*/ Printer* pPrt = 0; //!! will be 0 for PDF export !! /*TLPDF*/ #endif // TL_NOT_NOW /*TLPDF*/ @@ -1101,13 +1106,14 @@ BOOL ViewShell::Prt( BOOL bStop = FALSE; int nJobStartError = JOBSET_ERR_DEFAULT; - USHORT nCopyCnt = rOptions.bCollate ? rOptions.nCopyCount : 1; +// TLPDF USHORT nCopyCnt = rOptions.bCollate ? rOptions.nCopyCount : 1; - USHORT nPrintCount = 1; +// TLPDF USHORT nPrintCount = 1; XubString sJobName( rOptions.GetJobName() ); - for ( USHORT nCnt = 0; !bStop && nCnt < nCopyCnt; nCnt++ ) - { +// TLPDF the copy count is now handled by the printer itself... +// TLPDF for ( USHORT nCnt = 0; !bStop && nCnt < nCopyCnt; nCnt++ ) +// TLPDF { const SwPageFrm *pStPage = (SwPageFrm*)pShell->GetLayout()->Lower(); const SwFrm *pEndPage = pStPage; @@ -1126,8 +1132,9 @@ BOOL ViewShell::Prt( // Reschedule statt Yield, da Yield keine Events abarbeitet // und es sonst eine Endlosschleife gibt. - while( pOutDev->IsPrinting() && pProgress ) - pProgress->Reschedule(); +// TLPDF progrssbaris now handled by new print dialog +// TLPDF while( pOutDev->IsPrinting() && pProgress ) +// TLPDF pProgress->Reschedule(); sJobName = rOptions.MakeNextJobName(); nJobStartError = JOBSET_ERR_DEFAULT; @@ -1135,36 +1142,37 @@ BOOL ViewShell::Prt( } #endif //TL_NOT_NOW /*TLPDF*/ - for( USHORT i = 1; i <= (USHORT)aPages.Max(); ++i ) - { - if( i < (USHORT)aPages.Min() ) - { - if( !pStPage->GetNext() ) - break; - pStPage = (SwPageFrm*)pStPage->GetNext(); - pEndPage= pStPage; - } - else if( i == (USHORT)aPages.Min() ) - { - nFirstPageNo = i; - nLastPageNo = nFirstPageNo; - if( !pStPage->GetNext() || (i == (USHORT)aPages.Max()) ) - break; - pEndPage = pStPage->GetNext(); - } - else if( i > (USHORT)aPages.Min() ) - { - nLastPageNo = i; - if( !pEndPage->GetNext() || (i == (USHORT)aPages.Max()) ) - break; - pEndPage = pEndPage->GetNext(); - } - } - + for( USHORT i = 1; i <= (USHORT)aPages.Max(); ++i ) + { + if( i < (USHORT)aPages.Min() ) + { + if( !pStPage->GetNext() ) + break; + pStPage = (SwPageFrm*)pStPage->GetNext(); + pEndPage= pStPage; + } + else if( i == (USHORT)aPages.Min() ) + { + nFirstPageNo = i; + nLastPageNo = nFirstPageNo; + if( !pStPage->GetNext() || (i == (USHORT)aPages.Max()) ) + break; + pEndPage = pStPage->GetNext(); + } + else if( i > (USHORT)aPages.Min() ) + { + nLastPageNo = i; + if( !pEndPage->GetNext() || (i == (USHORT)aPages.Max()) ) + break; + pEndPage = pEndPage->GetNext(); + } + } + + OSL_ENSURE( nFirstPageNo, "fist page not found! Should not happen!" ); // TLPDF if( !nFirstPageNo ) { - bStop = TRUE; - break; +// TLPDF bStop = TRUE; +// TLPDF break; // TLPDF should continue after '(end of the copy count loop)' } // HACK: Hier muss von der MultiSelection noch eine akzeptable Moeglichkeit @@ -1357,10 +1365,12 @@ BOOL ViewShell::Prt( rOptions.bPrintRightPage, rOptions.bPrintLeftPage, rOptions.bPrintReverse ); +#ifdef TL_NOT_NOW /*TLPDF*/ if ( pProgress ) lcl_SetState( *pProgress, nPrintCount++, nSelCount, pStr, nMergeAct, nMergeCnt, nSelCount, nPageNo ); +#endif // TL_NOT_NOW /*TLPDF*/ if( !bStartJob && JOBSET_ERR_DEFAULT == nJobStartError && sJobName.Len() ) @@ -1438,28 +1448,34 @@ BOOL ViewShell::Prt( { ++nPageNo; pStPage = (SwPageFrm*)pStPage->GetNext(); } - } - if ( bStop ) - break; + } // TLPDF loop end: while( pStPage && !bStop ) +// TLPDF if ( bStop ) +// TLPDF break; } - // Wenn PostIts am Dokumentenende gedruckt werden sollen, dann hier machen - if( ((rOptions.nPrintPostIts == POSTITS_ENDDOC) && !rOptions.bPrintReverse) - || (rOptions.nPrintPostIts == POSTITS_ONLY) ) - lcl_PrintPostItsEndDoc( pPostItShell, aPostItFields, aMulti, - sJobName, bStartJob, nJobStartError, - rOptions.bPrintRightPage, rOptions.bPrintLeftPage, - rOptions.bPrintReverse ); - - if( pPostItShell ) + if (!bStop) // TLPDF: see break above { - pPostItDoc->setPrinter( 0, false, false ); //damit am echten DOC der Drucker bleibt - delete pPostItShell; //Nimmt das PostItDoc mit ins Grab. - } + // Wenn PostIts am Dokumentenende gedruckt werden sollen, dann hier machen + if( ((rOptions.nPrintPostIts == POSTITS_ENDDOC) && !rOptions.bPrintReverse) + || (rOptions.nPrintPostIts == POSTITS_ONLY) ) + lcl_PrintPostItsEndDoc( pPostItShell, aPostItFields, aMulti, + sJobName, bStartJob, nJobStartError, + rOptions.bPrintRightPage, rOptions.bPrintLeftPage, + rOptions.bPrintReverse ); + + if( pPostItShell ) + { + pPostItDoc->setPrinter( 0, false, false ); //damit am echten DOC der Drucker bleibt + delete pPostItShell; //Nimmt das PostItDoc mit ins Grab. + } - if( bStartJob ) - rOptions.bJobStartet = TRUE; - } + if( bStartJob ) + rOptions.bJobStartet = TRUE; + } // TLPDF: if (!bStop) see break above + +// TLPDF the copy count is now handled by the printer itself... +// TLPDF (end of the copy count loop) +// TLPDF } } delete pStr; diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index a71f1f9f8a27..acb13e3681b4 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -133,6 +133,7 @@ #include #include #include +#include #include #include @@ -2935,6 +2936,141 @@ SfxViewShell * SwXTextDocument::GuessViewShell() /* -----------------------------23.08.02 16:00-------------------------------- ---------------------------------------------------------------------------*/ + +static bool lcl_getSingleValue( + const OUString &rText, + sal_Int32 &rVal ) +{ + bool bRes = false; + const sal_Int32 nLen = rText.getLength(); + if (nLen > 0) + { + // verify that text consists of decimal number 0..9 only + bool bValidText = true; + const sal_Unicode *pText = rText.getStr(); + for (sal_Int32 i = 0; i < nLen && bValidText; ++i) + { + const sal_Unicode cChar = pText[i]; + if (cChar < '0' || cChar > '9') + bValidText = false; + } + + // get integer value if text is valid + if (bValidText) + { + rVal = rText.toInt32(); + bRes = true; + } + } + return bRes; +} + +static bool lcl_getSubRangeBounds( + const OUString &rSubRange, + sal_Int32 &rFirst, + sal_Int32 &rLast ) +{ + bool bRes = false; + + // check for page range... + sal_Int32 nPos = rSubRange.indexOf( (sal_Unicode)'-' ); + if (nPos > 0) + { + // page range found... + nPos = 0; + const OUString aFirstPage( rSubRange.getToken( 0, '-', nPos ) ); + const OUString aLastPage( rSubRange.getToken( 0, '-', nPos ) ); + sal_Int32 nTmpFirst = -1; + sal_Int32 nTmpLast = -1; + if (lcl_getSingleValue( aFirstPage, nTmpFirst ) && lcl_getSingleValue( aLastPage, nTmpLast )) + { + rFirst = nTmpFirst; + rLast = nTmpLast; + bRes = true; + } + } + else + { + // single page value... + sal_Int32 nVal = -1; + if (lcl_getSingleValue( rSubRange, nVal )) + { + rFirst = rLast = nVal; + bRes = true; + } + } + + return bRes; +} + +static bool lcl_PageRangeToVector( + const OUString &rPageRange, // valid format example "5-3,9,9,7-8" instead of ',' ';' or ' ' are allowed as well + std::vector< sal_Int32 > &rPageVector ) +{ + bool bRes = false; + + // - strip leading and trailing whitespaces + // - unify token delimeters to ';' + // - remove duplicate delimiters + OUString aRange( rPageRange.trim() ); + aRange = aRange.replace( (sal_Unicode)' ', (sal_Unicode)';' ); + aRange = aRange.replace( (sal_Unicode)',', (sal_Unicode)';' ); + sal_Int32 nPos = -1; + while ((nPos = aRange.indexOf( C2U(";;") )) >= 0) + aRange = aRange.replaceAt( nPos, 2, C2U(";") ); + + if (aRange.getLength() > 0) + { + std::vector< sal_Int32 > aTmpVector; + + // iterate over all sub ranges and add the respective pages to the + // vector while preserving the page order + bool bFailed = false; + nPos = 0; + do + { + const OUString aSubRange = aRange.getToken( 0, ';', nPos ); + sal_Int32 nFirst = -1, nLast = -1; + if (lcl_getSubRangeBounds( aSubRange, nFirst, nLast ) + && nFirst > 0 && nLast > 0) + { + // add pages of sub range to vector + if (nFirst == nLast) + aTmpVector.push_back( nFirst ); + else if (nFirst < nLast) + { + for (sal_Int32 i = nFirst; i <= nLast; ++i) + aTmpVector.push_back( i ); + } + else if (nFirst > nLast) + { + for (sal_Int32 i = nFirst; i >= nLast; --i) + aTmpVector.push_back( i ); + } + else + OSL_ENSURE( 0, "unexpected case" ); + } + else + bFailed = true; + } + while (!bFailed && 0 <= nPos && nPos < aRange.getLength()); + + if (!bFailed) + { + rPageVector = aTmpVector; + bRes = true; + } + } + else + { + // empty string ... + rPageVector.clear(); + bRes = true; + } + + return bRes; +} + void SAL_CALL SwXTextDocument::render( sal_Int32 nRenderer, const uno::Any& rSelection, @@ -3015,6 +3151,16 @@ void SAL_CALL SwXTextDocument::render( rxOptions[ nProperty].Value >>= bSkipEmptyPages; } +#if OSL_DEBUG_LEVEL > 1 + std::vector< sal_Int32 > _aVec1; + bool _bTmp1 = lcl_PageRangeToVector( C2U(""), _aVec1 ); + _bTmp1 = lcl_PageRangeToVector( C2U("-1"), _aVec1 ); + _bTmp1 = lcl_PageRangeToVector( C2U("3 0"), _aVec1 ); + _bTmp1 = lcl_PageRangeToVector( C2U("1-5,7 7,15-12;8"), _aVec1 ); + _bTmp1 = lcl_PageRangeToVector( C2U(" 2-6,,7 7,15-12;;;9"), _aVec1 ); + _bTmp1 = lcl_PageRangeToVector( C2U(";,5-1,,7 7,12-15;;;9"), _aVec1 ); +#endif + OutputDevice* pOut = 0; if (xRenderDevice.is()) { -- cgit From 3c7537520ff5fb728e357a6f6cb7b1a343cd54fe Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Thu, 16 Jul 2009 14:39:49 +0000 Subject: #i101242# new print UI dialog; PageRange now basically functional --- sw/inc/doc.hxx | 9 + sw/inc/swprtopt.hxx | 40 +++ sw/inc/viewsh.hxx | 6 +- sw/source/core/doc/doc.cxx | 130 +++++++++- sw/source/core/view/vprint.cxx | 566 +++++++++++++++++++---------------------- sw/source/ui/dbui/dbmgr.cxx | 8 + sw/source/ui/uiview/pview.cxx | 4 + sw/source/ui/uno/unotxdoc.cxx | 407 ++++------------------------- 8 files changed, 502 insertions(+), 668 deletions(-) (limited to 'sw') diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index a82ea0235359..87252e9119ee 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -113,6 +113,8 @@ class SwList; #include #include +#include +#include #include @@ -239,6 +241,8 @@ class SwMsgPoolItem; class SwChartDataProvider; class SwChartLockController_Helper; class IGrammarContact; +class SwPrintUIOptions; +class SwPageFrm; namespace sw { namespace mark { class MarkManager; @@ -1350,6 +1354,11 @@ public: sal_Bool InsertGlossary( SwTextBlocks& rBlock, const String& rEntry, SwPaM& rPaM, SwCrsrShell* pShell = 0); + // get the set of printable pages for the XRenderable API by + // evaluating the respective settings (see implementation) + void GetValidPagesForPrinting( SwPrintUIOptions &rPrintUIOptions, + sal_Int32 nDocPageCount ); + sal_uInt16 GetPageCount() const; const Size GetPageSize( sal_uInt16 nPageNum, bool bSkipEmptyPages ) const; diff --git a/sw/inc/swprtopt.hxx b/sw/inc/swprtopt.hxx index 38250fe7f28d..d2b45b37d234 100644 --- a/sw/inc/swprtopt.hxx +++ b/sw/inc/swprtopt.hxx @@ -31,14 +31,24 @@ #ifndef _SWPRTOPT_HXX #define _SWPRTOPT_HXX +#include #include #include +#include +#include +#include + #define POSTITS_NONE 0 #define POSTITS_ONLY 1 #define POSTITS_ENDDOC 2 #define POSTITS_ENDPAGE 3 + +class SwPageFrm; + +//////////////////////////////////////////////////////////// + class SwPrtOptions : public SwPrintData { USHORT nJobNo; @@ -83,6 +93,36 @@ public: }; +//////////////////////////////////////////////////////////// + +class SwPrintUIOptions : public vcl::PrinterOptionsHelper +{ + OutputDevice* mpLast; + + // pages valid for printing (accoridng to the current settings) + // and their respective start frames (see getRendererCount in unotxdoc.cxx) + std::set< sal_Int32 > aValidPages; // the set of possible pages (see StringRangeEnumerator::getRangesFromString ) + std::map< sal_Int32, const SwPageFrm * > aValidStartFrms; // the map of start frames for those pages + + // vector of pages and their order to be printed (duplicates and any order allowed!) + // (see 'render' in unotxdoc.cxx) + std::vector< sal_Int32 > aPagesToPrint; + +public: + SwPrintUIOptions( BOOL bWeb ); + + bool processPropertiesAndCheckFormat( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& i_rNewProp ); + + typedef std::map< sal_Int32, const SwPageFrm * > ValidStartFramesMap_t; + + std::set< sal_Int32 > & GetValidPagesSet() { return aValidPages; } + ValidStartFramesMap_t & GetValidStartFrms() { return aValidStartFrms; } + const ValidStartFramesMap_t & GetValidStartFrms() const { return aValidStartFrms; } + std::vector< sal_Int32 > & GetPagesToPrint() { return aPagesToPrint; } + const std::vector< sal_Int32 > & GetPagesToPrint() const { return aPagesToPrint; } +}; + + #endif //_SWPRTOPT_HXX diff --git a/sw/inc/viewsh.hxx b/sw/inc/viewsh.hxx index 5a249db26337..dbbeec0e7d8e 100644 --- a/sw/inc/viewsh.hxx +++ b/sw/inc/viewsh.hxx @@ -71,6 +71,7 @@ class SfxViewShell; class SwViewOption; class SwViewImp; class SwPrtOptions; +class SwPrintUIOptions; class SwPagePreViewPrtData; class Window; class OutputDevice; @@ -364,8 +365,9 @@ public: //Druckauftrag abwickeln. // bIsPDFExport == true is: do PDF Export (no printing!) - sal_Bool Prt( OutputDevice* pOutDev, SwPrtOptions& rOptions, SfxProgress* pProgress, - bool bIsPDFExport = false ); + sal_Bool Prt( OutputDevice* pOutDev, SwPrtOptions& rOptions, + const SwPrintUIOptions &rPrintUIOptions, sal_Int32 nRenderer /* offset in vector of pages to print */, + SfxProgress* pProgress, bool bIsPDFExport = false ); //"Drucken" fuer OLE 2.0 static void PrtOle2( SwDoc *pDoc, const SwViewOption *pOpt, SwPrtOptions& rOptions, diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index ae48966e31b8..2e92d8adb89b 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -46,6 +46,7 @@ #include #include #include +#include #include #include #include @@ -95,12 +96,9 @@ #include #include #include -#ifndef _CMDID_H +#include #include // fuer den dflt - Printer in SetJob -#endif -#ifndef _STATSTR_HRC #include // StatLine-String -#endif #include #include #include @@ -991,6 +989,130 @@ const SwDocStat& SwDoc::GetDocStat() const return *pDocStat; } + +void SwDoc::GetValidPagesForPrinting( + SwPrintUIOptions &rPrintUIOptions, + sal_Int32 nDocPageCount ) +{ + DBG_ASSERT( pLayout, "no layout present" ); + if (!pLayout) + return; + + // properties to take into account when calcualting the set of pages + const bool bPrintLeftPage = rPrintUIOptions.getBoolValue( C2U( "PrintLeftPages" ), false ); + const bool bPrintRightPage = rPrintUIOptions.getBoolValue( C2U( "PrintRightPages" ), false ); + const bool bPrintReverse = rPrintUIOptions.getBoolValue( C2U( "PrintReverseOrder" ), false ); + const bool bPrintEmptyPages = rPrintUIOptions.getBoolValue( C2U( "PrintEmptyPages" ), false ); + + Range aPages( 1, nDocPageCount ); + + MultiSelection aMulti( aPages ); + aMulti.SetTotalRange( Range( 0, RANGE_MAX ) ); + aMulti.Select( aPages ); + + const SwPageFrm *pStPage = (SwPageFrm*)pLayout->Lower(); + const SwFrm *pEndPage = pStPage; + + USHORT nFirstPageNo = 0; + USHORT nLastPageNo = 0; + USHORT nPageNo = 1; + + for( USHORT i = 1; i <= (USHORT)aPages.Max(); ++i ) + { + if( i < (USHORT)aPages.Min() ) + { + if( !pStPage->GetNext() ) + break; + pStPage = (SwPageFrm*)pStPage->GetNext(); + pEndPage= pStPage; + } + else if( i == (USHORT)aPages.Min() ) + { + nFirstPageNo = i; + nLastPageNo = nFirstPageNo; + if( !pStPage->GetNext() || (i == (USHORT)aPages.Max()) ) + break; + pEndPage = pStPage->GetNext(); + } + else if( i > (USHORT)aPages.Min() ) + { + nLastPageNo = i; + if( !pEndPage->GetNext() || (i == (USHORT)aPages.Max()) ) + break; + pEndPage = pEndPage->GetNext(); + } + } + + DBG_ASSERT( nFirstPageNo, "first page not found! Should not happen!" ); + if (nFirstPageNo) + { +// HACK: Hier muss von der MultiSelection noch eine akzeptable Moeglichkeit +// geschaffen werden, alle Seiten von Seite x an zu deselektieren. +// Z.B. durch SetTotalRange .... + +// aMulti.Select( Range( nLastPageNo+1, SELECTION_MAX ), FALSE ); + MultiSelection aTmpMulti( Range( 1, nLastPageNo ) ); + long nTmpIdx = aMulti.FirstSelected(); + static long nEndOfSelection = SFX_ENDOFSELECTION; + while ( nEndOfSelection != nTmpIdx && nTmpIdx <= long(nLastPageNo) ) + { + aTmpMulti.Select( nTmpIdx ); + nTmpIdx = aMulti.NextSelected(); + } + aMulti = aTmpMulti; +// Ende des HACKs + + if (bPrintReverse) + { + const SwFrm *pTmp = pStPage; + pStPage = (SwPageFrm*)pEndPage; + pEndPage = pTmp; + nPageNo = nLastPageNo; + } + else + nPageNo = nFirstPageNo; + + std::set< sal_Int32 > &rValidPages = rPrintUIOptions.GetValidPagesSet(); + std::map< sal_Int32, const SwPageFrm * > &rValidStartFrms = rPrintUIOptions.GetValidStartFrms(); + rValidPages.clear(); + rValidStartFrms.clear(); + while ( pStPage ) + { + const BOOL bRightPg = pStPage->OnRightPage(); + if ( aMulti.IsSelected( nPageNo ) && + ( (bRightPg && bPrintRightPage) || + (!bRightPg && bPrintLeftPage) ) ) + { + // --> FME 2005-12-12 #b6354161# Feature - Print empty pages + if ( bPrintEmptyPages || pStPage->Frm().Height() ) + // <-- + { + // pStPage->GetUpper()->Paint( pStPage->Frm() ); + rValidPages.insert( nPageNo ); + rValidStartFrms[ nPageNo ] = pStPage; + } + } + + if ( pStPage == pEndPage ) + { + pStPage = 0; + } + else if ( bPrintReverse ) + { + --nPageNo; + pStPage = (SwPageFrm*)pStPage->GetPrev(); + } + else + { ++nPageNo; + pStPage = (SwPageFrm*)pStPage->GetNext(); + } + } + } +} + + + + sal_uInt16 SwDoc::GetPageCount() const { return GetRootFrm() ? GetRootFrm()->GetPageNum() : 0; diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index 9d8fd79c139c..8e50ada89c58 100644 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -32,13 +32,18 @@ #include "precompiled_sw.hxx" +#include +#include + #include #include #include +#include +#include +#include +#include +#include -#ifndef _INTN_HXX //autogen -// #include -#endif #include #include #include @@ -46,6 +51,7 @@ #include #include #include + #include #include #include @@ -76,11 +82,15 @@ #include // MinPrtLine #include // SwShellCrsr #include // SwFmtPageDesc +#include #define JOBSET_ERR_DEFAULT 0 #define JOBSET_ERR_ERROR 1 #define JOBSET_ERR_ISSTARTET 2 + +using namespace ::com::sun::star; + //-------------------------------------------------------------------- //Klasse zum Puffern von Paints class SwQueuedPaint @@ -201,6 +211,7 @@ void SwPaintQueue::Remove( ViewShell *pSh ) } } +/*****************************************************************************/ const XubString& SwPrtOptions::MakeNextJobName() { @@ -214,6 +225,205 @@ const XubString& SwPrtOptions::MakeNextJobName() return sJobName += XubString::CreateFromInt32( ++nJobNo ); } +/*****************************************************************************/ + +SwPrintUIOptions::SwPrintUIOptions( BOOL bWeb ) : + mpLast( NULL ) +{ + ResStringArray aLocalizedStrings( SW_RES( STR_PRINTOPTUI ) ); + + DBG_ASSERT( aLocalizedStrings.Count() >= 46, "resource incomplete" ); + if( aLocalizedStrings.Count() < 46 ) // bad resource ? + return; + + // create sequence of print UI options + // (5 options are not available for Writer-Web) + const int nNumProps = bWeb? 17 : 22; + m_aUIProperties.realloc( nNumProps ); + int nIdx = 0; + + // create Section for Contents (results in an extra tab page in dialog) + m_aUIProperties[ nIdx++ ].Value = getGroupControlOpt( aLocalizedStrings.GetString( 0 ), rtl::OUString() ); + + // create a bool option for graphics + m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 1 ), + aLocalizedStrings.GetString( 2 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintGraphics" ) ), + sal_True ); + // create a bool option for tables + m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 3 ), + aLocalizedStrings.GetString( 4 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintTables" ) ), + sal_True ); + + if (!bWeb) + { + // create a bool option for drawings + m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 5 ), + aLocalizedStrings.GetString( 6 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDrawings" ) ), + sal_True ); + } + + // create a bool option for controls + m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 7 ), + aLocalizedStrings.GetString( 8 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintControls" ) ), + sal_True ); + + // create a bool option for background + m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 9 ), + aLocalizedStrings.GetString( 10 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintBackground" ) ), + sal_True ); + + // create a bool option for black + m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 11 ), + aLocalizedStrings.GetString( 12 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintBlack" ) ), + sal_False ); + + if (!bWeb) + { + // create a bool option for hidden text + m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 13 ), + aLocalizedStrings.GetString( 14 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintHiddenText" ) ), + sal_False ); + + // create a bool option for place holder + m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 15 ), + aLocalizedStrings.GetString( 16 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintPlaceholder" ) ), + sal_False ); + } + + // create a list box for notes content + uno::Sequence< rtl::OUString > aChoices( 4 ); + aChoices[0] = aLocalizedStrings.GetString( 19 ); + aChoices[1] = aLocalizedStrings.GetString( 20 ); + aChoices[2] = aLocalizedStrings.GetString( 21 ); + aChoices[3] = aLocalizedStrings.GetString( 22 ); + uno::Sequence< rtl::OUString > aHelpText( 2 ); + aHelpText[0] = aLocalizedStrings.GetString( 18 ); + aHelpText[1] = aLocalizedStrings.GetString( 18 ); + m_aUIProperties[ nIdx++ ].Value = getChoiceControlOpt( aLocalizedStrings.GetString( 17 ), + aHelpText, + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintNotes" ) ), + aChoices, + 0, + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "List" ) ) + ); + + // create Section for Page settings (results in an extra tab page in dialog) + m_aUIProperties[ nIdx++ ].Value = getGroupControlOpt( aLocalizedStrings.GetString( 23 ), rtl::OUString() ); + + if (!bWeb) + { + // create a bool option for left pages + m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 24 ), + aLocalizedStrings.GetString( 25 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintLeftPages" ) ), + sal_True ); + + // create a bool option for right pages + m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 26 ), + aLocalizedStrings.GetString( 27 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintRightPages" ) ), + sal_True ); + } + + // create a bool option for reversed order (solve in vcl ?) + m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 28 ), + aLocalizedStrings.GetString( 29 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintReverseOrder" ) ), + sal_False ); + + // create a bool option for brochure + rtl::OUString aBrochurePropertyName( RTL_CONSTASCII_USTRINGPARAM( "PrintBrochure" ) ); + m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 30 ), + aLocalizedStrings.GetString( 31 ), + aBrochurePropertyName, + sal_False ); + + // create a bool option for brochure RTL dependent on brochure + m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 32 ), + aLocalizedStrings.GetString( 33 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintBrochureRTL" ) ), + sal_False, + &aBrochurePropertyName, + -1, + sal_True + ); + + // create subgroup for misc options + m_aUIProperties[ nIdx++ ].Value = getSubgroupControlOpt( rtl::OUString( aLocalizedStrings.GetString( 34 ) ), rtl::OUString() ); + + // create a bool option for blank pages + m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 35 ), + aLocalizedStrings.GetString( 36 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintEmptyPages" ) ), + sal_True ); + + // create a bool option for paper tray + m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 37 ), + aLocalizedStrings.GetString( 38 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PaperTray" ) ), + sal_False ); + + // print range selection + m_aUIProperties[nIdx++].Value = getSubgroupControlOpt( rtl::OUString( aLocalizedStrings.GetString( 39 ) ), rtl::OUString(), true, true ); + + // create a choice for the content to create + rtl::OUString aPrintRangeName( RTL_CONSTASCII_USTRINGPARAM( "PrintContent" ) ); + aChoices.realloc( 3 ); + aHelpText.realloc( 3 ); + aChoices[0] = aLocalizedStrings.GetString( 40 ); + aHelpText[0] = aLocalizedStrings.GetString( 41 ); + aChoices[1] = aLocalizedStrings.GetString( 42 ); + aHelpText[1] = aLocalizedStrings.GetString( 43 ); + aChoices[2] = aLocalizedStrings.GetString( 44 ); + aHelpText[2] = aLocalizedStrings.GetString( 45 ); + m_aUIProperties[nIdx++].Value = getChoiceControlOpt( rtl::OUString(), + aHelpText, + aPrintRangeName, + aChoices, + 0 ); + // create a an Edit dependent on "Pages" selected + m_aUIProperties[nIdx++].Value = getEditControlOpt( rtl::OUString(), + rtl::OUString(), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PageRange" ) ), + rtl::OUString(), + &aPrintRangeName, 1, sal_True + ); + + + DBG_ASSERT( nIdx == nNumProps, "number of added properties is not as expected" ); +} + + +bool SwPrintUIOptions::processPropertiesAndCheckFormat( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& i_rNewProp ) +{ + bool bChanged = processProperties( i_rNewProp ); + + uno::Reference< awt::XDevice > xRenderDevice; + uno::Any aVal( getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "RenderDevice" ) ) ) ); + aVal >>= xRenderDevice; + + OutputDevice* pOut = 0; + if (xRenderDevice.is()) + { + VCLXDevice* pDevice = VCLXDevice::GetImplementation( xRenderDevice ); + pOut = pDevice ? pDevice->GetOutputDevice() : 0; + } + bChanged = bChanged || (pOut != mpLast); + if( pOut ) + mpLast = pOut; + + return bChanged; +} + + /****************************************************************************** * Methode : void SetSwVisArea( ViewShell *pSh, Point aPrtOffset, ... * Beschreibung: @@ -228,8 +438,12 @@ void SetSwVisArea( ViewShell *pSh, const SwRect &rRect, BOOL bPDFExport ) pSh->Imp()->SetFirstVisPageInvalid(); Point aPt( rRect.Pos() ); - if (!bPDFExport) - aPt += pSh->aPrtOffst; + // calculate an offset for the rectangle of the n-th page to + // move the start point of the output operation to a position + // such that in the output device all pages will be painted + // at the same position +// TLPDF if (!bPDFExport) +// TLPDF aPt += pSh->aPrtOffst; aPt.X() = -aPt.X(); aPt.Y() = -aPt.Y(); // TLPDF OutputDevice *pOut = bPDFExport ? @@ -428,13 +642,13 @@ void lcl_PrintPostIts( ViewShell* pPrtShell, const XubString& rJobName, pPrn->EndPage(); pPage = bReverse ? pPage->GetPrev() : pPage->GetNext(); } - #else - (void)pPrtShell; - (void)rJobName; - (void)rStartJob; - (void)rJobStartError; - (void)bReverse; - #endif +#else +(void)pPrtShell; +(void)rJobName; +(void)rStartJob; +(void)rJobStartError; +(void)bReverse; +#endif } /****************************************************************************** @@ -543,7 +757,7 @@ void ViewShell::InitPrt( /*Printer *pPrt,*/ OutputDevice *pOutDev ) /* TLPDF */ OutputDevice *pTmpDev = pOutDev; // TLPDF pPDFOut ? pPDFOut : (OutputDevice *) pPrt; if ( pTmpDev ) { -// TLPDRF aPrtOffst = pPrt ? pPrt->GetPageOffset() : Point(); +// TLPDF aPrtOffst = pPrt ? pPrt->GetPageOffset() : Point(); aPrtOffst = Point(); aPrtOffst += pTmpDev->GetMapMode().GetOrigin(); @@ -944,16 +1158,16 @@ SwDoc * ViewShell::FillPrtDoc( SwDoc *pPrtDoc, const SfxPrinter* pPrt) BOOL ViewShell::Prt( OutputDevice* pOutDev, SwPrtOptions& rOptions, + const SwPrintUIOptions &rPrintUIOptions, /* TLPDF keep this or the above? */ + sal_Int32 nRenderer, SfxProgress* pProgress, /* TLPDF superfluous ??? */ bool bIsPDFExport ) { //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! //Immer die Druckroutine in viewpg.cxx (fuer Seitenvorschau) mitpflegen!! //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -// TLPDF ASSERT( bIsPDFExport || pProgress, "Printing without progress bar!" ) BOOL bStartJob = FALSE; - //! Note: Since for PDF export of (multi-)selection a temporary //! document is created that contains only the selects parts, //! and thus that document is to printed in whole the, @@ -966,6 +1180,10 @@ BOOL ViewShell::Prt( if ( !aMulti.GetSelectCount() ) return bStartJob; + // save settings of OutputDevice (should be done always now since the + // output device is now provided by a call from outside the Writer) + pOutDev->Push(); + Range aPages( aMulti.FirstSelected(), aMulti.LastSelected() ); if ( aPages.Max() > USHRT_MAX ) aPages.Max() = USHRT_MAX; @@ -976,32 +1194,12 @@ BOOL ViewShell::Prt( "MinSeite groesser MaxSeite." ); // TLPDF - ASSERT( aPages.Min() == aPages.Max(), "Min page should be equal to Max page now" ); /* TL PDF */ + ASSERT( aPages.Min() == aPages.Max(), "Min page should be equal to Max page now" ); /* TLPDF */ // TLPDF TODO: clean-up aPage.Min/Max which should be identical now -#ifdef TL_NOT_NOW /*TLPDF*/ - Printer* pPrt = 0; //!! will be 0 for PDF export !! /*TLPDF*/ -#endif // TL_NOT_NOW /*TLPDF*/ - if (bIsPDFExport) - pOutDev->Push(); - else - { -#ifdef TL_NOT_NOW /*TLPDF*/ -// pOutDev = dynamic_cast< Printer* >(pOutDev); - DBG_ASSERT( pOutDev, "printer missing" ); - if( !pOutDev || !pOutDev->GetName().Len() ) - { - ASSERT( FALSE, "Drucken ohne Drucker?" ); - return bStartJob; - } - - if( !rOptions.GetJobName().Len() && !pOutDev->IsJobActive() ) - return bStartJob; -#endif // TL_NOT_NOW /*TLPDF*/ - } // Einstellungen am Drucker merken -// SwPrtOptSave aPrtSave( pOutDev ); /*TLPDF ???*/ +// SwPrtOptSave aPrtSave( pOutDev ); /* TLPDF wo dann heutzutage ??? */ // eine neue Shell fuer den Printer erzeugen ViewShell *pShell; @@ -1046,14 +1244,6 @@ BOOL ViewShell::Prt( SET_CURR_SHELL( pShell ); -#ifdef TL_NOT_NOW /*TLPDF*/ - if ( pProgress ) - { - Link aLnk = LINK(pShell->Imp(), SwViewImp, SetStopOutDev); - ((SfxPrintProgress *)pProgress)->SetCancelHdl(aLnk); - } -#endif // TL_NOT_NOW /*TLPDF*/ - //JP 01.02.99: das ReadOnly Flag wird NIE mitkopiert; Bug 61335 if( pOpt->IsReadonly() ) pShell->pOpt->SetReadonly( TRUE ); @@ -1065,27 +1255,27 @@ BOOL ViewShell::Prt( XubString* pStr = 0; ULONG nMergeAct = rOptions.nMergeAct, nMergeCnt = rOptions.nMergeCnt; - if ( pProgress ) - { - if( nMergeAct ) - { - pStr = new SW_RESSTR(STR_STATSTR_LETTER); - *pStr += ' '; - *pStr += XubString::CreateFromInt64( nMergeAct ); - if( nMergeCnt ) - { - *pStr += '/'; - *pStr += XubString::CreateFromInt64( nMergeCnt ); - } - } - else - { - ++nMergeAct; - } - } - // Seiten fuers Drucken formatieren - pShell->CalcPagesForPrint( (USHORT)aPages.Max(), pProgress, pStr, + +/* TLPDF neu: start */ +#if OSL_DEBUG_LEVEL > 1 + DBG_ASSERT( 0 <= nRenderer && nRenderer <= rPrintUIOptions.GetPagesToPrint().size(), + "nRenderer out of bounds"); +#endif + const sal_Int32 nPage = rPrintUIOptions.GetPagesToPrint()[ nRenderer ]; /* TLPDF */ +#if OSL_DEBUG_LEVEL > 1 + DBG_ASSERT( 0 <= nPage && nPage <= rPrintUIOptions.GetValidStartFrms().size(), + "nPage out of bounds"); +#endif + const SwPrintUIOptions::ValidStartFramesMap_t &rFrms = rPrintUIOptions.GetValidStartFrms(); + SwPrintUIOptions::ValidStartFramesMap_t::const_iterator aIt( rFrms.find( nPage ) ); + DBG_ASSERT( aIt != rFrms.end(), "failed to find start frame" ); + const SwPageFrm *pStPage = aIt->second; +/* TLPDF neu: end */ + + + // benötigte Seiten fuers Drucken formatieren + pShell->CalcPagesForPrint( (USHORT)nPage, pProgress, pStr, nMergeAct, nMergeCnt ); // Some field types, can require a valid layout @@ -1106,84 +1296,19 @@ BOOL ViewShell::Prt( BOOL bStop = FALSE; int nJobStartError = JOBSET_ERR_DEFAULT; -// TLPDF USHORT nCopyCnt = rOptions.bCollate ? rOptions.nCopyCount : 1; - -// TLPDF USHORT nPrintCount = 1; XubString sJobName( rOptions.GetJobName() ); -// TLPDF the copy count is now handled by the printer itself... -// TLPDF for ( USHORT nCnt = 0; !bStop && nCnt < nCopyCnt; nCnt++ ) -// TLPDF { - const SwPageFrm *pStPage = (SwPageFrm*)pShell->GetLayout()->Lower(); - const SwFrm *pEndPage = pStPage; - - USHORT nFirstPageNo = 0; - USHORT nLastPageNo = 0; - USHORT nPageNo = 1; -#ifdef TL_NOT_NOW /*TLPDF*/ - if (pOutDev) - { - if( rOptions.IsPrintSingleJobs() && sJobName.Len() && - ( bStartJob || rOptions.bJobStartet ) ) - { - pOutDev->EndJob(); - bStartJob = FALSE; - rOptions.bJobStartet = TRUE; - - // Reschedule statt Yield, da Yield keine Events abarbeitet - // und es sonst eine Endlosschleife gibt. -// TLPDF progrssbaris now handled by new print dialog -// TLPDF while( pOutDev->IsPrinting() && pProgress ) -// TLPDF pProgress->Reschedule(); - - sJobName = rOptions.MakeNextJobName(); - nJobStartError = JOBSET_ERR_DEFAULT; - } - } -#endif //TL_NOT_NOW /*TLPDF*/ - - for( USHORT i = 1; i <= (USHORT)aPages.Max(); ++i ) - { - if( i < (USHORT)aPages.Min() ) - { - if( !pStPage->GetNext() ) - break; - pStPage = (SwPageFrm*)pStPage->GetNext(); - pEndPage= pStPage; - } - else if( i == (USHORT)aPages.Min() ) - { - nFirstPageNo = i; - nLastPageNo = nFirstPageNo; - if( !pStPage->GetNext() || (i == (USHORT)aPages.Max()) ) - break; - pEndPage = pStPage->GetNext(); - } - else if( i > (USHORT)aPages.Min() ) - { - nLastPageNo = i; - if( !pEndPage->GetNext() || (i == (USHORT)aPages.Max()) ) - break; - pEndPage = pEndPage->GetNext(); - } - } - - OSL_ENSURE( nFirstPageNo, "fist page not found! Should not happen!" ); // TLPDF - if( !nFirstPageNo ) - { -// TLPDF bStop = TRUE; -// TLPDF break; // TLPDF should continue after '(end of the copy count loop)' - } - // HACK: Hier muss von der MultiSelection noch eine akzeptable Moeglichkeit // geschaffen werden, alle Seiten von Seite x an zu deselektieren. // Z.B. durch SetTotalRange .... // aMulti.Select( Range( nLastPageNo+1, SELECTION_MAX ), FALSE ); - MultiSelection aTmpMulti( Range( 1, nLastPageNo ) ); +// TLPDF MultiSelection aTmpMulti( Range( 1, nLastPageNo ) ); + MultiSelection aTmpMulti( Range( 1, nPage ) ); long nTmpIdx = aMulti.FirstSelected(); static long nEndOfSelection = SFX_ENDOFSELECTION; - while ( nEndOfSelection != nTmpIdx && nTmpIdx <= long(nLastPageNo) ) +// TLPDF while ( nEndOfSelection != nTmpIdx && nTmpIdx <= long(nLastPageNo) ) + while ( nEndOfSelection != nTmpIdx && nTmpIdx <= long(nPage) ) { aTmpMulti.Select( nTmpIdx ); nTmpIdx = aMulti.NextSelected(); @@ -1194,23 +1319,6 @@ BOOL ViewShell::Prt( const USHORT nSelCount = USHORT(aMulti.GetSelectCount() /* * nCopyCnt*/); - if ( pProgress ) - { - pProgress->SetText( SW_RESSTR(STR_STATSTR_PRINT) ); - lcl_SetState( *pProgress, 1, nSelCount, pStr, - nMergeAct, nMergeCnt, nSelCount, 1 ); - } - - if ( rOptions.bPrintReverse ) - { - const SwFrm *pTmp = pStPage; - pStPage = (SwPageFrm*)pEndPage; - pEndPage = pTmp; - nPageNo = nLastPageNo; - } - else - nPageNo = nFirstPageNo; - // PostitListe holen _SetGetExpFlds aPostItFields; SwDoc* pPostItDoc = 0; @@ -1241,51 +1349,12 @@ BOOL ViewShell::Prt( const SwPageDesc *pLastPageDesc = NULL; BOOL bSetOrient = FALSE; BOOL bSetPaperSz = FALSE; -#ifdef TL_NOT_NOW /*TLPDF*/ - BOOL bSetPaperBin = FALSE; -#endif // TL_NOT_NOW /*TLPDF*/ BOOL bSetPrt = FALSE; - if (pOutDev) - { -#ifdef TL_NOT_NOW /*TLPDF*/ - bSetOrient = pOutDev->HasSupport( SUPPORT_SET_ORIENTATION ); - bSetPaperSz = pOutDev->HasSupport( SUPPORT_SET_PAPERSIZE ); - bSetPaperBin = !rOptions.bPaperFromSetup && - pOutDev->HasSupport( SUPPORT_SET_PAPERBIN ); - bSetPrt = bSetOrient || bSetPaperSz || bSetPaperBin; -#endif // TL_NOT_NOW /*TLPDF*/ - } if ( rOptions.nPrintPostIts != POSTITS_ONLY ) { - // --> FME 2005-01-05 #110536# This valiable is used to track - // the number of pages which actually have been printed. - // If nPagesPrinted is odd, we have to send an additional - // empty page to the printer if we are currently in collation - // and duplex mode and there are still some more copies of the - // document to print. - USHORT nPagesPrinted = 0; - // <-- - - while( pStPage && !bStop ) +//TLPDF while( pStPage && !bStop ) { - // Mag der Anwender noch ? - if ( pProgress ) - pProgress->Reschedule(); - -#ifdef TL_NOT_NOW /*TLPDF*/ - if (pOutDev) - { - if ( JOBSET_ERR_ERROR == nJobStartError || - ( !pOutDev->IsJobActive() && ( !sJobName.Len() || bStartJob ) ) || - pShell->Imp()->IsStopOutDev() ) - { - bStop = TRUE; - break; - } - } -#endif // TL_NOT_NOW /*TLPDF*/ - ::SetSwVisArea( pShell, pStPage->Frm(), bIsPDFExport ); // wenn wir einen Umschlag drucken wird ein Offset beachtet @@ -1299,10 +1368,6 @@ BOOL ViewShell::Prt( pOutDev->SetMapMode( aTmp ); } - const BOOL bRightPg = pStPage->OnRightPage(); - if( aMulti.IsSelected( nPageNo ) && - ( (bRightPg && rOptions.bPrintRightPage) || - (!bRightPg && rOptions.bPrintLeftPage) ) ) { if ( bSetPrt ) { @@ -1312,47 +1377,6 @@ BOOL ViewShell::Prt( if ( pLastPageDesc != rFormatPage.GetPageDesc() ) { pLastPageDesc = rFormatPage.GetPageDesc(); - -#ifdef TL_NOT_NOW /*TLPDF*/ - const BOOL bLandScp = rFormatPage.GetPageDesc()->GetLandscape(); - - if( bSetPaperBin ) // Schacht einstellen. - pOutDev->SetPaperBin( rFormatPage.GetFmt()-> - GetPaperBin().GetValue() ); -#endif // TL_NOT_NOW /*TLPDF*/ - - if (bSetOrient ) - { -#ifdef TL_NOT_NOW /*TLPDF*/ - // Orientation einstellen: Breiter als Hoch - // -> Landscape, sonst -> Portrait. - if( bLandScp ) - pOutDev->SetOrientation(ORIENTATION_LANDSCAPE); - else - pOutDev->SetOrientation(ORIENTATION_PORTRAIT); -#endif // TL_NOT_NOW /*TLPDF*/ - } - - if (bSetPaperSz ) - { -#ifdef TL_NOT_NOW /*TLPDF*/ - Size aSize = pStPage->Frm().SSize(); - if ( bLandScp && bSetOrient ) - { - // landscape is always interpreted as a rotation by 90 degrees ! - // this leads to non WYSIWIG but at least it prints! - // #i21775# - long nWidth = aSize.Width(); - aSize.Width() = aSize.Height(); - aSize.Height() = nWidth; - } - Paper ePaper = SvxPaperInfo::GetSvPaper(aSize,MAP_TWIP,TRUE); - if ( PAPER_USER == ePaper ) - pOutDev->SetPaperSizeUser( aSize ); - else - pOutDev->SetPaper( ePaper ); -#endif // TL_NOT_NOW /*TLPDF*/ - } } } @@ -1361,50 +1385,26 @@ BOOL ViewShell::Prt( if( rOptions.bPrintReverse && rOptions.nPrintPostIts == POSTITS_ENDPAGE ) lcl_PrintPostItsEndPage( pPostItShell, aPostItFields, - nPageNo, aMulti, sJobName, bStartJob, nJobStartError, + nPage /* TLPDF nPageNo*/, aMulti, sJobName, bStartJob, nJobStartError, rOptions.bPrintRightPage, rOptions.bPrintLeftPage, rOptions.bPrintReverse ); -#ifdef TL_NOT_NOW /*TLPDF*/ - if ( pProgress ) - lcl_SetState( *pProgress, nPrintCount++, nSelCount, - pStr, nMergeAct, nMergeCnt, - nSelCount, nPageNo ); -#endif // TL_NOT_NOW /*TLPDF*/ if( !bStartJob && JOBSET_ERR_DEFAULT == nJobStartError && sJobName.Len() ) { -#ifdef TL_NOT_NOW /*TLPDF*/ - if( pOutDev && !pOutDev->IsJobActive() ) - { - bStartJob = pOutDev->StartJob( sJobName ); - if( !bStartJob ) - { - nJobStartError = JOBSET_ERR_ERROR; - continue; - } - } -#endif // TL_NOT_NOW /*TLPDF*/ // TLPDF pShell->InitPrt( pOutDev, bIsPDFExport ? pOutDev : 0 ); pShell->InitPrt( pOutDev ); - ::SetSwVisArea( pShell, pStPage->Frm(), TRUE /*bIsPDFExport*/ ); // TLPDF + ::SetSwVisArea( pShell, pStPage->Frm(), bIsPDFExport ); // TLPDF nJobStartError = JOBSET_ERR_ISSTARTET; } // --> FME 2005-12-12 #b6354161# Feature - Print empty pages - if ( rOptions.bPrintEmptyPages || pStPage->Frm().Height() ) +// TLPDF if ( rOptions.bPrintEmptyPages || pStPage->Frm().Height() ) // <-- { -// TLPDF if (pOutDev) -// TLPDF pOutDev->StartPage(); - pStPage->GetUpper()->Paint( pStPage->Frm() ); - ++nPagesPrinted; - -// TLPDF if (pOutDev) -// TLPDF pOutDev->EndPage(); } SwPaintQueue::Repaint(); @@ -1412,7 +1412,7 @@ BOOL ViewShell::Prt( if( (!rOptions.bPrintReverse) && rOptions.nPrintPostIts == POSTITS_ENDPAGE ) lcl_PrintPostItsEndPage( pPostItShell, aPostItFields, - nPageNo, aMulti, sJobName, bStartJob, nJobStartError, + nPage /* TLPDF nPageNo */, aMulti, sJobName, bStartJob, nJobStartError, rOptions.bPrintRightPage, rOptions.bPrintLeftPage, rOptions.bPrintReverse ); } @@ -1422,35 +1422,7 @@ BOOL ViewShell::Prt( if( pStPage->GetFmt()->GetPoolFmtId() == RES_POOLPAGE_JAKET ) pOutDev->SetMapMode( aOldMapMode ); - if ( pStPage == pEndPage ) - { -#ifdef TL_NOT_NOW /*TLPDF*/ - // --> FME 2005-01-05 #110536# Print emtpy page if - // we are have an odd page count in collation/duplex - // mode and there are still some copies to print: - if ( pPrt && ( 1 == ( nPagesPrinted % 2 ) ) && - ( DUPLEX_SHORTEDGE == pPrt->GetDuplexMode() || DUPLEX_LONGEDGE == pPrt->GetDuplexMode() ) && - nCnt + 1 < nCopyCnt ) - { - pOutDev->StartPage(); - pOutDev->EndPage(); - } - // <-- -#endif // TL_NOT_NOW /*TLPDF*/ - pStPage = 0; - } - else if ( rOptions.bPrintReverse ) - { - --nPageNo; - pStPage = (SwPageFrm*)pStPage->GetPrev(); - } - else - { ++nPageNo; - pStPage = (SwPageFrm*)pStPage->GetNext(); - } } // TLPDF loop end: while( pStPage && !bStop ) -// TLPDF if ( bStop ) -// TLPDF break; } if (!bStop) // TLPDF: see break above @@ -1473,10 +1445,6 @@ BOOL ViewShell::Prt( rOptions.bJobStartet = TRUE; } // TLPDF: if (!bStop) see break above -// TLPDF the copy count is now handled by the printer itself... -// TLPDF (end of the copy count loop) -// TLPDF } - } delete pStr; @@ -1493,9 +1461,9 @@ BOOL ViewShell::Prt( delete pOutDevDoc; } - // restore settings of OutputDevice - if (bIsPDFExport) - pOutDev->Pop(); + // restore settings of OutputDevice (should be done always now since the + // output device is now provided by a call from outside the Writer) + pOutDev->Pop(); return bStartJob; } diff --git a/sw/source/ui/dbui/dbmgr.cxx b/sw/source/ui/dbui/dbmgr.cxx index 0f7c203195be..7fa9a24338c2 100644 --- a/sw/source/ui/dbui/dbmgr.cxx +++ b/sw/source/ui/dbui/dbmgr.cxx @@ -881,6 +881,8 @@ SwNewDBMgr::~SwNewDBMgr() BOOL SwNewDBMgr::MergePrint( SwView& rView, SwPrtOptions& rOpt, SfxProgress& rProgress, BOOL bIsAPI ) { + (void) rView; (void) rOpt; (void) rProgress; (void) bIsAPI; /* TLPDF */ +#ifdef TL_NOT_NOW /*TLPDF*/ //!! Currently broken beyond repair since we will not have a printer SwWrtShell* pSh = &rView.GetWrtShell(); //check if the doc is synchronized and contains at least one linked section BOOL bSynchronizedDoc = pSh->IsLabelDoc() && pSh->GetSectionFmtCount() > 1; @@ -1038,6 +1040,8 @@ BOOL SwNewDBMgr::MergePrint( SwView& rView, } return bRet; +#endif // TL_NOT_NOW /*TLPDF*/ //!! Currently broken beyond repair since we will not have a printer + return TRUE; /* TLPDF */ } /*-- 21.06.2004 09:08:16--------------------------------------------------- @@ -1045,6 +1049,8 @@ BOOL SwNewDBMgr::MergePrint( SwView& rView, BOOL SwNewDBMgr::MergePrintDocuments( SwView& rView, SwPrtOptions& rOpt, SfxProgress& rProgress, BOOL bIsAPI ) { + (void) rView; (void) rOpt; (void) rProgress; (void) bIsAPI; /* TLPDF */ +#ifdef TL_NOT_NOW /*TLPDF*/ //!! Currently broken beyond repair since we will not have a printer SwWrtShell* pSh = &rView.GetWrtShell(); //check if the doc is synchronized and contains at least one linked section //merge source is already open @@ -1201,6 +1207,8 @@ BOOL SwNewDBMgr::MergePrintDocuments( SwView& rView, } return bRet; +#endif // TL_NOT_NOW /*TLPDF*/ //!! Currently broken beyond repair since we will not have a printer + return TRUE; /* TLPDF */ } diff --git a/sw/source/ui/uiview/pview.cxx b/sw/source/ui/uiview/pview.cxx index a9b36d255a23..263068d03a42 100644 --- a/sw/source/ui/uiview/pview.cxx +++ b/sw/source/ui/uiview/pview.cxx @@ -2470,7 +2470,11 @@ USHORT SwPagePreView::Print( SfxProgress &rProgress, BOOL bIsAPI, PrintDialog * if( bPrtPros ) pSh->PrintProspect( aOpts, rProgress, bPrtPros_RTL ); else + { +#ifdef TL_NOT_NOW /*TLPDF*/ //!! Currently broken beyond repair since we will not have a printer pSh->Prt( pPrinter, aOpts, &rProgress ); /*TLPDF*/ +#endif // TL_NOT_NOW /*TLPDF*/ //!! Currently broken beyond repair since we will not have a printer + } } else { diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index acb13e3681b4..097dbfa7bf96 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -31,8 +31,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" -#include -#include +#include #include #include #include @@ -40,6 +39,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -56,7 +58,6 @@ #include #include #include -#include #include #include #include // SfxObjectShellRef <-> SV_DECL_REF(SfxObjectShell) @@ -171,210 +172,6 @@ using ::osl::FileBase; * ******************************************************************************/ -class SwPrintUIOptions : public vcl::PrinterOptionsHelper -{ - OutputDevice* mpLast; -public: - SwPrintUIOptions( BOOL bWeb ); - - bool processPropertiesAndCheckFormat( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& i_rNewProp ); - -}; - -SwPrintUIOptions::SwPrintUIOptions( BOOL bWeb ) : - mpLast( NULL ) -{ - ResStringArray aLocalizedStrings( SW_RES( STR_PRINTOPTUI ) ); - - DBG_ASSERT( aLocalizedStrings.Count() >= 46, "resource incomplete" ); - if( aLocalizedStrings.Count() < 46 ) // bad resource ? - return; - - // create sequence of print UI options - // (5 options are not available for Writer-Web) - const int nNumProps = bWeb? 17 : 22; - m_aUIProperties.realloc( nNumProps ); - int nIdx = 0; - - // create Section for Contents (results in an extra tab page in dialog) - m_aUIProperties[ nIdx++ ].Value = getGroupControlOpt( aLocalizedStrings.GetString( 0 ), rtl::OUString() ); - - // create a bool option for graphics - m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 1 ), - aLocalizedStrings.GetString( 2 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintGraphics" ) ), - sal_True ); - // create a bool option for tables - m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 3 ), - aLocalizedStrings.GetString( 4 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintTables" ) ), - sal_True ); - - if (!bWeb) - { - // create a bool option for drawings - m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 5 ), - aLocalizedStrings.GetString( 6 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDrawings" ) ), - sal_True ); - } - - // create a bool option for controls - m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 7 ), - aLocalizedStrings.GetString( 8 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintControls" ) ), - sal_True ); - - // create a bool option for background - m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 9 ), - aLocalizedStrings.GetString( 10 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintBackground" ) ), - sal_True ); - - // create a bool option for black - m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 11 ), - aLocalizedStrings.GetString( 12 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintBlack" ) ), - sal_False ); - - if (!bWeb) - { - // create a bool option for hidden text - m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 13 ), - aLocalizedStrings.GetString( 14 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintHiddenText" ) ), - sal_False ); - - // create a bool option for place holder - m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 15 ), - aLocalizedStrings.GetString( 16 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintPlaceholder" ) ), - sal_False ); - } - - // create a list box for notes content - Sequence< rtl::OUString > aChoices( 4 ); - aChoices[0] = aLocalizedStrings.GetString( 19 ); - aChoices[1] = aLocalizedStrings.GetString( 20 ); - aChoices[2] = aLocalizedStrings.GetString( 21 ); - aChoices[3] = aLocalizedStrings.GetString( 22 ); - Sequence< rtl::OUString > aHelpText( 2 ); - aHelpText[0] = aLocalizedStrings.GetString( 18 ); - aHelpText[1] = aLocalizedStrings.GetString( 18 ); - m_aUIProperties[ nIdx++ ].Value = getChoiceControlOpt( aLocalizedStrings.GetString( 17 ), - aHelpText, - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintNotes" ) ), - aChoices, - 0, - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "List" ) ) - ); - - // create Section for Page settings (results in an extra tab page in dialog) - m_aUIProperties[ nIdx++ ].Value = getGroupControlOpt( aLocalizedStrings.GetString( 23 ), rtl::OUString() ); - - if (!bWeb) - { - // create a bool option for left pages - m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 24 ), - aLocalizedStrings.GetString( 25 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintLeftPages" ) ), - sal_True ); - - // create a bool option for right pages - m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 26 ), - aLocalizedStrings.GetString( 27 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintRightPages" ) ), - sal_True ); - } - - // create a bool option for reversed order (solve in vcl ?) - m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 28 ), - aLocalizedStrings.GetString( 29 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintReverseOrder" ) ), - sal_False ); - - // create a bool option for brochure - OUString aBrochurePropertyName( RTL_CONSTASCII_USTRINGPARAM( "PrintBrochure" ) ); - m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 30 ), - aLocalizedStrings.GetString( 31 ), - aBrochurePropertyName, - sal_False ); - - // create a bool option for brochure RTL dependent on brochure - m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 32 ), - aLocalizedStrings.GetString( 33 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintBrochureRTL" ) ), - sal_False, - &aBrochurePropertyName, - -1, - sal_True - ); - - // create subgroup for misc options - m_aUIProperties[ nIdx++ ].Value = getSubgroupControlOpt( rtl::OUString( aLocalizedStrings.GetString( 34 ) ), rtl::OUString() ); - - // create a bool option for blank pages - m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 35 ), - aLocalizedStrings.GetString( 36 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintEmptyPages" ) ), - sal_True ); - - // create a bool option for paper tray - m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 37 ), - aLocalizedStrings.GetString( 38 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PaperTray" ) ), - sal_False ); - - // print range selection - m_aUIProperties[nIdx++].Value = getSubgroupControlOpt( rtl::OUString( aLocalizedStrings.GetString( 39 ) ), rtl::OUString(), true, true ); - - // create a choice for the content to create - rtl::OUString aPrintRangeName( RTL_CONSTASCII_USTRINGPARAM( "PrintContent" ) ); - aChoices.realloc( 3 ); - aHelpText.realloc( 3 ); - aChoices[0] = aLocalizedStrings.GetString( 40 ); - aHelpText[0] = aLocalizedStrings.GetString( 41 ); - aChoices[1] = aLocalizedStrings.GetString( 42 ); - aHelpText[1] = aLocalizedStrings.GetString( 43 ); - aChoices[2] = aLocalizedStrings.GetString( 44 ); - aHelpText[2] = aLocalizedStrings.GetString( 45 ); - m_aUIProperties[nIdx++].Value = getChoiceControlOpt( rtl::OUString(), - aHelpText, - aPrintRangeName, - aChoices, - 0 ); - // create a an Edit dependent on "Pages" selected - m_aUIProperties[nIdx++].Value = getEditControlOpt( rtl::OUString(), - rtl::OUString(), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PageRange" ) ), - rtl::OUString(), - &aPrintRangeName, 1, sal_True - ); - - - DBG_ASSERT( nIdx == nNumProps, "number of added properties is not as expected" ); -} - -bool SwPrintUIOptions::processPropertiesAndCheckFormat( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& i_rNewProp ) -{ - bool bChanged = processProperties( i_rNewProp ); - - uno::Reference< awt::XDevice > xRenderDevice; - Any aVal( getValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "RenderDevice" ) ) ) ); - aVal >>= xRenderDevice; - - OutputDevice* pOut = 0; - if (xRenderDevice.is()) - { - VCLXDevice* pDevice = VCLXDevice::GetImplementation( xRenderDevice ); - pOut = pDevice ? pDevice->GetOutputDevice() : 0; - } - bChanged = bChanged || (pOut != mpLast); - if( pOut ) - mpLast = pOut; - - return bChanged; -} SwTxtFmtColl *lcl_GetParaStyle(const String& rCollName, SwDoc* pDoc) { @@ -2758,7 +2555,6 @@ SwViewOptionAdjust_Impl::~SwViewOptionAdjust_Impl() SwDoc * SwXTextDocument::GetRenderDoc( SfxViewShell *&rpView, const uno::Any& rSelection, bool bIsPDFExport ) { - (void) bIsPDFExport; SwDoc *pDoc = 0; uno::Reference< frame::XModel > xModel; @@ -2798,6 +2594,7 @@ SwDoc * SwXTextDocument::GetRenderDoc( SfxViewShell *&rpView, const uno::Any& rS } return pDoc; } + /* -----------------------------23.08.02 16:00-------------------------------- ---------------------------------------------------------------------------*/ @@ -2844,18 +2641,43 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount( SwViewOptionAdjust_Impl aAdjust(*pWrtShell); if( bFormat ) { - if (bIsPDFExport) - pWrtShell->SetPDFExportOption( sal_True ); + // since printing now also use the API for PDF export this option + // should be set for printing as well ... + pWrtShell->SetPDFExportOption( sal_True ); // --> FME 2005-05-23 #122919# Force field update before PDF export: pWrtShell->ViewShell::UpdateFlds(TRUE); // <-- pWrtShell->CalcLayout(); - if (bIsPDFExport) - pWrtShell->SetPDFExportOption( sal_False ); + pWrtShell->SetPDFExportOption( sal_False ); + } + + const sal_Int32 nPageCount = pDoc->GetPageCount(); + if (bIsPDFExport) + nRet = nPageCount; + else + { + OUString aPageRange = m_pPrintUIOptions->getStringValue( C2U( "PageRange" ), OUString() ); + if (aPageRange.getLength() == 0) + { + // set page range to print all pages + aPageRange = OUString::valueOf( (sal_Int32)1 ); + aPageRange += OUString::valueOf( (sal_Unicode)'-'); + aPageRange += OUString::valueOf( nPageCount ); + } + + // get set of valid pages (according to the current settings) + // and their start frames + pDoc->GetValidPagesForPrinting( *m_pPrintUIOptions, nPageCount ); + + // get vector of pages to print according to PageRange and valid pages from above + StringRangeEnumerator::getRangesFromString( + aPageRange, m_pPrintUIOptions->GetPagesToPrint(), + 1, nPageCount, 0, &m_pPrintUIOptions->GetValidPagesSet() ); + + nRet = m_pPrintUIOptions->GetPagesToPrint().size(); } - nRet = pDoc->GetPageCount(); return nRet; } @@ -2937,140 +2759,6 @@ SfxViewShell * SwXTextDocument::GuessViewShell() ---------------------------------------------------------------------------*/ -static bool lcl_getSingleValue( - const OUString &rText, - sal_Int32 &rVal ) -{ - bool bRes = false; - const sal_Int32 nLen = rText.getLength(); - if (nLen > 0) - { - // verify that text consists of decimal number 0..9 only - bool bValidText = true; - const sal_Unicode *pText = rText.getStr(); - for (sal_Int32 i = 0; i < nLen && bValidText; ++i) - { - const sal_Unicode cChar = pText[i]; - if (cChar < '0' || cChar > '9') - bValidText = false; - } - - // get integer value if text is valid - if (bValidText) - { - rVal = rText.toInt32(); - bRes = true; - } - } - return bRes; -} - -static bool lcl_getSubRangeBounds( - const OUString &rSubRange, - sal_Int32 &rFirst, - sal_Int32 &rLast ) -{ - bool bRes = false; - - // check for page range... - sal_Int32 nPos = rSubRange.indexOf( (sal_Unicode)'-' ); - if (nPos > 0) - { - // page range found... - nPos = 0; - const OUString aFirstPage( rSubRange.getToken( 0, '-', nPos ) ); - const OUString aLastPage( rSubRange.getToken( 0, '-', nPos ) ); - sal_Int32 nTmpFirst = -1; - sal_Int32 nTmpLast = -1; - if (lcl_getSingleValue( aFirstPage, nTmpFirst ) && lcl_getSingleValue( aLastPage, nTmpLast )) - { - rFirst = nTmpFirst; - rLast = nTmpLast; - bRes = true; - } - } - else - { - // single page value... - sal_Int32 nVal = -1; - if (lcl_getSingleValue( rSubRange, nVal )) - { - rFirst = rLast = nVal; - bRes = true; - } - } - - return bRes; -} - -static bool lcl_PageRangeToVector( - const OUString &rPageRange, // valid format example "5-3,9,9,7-8" instead of ',' ';' or ' ' are allowed as well - std::vector< sal_Int32 > &rPageVector ) -{ - bool bRes = false; - - // - strip leading and trailing whitespaces - // - unify token delimeters to ';' - // - remove duplicate delimiters - OUString aRange( rPageRange.trim() ); - aRange = aRange.replace( (sal_Unicode)' ', (sal_Unicode)';' ); - aRange = aRange.replace( (sal_Unicode)',', (sal_Unicode)';' ); - sal_Int32 nPos = -1; - while ((nPos = aRange.indexOf( C2U(";;") )) >= 0) - aRange = aRange.replaceAt( nPos, 2, C2U(";") ); - - if (aRange.getLength() > 0) - { - std::vector< sal_Int32 > aTmpVector; - - // iterate over all sub ranges and add the respective pages to the - // vector while preserving the page order - bool bFailed = false; - nPos = 0; - do - { - const OUString aSubRange = aRange.getToken( 0, ';', nPos ); - sal_Int32 nFirst = -1, nLast = -1; - if (lcl_getSubRangeBounds( aSubRange, nFirst, nLast ) - && nFirst > 0 && nLast > 0) - { - // add pages of sub range to vector - if (nFirst == nLast) - aTmpVector.push_back( nFirst ); - else if (nFirst < nLast) - { - for (sal_Int32 i = nFirst; i <= nLast; ++i) - aTmpVector.push_back( i ); - } - else if (nFirst > nLast) - { - for (sal_Int32 i = nFirst; i >= nLast; --i) - aTmpVector.push_back( i ); - } - else - OSL_ENSURE( 0, "unexpected case" ); - } - else - bFailed = true; - } - while (!bFailed && 0 <= nPos && nPos < aRange.getLength()); - - if (!bFailed) - { - rPageVector = aTmpVector; - bRes = true; - } - } - else - { - // empty string ... - rPageVector.clear(); - bRes = true; - } - - return bRes; -} - void SAL_CALL SwXTextDocument::render( sal_Int32 nRenderer, const uno::Any& rSelection, @@ -3151,16 +2839,6 @@ void SAL_CALL SwXTextDocument::render( rxOptions[ nProperty].Value >>= bSkipEmptyPages; } -#if OSL_DEBUG_LEVEL > 1 - std::vector< sal_Int32 > _aVec1; - bool _bTmp1 = lcl_PageRangeToVector( C2U(""), _aVec1 ); - _bTmp1 = lcl_PageRangeToVector( C2U("-1"), _aVec1 ); - _bTmp1 = lcl_PageRangeToVector( C2U("3 0"), _aVec1 ); - _bTmp1 = lcl_PageRangeToVector( C2U("1-5,7 7,15-12;8"), _aVec1 ); - _bTmp1 = lcl_PageRangeToVector( C2U(" 2-6,,7 7,15-12;;;9"), _aVec1 ); - _bTmp1 = lcl_PageRangeToVector( C2U(";,5-1,,7 7,12-15;;;9"), _aVec1 ); -#endif - OutputDevice* pOut = 0; if (xRenderDevice.is()) { @@ -3184,13 +2862,16 @@ void SAL_CALL SwXTextDocument::render( aOptions.bPrintRightPage = m_pPrintUIOptions->getBoolValue( C2U( "PrintRightPages" ), aOptions.bPrintRightPage ); aOptions.bPrintPageBackground = m_pPrintUIOptions->getBoolValue( C2U( "PrintBackground" ), aOptions.bPrintPageBackground ); aOptions.bPrintEmptyPages = m_pPrintUIOptions->getBoolValue( C2U( "PrintEmptyPages" ), aOptions.bPrintEmptyPages ); + // bUpdateFieldsInPrinting <-- not set here // TLPDF: TODO: remove this from SwPrintData?? Get rid of SwPrtOptions?? + aOptions.bPaperFromSetup = m_pPrintUIOptions->getBoolValue( C2U( "PaperTray" ), aOptions.bPaperFromSetup ); aOptions.bPrintReverse = m_pPrintUIOptions->getBoolValue( C2U( "PrintReverseOrder" ), aOptions.bPrintReverse ); aOptions.bPrintProspect = m_pPrintUIOptions->getBoolValue( C2U( "PrintBrochure" ), aOptions.bPrintProspect ); aOptions.bPrintProspect_RTL = m_pPrintUIOptions->getBoolValue( C2U( "PrintBrochureRTL" ), aOptions.bPrintProspect_RTL ); + // bPrintSingleJobs <-- not set here // TLPDF: TODO: remove this from SwPrintData?? Get rid of SwPrtOptions?? + // bModified <-- not set here // TLPDF: TODO: remove this from SwPrintData?? Get rid of SwPrtOptions?? aOptions.bPrintBlackFont = m_pPrintUIOptions->getBoolValue( C2U( "PrintBlack" ), aOptions.bPrintBlackFont ); aOptions.bPrintHiddenText = m_pPrintUIOptions->getBoolValue( C2U( "PrintHiddenText" ), aOptions.bPrintHiddenText ); aOptions.bPrintTextPlaceholder = m_pPrintUIOptions->getBoolValue( C2U( "PrintPlaceholder" ), aOptions.bPrintTextPlaceholder ); - aOptions.bPaperFromSetup = m_pPrintUIOptions->getBoolValue( C2U( "PaperTray" ), aOptions.bPaperFromSetup ); aOptions.nPrintPostIts = static_cast< sal_Int16 >(m_pPrintUIOptions->getIntValue( C2U( "PrintNotes" ), aOptions.nPrintPostIts )); Range aPageRange( nRenderer+1, nRenderer+1 ); @@ -3209,8 +2890,9 @@ void SAL_CALL SwXTextDocument::render( SwViewOptionAdjust_Impl* pViewOptionAdjust = pView->IsA(aSwViewTypeId) ? new SwViewOptionAdjust_Impl(*((SwView*)pView)->GetWrtShellPtr()) : 0; - if (bIsPDFExport) - pVwSh->SetPDFExportOption( sal_True ); + // since printing now also use the API for PDF export this option + // should be set for printing as well ... + pVwSh->SetPDFExportOption( sal_True ); // --> FME 2004-06-08 #i12836# enhanced pdf export // @@ -3229,7 +2911,7 @@ void SAL_CALL SwXTextDocument::render( // <-- // TLPDF OutputDevice *pOldDev = pVwSh->GetOut(); // TLPDF - pVwSh->Prt( pOut, aOptions, 0, bIsPDFExport ); + pVwSh->Prt( pOut, aOptions, *m_pPrintUIOptions, nRenderer, 0, bIsPDFExport ); // --> FME 2004-10-08 #i35176# // @@ -3243,8 +2925,7 @@ void SAL_CALL SwXTextDocument::render( } // <-- - if (bIsPDFExport) - pVwSh->SetPDFExportOption( sal_False ); + pVwSh->SetPDFExportOption( sal_False ); // #i96167# haggai: delete pViewOptionsAdjust here because it makes use // of the shell, which might get destroyed in lcl_DisposeView! -- cgit From 45ad2c0071344539dae16d686dd8dc838a085b33 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Fri, 17 Jul 2009 08:40:57 +0000 Subject: fix warnings --- sw/source/core/view/vprint.cxx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'sw') diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index 8e50ada89c58..14785e5adf91 100644 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -42,7 +42,7 @@ #include #include #include -#include +#include #include #include @@ -431,7 +431,7 @@ bool SwPrintUIOptions::processPropertiesAndCheckFormat( const com::sun::star::un * Aenderung : ******************************************************************************/ -void SetSwVisArea( ViewShell *pSh, const SwRect &rRect, BOOL bPDFExport ) +void SetSwVisArea( ViewShell *pSh, const SwRect &rRect, BOOL /*bPDFExport*/ ) { ASSERT( !pSh->GetWin(), "Drucken mit Window?" ); pSh->aVisArea = rRect; @@ -1316,8 +1316,10 @@ BOOL ViewShell::Prt( aMulti = aTmpMulti; // Ende des HACKs +#if 0 const USHORT nSelCount = USHORT(aMulti.GetSelectCount() /* * nCopyCnt*/); +#endif // PostitListe holen _SetGetExpFlds aPostItFields; @@ -1347,8 +1349,8 @@ BOOL ViewShell::Prt( MapMode aOldMapMode; const SwPageDesc *pLastPageDesc = NULL; - BOOL bSetOrient = FALSE; - BOOL bSetPaperSz = FALSE; + // BOOL bSetOrient = FALSE; + // BOOL bSetPaperSz = FALSE; BOOL bSetPrt = FALSE; if ( rOptions.nPrintPostIts != POSTITS_ONLY ) -- cgit From 3c33f07b5c7079d663b68876d7a156d99f41abdb Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Fri, 17 Jul 2009 09:37:10 +0000 Subject: fix warnings --- sw/source/ui/uno/unotxdoc.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sw') diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index 097dbfa7bf96..639133089530 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -39,7 +39,7 @@ #include #include #include -#include +#include #include #include #include @@ -2567,6 +2567,7 @@ SwDoc * SwXTextDocument::GetRenderDoc( SfxViewShell *&rpView, const uno::Any& rS // Otherwise the View should be obtained from the "View" property passed on in the // calls to the XRenderable functions. DBG_ASSERT( bIsPDFExport, "code should have been called for PDF export only..." ); + (void)bIsPDFExport; // avoid warning in non dbg case // used for PDF export of (multi-)selection if (rSelection.hasValue()) // is anything selected ? -- cgit From 2938f82faeb4d1c7999f06a1b0fe0ad0ef8fb8b9 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Wed, 22 Jul 2009 17:16:03 +0000 Subject: #i92516# adapt to new UI spec --- sw/source/core/view/vprint.cxx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'sw') diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index 14785e5adf91..2e868a493d30 100644 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -372,7 +372,10 @@ SwPrintUIOptions::SwPrintUIOptions( BOOL bWeb ) : sal_False ); // print range selection - m_aUIProperties[nIdx++].Value = getSubgroupControlOpt( rtl::OUString( aLocalizedStrings.GetString( 39 ) ), rtl::OUString(), true, true ); + m_aUIProperties[nIdx++].Value = getSubgroupControlOpt( rtl::OUString( aLocalizedStrings.GetString( 39 ) ), + rtl::OUString(), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintRange" ) ), + true ); // create a choice for the content to create rtl::OUString aPrintRangeName( RTL_CONSTASCII_USTRINGPARAM( "PrintContent" ) ); @@ -1259,12 +1262,12 @@ BOOL ViewShell::Prt( /* TLPDF neu: start */ #if OSL_DEBUG_LEVEL > 1 - DBG_ASSERT( 0 <= nRenderer && nRenderer <= rPrintUIOptions.GetPagesToPrint().size(), + DBG_ASSERT( 0 <= nRenderer && nRenderer <= sal_Int32(rPrintUIOptions.GetPagesToPrint().size()), "nRenderer out of bounds"); #endif const sal_Int32 nPage = rPrintUIOptions.GetPagesToPrint()[ nRenderer ]; /* TLPDF */ #if OSL_DEBUG_LEVEL > 1 - DBG_ASSERT( 0 <= nPage && nPage <= rPrintUIOptions.GetValidStartFrms().size(), + DBG_ASSERT( 0 <= nPage && nPage <= sal_Int32(rPrintUIOptions.GetValidStartFrms().size()), "nPage out of bounds"); #endif const SwPrintUIOptions::ValidStartFramesMap_t &rFrms = rPrintUIOptions.GetValidStartFrms(); -- cgit From f3c2c59f9df88a6ef538bc438a24bf8cd18001d4 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Thu, 23 Jul 2009 17:27:06 +0000 Subject: #i92516# adapt new UX spec --- sw/source/core/view/vprint.cxx | 111 ++++++++++++++++++++--------------------- sw/source/ui/config/optdlg.src | 13 +++-- sw/source/ui/uno/unotxdoc.cxx | 6 +-- 3 files changed, 66 insertions(+), 64 deletions(-) (limited to 'sw') diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index 2e868a493d30..8ed59b1e19f5 100644 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -52,6 +52,8 @@ #include #include +#include + #include #include #include @@ -238,31 +240,41 @@ SwPrintUIOptions::SwPrintUIOptions( BOOL bWeb ) : // create sequence of print UI options // (5 options are not available for Writer-Web) - const int nNumProps = bWeb? 17 : 22; + const int nNumProps = bWeb? 19 : 23; m_aUIProperties.realloc( nNumProps ); int nIdx = 0; - // create Section for Contents (results in an extra tab page in dialog) - m_aUIProperties[ nIdx++ ].Value = getGroupControlOpt( aLocalizedStrings.GetString( 0 ), rtl::OUString() ); + // create "writer" section (new tab page in dialog) + SvtModuleOptions aOpt; + m_aUIProperties[ nIdx++ ].Value = getGroupControlOpt( aOpt.GetModuleName( SvtModuleOptions::E_SWRITER ), rtl::OUString() ); + + // create sub section for Contents + m_aUIProperties[ nIdx++ ].Value = getSubgroupControlOpt( aLocalizedStrings.GetString( 0 ), rtl::OUString() ); + + // create a bool option for background + m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 9 ), + aLocalizedStrings.GetString( 10 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintBackground" ) ), + sal_True ); // create a bool option for graphics m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 1 ), aLocalizedStrings.GetString( 2 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintGraphics" ) ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintGraphicsAndDiagrams" ) ), sal_True ); - // create a bool option for tables - m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 3 ), - aLocalizedStrings.GetString( 4 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintTables" ) ), - sal_True ); - if (!bWeb) { - // create a bool option for drawings - m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 5 ), - aLocalizedStrings.GetString( 6 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDrawings" ) ), - sal_True ); + // create a bool option for hidden text + m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 13 ), + aLocalizedStrings.GetString( 14 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintHiddenText" ) ), + sal_False ); + + // create a bool option for place holder + m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 15 ), + aLocalizedStrings.GetString( 16 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintPlaceholder" ) ), + sal_False ); } // create a bool option for controls @@ -271,11 +283,8 @@ SwPrintUIOptions::SwPrintUIOptions( BOOL bWeb ) : rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintControls" ) ), sal_True ); - // create a bool option for background - m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 9 ), - aLocalizedStrings.GetString( 10 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintBackground" ) ), - sal_True ); + // create sub section for Color + m_aUIProperties[ nIdx++ ].Value = getSubgroupControlOpt( aLocalizedStrings.GetString( 47 ), rtl::OUString() ); // create a bool option for black m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 11 ), @@ -283,21 +292,32 @@ SwPrintUIOptions::SwPrintUIOptions( BOOL bWeb ) : rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintBlack" ) ), sal_False ); - if (!bWeb) - { - // create a bool option for hidden text - m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 13 ), - aLocalizedStrings.GetString( 14 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintHiddenText" ) ), - sal_False ); + // create subgroup for misc options + m_aUIProperties[ nIdx++ ].Value = getSubgroupControlOpt( rtl::OUString( aLocalizedStrings.GetString( 34 ) ), rtl::OUString() ); - // create a bool option for place holder - m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 15 ), - aLocalizedStrings.GetString( 16 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintPlaceholder" ) ), - sal_False ); - } + // create a bool option for blank pages + m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 35 ), + aLocalizedStrings.GetString( 36 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintEmptyPages" ) ), + sal_True ); + + // print content selection + m_aUIProperties[nIdx++].Value = getSubgroupControlOpt( rtl::OUString( aLocalizedStrings.GetString( 48 ) ), + rtl::OUString(), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OptionsPage" ) ) + ); + + // create a bool option for paper tray + m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 37 ), + aLocalizedStrings.GetString( 38 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PaperTray" ) ), + sal_False ); + // print content selection + m_aUIProperties[nIdx++].Value = getSubgroupControlOpt( rtl::OUString( aLocalizedStrings.GetString( 46 ) ), + rtl::OUString(), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "JobPage" ) ) + ); // create a list box for notes content uno::Sequence< rtl::OUString > aChoices( 4 ); aChoices[0] = aLocalizedStrings.GetString( 19 ); @@ -315,8 +335,8 @@ SwPrintUIOptions::SwPrintUIOptions( BOOL bWeb ) : rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "List" ) ) ); - // create Section for Page settings (results in an extra tab page in dialog) - m_aUIProperties[ nIdx++ ].Value = getGroupControlOpt( aLocalizedStrings.GetString( 23 ), rtl::OUString() ); + // create subsection for Page settings + m_aUIProperties[ nIdx++ ].Value = getSubgroupControlOpt( aLocalizedStrings.GetString( 23 ), rtl::OUString() ); if (!bWeb) { @@ -333,12 +353,6 @@ SwPrintUIOptions::SwPrintUIOptions( BOOL bWeb ) : sal_True ); } - // create a bool option for reversed order (solve in vcl ?) - m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 28 ), - aLocalizedStrings.GetString( 29 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintReverseOrder" ) ), - sal_False ); - // create a bool option for brochure rtl::OUString aBrochurePropertyName( RTL_CONSTASCII_USTRINGPARAM( "PrintBrochure" ) ); m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 30 ), @@ -356,21 +370,6 @@ SwPrintUIOptions::SwPrintUIOptions( BOOL bWeb ) : sal_True ); - // create subgroup for misc options - m_aUIProperties[ nIdx++ ].Value = getSubgroupControlOpt( rtl::OUString( aLocalizedStrings.GetString( 34 ) ), rtl::OUString() ); - - // create a bool option for blank pages - m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 35 ), - aLocalizedStrings.GetString( 36 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintEmptyPages" ) ), - sal_True ); - - // create a bool option for paper tray - m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 37 ), - aLocalizedStrings.GetString( 38 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PaperTray" ) ), - sal_False ); - // print range selection m_aUIProperties[nIdx++].Value = getSubgroupControlOpt( rtl::OUString( aLocalizedStrings.GetString( 39 ) ), rtl::OUString(), diff --git a/sw/source/ui/config/optdlg.src b/sw/source/ui/config/optdlg.src index 16d1c57b13ad..0a86f1d5ad5e 100644 --- a/sw/source/ui/config/optdlg.src +++ b/sw/source/ui/config/optdlg.src @@ -941,17 +941,17 @@ StringArray STR_PRINTOPTUI ItemList [en-US] = { < "Contents"; >; - < "~Graphics"; >; + < "~Graphics and diagrams"; >; < "Specifies whether the graphics of your text document are printed"; >; < "~Tables"; >; < "Specifies whether the tables of the text document are printed"; >; < "Dra~wings"; >; < "Specifies whether graphics created with %PRODUCTNAME drawing functions are printed."; >; - < "Control~s"; >; + < "Form control~s"; >; < "Specifies whether the form control fields of the text document are printed"; >; - < "Ba~ckground"; >; + < "Page Ba~ckground"; >; < "Specifies whether to include colors and objects that are inserted to the background of the page (Format - Page - Background) in the printed document."; >; - < "Print blac~k"; >; + < "Print text in blac~k"; >; < "Specifies whether to always print text in black."; >; < "Hidden te~xt"; >; < "Enable this option to print text that is marked as hidden."; >; @@ -959,7 +959,7 @@ StringArray STR_PRINTOPTUI < "Enable this option to print text placeholders. Disable this option to leave the text placeholders blank in the printout."; >; < "~Notes"; >; < "Specify where to print notes (if any)."; >; - < "None"; >; + < "Document only"; >; < "Notes only"; >; < " at end of document"; >; < " at end of page"; >; @@ -986,6 +986,9 @@ StringArray STR_PRINTOPTUI < "Print a range of pages of the document."; >; < "~Selection"; >; < "Print only the currently selected content."; >; + < "Print"; >; + < "Color"; >; + < "Paper tray"; >; }; }; diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index 639133089530..a00933d49dac 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -2855,9 +2855,9 @@ void SAL_CALL SwXTextDocument::render( const TypeId aSwWebDocShellTypeId = TYPE(SwWebDocShell); BOOL bWeb = pDocShell->IsA( aSwWebDocShellTypeId ); SwView::MakeOptions( NULL, aOptions, NULL, NULL, bWeb, NULL, NULL ); - aOptions.bPrintGraphic = m_pPrintUIOptions->getBoolValue( C2U( "PrintGraphics" ), aOptions.bPrintGraphic ); - aOptions.bPrintTable = m_pPrintUIOptions->getBoolValue( C2U( "PrintTables" ), aOptions.bPrintTable ); - aOptions.bPrintDraw = m_pPrintUIOptions->getBoolValue( C2U( "PrintDrawings" ), aOptions.bPrintDraw ); + aOptions.bPrintGraphic = m_pPrintUIOptions->getBoolValue( C2U( "PrintGraphicsAndDiagrams" ), aOptions.bPrintGraphic ); + aOptions.bPrintTable = m_pPrintUIOptions->getBoolValue( C2U( "PrintGraphicsAndDiagrams" ), aOptions.bPrintTable ); + aOptions.bPrintDraw = m_pPrintUIOptions->getBoolValue( C2U( "PrintGraphicsAndDiagrams" ), aOptions.bPrintDraw ); aOptions.bPrintControl = m_pPrintUIOptions->getBoolValue( C2U( "PrintControls" ), aOptions.bPrintControl ); aOptions.bPrintLeftPage = m_pPrintUIOptions->getBoolValue( C2U( "PrintLeftPages" ), aOptions.bPrintLeftPage ); aOptions.bPrintRightPage = m_pPrintUIOptions->getBoolValue( C2U( "PrintRightPages" ), aOptions.bPrintRightPage ); -- cgit From e7200b2b026e535228b1fa27d4ab450b8125f2fd Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Tue, 28 Jul 2009 09:43:30 +0000 Subject: #i101242# fixed crashwhen printing the page preview with new print UI --- sw/inc/unotxdoc.hxx | 441 +++++++++++++++++++++--------------------- sw/source/ui/inc/unotxvw.hxx | 6 - sw/source/ui/uiview/pview.cxx | 63 +----- sw/source/ui/uno/unotxdoc.cxx | 50 +++-- sw/source/ui/uno/unotxvw.cxx | 24 --- 5 files changed, 258 insertions(+), 326 deletions(-) (limited to 'sw') diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx index 50851a31e945..7b81a0ce191b 100644 --- a/sw/inc/unotxdoc.hxx +++ b/sw/inc/unotxdoc.hxx @@ -61,6 +61,7 @@ #include #include #include +#include #include #include #include @@ -115,6 +116,8 @@ public Ifc31 __DEF_IMPLHELPER_EX( 31 ) +namespace css = ::com::sun::star; + class SwDoc; class SwDocShell; class UnoActionContext; @@ -135,37 +138,37 @@ SV_DECL_PTRARR(ActionContextArr, UnoActionContextPtr, 4, 4) typedef cppu::WeakImplHelper31 < - ::com::sun::star::text::XTextDocument, - ::com::sun::star::text::XLineNumberingProperties, - ::com::sun::star::text::XChapterNumberingSupplier, - ::com::sun::star::text::XNumberingRulesSupplier, - ::com::sun::star::text::XFootnotesSupplier, - ::com::sun::star::text::XEndnotesSupplier, - ::com::sun::star::util::XReplaceable, - ::com::sun::star::text::XPagePrintable, - ::com::sun::star::text::XReferenceMarksSupplier, - ::com::sun::star::text::XTextTablesSupplier, - ::com::sun::star::text::XTextFramesSupplier, - ::com::sun::star::text::XBookmarksSupplier, - ::com::sun::star::text::XTextSectionsSupplier, - ::com::sun::star::text::XTextGraphicObjectsSupplier, - ::com::sun::star::text::XTextEmbeddedObjectsSupplier, - ::com::sun::star::text::XTextFieldsSupplier, - ::com::sun::star::style::XStyleFamiliesSupplier, - ::com::sun::star::style::XAutoStylesSupplier, - ::com::sun::star::lang::XServiceInfo, - ::com::sun::star::drawing::XDrawPageSupplier, - ::com::sun::star::text::XDocumentIndexesSupplier, - ::com::sun::star::beans::XPropertySet, - ::com::sun::star::beans::XPropertyState, - ::com::sun::star::document::XLinkTargetSupplier, - ::com::sun::star::document::XRedlinesSupplier, - ::com::sun::star::util::XRefreshable, - ::com::sun::star::util::XLinkUpdate, - ::com::sun::star::view::XRenderable, - ::com::sun::star::xforms::XFormsSupplier, - ::com::sun::star::text::XFlatParagraphIteratorProvider, - ::com::sun::star::document::XDocumentLanguages + css::text::XTextDocument, + css::text::XLineNumberingProperties, + css::text::XChapterNumberingSupplier, + css::text::XNumberingRulesSupplier, + css::text::XFootnotesSupplier, + css::text::XEndnotesSupplier, + css::util::XReplaceable, + css::text::XPagePrintable, + css::text::XReferenceMarksSupplier, + css::text::XTextTablesSupplier, + css::text::XTextFramesSupplier, + css::text::XBookmarksSupplier, + css::text::XTextSectionsSupplier, + css::text::XTextGraphicObjectsSupplier, + css::text::XTextEmbeddedObjectsSupplier, + css::text::XTextFieldsSupplier, + css::style::XStyleFamiliesSupplier, + css::style::XAutoStylesSupplier, + css::lang::XServiceInfo, + css::drawing::XDrawPageSupplier, + css::text::XDocumentIndexesSupplier, + css::beans::XPropertySet, + css::beans::XPropertyState, + css::document::XLinkTargetSupplier, + css::document::XRedlinesSupplier, + css::util::XRefreshable, + css::util::XLinkUpdate, + css::view::XRenderable, + css::xforms::XFormsSupplier, + css::text::XFlatParagraphIteratorProvider, + css::document::XDocumentLanguages > SwXTextDocumentBaseClass; @@ -182,39 +185,39 @@ class SwXTextDocument : public SwXTextDocumentBaseClass, sal_Bool bObjectValid; SwXDrawPage* pDrawPage; - ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage > * pxXDrawPage; + css::uno::Reference< css::drawing::XDrawPage > * pxXDrawPage; - ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > xBodyText; + css::uno::Reference< css::text::XText > xBodyText; SwXBodyText* pBodyText; - ::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation > xNumFmtAgg; - - ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > * pxXNumberingRules; - ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > * pxXFootnotes; - ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > * pxXFootnoteSettings; - ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > * pxXEndnotes; - ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > * pxXEndnoteSettings; - ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > * pxXReferenceMarks; - ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumerationAccess > * pxXTextFieldTypes; - ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > * pxXTextFieldMasters; - ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > * pxXTextSections; - ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > * pxXBookmarks; - ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > * pxXTextTables; - ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > * pxXTextFrames; - ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > * pxXGraphicObjects; - ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > * pxXEmbeddedObjects; - ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > * pxXStyleFamilies; - mutable ::com::sun::star::uno::Reference< ::com::sun::star::style::XAutoStyles > * pxXAutoStyles; - ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexReplace > * pxXChapterNumbering; - ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > * pxXDocumentIndexes; - - ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > * pxXLineNumberingProperties; - ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > * pxLinkTargetSupplier; - ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumerationAccess >* pxXRedlines; - ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer> xXFormsContainer; + css::uno::Reference< css::uno::XAggregation > xNumFmtAgg; + + css::uno::Reference< css::container::XIndexAccess > * pxXNumberingRules; + css::uno::Reference< css::container::XIndexAccess > * pxXFootnotes; + css::uno::Reference< css::beans::XPropertySet > * pxXFootnoteSettings; + css::uno::Reference< css::container::XIndexAccess > * pxXEndnotes; + css::uno::Reference< css::beans::XPropertySet > * pxXEndnoteSettings; + css::uno::Reference< css::container::XNameAccess > * pxXReferenceMarks; + css::uno::Reference< css::container::XEnumerationAccess > * pxXTextFieldTypes; + css::uno::Reference< css::container::XNameAccess > * pxXTextFieldMasters; + css::uno::Reference< css::container::XNameAccess > * pxXTextSections; + css::uno::Reference< css::container::XNameAccess > * pxXBookmarks; + css::uno::Reference< css::container::XNameAccess > * pxXTextTables; + css::uno::Reference< css::container::XNameAccess > * pxXTextFrames; + css::uno::Reference< css::container::XNameAccess > * pxXGraphicObjects; + css::uno::Reference< css::container::XNameAccess > * pxXEmbeddedObjects; + css::uno::Reference< css::container::XNameAccess > * pxXStyleFamilies; + mutable css::uno::Reference< css::style::XAutoStyles > * pxXAutoStyles; + css::uno::Reference< css::container::XIndexReplace > * pxXChapterNumbering; + css::uno::Reference< css::container::XIndexAccess > * pxXDocumentIndexes; + + css::uno::Reference< css::beans::XPropertySet > * pxXLineNumberingProperties; + css::uno::Reference< css::container::XNameAccess > * pxLinkTargetSupplier; + css::uno::Reference< css::container::XEnumerationAccess >* pxXRedlines; + css::uno::Reference< css::container::XNameContainer> xXFormsContainer; //temporary frame to enable PDF export if no valid view is available SfxViewFrame* m_pHiddenViewFrame; - ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> xPropertyHelper; + css::uno::Reference< css::uno::XInterface> xPropertyHelper; SwXDocumentPropertyHelper* pPropertyHelper; SwPrintUIOptions* m_pPrintUIOptions; @@ -223,8 +226,8 @@ class SwXTextDocument : public SwXTextDocumentBaseClass, void GetNumberFormatter(); // used for XRenderable implementation - SfxViewShell * GuessViewShell(); - SwDoc * GetRenderDoc( SfxViewShell *&rpView, const ::com::sun::star::uno::Any& rSelection, bool bIsPDFExport ); + SfxViewShell * GuessViewShell( const css::uno::Reference< css::frame::XController > xController = css::uno::Reference< css::frame::XController >() ); + SwDoc * GetRenderDoc( SfxViewShell *&rpView, const css::uno::Any& rSelection, bool bIsPDFExport ); rtl::OUString maBuildId; @@ -237,173 +240,173 @@ public: SwXTextDocument(SwDocShell* pShell); inline void notifyRefreshListeners() { aRefreshCont.Refreshed(); } - virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw(::com::sun::star::uno::RuntimeException); + virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) throw(css::uno::RuntimeException); virtual void SAL_CALL acquire( ) throw(); virtual void SAL_CALL release( ) throw(); //XWeak - virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XAdapter > SAL_CALL queryAdapter( ) throw(::com::sun::star::uno::RuntimeException); + virtual css::uno::Reference< css::uno::XAdapter > SAL_CALL queryAdapter( ) throw(css::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) throw(css::uno::RuntimeException); - SW_DLLPUBLIC static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId(); + SW_DLLPUBLIC static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId(); //XUnoTunnel - virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); + virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) throw(css::uno::RuntimeException); //XTextDocument - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > SAL_CALL getText(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL reformat(void) throw( ::com::sun::star::uno::RuntimeException ); + virtual css::uno::Reference< css::text::XText > SAL_CALL getText(void) throw( css::uno::RuntimeException ); + virtual void SAL_CALL reformat(void) throw( css::uno::RuntimeException ); //XModel - virtual sal_Bool SAL_CALL attachResource( const ::rtl::OUString& aURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArgs ) throw(::com::sun::star::uno::RuntimeException); - virtual ::rtl::OUString SAL_CALL getURL( ) throw(::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL getArgs( ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL connectController( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >& xController ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL disconnectController( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >& xController ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL lockControllers( ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL unlockControllers( ) throw(::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL hasControllersLocked( ) throw(::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > SAL_CALL getCurrentController( ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setCurrentController( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >& xController ) throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getCurrentSelection( ) throw(::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL attachResource( const ::rtl::OUString& aURL, const css::uno::Sequence< css::beans::PropertyValue >& aArgs ) throw(css::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getURL( ) throw(css::uno::RuntimeException); + virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getArgs( ) throw(css::uno::RuntimeException); + virtual void SAL_CALL connectController( const css::uno::Reference< css::frame::XController >& xController ) throw(css::uno::RuntimeException); + virtual void SAL_CALL disconnectController( const css::uno::Reference< css::frame::XController >& xController ) throw(css::uno::RuntimeException); + virtual void SAL_CALL lockControllers( ) throw(css::uno::RuntimeException); + virtual void SAL_CALL unlockControllers( ) throw(css::uno::RuntimeException); + virtual sal_Bool SAL_CALL hasControllersLocked( ) throw(css::uno::RuntimeException); + virtual css::uno::Reference< css::frame::XController > SAL_CALL getCurrentController( ) throw(css::uno::RuntimeException); + virtual void SAL_CALL setCurrentController( const css::uno::Reference< css::frame::XController >& xController ) throw(css::container::NoSuchElementException, css::uno::RuntimeException); + virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getCurrentSelection( ) throw(css::uno::RuntimeException); //XComponent - virtual void SAL_CALL dispose(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL dispose(void) throw( css::uno::RuntimeException ); + virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > & aListener) throw( css::uno::RuntimeException ); + virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > & aListener) throw( css::uno::RuntimeException ); //XCloseable - virtual void SAL_CALL close( sal_Bool bDeliverOwnership ) throw (::com::sun::star::util::CloseVetoException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL close( sal_Bool bDeliverOwnership ) throw (css::util::CloseVetoException, css::uno::RuntimeException); //XLineNumberingProperties - virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL getLineNumberingProperties(void) throw( ::com::sun::star::uno::RuntimeException ); + virtual css::uno::Reference< css::beans::XPropertySet > SAL_CALL getLineNumberingProperties(void) throw( css::uno::RuntimeException ); //XChapterNumberingSupplier - virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexReplace > SAL_CALL getChapterNumberingRules(void) throw( ::com::sun::star::uno::RuntimeException ); + virtual css::uno::Reference< css::container::XIndexReplace > SAL_CALL getChapterNumberingRules(void) throw( css::uno::RuntimeException ); //XNumberingRulesSupplier - virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > SAL_CALL getNumberingRules() throw (::com::sun::star::uno::RuntimeException); + virtual css::uno::Reference< css::container::XIndexAccess > SAL_CALL getNumberingRules() throw (css::uno::RuntimeException); //XFootnotesSupplier - virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > SAL_CALL getFootnotes(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL getFootnoteSettings(void) throw( ::com::sun::star::uno::RuntimeException ); + virtual css::uno::Reference< css::container::XIndexAccess > SAL_CALL getFootnotes(void) throw( css::uno::RuntimeException ); + virtual css::uno::Reference< css::beans::XPropertySet > SAL_CALL getFootnoteSettings(void) throw( css::uno::RuntimeException ); //XEndnotesSupplier - virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > SAL_CALL getEndnotes(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL getEndnoteSettings(void) throw( ::com::sun::star::uno::RuntimeException ); + virtual css::uno::Reference< css::container::XIndexAccess > SAL_CALL getEndnotes(void) throw( css::uno::RuntimeException ); + virtual css::uno::Reference< css::beans::XPropertySet > SAL_CALL getEndnoteSettings(void) throw( css::uno::RuntimeException ); //XReplaceable - virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XReplaceDescriptor > SAL_CALL createReplaceDescriptor(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual sal_Int32 SAL_CALL replaceAll(const ::com::sun::star::uno::Reference< ::com::sun::star::util::XSearchDescriptor > & xDesc) throw( ::com::sun::star::uno::RuntimeException ); + virtual css::uno::Reference< css::util::XReplaceDescriptor > SAL_CALL createReplaceDescriptor(void) throw( css::uno::RuntimeException ); + virtual sal_Int32 SAL_CALL replaceAll(const css::uno::Reference< css::util::XSearchDescriptor > & xDesc) throw( css::uno::RuntimeException ); //XSearchable - virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XSearchDescriptor > SAL_CALL createSearchDescriptor(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > SAL_CALL findAll(const ::com::sun::star::uno::Reference< ::com::sun::star::util::XSearchDescriptor > & xDesc) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL findFirst(const ::com::sun::star::uno::Reference< ::com::sun::star::util::XSearchDescriptor > & xDesc) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL findNext(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & xStartAt, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XSearchDescriptor > & xDesc) throw( ::com::sun::star::uno::RuntimeException ); + virtual css::uno::Reference< css::util::XSearchDescriptor > SAL_CALL createSearchDescriptor(void) throw( css::uno::RuntimeException ); + virtual css::uno::Reference< css::container::XIndexAccess > SAL_CALL findAll(const css::uno::Reference< css::util::XSearchDescriptor > & xDesc) throw( css::uno::RuntimeException ); + virtual css::uno::Reference< css::uno::XInterface > SAL_CALL findFirst(const css::uno::Reference< css::util::XSearchDescriptor > & xDesc) throw( css::uno::RuntimeException ); + virtual css::uno::Reference< css::uno::XInterface > SAL_CALL findNext(const css::uno::Reference< css::uno::XInterface > & xStartAt, const css::uno::Reference< css::util::XSearchDescriptor > & xDesc) throw( css::uno::RuntimeException ); //XPagePrintable - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL getPagePrintSettings(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL setPagePrintSettings(const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aSettings) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL printPages(const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& xOptions) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); + virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getPagePrintSettings(void) throw( css::uno::RuntimeException ); + virtual void SAL_CALL setPagePrintSettings(const css::uno::Sequence< css::beans::PropertyValue >& aSettings) throw( css::uno::RuntimeException ); + virtual void SAL_CALL printPages(const css::uno::Sequence< css::beans::PropertyValue >& xOptions) throw( css::lang::IllegalArgumentException, css::uno::RuntimeException ); //XReferenceMarksSupplier - virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getReferenceMarks(void) throw( ::com::sun::star::uno::RuntimeException ); + virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getReferenceMarks(void) throw( css::uno::RuntimeException ); - // ::com::sun::star::text::XTextFieldsSupplier - virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumerationAccess > SAL_CALL getTextFields(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getTextFieldMasters(void) throw( ::com::sun::star::uno::RuntimeException ); + // css::text::XTextFieldsSupplier + virtual css::uno::Reference< css::container::XEnumerationAccess > SAL_CALL getTextFields(void) throw( css::uno::RuntimeException ); + virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getTextFieldMasters(void) throw( css::uno::RuntimeException ); - // ::com::sun::star::text::XTextEmbeddedObjectsSupplier - virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getEmbeddedObjects(void) throw( ::com::sun::star::uno::RuntimeException ); + // css::text::XTextEmbeddedObjectsSupplier + virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getEmbeddedObjects(void) throw( css::uno::RuntimeException ); -// // ::com::sun::star::text::XTextShapesSupplier -// virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > getShapes(void) throw( ::com::sun::star::uno::RuntimeException ); +// // css::text::XTextShapesSupplier +// virtual css::uno::Reference< css::container::XIndexAccess > getShapes(void) throw( css::uno::RuntimeException ); - // ::com::sun::star::text::XBookmarksSupplier - virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getBookmarks(void) throw( ::com::sun::star::uno::RuntimeException ); + // css::text::XBookmarksSupplier + virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getBookmarks(void) throw( css::uno::RuntimeException ); - // ::com::sun::star::text::XTextSectionsSupplier - virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getTextSections(void) throw( ::com::sun::star::uno::RuntimeException ); + // css::text::XTextSectionsSupplier + virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getTextSections(void) throw( css::uno::RuntimeException ); - // ::com::sun::star::text::XTextTablesSupplier - virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getTextTables(void) throw( ::com::sun::star::uno::RuntimeException ); + // css::text::XTextTablesSupplier + virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getTextTables(void) throw( css::uno::RuntimeException ); - // ::com::sun::star::text::XTextGraphicObjectsSupplier - virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getGraphicObjects(void) throw( ::com::sun::star::uno::RuntimeException ); + // css::text::XTextGraphicObjectsSupplier + virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getGraphicObjects(void) throw( css::uno::RuntimeException ); - // ::com::sun::star::text::XTextFramesSupplier - virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getTextFrames(void) throw( ::com::sun::star::uno::RuntimeException ); + // css::text::XTextFramesSupplier + virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getTextFrames(void) throw( css::uno::RuntimeException ); //XStyleFamiliesSupplier - virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getStyleFamilies(void) throw( ::com::sun::star::uno::RuntimeException ); + virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getStyleFamilies(void) throw( css::uno::RuntimeException ); //XAutoStylesSupplier - virtual ::com::sun::star::uno::Reference< ::com::sun::star::style::XAutoStyles > SAL_CALL getAutoStyles( ) throw (::com::sun::star::uno::RuntimeException); + virtual css::uno::Reference< css::style::XAutoStyles > SAL_CALL getAutoStyles( ) throw (css::uno::RuntimeException); //XMultiServiceFactory - virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstance(const rtl::OUString& ServiceSpecifier) - throw( ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstanceWithArguments(const rtl::OUString& ServiceSpecifier, - const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Arguments) - throw( ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getAvailableServiceNames(void) - throw( ::com::sun::star::uno::RuntimeException ); + virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstance(const rtl::OUString& ServiceSpecifier) + throw( css::uno::Exception, css::uno::RuntimeException ); + virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstanceWithArguments(const rtl::OUString& ServiceSpecifier, + const css::uno::Sequence< css::uno::Any >& Arguments) + throw( css::uno::Exception, css::uno::RuntimeException ); + virtual css::uno::Sequence< rtl::OUString > SAL_CALL getAvailableServiceNames(void) + throw( css::uno::RuntimeException ); //XServiceInfo - virtual rtl::OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual BOOL SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException ); + virtual rtl::OUString SAL_CALL getImplementationName(void) throw( css::uno::RuntimeException ); + virtual BOOL SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( css::uno::RuntimeException ); + virtual css::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( css::uno::RuntimeException ); - // ::com::sun::star::drawing::XDrawPageSupplier - virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage > SAL_CALL getDrawPage(void) throw( ::com::sun::star::uno::RuntimeException ); + // css::drawing::XDrawPageSupplier + virtual css::uno::Reference< css::drawing::XDrawPage > SAL_CALL getDrawPage(void) throw( css::uno::RuntimeException ); - // ::com::sun::star::text::XDocumentIndexesSupplier - virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > SAL_CALL getDocumentIndexes(void) throw( ::com::sun::star::uno::RuntimeException ); + // css::text::XDocumentIndexesSupplier + virtual css::uno::Reference< css::container::XIndexAccess > SAL_CALL getDocumentIndexes(void) throw( css::uno::RuntimeException ); //XPropertySet - virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(css::uno::RuntimeException); + virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const css::uno::Any& aValue ) throw(css::beans::UnknownPropertyException, css::beans::PropertyVetoException, css::lang::IllegalArgumentException, css::lang::WrappedTargetException, css::uno::RuntimeException); + virtual css::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException); + virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException); + virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException); + virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException); + virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException); //XPropertyState - virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState( const ::rtl::OUString& rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyState > SAL_CALL getPropertyStates( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rPropertyNames ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setPropertyToDefault( const ::rtl::OUString& rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault( const ::rtl::OUString& rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual css::beans::PropertyState SAL_CALL getPropertyState( const ::rtl::OUString& rPropertyName ) throw (css::beans::UnknownPropertyException, css::uno::RuntimeException); + virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL getPropertyStates( const css::uno::Sequence< ::rtl::OUString >& rPropertyNames ) throw (css::beans::UnknownPropertyException, css::uno::RuntimeException); + virtual void SAL_CALL setPropertyToDefault( const ::rtl::OUString& rPropertyName ) throw (css::beans::UnknownPropertyException, css::uno::RuntimeException); + virtual css::uno::Any SAL_CALL getPropertyDefault( const ::rtl::OUString& rPropertyName ) throw (css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException); //XLinkTargetSupplier - virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getLinks(void) throw( ::com::sun::star::uno::RuntimeException ); + virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getLinks(void) throw( css::uno::RuntimeException ); //XRedlinesSupplier - virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumerationAccess > SAL_CALL getRedlines( ) throw(::com::sun::star::uno::RuntimeException); + virtual css::uno::Reference< css::container::XEnumerationAccess > SAL_CALL getRedlines( ) throw(css::uno::RuntimeException); - // ::com::sun::star::util::XRefreshable - virtual void SAL_CALL refresh(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL addRefreshListener(const ::com::sun::star::uno::Reference< ::com::sun::star::util::XRefreshListener > & l) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL removeRefreshListener(const ::com::sun::star::uno::Reference< ::com::sun::star::util::XRefreshListener > & l) throw( ::com::sun::star::uno::RuntimeException ); + // css::util::XRefreshable + virtual void SAL_CALL refresh(void) throw( css::uno::RuntimeException ); + virtual void SAL_CALL addRefreshListener(const css::uno::Reference< css::util::XRefreshListener > & l) throw( css::uno::RuntimeException ); + virtual void SAL_CALL removeRefreshListener(const css::uno::Reference< css::util::XRefreshListener > & l) throw( css::uno::RuntimeException ); - // ::com::sun::star::util::XLinkUpdate, - virtual void SAL_CALL updateLinks( ) throw(::com::sun::star::uno::RuntimeException); + // css::util::XLinkUpdate, + virtual void SAL_CALL updateLinks( ) throw(css::uno::RuntimeException); - // ::com::sun::star::view::XRenderable - virtual sal_Int32 SAL_CALL getRendererCount( const ::com::sun::star::uno::Any& aSelection, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& xOptions ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL getRenderer( sal_Int32 nRenderer, const ::com::sun::star::uno::Any& aSelection, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& xOptions ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL render( sal_Int32 nRenderer, const ::com::sun::star::uno::Any& aSelection, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& xOptions ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + // css::view::XRenderable + virtual sal_Int32 SAL_CALL getRendererCount( const css::uno::Any& aSelection, const css::uno::Sequence< css::beans::PropertyValue >& xOptions ) throw (css::lang::IllegalArgumentException, css::uno::RuntimeException); + virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getRenderer( sal_Int32 nRenderer, const css::uno::Any& aSelection, const css::uno::Sequence< css::beans::PropertyValue >& xOptions ) throw (css::lang::IllegalArgumentException, css::uno::RuntimeException); + virtual void SAL_CALL render( sal_Int32 nRenderer, const css::uno::Any& aSelection, const css::uno::Sequence< css::beans::PropertyValue >& xOptions ) throw (css::lang::IllegalArgumentException, css::uno::RuntimeException); - // ::com::sun::star::xforms::XFormsSupplier - virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > SAL_CALL getXForms( ) throw (::com::sun::star::uno::RuntimeException); + // css::xforms::XFormsSupplier + virtual css::uno::Reference< css::container::XNameContainer > SAL_CALL getXForms( ) throw (css::uno::RuntimeException); - // ::com::sun::star::document::XDocumentLanguages - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::lang::Locale > SAL_CALL getDocumentLanguages( ::sal_Int16 nScriptTypes, ::sal_Int16 nCount ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + // css::document::XDocumentLanguages + virtual css::uno::Sequence< css::lang::Locale > SAL_CALL getDocumentLanguages( ::sal_Int16 nScriptTypes, ::sal_Int16 nCount ) throw (css::lang::IllegalArgumentException, css::uno::RuntimeException); - // ::com::sun::star::text::XFlatParagraphIteratorProvider: - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XFlatParagraphIterator > SAL_CALL getFlatParagraphIterator(::sal_Int32 nTextMarkupType, sal_Bool bAutomatic ) throw (::com::sun::star::uno::RuntimeException); + // css::text::XFlatParagraphIteratorProvider: + virtual css::uno::Reference< css::text::XFlatParagraphIterator > SAL_CALL getFlatParagraphIterator(::sal_Int32 nTextMarkupType, sal_Bool bAutomatic ) throw (css::uno::RuntimeException); // void Invalidate(); @@ -413,11 +416,11 @@ public: void InitNewDoc(); - SwUnoCrsr* CreateCursorForSearch(::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > & xCrsr); - SwUnoCrsr* FindAny(const ::com::sun::star::uno::Reference< ::com::sun::star::util::XSearchDescriptor > & xDesc, - ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > & xCrsr, sal_Bool bAll, + SwUnoCrsr* CreateCursorForSearch(css::uno::Reference< css::text::XTextCursor > & xCrsr); + SwUnoCrsr* FindAny(const css::uno::Reference< css::util::XSearchDescriptor > & xDesc, + css::uno::Reference< css::text::XTextCursor > & xCrsr, sal_Bool bAll, sal_Int32& nResult, - ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xLastResult); + css::uno::Reference< css::uno::XInterface > xLastResult); SwXDrawPage* GetDrawPage(); SwDocShell* GetDocShell() {return pDocShell;} @@ -431,8 +434,8 @@ public: --------------------------------------------------*/ class SwXLinkTargetSupplier : public cppu::WeakImplHelper2 < - ::com::sun::star::container::XNameAccess, - ::com::sun::star::lang::XServiceInfo + css::container::XNameAccess, + css::lang::XServiceInfo > { SwXTextDocument* pxDoc; @@ -449,18 +452,18 @@ public: ~SwXLinkTargetSupplier(); //XNameAccess - virtual ::com::sun::star::uno::Any SAL_CALL getByName(const rtl::OUString& Name) throw( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getElementNames(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual sal_Bool SAL_CALL hasByName(const rtl::OUString& Name) throw( ::com::sun::star::uno::RuntimeException ); + virtual css::uno::Any SAL_CALL getByName(const rtl::OUString& Name) throw( css::container::NoSuchElementException, css::lang::WrappedTargetException, css::uno::RuntimeException ); + virtual css::uno::Sequence< rtl::OUString > SAL_CALL getElementNames(void) throw( css::uno::RuntimeException ); + virtual sal_Bool SAL_CALL hasByName(const rtl::OUString& Name) throw( css::uno::RuntimeException ); //XElementAccess - virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw(::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL hasElements( ) throw(::com::sun::star::uno::RuntimeException); + virtual css::uno::Type SAL_CALL getElementType( ) throw(css::uno::RuntimeException); + virtual sal_Bool SAL_CALL hasElements( ) throw(css::uno::RuntimeException); //XServiceInfo - virtual rtl::OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual BOOL SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException ); + virtual rtl::OUString SAL_CALL getImplementationName(void) throw( css::uno::RuntimeException ); + virtual BOOL SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( css::uno::RuntimeException ); + virtual css::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( css::uno::RuntimeException ); // void Invalidate() {pxDoc = 0;} @@ -470,52 +473,52 @@ public: --------------------------------------------------*/ class SwXLinkNameAccessWrapper : public cppu::WeakImplHelper4 < - ::com::sun::star::beans::XPropertySet, - ::com::sun::star::container::XNameAccess, - ::com::sun::star::lang::XServiceInfo, - ::com::sun::star::document::XLinkTargetSupplier + css::beans::XPropertySet, + css::container::XNameAccess, + css::lang::XServiceInfo, + css::document::XLinkTargetSupplier > { - ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > xRealAccess; + css::uno::Reference< css::container::XNameAccess > xRealAccess; const SfxItemPropertySet* pPropSet; const String sLinkSuffix; const String sLinkDisplayName; - ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextDocument > xDoc; + css::uno::Reference< css::text::XTextDocument > xDoc; SwXTextDocument* pxDoc; public: - SwXLinkNameAccessWrapper(::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > xAccess, + SwXLinkNameAccessWrapper(css::uno::Reference< css::container::XNameAccess > xAccess, const String& rLinkDisplayName, String sSuffix); SwXLinkNameAccessWrapper(SwXTextDocument& rxDoc, const String& rLinkDisplayName, String sSuffix); ~SwXLinkNameAccessWrapper(); //XNameAccess - virtual ::com::sun::star::uno::Any SAL_CALL getByName(const rtl::OUString& Name) throw( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getElementNames(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual sal_Bool SAL_CALL hasByName(const rtl::OUString& Name) throw( ::com::sun::star::uno::RuntimeException ); + virtual css::uno::Any SAL_CALL getByName(const rtl::OUString& Name) throw( css::container::NoSuchElementException, css::lang::WrappedTargetException, css::uno::RuntimeException ); + virtual css::uno::Sequence< rtl::OUString > SAL_CALL getElementNames(void) throw( css::uno::RuntimeException ); + virtual sal_Bool SAL_CALL hasByName(const rtl::OUString& Name) throw( css::uno::RuntimeException ); //XElementAccess - virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw(::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL hasElements( ) throw(::com::sun::star::uno::RuntimeException); + virtual css::uno::Type SAL_CALL getElementType( ) throw(css::uno::RuntimeException); + virtual sal_Bool SAL_CALL hasElements( ) throw(css::uno::RuntimeException); //XPropertySet - virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(css::uno::RuntimeException); + virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const css::uno::Any& aValue ) throw(css::beans::UnknownPropertyException, css::beans::PropertyVetoException, css::lang::IllegalArgumentException, css::lang::WrappedTargetException, css::uno::RuntimeException); + virtual css::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException); + virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException); + virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException); + virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException); + virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException); //XLinkTargetSupplier - virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getLinks(void) throw( ::com::sun::star::uno::RuntimeException ); + virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getLinks(void) throw( css::uno::RuntimeException ); //XServiceInfo - virtual rtl::OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual BOOL SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException ); + virtual rtl::OUString SAL_CALL getImplementationName(void) throw( css::uno::RuntimeException ); + virtual BOOL SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( css::uno::RuntimeException ); + virtual css::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( css::uno::RuntimeException ); }; /* -----------------26.10.99 15:46------------------- @@ -523,8 +526,8 @@ public: --------------------------------------------------*/ class SwXOutlineTarget : public cppu::WeakImplHelper2 < - ::com::sun::star::beans::XPropertySet, - ::com::sun::star::lang::XServiceInfo + css::beans::XPropertySet, + css::lang::XServiceInfo > { const SfxItemPropertySet* pPropSet; @@ -535,36 +538,36 @@ public: ~SwXOutlineTarget(); //XPropertySet - virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(css::uno::RuntimeException); + virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const css::uno::Any& aValue ) throw(css::beans::UnknownPropertyException, css::beans::PropertyVetoException, css::lang::IllegalArgumentException, css::lang::WrappedTargetException, css::uno::RuntimeException); + virtual css::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException); + virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException); + virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException); + virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException); + virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException); //XServiceInfo - virtual rtl::OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual BOOL SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException ); + virtual rtl::OUString SAL_CALL getImplementationName(void) throw( css::uno::RuntimeException ); + virtual BOOL SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( css::uno::RuntimeException ); + virtual css::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( css::uno::RuntimeException ); }; #endif class SwXDocumentPropertyHelper : public SvxUnoForbiddenCharsTable { - com::sun::star::uno::Reference < com::sun::star::uno::XInterface > xDashTable; - com::sun::star::uno::Reference < com::sun::star::uno::XInterface > xGradientTable; - com::sun::star::uno::Reference < com::sun::star::uno::XInterface > xHatchTable; - com::sun::star::uno::Reference < com::sun::star::uno::XInterface > xBitmapTable; - com::sun::star::uno::Reference < com::sun::star::uno::XInterface > xTransGradientTable; - com::sun::star::uno::Reference < com::sun::star::uno::XInterface > xMarkerTable; - com::sun::star::uno::Reference < com::sun::star::uno::XInterface > xDrawDefaults; + css::uno::Reference < css::uno::XInterface > xDashTable; + css::uno::Reference < css::uno::XInterface > xGradientTable; + css::uno::Reference < css::uno::XInterface > xHatchTable; + css::uno::Reference < css::uno::XInterface > xBitmapTable; + css::uno::Reference < css::uno::XInterface > xTransGradientTable; + css::uno::Reference < css::uno::XInterface > xMarkerTable; + css::uno::Reference < css::uno::XInterface > xDrawDefaults; SwDoc* m_pDoc; public: SwXDocumentPropertyHelper(SwDoc& rDoc); ~SwXDocumentPropertyHelper(); - com::sun::star::uno::Reference GetDrawTable(short nWhich); + css::uno::Reference GetDrawTable(short nWhich); void Invalidate(); virtual void onChange(); diff --git a/sw/source/ui/inc/unotxvw.hxx b/sw/source/ui/inc/unotxvw.hxx index 794371499186..4db18720cf87 100644 --- a/sw/source/ui/inc/unotxvw.hxx +++ b/sw/source/ui/inc/unotxvw.hxx @@ -72,7 +72,6 @@ class SwXTextView : public ::com::sun::star::view::XViewSettingsSupplier, public ::com::sun::star::beans::XPropertySet, public ::com::sun::star::datatransfer::XTransferableSupplier, - public ::com::sun::star::lang::XUnoTunnel, public SfxBaseController { SelectionChangeListenerArr aSelChangedListeners; @@ -153,11 +152,6 @@ public: virtual ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > SAL_CALL getTransferable( ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL insertTransferable( const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& xTrans ) throw (::com::sun::star::datatransfer::UnsupportedFlavorException, ::com::sun::star::uno::RuntimeException); - // XUnoTunnel - virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); - - static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId(); - void NotifySelChanged(); void NotifyDBChanged(); diff --git a/sw/source/ui/uiview/pview.cxx b/sw/source/ui/uiview/pview.cxx index c2512a3e5d2a..e9b8094d0e7f 100644 --- a/sw/source/ui/uiview/pview.cxx +++ b/sw/source/ui/uiview/pview.cxx @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include @@ -2415,65 +2416,9 @@ void SwPagePreView::ScrollDocSzChg() USHORT SwPagePreView::Print( SfxProgress &rProgress, BOOL bIsAPI, PrintDialog *pDlg ) { - ViewShell* pSh = aViewWin.GetViewShell(); - SfxPrinter* pPrinter = GetPrinter(); - if( !pPrinter || !pPrinter->InitJob( &aViewWin, - pSh->HasDrawView() && !bIsAPI && pSh->GetDrawView()->GetModel()->HasTransparentObjects() )) - return ERRCODE_IO_ABORT; - - SwWait aWait( *GetDocShell(), TRUE ); - - USHORT nRowCol = ( aViewWin.GetRow() << 8 ) + - aViewWin.GetCol(); // Zeilen / DoppelSeiten - - { - // die Felder aktualisieren - // ACHTUNG: hochcasten auf die EditShell, um die SS zu nutzen. - // In den Methoden wird auf die akt. Shell abgefragt! - SwEditShell* pESh = (SwEditShell*)pSh; - SwDocStat aDocStat; - BOOL bIsModified = pESh->IsModified(); - - pESh->StartAllAction(); - pESh->UpdateDocStat( aDocStat ); - pSh->UpdateFlds(); - pESh->EndAllAction(); - - if( !bIsModified ) - pESh->ResetModified(); - } - - // Druckauftrag starten - SfxObjectShell *pObjShell = GetViewFrame()->GetObjectShell(); - SwPrtOptions aOpts( pObjShell->GetTitle(0) ); - - BOOL bPrtPros; - BOOL bPrtPros_RTL; - SwView::MakeOptions( pDlg, aOpts, &bPrtPros, &bPrtPros_RTL, FALSE, GetPrinter(), GetDocShell()->GetDoc()->getPrintData() ); - - if( bNormalPrint ) - { - if( bPrtPros ) - pSh->PrintProspect( aOpts, rProgress, bPrtPros_RTL ); - else - { -#ifdef TL_NOT_NOW /*TLPDF*/ //!! Currently broken beyond repair since we will not have a printer - pSh->Prt( pPrinter, aOpts, &rProgress ); /*TLPDF*/ -#endif // TL_NOT_NOW /*TLPDF*/ //!! Currently broken beyond repair since we will not have a printer - } - } - else - { - const SwPagePreViewPrtData* pPPVPD = pSh->GetDoc()->GetPreViewPrtData(); - if( pPPVPD && pPPVPD->GetCol() && pPPVPD->GetRow() ) - { - // Zeilen / Seiten - nRowCol = ( pPPVPD->GetRow() << 8 ) + pPPVPD->GetCol(); - } - else - pPPVPD = 0; - pSh->PrintPreViewPage( aOpts, nRowCol, rProgress, pPPVPD ); - } + (void) rProgress; (void) bIsAPI; (void) pDlg; + // TLPDF no longer needed in new print UI + // TLPDF TODO: clean-up return 0; // OK } diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index a00933d49dac..5ea1e3f5bb1b 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -2733,7 +2733,8 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SwXTextDocument::getRenderer( /* -----------------------------28.10.02 16:00-------------------------------- ---------------------------------------------------------------------------*/ -SfxViewShell * SwXTextDocument::GuessViewShell() +SfxViewShell * SwXTextDocument::GuessViewShell( + const uno::Reference< css::frame::XController > xController ) { // #130810# SfxViewShell::Current() / SfxViewShell::GetObjectShell() // must not be used (see comment from MBA) @@ -2742,18 +2743,30 @@ SfxViewShell * SwXTextDocument::GuessViewShell() SwView *pSwView = 0; SwPagePreView *pSwPagePreView = 0; SfxViewFrame *pFrame = SfxViewFrame::GetFirst( pDocShell, 0, sal_False ); + + // look for the view shell with the same controller in use, + // otherwise look for a suitable view, preferably a SwView, + // if that one is not found use a SwPagePreView if found. while (pFrame) { pView = pFrame->GetViewShell(); pSwView = dynamic_cast< SwView * >(pView); - if (pSwView) - break; if (!pSwPagePreView) pSwPagePreView = dynamic_cast< SwPagePreView * >(pView); + if (xController.is()) + { + if (pView && pView->GetController() == xController) + break; + } + else if (pSwView) + break; pFrame = SfxViewFrame::GetNext( *pFrame, pDocShell, 0, sal_False ); } - return pSwView ? pSwView : dynamic_cast< SwView * >(pSwPagePreView); + DBG_ASSERT( pSwView || pSwPagePreView, "failed to get view shell" ); + return pSwView ? + dynamic_cast< SfxViewShell * >(pSwView) : + dynamic_cast< SfxViewShell * >(pSwPagePreView); } /* -----------------------------23.08.02 16:00-------------------------------- @@ -2788,15 +2801,8 @@ void SAL_CALL SwXTextDocument::render( uno::Reference< frame::XController > xController; if (aTmp >>= xController) { - uno::Reference< lang::XUnoTunnel > xTunnel( xController, uno::UNO_QUERY ); - if (xTunnel.is()) - { - SwXTextView *pTextView = reinterpret_cast< SwXTextView * >( - sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething( SwXTextView::getUnoTunnelId()) )); - if (pTextView) - pView = pTextView->GetView(); - } - + DBG_ASSERT( xController.is(), "controller is empty!" ); + pView = GuessViewShell( xController ); } } @@ -2808,18 +2814,26 @@ void SAL_CALL SwXTextDocument::render( // due to #110067# (document page count changes sometimes during // PDF export/printing) we can not check for the upper bound properly. // Thus instead of throwing the exception we silently return. - if (!(0 <= nRenderer /* && nRenderer < pDoc->GetPageCount()*/)) + if (0 > nRenderer) throw IllegalArgumentException(); - if (nRenderer >= pDoc->GetPageCount()) + const sal_Int32 nMaxCount = bIsPDFExport? + static_cast< sal_Int32 >(pDoc->GetPageCount()) : + static_cast< sal_Int32 >(m_pPrintUIOptions->GetPagesToPrint().size()); + if (nRenderer >= nMaxCount) return; // the view shell should be SwView for documents PDF export // or SwPagePreView for PDF export of the page preview //!! (check for SwView first as in GuessViewShell) !! + DBG_ASSERT( pView, "!! view missing !!" ); const TypeId aSwViewTypeId = TYPE(SwView); - ViewShell* pVwSh = pView->IsA(aSwViewTypeId) ? - ((SwView*)pView)->GetWrtShellPtr() : - ((SwPagePreView*)pView)->GetViewShell(); + ViewShell* pVwSh = 0; + if (pView) + { + pVwSh = pView->IsA(aSwViewTypeId) ? + ((SwView*)pView)->GetWrtShellPtr() : + ((SwPagePreView*)pView)->GetViewShell(); + } uno::Reference< awt::XDevice > xRenderDevice; bool bFirstPage = false; diff --git a/sw/source/ui/uno/unotxvw.cxx b/sw/source/ui/uno/unotxvw.cxx index a91a1ca26a6a..667d0f987783 100644 --- a/sw/source/ui/uno/unotxvw.cxx +++ b/sw/source/ui/uno/unotxvw.cxx @@ -293,11 +293,6 @@ uno::Any SAL_CALL SwXTextView::queryInterface( const uno::Type& aType ) uno::Reference xRet = this; aRet.setValue(&xRet, aType); } - else if(aType == ::getCppuType((uno::Reference*)0)) - { - uno::Reference xRet = this; - aRet.setValue(&xRet, aType); - } else aRet = SfxBaseController::queryInterface(aType); return aRet; @@ -2220,24 +2215,5 @@ void SAL_CALL SwXTextView::insertTransferable( const uno::Reference< datatransfe } } -const uno::Sequence< sal_Int8 > & SwXTextView::getUnoTunnelId() -{ - static uno::Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId(); - return aSeq; -} - -sal_Int64 SAL_CALL SwXTextView::getSomething( - const uno::Sequence< sal_Int8 >& rId ) -throw(uno::RuntimeException) -{ - if( rId.getLength() == 16 - && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), - rId.getConstArray(), 16 ) ) - { - return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >( this )); - } - return 0; -} - // ----------------------------------------------------------------------------- -- cgit From 938fa6d43dbf395adc0aaee52d694ccd815fc8ad Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Tue, 28 Jul 2009 13:36:59 +0000 Subject: #i101242# print-preview toolbar changes --- sw/uiconfig/sglobal/toolbar/previewobjectbar.xml | 1 - sw/uiconfig/sweb/toolbar/previewobjectbar.xml | 1 - sw/uiconfig/swform/toolbar/previewobjectbar.xml | 1 - sw/uiconfig/swreport/toolbar/previewobjectbar.xml | 1 - sw/uiconfig/swriter/toolbar/previewobjectbar.xml | 1 - sw/uiconfig/swxform/toolbar/previewobjectbar.xml | 1 - 6 files changed, 6 deletions(-) (limited to 'sw') diff --git a/sw/uiconfig/sglobal/toolbar/previewobjectbar.xml b/sw/uiconfig/sglobal/toolbar/previewobjectbar.xml index a1a2c2f84f89..f0dc732d4ef9 100644 --- a/sw/uiconfig/sglobal/toolbar/previewobjectbar.xml +++ b/sw/uiconfig/sglobal/toolbar/previewobjectbar.xml @@ -19,7 +19,6 @@ - diff --git a/sw/uiconfig/sweb/toolbar/previewobjectbar.xml b/sw/uiconfig/sweb/toolbar/previewobjectbar.xml index a1c2fe8ded6e..5c6d30522614 100644 --- a/sw/uiconfig/sweb/toolbar/previewobjectbar.xml +++ b/sw/uiconfig/sweb/toolbar/previewobjectbar.xml @@ -19,7 +19,6 @@ - diff --git a/sw/uiconfig/swform/toolbar/previewobjectbar.xml b/sw/uiconfig/swform/toolbar/previewobjectbar.xml index 8278110f8e4c..435250b63af5 100644 --- a/sw/uiconfig/swform/toolbar/previewobjectbar.xml +++ b/sw/uiconfig/swform/toolbar/previewobjectbar.xml @@ -19,7 +19,6 @@ - diff --git a/sw/uiconfig/swreport/toolbar/previewobjectbar.xml b/sw/uiconfig/swreport/toolbar/previewobjectbar.xml index 8278110f8e4c..435250b63af5 100644 --- a/sw/uiconfig/swreport/toolbar/previewobjectbar.xml +++ b/sw/uiconfig/swreport/toolbar/previewobjectbar.xml @@ -19,7 +19,6 @@ - diff --git a/sw/uiconfig/swriter/toolbar/previewobjectbar.xml b/sw/uiconfig/swriter/toolbar/previewobjectbar.xml index 8278110f8e4c..435250b63af5 100644 --- a/sw/uiconfig/swriter/toolbar/previewobjectbar.xml +++ b/sw/uiconfig/swriter/toolbar/previewobjectbar.xml @@ -19,7 +19,6 @@ - diff --git a/sw/uiconfig/swxform/toolbar/previewobjectbar.xml b/sw/uiconfig/swxform/toolbar/previewobjectbar.xml index 8278110f8e4c..435250b63af5 100644 --- a/sw/uiconfig/swxform/toolbar/previewobjectbar.xml +++ b/sw/uiconfig/swxform/toolbar/previewobjectbar.xml @@ -19,7 +19,6 @@ - -- cgit From bbca31dd7f98e9e1c7f79be366191f7d39430877 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Tue, 28 Jul 2009 19:03:24 +0000 Subject: #i92518# adapt UI spec --- sw/inc/swprtopt.hxx | 2 ++ sw/source/core/doc/doc.cxx | 6 ++-- sw/source/core/view/vprint.cxx | 78 ++++++++++++++++++++++++++---------------- sw/source/ui/config/optdlg.src | 5 +++ sw/source/ui/uno/unotxdoc.cxx | 10 ++++-- 5 files changed, 67 insertions(+), 34 deletions(-) (limited to 'sw') diff --git a/sw/inc/swprtopt.hxx b/sw/inc/swprtopt.hxx index d2b45b37d234..b8a48d678f1a 100644 --- a/sw/inc/swprtopt.hxx +++ b/sw/inc/swprtopt.hxx @@ -120,6 +120,8 @@ public: const ValidStartFramesMap_t & GetValidStartFrms() const { return aValidStartFrms; } std::vector< sal_Int32 > & GetPagesToPrint() { return aPagesToPrint; } const std::vector< sal_Int32 > & GetPagesToPrint() const { return aPagesToPrint; } + bool isPrintLeftPages() const; + bool isPrintRightPages() const; }; diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index 2e92d8adb89b..9a4f94c9de80 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -46,7 +46,7 @@ #include #include #include -#include +#include #include #include #include @@ -999,8 +999,8 @@ void SwDoc::GetValidPagesForPrinting( return; // properties to take into account when calcualting the set of pages - const bool bPrintLeftPage = rPrintUIOptions.getBoolValue( C2U( "PrintLeftPages" ), false ); - const bool bPrintRightPage = rPrintUIOptions.getBoolValue( C2U( "PrintRightPages" ), false ); + const bool bPrintLeftPage = rPrintUIOptions.isPrintLeftPages(); + const bool bPrintRightPage = rPrintUIOptions.isPrintRightPages(); const bool bPrintReverse = rPrintUIOptions.getBoolValue( C2U( "PrintReverseOrder" ), false ); const bool bPrintEmptyPages = rPrintUIOptions.getBoolValue( C2U( "PrintEmptyPages" ), false ); diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index 19bdd5c8145b..a13396da99b0 100644 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -240,7 +240,7 @@ SwPrintUIOptions::SwPrintUIOptions( BOOL bWeb ) : // create sequence of print UI options // (5 options are not available for Writer-Web) - const int nNumProps = bWeb? 19 : 23; + const int nNumProps = bWeb? 18 : 21; m_aUIProperties.realloc( nNumProps ); int nIdx = 0; @@ -301,22 +301,22 @@ SwPrintUIOptions::SwPrintUIOptions( BOOL bWeb ) : rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintEmptyPages" ) ), sal_True ); - // print content selection - m_aUIProperties[nIdx++].Value = getSubgroupControlOpt( rtl::OUString( aLocalizedStrings.GetString( 48 ) ), - rtl::OUString(), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OptionsPage" ) ) - ); - // create a bool option for paper tray + vcl::PrinterOptionsHelper::UIControlOptions aPaperTrayOpt; + aPaperTrayOpt.maGroupHint = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OptionsPageOptGroup" ) ); m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 37 ), aLocalizedStrings.GetString( 38 ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PaperTray" ) ), - sal_False ); + sal_False, + aPaperTrayOpt + ); // print content selection + vcl::PrinterOptionsHelper::UIControlOptions aContentsOpt; + aContentsOpt.maGroupHint = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "JobPage" ) ); m_aUIProperties[nIdx++].Value = getSubgroupControlOpt( rtl::OUString( aLocalizedStrings.GetString( 46 ) ), rtl::OUString(), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "JobPage" ) ) + aContentsOpt ); // create a list box for notes content uno::Sequence< rtl::OUString > aChoices( 4 ); @@ -336,21 +336,24 @@ SwPrintUIOptions::SwPrintUIOptions( BOOL bWeb ) : ); // create subsection for Page settings - m_aUIProperties[ nIdx++ ].Value = getSubgroupControlOpt( aLocalizedStrings.GetString( 23 ), rtl::OUString() ); + vcl::PrinterOptionsHelper::UIControlOptions aPageSetOpt; + aPageSetOpt.maGroupHint = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutPage" ) ); if (!bWeb) { - // create a bool option for left pages - m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 24 ), - aLocalizedStrings.GetString( 25 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintLeftPages" ) ), - sal_True ); - - // create a bool option for right pages - m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 26 ), - aLocalizedStrings.GetString( 27 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintRightPages" ) ), - sal_True ); + uno::Sequence< rtl::OUString > aRLChoices( 3 ); + aRLChoices[0] = aLocalizedStrings.GetString( 51 ); + aRLChoices[1] = aLocalizedStrings.GetString( 52 ); + aRLChoices[2] = aLocalizedStrings.GetString( 53 ); + uno::Sequence< rtl::OUString > aRLHelp( 1 ); + aRLHelp[0] = aLocalizedStrings.GetString( 50 ); + // create a choice option for all/left/right pages + m_aUIProperties[ nIdx++ ].Value = getChoiceControlOpt( aLocalizedStrings.GetString( 49 ), + aRLHelp, + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintLeftRightPages" ) ), + aRLChoices, 0, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "List" ) ), + aPageSetOpt + ); } // create a bool option for brochure @@ -358,23 +361,28 @@ SwPrintUIOptions::SwPrintUIOptions( BOOL bWeb ) : m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 30 ), aLocalizedStrings.GetString( 31 ), aBrochurePropertyName, - sal_False ); + sal_False, + aPageSetOpt + ); // create a bool option for brochure RTL dependent on brochure + vcl::PrinterOptionsHelper::UIControlOptions aBrochureRTLOpt( aBrochurePropertyName, -1, sal_True ); + aBrochureRTLOpt.maGroupHint = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutPage" ) ); m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 32 ), aLocalizedStrings.GetString( 33 ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintBrochureRTL" ) ), sal_False, - &aBrochurePropertyName, - -1, - sal_True + aBrochureRTLOpt ); // print range selection + vcl::PrinterOptionsHelper::UIControlOptions aPrintRangeOpt; + aPrintRangeOpt.maGroupHint = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintRange" ) ); + aPrintRangeOpt.mbInternalOnly = sal_True; m_aUIProperties[nIdx++].Value = getSubgroupControlOpt( rtl::OUString( aLocalizedStrings.GetString( 39 ) ), rtl::OUString(), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintRange" ) ), - true ); + aPrintRangeOpt + ); // create a choice for the content to create rtl::OUString aPrintRangeName( RTL_CONSTASCII_USTRINGPARAM( "PrintContent" ) ); @@ -392,17 +400,29 @@ SwPrintUIOptions::SwPrintUIOptions( BOOL bWeb ) : aChoices, 0 ); // create a an Edit dependent on "Pages" selected + vcl::PrinterOptionsHelper::UIControlOptions aPageRangeOpt( aPrintRangeName, 1, sal_True ); m_aUIProperties[nIdx++].Value = getEditControlOpt( rtl::OUString(), rtl::OUString(), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PageRange" ) ), rtl::OUString(), - &aPrintRangeName, 1, sal_True - ); + aPageRangeOpt + ); DBG_ASSERT( nIdx == nNumProps, "number of added properties is not as expected" ); } +bool SwPrintUIOptions::isPrintLeftPages() const +{ + sal_Int64 nLRPages = getIntValue( "PrintLeftRightPages", 0 ); + return nLRPages == 0 || nLRPages == 1; +} + +bool SwPrintUIOptions::isPrintRightPages() const +{ + sal_Int64 nLRPages = getIntValue( "PrintLeftRightPages", 0 ); + return nLRPages == 0 || nLRPages == 2; +} bool SwPrintUIOptions::processPropertiesAndCheckFormat( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& i_rNewProp ) { diff --git a/sw/source/ui/config/optdlg.src b/sw/source/ui/config/optdlg.src index 0a86f1d5ad5e..24692190abdf 100644 --- a/sw/source/ui/config/optdlg.src +++ b/sw/source/ui/config/optdlg.src @@ -989,6 +989,11 @@ StringArray STR_PRINTOPTUI < "Print"; >; < "Color"; >; < "Paper tray"; >; + < "Include"; >; + < "Specify which pages to include in the output"; >; + < "left and right pages"; >; + < "left pages"; >; + < "right pages"; >; }; }; diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index 5ea1e3f5bb1b..027b787db29d 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -2869,12 +2869,18 @@ void SAL_CALL SwXTextDocument::render( const TypeId aSwWebDocShellTypeId = TYPE(SwWebDocShell); BOOL bWeb = pDocShell->IsA( aSwWebDocShellTypeId ); SwView::MakeOptions( NULL, aOptions, NULL, NULL, bWeb, NULL, NULL ); + sal_Int64 nLeftRightPages = 0; + if( ! aOptions.bPrintLeftPage ) + nLeftRightPages = 2; + if( ! aOptions.bPrintRightPage ) + nLeftRightPages = 1; + nLeftRightPages = m_pPrintUIOptions->getIntValue( "PrintLeftRightPages", nLeftRightPages ); aOptions.bPrintGraphic = m_pPrintUIOptions->getBoolValue( C2U( "PrintGraphicsAndDiagrams" ), aOptions.bPrintGraphic ); aOptions.bPrintTable = m_pPrintUIOptions->getBoolValue( C2U( "PrintGraphicsAndDiagrams" ), aOptions.bPrintTable ); aOptions.bPrintDraw = m_pPrintUIOptions->getBoolValue( C2U( "PrintGraphicsAndDiagrams" ), aOptions.bPrintDraw ); aOptions.bPrintControl = m_pPrintUIOptions->getBoolValue( C2U( "PrintControls" ), aOptions.bPrintControl ); - aOptions.bPrintLeftPage = m_pPrintUIOptions->getBoolValue( C2U( "PrintLeftPages" ), aOptions.bPrintLeftPage ); - aOptions.bPrintRightPage = m_pPrintUIOptions->getBoolValue( C2U( "PrintRightPages" ), aOptions.bPrintRightPage ); + aOptions.bPrintLeftPage = nLeftRightPages == 0 || nLeftRightPages == 1; + aOptions.bPrintRightPage = nLeftRightPages == 0 || nLeftRightPages == 2; aOptions.bPrintPageBackground = m_pPrintUIOptions->getBoolValue( C2U( "PrintBackground" ), aOptions.bPrintPageBackground ); aOptions.bPrintEmptyPages = m_pPrintUIOptions->getBoolValue( C2U( "PrintEmptyPages" ), aOptions.bPrintEmptyPages ); // bUpdateFieldsInPrinting <-- not set here // TLPDF: TODO: remove this from SwPrintData?? Get rid of SwPrtOptions?? -- cgit From 3c93e8d423b0f7c3f448fd1e7ccf06fce0b307cd Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Wed, 29 Jul 2009 09:01:57 +0000 Subject: #i101242# print-preview toolbar changes --- sw/inc/cmdid.h | 1 - sw/sdi/swriter.sdi | 25 ------------------------- sw/sdi/swslots.src | 6 +----- sw/sdi/viewsh.sdi | 4 ---- sw/source/ui/app/mn.src | 6 ------ sw/source/ui/uiview/pview.cxx | 6 ------ sw/source/ui/uiview/pview.src | 5 ----- 7 files changed, 1 insertion(+), 52 deletions(-) (limited to 'sw') diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h index 1fab6f1d15d4..8d56735d17a9 100644 --- a/sw/inc/cmdid.h +++ b/sw/inc/cmdid.h @@ -324,7 +324,6 @@ Achtung: Ab sofort sind in diesem File keine C++-Kommentare (//) mehr #define FN_GLOBAL_OPEN (FN_VIEW + 47) /* oeffnen */ #define FN_GLOBAL_SAVE_CONTENT (FN_VIEW + 48) /* Inhalt der Verknuepfung mitspeichern */ #define FN_CREATE_NAVIGATION (FN_VIEW + 49) /* Navigations-Controller erzeugen */ -#define FN_PREVIEW_PRINT_OPTIONS (FN_VIEW + 50) /* Optionsdialog Preview drucken */ #define FN_PREVIEW_ZOOM (FN_VIEW + 51) /* der Tabellencontroller fuer den Zoom */ #define FN_SET_MODOPT_TBLNUMFMT (FN_VIEW + 52) /* Zahlenerkennung in Tabellen */ diff --git a/sw/sdi/swriter.sdi b/sw/sdi/swriter.sdi index 784100694d4a..97093e15a04f 100644 --- a/sw/sdi/swriter.sdi +++ b/sw/sdi/swriter.sdi @@ -6533,31 +6533,6 @@ SfxInt16Item PasteSpecial FN_PASTESPECIAL GroupId = GID_EDIT; ] -//-------------------------------------------------------------------------- -SfxVoidItem PreviewPrintOptions FN_PREVIEW_PRINT_OPTIONS -() -[ - /* flags: */ - AutoUpdate = TRUE, - Cachable = Cachable, - FastCall = TRUE, - HasCoreId = FALSE, - HasDialog = TRUE, - ReadOnlyDoc = FALSE, - Toggle = FALSE, - Container = FALSE, - RecordAbsolute = FALSE, - RecordPerSet; - Synchron; - - /* config: */ - AccelConfig = TRUE, - MenuConfig = TRUE, - StatusBarConfig = FALSE, - ToolBoxConfig = TRUE, - GroupId = GID_DOC; -] - //-------------------------------------------------------------------------- SfxVoidItem PreviewZoom FN_PREVIEW_ZOOM ( SfxUInt16Item PreviewZoom FN_PREVIEW_ZOOM ) diff --git a/sw/sdi/swslots.src b/sw/sdi/swslots.src index d62d1da6b35b..0638e462a7ab 100644 --- a/sw/sdi/swslots.src +++ b/sw/sdi/swslots.src @@ -902,10 +902,6 @@ SfxSlotInfo FN_PREV_WORD_SEL { Slotname [ en-US ] = "Select to Begin of Word"; }; -SfxSlotInfo FN_PREVIEW_PRINT_OPTIONS -{ - Slotname [ en-US ] = "Print options page view"; -}; SfxSlotInfo FN_PREVIEW_ZOOM { Slotname [ en-US ] = "Preview Zoom"; @@ -916,7 +912,7 @@ SfxSlotInfo FN_PRINT_LAYOUT }; SfxSlotInfo FN_PRINT_PAGEPREVIEW { - Slotname [ en-US ] = "Print page view"; + Slotname [ en-US ] = "Print document"; }; SfxSlotInfo FN_MAILMERGE_WIZARD { diff --git a/sw/sdi/viewsh.sdi b/sw/sdi/viewsh.sdi index 18d537144c5b..1f3113ffe286 100644 --- a/sw/sdi/viewsh.sdi +++ b/sw/sdi/viewsh.sdi @@ -218,10 +218,6 @@ interface TextPrintPreview : View ExecMethod = Execute ; StateMethod = GetState ; ] - FN_PREVIEW_PRINT_OPTIONS //status() - [ - ExecMethod = Execute ; - ] FN_PRINT_PAGEPREVIEW // status() [ ExecMethod = Execute ; diff --git a/sw/source/ui/app/mn.src b/sw/source/ui/app/mn.src index e13d2418cc58..b07ec9cd984a 100644 --- a/sw/source/ui/app/mn.src +++ b/sw/source/ui/app/mn.src @@ -1053,12 +1053,6 @@ Menu MN_PPREVIEW_POPUPMENU HelpID = FN_PRINT_PAGEPREVIEW ; Text [ en-US ] = "Print" ; }; - MenuItem - { - Identifier = FN_PREVIEW_PRINT_OPTIONS; - HelpID = FN_PREVIEW_PRINT_OPTIONS; - Text [ en-US ] = "Print Options"; - }; SEPARATOR ; MenuItem { diff --git a/sw/source/ui/uiview/pview.cxx b/sw/source/ui/uiview/pview.cxx index e9b8094d0e7f..1dc6c393dfcf 100644 --- a/sw/source/ui/uiview/pview.cxx +++ b/sw/source/ui/uiview/pview.cxx @@ -1521,12 +1521,6 @@ MOVEPAGE: rReq.SetSlot( FN_PRINT_PAGEPREVIEW ); return; } - case FN_PREVIEW_PRINT_OPTIONS : - { - SwPreviewPrintOptionsDialog aDlg(aViewWin, *this); - aDlg.Execute(); - } - break; case SID_PRINTDOCDIRECT: case SID_PRINTDOC: ::SetAppPrintOptions( aViewWin.GetViewShell(), FALSE ); diff --git a/sw/source/ui/uiview/pview.src b/sw/source/ui/uiview/pview.src index a213c8df80e7..ff7f834db7a6 100644 --- a/sw/source/ui/uiview/pview.src +++ b/sw/source/ui/uiview/pview.src @@ -453,11 +453,6 @@ ToolBox RID_PVIEW_TOOLBOX Identifier = FN_PRINT_PAGEPREVIEW ; HelpID = FN_PRINT_PAGEPREVIEW ; }; - ToolBoxItem - { - Identifier = FN_PREVIEW_PRINT_OPTIONS ; - HelpID = FN_PREVIEW_PRINT_OPTIONS ; - }; ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; }; ToolBoxItem { -- cgit From f1c760737a33e1afc96d949149f6104fff110976 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Sat, 1 Aug 2009 15:16:11 +0000 Subject: #i92518# lates UI changes --- sw/source/core/view/vprint.cxx | 7 +++++-- sw/source/ui/config/optdlg.src | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'sw') diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index a13396da99b0..323c692948a3 100644 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -246,7 +246,10 @@ SwPrintUIOptions::SwPrintUIOptions( BOOL bWeb ) : // create "writer" section (new tab page in dialog) SvtModuleOptions aOpt; - m_aUIProperties[ nIdx++ ].Value = getGroupControlOpt( aOpt.GetModuleName( SvtModuleOptions::E_SWRITER ), rtl::OUString() ); + String aAppGroupname( aLocalizedStrings.GetString( 54 ) ); + aAppGroupname.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "%s" ) ), + aOpt.GetModuleName( SvtModuleOptions::E_SWRITER ) ); + m_aUIProperties[ nIdx++ ].Value = getGroupControlOpt( aAppGroupname, rtl::OUString() ); // create sub section for Contents m_aUIProperties[ nIdx++ ].Value = getSubgroupControlOpt( aLocalizedStrings.GetString( 0 ), rtl::OUString() ); @@ -1300,7 +1303,7 @@ BOOL ViewShell::Prt( /* TLPDF neu: end */ - // benötigte Seiten fuers Drucken formatieren + // ben�tigte Seiten fuers Drucken formatieren pShell->CalcPagesForPrint( (USHORT)nPage, pProgress, pStr, nMergeAct, nMergeCnt ); diff --git a/sw/source/ui/config/optdlg.src b/sw/source/ui/config/optdlg.src index 24692190abdf..19df21c5a26a 100644 --- a/sw/source/ui/config/optdlg.src +++ b/sw/source/ui/config/optdlg.src @@ -994,6 +994,7 @@ StringArray STR_PRINTOPTUI < "left and right pages"; >; < "left pages"; >; < "right pages"; >; + < "%PRODUCTNAME %s"; >; }; }; -- cgit From 8baea37360aa2da89c0156c4d735df242a377dc4 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Sat, 1 Aug 2009 15:43:09 +0000 Subject: #i92518# lates UI changes --- sw/source/ui/config/optdlg.src | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sw') diff --git a/sw/source/ui/config/optdlg.src b/sw/source/ui/config/optdlg.src index 19df21c5a26a..103b5970decf 100644 --- a/sw/source/ui/config/optdlg.src +++ b/sw/source/ui/config/optdlg.src @@ -949,7 +949,7 @@ StringArray STR_PRINTOPTUI < "Specifies whether graphics created with %PRODUCTNAME drawing functions are printed."; >; < "Form control~s"; >; < "Specifies whether the form control fields of the text document are printed"; >; - < "Page Ba~ckground"; >; + < "Page ba~ckground"; >; < "Specifies whether to include colors and objects that are inserted to the background of the page (Format - Page - Background) in the printed document."; >; < "Print text in blac~k"; >; < "Specifies whether to always print text in black."; >; -- cgit From 79a0372102d3804b2917b089cf087403b0a1c041 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Sat, 1 Aug 2009 15:58:08 +0000 Subject: #i92518# lates UI changes --- sw/source/ui/config/optdlg.src | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sw') diff --git a/sw/source/ui/config/optdlg.src b/sw/source/ui/config/optdlg.src index 103b5970decf..a329decc41cc 100644 --- a/sw/source/ui/config/optdlg.src +++ b/sw/source/ui/config/optdlg.src @@ -974,7 +974,7 @@ StringArray STR_PRINTOPTUI < "Select the Brochure option to print the document in brochure format."; >; < "Right to Left"; >; < "Check to print the pages of the brochure in the correct order for a right-to-left script."; >; - < "Other"; >; + < "Pages"; >; < "Print ~automatically inserted blank pages"; >; < "If this option is enabled automatically inserted blank pages are printed. This is best if you are printing double-sided. For example, in a book, a \"chapter\" paragraph style has been set to always start with an odd numbered page. If the previous chapter ends on an odd page, %PRODUCTNAME inserts an even numbered blank page. This option controls whether to print that even numbered page or not"; >; < "~Paper tray from printer settings"; >; -- cgit From 9318ceab8acced650a36d7e0e13720c01645ba13 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Mon, 3 Aug 2009 15:15:11 +0000 Subject: #i92518# latest fashion updates --- sw/source/core/view/vprint.cxx | 17 ++++++++++------- sw/source/ui/config/optdlg.src | 2 ++ sw/source/ui/uno/unotxdoc.cxx | 2 +- 3 files changed, 13 insertions(+), 8 deletions(-) (limited to 'sw') diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index 323c692948a3..b2a2ba26e357 100644 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -240,7 +240,7 @@ SwPrintUIOptions::SwPrintUIOptions( BOOL bWeb ) : // create sequence of print UI options // (5 options are not available for Writer-Web) - const int nNumProps = bWeb? 18 : 21; + const int nNumProps = bWeb? 17 : 20; m_aUIProperties.realloc( nNumProps ); int nIdx = 0; @@ -369,14 +369,17 @@ SwPrintUIOptions::SwPrintUIOptions( BOOL bWeb ) : ); // create a bool option for brochure RTL dependent on brochure + uno::Sequence< rtl::OUString > aBRTLChoices( 3 ); + aBRTLChoices[0] = aLocalizedStrings.GetString( 55 ); + aBRTLChoices[1] = aLocalizedStrings.GetString( 56 ); vcl::PrinterOptionsHelper::UIControlOptions aBrochureRTLOpt( aBrochurePropertyName, -1, sal_True ); aBrochureRTLOpt.maGroupHint = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutPage" ) ); - m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 32 ), - aLocalizedStrings.GetString( 33 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintBrochureRTL" ) ), - sal_False, - aBrochureRTLOpt - ); + m_aUIProperties[ nIdx++ ].Value = getChoiceControlOpt( rtl::OUString(), + uno::Sequence< rtl::OUString >(), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintBrochureRTL" ) ), + aBRTLChoices, 0, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "List" ) ), + aBrochureRTLOpt + ); // print range selection vcl::PrinterOptionsHelper::UIControlOptions aPrintRangeOpt; diff --git a/sw/source/ui/config/optdlg.src b/sw/source/ui/config/optdlg.src index a329decc41cc..d6456f69d2a6 100644 --- a/sw/source/ui/config/optdlg.src +++ b/sw/source/ui/config/optdlg.src @@ -995,6 +995,8 @@ StringArray STR_PRINTOPTUI < "left pages"; >; < "right pages"; >; < "%PRODUCTNAME %s"; >; + < "Left-to-right script"; >; + < "Right-to-left script"; >; }; }; diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index 027b787db29d..0f4865fbf85c 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -2887,7 +2887,7 @@ void SAL_CALL SwXTextDocument::render( aOptions.bPaperFromSetup = m_pPrintUIOptions->getBoolValue( C2U( "PaperTray" ), aOptions.bPaperFromSetup ); aOptions.bPrintReverse = m_pPrintUIOptions->getBoolValue( C2U( "PrintReverseOrder" ), aOptions.bPrintReverse ); aOptions.bPrintProspect = m_pPrintUIOptions->getBoolValue( C2U( "PrintBrochure" ), aOptions.bPrintProspect ); - aOptions.bPrintProspect_RTL = m_pPrintUIOptions->getBoolValue( C2U( "PrintBrochureRTL" ), aOptions.bPrintProspect_RTL ); + aOptions.bPrintProspect_RTL = m_pPrintUIOptions->getIntValue( C2U( "PrintBrochureRTL" ), aOptions.bPrintProspect_RTL ) ? true : false; // bPrintSingleJobs <-- not set here // TLPDF: TODO: remove this from SwPrintData?? Get rid of SwPrtOptions?? // bModified <-- not set here // TLPDF: TODO: remove this from SwPrintData?? Get rid of SwPrtOptions?? aOptions.bPrintBlackFont = m_pPrintUIOptions->getBoolValue( C2U( "PrintBlack" ), aOptions.bPrintBlackFont ); -- cgit From 89b70cad0e882861714d7a158c21a1fceca921a1 Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Tue, 4 Aug 2009 09:27:27 +0000 Subject: #i103991# fixed crash --- sw/inc/rolbck.hxx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'sw') diff --git a/sw/inc/rolbck.hxx b/sw/inc/rolbck.hxx index 6dd6a90ad640..63bd174830af 100644 --- a/sw/inc/rolbck.hxx +++ b/sw/inc/rolbck.hxx @@ -160,8 +160,11 @@ public: class SwHistorySetTxtFld : public SwHistoryHint { - const ::std::auto_ptr m_pFld; + //!! beware of the order for the declation of thje auto_ptrs. + //!! If they get destroyed in the wrong order sw may crash (namely mail-merge as well) ::std::auto_ptr m_pFldType; + const ::std::auto_ptr m_pFld; + ULONG m_nNodeIndex; xub_StrLen m_nPos; USHORT m_nFldWhich; -- cgit From c195e304f8df070971e77038a17ea3e09f1fbd36 Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Tue, 4 Aug 2009 12:13:41 +0000 Subject: #i101242# new print UI --- sw/inc/dbfld.hxx | 1 + sw/inc/doc.hxx | 2 +- sw/inc/swprtopt.hxx | 21 ++++------------ sw/source/core/doc/doc.cxx | 20 ++++++++++++---- sw/source/core/fields/dbfld.cxx | 4 ++++ sw/source/core/view/vprint.cxx | 6 ++--- sw/source/ui/uno/unotxdoc.cxx | 53 +++++++++++++++++++++++++---------------- 7 files changed, 60 insertions(+), 47 deletions(-) (limited to 'sw') diff --git a/sw/inc/dbfld.hxx b/sw/inc/dbfld.hxx index 9b61f001ed12..9adb2eb688a5 100644 --- a/sw/inc/dbfld.hxx +++ b/sw/inc/dbfld.hxx @@ -52,6 +52,7 @@ class SW_DLLPUBLIC SwDBFieldType : public SwValueFieldType public: SwDBFieldType(SwDoc* pDocPtr, const String& rColumnName, const SwDBData& rDBData); + ~SwDBFieldType(); virtual const String& GetName() const; virtual SwFieldType* Copy() const; diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index 98aabe79c01a..d0d18f1043b7 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -1335,7 +1335,7 @@ public: // get the set of printable pages for the XRenderable API by // evaluating the respective settings (see implementation) - void GetValidPagesForPrinting( SwPrintUIOptions &rPrintUIOptions, + void GetValidPagesForPrinting( bool bIsPDFExport, SwPrintUIOptions &rPrintUIOptions, sal_Int32 nDocPageCount ); sal_uInt16 GetPageCount() const; diff --git a/sw/inc/swprtopt.hxx b/sw/inc/swprtopt.hxx index b8a48d678f1a..741e2d7618f8 100644 --- a/sw/inc/swprtopt.hxx +++ b/sw/inc/swprtopt.hxx @@ -115,9 +115,10 @@ public: typedef std::map< sal_Int32, const SwPageFrm * > ValidStartFramesMap_t; - std::set< sal_Int32 > & GetValidPagesSet() { return aValidPages; } - ValidStartFramesMap_t & GetValidStartFrms() { return aValidStartFrms; } - const ValidStartFramesMap_t & GetValidStartFrms() const { return aValidStartFrms; } + std::set< sal_Int32 > & GetValidPagesSet() { return aValidPages; } + const std::set< sal_Int32 > & GetValidPagesSet() const { return aValidPages; } + ValidStartFramesMap_t & GetValidStartFrms() { return aValidStartFrms; } + const ValidStartFramesMap_t & GetValidStartFrms() const { return aValidStartFrms; } std::vector< sal_Int32 > & GetPagesToPrint() { return aPagesToPrint; } const std::vector< sal_Int32 > & GetPagesToPrint() const { return aPagesToPrint; } bool isPrintLeftPages() const; @@ -127,17 +128,3 @@ public: #endif //_SWPRTOPT_HXX - - - - - - - - - - - - - - diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index 9a4f94c9de80..8c4ff026876b 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -991,6 +991,7 @@ const SwDocStat& SwDoc::GetDocStat() const void SwDoc::GetValidPagesForPrinting( + bool bIsPDFExport, SwPrintUIOptions &rPrintUIOptions, sal_Int32 nDocPageCount ) { @@ -999,10 +1000,21 @@ void SwDoc::GetValidPagesForPrinting( return; // properties to take into account when calcualting the set of pages - const bool bPrintLeftPage = rPrintUIOptions.isPrintLeftPages(); - const bool bPrintRightPage = rPrintUIOptions.isPrintRightPages(); - const bool bPrintReverse = rPrintUIOptions.getBoolValue( C2U( "PrintReverseOrder" ), false ); - const bool bPrintEmptyPages = rPrintUIOptions.getBoolValue( C2U( "PrintEmptyPages" ), false ); + bool bPrintLeftPage = rPrintUIOptions.isPrintLeftPages(); + bool bPrintRightPage = rPrintUIOptions.isPrintRightPages(); + bool bPrintReverse = rPrintUIOptions.getBoolValue( C2U( "PrintReverseOrder" ), false ); + bool bPrintEmptyPages = rPrintUIOptions.getBoolValue( C2U( "PrintEmptyPages" ), false ); + + if (bIsPDFExport) + { + // PDF export UI does not allow for selecting left or right pages only or reverse print + bPrintLeftPage = true; + bPrintRightPage = true; + bPrintReverse = false; + // TLPDF, TODO; take care of the option 'Export automatically inserted blank pages' + // from the 'Export as PDF' (aka PDF Options) dialog. + bPrintEmptyPages = false; + } Range aPages( 1, nDocPageCount ); diff --git a/sw/source/core/fields/dbfld.cxx b/sw/source/core/fields/dbfld.cxx index 996f3b092313..b59eb29a8192 100644 --- a/sw/source/core/fields/dbfld.cxx +++ b/sw/source/core/fields/dbfld.cxx @@ -96,6 +96,10 @@ SwDBFieldType::SwDBFieldType(SwDoc* pDocPtr, const String& rNam, const SwDBData& sName += GetColumnName(); } //------------------------------------------------------------------------------ +SwDBFieldType::~SwDBFieldType() +{ +} +//------------------------------------------------------------------------------ SwFieldType* SwDBFieldType::Copy() const { diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index b2a2ba26e357..35caadbd1855 100644 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -1291,13 +1291,11 @@ BOOL ViewShell::Prt( /* TLPDF neu: start */ #if OSL_DEBUG_LEVEL > 1 - DBG_ASSERT( 0 <= nRenderer && nRenderer <= sal_Int32(rPrintUIOptions.GetPagesToPrint().size()), - "nRenderer out of bounds"); + DBG_ASSERT( 0 <= nRenderer && nRenderer < (sal_Int32)rPrintUIOptions.GetPagesToPrint().size(), "nRenderer out of bounds"); #endif const sal_Int32 nPage = rPrintUIOptions.GetPagesToPrint()[ nRenderer ]; /* TLPDF */ #if OSL_DEBUG_LEVEL > 1 - DBG_ASSERT( 0 <= nPage && nPage <= sal_Int32(rPrintUIOptions.GetValidStartFrms().size()), - "nPage out of bounds"); + DBG_ASSERT( rPrintUIOptions.GetValidPagesSet().count( nPage ) == 1, "nPage not valid" ); #endif const SwPrintUIOptions::ValidStartFramesMap_t &rFrms = rPrintUIOptions.GetValidStartFrms(); SwPrintUIOptions::ValidStartFramesMap_t::const_iterator aIt( rFrms.find( nPage ) ); diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index 0f4865fbf85c..d6360c22be86 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -2655,30 +2655,44 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount( } const sal_Int32 nPageCount = pDoc->GetPageCount(); + OUString aPageRange; if (bIsPDFExport) - nRet = nPageCount; - else { - OUString aPageRange = m_pPrintUIOptions->getStringValue( C2U( "PageRange" ), OUString() ); - if (aPageRange.getLength() == 0) +// uno::Any aSelection; + for( sal_Int32 i = 0, nCount = rxOptions.getLength(); i < nCount; ++i ) { - // set page range to print all pages - aPageRange = OUString::valueOf( (sal_Int32)1 ); - aPageRange += OUString::valueOf( (sal_Unicode)'-'); - aPageRange += OUString::valueOf( nPageCount ); + if( rxOptions[ i ].Name == OUString( RTL_CONSTASCII_USTRINGPARAM( "PageRange" ) ) ) + rxOptions[ i ].Value >>= aPageRange; +// else if( rxOptions[ i ].Name == OUString( RTL_CONSTASCII_USTRINGPARAM( "Selection" ) ) ) +// rxOptions[ i ].Value >>= aSelection; } + } + else + { + aPageRange = m_pPrintUIOptions->getStringValue( C2U( "PageRange" ), OUString() ); + } - // get set of valid pages (according to the current settings) - // and their start frames - pDoc->GetValidPagesForPrinting( *m_pPrintUIOptions, nPageCount ); + if (aPageRange.getLength() == 0) + { + // set page range to print to 'all pages' + aPageRange = OUString::valueOf( (sal_Int32)1 ); + aPageRange += OUString::valueOf( (sal_Unicode)'-'); + aPageRange += OUString::valueOf( nPageCount ); + } - // get vector of pages to print according to PageRange and valid pages from above - StringRangeEnumerator::getRangesFromString( - aPageRange, m_pPrintUIOptions->GetPagesToPrint(), - 1, nPageCount, 0, &m_pPrintUIOptions->GetValidPagesSet() ); + // get set of valid pages (according to the current settings) + // and their start frames + pDoc->GetValidPagesForPrinting( bIsPDFExport, *m_pPrintUIOptions, nPageCount ); + DBG_ASSERT( nPageCount >= 1, "valid pages count is 0! Should not happen." ); - nRet = m_pPrintUIOptions->GetPagesToPrint().size(); - } + // get vector of pages to print according to PageRange and valid pages from above + // (result may be an empty vector, for example if the range string is not correct) + StringRangeEnumerator::getRangesFromString( + aPageRange, m_pPrintUIOptions->GetPagesToPrint(), + 1, nPageCount, 0, &m_pPrintUIOptions->GetValidPagesSet() ); + + nRet = m_pPrintUIOptions->GetPagesToPrint().size(); + DBG_ASSERT( nRet >= 0, "negative number of pages???" ); return nRet; } @@ -2816,10 +2830,7 @@ void SAL_CALL SwXTextDocument::render( // Thus instead of throwing the exception we silently return. if (0 > nRenderer) throw IllegalArgumentException(); - const sal_Int32 nMaxCount = bIsPDFExport? - static_cast< sal_Int32 >(pDoc->GetPageCount()) : - static_cast< sal_Int32 >(m_pPrintUIOptions->GetPagesToPrint().size()); - if (nRenderer >= nMaxCount) + if (nRenderer >= m_pPrintUIOptions->GetPagesToPrint().size()) return; // the view shell should be SwView for documents PDF export -- cgit From 1b4b6cfb19e8e73c804ac394394311581a4618c9 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Tue, 4 Aug 2009 16:15:36 +0000 Subject: fix warnings --- sw/source/core/undo/rolbck.cxx | 2 +- sw/source/ui/uno/unotxdoc.cxx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'sw') diff --git a/sw/source/core/undo/rolbck.cxx b/sw/source/core/undo/rolbck.cxx index aee144900959..ec62ab78de79 100644 --- a/sw/source/core/undo/rolbck.cxx +++ b/sw/source/core/undo/rolbck.cxx @@ -271,8 +271,8 @@ void SwHistorySetTxt::SetInDoc( SwDoc* pDoc, bool ) SwHistorySetTxtFld::SwHistorySetTxtFld( SwTxtFld* pTxtFld, ULONG nNodePos ) : SwHistoryHint( HSTRY_SETTXTFLDHNT ) - , m_pFld( new SwFmtFld( *pTxtFld->GetFld().GetFld() ) ) , m_pFldType( 0 ) + , m_pFld( new SwFmtFld( *pTxtFld->GetFld().GetFld() ) ) { // only copy if not Sys-FieldType SwDoc* pDoc = pTxtFld->GetTxtNode().GetDoc(); diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index d6360c22be86..ba7f79d681a8 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -2830,7 +2830,7 @@ void SAL_CALL SwXTextDocument::render( // Thus instead of throwing the exception we silently return. if (0 > nRenderer) throw IllegalArgumentException(); - if (nRenderer >= m_pPrintUIOptions->GetPagesToPrint().size()) + if (nRenderer >= sal_Int32(m_pPrintUIOptions->GetPagesToPrint().size())) return; // the view shell should be SwView for documents PDF export -- cgit From 063c55820f1f7b21f2999d9a5f8a0e18078c3f32 Mon Sep 17 00:00:00 2001 From: Carsten Driesner Date: Thu, 6 Aug 2009 12:40:39 +0000 Subject: #i92516# Fix mail merge with new printing function. Don't set SID_ASYNCHRON to true for normal mail merge operations --- sw/inc/dbmgr.hxx | 2 +- sw/source/ui/dbui/dbmgr.cxx | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) (limited to 'sw') diff --git a/sw/inc/dbmgr.hxx b/sw/inc/dbmgr.hxx index 0c359bd05cdb..9e13058e90e6 100644 --- a/sw/inc/dbmgr.hxx +++ b/sw/inc/dbmgr.hxx @@ -184,7 +184,7 @@ struct SwMergeDescriptor rDescriptor(rDesc), bSendAsHTML( sal_True ), bSendAsAttachment( sal_False ), - bPrintAsync( sal_True ), + bPrintAsync( sal_False ), bCreateSingleFile( sal_False ), pMailMergeConfigItem(0) {} diff --git a/sw/source/ui/dbui/dbmgr.cxx b/sw/source/ui/dbui/dbmgr.cxx index 7fa9a24338c2..97d882c3a8e1 100644 --- a/sw/source/ui/dbui/dbmgr.cxx +++ b/sw/source/ui/dbui/dbmgr.cxx @@ -500,12 +500,11 @@ BOOL SwNewDBMgr::MergeNew(const SwMergeDescriptor& rMergeDesc ) if(IsMergeSilent()) { aPrintArgs.Put( SfxBoolItem(SID_SILENT, TRUE) ); - // #i25686# printing should be done asynchronously to prevent dangling offices - // when mail merge is called as command line macro - // #i52629# aynchronous printing should only be done in silent mode - otherwise - // the printer dialog does not come up - aPrintArgs.Put( SfxBoolItem( SID_ASYNCHRON, rMergeDesc.bPrintAsync )); } + // #i52629# aynchronous printing should only be done in silent mode - otherwise + // the printer dialog does not come up + aPrintArgs.Put( SfxBoolItem( SID_ASYNCHRON, rMergeDesc.bPrintAsync )); + // convert PropertyValues const beans::PropertyValue* pPrintOptions = rMergeDesc.aPrintOptions.getConstArray(); for( sal_Int32 nOption = 0; nOption < rMergeDesc.aPrintOptions.getLength(); ++nOption) -- cgit From 278729a448d7e56c426229325a960f08c38fafbc Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Fri, 7 Aug 2009 14:42:45 +0000 Subject: #i103991# prospect printing --- sw/inc/doc.hxx | 4 +- sw/inc/swprtopt.hxx | 22 +++++- sw/inc/viewsh.hxx | 15 ++-- sw/source/core/doc/doc.cxx | 166 ++++++++++++++++++++++++++++++++++++++++- sw/source/core/view/viewpg.cxx | 129 +++++++++++++++++++++++++------- sw/source/core/view/vprint.cxx | 30 ++------ sw/source/ui/uno/unotxdoc.cxx | 46 ++++++++---- 7 files changed, 333 insertions(+), 79 deletions(-) (limited to 'sw') diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index d0d18f1043b7..2b1937f2912e 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -1335,7 +1335,9 @@ public: // get the set of printable pages for the XRenderable API by // evaluating the respective settings (see implementation) - void GetValidPagesForPrinting( bool bIsPDFExport, SwPrintUIOptions &rPrintUIOptions, + void CalculatePagesForPrinting( bool bIsPDFExport, SwPrintUIOptions &rPrintUIOptions, + sal_Int32 nDocPageCount ); + void CalculatePagePairsForProspectPrinting( SwPrintUIOptions &rPrintUIOptions, sal_Int32 nDocPageCount ); sal_uInt16 GetPageCount() const; diff --git a/sw/inc/swprtopt.hxx b/sw/inc/swprtopt.hxx index 741e2d7618f8..53b00bff4f07 100644 --- a/sw/inc/swprtopt.hxx +++ b/sw/inc/swprtopt.hxx @@ -38,6 +38,7 @@ #include #include #include +#include #define POSTITS_NONE 0 #define POSTITS_ONLY 1 @@ -99,8 +100,9 @@ class SwPrintUIOptions : public vcl::PrinterOptionsHelper { OutputDevice* mpLast; - // pages valid for printing (accoridng to the current settings) + // pages valid for printing (according to the current settings) // and their respective start frames (see getRendererCount in unotxdoc.cxx) + // This set of pages does NOT depend on the 'PageRange' that is used as a printing option! std::set< sal_Int32 > aValidPages; // the set of possible pages (see StringRangeEnumerator::getRangesFromString ) std::map< sal_Int32, const SwPageFrm * > aValidStartFrms; // the map of start frames for those pages @@ -108,21 +110,33 @@ class SwPrintUIOptions : public vcl::PrinterOptionsHelper // (see 'render' in unotxdoc.cxx) std::vector< sal_Int32 > aPagesToPrint; + // for prospect printing: the pairs of pages to be printed together on a single prospect page. + // -1 indicates a half page to be left empty. + std::vector< std::pair< sal_Int32, sal_Int32 > > aPagePairs; + public: SwPrintUIOptions( BOOL bWeb ); bool processPropertiesAndCheckFormat( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& i_rNewProp ); - typedef std::map< sal_Int32, const SwPageFrm * > ValidStartFramesMap_t; + typedef std::map< sal_Int32, const SwPageFrm * > ValidStartFramesMap_t; + typedef std::vector< std::pair< sal_Int32, sal_Int32 > > PagePairsVec_t; std::set< sal_Int32 > & GetValidPagesSet() { return aValidPages; } const std::set< sal_Int32 > & GetValidPagesSet() const { return aValidPages; } ValidStartFramesMap_t & GetValidStartFrms() { return aValidStartFrms; } const ValidStartFramesMap_t & GetValidStartFrms() const { return aValidStartFrms; } + + // used for 'normal' printing std::vector< sal_Int32 > & GetPagesToPrint() { return aPagesToPrint; } const std::vector< sal_Int32 > & GetPagesToPrint() const { return aPagesToPrint; } - bool isPrintLeftPages() const; - bool isPrintRightPages() const; + + // used for prospect printing only + PagePairsVec_t & GetPagePairsForProspectPrinting() { return aPagePairs; } + const PagePairsVec_t & GetPagePairsForProspectPrinting() const { return aPagePairs; } + + bool IsPrintLeftPages() const; + bool IsPrintRightPages() const; }; diff --git a/sw/inc/viewsh.hxx b/sw/inc/viewsh.hxx index dbbeec0e7d8e..007fc7c05ed3 100644 --- a/sw/inc/viewsh.hxx +++ b/sw/inc/viewsh.hxx @@ -365,9 +365,15 @@ public: //Druckauftrag abwickeln. // bIsPDFExport == true is: do PDF Export (no printing!) - sal_Bool Prt( OutputDevice* pOutDev, SwPrtOptions& rOptions, - const SwPrintUIOptions &rPrintUIOptions, sal_Int32 nRenderer /* offset in vector of pages to print */, - SfxProgress* pProgress, bool bIsPDFExport = false ); + sal_Bool PrintOrPDFExport( OutputDevice* pOutDev, SwPrtOptions& rOptions, + const SwPrintUIOptions &rPrintUIOptions, + sal_Int32 nRenderer, /* offset in vector of pages to print */ + bool bIsPDFExport = sal_False ); + + // Prospekt-Format drucken + void PrintProspect( OutputDevice* pOutDev, SwPrtOptions& rOptions, + const SwPrintUIOptions &rPrintUIOptions, + sal_Int32 nRenderer /* offset in vector of page pairs for prospect */ ); //"Drucken" fuer OLE 2.0 static void PrtOle2( SwDoc *pDoc, const SwViewOption *pOpt, SwPrtOptions& rOptions, @@ -483,9 +489,6 @@ public: SfxProgress& rProgress, const SwPagePreViewPrtData* = 0 ); - // Prospekt-Format drucken - void PrintProspect( SwPrtOptions&, SfxProgress& , BOOL bRTL); - sal_Bool IsViewLocked() const { return bViewLocked; } void LockView( sal_Bool b ) { bViewLocked = b; } diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index 8c4ff026876b..681af392f2dd 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include @@ -990,7 +991,7 @@ const SwDocStat& SwDoc::GetDocStat() const } -void SwDoc::GetValidPagesForPrinting( +void SwDoc::CalculatePagesForPrinting( bool bIsPDFExport, SwPrintUIOptions &rPrintUIOptions, sal_Int32 nDocPageCount ) @@ -1000,8 +1001,9 @@ void SwDoc::GetValidPagesForPrinting( return; // properties to take into account when calcualting the set of pages - bool bPrintLeftPage = rPrintUIOptions.isPrintLeftPages(); - bool bPrintRightPage = rPrintUIOptions.isPrintRightPages(); + bool bPrintLeftPage = rPrintUIOptions.IsPrintLeftPages(); + bool bPrintRightPage = rPrintUIOptions.IsPrintRightPages(); + // TLPDF, TODO: remove bPrintReverse, should be handled by PLs framework now bool bPrintReverse = rPrintUIOptions.getBoolValue( C2U( "PrintReverseOrder" ), false ); bool bPrintEmptyPages = rPrintUIOptions.getBoolValue( C2U( "PrintEmptyPages" ), false ); @@ -1123,6 +1125,164 @@ void SwDoc::GetValidPagesForPrinting( } +void SwDoc::CalculatePagePairsForProspectPrinting( + SwPrintUIOptions &rPrintUIOptions, + sal_Int32 nDocPageCount ) +{ + std::set< sal_Int32 > &rValidPagesSet = rPrintUIOptions.GetValidPagesSet(); + std::map< sal_Int32, const SwPageFrm * > &rValidStartFrms = rPrintUIOptions.GetValidStartFrms(); + std::vector< std::pair< sal_Int32, sal_Int32 > > &rPagePairs = rPrintUIOptions.GetPagePairsForProspectPrinting(); + + rPagePairs.clear(); + rValidPagesSet.clear(); + rValidStartFrms.clear(); + + rtl::OUString aPageRange = rPrintUIOptions.getStringValue( C2U( "PageRange" ), rtl::OUString() ); + StringRangeEnumerator aRange( aPageRange, 1, nDocPageCount, 0 ); + + DBG_ASSERT( pLayout, "no layout present" ); + if (!pLayout || aRange.size() <= 0) + return; + + const SwPageFrm *pStPage = (SwPageFrm*)pLayout->Lower(); + sal_Int32 i = 0; + for ( i = 1; pStPage && i < nDocPageCount; ++i ) + pStPage = (SwPageFrm*)pStPage->GetNext(); + if ( !pStPage ) // dann wars das + return; + + // currently for prospect printing all pages are valid to be printed + // thus we add them all to the respective map and set for later use + sal_Int32 nPageNum = 0; + const SwPageFrm *pPageFrm = (SwPageFrm*)pLayout->Lower(); + while( pPageFrm && nPageNum < nDocPageCount ) + { + DBG_ASSERT( pPageFrm, "Empty page frame. How are we gpoing to print this?" ); + ++nPageNum; + rValidPagesSet.insert( nPageNum ); + rValidStartFrms[ nPageNum ] = pPageFrm; + pPageFrm = (SwPageFrm*)pPageFrm->GetNext(); + } + DBG_ASSERT( nPageNum == nDocPageCount, "unexpected number of pages" ); + + // properties to take into account when calcualting the set of pages + // Note: here bPrintLeftPage and bPrintRightPage refer to the (virtual) resulting pages + // of the prospect! + bool bPrintLeftPage = rPrintUIOptions.IsPrintLeftPages(); + bool bPrintRightPage = rPrintUIOptions.IsPrintRightPages(); + // TLPDF, TODO: remove bPrintReverse, should be handled by PLs framework now + bool bPrintReverse = rPrintUIOptions.getBoolValue( C2U( "PrintReverseOrder" ), false ); + // TLPDF: this one seems not to be used in prospect printing: bool bPrintEmptyPages = rPrintUIOptions.getBoolValue( C2U( "PrintEmptyPages" ), false ); + bool bPrintProspect_RTL = rPrintUIOptions.getIntValue( C2U( "PrintBrochureRTL" ), 0 ) ? true : false; + + // get pages for prospect printing according to the 'PageRange' + // (duplicates and any order allowed!) + std::vector< sal_Int32 > aPagesToPrint; + StringRangeEnumerator::getRangesFromString( + aPageRange, aPagesToPrint, 1, nDocPageCount, 0 ); + + // now fill the vector for calculating the page pairs with the start frames + // from the above obtained vector + std::vector< const SwPageFrm * > aVec; + for (sal_Int32 i = 0; i < aPagesToPrint.size(); ++i) + { + const sal_Int32 nPage = aPagesToPrint[i]; + const SwPageFrm *pFrm = rValidStartFrms[ nPage ]; + aVec.push_back( pFrm ); + } + + // auf Doppelseiten auffuellen + if ( 1 == aVec.size() ) // eine Seite ist ein Sonderfall + aVec.insert( aVec.begin() + 1, 0 ); + else + { + while( aVec.size() & 3 ) + aVec.push_back( 0 ); + + if ( bPrintReverse && 4 < aVec.size() ) + { + // das Array umsortieren + // Array: 1 2 3 4 5 6 7 8 + // soll: 3 4 1 2 7 8 5 6 + // Algorhitmus: + // vordere Haelfte: Austausch von 2 Pointer von Vorne vor die Haelfte + // hintere Haelfte: Austausch von 2 Pointer von der Haelfte nach hinten + + USHORT nHalf = aVec.size() / 2; + USHORT nSwapCount = nHalf / 4; + + const SwPageFrm ** ppArrStt = &aVec[ 0 ]; + const SwPageFrm ** ppArrHalf = &aVec[ nHalf ]; + + for ( int k = 0; k < 2; ++k ) + { + for ( USHORT n = 0; n < nSwapCount; ++n ) + { + const SwPageFrm * pTmp = *ppArrStt; + *ppArrStt++ = *(ppArrHalf-2); + *(ppArrHalf-2) = pTmp; + + pTmp = *ppArrStt; + *ppArrStt++ = *--ppArrHalf; + *ppArrHalf-- = pTmp; + } + ppArrStt = &aVec[ nHalf ]; + ppArrHalf = &aVec[ 0 ] + aVec.size(); + } + } + } + + // dann sorge mal dafuer, das alle Seiten in der richtigen + // Reihenfolge stehen: + USHORT nSPg = 0, nEPg = aVec.size(), nStep = 1; + if ( 0 == (nEPg & 1 )) // ungerade gibt es nicht! + --nEPg; + + if ( !bPrintLeftPage ) + ++nStep; + else if ( !bPrintRightPage ) + { + ++nStep; + ++nSPg, --nEPg; + } + + sal_Int32 nCntPage = (( nEPg - nSPg ) / ( 2 * nStep )) + 1; + DBG_ASSERT( nCntPage * 2 == aVec.size(), "vector size vs. page count mismatch" ); + + for ( USHORT nPrintCount = 0; nSPg < nEPg && + nPrintCount < nCntPage; ++nPrintCount ) + { + pStPage = aVec[ nSPg ]; + const SwPageFrm* pNxtPage = nEPg < aVec.size() ? aVec[ nEPg ] : 0; + + short nRtlOfs = bPrintProspect_RTL ? 1 : 0; + if ( 0 == (( nSPg + nRtlOfs) & 1 ) ) // switch for odd number in LTR, even number in RTL + { + const SwPageFrm* pTmp = pStPage; + pStPage = pNxtPage; + pNxtPage = pTmp; + } + + sal_Int32 nFirst, nSecond = -1; + for ( int nC = 0; nC < 2; ++nC ) + { + sal_Int32 nPageNum = -1; + if ( pStPage ) + nPageNum = pStPage->GetPhyPageNum(); + if (nC == 0) + nFirst = nPageNum; + else + nSecond = nPageNum; + + pStPage = pNxtPage; + } + rPagePairs.push_back( std::pair< sal_Int32, sal_Int32 >(nFirst, nSecond) ); + + nSPg = nSPg + nStep; + nEPg = nEPg - nStep; + } + DBG_ASSERT( nCntPage == rPagePairs.size(), "size mismatch for number of page pairs" ); +} sal_uInt16 SwDoc::GetPageCount() const diff --git a/sw/source/core/view/viewpg.cxx b/sw/source/core/view/viewpg.cxx index 7051b58aa1dd..49ec9bb483b3 100644 --- a/sw/source/core/view/viewpg.cxx +++ b/sw/source/core/view/viewpg.cxx @@ -413,7 +413,7 @@ void ViewShell::PrintPreViewPage( SwPrtOptions& rOptions, SwPaintQueue::Repaint(); memset( aPageArr, 0, sizeof( SwPageFrm* ) * nPages ); - nCntPage = 0; + nCntPage = 0; nMaxRowSz = nMaxColSz = nCalcH = nCalcW = 0; } } @@ -450,18 +450,44 @@ void ViewShell::PrintPreViewPage( SwPrtOptions& rOptions, // print brochure // OD 05.05.2003 #i14016# - consider empty pages on calculation of the scaling // for a page to be printed. -void ViewShell::PrintProspect( SwPrtOptions& rOptions, - SfxProgress& rProgress , BOOL bRTL) +void ViewShell::PrintProspect( + OutputDevice* pOutDev, + SwPrtOptions& rOptions, + const SwPrintUIOptions & rPrintUIOptions, /* TLPDF keep this or the above? */ + sal_Int32 nRenderer ) { - if( !rOptions.aMulti.GetSelectCount() ) +// TLPDF if( !rOptions.aMulti.GetSelectCount() ) + Printer *pPrinter = dynamic_cast< Printer * >(pOutDev); + if (!pPrinter || rPrintUIOptions.GetPagePairsForProspectPrinting().size() <= 0) return; +#ifdef TL_NOT_NOW /*TLPDF*/ // wenn kein Drucker vorhanden ist, wird nicht gedruckt SfxPrinter* pPrt = getIDocumentDeviceAccess()->getPrinter(false); if( !pPrt || !pPrt->GetName().Len() || ( !rOptions.bPrintLeftPage && !rOptions.bPrintRightPage )) return; +#endif // TL_NOT_NOW /*TLPDF*/ + + // save settings of OutputDevice (should be done always now since the + // output device is now provided by a call from outside the Writer) + pPrinter->Push(); + +/* TLPDF neu: start */ +#if OSL_DEBUG_LEVEL > 1 + DBG_ASSERT( 0 <= nRenderer && nRenderer < (sal_Int32)rPrintUIOptions.GetPagePairsForProspectPrinting().size(), "nRenderer out of bounds"); +#endif + std::pair< sal_Int32, sal_Int32 > rPagesToPrint = + rPrintUIOptions.GetPagePairsForProspectPrinting()[ nRenderer ]; + const USHORT nPageMax = static_cast< USHORT >(rPagesToPrint.first > rPagesToPrint.second ? + rPagesToPrint.first : rPagesToPrint.second); +#if OSL_DEBUG_LEVEL > 1 + DBG_ASSERT( rPagesToPrint.first == -1 || rPrintUIOptions.GetValidPagesSet().count( rPagesToPrint.first ) == 1, "first Page not valid" ); + DBG_ASSERT( rPagesToPrint.second == -1 || rPrintUIOptions.GetValidPagesSet().count( rPagesToPrint.second ) == 1, "second Page not valid" ); +#endif +/* TLPDF neu: end */ +#ifdef TL_NOT_NOW /*TLPDF*/ MultiSelection aMulti( rOptions.aMulti ); Range aPages( aMulti.FirstSelected(), aMulti.LastSelected() ); if ( aPages.Max() > USHRT_MAX ) @@ -471,11 +497,15 @@ void ViewShell::PrintProspect( SwPrtOptions& rOptions, "Seite 0 Drucken?" ); ASSERT( aPages.Min() <= aPages.Max(), "MinSeite groesser MaxSeite." ); +#endif // TL_NOT_NOW /*TLPDF*/ // eine neue Shell fuer den Printer erzeugen - ViewShell aShell( *this, 0 ); +// TLPDF ViewShell aShell( *this, 0 ); + ViewShell aShell( *this, 0, pPrinter ); +#ifdef TL_NOT_NOW /*TLPDF*/ if ( &GetRefDev() == pPrt ) aShell.mpTmpRef = new SfxPrinter( *pPrt ); +#endif // TL_NOT_NOW /*TLPDF*/ SET_CURR_SHELL( &aShell ); @@ -497,8 +527,9 @@ void ViewShell::PrintProspect( SwPrtOptions& rOptions, } // Seiten fuers Drucken formatieren - aShell.CalcPagesForPrint( (USHORT)aPages.Max(), &rProgress ); + aShell.CalcPagesForPrint( nPageMax, 0 /*(USHORT)aPages.Max(), &rProgress*/ ); +#ifdef TL_NOT_NOW /*TLPDF*/ USHORT nCopyCnt = rOptions.bCollate ? rOptions.nCopyCount : 1; const SwPageFrm *pStPage = (SwPageFrm*)GetLayout()->Lower(); @@ -506,23 +537,30 @@ void ViewShell::PrintProspect( SwPrtOptions& rOptions, for( i = 1; pStPage && i < (USHORT)aPages.Min(); ++i ) pStPage = (SwPageFrm*)pStPage->GetNext(); +#endif // TL_NOT_NOW /*TLPDF*/ - if( !pStPage ) // dann wars das +#ifdef TL_NOT_NOW /*TLPDF*/ + should not happen any more since the test + rPrintUIOptions.GetPagePairsForProspectPrinting().size() <= 0 + above should have taken care that there is at least one page to print + if( !pStPage ) // dann wars das { if( bHiddenFlds ) { SwMsgPoolItem aHnt( RES_HIDDENPARA_PRINT ); pFldType->Modify( &aHnt, 0); - CalcPagesForPrint( (USHORT)aPages.Max() ); + CalcPagesForPrint( nPageMax /*(USHORT)aPages.Max()*/ ); } return; } +#endif // TL_NOT_NOW /*TLPDF*/ +#ifdef TL_NOT_NOW /*TLPDF*/ // unsere SttPage haben wir, dann die EndPage suchen SvPtrarr aArr( 255, 255 ); aArr.Insert( (void*)pStPage, aArr.Count() ); - while( pStPage->GetNext() && i < (USHORT)aPages.Max() ) + while( pStPage->GetNext() && i < nPageMax (USHORT)aPages.Max() ) { pStPage = (SwPageFrm*)pStPage->GetNext(); if( aMulti.IsSelected( ++i ) ) @@ -569,17 +607,17 @@ void ViewShell::PrintProspect( SwPrtOptions& rOptions, } } } +#endif // TL_NOT_NOW /*TLPDF*/ - BOOL bStartJob = FALSE; +//TLPDF BOOL bStartJob = FALSE; - for( USHORT nCnt = 0; nCnt < nCopyCnt; nCnt++ ) + for( USHORT nCnt = 0; nCnt <= 0 /*< 1 TLPDF nCopyCnt*/; nCnt++ ) { +#ifdef TL_NOT_NOW /*TLPDF*/ if( rOptions.IsPrintSingleJobs() && rOptions.GetJobName().Len() && ( bStartJob || rOptions.bJobStartet ) ) { -#ifdef TL_NOT_NOW /*TLPDF*/ pPrt->EndJob(); -#endif rOptions.bJobStartet = TRUE; // Reschedule statt Yield, da Yield keine Events abarbeitet @@ -607,31 +645,55 @@ void ViewShell::PrintProspect( SwPrtOptions& rOptions, } USHORT nCntPage = (( nEPg - nSPg ) / ( 2 * nStep )) + 1; +#endif // TL_NOT_NOW /*TLPDF*/ - MapMode aOld( pPrt->GetMapMode() ); + MapMode aOld( /*TLPDF pPrt*/pPrinter->GetMapMode() ); MapMode aMapMode( MAP_TWIP ); - Size aPrtSize( pPrt->PixelToLogic( pPrt->GetPaperSizePixel(), aMapMode ) ); +// TLPDF Size aPrtSize( pPrt->PixelToLogic( pPrt->GetPaperSizePixel(), aMapMode ) ); + Size aPrtSize( pPrinter->PixelToLogic( pPrinter->GetPaperSizePixel(), aMapMode ) ); /* TLPDF */ +#ifdef TL_NOT_NOW /*TLPDF*/ const XubString aTmp( SW_RES( STR_STATSTR_PRINT ) ); rProgress.SetText( aTmp ); //HACK, damit die Anzeige nicht durcheinander kommt: rProgress.SetState( 1, nCntPage ); rProgress.SetText( aTmp ); +#endif // TL_NOT_NOW /*TLPDF*/ - for( USHORT nPrintCount = 0; nSPg < nEPg && - nPrintCount < nCntPage; ++nPrintCount ) + for( USHORT nPrintCount = 0; nPrintCount <= 0 /*nSPg < nEPg && nPrintCount < nCntPage*/; ++nPrintCount ) { +#ifdef TL_NOT_NOW /*TLPDF*/ // Mag der Anwender noch ? rProgress.Reschedule(); if ( !pPrt->IsJobActive() ) break; - SwTwips nMaxRowSz, nMaxColSz; pStPage = (SwPageFrm*)aArr[ nSPg ]; const SwPageFrm* pNxtPage = nEPg < aArr.Count() ? (SwPageFrm*)aArr[ nEPg ] : 0; +#endif // TL_NOT_NOW /*TLPDF*/ + + SwTwips nMaxRowSz, nMaxColSz; + +/* TLPDF neu: start */ + const SwPageFrm *pStPage = 0; + const SwPageFrm *pNxtPage = 0; + const SwPrintUIOptions::ValidStartFramesMap_t &rFrms = rPrintUIOptions.GetValidStartFrms(); + if (rPagesToPrint.first > 0) + { + SwPrintUIOptions::ValidStartFramesMap_t::const_iterator aIt( rFrms.find( rPagesToPrint.first ) ); + DBG_ASSERT( aIt != rFrms.end(), "failed to find start frame" ); + pStPage = aIt->second; + } + if (rPagesToPrint.second > 0) + { + SwPrintUIOptions::ValidStartFramesMap_t::const_iterator aIt( rFrms.find( rPagesToPrint.second ) ); + DBG_ASSERT( aIt != rFrms.end(), "failed to find start frame" ); + pNxtPage = aIt->second; + } +/* TLPDF neu: end */ // OD 05.05.2003 #i14016# - consider empty pages on calculation // of page size, used for calculation of scaling. @@ -684,6 +746,7 @@ void ViewShell::PrintProspect( SwPrtOptions& rOptions, aSttPageSize.Height() ); } +#ifdef TL_NOT_NOW /*TLPDF*/ short nRtlOfs = bRTL ? 1 : 0; if( 0 == (( nSPg + nRtlOfs) & 1 ) ) // switch for odd number in LTR, even number in RTL { @@ -691,6 +754,7 @@ void ViewShell::PrintProspect( SwPrtOptions& rOptions, pStPage = pNxtPage; pNxtPage = pTmp; } +#endif // TL_NOT_NOW /*TLPDF*/ // den MapMode einstellen aMapMode.SetOrigin( Point() ); @@ -716,14 +780,14 @@ void ViewShell::PrintProspect( SwPrtOptions& rOptions, aMapMode.SetScaleX( aScY ); } - Point aPrtOff( pPrt->PixelToLogic( - pPrt->GetPageOffsetPixel(), aMapMode ) ); - Size aTmpPrtSize( pPrt->PixelToLogic( - pPrt->GetPaperSizePixel(), aMapMode ) ); +// TLPDF Point aPrtOff( pPrt->PixelToLogic( pPrt->GetPageOffsetPixel(), aMapMode ) ); +// TLPDF Size aTmpPrtSize( pPrt->PixelToLogic( pPrt->GetPaperSizePixel(), aMapMode ) ); + Point aPrtOff( pPrinter->PixelToLogic( pPrinter->GetPageOffsetPixel(), aMapMode ) ); /* TLPDF */ + Size aTmpPrtSize( pPrinter->PixelToLogic( pPrinter->GetPaperSizePixel(), aMapMode ) ); /* TLPDF */ // dann kann das drucken losgehen - bStartJob = TRUE; - rProgress.SetState( nPrintCount, nCntPage ); +//TLPDF bStartJob = TRUE; +//TLPDF rProgress.SetState( nPrintCount, nCntPage ); #ifdef TL_NOT_NOW /*TLPDF*/ pPrt->StartPage(); @@ -741,7 +805,7 @@ void ViewShell::PrintProspect( SwPrtOptions& rOptions, aPos -= aShell.aVisArea.Pos(); aPos -= aPrtOff; aMapMode.SetOrigin( aPos ); - pPrt->SetMapMode( aMapMode ); + pPrinter->SetMapMode( aMapMode ); pStPage->GetUpper()->Paint( pStPage->Frm() ); } @@ -753,20 +817,31 @@ void ViewShell::PrintProspect( SwPrtOptions& rOptions, pPrt->EndPage(); #endif SwPaintQueue::Repaint(); + +#ifdef TL_NOT_NOW /*TLPDF*/ nSPg = nSPg + nStep; nEPg = nEPg - nStep; +#endif // TL_NOT_NOW /*TLPDF*/ } - pPrt->SetMapMode( aOld ); + pPrinter->SetMapMode( aOld ); if( bHiddenFlds ) { SwMsgPoolItem aHnt( RES_HIDDENPARA_PRINT ); pFldType->Modify( &aHnt, 0); - CalcPagesForPrint( (USHORT)aPages.Max() ); + CalcPagesForPrint( nPageMax /*(USHORT)aPages.Max()*/ ); } +#ifdef TL_NOT_NOW /*TLPDF*/ if( bStartJob ) rOptions.bJobStartet = TRUE; +#endif // TL_NOT_NOW /*TLPDF*/ } pFntCache->Flush(); + + // restore settings of OutputDevice (should be done always now since the + // output device is now provided by a call from outside the Writer) + pPrinter->Pop(); } + + diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index 35caadbd1855..e4083016131a 100644 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -418,13 +418,13 @@ SwPrintUIOptions::SwPrintUIOptions( BOOL bWeb ) : DBG_ASSERT( nIdx == nNumProps, "number of added properties is not as expected" ); } -bool SwPrintUIOptions::isPrintLeftPages() const +bool SwPrintUIOptions::IsPrintLeftPages() const { sal_Int64 nLRPages = getIntValue( "PrintLeftRightPages", 0 ); return nLRPages == 0 || nLRPages == 1; } -bool SwPrintUIOptions::isPrintRightPages() const +bool SwPrintUIOptions::IsPrintRightPages() const { sal_Int64 nLRPages = getIntValue( "PrintLeftRightPages", 0 ); return nLRPages == 0 || nLRPages == 2; @@ -890,14 +890,6 @@ void ViewShell::ChgAllPageSize( Size &rSz ) } } -/****************************************************************************** - * Methode : void ViewShell::CalcPagesForPrint( short nMax, BOOL ... - * Beschreibung: - * Erstellt : OK 04.11.94 15:33 - * Aenderung : MA 07. Jun. 95 - ******************************************************************************/ - - void lcl_SetState( SfxProgress& rProgress, ULONG nPage, ULONG nMax, const XubString *pStr, ULONG nAct, ULONG nCnt, ULONG nOffs, ULONG nPageNo ) @@ -1179,24 +1171,16 @@ SwDoc * ViewShell::FillPrtDoc( SwDoc *pPrtDoc, const SfxPrinter* pPrt) return pPrtDoc; } -/****************************************************************************** - * Methode : void ViewShell::Prt - * Beschreibung: - * Erstellt : OK 04.11.94 15:33 - * Aenderung : MA 10. May. 95 - ******************************************************************************/ - -BOOL ViewShell::Prt( +sal_Bool ViewShell::PrintOrPDFExport( OutputDevice* pOutDev, SwPrtOptions& rOptions, const SwPrintUIOptions &rPrintUIOptions, /* TLPDF keep this or the above? */ sal_Int32 nRenderer, - SfxProgress* pProgress, /* TLPDF superfluous ??? */ bool bIsPDFExport ) { //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -//Immer die Druckroutine in viewpg.cxx (fuer Seitenvorschau) mitpflegen!! +//Immer die Druckroutinen in viewpg.cxx (PrintPreViewPage und PrintProspect) mitpflegen!! //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! BOOL bStartJob = FALSE; @@ -1209,7 +1193,7 @@ BOOL ViewShell::Prt( // TLPDF: this one should hold just one page now. Thus clean-up should be possible MultiSelection aMulti( rOptions.aMulti ); - if ( !aMulti.GetSelectCount() ) + if ( !pOutDev || !aMulti.GetSelectCount() ) return bStartJob; // save settings of OutputDevice (should be done always now since the @@ -1305,7 +1289,7 @@ BOOL ViewShell::Prt( // ben�tigte Seiten fuers Drucken formatieren - pShell->CalcPagesForPrint( (USHORT)nPage, pProgress, pStr, + pShell->CalcPagesForPrint( (USHORT)nPage, 0 /*TLPDF*/, pStr, nMergeAct, nMergeCnt ); // Some field types, can require a valid layout @@ -1523,7 +1507,7 @@ BOOL ViewShell::Prt( if (bSelection ) { // damit das Dokument nicht den Drucker mit ins Grab nimmt - pOutDevDoc->setPrinter( 0, false, false ); +// pOutDevDoc->setPrinter( 0, false, false ); /*TLPDF should not be needed anymore*/ if ( !pOutDevDoc->release() ) delete pOutDevDoc; diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index ba7f79d681a8..bf45078b6550 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -2614,7 +2614,8 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount( m_pPrintUIOptions = new SwPrintUIOptions( bWebDoc ); } bool bFormat = m_pPrintUIOptions->processPropertiesAndCheckFormat( rxOptions ); - const bool bIsPDFExport = !m_pPrintUIOptions->hasProperty( "IsPrinter" ); + const bool bPrintProspect = m_pPrintUIOptions->getBoolValue( C2U( "PrintBrochure" ), false ); + const bool bIsPDFExport = !m_pPrintUIOptions->hasProperty( "IsPrinter" ); SfxViewShell *pView = 0; SwDoc *pDoc = GetRenderDoc( pView, rSelection, bIsPDFExport ); @@ -2655,6 +2656,8 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount( } const sal_Int32 nPageCount = pDoc->GetPageCount(); + + // get PageRange option OUString aPageRange; if (bIsPDFExport) { @@ -2671,7 +2674,6 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount( { aPageRange = m_pPrintUIOptions->getStringValue( C2U( "PageRange" ), OUString() ); } - if (aPageRange.getLength() == 0) { // set page range to print to 'all pages' @@ -2680,18 +2682,27 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount( aPageRange += OUString::valueOf( nPageCount ); } - // get set of valid pages (according to the current settings) - // and their start frames - pDoc->GetValidPagesForPrinting( bIsPDFExport, *m_pPrintUIOptions, nPageCount ); - DBG_ASSERT( nPageCount >= 1, "valid pages count is 0! Should not happen." ); + // get number of pages to be rendered + if(bPrintProspect) + { + pDoc->CalculatePagePairsForProspectPrinting( *m_pPrintUIOptions, nPageCount ); + nRet = m_pPrintUIOptions->GetPagePairsForProspectPrinting().size(); + } + else + { + // get set of valid pages (according to the current settings) + // and their start frames + pDoc->CalculatePagesForPrinting( bIsPDFExport, *m_pPrintUIOptions, nPageCount ); + DBG_ASSERT( nPageCount >= 1, "valid pages count is 0! Should not happen." ); - // get vector of pages to print according to PageRange and valid pages from above - // (result may be an empty vector, for example if the range string is not correct) - StringRangeEnumerator::getRangesFromString( - aPageRange, m_pPrintUIOptions->GetPagesToPrint(), - 1, nPageCount, 0, &m_pPrintUIOptions->GetValidPagesSet() ); + // get vector of pages to print according to PageRange and valid pages from above + // (result may be an empty vector, for example if the range string is not correct) + StringRangeEnumerator::getRangesFromString( + aPageRange, m_pPrintUIOptions->GetPagesToPrint(), + 1, nPageCount, 0, &m_pPrintUIOptions->GetValidPagesSet() ); - nRet = m_pPrintUIOptions->GetPagesToPrint().size(); + nRet = m_pPrintUIOptions->GetPagesToPrint().size(); + } DBG_ASSERT( nRet >= 0, "negative number of pages???" ); return nRet; @@ -2803,7 +2814,8 @@ void SAL_CALL SwXTextDocument::render( m_pPrintUIOptions = new SwPrintUIOptions( bWebDoc ); } m_pPrintUIOptions->processProperties( rxOptions ); - const bool bIsPDFExport = !m_pPrintUIOptions->hasProperty( "IsPrinter" ); + const bool bPrintProspect = m_pPrintUIOptions->getBoolValue( C2U( "PrintBrochure" ), false ); + const bool bIsPDFExport = !m_pPrintUIOptions->hasProperty( "IsPrinter" ); // get view shell to use SfxViewShell *pView = 0; @@ -2830,7 +2842,8 @@ void SAL_CALL SwXTextDocument::render( // Thus instead of throwing the exception we silently return. if (0 > nRenderer) throw IllegalArgumentException(); - if (nRenderer >= sal_Int32(m_pPrintUIOptions->GetPagesToPrint().size())) + if ( (bPrintProspect && nRenderer >= m_pPrintUIOptions->GetPagePairsForProspectPrinting().size()) + || (!bPrintProspect && nRenderer >= m_pPrintUIOptions->GetPagesToPrint().size())) return; // the view shell should be SwView for documents PDF export @@ -2943,7 +2956,10 @@ void SAL_CALL SwXTextDocument::render( // <-- // TLPDF OutputDevice *pOldDev = pVwSh->GetOut(); // TLPDF - pVwSh->Prt( pOut, aOptions, *m_pPrintUIOptions, nRenderer, 0, bIsPDFExport ); + if (bPrintProspect) + pVwSh->PrintProspect( pOut, aOptions, *m_pPrintUIOptions, nRenderer ); + else // normal printing and PDF export + pVwSh->PrintOrPDFExport( pOut, aOptions, *m_pPrintUIOptions, nRenderer, bIsPDFExport ); // --> FME 2004-10-08 #i35176# // -- cgit From 241b10510b86266f8bc169bdad3588e488647127 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Fri, 7 Aug 2009 15:49:37 +0000 Subject: #i92516# fix warning and brochure page size --- sw/source/core/doc/doc.cxx | 6 +++--- sw/source/ui/uno/unotxdoc.cxx | 9 +++++++-- 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'sw') diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index 681af392f2dd..5f8e2a3c5265 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -1184,7 +1184,7 @@ void SwDoc::CalculatePagePairsForProspectPrinting( // now fill the vector for calculating the page pairs with the start frames // from the above obtained vector std::vector< const SwPageFrm * > aVec; - for (sal_Int32 i = 0; i < aPagesToPrint.size(); ++i) + for (size_t i = 0; i < aPagesToPrint.size(); ++i) { const sal_Int32 nPage = aPagesToPrint[i]; const SwPageFrm *pFrm = rValidStartFrms[ nPage ]; @@ -1247,7 +1247,7 @@ void SwDoc::CalculatePagePairsForProspectPrinting( } sal_Int32 nCntPage = (( nEPg - nSPg ) / ( 2 * nStep )) + 1; - DBG_ASSERT( nCntPage * 2 == aVec.size(), "vector size vs. page count mismatch" ); + DBG_ASSERT( size_t(nCntPage * 2) == aVec.size(), "vector size vs. page count mismatch" ); for ( USHORT nPrintCount = 0; nSPg < nEPg && nPrintCount < nCntPage; ++nPrintCount ) @@ -1281,7 +1281,7 @@ void SwDoc::CalculatePagePairsForProspectPrinting( nSPg = nSPg + nStep; nEPg = nEPg - nStep; } - DBG_ASSERT( nCntPage == rPagePairs.size(), "size mismatch for number of page pairs" ); + DBG_ASSERT( size_t(nCntPage) == rPagePairs.size(), "size mismatch for number of page pairs" ); } diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index bf45078b6550..2686026ef24f 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -2744,6 +2744,11 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SwXTextDocument::getRenderer( bool bSkipEmptyPages = m_pPrintUIOptions->getBoolValue( "IsSkipEmptyPages", sal_False ); Size aPgSize( pDoc->GetPageSize( sal_uInt16(nRenderer + 1), bSkipEmptyPages ) ); + if( m_pPrintUIOptions->getBoolValue( C2U( "PrintBrochure" ), sal_False ) ) + { + aPgSize = Size( aPgSize.Height(), aPgSize.Width() ); + } + awt::Size aPageSize( TWIP_TO_MM100( aPgSize.Width() ), TWIP_TO_MM100( aPgSize.Height() )); uno::Sequence< beans::PropertyValue > aRenderer(1); @@ -2842,8 +2847,8 @@ void SAL_CALL SwXTextDocument::render( // Thus instead of throwing the exception we silently return. if (0 > nRenderer) throw IllegalArgumentException(); - if ( (bPrintProspect && nRenderer >= m_pPrintUIOptions->GetPagePairsForProspectPrinting().size()) - || (!bPrintProspect && nRenderer >= m_pPrintUIOptions->GetPagesToPrint().size())) + if ( (bPrintProspect && size_t(nRenderer) >= m_pPrintUIOptions->GetPagePairsForProspectPrinting().size()) + || (!bPrintProspect && size_t(nRenderer) >= m_pPrintUIOptions->GetPagesToPrint().size())) return; // the view shell should be SwView for documents PDF export -- cgit From 25550e914d7c353e5472ffb2db23efe95b76b2d3 Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Mon, 10 Aug 2009 09:55:47 +0000 Subject: #i103991# prospect printing --- sw/source/core/view/viewpg.cxx | 8 +++++--- sw/source/ui/uno/unotxdoc.cxx | 9 +++------ 2 files changed, 8 insertions(+), 9 deletions(-) (limited to 'sw') diff --git a/sw/source/core/view/viewpg.cxx b/sw/source/core/view/viewpg.cxx index 49ec9bb483b3..283e6b6a79f2 100644 --- a/sw/source/core/view/viewpg.cxx +++ b/sw/source/core/view/viewpg.cxx @@ -782,7 +782,7 @@ void ViewShell::PrintProspect( // TLPDF Point aPrtOff( pPrt->PixelToLogic( pPrt->GetPageOffsetPixel(), aMapMode ) ); // TLPDF Size aTmpPrtSize( pPrt->PixelToLogic( pPrt->GetPaperSizePixel(), aMapMode ) ); - Point aPrtOff( pPrinter->PixelToLogic( pPrinter->GetPageOffsetPixel(), aMapMode ) ); /* TLPDF */ +// TLPDF Point aPrtOff( pPrinter->PixelToLogic( pPrinter->GetPageOffsetPixel(), aMapMode ) ); /* TLPDF */ Size aTmpPrtSize( pPrinter->PixelToLogic( pPrinter->GetPaperSizePixel(), aMapMode ) ); /* TLPDF */ // dann kann das drucken losgehen @@ -793,7 +793,9 @@ void ViewShell::PrintProspect( pPrt->StartPage(); #endif - Point aSttPt; + // calculate start point for equal border on all sides + Point aSttPt( (aTmpPrtSize.Width() - nMaxColSz) / 2, + (aTmpPrtSize.Height() - nMaxRowSz) / 2 ); for( int nC = 0; nC < 2; ++nC ) { if( pStPage ) @@ -803,7 +805,7 @@ void ViewShell::PrintProspect( Point aPos( aSttPt ); aPos -= aShell.aVisArea.Pos(); - aPos -= aPrtOff; +// TLPDF aPos -= aPrtOff; aMapMode.SetOrigin( aPos ); pPrinter->SetMapMode( aMapMode ); pStPage->GetUpper()->Paint( pStPage->Frm() ); diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index 2686026ef24f..64971f8f49f8 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -2743,14 +2743,11 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SwXTextDocument::getRenderer( bool bSkipEmptyPages = m_pPrintUIOptions->getBoolValue( "IsSkipEmptyPages", sal_False ); Size aPgSize( pDoc->GetPageSize( sal_uInt16(nRenderer + 1), bSkipEmptyPages ) ); - - if( m_pPrintUIOptions->getBoolValue( C2U( "PrintBrochure" ), sal_False ) ) - { - aPgSize = Size( aPgSize.Height(), aPgSize.Width() ); - } - awt::Size aPageSize( TWIP_TO_MM100( aPgSize.Width() ), TWIP_TO_MM100( aPgSize.Height() )); + // prospect printing should be landscape, thus switching width and height + if (m_pPrintUIOptions->getBoolValue( C2U( "PrintBrochure" ), sal_False )) + aPageSize = awt::Size( aPageSize.Height, aPageSize.Width ); uno::Sequence< beans::PropertyValue > aRenderer(1); PropertyValue &rValue = aRenderer.getArray()[0]; rValue.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "PageSize" ) ); -- cgit From 3afe7e6f516a073c319d413344761373dd6c55db Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Mon, 10 Aug 2009 12:19:26 +0000 Subject: #i103991# page range evaluation fixed --- sw/source/core/doc/doc.cxx | 29 ++++++++++++++++--------- sw/source/ui/uno/unotxdoc.cxx | 49 ++++++++++++++++++++++++------------------- 2 files changed, 46 insertions(+), 32 deletions(-) (limited to 'sw') diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index 5f8e2a3c5265..8f8ccdbecdab 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -1004,15 +1004,15 @@ void SwDoc::CalculatePagesForPrinting( bool bPrintLeftPage = rPrintUIOptions.IsPrintLeftPages(); bool bPrintRightPage = rPrintUIOptions.IsPrintRightPages(); // TLPDF, TODO: remove bPrintReverse, should be handled by PLs framework now - bool bPrintReverse = rPrintUIOptions.getBoolValue( C2U( "PrintReverseOrder" ), false ); - bool bPrintEmptyPages = rPrintUIOptions.getBoolValue( C2U( "PrintEmptyPages" ), false ); +//TLPDF bool bPrintReverse = rPrintUIOptions.getBoolValue( C2U( "PrintReverseOrder" ), false ); + bool bPrintEmptyPages = rPrintUIOptions.getBoolValue( "PrintEmptyPages", false ); if (bIsPDFExport) { // PDF export UI does not allow for selecting left or right pages only or reverse print bPrintLeftPage = true; bPrintRightPage = true; - bPrintReverse = false; +// bPrintReverse = false; // TLPDF, TODO; take care of the option 'Export automatically inserted blank pages' // from the 'Export as PDF' (aka PDF Options) dialog. bPrintEmptyPages = false; @@ -1076,6 +1076,7 @@ void SwDoc::CalculatePagesForPrinting( aMulti = aTmpMulti; // Ende des HACKs +#ifdef TL_NOT_NOW /*TLPDF*/ if (bPrintReverse) { const SwFrm *pTmp = pStPage; @@ -1084,6 +1085,7 @@ void SwDoc::CalculatePagesForPrinting( nPageNo = nLastPageNo; } else +#endif // TL_NOT_NOW /*TLPDF*/ nPageNo = nFirstPageNo; std::set< sal_Int32 > &rValidPages = rPrintUIOptions.GetValidPagesSet(); @@ -1111,11 +1113,13 @@ void SwDoc::CalculatePagesForPrinting( { pStPage = 0; } +#ifdef TL_NOT_NOW /*TLPDF*/ else if ( bPrintReverse ) { --nPageNo; pStPage = (SwPageFrm*)pStPage->GetPrev(); } +#endif // TL_NOT_NOW /*TLPDF*/ else { ++nPageNo; pStPage = (SwPageFrm*)pStPage->GetNext(); @@ -1137,7 +1141,7 @@ void SwDoc::CalculatePagePairsForProspectPrinting( rValidPagesSet.clear(); rValidStartFrms.clear(); - rtl::OUString aPageRange = rPrintUIOptions.getStringValue( C2U( "PageRange" ), rtl::OUString() ); + rtl::OUString aPageRange = rPrintUIOptions.getStringValue( "PageRange", rtl::OUString() ); StringRangeEnumerator aRange( aPageRange, 1, nDocPageCount, 0 ); DBG_ASSERT( pLayout, "no layout present" ); @@ -1171,9 +1175,9 @@ void SwDoc::CalculatePagePairsForProspectPrinting( bool bPrintLeftPage = rPrintUIOptions.IsPrintLeftPages(); bool bPrintRightPage = rPrintUIOptions.IsPrintRightPages(); // TLPDF, TODO: remove bPrintReverse, should be handled by PLs framework now - bool bPrintReverse = rPrintUIOptions.getBoolValue( C2U( "PrintReverseOrder" ), false ); +//TLPDF bool bPrintReverse = rPrintUIOptions.getBoolValue( C2U( "PrintReverseOrder" ), false ); // TLPDF: this one seems not to be used in prospect printing: bool bPrintEmptyPages = rPrintUIOptions.getBoolValue( C2U( "PrintEmptyPages" ), false ); - bool bPrintProspect_RTL = rPrintUIOptions.getIntValue( C2U( "PrintBrochureRTL" ), 0 ) ? true : false; + bool bPrintProspect_RTL = rPrintUIOptions.getIntValue( "PrintBrochureRTL", 0 ) ? true : false; // get pages for prospect printing according to the 'PageRange' // (duplicates and any order allowed!) @@ -1191,14 +1195,18 @@ void SwDoc::CalculatePagePairsForProspectPrinting( aVec.push_back( pFrm ); } - // auf Doppelseiten auffuellen - if ( 1 == aVec.size() ) // eine Seite ist ein Sonderfall - aVec.insert( aVec.begin() + 1, 0 ); + // just one page is special ... + if ( 1 == aVec.size() ) + aVec.insert( aVec.begin() + 1, 0 ); // insert a second empty page else { + // now extend the number of pages to fit a multiple of 4 + // (4 'normal' pages are needed for a single prospect paper + // with back and front) while( aVec.size() & 3 ) aVec.push_back( 0 ); +#ifdef TL_NOT_NOW /*TLPDF*/ if ( bPrintReverse && 4 < aVec.size() ) { // das Array umsortieren @@ -1230,6 +1238,7 @@ void SwDoc::CalculatePagePairsForProspectPrinting( ppArrHalf = &aVec[ 0 ] + aVec.size(); } } +#endif // TL_NOT_NOW /*TLPDF*/ } // dann sorge mal dafuer, das alle Seiten in der richtigen @@ -1246,8 +1255,8 @@ void SwDoc::CalculatePagePairsForProspectPrinting( ++nSPg, --nEPg; } + // the number of 'virtual' pages to be printed sal_Int32 nCntPage = (( nEPg - nSPg ) / ( 2 * nStep )) + 1; - DBG_ASSERT( size_t(nCntPage * 2) == aVec.size(), "vector size vs. page count mismatch" ); for ( USHORT nPrintCount = 0; nSPg < nEPg && nPrintCount < nCntPage; ++nPrintCount ) diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index 64971f8f49f8..0121d2de348f 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -2614,7 +2614,7 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount( m_pPrintUIOptions = new SwPrintUIOptions( bWebDoc ); } bool bFormat = m_pPrintUIOptions->processPropertiesAndCheckFormat( rxOptions ); - const bool bPrintProspect = m_pPrintUIOptions->getBoolValue( C2U( "PrintBrochure" ), false ); + const bool bPrintProspect = m_pPrintUIOptions->getBoolValue( "PrintBrochure", false ); const bool bIsPDFExport = !m_pPrintUIOptions->hasProperty( "IsPrinter" ); SfxViewShell *pView = 0; @@ -2657,7 +2657,7 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount( const sal_Int32 nPageCount = pDoc->GetPageCount(); - // get PageRange option + // get PageRange value to use OUString aPageRange; if (bIsPDFExport) { @@ -2672,9 +2672,14 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount( } else { - aPageRange = m_pPrintUIOptions->getStringValue( C2U( "PageRange" ), OUString() ); + // PageContent : + // 0 -> print all pages + // 1 -> print range according to PageRange + // 2 -> print selection + if (1 == m_pPrintUIOptions->getIntValue( "PrintContent", 0 )) + aPageRange = m_pPrintUIOptions->getStringValue( "PageRange", OUString() ); } - if (aPageRange.getLength() == 0) + if (aPageRange.getLength() == 0) // empty string -> print all { // set page range to print to 'all pages' aPageRange = OUString::valueOf( (sal_Int32)1 ); @@ -2683,7 +2688,7 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount( } // get number of pages to be rendered - if(bPrintProspect) + if (bPrintProspect) { pDoc->CalculatePagePairsForProspectPrinting( *m_pPrintUIOptions, nPageCount ); nRet = m_pPrintUIOptions->GetPagePairsForProspectPrinting().size(); @@ -2746,7 +2751,7 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SwXTextDocument::getRenderer( awt::Size aPageSize( TWIP_TO_MM100( aPgSize.Width() ), TWIP_TO_MM100( aPgSize.Height() )); // prospect printing should be landscape, thus switching width and height - if (m_pPrintUIOptions->getBoolValue( C2U( "PrintBrochure" ), sal_False )) + if (m_pPrintUIOptions->getBoolValue( "PrintBrochure", sal_False )) aPageSize = awt::Size( aPageSize.Height, aPageSize.Width ); uno::Sequence< beans::PropertyValue > aRenderer(1); PropertyValue &rValue = aRenderer.getArray()[0]; @@ -2816,7 +2821,7 @@ void SAL_CALL SwXTextDocument::render( m_pPrintUIOptions = new SwPrintUIOptions( bWebDoc ); } m_pPrintUIOptions->processProperties( rxOptions ); - const bool bPrintProspect = m_pPrintUIOptions->getBoolValue( C2U( "PrintBrochure" ), false ); + const bool bPrintProspect = m_pPrintUIOptions->getBoolValue( "PrintBrochure", false ); const bool bIsPDFExport = !m_pPrintUIOptions->hasProperty( "IsPrinter" ); // get view shell to use @@ -2825,7 +2830,7 @@ void SAL_CALL SwXTextDocument::render( pView = GuessViewShell(); else { - uno::Any aTmp( m_pPrintUIOptions->getValue( C2U("View") ) ); + uno::Any aTmp( m_pPrintUIOptions->getValue( C2U( "View" ) )); uno::Reference< frame::XController > xController; if (aTmp >>= xController) { @@ -2901,25 +2906,25 @@ void SAL_CALL SwXTextDocument::render( if( ! aOptions.bPrintRightPage ) nLeftRightPages = 1; nLeftRightPages = m_pPrintUIOptions->getIntValue( "PrintLeftRightPages", nLeftRightPages ); - aOptions.bPrintGraphic = m_pPrintUIOptions->getBoolValue( C2U( "PrintGraphicsAndDiagrams" ), aOptions.bPrintGraphic ); - aOptions.bPrintTable = m_pPrintUIOptions->getBoolValue( C2U( "PrintGraphicsAndDiagrams" ), aOptions.bPrintTable ); - aOptions.bPrintDraw = m_pPrintUIOptions->getBoolValue( C2U( "PrintGraphicsAndDiagrams" ), aOptions.bPrintDraw ); - aOptions.bPrintControl = m_pPrintUIOptions->getBoolValue( C2U( "PrintControls" ), aOptions.bPrintControl ); + aOptions.bPrintGraphic = m_pPrintUIOptions->getBoolValue( "PrintGraphicsAndDiagrams", aOptions.bPrintGraphic ); + aOptions.bPrintTable = m_pPrintUIOptions->getBoolValue( "PrintGraphicsAndDiagrams", aOptions.bPrintTable ); + aOptions.bPrintDraw = m_pPrintUIOptions->getBoolValue( "PrintGraphicsAndDiagrams", aOptions.bPrintDraw ); + aOptions.bPrintControl = m_pPrintUIOptions->getBoolValue( "PrintControls", aOptions.bPrintControl ); aOptions.bPrintLeftPage = nLeftRightPages == 0 || nLeftRightPages == 1; aOptions.bPrintRightPage = nLeftRightPages == 0 || nLeftRightPages == 2; - aOptions.bPrintPageBackground = m_pPrintUIOptions->getBoolValue( C2U( "PrintBackground" ), aOptions.bPrintPageBackground ); - aOptions.bPrintEmptyPages = m_pPrintUIOptions->getBoolValue( C2U( "PrintEmptyPages" ), aOptions.bPrintEmptyPages ); + aOptions.bPrintPageBackground = m_pPrintUIOptions->getBoolValue( "PrintBackground", aOptions.bPrintPageBackground ); + aOptions.bPrintEmptyPages = m_pPrintUIOptions->getBoolValue( "PrintEmptyPages", aOptions.bPrintEmptyPages ); // bUpdateFieldsInPrinting <-- not set here // TLPDF: TODO: remove this from SwPrintData?? Get rid of SwPrtOptions?? - aOptions.bPaperFromSetup = m_pPrintUIOptions->getBoolValue( C2U( "PaperTray" ), aOptions.bPaperFromSetup ); - aOptions.bPrintReverse = m_pPrintUIOptions->getBoolValue( C2U( "PrintReverseOrder" ), aOptions.bPrintReverse ); - aOptions.bPrintProspect = m_pPrintUIOptions->getBoolValue( C2U( "PrintBrochure" ), aOptions.bPrintProspect ); - aOptions.bPrintProspect_RTL = m_pPrintUIOptions->getIntValue( C2U( "PrintBrochureRTL" ), aOptions.bPrintProspect_RTL ) ? true : false; + aOptions.bPaperFromSetup = m_pPrintUIOptions->getBoolValue( "PaperTray", aOptions.bPaperFromSetup ); + aOptions.bPrintReverse = m_pPrintUIOptions->getBoolValue( "PrintReverseOrder", aOptions.bPrintReverse ); + aOptions.bPrintProspect = m_pPrintUIOptions->getBoolValue( "PrintBrochure", aOptions.bPrintProspect ); + aOptions.bPrintProspect_RTL = m_pPrintUIOptions->getIntValue( "PrintBrochureRTL", aOptions.bPrintProspect_RTL ) ? true : false; // bPrintSingleJobs <-- not set here // TLPDF: TODO: remove this from SwPrintData?? Get rid of SwPrtOptions?? // bModified <-- not set here // TLPDF: TODO: remove this from SwPrintData?? Get rid of SwPrtOptions?? - aOptions.bPrintBlackFont = m_pPrintUIOptions->getBoolValue( C2U( "PrintBlack" ), aOptions.bPrintBlackFont ); - aOptions.bPrintHiddenText = m_pPrintUIOptions->getBoolValue( C2U( "PrintHiddenText" ), aOptions.bPrintHiddenText ); - aOptions.bPrintTextPlaceholder = m_pPrintUIOptions->getBoolValue( C2U( "PrintPlaceholder" ), aOptions.bPrintTextPlaceholder ); - aOptions.nPrintPostIts = static_cast< sal_Int16 >(m_pPrintUIOptions->getIntValue( C2U( "PrintNotes" ), aOptions.nPrintPostIts )); + aOptions.bPrintBlackFont = m_pPrintUIOptions->getBoolValue( "PrintBlack", aOptions.bPrintBlackFont ); + aOptions.bPrintHiddenText = m_pPrintUIOptions->getBoolValue( "PrintHiddenText", aOptions.bPrintHiddenText ); + aOptions.bPrintTextPlaceholder = m_pPrintUIOptions->getBoolValue( "PrintPlaceholder", aOptions.bPrintTextPlaceholder ); + aOptions.nPrintPostIts = static_cast< sal_Int16 >(m_pPrintUIOptions->getIntValue( "PrintNotes", aOptions.nPrintPostIts )); Range aPageRange( nRenderer+1, nRenderer+1 ); MultiSelection aPage( aPageRange ); -- cgit From 8024a0f98383645946d25d83edd6d22ecd1f9702 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Mon, 10 Aug 2009 14:52:25 +0000 Subject: fix a warning --- sw/source/core/doc/doc.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sw') diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index 8f8ccdbecdab..e17f01a88d2c 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -1272,7 +1272,7 @@ void SwDoc::CalculatePagePairsForProspectPrinting( pNxtPage = pTmp; } - sal_Int32 nFirst, nSecond = -1; + sal_Int32 nFirst = -1, nSecond = -1; for ( int nC = 0; nC < 2; ++nC ) { sal_Int32 nPageNum = -1; -- cgit From 3fbd3247c9d5d0ece2cda623250915bea14c066d Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Mon, 10 Aug 2009 17:36:31 +0000 Subject: #i92516# more changes for final UI spec --- sw/source/core/view/vprint.cxx | 101 +++++++++++++++++++++-------------------- sw/source/ui/config/optdlg.src | 69 ++++++++++++---------------- 2 files changed, 80 insertions(+), 90 deletions(-) (limited to 'sw') diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index e4083016131a..a1878283cf01 100644 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -234,81 +234,81 @@ SwPrintUIOptions::SwPrintUIOptions( BOOL bWeb ) : { ResStringArray aLocalizedStrings( SW_RES( STR_PRINTOPTUI ) ); - DBG_ASSERT( aLocalizedStrings.Count() >= 46, "resource incomplete" ); - if( aLocalizedStrings.Count() < 46 ) // bad resource ? + DBG_ASSERT( aLocalizedStrings.Count() >= 44, "resource incomplete" ); + if( aLocalizedStrings.Count() < 44 ) // bad resource ? return; // create sequence of print UI options // (5 options are not available for Writer-Web) - const int nNumProps = bWeb? 17 : 20; + const int nNumProps = bWeb? 17 : 21; m_aUIProperties.realloc( nNumProps ); int nIdx = 0; // create "writer" section (new tab page in dialog) SvtModuleOptions aOpt; - String aAppGroupname( aLocalizedStrings.GetString( 54 ) ); + String aAppGroupname( aLocalizedStrings.GetString( 0 ) ); aAppGroupname.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "%s" ) ), aOpt.GetModuleName( SvtModuleOptions::E_SWRITER ) ); m_aUIProperties[ nIdx++ ].Value = getGroupControlOpt( aAppGroupname, rtl::OUString() ); // create sub section for Contents - m_aUIProperties[ nIdx++ ].Value = getSubgroupControlOpt( aLocalizedStrings.GetString( 0 ), rtl::OUString() ); + m_aUIProperties[ nIdx++ ].Value = getSubgroupControlOpt( aLocalizedStrings.GetString( 1 ), rtl::OUString() ); // create a bool option for background - m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 9 ), - aLocalizedStrings.GetString( 10 ), + m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 2 ), + aLocalizedStrings.GetString( 3 ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintBackground" ) ), sal_True ); // create a bool option for graphics - m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 1 ), - aLocalizedStrings.GetString( 2 ), + m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 4 ), + aLocalizedStrings.GetString( 5 ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintGraphicsAndDiagrams" ) ), sal_True ); if (!bWeb) { // create a bool option for hidden text - m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 13 ), - aLocalizedStrings.GetString( 14 ), + m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 6 ), + aLocalizedStrings.GetString( 7 ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintHiddenText" ) ), sal_False ); // create a bool option for place holder - m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 15 ), - aLocalizedStrings.GetString( 16 ), + m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 8 ), + aLocalizedStrings.GetString( 9 ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintPlaceholder" ) ), sal_False ); } // create a bool option for controls - m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 7 ), - aLocalizedStrings.GetString( 8 ), + m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 10 ), + aLocalizedStrings.GetString( 11 ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintControls" ) ), sal_True ); // create sub section for Color - m_aUIProperties[ nIdx++ ].Value = getSubgroupControlOpt( aLocalizedStrings.GetString( 47 ), rtl::OUString() ); + m_aUIProperties[ nIdx++ ].Value = getSubgroupControlOpt( aLocalizedStrings.GetString( 12 ), rtl::OUString() ); // create a bool option for black - m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 11 ), - aLocalizedStrings.GetString( 12 ), + m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 13 ), + aLocalizedStrings.GetString( 14 ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintBlack" ) ), sal_False ); // create subgroup for misc options - m_aUIProperties[ nIdx++ ].Value = getSubgroupControlOpt( rtl::OUString( aLocalizedStrings.GetString( 34 ) ), rtl::OUString() ); + m_aUIProperties[ nIdx++ ].Value = getSubgroupControlOpt( rtl::OUString( aLocalizedStrings.GetString( 15 ) ), rtl::OUString() ); // create a bool option for blank pages - m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 35 ), - aLocalizedStrings.GetString( 36 ), + m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 16 ), + aLocalizedStrings.GetString( 17 ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintEmptyPages" ) ), sal_True ); // create a bool option for paper tray vcl::PrinterOptionsHelper::UIControlOptions aPaperTrayOpt; aPaperTrayOpt.maGroupHint = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OptionsPageOptGroup" ) ); - m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 37 ), - aLocalizedStrings.GetString( 38 ), + m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 18 ), + aLocalizedStrings.GetString( 19 ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PaperTray" ) ), sal_False, aPaperTrayOpt @@ -317,20 +317,20 @@ SwPrintUIOptions::SwPrintUIOptions( BOOL bWeb ) : // print content selection vcl::PrinterOptionsHelper::UIControlOptions aContentsOpt; aContentsOpt.maGroupHint = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "JobPage" ) ); - m_aUIProperties[nIdx++].Value = getSubgroupControlOpt( rtl::OUString( aLocalizedStrings.GetString( 46 ) ), + m_aUIProperties[nIdx++].Value = getSubgroupControlOpt( rtl::OUString( aLocalizedStrings.GetString( 20 ) ), rtl::OUString(), aContentsOpt ); // create a list box for notes content uno::Sequence< rtl::OUString > aChoices( 4 ); - aChoices[0] = aLocalizedStrings.GetString( 19 ); - aChoices[1] = aLocalizedStrings.GetString( 20 ); - aChoices[2] = aLocalizedStrings.GetString( 21 ); - aChoices[3] = aLocalizedStrings.GetString( 22 ); + aChoices[0] = aLocalizedStrings.GetString( 21 ); + aChoices[1] = aLocalizedStrings.GetString( 22 ); + aChoices[2] = aLocalizedStrings.GetString( 23 ); + aChoices[3] = aLocalizedStrings.GetString( 24 ); uno::Sequence< rtl::OUString > aHelpText( 2 ); - aHelpText[0] = aLocalizedStrings.GetString( 18 ); - aHelpText[1] = aLocalizedStrings.GetString( 18 ); - m_aUIProperties[ nIdx++ ].Value = getChoiceControlOpt( aLocalizedStrings.GetString( 17 ), + aHelpText[0] = aLocalizedStrings.GetString( 25 ); + aHelpText[1] = aLocalizedStrings.GetString( 25 ); + m_aUIProperties[ nIdx++ ].Value = getChoiceControlOpt( aLocalizedStrings.GetString( 26 ), aHelpText, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintNotes" ) ), aChoices, @@ -344,25 +344,28 @@ SwPrintUIOptions::SwPrintUIOptions( BOOL bWeb ) : if (!bWeb) { + m_aUIProperties[nIdx++].Value = getSubgroupControlOpt( rtl::OUString( aLocalizedStrings.GetString( 27 ) ), + rtl::OUString(), + aPageSetOpt + ); uno::Sequence< rtl::OUString > aRLChoices( 3 ); - aRLChoices[0] = aLocalizedStrings.GetString( 51 ); - aRLChoices[1] = aLocalizedStrings.GetString( 52 ); - aRLChoices[2] = aLocalizedStrings.GetString( 53 ); + aRLChoices[0] = aLocalizedStrings.GetString( 28 ); + aRLChoices[1] = aLocalizedStrings.GetString( 29 ); + aRLChoices[2] = aLocalizedStrings.GetString( 30 ); uno::Sequence< rtl::OUString > aRLHelp( 1 ); - aRLHelp[0] = aLocalizedStrings.GetString( 50 ); + aRLHelp[0] = aLocalizedStrings.GetString( 31 ); // create a choice option for all/left/right pages - m_aUIProperties[ nIdx++ ].Value = getChoiceControlOpt( aLocalizedStrings.GetString( 49 ), + m_aUIProperties[ nIdx++ ].Value = getChoiceControlOpt( aLocalizedStrings.GetString( 32 ), aRLHelp, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintLeftRightPages" ) ), - aRLChoices, 0, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "List" ) ), - aPageSetOpt + aRLChoices, 0, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "List" ) ) ); } // create a bool option for brochure rtl::OUString aBrochurePropertyName( RTL_CONSTASCII_USTRINGPARAM( "PrintBrochure" ) ); - m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 30 ), - aLocalizedStrings.GetString( 31 ), + m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 33 ), + aLocalizedStrings.GetString( 34 ), aBrochurePropertyName, sal_False, aPageSetOpt @@ -370,8 +373,8 @@ SwPrintUIOptions::SwPrintUIOptions( BOOL bWeb ) : // create a bool option for brochure RTL dependent on brochure uno::Sequence< rtl::OUString > aBRTLChoices( 3 ); - aBRTLChoices[0] = aLocalizedStrings.GetString( 55 ); - aBRTLChoices[1] = aLocalizedStrings.GetString( 56 ); + aBRTLChoices[0] = aLocalizedStrings.GetString( 35 ); + aBRTLChoices[1] = aLocalizedStrings.GetString( 36 ); vcl::PrinterOptionsHelper::UIControlOptions aBrochureRTLOpt( aBrochurePropertyName, -1, sal_True ); aBrochureRTLOpt.maGroupHint = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutPage" ) ); m_aUIProperties[ nIdx++ ].Value = getChoiceControlOpt( rtl::OUString(), @@ -385,7 +388,7 @@ SwPrintUIOptions::SwPrintUIOptions( BOOL bWeb ) : vcl::PrinterOptionsHelper::UIControlOptions aPrintRangeOpt; aPrintRangeOpt.maGroupHint = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintRange" ) ); aPrintRangeOpt.mbInternalOnly = sal_True; - m_aUIProperties[nIdx++].Value = getSubgroupControlOpt( rtl::OUString( aLocalizedStrings.GetString( 39 ) ), + m_aUIProperties[nIdx++].Value = getSubgroupControlOpt( rtl::OUString( aLocalizedStrings.GetString( 37 ) ), rtl::OUString(), aPrintRangeOpt ); @@ -394,12 +397,12 @@ SwPrintUIOptions::SwPrintUIOptions( BOOL bWeb ) : rtl::OUString aPrintRangeName( RTL_CONSTASCII_USTRINGPARAM( "PrintContent" ) ); aChoices.realloc( 3 ); aHelpText.realloc( 3 ); - aChoices[0] = aLocalizedStrings.GetString( 40 ); - aHelpText[0] = aLocalizedStrings.GetString( 41 ); - aChoices[1] = aLocalizedStrings.GetString( 42 ); - aHelpText[1] = aLocalizedStrings.GetString( 43 ); - aChoices[2] = aLocalizedStrings.GetString( 44 ); - aHelpText[2] = aLocalizedStrings.GetString( 45 ); + aChoices[0] = aLocalizedStrings.GetString( 38 ); + aHelpText[0] = aLocalizedStrings.GetString( 39 ); + aChoices[1] = aLocalizedStrings.GetString( 40 ); + aHelpText[1] = aLocalizedStrings.GetString( 41 ); + aChoices[2] = aLocalizedStrings.GetString( 42 ); + aHelpText[2] = aLocalizedStrings.GetString( 43 ); m_aUIProperties[nIdx++].Value = getChoiceControlOpt( rtl::OUString(), aHelpText, aPrintRangeName, diff --git a/sw/source/ui/config/optdlg.src b/sw/source/ui/config/optdlg.src index d6456f69d2a6..87bfc608ae41 100644 --- a/sw/source/ui/config/optdlg.src +++ b/sw/source/ui/config/optdlg.src @@ -940,63 +940,50 @@ StringArray STR_PRINTOPTUI { ItemList [en-US] = { + < "%PRODUCTNAME %s"; >; < "Contents"; >; - < "~Graphics and diagrams"; >; - < "Specifies whether the graphics of your text document are printed"; >; - < "~Tables"; >; - < "Specifies whether the tables of the text document are printed"; >; - < "Dra~wings"; >; - < "Specifies whether graphics created with %PRODUCTNAME drawing functions are printed."; >; - < "Form control~s"; >; - < "Specifies whether the form control fields of the text document are printed"; >; < "Page ba~ckground"; >; < "Specifies whether to include colors and objects that are inserted to the background of the page (Format - Page - Background) in the printed document."; >; - < "Print text in blac~k"; >; - < "Specifies whether to always print text in black."; >; + < "~Graphics and diagrams"; >; + < "Specifies whether the graphics of your text document are printed"; >; < "Hidden te~xt"; >; < "Enable this option to print text that is marked as hidden."; >; < "Text ~placeholder"; >; < "Enable this option to print text placeholders. Disable this option to leave the text placeholders blank in the printout."; >; - < "~Notes"; >; - < "Specify where to print notes (if any)."; >; + < "Form control~s"; >; + < "Specifies whether the form control fields of the text document are printed"; >; + < "Color"; >; + < "Print text in blac~k"; >; + < "Specifies whether to always print text in black."; >; + < "Pages"; >; + < "~Add blank pages for page breaks"; >; + < "If this option is enabled automatically inserted blank pages are printed. This is best if you are printing double-sided. For example, in a book, a \"chapter\" paragraph style has been set to always start with an odd numbered page. If the previous chapter ends on an odd page, %PRODUCTNAME inserts an even numbered blank page. This option controls whether to print that even numbered page or not"; >; + < "~Use only paper tray from printer preferences"; >; + < "For printers with multiple trays this option specifies whether the paper tray used is specified by the system settings of the printer."; >; + < "Print"; >; < "Document only"; >; < "Notes only"; >; < " at end of document"; >; < " at end of page"; >; - < "Page settings"; >; - < "~Left pages"; >; - < "Specifies whether to print all left pages of the document."; >; - < "~Right pages"; >; - < "Specifies whether to print all right pages of the document."; >; - < "Re~versed"; >; - < "Specifies whether to reverse the printing order."; >; + < "Specify where to print notes (if any)."; >; + < "~Notes"; >; + < "Page sides";>; + < "All pages"; >; + < "Back sides / left pages"; >; + < "Front sides / right pages"; >; + < "Specify which pages to include in the output"; >; + < "Include"; >; < "Broch~ure"; >; < "Select the Brochure option to print the document in brochure format."; >; - < "Right to Left"; >; - < "Check to print the pages of the brochure in the correct order for a right-to-left script."; >; - < "Pages"; >; - < "Print ~automatically inserted blank pages"; >; - < "If this option is enabled automatically inserted blank pages are printed. This is best if you are printing double-sided. For example, in a book, a \"chapter\" paragraph style has been set to always start with an odd numbered page. If the previous chapter ends on an odd page, %PRODUCTNAME inserts an even numbered blank page. This option controls whether to print that even numbered page or not"; >; - < "~Paper tray from printer settings"; >; - < "For printers with multiple trays this option specifies whether the paper tray used is specified by the system settings of the printer."; >; - < "Print Range"; >; + < "Left-to-right script"; >; + < "Right-to-left script"; >; + < "Ranges and copies"; >; < "~All pages"; >; - < "Print all pages of the document."; >; - < "~Pages"; >; + < "Print the whole document."; >; + < "Pa~ges"; >; < "Print a range of pages of the document."; >; < "~Selection"; >; - < "Print only the currently selected content."; >; - < "Print"; >; - < "Color"; >; - < "Paper tray"; >; - < "Include"; >; - < "Specify which pages to include in the output"; >; - < "left and right pages"; >; - < "left pages"; >; - < "right pages"; >; - < "%PRODUCTNAME %s"; >; - < "Left-to-right script"; >; - < "Right-to-left script"; >; + < "Print only the selected parts of the document"; >; }; }; -- cgit From 5efcf0dbf3ee0c6136f4a261b1b8f0ed1f013bbf Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Tue, 11 Aug 2009 08:25:58 +0000 Subject: fix warnings --- sw/source/core/doc/doc.cxx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'sw') diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index e17f01a88d2c..e480138a8ca6 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -1188,7 +1188,7 @@ void SwDoc::CalculatePagePairsForProspectPrinting( // now fill the vector for calculating the page pairs with the start frames // from the above obtained vector std::vector< const SwPageFrm * > aVec; - for (size_t i = 0; i < aPagesToPrint.size(); ++i) + for ( i = 0; i < sal_Int32(aPagesToPrint.size()); ++i) { const sal_Int32 nPage = aPagesToPrint[i]; const SwPageFrm *pFrm = rValidStartFrms[ nPage ]; @@ -1275,13 +1275,13 @@ void SwDoc::CalculatePagePairsForProspectPrinting( sal_Int32 nFirst = -1, nSecond = -1; for ( int nC = 0; nC < 2; ++nC ) { - sal_Int32 nPageNum = -1; + sal_Int32 nPage = -1; if ( pStPage ) - nPageNum = pStPage->GetPhyPageNum(); + nPage = pStPage->GetPhyPageNum(); if (nC == 0) - nFirst = nPageNum; + nFirst = nPage; else - nSecond = nPageNum; + nSecond = nPage; pStPage = pNxtPage; } -- cgit From 6f114639ebbd358fbe45f389e838595fea1cf88b Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Tue, 11 Aug 2009 12:37:03 +0000 Subject: #i103991# small clean-up --- sw/source/ui/uno/unotxdoc.cxx | 54 +++++++++++++++---------------------------- 1 file changed, 19 insertions(+), 35 deletions(-) (limited to 'sw') diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index 0121d2de348f..104e3257ccfb 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -2614,7 +2614,6 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount( m_pPrintUIOptions = new SwPrintUIOptions( bWebDoc ); } bool bFormat = m_pPrintUIOptions->processPropertiesAndCheckFormat( rxOptions ); - const bool bPrintProspect = m_pPrintUIOptions->getBoolValue( "PrintBrochure", false ); const bool bIsPDFExport = !m_pPrintUIOptions->hasProperty( "IsPrinter" ); SfxViewShell *pView = 0; @@ -2661,14 +2660,8 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount( OUString aPageRange; if (bIsPDFExport) { -// uno::Any aSelection; - for( sal_Int32 i = 0, nCount = rxOptions.getLength(); i < nCount; ++i ) - { - if( rxOptions[ i ].Name == OUString( RTL_CONSTASCII_USTRINGPARAM( "PageRange" ) ) ) - rxOptions[ i ].Value >>= aPageRange; -// else if( rxOptions[ i ].Name == OUString( RTL_CONSTASCII_USTRINGPARAM( "Selection" ) ) ) -// rxOptions[ i ].Value >>= aSelection; - } +// TLPDF ?? m_pPrintUIOptions->getValue( C2U("Selection") ); + aPageRange = m_pPrintUIOptions->getStringValue( "PageRange", OUString() ); } else { @@ -2688,6 +2681,7 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount( } // get number of pages to be rendered + const bool bPrintProspect = m_pPrintUIOptions->getBoolValue( "PrintBrochure", false ); if (bPrintProspect) { pDoc->CalculatePagePairsForProspectPrinting( *m_pPrintUIOptions, nPageCount ); @@ -2746,8 +2740,8 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SwXTextDocument::getRenderer( if (nRenderer >= pDoc->GetPageCount()) return uno::Sequence< beans::PropertyValue >(); - bool bSkipEmptyPages = m_pPrintUIOptions->getBoolValue( "IsSkipEmptyPages", sal_False ); - Size aPgSize( pDoc->GetPageSize( sal_uInt16(nRenderer + 1), bSkipEmptyPages ) ); + const bool bIsSkipEmptyPages = m_pPrintUIOptions->getBoolValue( "IsSkipEmptyPages", sal_False ); + Size aPgSize( pDoc->GetPageSize( sal_uInt16(nRenderer + 1), bIsSkipEmptyPages ) ); awt::Size aPageSize( TWIP_TO_MM100( aPgSize.Width() ), TWIP_TO_MM100( aPgSize.Height() )); // prospect printing should be landscape, thus switching width and height @@ -2866,24 +2860,9 @@ void SAL_CALL SwXTextDocument::render( ((SwPagePreView*)pView)->GetViewShell(); } + uno::Any aAny( m_pPrintUIOptions->getValue( C2U( "RenderDevice" ) )); uno::Reference< awt::XDevice > xRenderDevice; - bool bFirstPage = false; - bool bLastPage = false; - rtl::OUString aPages; - bool bSkipEmptyPages = false; - for( sal_Int32 nProperty = 0, nPropertyCount = rxOptions.getLength(); nProperty < nPropertyCount; ++nProperty ) - { - if( rxOptions[ nProperty ].Name == OUString( RTL_CONSTASCII_USTRINGPARAM( "RenderDevice" ) ) ) - rxOptions[ nProperty].Value >>= xRenderDevice; - else if( rxOptions[ nProperty ].Name == OUString( RTL_CONSTASCII_USTRINGPARAM( "IsFirstPage" ) ) ) - rxOptions[ nProperty].Value >>= bFirstPage; - else if( rxOptions[ nProperty ].Name == OUString( RTL_CONSTASCII_USTRINGPARAM( "IsLastPage" ) ) ) - rxOptions[ nProperty].Value >>= bLastPage; - else if( rxOptions[ nProperty ].Name == OUString( RTL_CONSTASCII_USTRINGPARAM( "PageRange" ) ) ) - rxOptions[ nProperty].Value >>= aPages; - else if( rxOptions[ nProperty ].Name == OUString( RTL_CONSTASCII_USTRINGPARAM( "IsSkipEmptyPages" ) ) ) - rxOptions[ nProperty].Value >>= bSkipEmptyPages; - } + aAny >>= xRenderDevice; OutputDevice* pOut = 0; if (xRenderDevice.is()) @@ -2894,6 +2873,11 @@ void SAL_CALL SwXTextDocument::render( if(pVwSh && pOut) { + const bool bFirstPage = m_pPrintUIOptions->getBoolValue( "IsFirstPage", sal_False ); + const bool bLastPage = m_pPrintUIOptions->getBoolValue( "IsLastPage", sal_False ); + const bool bIsSkipEmptyPages = m_pPrintUIOptions->getBoolValue( "IsSkipEmptyPages", sal_False ); + const rtl::OUString aPageRange = m_pPrintUIOptions->getStringValue( "PageRange", OUString() ); + SwPrtOptions aOptions( C2U("PDF export") ); // get print options to use from provided properties @@ -2926,11 +2910,11 @@ void SAL_CALL SwXTextDocument::render( aOptions.bPrintTextPlaceholder = m_pPrintUIOptions->getBoolValue( "PrintPlaceholder", aOptions.bPrintTextPlaceholder ); aOptions.nPrintPostIts = static_cast< sal_Int16 >(m_pPrintUIOptions->getIntValue( "PrintNotes", aOptions.nPrintPostIts )); - Range aPageRange( nRenderer+1, nRenderer+1 ); - MultiSelection aPage( aPageRange ); - aPage.SetTotalRange( Range( 0, RANGE_MAX ) ); - aPage.Select( aPageRange ); - aOptions.aMulti = aPage; + Range aRange( nRenderer+1, nRenderer+1 ); + MultiSelection aPages( aRange ); + aPages.SetTotalRange( Range( 0, RANGE_MAX ) ); + aPages.Select( aRange ); + aOptions.aMulti = aPages; //! Note: Since for PDF export of (multi-)selection a temporary //! document is created that contains only the selects parts, @@ -2958,7 +2942,7 @@ void SAL_CALL SwXTextDocument::render( if (bIsPDFExport && bFirstPage && pWrtShell) /*TLPDF*/ { - SwEnhancedPDFExportHelper aHelper( *pWrtShell, *pOut, aPages, bSkipEmptyPages, sal_False ); + SwEnhancedPDFExportHelper aHelper( *pWrtShell, *pOut, aPageRange, bIsSkipEmptyPages, sal_False ); } // <-- @@ -2976,7 +2960,7 @@ void SAL_CALL SwXTextDocument::render( // if (bIsPDFExport && bLastPage && pWrtShell) /*TLPDF*/ { - SwEnhancedPDFExportHelper aHelper( *pWrtShell, *pOut, aPages, bSkipEmptyPages, sal_True ); + SwEnhancedPDFExportHelper aHelper( *pWrtShell, *pOut, aPageRange, bIsSkipEmptyPages, sal_True ); } // <-- -- cgit From a6e4f39c82a75fb2684d3563b9c2a7af3518d2bc Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Fri, 14 Aug 2009 13:56:56 +0000 Subject: #i101242# new print UI --- sw/inc/IDocumentDeviceAccess.hxx | 2 +- sw/inc/doc.hxx | 9 +- sw/inc/printdata.hxx | 79 +++++++++++++++- sw/inc/swprtopt.hxx | 48 +--------- sw/inc/unomod.hxx | 2 +- sw/inc/unotxdoc.hxx | 9 +- sw/inc/viewsh.hxx | 36 +++++--- sw/source/core/doc/doc.cxx | 56 +++++------- sw/source/core/view/viewpg.cxx | 34 ++++--- sw/source/core/view/vprint.cxx | 189 +++++++++++++++++++++++++++------------ sw/source/ui/dbui/dbmgr.cxx | 90 +++++++++---------- sw/source/ui/inc/view.hxx | 2 +- sw/source/ui/uiview/viewprt.cxx | 44 ++++----- sw/source/ui/uno/unotxdoc.cxx | 131 ++++++++++++++------------- 14 files changed, 430 insertions(+), 301 deletions(-) (limited to 'sw') diff --git a/sw/inc/IDocumentDeviceAccess.hxx b/sw/inc/IDocumentDeviceAccess.hxx index 30e698e74d70..fbfdd82d001b 100755 --- a/sw/inc/IDocumentDeviceAccess.hxx +++ b/sw/inc/IDocumentDeviceAccess.hxx @@ -33,7 +33,7 @@ class SfxPrinter; class JobSetup; - struct SwPrintData; + class SwPrintData; class VirtualDevice; class OutputDevice; diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index 2b1937f2912e..d2ec00c8ad0c 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -208,7 +208,8 @@ struct SwDocStat; struct SwHash; struct SwSortOptions; struct SwDefTOXBase_Impl; -struct SwPrintData; +class SwPrintData; +class SwPrintUIOptions; class SdrPageView; struct SwConversionArgs; class SwRewriter; @@ -216,7 +217,7 @@ class SwMsgPoolItem; class SwChartDataProvider; class SwChartLockController_Helper; class IGrammarContact; -class SwPrintUIOptions; +class SwPrintData; class SwPageFrm; namespace sw { namespace mark { @@ -1335,9 +1336,9 @@ public: // get the set of printable pages for the XRenderable API by // evaluating the respective settings (see implementation) - void CalculatePagesForPrinting( bool bIsPDFExport, SwPrintUIOptions &rPrintUIOptions, + void CalculatePagesForPrinting( bool bIsPDFExport, SwPrintUIOptions &rOptions, sal_Int32 nDocPageCount ); - void CalculatePagePairsForProspectPrinting( SwPrintUIOptions &rPrintUIOptions, + void CalculatePagePairsForProspectPrinting( SwPrintUIOptions &rOptions, sal_Int32 nDocPageCount ); sal_uInt16 GetPageCount() const; diff --git a/sw/inc/printdata.hxx b/sw/inc/printdata.hxx index 1a6547ab540e..3ff07102733a 100644 --- a/sw/inc/printdata.hxx +++ b/sw/inc/printdata.hxx @@ -33,9 +33,75 @@ #include #include +#include -struct SwPrintData +#include +#include +#include +#include + +class SwPageFrm; + +//////////////////////////////////////////////////////////// + +class SwPrintUIOptions : public vcl::PrinterOptionsHelper +{ + OutputDevice* m_pLast; + + // pages valid for printing (according to the current settings) + // and their respective start frames (see getRendererCount in unotxdoc.cxx) + // This set of pages does NOT depend on the 'PageRange' that is used as a printing option! + std::set< sal_Int32 > aValidPages; // the set of possible pages (see StringRangeEnumerator::getRangesFromString ) + std::map< sal_Int32, const SwPageFrm * > aValidStartFrms; // the map of start frames for those pages + + // vector of pages and their order to be printed (duplicates and any order allowed!) + // (see 'render' in unotxdoc.cxx) + std::vector< sal_Int32 > aPagesToPrint; + + // for prospect printing: the pairs of pages to be printed together on a single prospect page. + // -1 indicates a half page to be left empty. + std::vector< std::pair< sal_Int32, sal_Int32 > > aPagePairs; + +public: + SwPrintUIOptions( BOOL bWeb = FALSE ); + ~SwPrintUIOptions(); + + bool processPropertiesAndCheckFormat( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& i_rNewProp ); + + typedef std::map< sal_Int32, const SwPageFrm * > ValidStartFramesMap_t; + typedef std::vector< std::pair< sal_Int32, sal_Int32 > > PagePairsVec_t; + + std::set< sal_Int32 > & GetValidPagesSet() { return aValidPages; } + const std::set< sal_Int32 > & GetValidPagesSet() const { return aValidPages; } + ValidStartFramesMap_t & GetValidStartFrms() { return aValidStartFrms; } + const ValidStartFramesMap_t & GetValidStartFrms() const { return aValidStartFrms; } + + // used for 'normal' printing + std::vector< sal_Int32 > & GetPagesToPrint() { return aPagesToPrint; } + const std::vector< sal_Int32 > & GetPagesToPrint() const { return aPagesToPrint; } + + // used for prospect printing only + PagePairsVec_t & GetPagePairsForProspectPrinting() { return aPagePairs; } + const PagePairsVec_t & GetPagePairsForProspectPrinting() const { return aPagePairs; } + + bool IsPrintLeftPages() const; + bool IsPrintRightPages() const; + bool IsPrintEmptyPages( bool bIsPDFExport ) const; + bool IsPrintTables() const; + bool IsPrintGraphics() const; + bool IsPrintDrawings() const; +}; + + +//////////////////////////////////////////////////////////// + + +class SwPrintData { + const SwPrintUIOptions * m_pPrintUIOptions; + +public: + sal_Bool bPrintGraphic, bPrintTable, bPrintDraw, bPrintControl, bPrintPageBackground, bPrintBlackFont, //#i81434# - printing of hidden text @@ -55,6 +121,8 @@ struct SwPrintData SwPrintData() { + m_pPrintUIOptions = NULL; + bPrintGraphic = bPrintTable = bPrintDraw = @@ -103,6 +171,12 @@ struct SwPrintData bPrintHiddenText == rData.bPrintHiddenText && bPrintTextPlaceholder == rData.bPrintTextPlaceholder; } + + // Note: int the conntext where this class ist used the pointer should always be valid + // during the lifetime of this object + const SwPrintUIOptions & GetPrintUIOptions() const { return *m_pPrintUIOptions; } + void SetPrintUIOptions( const SwPrintUIOptions *pOpt ) { m_pPrintUIOptions = pOpt; } + sal_Bool IsPrintGraphic() const { return bPrintGraphic; } sal_Bool IsPrintTable() const { return bPrintTable; } sal_Bool IsPrintDraw() const { return bPrintDraw; } @@ -139,8 +213,11 @@ struct SwPrintData void SetFaxName(const rtl::OUString& rSet){sFaxName = rSet;} void SetPrintHiddenText(sal_Bool b){ doSetModified(); bPrintHiddenText = b;} void SetPrintTextPlaceholder(sal_Bool b){ doSetModified(); bPrintTextPlaceholder = b;} + virtual void doSetModified () { bModified = sal_True;} }; +//////////////////////////////////////////////////////////// + #endif //_SW_PRINTDATA_HXX diff --git a/sw/inc/swprtopt.hxx b/sw/inc/swprtopt.hxx index 53b00bff4f07..86bcefa5d455 100644 --- a/sw/inc/swprtopt.hxx +++ b/sw/inc/swprtopt.hxx @@ -31,7 +31,6 @@ #ifndef _SWPRTOPT_HXX #define _SWPRTOPT_HXX -#include #include #include @@ -46,10 +45,9 @@ #define POSTITS_ENDPAGE 3 -class SwPageFrm; - //////////////////////////////////////////////////////////// + class SwPrtOptions : public SwPrintData { USHORT nJobNo; @@ -96,49 +94,5 @@ public: //////////////////////////////////////////////////////////// -class SwPrintUIOptions : public vcl::PrinterOptionsHelper -{ - OutputDevice* mpLast; - - // pages valid for printing (according to the current settings) - // and their respective start frames (see getRendererCount in unotxdoc.cxx) - // This set of pages does NOT depend on the 'PageRange' that is used as a printing option! - std::set< sal_Int32 > aValidPages; // the set of possible pages (see StringRangeEnumerator::getRangesFromString ) - std::map< sal_Int32, const SwPageFrm * > aValidStartFrms; // the map of start frames for those pages - - // vector of pages and their order to be printed (duplicates and any order allowed!) - // (see 'render' in unotxdoc.cxx) - std::vector< sal_Int32 > aPagesToPrint; - - // for prospect printing: the pairs of pages to be printed together on a single prospect page. - // -1 indicates a half page to be left empty. - std::vector< std::pair< sal_Int32, sal_Int32 > > aPagePairs; - -public: - SwPrintUIOptions( BOOL bWeb ); - - bool processPropertiesAndCheckFormat( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& i_rNewProp ); - - typedef std::map< sal_Int32, const SwPageFrm * > ValidStartFramesMap_t; - typedef std::vector< std::pair< sal_Int32, sal_Int32 > > PagePairsVec_t; - - std::set< sal_Int32 > & GetValidPagesSet() { return aValidPages; } - const std::set< sal_Int32 > & GetValidPagesSet() const { return aValidPages; } - ValidStartFramesMap_t & GetValidStartFrms() { return aValidStartFrms; } - const ValidStartFramesMap_t & GetValidStartFrms() const { return aValidStartFrms; } - - // used for 'normal' printing - std::vector< sal_Int32 > & GetPagesToPrint() { return aPagesToPrint; } - const std::vector< sal_Int32 > & GetPagesToPrint() const { return aPagesToPrint; } - - // used for prospect printing only - PagePairsVec_t & GetPagePairsForProspectPrinting() { return aPagePairs; } - const PagePairsVec_t & GetPagePairsForProspectPrinting() const { return aPagePairs; } - - bool IsPrintLeftPages() const; - bool IsPrintRightPages() const; -}; - - #endif //_SWPRTOPT_HXX diff --git a/sw/inc/unomod.hxx b/sw/inc/unomod.hxx index dcb2f9cfcbda..0f46a92f323e 100644 --- a/sw/inc/unomod.hxx +++ b/sw/inc/unomod.hxx @@ -45,7 +45,7 @@ class SwView; class SwViewOption; -struct SwPrintData; +class SwPrintData; class SwDoc; /****************************************************************************** diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx index 7b81a0ce191b..7292ce74fcff 100644 --- a/sw/inc/unotxdoc.hxx +++ b/sw/inc/unotxdoc.hxx @@ -127,6 +127,7 @@ class SwUnoCrsr; class SwXDocumentPropertyHelper; class SfxViewFrame; class SwPrintUIOptions; +class SwPrintData; typedef UnoActionContext* UnoActionContextPtr; SV_DECL_PTRARR(ActionContextArr, UnoActionContextPtr, 4, 4) @@ -216,11 +217,11 @@ class SwXTextDocument : public SwXTextDocumentBaseClass, css::uno::Reference< css::container::XNameContainer> xXFormsContainer; //temporary frame to enable PDF export if no valid view is available - SfxViewFrame* m_pHiddenViewFrame; - css::uno::Reference< css::uno::XInterface> xPropertyHelper; - SwXDocumentPropertyHelper* pPropertyHelper; + SfxViewFrame* m_pHiddenViewFrame; + css::uno::Reference< css::uno::XInterface> xPropertyHelper; + SwXDocumentPropertyHelper* pPropertyHelper; - SwPrintUIOptions* m_pPrintUIOptions; + SwPrintUIOptions* m_pPrintUIOprions; void GetBodyText(); void GetNumberFormatter(); diff --git a/sw/inc/viewsh.hxx b/sw/inc/viewsh.hxx index 007fc7c05ed3..9e4f89fb1134 100644 --- a/sw/inc/viewsh.hxx +++ b/sw/inc/viewsh.hxx @@ -71,7 +71,7 @@ class SfxViewShell; class SwViewOption; class SwViewImp; class SwPrtOptions; -class SwPrintUIOptions; +class SwPrintData; class SwPagePreViewPrtData; class Window; class OutputDevice; @@ -94,12 +94,19 @@ class SwPostItMgr; // #i74769# class SdrPaintWindow; +namespace vcl +{ + class PrinterController; +}; + + //JP 19.07.98: - Bug 52312 // define fuer Flags, die im CTOR oder den darunter liegenden Schichten // benoetigt werden. // Zur Zeit wird fuer die DrawPage das PreView Flag benoetigt #define VSHELLFLAG_ISPREVIEW ((long)0x1) + class SW_DLLPUBLIC ViewShell : public Ring { friend void SetOutDev( ViewShell *pSh, OutputDevice *pOut ); @@ -188,7 +195,7 @@ class SW_DLLPUBLIC ViewShell : public Ring SW_DLLPRIVATE void Scroll(); //Scrollen wenn sich aus der LayAction Scrollmoeglichkeiten //ergaben. - SW_DLLPRIVATE void PrepareForPrint( const SwPrtOptions &rOptions ); + SW_DLLPRIVATE void PrepareForPrint( const SwPrintData &rOptions ); SW_DLLPRIVATE void ImplApplyViewOptions( const SwViewOption &rOpt ); @@ -363,20 +370,27 @@ public: void ChgAllPageOrientation( sal_uInt16 eOri ); void ChgAllPageSize( Size &rSz ); - //Druckauftrag abwickeln. + // printing of one page. // bIsPDFExport == true is: do PDF Export (no printing!) - sal_Bool PrintOrPDFExport( OutputDevice* pOutDev, SwPrtOptions& rOptions, - const SwPrintUIOptions &rPrintUIOptions, + sal_Bool PrintOrPDFExport( OutputDevice *pOutDev, const SwPrtOptions &rPrintData, sal_Int32 nRenderer, /* offset in vector of pages to print */ bool bIsPDFExport = sal_False ); - // Prospekt-Format drucken - void PrintProspect( OutputDevice* pOutDev, SwPrtOptions& rOptions, - const SwPrintUIOptions &rPrintUIOptions, - sal_Int32 nRenderer /* offset in vector of page pairs for prospect */ ); + // printing of one brochure page + void PrintProspect( OutputDevice *pOutDev, const SwPrintData &rPrintData, + sal_Int32 nRenderer /* offset in vector of page pairs for prospect printing */ ); + + // printing of a complete document for mail merge + // bIsPDFExport == true is: do PDF Export (no printing!) + sal_Bool PrintOrPDFExportMM( const boost::shared_ptr< vcl::PrinterController > & rpPrinterController, + const SwPrtOptions &rPrintData, bool bIsPDFExport = sal_False ); + + // printing of a complete brochure for mail merge + void PrintProspectMM( const boost::shared_ptr< vcl::PrinterController > & rpPrinterController, + const SwPrintData &rPrintData, bool bProspectRTL ); - //"Drucken" fuer OLE 2.0 - static void PrtOle2( SwDoc *pDoc, const SwViewOption *pOpt, SwPrtOptions& rOptions, + // printing for OLE 2.0 + static void PrtOle2( SwDoc *pDoc, const SwViewOption *pOpt, const SwPrintData& rOptions, OutputDevice* pOleOut, const Rectangle& rRect ); // creates temporary doc with selected text for PDF export diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index e480138a8ca6..ca02f3e2eb30 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -993,7 +993,7 @@ const SwDocStat& SwDoc::GetDocStat() const void SwDoc::CalculatePagesForPrinting( bool bIsPDFExport, - SwPrintUIOptions &rPrintUIOptions, + SwPrintUIOptions &rOptions, sal_Int32 nDocPageCount ) { DBG_ASSERT( pLayout, "no layout present" ); @@ -1001,22 +1001,12 @@ void SwDoc::CalculatePagesForPrinting( return; // properties to take into account when calcualting the set of pages - bool bPrintLeftPage = rPrintUIOptions.IsPrintLeftPages(); - bool bPrintRightPage = rPrintUIOptions.IsPrintRightPages(); + // (PDF export UI does not allow for selecting left or right pages only) + bool bPrintLeftPages = bIsPDFExport ? true : rOptions.IsPrintLeftPages(); + bool bPrintRightPages = bIsPDFExport ? true : rOptions.IsPrintRightPages(); // TLPDF, TODO: remove bPrintReverse, should be handled by PLs framework now -//TLPDF bool bPrintReverse = rPrintUIOptions.getBoolValue( C2U( "PrintReverseOrder" ), false ); - bool bPrintEmptyPages = rPrintUIOptions.getBoolValue( "PrintEmptyPages", false ); - - if (bIsPDFExport) - { - // PDF export UI does not allow for selecting left or right pages only or reverse print - bPrintLeftPage = true; - bPrintRightPage = true; -// bPrintReverse = false; - // TLPDF, TODO; take care of the option 'Export automatically inserted blank pages' - // from the 'Export as PDF' (aka PDF Options) dialog. - bPrintEmptyPages = false; - } +//TLPDF bool bPrintReverse = rOptions.getBoolValue( C2U( "PrintReverseOrder" ), false ); + bool bPrintEmptyPages = rOptions.IsPrintEmptyPages( bIsPDFExport ); Range aPages( 1, nDocPageCount ); @@ -1088,16 +1078,16 @@ void SwDoc::CalculatePagesForPrinting( #endif // TL_NOT_NOW /*TLPDF*/ nPageNo = nFirstPageNo; - std::set< sal_Int32 > &rValidPages = rPrintUIOptions.GetValidPagesSet(); - std::map< sal_Int32, const SwPageFrm * > &rValidStartFrms = rPrintUIOptions.GetValidStartFrms(); + std::set< sal_Int32 > &rValidPages = rOptions.GetValidPagesSet(); + std::map< sal_Int32, const SwPageFrm * > &rValidStartFrms = rOptions.GetValidStartFrms(); rValidPages.clear(); rValidStartFrms.clear(); while ( pStPage ) { const BOOL bRightPg = pStPage->OnRightPage(); if ( aMulti.IsSelected( nPageNo ) && - ( (bRightPg && bPrintRightPage) || - (!bRightPg && bPrintLeftPage) ) ) + ( (bRightPg && bPrintRightPages) || + (!bRightPg && bPrintLeftPages) ) ) { // --> FME 2005-12-12 #b6354161# Feature - Print empty pages if ( bPrintEmptyPages || pStPage->Frm().Height() ) @@ -1130,18 +1120,18 @@ void SwDoc::CalculatePagesForPrinting( void SwDoc::CalculatePagePairsForProspectPrinting( - SwPrintUIOptions &rPrintUIOptions, + SwPrintUIOptions &rOptions, sal_Int32 nDocPageCount ) { - std::set< sal_Int32 > &rValidPagesSet = rPrintUIOptions.GetValidPagesSet(); - std::map< sal_Int32, const SwPageFrm * > &rValidStartFrms = rPrintUIOptions.GetValidStartFrms(); - std::vector< std::pair< sal_Int32, sal_Int32 > > &rPagePairs = rPrintUIOptions.GetPagePairsForProspectPrinting(); + std::set< sal_Int32 > &rValidPagesSet = rOptions.GetValidPagesSet(); + std::map< sal_Int32, const SwPageFrm * > &rValidStartFrms = rOptions.GetValidStartFrms(); + std::vector< std::pair< sal_Int32, sal_Int32 > > &rPagePairs = rOptions.GetPagePairsForProspectPrinting(); rPagePairs.clear(); rValidPagesSet.clear(); rValidStartFrms.clear(); - rtl::OUString aPageRange = rPrintUIOptions.getStringValue( "PageRange", rtl::OUString() ); + rtl::OUString aPageRange = rOptions.getStringValue( "PageRange", rtl::OUString() ); StringRangeEnumerator aRange( aPageRange, 1, nDocPageCount, 0 ); DBG_ASSERT( pLayout, "no layout present" ); @@ -1170,14 +1160,14 @@ void SwDoc::CalculatePagePairsForProspectPrinting( DBG_ASSERT( nPageNum == nDocPageCount, "unexpected number of pages" ); // properties to take into account when calcualting the set of pages - // Note: here bPrintLeftPage and bPrintRightPage refer to the (virtual) resulting pages + // Note: here bPrintLeftPages and bPrintRightPages refer to the (virtual) resulting pages // of the prospect! - bool bPrintLeftPage = rPrintUIOptions.IsPrintLeftPages(); - bool bPrintRightPage = rPrintUIOptions.IsPrintRightPages(); + bool bPrintLeftPages = rOptions.IsPrintLeftPages(); + bool bPrintRightPages = rOptions.IsPrintRightPages(); // TLPDF, TODO: remove bPrintReverse, should be handled by PLs framework now -//TLPDF bool bPrintReverse = rPrintUIOptions.getBoolValue( C2U( "PrintReverseOrder" ), false ); - // TLPDF: this one seems not to be used in prospect printing: bool bPrintEmptyPages = rPrintUIOptions.getBoolValue( C2U( "PrintEmptyPages" ), false ); - bool bPrintProspect_RTL = rPrintUIOptions.getIntValue( "PrintBrochureRTL", 0 ) ? true : false; +//TLPDF bool bPrintReverse = rOptions.getBoolValue( C2U( "PrintReverseOrder" ), false ); + // TLPDF: this one seems not to be used in prospect printing: bool bPrintEmptyPages = rOptions.getBoolValue( C2U( "PrintEmptyPages" ), false ); + bool bPrintProspect_RTL = rOptions.getIntValue( "PrintBrochureRTL", 0 ) ? true : false; // get pages for prospect printing according to the 'PageRange' // (duplicates and any order allowed!) @@ -1247,9 +1237,9 @@ void SwDoc::CalculatePagePairsForProspectPrinting( if ( 0 == (nEPg & 1 )) // ungerade gibt es nicht! --nEPg; - if ( !bPrintLeftPage ) + if ( !bPrintLeftPages ) ++nStep; - else if ( !bPrintRightPage ) + else if ( !bPrintRightPages ) { ++nStep; ++nSPg, --nEPg; diff --git a/sw/source/core/view/viewpg.cxx b/sw/source/core/view/viewpg.cxx index 283e6b6a79f2..fbcae6776d82 100644 --- a/sw/source/core/view/viewpg.cxx +++ b/sw/source/core/view/viewpg.cxx @@ -447,18 +447,30 @@ void ViewShell::PrintPreViewPage( SwPrtOptions& rOptions, pFntCache->Flush(); } + +void ViewShell::PrintProspectMM( + const boost::shared_ptr< vcl::PrinterController > & rpPrinterController, + const SwPrintData & rPrintData, + bool bProspectRTL ) +{ + (void) rpPrinterController; (void) rPrintData; (void) bProspectRTL; + + Printer::PrintJob( rpPrinterController, JobSetup() ); +} + + // print brochure // OD 05.05.2003 #i14016# - consider empty pages on calculation of the scaling // for a page to be printed. void ViewShell::PrintProspect( OutputDevice* pOutDev, - SwPrtOptions& rOptions, - const SwPrintUIOptions & rPrintUIOptions, /* TLPDF keep this or the above? */ - sal_Int32 nRenderer ) + const SwPrintData & rPrintData, + sal_Int32 nRenderer // the index in the vector of prospect pages to be printed + ) { // TLPDF if( !rOptions.aMulti.GetSelectCount() ) Printer *pPrinter = dynamic_cast< Printer * >(pOutDev); - if (!pPrinter || rPrintUIOptions.GetPagePairsForProspectPrinting().size() <= 0) + if (!pPrinter || rPrintData.GetPrintUIOptions().GetPagePairsForProspectPrinting().size() <= 0) return; #ifdef TL_NOT_NOW /*TLPDF*/ @@ -475,15 +487,15 @@ void ViewShell::PrintProspect( /* TLPDF neu: start */ #if OSL_DEBUG_LEVEL > 1 - DBG_ASSERT( 0 <= nRenderer && nRenderer < (sal_Int32)rPrintUIOptions.GetPagePairsForProspectPrinting().size(), "nRenderer out of bounds"); + DBG_ASSERT( 0 <= nRenderer && nRenderer < (sal_Int32)rPrintData.GetPrintUIOptions().GetPagePairsForProspectPrinting().size(), "nRenderer out of bounds"); #endif std::pair< sal_Int32, sal_Int32 > rPagesToPrint = - rPrintUIOptions.GetPagePairsForProspectPrinting()[ nRenderer ]; + rPrintData.GetPrintUIOptions().GetPagePairsForProspectPrinting()[ nRenderer ]; const USHORT nPageMax = static_cast< USHORT >(rPagesToPrint.first > rPagesToPrint.second ? rPagesToPrint.first : rPagesToPrint.second); #if OSL_DEBUG_LEVEL > 1 - DBG_ASSERT( rPagesToPrint.first == -1 || rPrintUIOptions.GetValidPagesSet().count( rPagesToPrint.first ) == 1, "first Page not valid" ); - DBG_ASSERT( rPagesToPrint.second == -1 || rPrintUIOptions.GetValidPagesSet().count( rPagesToPrint.second ) == 1, "second Page not valid" ); + DBG_ASSERT( rPagesToPrint.first == -1 || rPrintData.GetPrintUIOptions().GetValidPagesSet().count( rPagesToPrint.first ) == 1, "first Page not valid" ); + DBG_ASSERT( rPagesToPrint.second == -1 || rPrintData.GetPrintUIOptions().GetValidPagesSet().count( rPagesToPrint.second ) == 1, "second Page not valid" ); #endif /* TLPDF neu: end */ @@ -509,7 +521,7 @@ void ViewShell::PrintProspect( SET_CURR_SHELL( &aShell ); - aShell.PrepareForPrint( rOptions ); + aShell.PrepareForPrint( rPrintData ); // gibt es versteckte Absatzfelder, unnoetig wenn die Absaetze bereits // ausgeblendet sind. @@ -541,7 +553,7 @@ void ViewShell::PrintProspect( #ifdef TL_NOT_NOW /*TLPDF*/ should not happen any more since the test - rPrintUIOptions.GetPagePairsForProspectPrinting().size() <= 0 + rPrintData.GetPagePairsForProspectPrinting().size() <= 0 above should have taken care that there is at least one page to print if( !pStPage ) // dann wars das { @@ -680,7 +692,7 @@ void ViewShell::PrintProspect( /* TLPDF neu: start */ const SwPageFrm *pStPage = 0; const SwPageFrm *pNxtPage = 0; - const SwPrintUIOptions::ValidStartFramesMap_t &rFrms = rPrintUIOptions.GetValidStartFrms(); + const SwPrintUIOptions::ValidStartFramesMap_t &rFrms = rPrintData.GetPrintUIOptions().GetValidStartFrms(); if (rPagesToPrint.first > 0) { SwPrintUIOptions::ValidStartFramesMap_t::const_iterator aIt( rFrms.find( rPagesToPrint.first ) ); diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index a1878283cf01..23cf28e938ea 100644 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -230,7 +230,7 @@ const XubString& SwPrtOptions::MakeNextJobName() /*****************************************************************************/ SwPrintUIOptions::SwPrintUIOptions( BOOL bWeb ) : - mpLast( NULL ) + m_pLast( NULL ) { ResStringArray aLocalizedStrings( SW_RES( STR_PRINTOPTUI ) ); @@ -257,13 +257,13 @@ SwPrintUIOptions::SwPrintUIOptions( BOOL bWeb ) : // create a bool option for background m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 2 ), aLocalizedStrings.GetString( 3 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintBackground" ) ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintPageBackground" ) ), sal_True ); // create a bool option for graphics m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 4 ), aLocalizedStrings.GetString( 5 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintGraphicsAndDiagrams" ) ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintTablesGraphicsAndDiagrams" ) ), sal_True ); if (!bWeb) { @@ -276,7 +276,7 @@ SwPrintUIOptions::SwPrintUIOptions( BOOL bWeb ) : // create a bool option for place holder m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 8 ), aLocalizedStrings.GetString( 9 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintPlaceholder" ) ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintTextPlaceholder" ) ), sal_False ); } @@ -292,7 +292,7 @@ SwPrintUIOptions::SwPrintUIOptions( BOOL bWeb ) : // create a bool option for black m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 13 ), aLocalizedStrings.GetString( 14 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintBlack" ) ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintBlackFonts" ) ), sal_False ); // create subgroup for misc options @@ -309,7 +309,7 @@ SwPrintUIOptions::SwPrintUIOptions( BOOL bWeb ) : aPaperTrayOpt.maGroupHint = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OptionsPageOptGroup" ) ); m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 18 ), aLocalizedStrings.GetString( 19 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PaperTray" ) ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintPaperFromSetup" ) ), sal_False, aPaperTrayOpt ); @@ -332,7 +332,7 @@ SwPrintUIOptions::SwPrintUIOptions( BOOL bWeb ) : aHelpText[1] = aLocalizedStrings.GetString( 25 ); m_aUIProperties[ nIdx++ ].Value = getChoiceControlOpt( aLocalizedStrings.GetString( 26 ), aHelpText, - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintNotes" ) ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintAnnotationMode" ) ), aChoices, 0, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "List" ) ) @@ -363,7 +363,7 @@ SwPrintUIOptions::SwPrintUIOptions( BOOL bWeb ) : } // create a bool option for brochure - rtl::OUString aBrochurePropertyName( RTL_CONSTASCII_USTRINGPARAM( "PrintBrochure" ) ); + rtl::OUString aBrochurePropertyName( RTL_CONSTASCII_USTRINGPARAM( "PrintProspect" ) ); m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 33 ), aLocalizedStrings.GetString( 34 ), aBrochurePropertyName, @@ -379,7 +379,7 @@ SwPrintUIOptions::SwPrintUIOptions( BOOL bWeb ) : aBrochureRTLOpt.maGroupHint = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutPage" ) ); m_aUIProperties[ nIdx++ ].Value = getChoiceControlOpt( rtl::OUString(), uno::Sequence< rtl::OUString >(), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintBrochureRTL" ) ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintProspectRTL" ) ), aBRTLChoices, 0, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "List" ) ), aBrochureRTLOpt ); @@ -417,22 +417,79 @@ SwPrintUIOptions::SwPrintUIOptions( BOOL bWeb ) : aPageRangeOpt ); - DBG_ASSERT( nIdx == nNumProps, "number of added properties is not as expected" ); } + +SwPrintUIOptions::~SwPrintUIOptions() +{ +} + bool SwPrintUIOptions::IsPrintLeftPages() const { - sal_Int64 nLRPages = getIntValue( "PrintLeftRightPages", 0 ); - return nLRPages == 0 || nLRPages == 1; + // take care of different property names for the option. + // for compatibility the old name should win + + // 0: left and right pages + // 1: left pages only + // 2: right pages only + sal_Int64 nLRPages = getIntValue( "PrintLeftRightPages", 0 /* default: all */ ); + bool bRes = nLRPages == 0 || nLRPages == 1; + bRes = getBoolValue( "PrintLeftPages", bRes /* <- default value if property is not found */ ); + return bRes; } bool SwPrintUIOptions::IsPrintRightPages() const { - sal_Int64 nLRPages = getIntValue( "PrintLeftRightPages", 0 ); - return nLRPages == 0 || nLRPages == 2; + // take care of different property names for the option. + // for compatibility the old name should win + + sal_Int64 nLRPages = getIntValue( "PrintLeftRightPages", 0 /* default: all */ ); + bool bRes = nLRPages == 0 || nLRPages == 2; + bRes = getBoolValue( "PrintRightPages", bRes /* <- default value if property is not found */ ); + return bRes; } +bool SwPrintUIOptions::IsPrintEmptyPages( bool bIsPDFExport ) const +{ + // take care of different property names for the option. + + bool bRes = bIsPDFExport ? + !getBoolValue( "IsSkipEmptyPages", sal_True ) : + getBoolValue( "PrintEmptyPages", sal_True ); + return bRes; +} + +bool SwPrintUIOptions::IsPrintTables() const +{ + // take care of different property names for the option. + // for compatibility the old name should win + + bool bRes = getBoolValue( "PrintTablesGraphicsAndDiagrams", sal_True ); + bRes = getBoolValue( "PrintTables", bRes ); + return bRes; +} + +bool SwPrintUIOptions::IsPrintGraphics() const +{ + // take care of different property names for the option. + // for compatibility the old name should win + + bool bRes = getBoolValue( "PrintTablesGraphicsAndDiagrams", sal_True ); + bRes = getBoolValue( "PrintGraphics", bRes ); + return bRes; +} + +bool SwPrintUIOptions::IsPrintDrawings() const +{ + // take care of different property names for the option. + // for compatibility the old name should win + + bool bRes = getBoolValue( "PrintTablesGraphicsAndDiagrams", sal_True ); + bRes = getBoolValue( "PrintDDrawings", bRes ); + return bRes; +} + bool SwPrintUIOptions::processPropertiesAndCheckFormat( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& i_rNewProp ) { bool bChanged = processProperties( i_rNewProp ); @@ -447,9 +504,9 @@ bool SwPrintUIOptions::processPropertiesAndCheckFormat( const com::sun::star::un VCLXDevice* pDevice = VCLXDevice::GetImplementation( xRenderDevice ); pOut = pDevice ? pDevice->GetOutputDevice() : 0; } - bChanged = bChanged || (pOut != mpLast); + bChanged = bChanged || (pOut != m_pLast); if( pOut ) - mpLast = pOut; + m_pLast = pOut; return bChanged; } @@ -938,6 +995,9 @@ void ViewShell::CalcPagesForPrint( USHORT nMax, SfxProgress* pProgress, const SwFrm *pPage = pLayout->Lower(); SwLayAction aAction( pLayout, Imp() ); +#ifdef TL_NOT_NOW /*TLPDF*/ +//Currently we have no progress bar here. It is handled in the new Print UI now. +//Not year clear: what about Progressbar in MailMerge if( pProgress ) { // HACK, damit die Anzeige sich nicht verschluckt. @@ -947,6 +1007,7 @@ void ViewShell::CalcPagesForPrint( USHORT nMax, SfxProgress* pProgress, pProgress->Reschedule(); //Mag der Anwender noch oder hat er genug? aAction.SetProgress(pProgress); } +#endif // TL_NOT_NOW /*TLPDF*/ pLayout->StartAllAction(); for ( USHORT i = 1; pPage && i <= nMax; pPage = pPage->GetNext(), ++i ) @@ -954,6 +1015,7 @@ void ViewShell::CalcPagesForPrint( USHORT nMax, SfxProgress* pProgress, if ( ( bPrtJob && !pPrt->IsJobActive() ) || Imp()->IsStopPrt() ) break; +#ifdef TL_NOT_NOW /*TLPDF*/ if( pProgress ) { //HACK, damit die Anzeige sich nicht verschluckt. @@ -961,6 +1023,7 @@ void ViewShell::CalcPagesForPrint( USHORT nMax, SfxProgress* pProgress, lcl_SetState( *pProgress, i, nStatMax, pStr, nMergeAct, nMergeCnt, 0, i ); pProgress->Reschedule(); //Mag der Anwender noch oder hat er genug? } +#endif // TL_NOT_NOW /*TLPDF*/ if ( ( bPrtJob && !pPrt->IsJobActive() ) || Imp()->IsStopPrt() ) break; @@ -980,8 +1043,10 @@ void ViewShell::CalcPagesForPrint( USHORT nMax, SfxProgress* pProgress, Imp()->SetFirstVisPageInvalid(); SwPaintQueue::Repaint(); +#ifdef TL_NOT_NOW /*TLPDF*/ if ( pProgress ) pProgress->Reschedule(); //Mag der Anwender noch oder hat er genug? +#endif // TL_NOT_NOW /*TLPDF*/ } if (pProgress) @@ -1175,11 +1240,23 @@ SwDoc * ViewShell::FillPrtDoc( SwDoc *pPrtDoc, const SfxPrinter* pPrt) } +sal_Bool ViewShell::PrintOrPDFExportMM( + const boost::shared_ptr< vcl::PrinterController > & rpPrinterController, + const SwPrtOptions &rPrintData, /* TLPDF can't we make use of just SwPrintData only as it is the case in PrintProspect??? */ + bool bIsPDFExport ) +{ + (void) rpPrinterController; (void) rPrintData; (void) bIsPDFExport; + + + Printer::PrintJob( rpPrinterController, JobSetup() ); + return sal_True; +} + + sal_Bool ViewShell::PrintOrPDFExport( OutputDevice* pOutDev, - SwPrtOptions& rOptions, - const SwPrintUIOptions &rPrintUIOptions, /* TLPDF keep this or the above? */ - sal_Int32 nRenderer, + const SwPrtOptions &rPrintData, /* TLPDF can't we make use of just SwPrintData only as it is the case in PrintProspect??? */ + sal_Int32 nRenderer, // the index in the vector of pages to be printed bool bIsPDFExport ) { //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -1190,11 +1267,11 @@ sal_Bool ViewShell::PrintOrPDFExport( //! Note: Since for PDF export of (multi-)selection a temporary //! document is created that contains only the selects parts, //! and thus that document is to printed in whole the, - //! rOptions.bPrintSelection parameter will be false. - BOOL bSelection = rOptions.bPrintSelection; + //! rPrintData.bPrintSelection parameter will be false. + BOOL bSelection = rPrintData.bPrintSelection; // TLPDF: this one should hold just one page now. Thus clean-up should be possible - MultiSelection aMulti( rOptions.aMulti ); + MultiSelection aMulti( rPrintData.aMulti ); if ( !pOutDev || !aMulti.GetSelectCount() ) return bStartJob; @@ -1270,21 +1347,21 @@ sal_Bool ViewShell::PrintOrPDFExport( // save options at draw view: SwDrawViewSave aDrawViewSave( pShell->GetDrawView() ); - pShell->PrepareForPrint( rOptions ); + pShell->PrepareForPrint( rPrintData ); XubString* pStr = 0; - ULONG nMergeAct = rOptions.nMergeAct, nMergeCnt = rOptions.nMergeCnt; +//TLPDF ULONG nMergeAct = rPrintData.nMergeAct, nMergeCnt = rPrintData.nMergeCnt; /* TLPDF neu: start */ #if OSL_DEBUG_LEVEL > 1 - DBG_ASSERT( 0 <= nRenderer && nRenderer < (sal_Int32)rPrintUIOptions.GetPagesToPrint().size(), "nRenderer out of bounds"); + DBG_ASSERT( 0 <= nRenderer && nRenderer < (sal_Int32)rPrintData.GetPrintUIOptions().GetPagesToPrint().size(), "nRenderer out of bounds"); #endif - const sal_Int32 nPage = rPrintUIOptions.GetPagesToPrint()[ nRenderer ]; /* TLPDF */ + const sal_Int32 nPage = rPrintData.GetPrintUIOptions().GetPagesToPrint()[ nRenderer ]; /* TLPDF */ #if OSL_DEBUG_LEVEL > 1 - DBG_ASSERT( rPrintUIOptions.GetValidPagesSet().count( nPage ) == 1, "nPage not valid" ); + DBG_ASSERT( rPrintData.GetPrintUIOptions().GetValidPagesSet().count( nPage ) == 1, "nPage not valid" ); #endif - const SwPrintUIOptions::ValidStartFramesMap_t &rFrms = rPrintUIOptions.GetValidStartFrms(); + const SwPrintUIOptions::ValidStartFramesMap_t &rFrms = rPrintData.GetPrintUIOptions().GetValidStartFrms(); SwPrintUIOptions::ValidStartFramesMap_t::const_iterator aIt( rFrms.find( nPage ) ); DBG_ASSERT( aIt != rFrms.end(), "failed to find start frame" ); const SwPageFrm *pStPage = aIt->second; @@ -1293,7 +1370,7 @@ sal_Bool ViewShell::PrintOrPDFExport( // ben�tigte Seiten fuers Drucken formatieren pShell->CalcPagesForPrint( (USHORT)nPage, 0 /*TLPDF*/, pStr, - nMergeAct, nMergeCnt ); + 0, 0 /* TLPDF, there is no progressbar right now nMergeAct, nMergeCnt */ ); // Some field types, can require a valid layout // (expression fields in tables). For these we do an UpdateFlds @@ -1301,19 +1378,19 @@ sal_Bool ViewShell::PrintOrPDFExport( // --> FME 2004-06-21 #i9684# For performance reasons, we do not update // the fields during pdf export. // #i56195# prevent update of fields (for mail merge) - if ( !bIsPDFExport && rOptions.bUpdateFieldsInPrinting ) + if ( !bIsPDFExport && rPrintData.bUpdateFieldsInPrinting ) // <-- pShell->UpdateFlds(TRUE); // TLPDF if( !pShell->Imp()->IsStopOutDev() && -// TLPDF ( bIsPDFExport || rOptions.GetJobName().Len() || pOutDev->IsJobActive()) ) +// TLPDF ( bIsPDFExport || rPrintData.GetJobName().Len() || pOutDev->IsJobActive()) ) if( /*!pShell->Imp()->IsStopOutDev() && */ - ( bIsPDFExport || rOptions.GetJobName().Len() /*TLPDF|| pOutDev->IsJobActive()*/) ) + ( bIsPDFExport || rPrintData.GetJobName().Len() /*TLPDF|| pOutDev->IsJobActive()*/) ) { BOOL bStop = FALSE; int nJobStartError = JOBSET_ERR_DEFAULT; - XubString sJobName( rOptions.GetJobName() ); + XubString sJobName( rPrintData.GetJobName() ); // HACK: Hier muss von der MultiSelection noch eine akzeptable Moeglichkeit // geschaffen werden, alle Seiten von Seite x an zu deselektieren. @@ -1342,7 +1419,7 @@ sal_Bool ViewShell::PrintOrPDFExport( _SetGetExpFlds aPostItFields; SwDoc* pPostItDoc = 0; ViewShell* pPostItShell = 0; - if( rOptions.nPrintPostIts != POSTITS_NONE ) + if( rPrintData.nPrintPostIts != POSTITS_NONE ) { lcl_GetPostIts( pDoc, aPostItFields ); pPostItDoc = new SwDoc; @@ -1354,11 +1431,11 @@ sal_Bool ViewShell::PrintOrPDFExport( pShell->GetViewOptions() ); // Wenn PostIts am Dokumentenende gedruckt werden sollen, // die Druckreihenfolge allerdings umgekehrt ist, dann hier - if ( ( rOptions.nPrintPostIts == POSTITS_ENDDOC ) && - rOptions.bPrintReverse ) + if ( ( rPrintData.nPrintPostIts == POSTITS_ENDDOC ) && + rPrintData.bPrintReverse ) lcl_PrintPostItsEndDoc( pPostItShell, aPostItFields, aMulti, sJobName, bStartJob, nJobStartError, - rOptions.bPrintRightPage, rOptions.bPrintLeftPage, TRUE ); + rPrintData.bPrintRightPage, rPrintData.bPrintLeftPage, TRUE ); } @@ -1370,7 +1447,7 @@ sal_Bool ViewShell::PrintOrPDFExport( // BOOL bSetPaperSz = FALSE; BOOL bSetPrt = FALSE; - if ( rOptions.nPrintPostIts != POSTITS_ONLY ) + if ( rPrintData.nPrintPostIts != POSTITS_ONLY ) { //TLPDF while( pStPage && !bStop ) { @@ -1381,7 +1458,7 @@ sal_Bool ViewShell::PrintOrPDFExport( { aOldMapMode = pOutDev->GetMapMode(); Point aNewOrigin = pOutDev->GetMapMode().GetOrigin(); - aNewOrigin += rOptions.aOffset; + aNewOrigin += rPrintData.aOffset; MapMode aTmp( pOutDev->GetMapMode() ); aTmp.SetOrigin( aNewOrigin ); pOutDev->SetMapMode( aTmp ); @@ -1437,12 +1514,12 @@ sal_Bool ViewShell::PrintOrPDFExport( // Wenn PostIts nach Seite gedruckt werden sollen, // jedoch Reverse eingestellt ist ... - if( rOptions.bPrintReverse && - rOptions.nPrintPostIts == POSTITS_ENDPAGE ) + if( rPrintData.bPrintReverse && + rPrintData.nPrintPostIts == POSTITS_ENDPAGE ) lcl_PrintPostItsEndPage( pPostItShell, aPostItFields, nPage /* TLPDF nPageNo*/, aMulti, sJobName, bStartJob, nJobStartError, - rOptions.bPrintRightPage, rOptions.bPrintLeftPage, - rOptions.bPrintReverse ); + rPrintData.bPrintRightPage, rPrintData.bPrintLeftPage, + rPrintData.bPrintReverse ); if( !bStartJob && JOBSET_ERR_DEFAULT == nJobStartError @@ -1456,7 +1533,7 @@ sal_Bool ViewShell::PrintOrPDFExport( nJobStartError = JOBSET_ERR_ISSTARTET; } // --> FME 2005-12-12 #b6354161# Feature - Print empty pages -// TLPDF if ( rOptions.bPrintEmptyPages || pStPage->Frm().Height() ) +// TLPDF if ( rPrintData.bPrintEmptyPages || pStPage->Frm().Height() ) // <-- { pStPage->GetUpper()->Paint( pStPage->Frm() ); @@ -1464,12 +1541,12 @@ sal_Bool ViewShell::PrintOrPDFExport( SwPaintQueue::Repaint(); // Wenn PostIts nach Seite gedruckt werden sollen ... - if( (!rOptions.bPrintReverse) && - rOptions.nPrintPostIts == POSTITS_ENDPAGE ) + if( (!rPrintData.bPrintReverse) && + rPrintData.nPrintPostIts == POSTITS_ENDPAGE ) lcl_PrintPostItsEndPage( pPostItShell, aPostItFields, nPage /* TLPDF nPageNo */, aMulti, sJobName, bStartJob, nJobStartError, - rOptions.bPrintRightPage, rOptions.bPrintLeftPage, - rOptions.bPrintReverse ); + rPrintData.bPrintRightPage, rPrintData.bPrintLeftPage, + rPrintData.bPrintReverse ); } // den eventl. fuer Umschlaege modifizierte OutDevOffset wieder @@ -1483,12 +1560,12 @@ sal_Bool ViewShell::PrintOrPDFExport( if (!bStop) // TLPDF: see break above { // Wenn PostIts am Dokumentenende gedruckt werden sollen, dann hier machen - if( ((rOptions.nPrintPostIts == POSTITS_ENDDOC) && !rOptions.bPrintReverse) - || (rOptions.nPrintPostIts == POSTITS_ONLY) ) + if( ((rPrintData.nPrintPostIts == POSTITS_ENDDOC) && !rPrintData.bPrintReverse) + || (rPrintData.nPrintPostIts == POSTITS_ONLY) ) lcl_PrintPostItsEndDoc( pPostItShell, aPostItFields, aMulti, sJobName, bStartJob, nJobStartError, - rOptions.bPrintRightPage, rOptions.bPrintLeftPage, - rOptions.bPrintReverse ); + rPrintData.bPrintRightPage, rPrintData.bPrintLeftPage, + rPrintData.bPrintReverse ); if( pPostItShell ) { @@ -1496,8 +1573,8 @@ sal_Bool ViewShell::PrintOrPDFExport( delete pPostItShell; //Nimmt das PostItDoc mit ins Grab. } - if( bStartJob ) - rOptions.bJobStartet = TRUE; +//TLPDF if( bStartJob ) +//TLPDF rPrintData.bJobStartet = TRUE; } // TLPDF: if (!bStop) see break above } @@ -1532,7 +1609,7 @@ sal_Bool ViewShell::PrintOrPDFExport( -void ViewShell::PrtOle2( SwDoc *pDoc, const SwViewOption *pOpt, SwPrtOptions& rOptions, +void ViewShell::PrtOle2( SwDoc *pDoc, const SwViewOption *pOpt, const SwPrintData& rOptions, OutputDevice* pOleOut, const Rectangle& rRect ) { //Wir brauchen eine Shell fuer das Drucken. Entweder hat das Doc schon @@ -1679,7 +1756,7 @@ SwDrawViewSave::~SwDrawViewSave() // OD 09.01.2003 #i6467# - method also called for page preview -void ViewShell::PrepareForPrint( const SwPrtOptions &rOptions ) +void ViewShell::PrepareForPrint( const SwPrintData &rOptions ) { // Viewoptions fuer den Drucker setzen pOpt->SetGraphic ( TRUE == rOptions.bPrintGraphic ); diff --git a/sw/source/ui/dbui/dbmgr.cxx b/sw/source/ui/dbui/dbmgr.cxx index 97d882c3a8e1..e53f5d766427 100644 --- a/sw/source/ui/dbui/dbmgr.cxx +++ b/sw/source/ui/dbui/dbmgr.cxx @@ -79,7 +79,8 @@ #include #include #include -#include +#include +//#include #include #include #include @@ -877,11 +878,11 @@ SwNewDBMgr::~SwNewDBMgr() --------------------------------------------------------------------*/ -BOOL SwNewDBMgr::MergePrint( SwView& rView, - SwPrtOptions& rOpt, SfxProgress& rProgress, BOOL bIsAPI ) +BOOL SwNewDBMgr::MergePrint( SwView& /*rView*/, + SwPrtOptions& /*rOpt*/, SfxProgress& /*rProgress*/, BOOL /*bIsAPI*/ ) { - (void) rView; (void) rOpt; (void) rProgress; (void) bIsAPI; /* TLPDF */ -#ifdef TL_NOT_NOW /*TLPDF*/ //!! Currently broken beyond repair since we will not have a printer + return TRUE; +#ifdef TL_NOT_NOW /*TLPDF*/ SwWrtShell* pSh = &rView.GetWrtShell(); //check if the doc is synchronized and contains at least one linked section BOOL bSynchronizedDoc = pSh->IsLabelDoc() && pSh->GetSectionFmtCount() > 1; @@ -904,12 +905,12 @@ BOOL SwNewDBMgr::MergePrint( SwView& rView, SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig(); pModOpt->SetSinglePrintJob(rOpt.IsPrintSingleJobs()); - SfxPrinter *pPrt = pSh->getIDocumentDeviceAccess()->getPrinter( false ); -#ifdef TL_NOT_NOW /*TLPDF*/ - Link aSfxSaveLnk = pPrt->GetEndPrintHdl(); - if( rOpt.IsPrintSingleJobs() ) - pPrt->SetEndPrintHdl( Link() ); -#endif +//TLPDF SfxPrinter *pPrt = pSh->getIDocumentDeviceAccess()->getPrinter( false ); + const boost::shared_ptr< Printer > pPrt( new Printer /* Printer( const JobSetup& rJobSetup ) */ ); // TLPDF + vcl::OldStylePrintAdaptor aPrtAdaptor( pPrt ); // TLPDF +//TLPDF Link aSfxSaveLnk = pPrt->GetEndPrintHdl(); +//TLPDF if( rOpt.IsPrintSingleJobs() ) +//TLPDF pPrt->SetEndPrintHdl( Link() ); BOOL bUserBreak = FALSE, bRet = FALSE; @@ -986,23 +987,27 @@ BOOL SwNewDBMgr::MergePrint( SwView& rView, String( RTL_CONSTASCII_USTRINGPARAM( "true" ) ) ); pPrt->StartJob( rOpt.GetJobName() ); } -#endif if( pPrt->IsJobActive() ) { - pSh->PrintProspect( rOpt, rProgress, rOpt.IsPrintProspect_RTL() ); + pSh->PrintProspectMM( aPrtAdaptor, rOpt, rOpt.IsPrintProspect_RTL() ); /* TLPDF */ bRet = TRUE; } +#endif // TL_NOT_NOW /*TLPDF*/ + pSh->PrintProspectMM( aPrtAdaptor, rOpt, rOpt.IsPrintProspect_RTL() ); // TLPDF + bRet = TRUE; // TLPDF } - else if( pSh->Prt( pPrt, rOpt, &rProgress ) ) /* TLPDF */ + else if( pSh->PrintOrPDFExportMM( aPrtAdaptor, rOpt ) /* TLPDF */ ) bRet = TRUE; bMergeLock = FALSE; +#ifdef TL_NOT_NOW /*TLPDF*/ if( !pPrt->IsJobActive() ) { bUserBreak = TRUE; bRet = FALSE; break; } +#endif // TL_NOT_NOW /*TLPDF*/ if( !rOpt.IsPrintSingleJobs() ) { String& rJNm = (String&)rOpt.GetJobName(); @@ -1012,15 +1017,16 @@ BOOL SwNewDBMgr::MergePrint( SwView& rView, nEndRow = pImpl->pMergeData ? pImpl->pMergeData->xResultSet->getRow() : 0; } while( bSynchronizedDoc && (nStartRow != nEndRow)? ExistsNextRecord() : ToNextMergeRecord()); -#ifdef TL_NOT_NOW /*TLPDF*/ if( rOpt.IsPrintSingleJobs() ) { - SfxPrinter* pTmpPrinter = pSh->getIDocumentDeviceAccess()->getPrinter( true ); - pTmpPrinter->SetEndPrintHdl( aSfxSaveLnk ); - if ( !bUserBreak && !pTmpPrinter->IsJobActive() ) //Schon zu spaet? - aSfxSaveLnk.Call( pTmpPrinter ); +//TLPDF SfxPrinter* pTmpPrinter = pSh->getIDocumentDeviceAccess()->getPrinter( true ); +//TLPDF const boost::shared_ptr< Printer > pTmpPrinter( new Printer /* Printer( const JobSetup& rJobSetup ) */ ); // TLPDF +//TLPDF vcl::OldStylePrintAdaptor aPrtAdaptor( pTmpPrinter ); + // TLPDF +//TLPDF pTmpPrinter->SetEndPrintHdl( aSfxSaveLnk ); +//TLPDF if ( !bUserBreak && !pTmpPrinter->IsJobActive() ) //Schon zu spaet? +//TLPDF aSfxSaveLnk.Call( pTmpPrinter ); } -#endif rOpt.nMergeCnt = 0; rOpt.nMergeAct = 0; @@ -1039,29 +1045,28 @@ BOOL SwNewDBMgr::MergePrint( SwView& rView, } return bRet; -#endif // TL_NOT_NOW /*TLPDF*/ //!! Currently broken beyond repair since we will not have a printer - return TRUE; /* TLPDF */ +#endif // TL_NOT_NOW /*TLPDF*/ } /*-- 21.06.2004 09:08:16--------------------------------------------------- -----------------------------------------------------------------------*/ -BOOL SwNewDBMgr::MergePrintDocuments( SwView& rView, - SwPrtOptions& rOpt, SfxProgress& rProgress, BOOL bIsAPI ) +BOOL SwNewDBMgr::MergePrintDocuments( SwView& /*rView*/, + SwPrtOptions& /*rOpt*/, SfxProgress& /*rProgress*/, BOOL /*bIsAPI*/ ) { - (void) rView; (void) rOpt; (void) rProgress; (void) bIsAPI; /* TLPDF */ -#ifdef TL_NOT_NOW /*TLPDF*/ //!! Currently broken beyond repair since we will not have a printer + return TRUE; +#ifdef TL_NOT_NOW /*TLPDF*/ SwWrtShell* pSh = &rView.GetWrtShell(); //check if the doc is synchronized and contains at least one linked section //merge source is already open rOpt.nMergeCnt = 0; rOpt.SetPrintSingleJobs( sal_True ); - SfxPrinter *pPrt = pSh->getIDocumentDeviceAccess()->getPrinter( false ); -#ifdef TL_NOT_NOW /*TLPDF*/ - Link aSfxSaveLnk = pPrt->GetEndPrintHdl(); - if( rOpt.IsPrintSingleJobs() ) - pPrt->SetEndPrintHdl( Link() ); -#endif +//TLPDF SfxPrinter *pPrt = pSh->getIDocumentDeviceAccess()->getPrinter( false ); + const boost::shared_ptr< Printer > pPrt( new Printer /* Printer( const JobSetup& rJobSetup ) */ ); // TLPDF + vcl::OldStylePrintAdaptor aPrtAdaptor( pPrt ); // TLPDF +//TLPDF Link aSfxSaveLnk = pPrt->GetEndPrintHdl(); +//TLPDF if( rOpt.IsPrintSingleJobs() ) +//TLPDF pPrt->SetEndPrintHdl( Link() ); BOOL bUserBreak = FALSE, bRet = FALSE; @@ -1152,17 +1157,13 @@ BOOL SwNewDBMgr::MergePrintDocuments( SwView& rView, bMergeLock = TRUE; if(rOpt.IsPrintProspect()) { - if( pPrt->IsJobActive() -#ifdef TL_NOT_NOW /*TLPDF*/ - || pPrt->StartJob( rOpt.GetJobName() ) -#endif - ) - { - pSh->PrintProspect( rOpt, rProgress, rOpt.IsPrintProspect_RTL() ); +//TLPDF if( pPrt->IsJobActive() || pPrt->StartJob( rOpt.GetJobName() )) +//TLPDF { + pSh->PrintProspectMM( aPrtAdaptor, rOpt, rOpt.IsPrintProspect_RTL() ); bRet = TRUE; - } +//TLPDF } } - else if( pSh->Prt( pPrt, rOpt, &rProgress ) ) /* TLPDF */ + else if( pSh->PrintOrPDFExportMM( aPrtAdaptor, rOpt ) /* TLPDF */ ) bRet = TRUE; bMergeLock = FALSE; @@ -1179,15 +1180,15 @@ BOOL SwNewDBMgr::MergePrintDocuments( SwView& rView, } } -#ifdef TL_NOT_NOW /*TLPDF*/ if( rOpt.IsPrintSingleJobs() ) { +#ifdef TL_NOT_NOW /*TLPDF*/ SfxPrinter* pTmpPrinter = pSh->getIDocumentDeviceAccess()->getPrinter( true ); pTmpPrinter->SetEndPrintHdl( aSfxSaveLnk ); if ( !bUserBreak && !pTmpPrinter->IsJobActive() ) //Schon zu spaet? aSfxSaveLnk.Call( pTmpPrinter ); +#endif // TL_NOT_NOW /*TLPDF*/ } -#endif rOpt.nMergeCnt = 0; rOpt.nMergeAct = 0; @@ -1206,8 +1207,7 @@ BOOL SwNewDBMgr::MergePrintDocuments( SwView& rView, } return bRet; -#endif // TL_NOT_NOW /*TLPDF*/ //!! Currently broken beyond repair since we will not have a printer - return TRUE; /* TLPDF */ +#endif // TL_NOT_NOW /*TLPDF*/ } diff --git a/sw/source/ui/inc/view.hxx b/sw/source/ui/inc/view.hxx index 7ddfc2775299..0fb458573a61 100644 --- a/sw/source/ui/inc/view.hxx +++ b/sw/source/ui/inc/view.hxx @@ -88,7 +88,7 @@ class SwPrtOptions; class SwTransferable; class SwMailMergeConfigItem; class SwTxtNode; // #i23726# -struct SwPrintData; +class SwPrintData; class SwFormatClipboard; struct SwConversionArgs; class Graphic; diff --git a/sw/source/ui/uiview/viewprt.cxx b/sw/source/ui/uiview/viewprt.cxx index a6faae1894da..ab601c6926c3 100644 --- a/sw/source/ui/uiview/viewprt.cxx +++ b/sw/source/ui/uiview/viewprt.cxx @@ -47,6 +47,7 @@ #endif #include +#include #include #include #include @@ -174,9 +175,8 @@ USHORT __EXPORT SwView::SetPrinter(SfxPrinter* pNew, USHORT nDiffFlags, bool ) Beschreibung: --------------------------------------------------------------------*/ -ErrCode SwView::DoPrint( SfxPrinter* /*pPrinter*/, PrintDialog* /*pDlg*/, BOOL /*bSilent*/, BOOL /*bIsAPI*/ ) +ErrCode SwView::DoPrint( SfxPrinter* pPrinter, PrintDialog* pDlg, BOOL bSilent, BOOL bIsAPI ) { - #if 0 // First test SwWrtShell* pSh = &GetWrtShell(); SwNewDBMgr* pMgr = pSh->GetNewDBMgr(); @@ -200,10 +200,10 @@ ErrCode SwView::DoPrint( SfxPrinter* /*pPrinter*/, PrintDialog* /*pDlg*/, BOOL / } // Der PrintProgress stellt Handler am Printer der ViewShell ein. -// Das kann natuerlich erste nach dem evtl. Umschalten des Druckers korrekt +// Das kann natuerlich erst nach dem evtl. Umschalten des Druckers korrekt // funktionieren. #55210# // SfxPrintProgress *pProgress = new SfxPrintProgress( this, !bSilent ); - SfxPrintProgress *pProgress = 0; + /* TLPDF SfxPrintProgress */ SfxProgress *pProgress = 0; SfxPrinter *pDocPrinter = GetPrinter(TRUE); if ( !pPrinter ) pPrinter = pDocPrinter; @@ -211,13 +211,17 @@ ErrCode SwView::DoPrint( SfxPrinter* /*pPrinter*/, PrintDialog* /*pDlg*/, BOOL / { //Da der Doc-Drucker beim SetPrinter geloescht wird, // muss man ihn vorher clonen - SfxPrinter* pClone = pDocPrinter->Clone(); - SetPrinter( pPrinter, SFX_PRINTER_PRINTER ); - pProgress = new SfxPrintProgress( this, !bSilent ); - pProgress->RestoreOnEndPrint( pClone ); +//TLPDF SfxPrinter* pClone = pDocPrinter->Clone(); +//TLPDF SetPrinter( pPrinter, SFX_PRINTER_PRINTER ); +//TLPDF pProgress = new SfxPrintProgress( this, !bSilent ); +//TLPDF pProgress->RestoreOnEndPrint( pClone ); } if(!pProgress) - pProgress = new SfxPrintProgress( this, !bSilent ); +//TLPDF pProgress = new SfxPrintProgress( this, !bSilent ); + { + SfxObjectShell *pObjShell = GetViewFrame()->GetObjectShell(); // TLPDF ?? + pProgress = new SfxProgress( pObjShell, String(), 1 ); // TLPDF ?? + } pProgress->SetWaitMode(FALSE); BOOL bStartJob = pPrinter->InitJob( &GetEditWin(), @@ -384,16 +388,16 @@ ErrCode SwView::DoPrint( SfxPrinter* /*pPrinter*/, PrintDialog* /*pDlg*/, BOOL / SetAdditionalPrintOptions(aViewProperties); SfxViewShell::Print(*pProgress, bIsAPI ); - if ( !pProgress->IsAborted() ) +//TLPDF if ( !pProgress->IsAborted() ) { if( bPrtPros ) { - bStartJob = pPrinter->StartJob( aOpts.GetJobName() ); - if( bStartJob ) - pSh->PrintProspect( aOpts, *pProgress, bPrtPros_RTL ); +//TLPDF bStartJob = pPrinter->StartJob( aOpts.GetJobName() ); +//TLPDF if( bStartJob ) + pSh->PrintProspectMM( aPrtAdaptor, aOpts, bPrtPros_RTL ); /* TLPDF */ } else - bStartJob = pSh->Prt( pPrinter, aOpts, pProgress ); /*TLPDF*/ + bStartJob = pSh->PrintOrPDFExportMM( aPrtAdaptor, aOpts ); /*TLPDF*/ if ( bBrowse ) { @@ -404,8 +408,8 @@ ErrCode SwView::DoPrint( SfxPrinter* /*pPrinter*/, PrintDialog* /*pDlg*/, BOOL / pSh->UnlockPaint(); } } - else - bStartJob = FALSE; +//TLPDF else +//TLPDF bStartJob = FALSE; pSh->LockView( bLockedView ); } @@ -432,13 +436,9 @@ ErrCode SwView::DoPrint( SfxPrinter* /*pPrinter*/, PrintDialog* /*pDlg*/, BOOL / } pProgress->Stop(); - pProgress->DeleteOnEndPrint(); - pPrinter->EndJob(); +//TLPDF pProgress->DeleteOnEndPrint(); +//TLPDF pPrinter->EndJob(); return pPrinter->GetError(); - #else - DBG_ERROR( "dead code" ); - return ERRCODE_IO_NOTSUPPORTED; - #endif } diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index 104e3257ccfb..135e0c05bc10 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -360,7 +360,7 @@ SwXTextDocument::SwXTextDocument(SwDocShell* pShell) : pxLinkTargetSupplier(0), pxXRedlines(0), m_pHiddenViewFrame(0), - m_pPrintUIOptions( NULL ) + m_pPrintUIOprions( NULL ) { } /*-- 18.12.98 11:53:00--------------------------------------------------- @@ -375,7 +375,7 @@ SwXTextDocument::~SwXTextDocument() xNumFmtAgg->setDelegator(x0); xNumFmtAgg = 0; } - delete m_pPrintUIOptions; + delete m_pPrintUIOprions; } @@ -2608,13 +2608,13 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount( if(!IsValid()) throw RuntimeException(); - if( ! m_pPrintUIOptions ) + if( ! m_pPrintUIOprions ) { const BOOL bWebDoc = (0 != PTR_CAST(SwWebDocShell, pDocShell)); - m_pPrintUIOptions = new SwPrintUIOptions( bWebDoc ); + m_pPrintUIOprions = new SwPrintUIOptions( bWebDoc ); } - bool bFormat = m_pPrintUIOptions->processPropertiesAndCheckFormat( rxOptions ); - const bool bIsPDFExport = !m_pPrintUIOptions->hasProperty( "IsPrinter" ); + bool bFormat = m_pPrintUIOprions->processPropertiesAndCheckFormat( rxOptions ); + const bool bIsPDFExport = !m_pPrintUIOprions->hasProperty( "IsPrinter" ); SfxViewShell *pView = 0; SwDoc *pDoc = GetRenderDoc( pView, rSelection, bIsPDFExport ); @@ -2660,8 +2660,8 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount( OUString aPageRange; if (bIsPDFExport) { -// TLPDF ?? m_pPrintUIOptions->getValue( C2U("Selection") ); - aPageRange = m_pPrintUIOptions->getStringValue( "PageRange", OUString() ); +// TLPDF ?? m_pPrintUIOprions->getValue( C2U("Selection") ); + aPageRange = m_pPrintUIOprions->getStringValue( "PageRange", OUString() ); } else { @@ -2669,8 +2669,8 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount( // 0 -> print all pages // 1 -> print range according to PageRange // 2 -> print selection - if (1 == m_pPrintUIOptions->getIntValue( "PrintContent", 0 )) - aPageRange = m_pPrintUIOptions->getStringValue( "PageRange", OUString() ); + if (1 == m_pPrintUIOprions->getIntValue( "PrintContent", 0 )) + aPageRange = m_pPrintUIOprions->getStringValue( "PageRange", OUString() ); } if (aPageRange.getLength() == 0) // empty string -> print all { @@ -2681,26 +2681,26 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount( } // get number of pages to be rendered - const bool bPrintProspect = m_pPrintUIOptions->getBoolValue( "PrintBrochure", false ); + const bool bPrintProspect = m_pPrintUIOprions->getBoolValue( "PrintProspect", false ); if (bPrintProspect) { - pDoc->CalculatePagePairsForProspectPrinting( *m_pPrintUIOptions, nPageCount ); - nRet = m_pPrintUIOptions->GetPagePairsForProspectPrinting().size(); + pDoc->CalculatePagePairsForProspectPrinting( *m_pPrintUIOprions, nPageCount ); + nRet = m_pPrintUIOprions->GetPagePairsForProspectPrinting().size(); } else { // get set of valid pages (according to the current settings) // and their start frames - pDoc->CalculatePagesForPrinting( bIsPDFExport, *m_pPrintUIOptions, nPageCount ); + pDoc->CalculatePagesForPrinting( bIsPDFExport, *m_pPrintUIOprions, nPageCount ); DBG_ASSERT( nPageCount >= 1, "valid pages count is 0! Should not happen." ); // get vector of pages to print according to PageRange and valid pages from above // (result may be an empty vector, for example if the range string is not correct) StringRangeEnumerator::getRangesFromString( - aPageRange, m_pPrintUIOptions->GetPagesToPrint(), - 1, nPageCount, 0, &m_pPrintUIOptions->GetValidPagesSet() ); + aPageRange, m_pPrintUIOprions->GetPagesToPrint(), + 1, nPageCount, 0, &m_pPrintUIOprions->GetValidPagesSet() ); - nRet = m_pPrintUIOptions->GetPagesToPrint().size(); + nRet = m_pPrintUIOprions->GetPagesToPrint().size(); } DBG_ASSERT( nRet >= 0, "negative number of pages???" ); @@ -2719,13 +2719,13 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SwXTextDocument::getRenderer( if(!IsValid()) throw RuntimeException(); - if( ! m_pPrintUIOptions ) + if( ! m_pPrintUIOprions ) { const BOOL bWebDoc = (0 != PTR_CAST(SwWebDocShell, pDocShell)); m_pPrintUIOptions = new SwPrintUIOptions( bWebDoc ); } m_pPrintUIOptions->processProperties( rxOptions ); - const bool bIsPDFExport = !m_pPrintUIOptions->hasProperty( "IsPrinter" ); + const bool bIsPDFExport = !m_pPrintUIOprions->hasProperty( "IsPrinter" ); SfxViewShell *pView = 0; SwDoc *pDoc = GetRenderDoc( pView, rSelection, bIsPDFExport ); @@ -2740,19 +2740,21 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SwXTextDocument::getRenderer( if (nRenderer >= pDoc->GetPageCount()) return uno::Sequence< beans::PropertyValue >(); - const bool bIsSkipEmptyPages = m_pPrintUIOptions->getBoolValue( "IsSkipEmptyPages", sal_False ); + bool bIsSkipEmptyPages = !m_pPrintUIOptions->IsPrintEmptyPages(); Size aPgSize( pDoc->GetPageSize( sal_uInt16(nRenderer + 1), bIsSkipEmptyPages ) ); awt::Size aPageSize( TWIP_TO_MM100( aPgSize.Width() ), TWIP_TO_MM100( aPgSize.Height() )); // prospect printing should be landscape, thus switching width and height - if (m_pPrintUIOptions->getBoolValue( "PrintBrochure", sal_False )) + if (m_pPrintUIOprions->getBoolValue( "PrintProspect", sal_False )) aPageSize = awt::Size( aPageSize.Height, aPageSize.Width ); - uno::Sequence< beans::PropertyValue > aRenderer(1); + uno::Sequence< beans::PropertyValue > aRenderer(2); PropertyValue &rValue = aRenderer.getArray()[0]; rValue.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "PageSize" ) ); rValue.Value <<= aPageSize; + rValue.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "PageIncludesNonprintableArea" ) ); + rValue.Value <<= sal_False; - m_pPrintUIOptions->appendPrintUIOptions( aRenderer ); + m_pPrintUIOprions->appendPrintUIOptions( aRenderer ); return aRenderer; } @@ -2809,14 +2811,14 @@ void SAL_CALL SwXTextDocument::render( if(!IsValid()) throw RuntimeException(); - if (!m_pPrintUIOptions) + if (!m_pPrintUIOprions) { const BOOL bWebDoc = (0 != PTR_CAST(SwWebDocShell, pDocShell)); - m_pPrintUIOptions = new SwPrintUIOptions( bWebDoc ); + m_pPrintUIOprions = new SwPrintUIOptions( bWebDoc ); } - m_pPrintUIOptions->processProperties( rxOptions ); - const bool bPrintProspect = m_pPrintUIOptions->getBoolValue( "PrintBrochure", false ); - const bool bIsPDFExport = !m_pPrintUIOptions->hasProperty( "IsPrinter" ); + m_pPrintUIOprions->processProperties( rxOptions ); + const bool bPrintProspect = m_pPrintUIOprions->getBoolValue( "PrintProspect", false ); + const bool bIsPDFExport = !m_pPrintUIOprions->hasProperty( "IsPrinter" ); // get view shell to use SfxViewShell *pView = 0; @@ -2824,7 +2826,7 @@ void SAL_CALL SwXTextDocument::render( pView = GuessViewShell(); else { - uno::Any aTmp( m_pPrintUIOptions->getValue( C2U( "View" ) )); + uno::Any aTmp( m_pPrintUIOprions->getValue( C2U( "View" ) )); uno::Reference< frame::XController > xController; if (aTmp >>= xController) { @@ -2843,8 +2845,8 @@ void SAL_CALL SwXTextDocument::render( // Thus instead of throwing the exception we silently return. if (0 > nRenderer) throw IllegalArgumentException(); - if ( (bPrintProspect && size_t(nRenderer) >= m_pPrintUIOptions->GetPagePairsForProspectPrinting().size()) - || (!bPrintProspect && size_t(nRenderer) >= m_pPrintUIOptions->GetPagesToPrint().size())) + if ( (bPrintProspect && size_t(nRenderer) >= m_pPrintUIOprions->GetPagePairsForProspectPrinting().size()) + || (!bPrintProspect && size_t(nRenderer) >= m_pPrintUIOprions->GetPagesToPrint().size())) return; // the view shell should be SwView for documents PDF export @@ -2860,7 +2862,7 @@ void SAL_CALL SwXTextDocument::render( ((SwPagePreView*)pView)->GetViewShell(); } - uno::Any aAny( m_pPrintUIOptions->getValue( C2U( "RenderDevice" ) )); + uno::Any aAny( m_pPrintUIOprions->getValue( C2U( "RenderDevice" ) )); uno::Reference< awt::XDevice > xRenderDevice; aAny >>= xRenderDevice; @@ -2873,42 +2875,42 @@ void SAL_CALL SwXTextDocument::render( if(pVwSh && pOut) { - const bool bFirstPage = m_pPrintUIOptions->getBoolValue( "IsFirstPage", sal_False ); - const bool bLastPage = m_pPrintUIOptions->getBoolValue( "IsLastPage", sal_False ); - const bool bIsSkipEmptyPages = m_pPrintUIOptions->getBoolValue( "IsSkipEmptyPages", sal_False ); - const rtl::OUString aPageRange = m_pPrintUIOptions->getStringValue( "PageRange", OUString() ); - - SwPrtOptions aOptions( C2U("PDF export") ); + // TLPDF2DO: clean-up, need to check if only one of aOptions and m_pPrintUIOprions should be used + SwPrtOptions aOptions( C2U( bIsPDFExport ? "PDF export" : "Printing" ) ); - // get print options to use from provided properties + // get default print options const TypeId aSwWebDocShellTypeId = TYPE(SwWebDocShell); BOOL bWeb = pDocShell->IsA( aSwWebDocShellTypeId ); SwView::MakeOptions( NULL, aOptions, NULL, NULL, bWeb, NULL, NULL ); - sal_Int64 nLeftRightPages = 0; - if( ! aOptions.bPrintLeftPage ) - nLeftRightPages = 2; - if( ! aOptions.bPrintRightPage ) - nLeftRightPages = 1; - nLeftRightPages = m_pPrintUIOptions->getIntValue( "PrintLeftRightPages", nLeftRightPages ); - aOptions.bPrintGraphic = m_pPrintUIOptions->getBoolValue( "PrintGraphicsAndDiagrams", aOptions.bPrintGraphic ); - aOptions.bPrintTable = m_pPrintUIOptions->getBoolValue( "PrintGraphicsAndDiagrams", aOptions.bPrintTable ); - aOptions.bPrintDraw = m_pPrintUIOptions->getBoolValue( "PrintGraphicsAndDiagrams", aOptions.bPrintDraw ); - aOptions.bPrintControl = m_pPrintUIOptions->getBoolValue( "PrintControls", aOptions.bPrintControl ); - aOptions.bPrintLeftPage = nLeftRightPages == 0 || nLeftRightPages == 1; - aOptions.bPrintRightPage = nLeftRightPages == 0 || nLeftRightPages == 2; - aOptions.bPrintPageBackground = m_pPrintUIOptions->getBoolValue( "PrintBackground", aOptions.bPrintPageBackground ); - aOptions.bPrintEmptyPages = m_pPrintUIOptions->getBoolValue( "PrintEmptyPages", aOptions.bPrintEmptyPages ); + + // get print options to use from provided properties + const rtl::OUString aPageRange = m_pPrintUIOprions->getStringValue( "PageRange", OUString() ); + const bool bFirstPage = m_pPrintUIOprions->getBoolValue( "IsFirstPage", sal_False ); + const bool bLastPage = m_pPrintUIOprions->getBoolValue( "IsLastPage", sal_False ); + bool bIsSkipEmptyPages = !m_pPrintUIOprions->IsPrintEmptyPages( bIsPDFExport ); + aOptions.bPrintGraphic = m_pPrintUIOprions->IsPrintGraphics(); + aOptions.bPrintTable = m_pPrintUIOprions->IsPrintTables(); + aOptions.bPrintDraw = m_pPrintUIOprions->IsPrintDrawings(); + aOptions.bPrintControl = m_pPrintUIOprions->getBoolValue( "PrintControls", aOptions.bPrintControl ); + aOptions.bPrintLeftPage = m_pPrintUIOprions->IsPrintLeftPages(); + aOptions.bPrintRightPage = m_pPrintUIOprions->IsPrintRigthPages(); + aOptions.bPrintPageBackground = m_pPrintUIOprions->getBoolValue( "PrintPageBackground", aOptions.bPrintPageBackground ); + aOptions.bPrintEmptyPages = !bIsSkipEmptyPages; // bUpdateFieldsInPrinting <-- not set here // TLPDF: TODO: remove this from SwPrintData?? Get rid of SwPrtOptions?? - aOptions.bPaperFromSetup = m_pPrintUIOptions->getBoolValue( "PaperTray", aOptions.bPaperFromSetup ); - aOptions.bPrintReverse = m_pPrintUIOptions->getBoolValue( "PrintReverseOrder", aOptions.bPrintReverse ); - aOptions.bPrintProspect = m_pPrintUIOptions->getBoolValue( "PrintBrochure", aOptions.bPrintProspect ); - aOptions.bPrintProspect_RTL = m_pPrintUIOptions->getIntValue( "PrintBrochureRTL", aOptions.bPrintProspect_RTL ) ? true : false; + aOptions.bPaperFromSetup = m_pPrintUIOprions->getBoolValue( "PrintPaperFromSetup", aOptions.bPaperFromSetup ); + aOptions.bPrintReverse = m_pPrintUIOprions->getBoolValue( "PrintReversed", aOptions.bPrintReverse ); + aOptions.bPrintProspect = m_pPrintUIOprions->getBoolValue( "PrintProspect", aOptions.bPrintProspect ); + aOptions.bPrintProspect_RTL = m_pPrintUIOprions->getIntValue( "PrintProspectRTL", aOptions.bPrintProspect_RTL ) ? true : false; // bPrintSingleJobs <-- not set here // TLPDF: TODO: remove this from SwPrintData?? Get rid of SwPrtOptions?? // bModified <-- not set here // TLPDF: TODO: remove this from SwPrintData?? Get rid of SwPrtOptions?? - aOptions.bPrintBlackFont = m_pPrintUIOptions->getBoolValue( "PrintBlack", aOptions.bPrintBlackFont ); - aOptions.bPrintHiddenText = m_pPrintUIOptions->getBoolValue( "PrintHiddenText", aOptions.bPrintHiddenText ); - aOptions.bPrintTextPlaceholder = m_pPrintUIOptions->getBoolValue( "PrintPlaceholder", aOptions.bPrintTextPlaceholder ); - aOptions.nPrintPostIts = static_cast< sal_Int16 >(m_pPrintUIOptions->getIntValue( "PrintNotes", aOptions.nPrintPostIts )); + aOptions.bPrintBlackFont = m_pPrintUIOprions->getBoolValue( "PrintBlackFonts", aOptions.bPrintBlackFont ); + aOptions.bPrintHiddenText = m_pPrintUIOprions->getBoolValue( "PrintHiddenText", aOptions.bPrintHiddenText ); + aOptions.bPrintTextPlaceholder = m_pPrintUIOprions->getBoolValue( "PrintTextPlaceholder", aOptions.bPrintTextPlaceholder ); + aOptions.nPrintPostIts = static_cast< sal_Int16 >(m_pPrintUIOprions->getIntValue( "PrintAnnotationMode", aOptions.nPrintPostIts )); + + //! needs to be set after MakeOptions since the assingment operation in that + //! function will destroy this pointer + aOptions.SetPrintUIOptions( m_pPrintUIOprions ); Range aRange( nRenderer+1, nRenderer+1 ); MultiSelection aPages( aRange ); @@ -2948,9 +2950,9 @@ void SAL_CALL SwXTextDocument::render( // TLPDF OutputDevice *pOldDev = pVwSh->GetOut(); // TLPDF if (bPrintProspect) - pVwSh->PrintProspect( pOut, aOptions, *m_pPrintUIOptions, nRenderer ); + pVwSh->PrintProspect( pOut, aOptions, nRenderer ); else // normal printing and PDF export - pVwSh->PrintOrPDFExport( pOut, aOptions, *m_pPrintUIOptions, nRenderer, bIsPDFExport ); + pVwSh->PrintOrPDFExport( pOut, aOptions, nRenderer, bIsPDFExport ); // --> FME 2004-10-08 #i35176# // @@ -2977,7 +2979,8 @@ void SAL_CALL SwXTextDocument::render( lcl_DisposeView( m_pHiddenViewFrame, pDocShell ); m_pHiddenViewFrame = 0; } - delete m_pPrintUIOptions, m_pPrintUIOptions = NULL; + aOptions.SetPrintUIOptions( NULL ); + delete m_pPrintUIOprions, m_pPrintUIOprions = NULL; } } } -- cgit From 31c68b3b56ce4ffc1649fe83dd3f1dca97eb7551 Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Fri, 14 Aug 2009 14:00:36 +0000 Subject: #i101242# new print UI --- sw/inc/viewsh.hxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sw') diff --git a/sw/inc/viewsh.hxx b/sw/inc/viewsh.hxx index 9e4f89fb1134..350a095b6a69 100644 --- a/sw/inc/viewsh.hxx +++ b/sw/inc/viewsh.hxx @@ -97,7 +97,7 @@ class SdrPaintWindow; namespace vcl { class PrinterController; -}; +} //JP 19.07.98: - Bug 52312 -- cgit From dc48e555979cd69935d36231c75311933b5bbb1f Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Fri, 14 Aug 2009 14:39:33 +0000 Subject: #i101242# new print UI --- sw/source/core/view/vprint.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sw') diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index 23cf28e938ea..e30f8702e8b4 100644 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -979,7 +979,7 @@ void lcl_SetState( SfxProgress& rProgress, ULONG nPage, ULONG nMax, void ViewShell::CalcPagesForPrint( USHORT nMax, SfxProgress* pProgress, - const XubString* pStr, ULONG nMergeAct, ULONG nMergeCnt ) + const XubString* /*pStr*/, ULONG nMergeAct, ULONG nMergeCnt ) { SET_CURR_SHELL( this ); -- cgit From 41de88368a73475ba75c0fd47974f5fefdff2aaf Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Sat, 15 Aug 2009 16:55:10 +0000 Subject: #i92516# move solar.hrc to vcl --- sw/inc/helpid.h | 2 +- sw/inc/pch/precompiled_sw.hxx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'sw') diff --git a/sw/inc/helpid.h b/sw/inc/helpid.h index f709c95038f0..dca700fbb8b6 100644 --- a/sw/inc/helpid.h +++ b/sw/inc/helpid.h @@ -28,7 +28,7 @@ * ************************************************************************/ #ifndef _SOLAR_HRC -#include +#include #endif #define HID_BASE HID_APP_START diff --git a/sw/inc/pch/precompiled_sw.hxx b/sw/inc/pch/precompiled_sw.hxx index fc62291e85c7..a95604e32b0f 100644 --- a/sw/inc/pch/precompiled_sw.hxx +++ b/sw/inc/pch/precompiled_sw.hxx @@ -679,7 +679,7 @@ #include "svtools/slstitm.hxx" #include "svtools/smplhint.hxx" #include "svtools/soerr.hxx" -#include "svtools/solar.hrc" +#include "vcl/solar.hrc" #include "svtools/sourceviewconfig.hxx" #include "svtools/stdctrl.hxx" #include "svtools/stritem.hxx" -- cgit From 0ea31f2a9b6657925852ac5f3128ff2937e2a18d Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Sun, 16 Aug 2009 14:49:58 +0000 Subject: #i92516# fix warnings --- sw/source/core/view/vprint.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sw') diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index e30f8702e8b4..46fd54f09ac4 100644 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -979,7 +979,7 @@ void lcl_SetState( SfxProgress& rProgress, ULONG nPage, ULONG nMax, void ViewShell::CalcPagesForPrint( USHORT nMax, SfxProgress* pProgress, - const XubString* /*pStr*/, ULONG nMergeAct, ULONG nMergeCnt ) + const XubString* /*pStr*/, ULONG nMergeAct, ULONG /*nMergeCnt*/ ) { SET_CURR_SHELL( this ); @@ -990,7 +990,7 @@ void ViewShell::CalcPagesForPrint( USHORT nMax, SfxProgress* pProgress, SfxPrinter* pPrt = getIDocumentDeviceAccess()->getPrinter( false ); BOOL bPrtJob = pPrt ? pPrt->IsJobActive() : FALSE; SwRootFrm* pLayout = GetLayout(); - ULONG nStatMax = pLayout->GetPageNum(); + // ULONG nStatMax = pLayout->GetPageNum(); const SwFrm *pPage = pLayout->Lower(); SwLayAction aAction( pLayout, Imp() ); -- cgit From 0ccccd51bf9de6e53f32840754fce46307efbf57 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Sun, 16 Aug 2009 15:10:35 +0000 Subject: fix warning --- sw/source/core/view/vprint.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sw') diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index 46fd54f09ac4..31074dc1ac2c 100644 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -979,7 +979,7 @@ void lcl_SetState( SfxProgress& rProgress, ULONG nPage, ULONG nMax, void ViewShell::CalcPagesForPrint( USHORT nMax, SfxProgress* pProgress, - const XubString* /*pStr*/, ULONG nMergeAct, ULONG /*nMergeCnt*/ ) + const XubString* /*pStr*/, ULONG /*nMergeAct*/, ULONG /*nMergeCnt*/ ) { SET_CURR_SHELL( this ); -- cgit From 84d95bba0af714d81a889c6eb194d3e4ed21fa21 Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Mon, 17 Aug 2009 09:18:18 +0000 Subject: #i101242# new print UI --- sw/inc/unotxdoc.hxx | 2 +- sw/source/core/view/vprint.cxx | 4 ++ sw/source/ui/dbui/dbmgr.cxx | 10 ++-- sw/source/ui/uiview/viewprt.cxx | 11 +++-- sw/source/ui/uno/unotxdoc.cxx | 106 ++++++++++++++++++++-------------------- 5 files changed, 72 insertions(+), 61 deletions(-) (limited to 'sw') diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx index 7292ce74fcff..216516d0d879 100644 --- a/sw/inc/unotxdoc.hxx +++ b/sw/inc/unotxdoc.hxx @@ -221,7 +221,7 @@ class SwXTextDocument : public SwXTextDocumentBaseClass, css::uno::Reference< css::uno::XInterface> xPropertyHelper; SwXDocumentPropertyHelper* pPropertyHelper; - SwPrintUIOptions* m_pPrintUIOprions; + SwPrintUIOptions* m_pPrintUIOptions; void GetBodyText(); void GetNumberFormatter(); diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index 31074dc1ac2c..351f1126103c 100644 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -979,7 +979,11 @@ void lcl_SetState( SfxProgress& rProgress, ULONG nPage, ULONG nMax, void ViewShell::CalcPagesForPrint( USHORT nMax, SfxProgress* pProgress, +<<<<<<< .mine + const XubString* /*TLPDF pStr*/, ULONG /*TLPDF nMergeAct*/, ULONG /*TLPDF nMergeCnt*/ ) +======= const XubString* /*pStr*/, ULONG /*nMergeAct*/, ULONG /*nMergeCnt*/ ) +>>>>>>> .r275036 { SET_CURR_SHELL( this ); diff --git a/sw/source/ui/dbui/dbmgr.cxx b/sw/source/ui/dbui/dbmgr.cxx index e53f5d766427..62fe78702d1f 100644 --- a/sw/source/ui/dbui/dbmgr.cxx +++ b/sw/source/ui/dbui/dbmgr.cxx @@ -908,6 +908,7 @@ BOOL SwNewDBMgr::MergePrint( SwView& /*rView*/, //TLPDF SfxPrinter *pPrt = pSh->getIDocumentDeviceAccess()->getPrinter( false ); const boost::shared_ptr< Printer > pPrt( new Printer /* Printer( const JobSetup& rJobSetup ) */ ); // TLPDF vcl::OldStylePrintAdaptor aPrtAdaptor( pPrt ); // TLPDF + const boost::shared_ptr< vcl::PrinterController > pPrtController( &aPrtAdaptor ); //TLPDF Link aSfxSaveLnk = pPrt->GetEndPrintHdl(); //TLPDF if( rOpt.IsPrintSingleJobs() ) //TLPDF pPrt->SetEndPrintHdl( Link() ); @@ -993,10 +994,10 @@ BOOL SwNewDBMgr::MergePrint( SwView& /*rView*/, bRet = TRUE; } #endif // TL_NOT_NOW /*TLPDF*/ - pSh->PrintProspectMM( aPrtAdaptor, rOpt, rOpt.IsPrintProspect_RTL() ); // TLPDF + pSh->PrintProspectMM( pPrtController, rOpt, rOpt.IsPrintProspect_RTL() ); // TLPDF bRet = TRUE; // TLPDF } - else if( pSh->PrintOrPDFExportMM( aPrtAdaptor, rOpt ) /* TLPDF */ ) + else if( pSh->PrintOrPDFExportMM( pPrtController, rOpt ) /* TLPDF */ ) bRet = TRUE; bMergeLock = FALSE; @@ -1064,6 +1065,7 @@ BOOL SwNewDBMgr::MergePrintDocuments( SwView& /*rView*/, //TLPDF SfxPrinter *pPrt = pSh->getIDocumentDeviceAccess()->getPrinter( false ); const boost::shared_ptr< Printer > pPrt( new Printer /* Printer( const JobSetup& rJobSetup ) */ ); // TLPDF vcl::OldStylePrintAdaptor aPrtAdaptor( pPrt ); // TLPDF + const boost::shared_ptr< vcl::PrinterController > pPrtController( &aPrtAdaptor ); //TLPDF Link aSfxSaveLnk = pPrt->GetEndPrintHdl(); //TLPDF if( rOpt.IsPrintSingleJobs() ) //TLPDF pPrt->SetEndPrintHdl( Link() ); @@ -1159,11 +1161,11 @@ BOOL SwNewDBMgr::MergePrintDocuments( SwView& /*rView*/, { //TLPDF if( pPrt->IsJobActive() || pPrt->StartJob( rOpt.GetJobName() )) //TLPDF { - pSh->PrintProspectMM( aPrtAdaptor, rOpt, rOpt.IsPrintProspect_RTL() ); + pSh->PrintProspectMM( pPrtController, rOpt, rOpt.IsPrintProspect_RTL() ); bRet = TRUE; //TLPDF } } - else if( pSh->PrintOrPDFExportMM( aPrtAdaptor, rOpt ) /* TLPDF */ ) + else if( pSh->PrintOrPDFExportMM( pPrtController, rOpt ) /* TLPDF */ ) bRet = TRUE; bMergeLock = FALSE; diff --git a/sw/source/ui/uiview/viewprt.cxx b/sw/source/ui/uiview/viewprt.cxx index ab601c6926c3..9d51c50ae19e 100644 --- a/sw/source/ui/uiview/viewprt.cxx +++ b/sw/source/ui/uiview/viewprt.cxx @@ -51,6 +51,7 @@ #include #include #include +#include #include #include #include @@ -371,7 +372,7 @@ ErrCode SwView::DoPrint( SfxPrinter* pPrinter, PrintDialog* pDlg, BOOL bSilent, pViewProperties[10].Value <<= (text::NotePrintMode) aOpts.GetPrintPostIts(); pViewProperties[11].Name = C2U("PrintProspect"); pViewProperties[11].Value <<= (sal_Bool)aOpts.IsPrintProspect(); - pViewProperties[12].Name = C2U("PrintPageBackground"); + pViewProperties[12].Name = C2U("PrintPageBackground"); pViewProperties[12].Value <<= (sal_Bool)aOpts.IsPrintPageBackground(); pViewProperties[13].Name = C2U("PrintBlackFonts"); pViewProperties[13].Value <<= (sal_Bool)aOpts.IsPrintBlackFont(); @@ -390,14 +391,18 @@ ErrCode SwView::DoPrint( SfxPrinter* pPrinter, PrintDialog* pDlg, BOOL bSilent, SfxViewShell::Print(*pProgress, bIsAPI ); //TLPDF if ( !pProgress->IsAborted() ) { + const boost::shared_ptr< Printer > pPrt( pPrinter ); // TLPDF + vcl::OldStylePrintAdaptor aPrtAdaptor( pPrt ); // TLPDF + const boost::shared_ptr< vcl::PrinterController > pPrtController( &aPrtAdaptor ); + if( bPrtPros ) { //TLPDF bStartJob = pPrinter->StartJob( aOpts.GetJobName() ); //TLPDF if( bStartJob ) - pSh->PrintProspectMM( aPrtAdaptor, aOpts, bPrtPros_RTL ); /* TLPDF */ + pSh->PrintProspectMM( pPrtController, aOpts, bPrtPros_RTL ); /* TLPDF */ } else - bStartJob = pSh->PrintOrPDFExportMM( aPrtAdaptor, aOpts ); /*TLPDF*/ + bStartJob = pSh->PrintOrPDFExportMM( pPrtController, aOpts ); /*TLPDF*/ if ( bBrowse ) { diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index 135e0c05bc10..aa50d3f71372 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -360,7 +360,7 @@ SwXTextDocument::SwXTextDocument(SwDocShell* pShell) : pxLinkTargetSupplier(0), pxXRedlines(0), m_pHiddenViewFrame(0), - m_pPrintUIOprions( NULL ) + m_pPrintUIOptions( NULL ) { } /*-- 18.12.98 11:53:00--------------------------------------------------- @@ -375,7 +375,7 @@ SwXTextDocument::~SwXTextDocument() xNumFmtAgg->setDelegator(x0); xNumFmtAgg = 0; } - delete m_pPrintUIOprions; + delete m_pPrintUIOptions; } @@ -2608,13 +2608,13 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount( if(!IsValid()) throw RuntimeException(); - if( ! m_pPrintUIOprions ) + if( ! m_pPrintUIOptions ) { const BOOL bWebDoc = (0 != PTR_CAST(SwWebDocShell, pDocShell)); - m_pPrintUIOprions = new SwPrintUIOptions( bWebDoc ); + m_pPrintUIOptions = new SwPrintUIOptions( bWebDoc ); } - bool bFormat = m_pPrintUIOprions->processPropertiesAndCheckFormat( rxOptions ); - const bool bIsPDFExport = !m_pPrintUIOprions->hasProperty( "IsPrinter" ); + bool bFormat = m_pPrintUIOptions->processPropertiesAndCheckFormat( rxOptions ); + const bool bIsPDFExport = !m_pPrintUIOptions->hasProperty( "IsPrinter" ); SfxViewShell *pView = 0; SwDoc *pDoc = GetRenderDoc( pView, rSelection, bIsPDFExport ); @@ -2660,8 +2660,8 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount( OUString aPageRange; if (bIsPDFExport) { -// TLPDF ?? m_pPrintUIOprions->getValue( C2U("Selection") ); - aPageRange = m_pPrintUIOprions->getStringValue( "PageRange", OUString() ); +// TLPDF ?? m_pPrintUIOptions->getValue( C2U("Selection") ); + aPageRange = m_pPrintUIOptions->getStringValue( "PageRange", OUString() ); } else { @@ -2669,8 +2669,8 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount( // 0 -> print all pages // 1 -> print range according to PageRange // 2 -> print selection - if (1 == m_pPrintUIOprions->getIntValue( "PrintContent", 0 )) - aPageRange = m_pPrintUIOprions->getStringValue( "PageRange", OUString() ); + if (1 == m_pPrintUIOptions->getIntValue( "PrintContent", 0 )) + aPageRange = m_pPrintUIOptions->getStringValue( "PageRange", OUString() ); } if (aPageRange.getLength() == 0) // empty string -> print all { @@ -2681,26 +2681,26 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount( } // get number of pages to be rendered - const bool bPrintProspect = m_pPrintUIOprions->getBoolValue( "PrintProspect", false ); + const bool bPrintProspect = m_pPrintUIOptions->getBoolValue( "PrintProspect", false ); if (bPrintProspect) { - pDoc->CalculatePagePairsForProspectPrinting( *m_pPrintUIOprions, nPageCount ); - nRet = m_pPrintUIOprions->GetPagePairsForProspectPrinting().size(); + pDoc->CalculatePagePairsForProspectPrinting( *m_pPrintUIOptions, nPageCount ); + nRet = m_pPrintUIOptions->GetPagePairsForProspectPrinting().size(); } else { // get set of valid pages (according to the current settings) // and their start frames - pDoc->CalculatePagesForPrinting( bIsPDFExport, *m_pPrintUIOprions, nPageCount ); + pDoc->CalculatePagesForPrinting( bIsPDFExport, *m_pPrintUIOptions, nPageCount ); DBG_ASSERT( nPageCount >= 1, "valid pages count is 0! Should not happen." ); // get vector of pages to print according to PageRange and valid pages from above // (result may be an empty vector, for example if the range string is not correct) StringRangeEnumerator::getRangesFromString( - aPageRange, m_pPrintUIOprions->GetPagesToPrint(), - 1, nPageCount, 0, &m_pPrintUIOprions->GetValidPagesSet() ); + aPageRange, m_pPrintUIOptions->GetPagesToPrint(), + 1, nPageCount, 0, &m_pPrintUIOptions->GetValidPagesSet() ); - nRet = m_pPrintUIOprions->GetPagesToPrint().size(); + nRet = m_pPrintUIOptions->GetPagesToPrint().size(); } DBG_ASSERT( nRet >= 0, "negative number of pages???" ); @@ -2719,13 +2719,13 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SwXTextDocument::getRenderer( if(!IsValid()) throw RuntimeException(); - if( ! m_pPrintUIOprions ) + if( ! m_pPrintUIOptions ) { const BOOL bWebDoc = (0 != PTR_CAST(SwWebDocShell, pDocShell)); m_pPrintUIOptions = new SwPrintUIOptions( bWebDoc ); } m_pPrintUIOptions->processProperties( rxOptions ); - const bool bIsPDFExport = !m_pPrintUIOprions->hasProperty( "IsPrinter" ); + const bool bIsPDFExport = !m_pPrintUIOptions->hasProperty( "IsPrinter" ); SfxViewShell *pView = 0; SwDoc *pDoc = GetRenderDoc( pView, rSelection, bIsPDFExport ); @@ -2740,12 +2740,12 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SwXTextDocument::getRenderer( if (nRenderer >= pDoc->GetPageCount()) return uno::Sequence< beans::PropertyValue >(); - bool bIsSkipEmptyPages = !m_pPrintUIOptions->IsPrintEmptyPages(); + bool bIsSkipEmptyPages = !m_pPrintUIOptions->IsPrintEmptyPages( bIsPDFExport ); Size aPgSize( pDoc->GetPageSize( sal_uInt16(nRenderer + 1), bIsSkipEmptyPages ) ); awt::Size aPageSize( TWIP_TO_MM100( aPgSize.Width() ), TWIP_TO_MM100( aPgSize.Height() )); // prospect printing should be landscape, thus switching width and height - if (m_pPrintUIOprions->getBoolValue( "PrintProspect", sal_False )) + if (m_pPrintUIOptions->getBoolValue( "PrintProspect", sal_False )) aPageSize = awt::Size( aPageSize.Height, aPageSize.Width ); uno::Sequence< beans::PropertyValue > aRenderer(2); PropertyValue &rValue = aRenderer.getArray()[0]; @@ -2754,7 +2754,7 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SwXTextDocument::getRenderer( rValue.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "PageIncludesNonprintableArea" ) ); rValue.Value <<= sal_False; - m_pPrintUIOprions->appendPrintUIOptions( aRenderer ); + m_pPrintUIOptions->appendPrintUIOptions( aRenderer ); return aRenderer; } @@ -2811,14 +2811,14 @@ void SAL_CALL SwXTextDocument::render( if(!IsValid()) throw RuntimeException(); - if (!m_pPrintUIOprions) + if (!m_pPrintUIOptions) { const BOOL bWebDoc = (0 != PTR_CAST(SwWebDocShell, pDocShell)); - m_pPrintUIOprions = new SwPrintUIOptions( bWebDoc ); + m_pPrintUIOptions = new SwPrintUIOptions( bWebDoc ); } - m_pPrintUIOprions->processProperties( rxOptions ); - const bool bPrintProspect = m_pPrintUIOprions->getBoolValue( "PrintProspect", false ); - const bool bIsPDFExport = !m_pPrintUIOprions->hasProperty( "IsPrinter" ); + m_pPrintUIOptions->processProperties( rxOptions ); + const bool bPrintProspect = m_pPrintUIOptions->getBoolValue( "PrintProspect", false ); + const bool bIsPDFExport = !m_pPrintUIOptions->hasProperty( "IsPrinter" ); // get view shell to use SfxViewShell *pView = 0; @@ -2826,7 +2826,7 @@ void SAL_CALL SwXTextDocument::render( pView = GuessViewShell(); else { - uno::Any aTmp( m_pPrintUIOprions->getValue( C2U( "View" ) )); + uno::Any aTmp( m_pPrintUIOptions->getValue( C2U( "View" ) )); uno::Reference< frame::XController > xController; if (aTmp >>= xController) { @@ -2845,8 +2845,8 @@ void SAL_CALL SwXTextDocument::render( // Thus instead of throwing the exception we silently return. if (0 > nRenderer) throw IllegalArgumentException(); - if ( (bPrintProspect && size_t(nRenderer) >= m_pPrintUIOprions->GetPagePairsForProspectPrinting().size()) - || (!bPrintProspect && size_t(nRenderer) >= m_pPrintUIOprions->GetPagesToPrint().size())) + if ( (bPrintProspect && size_t(nRenderer) >= m_pPrintUIOptions->GetPagePairsForProspectPrinting().size()) + || (!bPrintProspect && size_t(nRenderer) >= m_pPrintUIOptions->GetPagesToPrint().size())) return; // the view shell should be SwView for documents PDF export @@ -2862,7 +2862,7 @@ void SAL_CALL SwXTextDocument::render( ((SwPagePreView*)pView)->GetViewShell(); } - uno::Any aAny( m_pPrintUIOprions->getValue( C2U( "RenderDevice" ) )); + uno::Any aAny( m_pPrintUIOptions->getValue( C2U( "RenderDevice" ) )); uno::Reference< awt::XDevice > xRenderDevice; aAny >>= xRenderDevice; @@ -2875,7 +2875,7 @@ void SAL_CALL SwXTextDocument::render( if(pVwSh && pOut) { - // TLPDF2DO: clean-up, need to check if only one of aOptions and m_pPrintUIOprions should be used + // TLPDF2DO: clean-up, need to check if only one of aOptions and m_pPrintUIOptions should be used SwPrtOptions aOptions( C2U( bIsPDFExport ? "PDF export" : "Printing" ) ); // get default print options @@ -2884,33 +2884,33 @@ void SAL_CALL SwXTextDocument::render( SwView::MakeOptions( NULL, aOptions, NULL, NULL, bWeb, NULL, NULL ); // get print options to use from provided properties - const rtl::OUString aPageRange = m_pPrintUIOprions->getStringValue( "PageRange", OUString() ); - const bool bFirstPage = m_pPrintUIOprions->getBoolValue( "IsFirstPage", sal_False ); - const bool bLastPage = m_pPrintUIOprions->getBoolValue( "IsLastPage", sal_False ); - bool bIsSkipEmptyPages = !m_pPrintUIOprions->IsPrintEmptyPages( bIsPDFExport ); - aOptions.bPrintGraphic = m_pPrintUIOprions->IsPrintGraphics(); - aOptions.bPrintTable = m_pPrintUIOprions->IsPrintTables(); - aOptions.bPrintDraw = m_pPrintUIOprions->IsPrintDrawings(); - aOptions.bPrintControl = m_pPrintUIOprions->getBoolValue( "PrintControls", aOptions.bPrintControl ); - aOptions.bPrintLeftPage = m_pPrintUIOprions->IsPrintLeftPages(); - aOptions.bPrintRightPage = m_pPrintUIOprions->IsPrintRigthPages(); - aOptions.bPrintPageBackground = m_pPrintUIOprions->getBoolValue( "PrintPageBackground", aOptions.bPrintPageBackground ); + const rtl::OUString aPageRange = m_pPrintUIOptions->getStringValue( "PageRange", OUString() ); + const bool bFirstPage = m_pPrintUIOptions->getBoolValue( "IsFirstPage", sal_False ); + const bool bLastPage = m_pPrintUIOptions->getBoolValue( "IsLastPage", sal_False ); + bool bIsSkipEmptyPages = !m_pPrintUIOptions->IsPrintEmptyPages( bIsPDFExport ); + aOptions.bPrintGraphic = m_pPrintUIOptions->IsPrintGraphics(); + aOptions.bPrintTable = m_pPrintUIOptions->IsPrintTables(); + aOptions.bPrintDraw = m_pPrintUIOptions->IsPrintDrawings(); + aOptions.bPrintControl = m_pPrintUIOptions->getBoolValue( "PrintControls", aOptions.bPrintControl ); + aOptions.bPrintLeftPage = m_pPrintUIOptions->IsPrintLeftPages(); + aOptions.bPrintRightPage = m_pPrintUIOptions->IsPrintRightPages(); + aOptions.bPrintPageBackground = m_pPrintUIOptions->getBoolValue( "PrintPageBackground", aOptions.bPrintPageBackground ); aOptions.bPrintEmptyPages = !bIsSkipEmptyPages; // bUpdateFieldsInPrinting <-- not set here // TLPDF: TODO: remove this from SwPrintData?? Get rid of SwPrtOptions?? - aOptions.bPaperFromSetup = m_pPrintUIOprions->getBoolValue( "PrintPaperFromSetup", aOptions.bPaperFromSetup ); - aOptions.bPrintReverse = m_pPrintUIOprions->getBoolValue( "PrintReversed", aOptions.bPrintReverse ); - aOptions.bPrintProspect = m_pPrintUIOprions->getBoolValue( "PrintProspect", aOptions.bPrintProspect ); - aOptions.bPrintProspect_RTL = m_pPrintUIOprions->getIntValue( "PrintProspectRTL", aOptions.bPrintProspect_RTL ) ? true : false; + aOptions.bPaperFromSetup = m_pPrintUIOptions->getBoolValue( "PrintPaperFromSetup", aOptions.bPaperFromSetup ); + aOptions.bPrintReverse = m_pPrintUIOptions->getBoolValue( "PrintReversed", aOptions.bPrintReverse ); + aOptions.bPrintProspect = m_pPrintUIOptions->getBoolValue( "PrintProspect", aOptions.bPrintProspect ); + aOptions.bPrintProspect_RTL = m_pPrintUIOptions->getIntValue( "PrintProspectRTL", aOptions.bPrintProspect_RTL ) ? true : false; // bPrintSingleJobs <-- not set here // TLPDF: TODO: remove this from SwPrintData?? Get rid of SwPrtOptions?? // bModified <-- not set here // TLPDF: TODO: remove this from SwPrintData?? Get rid of SwPrtOptions?? - aOptions.bPrintBlackFont = m_pPrintUIOprions->getBoolValue( "PrintBlackFonts", aOptions.bPrintBlackFont ); - aOptions.bPrintHiddenText = m_pPrintUIOprions->getBoolValue( "PrintHiddenText", aOptions.bPrintHiddenText ); - aOptions.bPrintTextPlaceholder = m_pPrintUIOprions->getBoolValue( "PrintTextPlaceholder", aOptions.bPrintTextPlaceholder ); - aOptions.nPrintPostIts = static_cast< sal_Int16 >(m_pPrintUIOprions->getIntValue( "PrintAnnotationMode", aOptions.nPrintPostIts )); + aOptions.bPrintBlackFont = m_pPrintUIOptions->getBoolValue( "PrintBlackFonts", aOptions.bPrintBlackFont ); + aOptions.bPrintHiddenText = m_pPrintUIOptions->getBoolValue( "PrintHiddenText", aOptions.bPrintHiddenText ); + aOptions.bPrintTextPlaceholder = m_pPrintUIOptions->getBoolValue( "PrintTextPlaceholder", aOptions.bPrintTextPlaceholder ); + aOptions.nPrintPostIts = static_cast< sal_Int16 >(m_pPrintUIOptions->getIntValue( "PrintAnnotationMode", aOptions.nPrintPostIts )); //! needs to be set after MakeOptions since the assingment operation in that //! function will destroy this pointer - aOptions.SetPrintUIOptions( m_pPrintUIOprions ); + aOptions.SetPrintUIOptions( m_pPrintUIOptions ); Range aRange( nRenderer+1, nRenderer+1 ); MultiSelection aPages( aRange ); @@ -2980,7 +2980,7 @@ void SAL_CALL SwXTextDocument::render( m_pHiddenViewFrame = 0; } aOptions.SetPrintUIOptions( NULL ); - delete m_pPrintUIOprions, m_pPrintUIOprions = NULL; + delete m_pPrintUIOptions, m_pPrintUIOptions = NULL; } } } -- cgit From 2cca472c56275721e42111c72cbfa1a2a989c297 Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Mon, 17 Aug 2009 09:30:18 +0000 Subject: #i101242# new print UI --- sw/source/core/view/vprint.cxx | 4 ---- 1 file changed, 4 deletions(-) (limited to 'sw') diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index 351f1126103c..be9067d5bde6 100644 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -979,11 +979,7 @@ void lcl_SetState( SfxProgress& rProgress, ULONG nPage, ULONG nMax, void ViewShell::CalcPagesForPrint( USHORT nMax, SfxProgress* pProgress, -<<<<<<< .mine const XubString* /*TLPDF pStr*/, ULONG /*TLPDF nMergeAct*/, ULONG /*TLPDF nMergeCnt*/ ) -======= - const XubString* /*pStr*/, ULONG /*nMergeAct*/, ULONG /*nMergeCnt*/ ) ->>>>>>> .r275036 { SET_CURR_SHELL( this ); -- cgit From 50d636b6013f7429b28147531f27052e5e9ca6e8 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Mon, 17 Aug 2009 09:35:25 +0000 Subject: fixe merge conflict --- sw/source/core/view/vprint.cxx | 66 +++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 33 deletions(-) (limited to 'sw') diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index be9067d5bde6..833ecb721657 100644 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -443,52 +443,52 @@ bool SwPrintUIOptions::IsPrintRightPages() const { // take care of different property names for the option. // for compatibility the old name should win - + sal_Int64 nLRPages = getIntValue( "PrintLeftRightPages", 0 /* default: all */ ); bool bRes = nLRPages == 0 || nLRPages == 2; bRes = getBoolValue( "PrintRightPages", bRes /* <- default value if property is not found */ ); return bRes; } -bool SwPrintUIOptions::IsPrintEmptyPages( bool bIsPDFExport ) const -{ +bool SwPrintUIOptions::IsPrintEmptyPages( bool bIsPDFExport ) const +{ // take care of different property names for the option. - - bool bRes = bIsPDFExport ? - !getBoolValue( "IsSkipEmptyPages", sal_True ) : - getBoolValue( "PrintEmptyPages", sal_True ); - return bRes; -} - -bool SwPrintUIOptions::IsPrintTables() const -{ + + bool bRes = bIsPDFExport ? + !getBoolValue( "IsSkipEmptyPages", sal_True ) : + getBoolValue( "PrintEmptyPages", sal_True ); + return bRes; +} + +bool SwPrintUIOptions::IsPrintTables() const +{ // take care of different property names for the option. // for compatibility the old name should win - - bool bRes = getBoolValue( "PrintTablesGraphicsAndDiagrams", sal_True ); - bRes = getBoolValue( "PrintTables", bRes ); - return bRes; -} - -bool SwPrintUIOptions::IsPrintGraphics() const -{ + + bool bRes = getBoolValue( "PrintTablesGraphicsAndDiagrams", sal_True ); + bRes = getBoolValue( "PrintTables", bRes ); + return bRes; +} + +bool SwPrintUIOptions::IsPrintGraphics() const +{ // take care of different property names for the option. // for compatibility the old name should win - - bool bRes = getBoolValue( "PrintTablesGraphicsAndDiagrams", sal_True ); - bRes = getBoolValue( "PrintGraphics", bRes ); - return bRes; -} - -bool SwPrintUIOptions::IsPrintDrawings() const -{ + + bool bRes = getBoolValue( "PrintTablesGraphicsAndDiagrams", sal_True ); + bRes = getBoolValue( "PrintGraphics", bRes ); + return bRes; +} + +bool SwPrintUIOptions::IsPrintDrawings() const +{ // take care of different property names for the option. // for compatibility the old name should win - - bool bRes = getBoolValue( "PrintTablesGraphicsAndDiagrams", sal_True ); - bRes = getBoolValue( "PrintDDrawings", bRes ); - return bRes; -} + + bool bRes = getBoolValue( "PrintTablesGraphicsAndDiagrams", sal_True ); + bRes = getBoolValue( "PrintDrawings", bRes ); + return bRes; +} bool SwPrintUIOptions::processPropertiesAndCheckFormat( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& i_rNewProp ) { -- cgit From b8dae601ca02cc4baa4d2a4ace860cfafd4edc94 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Mon, 17 Aug 2009 10:08:34 +0000 Subject: add missing exceptions --- sw/source/ui/uiview/makefile.mk | 1 + 1 file changed, 1 insertion(+) (limited to 'sw') diff --git a/sw/source/ui/uiview/makefile.mk b/sw/source/ui/uiview/makefile.mk index 2aa5e12e2631..28ab2271a823 100644 --- a/sw/source/ui/uiview/makefile.mk +++ b/sw/source/ui/uiview/makefile.mk @@ -54,6 +54,7 @@ EXCEPTIONSFILES= \ $(SLO)$/uivwimp.obj \ $(SLO)$/view.obj \ $(SLO)$/view2.obj \ + $(SLO)$/viewprt.obj \ $(SLO)$/viewling.obj \ $(SLO)$/viewmdi.obj \ -- cgit From 2982901c76e611e1305d68ea4aed4ee4ef546e87 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Mon, 17 Aug 2009 14:40:01 +0000 Subject: #i92516# fix several small issues (helpids, taborder, property names) --- sw/source/core/view/vprint.cxx | 68 +++++++++++++++++++++--------------------- sw/source/ui/config/optdlg.src | 2 +- 2 files changed, 35 insertions(+), 35 deletions(-) (limited to 'sw') diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index 833ecb721657..8648c2a463d8 100644 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -314,6 +314,38 @@ SwPrintUIOptions::SwPrintUIOptions( BOOL bWeb ) : aPaperTrayOpt ); + // print range selection + vcl::PrinterOptionsHelper::UIControlOptions aPrintRangeOpt; + aPrintRangeOpt.maGroupHint = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintRange" ) ); + aPrintRangeOpt.mbInternalOnly = sal_True; + m_aUIProperties[nIdx++].Value = getSubgroupControlOpt( rtl::OUString( aLocalizedStrings.GetString( 37 ) ), + rtl::OUString(), + aPrintRangeOpt + ); + + // create a choice for the content to create + rtl::OUString aPrintRangeName( RTL_CONSTASCII_USTRINGPARAM( "PrintContent" ) ); + uno::Sequence< rtl::OUString > aChoices( 3 ); + uno::Sequence< rtl::OUString > aHelpText( 3 ); + aChoices[0] = aLocalizedStrings.GetString( 38 ); + aHelpText[0] = aLocalizedStrings.GetString( 39 ); + aChoices[1] = aLocalizedStrings.GetString( 40 ); + aHelpText[1] = aLocalizedStrings.GetString( 41 ); + aChoices[2] = aLocalizedStrings.GetString( 42 ); + aHelpText[2] = aLocalizedStrings.GetString( 43 ); + m_aUIProperties[nIdx++].Value = getChoiceControlOpt( rtl::OUString(), + aHelpText, + aPrintRangeName, + aChoices, + 0 ); + // create a an Edit dependent on "Pages" selected + vcl::PrinterOptionsHelper::UIControlOptions aPageRangeOpt( aPrintRangeName, 1, sal_True ); + m_aUIProperties[nIdx++].Value = getEditControlOpt( rtl::OUString(), + rtl::OUString(), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PageRange" ) ), + rtl::OUString(), + aPageRangeOpt + ); // print content selection vcl::PrinterOptionsHelper::UIControlOptions aContentsOpt; aContentsOpt.maGroupHint = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "JobPage" ) ); @@ -322,12 +354,12 @@ SwPrintUIOptions::SwPrintUIOptions( BOOL bWeb ) : aContentsOpt ); // create a list box for notes content - uno::Sequence< rtl::OUString > aChoices( 4 ); + aChoices.realloc( 4 ); aChoices[0] = aLocalizedStrings.GetString( 21 ); aChoices[1] = aLocalizedStrings.GetString( 22 ); aChoices[2] = aLocalizedStrings.GetString( 23 ); aChoices[3] = aLocalizedStrings.GetString( 24 ); - uno::Sequence< rtl::OUString > aHelpText( 2 ); + aHelpText.realloc( 2 ); aHelpText[0] = aLocalizedStrings.GetString( 25 ); aHelpText[1] = aLocalizedStrings.GetString( 25 ); m_aUIProperties[ nIdx++ ].Value = getChoiceControlOpt( aLocalizedStrings.GetString( 26 ), @@ -384,38 +416,6 @@ SwPrintUIOptions::SwPrintUIOptions( BOOL bWeb ) : aBrochureRTLOpt ); - // print range selection - vcl::PrinterOptionsHelper::UIControlOptions aPrintRangeOpt; - aPrintRangeOpt.maGroupHint = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintRange" ) ); - aPrintRangeOpt.mbInternalOnly = sal_True; - m_aUIProperties[nIdx++].Value = getSubgroupControlOpt( rtl::OUString( aLocalizedStrings.GetString( 37 ) ), - rtl::OUString(), - aPrintRangeOpt - ); - - // create a choice for the content to create - rtl::OUString aPrintRangeName( RTL_CONSTASCII_USTRINGPARAM( "PrintContent" ) ); - aChoices.realloc( 3 ); - aHelpText.realloc( 3 ); - aChoices[0] = aLocalizedStrings.GetString( 38 ); - aHelpText[0] = aLocalizedStrings.GetString( 39 ); - aChoices[1] = aLocalizedStrings.GetString( 40 ); - aHelpText[1] = aLocalizedStrings.GetString( 41 ); - aChoices[2] = aLocalizedStrings.GetString( 42 ); - aHelpText[2] = aLocalizedStrings.GetString( 43 ); - m_aUIProperties[nIdx++].Value = getChoiceControlOpt( rtl::OUString(), - aHelpText, - aPrintRangeName, - aChoices, - 0 ); - // create a an Edit dependent on "Pages" selected - vcl::PrinterOptionsHelper::UIControlOptions aPageRangeOpt( aPrintRangeName, 1, sal_True ); - m_aUIProperties[nIdx++].Value = getEditControlOpt( rtl::OUString(), - rtl::OUString(), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PageRange" ) ), - rtl::OUString(), - aPageRangeOpt - ); DBG_ASSERT( nIdx == nNumProps, "number of added properties is not as expected" ); } diff --git a/sw/source/ui/config/optdlg.src b/sw/source/ui/config/optdlg.src index 87bfc608ae41..0d5883390ff6 100644 --- a/sw/source/ui/config/optdlg.src +++ b/sw/source/ui/config/optdlg.src @@ -948,7 +948,7 @@ StringArray STR_PRINTOPTUI < "Specifies whether the graphics of your text document are printed"; >; < "Hidden te~xt"; >; < "Enable this option to print text that is marked as hidden."; >; - < "Text ~placeholder"; >; + < "~Text placeholder"; >; < "Enable this option to print text placeholders. Disable this option to leave the text placeholders blank in the printout."; >; < "Form control~s"; >; < "Specifies whether the form control fields of the text document are printed"; >; -- cgit From 00eb1cf049970426333503731f6102909555b484 Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Wed, 19 Aug 2009 07:32:06 +0000 Subject: #i101242# new print UI --- sw/inc/viewsh.hxx | 8 ++-- sw/source/core/view/viewpg.cxx | 17 +++++-- sw/source/core/view/vprint.cxx | 98 ++++++++++++++++++++++++----------------- sw/source/ui/dbui/dbmgr.cxx | 27 +++++++----- sw/source/ui/uiview/viewprt.cxx | 10 +++-- 5 files changed, 98 insertions(+), 62 deletions(-) (limited to 'sw') diff --git a/sw/inc/viewsh.hxx b/sw/inc/viewsh.hxx index 350a095b6a69..1e09bbde33de 100644 --- a/sw/inc/viewsh.hxx +++ b/sw/inc/viewsh.hxx @@ -96,7 +96,7 @@ class SdrPaintWindow; namespace vcl { - class PrinterController; + class OldStylePrintAdaptor; } @@ -382,11 +382,13 @@ public: // printing of a complete document for mail merge // bIsPDFExport == true is: do PDF Export (no printing!) - sal_Bool PrintOrPDFExportMM( const boost::shared_ptr< vcl::PrinterController > & rpPrinterController, + sal_Bool PrintOrPDFExportMM( vcl::OldStylePrintAdaptor &rAdaptor, + const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > &rOptions, const SwPrtOptions &rPrintData, bool bIsPDFExport = sal_False ); // printing of a complete brochure for mail merge - void PrintProspectMM( const boost::shared_ptr< vcl::PrinterController > & rpPrinterController, + void PrintProspectMM( vcl::OldStylePrintAdaptor &rAdaptor, + const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > &rOptions, const SwPrintData &rPrintData, bool bProspectRTL ); // printing for OLE 2.0 diff --git a/sw/source/core/view/viewpg.cxx b/sw/source/core/view/viewpg.cxx index fbcae6776d82..353e4483fd12 100644 --- a/sw/source/core/view/viewpg.cxx +++ b/sw/source/core/view/viewpg.cxx @@ -31,9 +31,11 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" +#include #include #include +#include #include #include #include @@ -59,6 +61,10 @@ #include #include + +using namespace ::com::sun::star; + + // OD 12.12.2002 #103492# SwPagePreviewLayout* ViewShell::PagePreviewLayout() { @@ -449,13 +455,18 @@ void ViewShell::PrintPreViewPage( SwPrtOptions& rOptions, void ViewShell::PrintProspectMM( - const boost::shared_ptr< vcl::PrinterController > & rpPrinterController, + vcl::OldStylePrintAdaptor &rAdaptor, + const uno::Sequence< beans::PropertyValue > &rOptions, /* TLPDF: this or the above ? */ const SwPrintData & rPrintData, bool bProspectRTL ) { - (void) rpPrinterController; (void) rPrintData; (void) bProspectRTL; + (void) rOptions; (void) rAdaptor; (void) rPrintData; (void) bProspectRTL; + // to be removed (not needed) +#ifdef TL_NOT_NOW /* TLPDF */ - Printer::PrintJob( rpPrinterController, JobSetup() ); + const boost::shared_ptr< vcl::PrinterController > pPrtController( &rAdaptor ); + Printer::PrintJob( pPrtController, JobSetup() ); +#endif // TL_NOT_NOW /* TLPDF */ } diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index 8648c2a463d8..30ceb9f810eb 100644 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -36,6 +36,7 @@ #include #include +#include #include #include #include @@ -54,6 +55,12 @@ #include +#include +#include + +#include + +#include #include #include #include @@ -596,13 +603,6 @@ USHORT _PostItFld::GetPageNo( MultiSelection &rMulti, BOOL bRgt, BOOL bLft, return 0; } -/****************************************************************************** - * Methode : void lcl_GetPostIts( IDocumentFieldsAccess* pIDFA, _SetGetExpFlds& ... - * Beschreibung: - * Erstellt : OK 07.11.94 10:20 - * Aenderung : - ******************************************************************************/ - void lcl_GetPostIts( IDocumentFieldsAccess* pIDFA, _SetGetExpFlds& rSrtLst ) { @@ -627,13 +627,6 @@ void lcl_GetPostIts( IDocumentFieldsAccess* pIDFA, _SetGetExpFlds& rSrtLst ) } } -/****************************************************************************** - * Methode : void lcl_FormatPostIt( IDocumentContentOperations* pIDCO, SwPaM& aPam, ... - * Beschreibung: - * Erstellt : OK 07.11.94 10:20 - * Aenderung : - ******************************************************************************/ - void lcl_FormatPostIt( IDocumentContentOperations* pIDCO, SwPaM& aPam, SwPostItField* pField, USHORT nPageNo, USHORT nLineNo ) @@ -672,13 +665,6 @@ void lcl_FormatPostIt( IDocumentContentOperations* pIDCO, SwPaM& aPam, SwPostItF pIDCO->SplitNode( *aPam.GetPoint(), false ); } -/****************************************************************************** - * Methode : void lcl_PrintPostIts( ViewShell* pPrtShell ) - * Beschreibung: - * Erstellt : OK 07.11.94 10:21 - * Aenderung : MA 10. May. 95 - ******************************************************************************/ - void lcl_PrintPostIts( ViewShell* pPrtShell, const XubString& rJobName, BOOL& rStartJob, int& rJobStartError, BOOL bReverse) @@ -739,13 +725,6 @@ void lcl_PrintPostIts( ViewShell* pPrtShell, const XubString& rJobName, #endif } -/****************************************************************************** - * Methode : void lcl_PrintPostItsEndDoc( ViewShell* pPrtShell, ... - * Beschreibung: - * Erstellt : OK 07.11.94 10:21 - * Aenderung : MA 10. May. 95 - ******************************************************************************/ - void lcl_PrintPostItsEndDoc( ViewShell* pPrtShell, _SetGetExpFlds& rPostItFields, MultiSelection &rMulti, @@ -779,13 +758,6 @@ void lcl_PrintPostItsEndDoc( ViewShell* pPrtShell, lcl_PrintPostIts( pPrtShell, rJobName, rStartJob, rJobStartError, bRev ); } -/****************************************************************************** - * Methode : void lcl_PrintPostItsEndPage( ViewShell* pPrtShell, ... - * Beschreibung: - * Erstellt : OK 07.11.94 10:22 - * Aenderung : - ******************************************************************************/ - void lcl_PrintPostItsEndPage( ViewShell* pPrtShell, _SetGetExpFlds& rPostItFields, USHORT nPageNo, MultiSelection &rMulti, @@ -1241,15 +1213,59 @@ SwDoc * ViewShell::FillPrtDoc( SwDoc *pPrtDoc, const SfxPrinter* pPrt) sal_Bool ViewShell::PrintOrPDFExportMM( - const boost::shared_ptr< vcl::PrinterController > & rpPrinterController, - const SwPrtOptions &rPrintData, /* TLPDF can't we make use of just SwPrintData only as it is the case in PrintProspect??? */ - bool bIsPDFExport ) + vcl::OldStylePrintAdaptor &/*rAdaptor*/, + const uno::Sequence< beans::PropertyValue > &/*rOptions*/, /* TLPDF: this or the above ? */ + const SwPrtOptions &/*rPrintData*/, /* TLPDF can't we make use of just SwPrintData only as it is the case in PrintProspect??? */ + bool /*bIsPDFExport*/ ) { - (void) rpPrinterController; (void) rPrintData; (void) bIsPDFExport; + return false; + // to be removed (not needed) +#ifdef TL_NOT_NOW /* TLPDF */ + (void) rPrintData; (void) bIsPDFExport; + + uno::Reference< frame::XModel > xModel( GetDoc()->GetDocShell()->GetModel() ); + uno::Reference< view::XRenderable > xTextDoc( xModel, uno::UNO_QUERY ); + if (!xModel.is() || xTextDoc.is()) + return sal_False; + + bool bRes = sal_True; + try + { + // print the whole document and not just a selection + uno::Any aSelection; + aSelection <<= xModel; + + const sal_Int32 nPages = xTextDoc->getRendererCount( aSelection, rOptions ); + for (sal_Int32 i = 0; i < nPages; ++i) + { + uno::Sequence< beans::PropertyValue > aRenderProps( xTextDoc->getRenderer( i, aSelection, rOptions ) ); + if (i == 0 || i == nPages - 1) + { + rtl::OUString aName( rtl::OUString::createFromAscii( i == 0 ? "IsFirstPage" : "IsLastPage" ) ); + const sal_Int32 nProps = aRenderProps.getLength(); + aRenderProps.realloc( nProps + 1 ); + aRenderProps[ nProps ].Name = aName; + aRenderProps[ nProps ].Value <<= sal_True; + } + rAdaptor.StartPage(); + xTextDoc->render( i, aSelection, aRenderProps ); + rAdaptor.EndPage(); + } + } + catch (uno::Exception &r) + { + (void) r; + bRes = sal_False; + } - Printer::PrintJob( rpPrinterController, JobSetup() ); - return sal_True; + if (bRes) + { + const boost::shared_ptr< vcl::PrinterController > pPrtController( &rAdaptor ); + Printer::PrintJob( pPrtController, JobSetup() ); + } + return bRes; +#endif // TL_NOT_NOW /* TLPDF */ } diff --git a/sw/source/ui/dbui/dbmgr.cxx b/sw/source/ui/dbui/dbmgr.cxx index 62fe78702d1f..7c0991bd39fe 100644 --- a/sw/source/ui/dbui/dbmgr.cxx +++ b/sw/source/ui/dbui/dbmgr.cxx @@ -881,8 +881,9 @@ SwNewDBMgr::~SwNewDBMgr() BOOL SwNewDBMgr::MergePrint( SwView& /*rView*/, SwPrtOptions& /*rOpt*/, SfxProgress& /*rProgress*/, BOOL /*bIsAPI*/ ) { - return TRUE; -#ifdef TL_NOT_NOW /*TLPDF*/ + DBG_ASSERT( 0, "not implemented" ); + return FALSE; +#ifdef TL_NOT_NOW /* TLPDF */ SwWrtShell* pSh = &rView.GetWrtShell(); //check if the doc is synchronized and contains at least one linked section BOOL bSynchronizedDoc = pSh->IsLabelDoc() && pSh->GetSectionFmtCount() > 1; @@ -990,14 +991,14 @@ BOOL SwNewDBMgr::MergePrint( SwView& /*rView*/, } if( pPrt->IsJobActive() ) { - pSh->PrintProspectMM( aPrtAdaptor, rOpt, rOpt.IsPrintProspect_RTL() ); /* TLPDF */ + pSh->PrintProspectMM( aPrtAdaptor, aViewProperties, rOpt, rOpt.IsPrintProspect_RTL() ); /* TLPDF */ bRet = TRUE; } #endif // TL_NOT_NOW /*TLPDF*/ - pSh->PrintProspectMM( pPrtController, rOpt, rOpt.IsPrintProspect_RTL() ); // TLPDF + pSh->PrintProspectMM( aPrtAdaptor, aViewProperties, rOpt, rOpt.IsPrintProspect_RTL() ); // TLPDF bRet = TRUE; // TLPDF } - else if( pSh->PrintOrPDFExportMM( pPrtController, rOpt ) /* TLPDF */ ) + else if( pSh->PrintOrPDFExportMM( aPrtAdaptor, aViewProperties, rOpt ) /* TLPDF */ ) bRet = TRUE; bMergeLock = FALSE; @@ -1046,7 +1047,7 @@ BOOL SwNewDBMgr::MergePrint( SwView& /*rView*/, } return bRet; -#endif // TL_NOT_NOW /*TLPDF*/ +#endif // TL_NOT_NOW /* TLPDF */ } /*-- 21.06.2004 09:08:16--------------------------------------------------- @@ -1054,8 +1055,9 @@ BOOL SwNewDBMgr::MergePrint( SwView& /*rView*/, BOOL SwNewDBMgr::MergePrintDocuments( SwView& /*rView*/, SwPrtOptions& /*rOpt*/, SfxProgress& /*rProgress*/, BOOL /*bIsAPI*/ ) { - return TRUE; -#ifdef TL_NOT_NOW /*TLPDF*/ + DBG_ASSERT( 0, "not implemented" ); + return FALSE; +#ifdef TL_NOT_NOW /* TLPDF */ SwWrtShell* pSh = &rView.GetWrtShell(); //check if the doc is synchronized and contains at least one linked section //merge source is already open @@ -1149,6 +1151,7 @@ BOOL SwNewDBMgr::MergePrintDocuments( SwView& /*rView*/, pAddViewProperties[0].Value <<= ::rtl::OUString( aTmp ); rView.SetAdditionalPrintOptions(aAddViewProperties); + // TLPDF: What abou this line ??? rView.SfxViewShell::Print( rProgress, bIsAPI ); // ggf Basic-Macro ausfuehren if( rOpt.IsPrintSingleJobs() && bRet ) { @@ -1161,11 +1164,11 @@ BOOL SwNewDBMgr::MergePrintDocuments( SwView& /*rView*/, { //TLPDF if( pPrt->IsJobActive() || pPrt->StartJob( rOpt.GetJobName() )) //TLPDF { - pSh->PrintProspectMM( pPrtController, rOpt, rOpt.IsPrintProspect_RTL() ); - bRet = TRUE; + pSh->PrintProspectMM( aPrtAdaptor, aAddViewProperties, rOpt, rOpt.IsPrintProspect_RTL() ); + bRet = TRUE; //TLPDF } } - else if( pSh->PrintOrPDFExportMM( pPrtController, rOpt ) /* TLPDF */ ) + else if( pSh->PrintOrPDFExportMM( aPrtAdaptor, aAddViewProperties, rOpt ) /* TLPDF */ ) bRet = TRUE; bMergeLock = FALSE; @@ -1209,7 +1212,7 @@ BOOL SwNewDBMgr::MergePrintDocuments( SwView& /*rView*/, } return bRet; -#endif // TL_NOT_NOW /*TLPDF*/ +#endif // TL_NOT_NOW /* TLPDF */ } diff --git a/sw/source/ui/uiview/viewprt.cxx b/sw/source/ui/uiview/viewprt.cxx index 9d51c50ae19e..b6f2308d9888 100644 --- a/sw/source/ui/uiview/viewprt.cxx +++ b/sw/source/ui/uiview/viewprt.cxx @@ -178,6 +178,10 @@ USHORT __EXPORT SwView::SetPrinter(SfxPrinter* pNew, USHORT nDiffFlags, bool ) ErrCode SwView::DoPrint( SfxPrinter* pPrinter, PrintDialog* pDlg, BOOL bSilent, BOOL bIsAPI ) { + (void) pPrinter; (void) pDlg; (void) bSilent; (void) bIsAPI; + DBG_ASSERT( 0, "not implemented" ); + return 0; +#ifdef TL_NOT_NOW /* TLPDF */ // First test SwWrtShell* pSh = &GetWrtShell(); SwNewDBMgr* pMgr = pSh->GetNewDBMgr(); @@ -393,16 +397,15 @@ ErrCode SwView::DoPrint( SfxPrinter* pPrinter, PrintDialog* pDlg, BOOL bSilent, { const boost::shared_ptr< Printer > pPrt( pPrinter ); // TLPDF vcl::OldStylePrintAdaptor aPrtAdaptor( pPrt ); // TLPDF - const boost::shared_ptr< vcl::PrinterController > pPrtController( &aPrtAdaptor ); if( bPrtPros ) { //TLPDF bStartJob = pPrinter->StartJob( aOpts.GetJobName() ); //TLPDF if( bStartJob ) - pSh->PrintProspectMM( pPrtController, aOpts, bPrtPros_RTL ); /* TLPDF */ + pSh->PrintProspectMM( aPrtAdaptor, aViewProperties, aOpts, bPrtPros_RTL ); /* TLPDF */ } else - bStartJob = pSh->PrintOrPDFExportMM( pPrtController, aOpts ); /*TLPDF*/ + bStartJob = pSh->PrintOrPDFExportMM( aPrtAdaptor, aViewProperties, aOpts ); /*TLPDF*/ if ( bBrowse ) { @@ -444,6 +447,7 @@ ErrCode SwView::DoPrint( SfxPrinter* pPrinter, PrintDialog* pDlg, BOOL bSilent, //TLPDF pProgress->DeleteOnEndPrint(); //TLPDF pPrinter->EndJob(); return pPrinter->GetError(); +#endif // TL_NOT_NOW /* TLPDF */ } -- cgit From 9e095aec061c14b180f88bd5d7b2ea6bef19d4f9 Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Fri, 21 Aug 2009 06:14:34 +0000 Subject: #i101242# new print UI in sw --- sw/inc/doc.hxx | 7 +- sw/inc/printdata.hxx | 73 ++++++--- sw/source/core/doc/doc.cxx | 254 ++++++++++++++++++++++++++++++- sw/source/core/view/vprint.cxx | 333 +++++++++-------------------------------- sw/source/ui/uno/unotxdoc.cxx | 81 +++++----- 5 files changed, 423 insertions(+), 325 deletions(-) (limited to 'sw') diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index d2ec00c8ad0c..b9726a08ee4b 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -219,6 +219,7 @@ class SwChartLockController_Helper; class IGrammarContact; class SwPrintData; class SwPageFrm; +class SwViewOption; namespace sw { namespace mark { class MarkManager; @@ -1336,9 +1337,11 @@ public: // get the set of printable pages for the XRenderable API by // evaluating the respective settings (see implementation) - void CalculatePagesForPrinting( bool bIsPDFExport, SwPrintUIOptions &rOptions, + void CalculatePagesForPrinting( /* out */ SwPrintUIOptions &rOptions, bool bIsPDFExport, sal_Int32 nDocPageCount ); - void CalculatePagePairsForProspectPrinting( SwPrintUIOptions &rOptions, + void UpdatePagesForPrintingWithPostItData( /* out */ SwPrintUIOptions &rOptions, bool bIsPDFExport, + sal_Int32 nDocPageCount ); + void CalculatePagePairsForProspectPrinting( /* out */ SwPrintUIOptions &rOptions, sal_Int32 nDocPageCount ); sal_uInt16 GetPageCount() const; diff --git a/sw/inc/printdata.hxx b/sw/inc/printdata.hxx index 3ff07102733a..ed463a6cb28c 100644 --- a/sw/inc/printdata.hxx +++ b/sw/inc/printdata.hxx @@ -41,6 +41,12 @@ #include class SwPageFrm; +class SwDoc; +class ViewShell; +class _SetGetExpFlds; +class SwViewOption; +class OutputDevice; + //////////////////////////////////////////////////////////// @@ -51,16 +57,28 @@ class SwPrintUIOptions : public vcl::PrinterOptionsHelper // pages valid for printing (according to the current settings) // and their respective start frames (see getRendererCount in unotxdoc.cxx) // This set of pages does NOT depend on the 'PageRange' that is used as a printing option! - std::set< sal_Int32 > aValidPages; // the set of possible pages (see StringRangeEnumerator::getRangesFromString ) - std::map< sal_Int32, const SwPageFrm * > aValidStartFrms; // the map of start frames for those pages + std::set< sal_Int32 > m_aValidPages; // the set of possible pages (see StringRangeEnumerator::getRangesFromString ) + std::map< sal_Int32, const SwPageFrm * > m_aValidStartFrms; // the map of start frames for those pages // vector of pages and their order to be printed (duplicates and any order allowed!) // (see 'render' in unotxdoc.cxx) - std::vector< sal_Int32 > aPagesToPrint; + std::vector< sal_Int32 > m_aPagesToPrint; + + std::vector< const SwPageFrm * > m_aPostItStartFrame; // for prospect printing: the pairs of pages to be printed together on a single prospect page. // -1 indicates a half page to be left empty. - std::vector< std::pair< sal_Int32, sal_Int32 > > aPagePairs; + std::vector< std::pair< sal_Int32, sal_Int32 > > m_aPagePairs; + + rtl::OUString m_PageRange; + +public: + + // PostIt relevant data + _SetGetExpFlds * m_pPostItFields; + SwDoc * m_pPostItDoc; + ViewShell * m_pPostItShell; + public: SwPrintUIOptions( BOOL bWeb = FALSE ); @@ -68,28 +86,47 @@ public: bool processPropertiesAndCheckFormat( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& i_rNewProp ); + bool IsPrintLeftPages() const; + bool IsPrintRightPages() const; + bool IsPrintEmptyPages( bool bIsPDFExport ) const; + bool IsPrintTables() const; + bool IsPrintGraphics() const; + bool IsPrintDrawings() const; + + bool HasPostItData() const { return m_pPostItShell != 0 && m_pPostItDoc != 0 && m_pPostItShell != 0; } + void CreatePostItData( SwDoc *pDoc, const SwViewOption *pViewOpt, OutputDevice *pOutDev ); + void DeletePostItData(); + typedef std::map< sal_Int32, const SwPageFrm * > ValidStartFramesMap_t; typedef std::vector< std::pair< sal_Int32, sal_Int32 > > PagePairsVec_t; - std::set< sal_Int32 > & GetValidPagesSet() { return aValidPages; } - const std::set< sal_Int32 > & GetValidPagesSet() const { return aValidPages; } - ValidStartFramesMap_t & GetValidStartFrms() { return aValidStartFrms; } - const ValidStartFramesMap_t & GetValidStartFrms() const { return aValidStartFrms; } + std::set< sal_Int32 > & GetValidPagesSet() { return m_aValidPages; } + const std::set< sal_Int32 > & GetValidPagesSet() const { return m_aValidPages; } + ValidStartFramesMap_t & GetValidStartFrms() { return m_aValidStartFrms; } + const ValidStartFramesMap_t & GetValidStartFrms() const { return m_aValidStartFrms; } // used for 'normal' printing - std::vector< sal_Int32 > & GetPagesToPrint() { return aPagesToPrint; } - const std::vector< sal_Int32 > & GetPagesToPrint() const { return aPagesToPrint; } + // A page value of 0 as entry indicates that this page is not from the document but + // from the post-it document. (See also GetPostItStartFrame below) + std::vector< sal_Int32 > & GetPagesToPrint() { return m_aPagesToPrint; } + const std::vector< sal_Int32 > & GetPagesToPrint() const { return m_aPagesToPrint; } + + // used for 'normal' printing with post-its + // - if the vector entry will be NULL then the respective page to be printed is from + // the document. In that case use the value from GetPagesToPrint at the same index to + // get the phys. page number to be printed, and then retrieve the start frame to use + // from GetValidStartFrms. + // - If the entry is not NULL it is the start frame of the page from the post-it document + // that is to be printed + std::vector< const SwPageFrm * > & GetPostItStartFrame() { return m_aPostItStartFrame; } + const std::vector< const SwPageFrm * > & GetPostItStartFrame() const { return m_aPostItStartFrame; } // used for prospect printing only - PagePairsVec_t & GetPagePairsForProspectPrinting() { return aPagePairs; } - const PagePairsVec_t & GetPagePairsForProspectPrinting() const { return aPagePairs; } + PagePairsVec_t & GetPagePairsForProspectPrinting() { return m_aPagePairs; } + const PagePairsVec_t & GetPagePairsForProspectPrinting() const { return m_aPagePairs; } - bool IsPrintLeftPages() const; - bool IsPrintRightPages() const; - bool IsPrintEmptyPages( bool bIsPDFExport ) const; - bool IsPrintTables() const; - bool IsPrintGraphics() const; - bool IsPrintDrawings() const; + rtl::OUString GetPageRange() const { return m_PageRange; } + void SetPageRange( const rtl::OUString &rRange ) { m_PageRange = rRange; } }; diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index ca02f3e2eb30..2abd783cc9f6 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -58,6 +58,8 @@ #include #include #include +#include + #include #include #include @@ -105,6 +107,12 @@ #include #include #include +#include // _SetGetExpFld +#include // SwPostItField +#include +#include +#include + #include #include @@ -118,6 +126,8 @@ // <-- using namespace ::com::sun::star; +using ::rtl::OUString; + // Seiten-Deskriptoren SV_IMPL_PTRARR(SwPageDescs,SwPageDescPtr); @@ -990,10 +1000,132 @@ const SwDocStat& SwDoc::GetDocStat() const return *pDocStat; } +/*************************************************************************/ + + +struct _PostItFld : public _SetGetExpFld +{ + _PostItFld( const SwNodeIndex& rNdIdx, const SwTxtFld* pFld, const SwIndex* pIdx = 0 ) + : _SetGetExpFld( rNdIdx, pFld, pIdx ) {} + + USHORT GetPageNo( const StringRangeEnumerator &rRangeEnum, + const std::set< sal_Int32 > &rPossiblePages, + BOOL bRgt, BOOL bLft, + USHORT& rVirtPgNo, USHORT& rLineNo ); + + SwPostItField* GetPostIt() const + { + return (SwPostItField*) GetFld()->GetFld().GetFld(); + } +}; + + +USHORT _PostItFld::GetPageNo( + const StringRangeEnumerator &rRangeEnum, + const std::set< sal_Int32 > &rPossiblePages, + BOOL bRgt, BOOL bLft, /* TLPDF both should not be needed since rMulti should only include the correct pages as stored in GetValidPagesSet */ + /* out */ USHORT& rVirtPgNo, /* out */ USHORT& rLineNo ) +{ + //Problem: Wenn ein PostItFld in einem Node steht, der von mehr als + //einer Layout-Instanz repraesentiert wird, steht die Frage im Raum, + //ob das PostIt nur ein- oder n-mal gedruck werden soll. + //Wahrscheinlich nur einmal, als Seitennummer soll hier keine Zufaellige + //sondern die des ersten Auftretens des PostIts innerhalb des selektierten + //Bereichs ermittelt werden. + rVirtPgNo = 0; + USHORT nPos = GetCntnt(); + SwClientIter aIter( (SwModify &)GetFld()->GetTxtNode() ); + for( SwTxtFrm* pFrm = (SwTxtFrm*)aIter.First( TYPE( SwFrm )); + pFrm; pFrm = (SwTxtFrm*)aIter.Next() ) + { + if( pFrm->GetOfst() > nPos || + (pFrm->HasFollow() && pFrm->GetFollow()->GetOfst() <= nPos) ) + continue; + USHORT nPgNo = pFrm->GetPhyPageNum(); + BOOL bRight = pFrm->OnRightPage(); + if( rRangeEnum.hasValue( nPgNo, &rPossiblePages ) && + ( (bRight && bRgt) || (!bRight && bLft) ) ) + { + rLineNo = (USHORT)(pFrm->GetLineCount( nPos ) + + pFrm->GetAllLines() - pFrm->GetThisLines()); + rVirtPgNo = pFrm->GetVirtPageNum(); + return nPgNo; + } + } + return 0; +} + + +void lcl_GetPostIts( + IDocumentFieldsAccess* pIDFA, + _SetGetExpFlds& rSrtLst ) +{ + SwFieldType* pFldType = pIDFA->GetSysFldType( RES_POSTITFLD ); + DBG_ASSERT( pFldType, "kein PostItType ? "); + + if( pFldType->GetDepends() ) + { + // Modify-Object gefunden, trage alle Felder ins Array ein + SwClientIter aIter( *pFldType ); + SwClient* pLast; + const SwTxtFld* pTxtFld; + + for( pLast = aIter.First( TYPE(SwFmtFld)); pLast; pLast = aIter.Next() ) + if( 0 != ( pTxtFld = ((SwFmtFld*)pLast)->GetTxtFld() ) && + pTxtFld->GetTxtNode().GetNodes().IsDocNodes() ) + { + SwNodeIndex aIdx( pTxtFld->GetTxtNode() ); + _PostItFld* pNew = new _PostItFld( aIdx, pTxtFld ); + rSrtLst.Insert( pNew ); + } + } +} + + +static void lcl_FormatPostIt( + IDocumentContentOperations* pIDCO, + SwPaM& aPam, + SwPostItField* pField, + USHORT nPageNo, USHORT nLineNo ) +{ + static char __READONLY_DATA sTmp[] = " : "; + + DBG_ASSERT( ViewShell::GetShellRes(), "missing ShellRes" ); + + String aStr( ViewShell::GetShellRes()->aPostItPage ); + aStr.AppendAscii(sTmp); + + aStr += XubString::CreateFromInt32( nPageNo ); + aStr += ' '; + if( nLineNo ) + { + aStr += ViewShell::GetShellRes()->aPostItLine; + aStr.AppendAscii(sTmp); + aStr += XubString::CreateFromInt32( nLineNo ); + aStr += ' '; + } + aStr += ViewShell::GetShellRes()->aPostItAuthor; + aStr.AppendAscii(sTmp); + aStr += pField->GetPar1(); + aStr += ' '; + aStr += GetAppLocaleData().getDate( pField->GetDate() ); + pIDCO->Insert( aPam, aStr, true ); + + pIDCO->SplitNode( *aPam.GetPoint(), false ); + aStr = pField->GetPar2(); +#if defined( WIN ) || defined( WNT ) || defined( PM2 ) + // Bei Windows und Co alle CR rausschmeissen + aStr.EraseAllChars( '\r' ); +#endif + pIDCO->Insert( aPam, aStr, true ); + pIDCO->SplitNode( *aPam.GetPoint(), false ); + pIDCO->SplitNode( *aPam.GetPoint(), false ); +} + void SwDoc::CalculatePagesForPrinting( + /* out */ SwPrintUIOptions &rOptions, bool bIsPDFExport, - SwPrintUIOptions &rOptions, sal_Int32 nDocPageCount ) { DBG_ASSERT( pLayout, "no layout present" ); @@ -1116,6 +1248,121 @@ void SwDoc::CalculatePagesForPrinting( } } } + + + // + // now that we have identified the valid pages for printing according + // to the print settings we need to get the PageRange to use and + // use both results to get the actual pages to be printed + // (post-it settings need to be taken into account later on!) + // + + // get PageRange value to use + OUString aPageRange; + if (bIsPDFExport) + { +// TLPDF ?? m_pPrintUIOptions->getValue( C2U("Selection") ); + aPageRange = rOptions.getStringValue( "PageRange", OUString() ); + } + else + { + // PageContent : + // 0 -> print all pages + // 1 -> print range according to PageRange + // 2 -> print selection + if (1 == rOptions.getIntValue( "PrintContent", 0 )) + aPageRange = rOptions.getStringValue( "PageRange", OUString() ); + } + if (aPageRange.getLength() == 0) // empty string -> print all + { + // set page range to print to 'all pages' + aPageRange = OUString::valueOf( (sal_Int32)1 ); + aPageRange += OUString::valueOf( (sal_Unicode)'-'); + aPageRange += OUString::valueOf( nDocPageCount ); + } + rOptions.SetPageRange( aPageRange ); + + // get vector of pages to print according to PageRange and valid pages set from above + // (result may be an empty vector, for example if the range string is not correct) + StringRangeEnumerator::getRangesFromString( + aPageRange, rOptions.GetPagesToPrint(), + 1, nDocPageCount, 0, &rOptions.GetValidPagesSet() ); +} + + +void SwDoc::UpdatePagesForPrintingWithPostItData( + /* out */ SwPrintUIOptions &rOptions, + bool bIsPDFExport, + sal_Int32 nDocPageCount ) +{ + + sal_Int16 nPostItMode = (sal_Int16) rOptions.getIntValue( "PrintAnnotationMode", 0 ); + DBG_ASSERT(nPostItMode == POSTITS_NONE || rOptions.HasPostItData(), + "print post-its without post-it data?" ); + const USHORT nPostItCount = rOptions.HasPostItData() ? rOptions.m_pPostItFields->Count() : 0; + if (nPostItMode != POSTITS_NONE && nPostItCount > 0) + { + SET_CURR_SHELL( rOptions.m_pPostItShell ); + + // clear document and move to end of it + SwPaM aPam( rOptions.m_pPostItDoc->GetNodes().GetEndOfContent() ); + aPam.Move( fnMoveBackward, fnGoDoc ); + aPam.SetMark(); + aPam.Move( fnMoveForward, fnGoDoc ); + rOptions.m_pPostItDoc->Delete( aPam ); + + const StringRangeEnumerator aRangeEnum( rOptions.GetPageRange(), 1, nDocPageCount, 0 ); + + USHORT nVirtPg = 0, nLineNo = 0; + for (USHORT i = 0; i < nPostItCount; ++i) + { + _PostItFld& rPostIt = (_PostItFld&)*(*rOptions.m_pPostItFields)[ i ]; + const USHORT nPhyPageNum = rPostIt.GetPageNo( + aRangeEnum, rOptions.GetValidPagesSet(), + true /*TLPDF bRgt*/, true /*TLPDF bLft*/, nVirtPg, nLineNo ); + if (nPhyPageNum) + lcl_FormatPostIt( rOptions.m_pPostItShell->GetDoc(), aPam, + rPostIt.GetPostIt(), nVirtPg, nLineNo ); + } + + // format post-it doc to get correct number of pages + rOptions.m_pPostItShell->CalcLayout(); + const sal_Int32 nPostItDocPageCount = rOptions.m_pPostItDoc->GetPageCount(); + + // now add those post-it pages to the vector of pages to print + // or replace them if only post-its should be printed + if (nPostItMode == POSTITS_ONLY || nPostItMode == POSTITS_ENDDOC) + { + rOptions.GetPostItStartFrame().clear(); + if (nPostItMode == POSTITS_ENDDOC) + { + // set all values up to number of pages to print currently known to NULL, + // meaning none of the pages currently in the vector is from the + // post-it document, they are the documents pages. + rOptions.GetPostItStartFrame().resize( rOptions.GetPagesToPrint().size() ); + } + else if (nPostItMode == POSTITS_ONLY) + { + // no document page to be printed + rOptions.GetPagesToPrint().clear(); + } + + // now we just need to add the post-it pages to be printed to the end + // of the vector of pages to print and keep the GetPostItStartFrame + // data conform with it + sal_Int32 nPageNum = 0; + const SwPageFrm *pPageFrm = (SwPageFrm*)rOptions.m_pPostItShell->GetLayout()->Lower(); + while( pPageFrm && nPageNum < nPostItDocPageCount ) + { + DBG_ASSERT( pPageFrm, "Empty page frame. How are we going to print this?" ); + ++nPageNum; + rOptions.GetPagesToPrint().push_back( 0 ); // a page number of 0 indicates this page is from the post-it doc + rOptions.GetPostItStartFrame().push_back( pPageFrm ); + pPageFrm = (SwPageFrm*)pPageFrm->GetNext(); + } + DBG_ASSERT( nPageNum == nPostItDocPageCount, "unexpected number of pages" ); + } + } } @@ -1151,7 +1398,7 @@ void SwDoc::CalculatePagePairsForProspectPrinting( const SwPageFrm *pPageFrm = (SwPageFrm*)pLayout->Lower(); while( pPageFrm && nPageNum < nDocPageCount ) { - DBG_ASSERT( pPageFrm, "Empty page frame. How are we gpoing to print this?" ); + DBG_ASSERT( pPageFrm, "Empty page frame. How are we going to print this?" ); ++nPageNum; rValidPagesSet.insert( nPageNum ); rValidStartFrms[ nPageNum ] = pPageFrm; @@ -1281,6 +1528,9 @@ void SwDoc::CalculatePagePairsForProspectPrinting( nEPg = nEPg - nStep; } DBG_ASSERT( size_t(nCntPage) == rPagePairs.size(), "size mismatch for number of page pairs" ); + + // luckily prospect printing does not make use of post-its so far, + // thus we are done here. } diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index 30ceb9f810eb..8e647db8fff7 100644 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -75,8 +75,8 @@ #include #include #include -#include // PostItFld /-Type #include // _SetGetExpFld +#include // PostItFld /-Type #include #include #include // SwPrtOptions @@ -98,6 +98,9 @@ #define JOBSET_ERR_ISSTARTET 2 +extern void lcl_GetPostIts( IDocumentFieldsAccess* pIDFA, _SetGetExpFlds& rSrtLst ); + + using namespace ::com::sun::star; //-------------------------------------------------------------------- @@ -425,6 +428,10 @@ SwPrintUIOptions::SwPrintUIOptions( BOOL bWeb ) : DBG_ASSERT( nIdx == nNumProps, "number of added properties is not as expected" ); + + m_pPostItFields = 0; + m_pPostItDoc = 0; + m_pPostItShell = 0; } @@ -519,6 +526,35 @@ bool SwPrintUIOptions::processPropertiesAndCheckFormat( const com::sun::star::un } +void SwPrintUIOptions::CreatePostItData( SwDoc *pDoc, const SwViewOption *pViewOpt, OutputDevice *pOutDev ) +{ + m_pPostItFields = new _SetGetExpFlds; + lcl_GetPostIts( pDoc, *m_pPostItFields ); + m_pPostItDoc = new SwDoc; + + //!! Disable spell and grammar checking in the temporary document. + //!! Otherwise the grammar checker might process it and crash if we later on + //!! simply delete this document while he is still at it. + SwViewOption aViewOpt( *pViewOpt ); + aViewOpt.SetOnlineSpell( FALSE ); + + m_pPostItShell = new ViewShell( *m_pPostItDoc, 0, &aViewOpt, pOutDev ); +} + + +void SwPrintUIOptions::DeletePostItData() +{ + if (HasPostItData()) + { + m_pPostItDoc->setPrinter( 0, false, false ); //damit am echten DOC der Drucker bleibt + delete m_pPostItShell; //Nimmt das PostItDoc mit ins Grab. + delete m_pPostItFields; + m_pPostItDoc = 0; + m_pPostItShell = 0; + m_pPostItFields = 0; + } +} + /****************************************************************************** * Methode : void SetSwVisArea( ViewShell *pSh, Point aPrtOffset, ... * Beschreibung: @@ -551,255 +587,6 @@ void SetSwVisArea( ViewShell *pSh, const SwRect &rRect, BOOL /*bPDFExport*/ ) pOut->SetMapMode( aMapMode ); } -/****************************************************************************** - * Methode : struct _PostItFld : public _SetGetExpFld - * Beschreibung: Update an das PostItFeld - * Erstellt : OK 07.11.94 10:18 - * Aenderung : - ******************************************************************************/ -struct _PostItFld : public _SetGetExpFld -{ - _PostItFld( const SwNodeIndex& rNdIdx, const SwTxtFld* pFld, - const SwIndex* pIdx = 0 ) - : _SetGetExpFld( rNdIdx, pFld, pIdx ) {} - - USHORT GetPageNo( MultiSelection &rMulti, BOOL bRgt, BOOL bLft, - USHORT& rVirtPgNo, USHORT& rLineNo ); - SwPostItField* GetPostIt() const - { return (SwPostItField*) GetFld()->GetFld().GetFld(); } -}; - - - -USHORT _PostItFld::GetPageNo( MultiSelection &rMulti, BOOL bRgt, BOOL bLft, - USHORT& rVirtPgNo, USHORT& rLineNo ) -{ - //Problem: Wenn ein PostItFld in einem Node steht, der von mehr als - //einer Layout-Instanz repraesentiert wird, steht die Frage im Raum, - //ob das PostIt nur ein- oder n-mal gedruck werden soll. - //Wahrscheinlich nur einmal, als Seitennummer soll hier keine Zufaellige - //sondern die des ersten Auftretens des PostIts innerhalb des selektierten - //Bereichs ermittelt werden. - rVirtPgNo = 0; - USHORT nPos = GetCntnt(); - SwClientIter aIter( (SwModify &)GetFld()->GetTxtNode() ); - for( SwTxtFrm* pFrm = (SwTxtFrm*)aIter.First( TYPE( SwFrm )); - pFrm; pFrm = (SwTxtFrm*)aIter.Next() ) - { - if( pFrm->GetOfst() > nPos || - (pFrm->HasFollow() && pFrm->GetFollow()->GetOfst() <= nPos) ) - continue; - USHORT nPgNo = pFrm->GetPhyPageNum(); - BOOL bRight = pFrm->OnRightPage(); - if( rMulti.IsSelected( nPgNo ) && - ( (bRight && bRgt) || (!bRight && bLft) ) ) - { - rLineNo = (USHORT)(pFrm->GetLineCount( nPos ) + - pFrm->GetAllLines() - pFrm->GetThisLines()); - rVirtPgNo = pFrm->GetVirtPageNum(); - return nPgNo; - } - } - return 0; -} - - -void lcl_GetPostIts( IDocumentFieldsAccess* pIDFA, _SetGetExpFlds& rSrtLst ) -{ - SwFieldType* pFldType = pIDFA->GetSysFldType( RES_POSTITFLD ); - ASSERT( pFldType, "kein PostItType ? "); - - if( pFldType->GetDepends() ) - { - // Modify-Object gefunden, trage alle Felder ins Array ein - SwClientIter aIter( *pFldType ); - SwClient* pLast; - const SwTxtFld* pTxtFld; - - for( pLast = aIter.First( TYPE(SwFmtFld)); pLast; pLast = aIter.Next() ) - if( 0 != ( pTxtFld = ((SwFmtFld*)pLast)->GetTxtFld() ) && - pTxtFld->GetTxtNode().GetNodes().IsDocNodes() ) - { - SwNodeIndex aIdx( pTxtFld->GetTxtNode() ); - _PostItFld* pNew = new _PostItFld( aIdx, pTxtFld ); - rSrtLst.Insert( pNew ); - } - } -} - - -void lcl_FormatPostIt( IDocumentContentOperations* pIDCO, SwPaM& aPam, SwPostItField* pField, - USHORT nPageNo, USHORT nLineNo ) -{ - static char __READONLY_DATA sTmp[] = " : "; - - ASSERT( ViewShell::GetShellRes(), "missing ShellRes" ); - - String aStr( ViewShell::GetShellRes()->aPostItPage ); - aStr.AppendAscii(sTmp); - - aStr += XubString::CreateFromInt32( nPageNo ); - aStr += ' '; - if( nLineNo ) - { - aStr += ViewShell::GetShellRes()->aPostItLine; - aStr.AppendAscii(sTmp); - aStr += XubString::CreateFromInt32( nLineNo ); - aStr += ' '; - } - aStr += ViewShell::GetShellRes()->aPostItAuthor; - aStr.AppendAscii(sTmp); - aStr += pField->GetPar1(); - aStr += ' '; - aStr += GetAppLocaleData().getDate( pField->GetDate() ); - pIDCO->Insert( aPam, aStr, true ); - - pIDCO->SplitNode( *aPam.GetPoint(), false ); - aStr = pField->GetPar2(); -#if defined( WIN ) || defined( WNT ) || defined( PM2 ) - // Bei Windows und Co alle CR rausschmeissen - aStr.EraseAllChars( '\r' ); -#endif - pIDCO->Insert( aPam, aStr, true ); - pIDCO->SplitNode( *aPam.GetPoint(), false ); - pIDCO->SplitNode( *aPam.GetPoint(), false ); -} - - -void lcl_PrintPostIts( ViewShell* pPrtShell, const XubString& rJobName, - BOOL& rStartJob, int& rJobStartError, BOOL bReverse) -{ -#ifdef TL_NOT_NOW /* TLPDF ??? */ - // Formatieren und Ausdrucken - pPrtShell->CalcLayout(); - - SfxPrinter* pPrn = pPrtShell->getIDocumentDeviceAccess()->getPrinter( false ); - - //Das Druckdokument ist ein default Dokument, mithin arbeitet es auf der - //StandardSeite. - SwFrm *pPage = pPrtShell->GetLayout()->Lower(); - - SwPrtOptSave aPrtSave( pPrn ); - - pPrn->SetOrientation( ORIENTATION_PORTRAIT ); - pPrn->SetPaperBin( pPage->GetAttrSet()->GetPaperBin().GetValue() ); - - if( !rStartJob && JOBSET_ERR_DEFAULT == rJobStartError && - rJobName.Len() ) - { - if( !pPrn->IsJobActive() ) - { - rStartJob = pPrn->StartJob( rJobName ); - if( !rStartJob ) - { - rJobStartError = JOBSET_ERR_ERROR; - return; - } - } - pPrtShell->InitPrt( pPrn ); - rJobStartError = JOBSET_ERR_ISSTARTET; - } - - // Wir koennen auch rueckwaerts: - if ( bReverse ) - pPage = pPrtShell->GetLayout()->GetLastPage(); - - while( pPage ) - { - //Mag der Anwender noch?, Abbruch erst in Prt() - GetpApp()->Reschedule(); - ::SetSwVisArea( pPrtShell, pPage->Frm() ); - pPrn->StartPage(); - pPage->GetUpper()->Paint( pPage->Frm() ); -// SFX_APP()->SpoilDemoOutput( *pPrtShell->GetOut(), pPage->Frm().SVRect()); - SwPaintQueue::Repaint(); - pPrn->EndPage(); - pPage = bReverse ? pPage->GetPrev() : pPage->GetNext(); - } -#else -(void)pPrtShell; -(void)rJobName; -(void)rStartJob; -(void)rJobStartError; -(void)bReverse; -#endif -} - - -void lcl_PrintPostItsEndDoc( ViewShell* pPrtShell, - _SetGetExpFlds& rPostItFields, MultiSelection &rMulti, - const XubString& rJobName, BOOL& rStartJob, int& rJobStartError, - BOOL bRgt, BOOL bLft, BOOL bRev ) -{ - USHORT nPostIts = rPostItFields.Count(); - if( !nPostIts ) - // Keine Arbeit - return; - - SET_CURR_SHELL( pPrtShell ); - - SwDoc* pPrtDoc = pPrtShell->GetDoc(); - - // Dokument leeren und ans Dokumentende gehen - SwPaM aPam( pPrtDoc->GetNodes().GetEndOfContent() ); - aPam.Move( fnMoveBackward, fnGoDoc ); - aPam.SetMark(); - aPam.Move( fnMoveForward, fnGoDoc ); - pPrtDoc->Delete( aPam ); - - for( USHORT i = 0, nVirtPg, nLineNo; i < nPostIts; ++i ) - { - _PostItFld& rPostIt = (_PostItFld&)*rPostItFields[ i ]; - if( rPostIt.GetPageNo( rMulti, bRgt, bLft, nVirtPg, nLineNo ) ) - lcl_FormatPostIt( pPrtShell->GetDoc(), aPam, - rPostIt.GetPostIt(), nVirtPg, nLineNo ); - } - - lcl_PrintPostIts( pPrtShell, rJobName, rStartJob, rJobStartError, bRev ); -} - - -void lcl_PrintPostItsEndPage( ViewShell* pPrtShell, - _SetGetExpFlds& rPostItFields, USHORT nPageNo, MultiSelection &rMulti, - const XubString& rJobName, BOOL& rStartJob, int& rJobStartError, - BOOL bRgt, BOOL bLft, BOOL bRev ) -{ - USHORT nPostIts = rPostItFields.Count(); - if( !nPostIts ) - // Keine Arbeit - return; - - SET_CURR_SHELL( pPrtShell ); - - USHORT i = 0, nVirtPg, nLineNo; - while( ( i < nPostIts ) && - ( nPageNo != ((_PostItFld&)*rPostItFields[ i ]). - GetPageNo( rMulti,bRgt, bLft, nVirtPg, nLineNo ))) - ++i; - if(i == nPostIts) - // Nix zu drucken - return; - - SwDoc* pPrtDoc = pPrtShell->GetDoc(); - - // Dokument leeren und ans Dokumentende gehen - SwPaM aPam( pPrtDoc->GetNodes().GetEndOfContent() ); - aPam.Move( fnMoveBackward, fnGoDoc ); - aPam.SetMark(); - aPam.Move( fnMoveForward, fnGoDoc ); - pPrtDoc->Delete( aPam ); - - while( i < nPostIts ) - { - _PostItFld& rPostIt = (_PostItFld&)*rPostItFields[ i ]; - if( nPageNo == rPostIt.GetPageNo( rMulti, bRgt, bLft, nVirtPg, nLineNo ) ) - lcl_FormatPostIt( pPrtShell->GetDoc(), aPam, - rPostIt.GetPostIt(), nVirtPg, nLineNo ); - ++i; - } - lcl_PrintPostIts( pPrtShell, rJobName, rStartJob, rJobStartError, bRev ); -} - /****************************************************************************** * Methode : void ViewShell::InitPrt( Printer *pNew, OutputDevice *pPDFOut ) * Beschreibung: @@ -1375,16 +1162,26 @@ sal_Bool ViewShell::PrintOrPDFExport( #endif const sal_Int32 nPage = rPrintData.GetPrintUIOptions().GetPagesToPrint()[ nRenderer ]; /* TLPDF */ #if OSL_DEBUG_LEVEL > 1 - DBG_ASSERT( rPrintData.GetPrintUIOptions().GetValidPagesSet().count( nPage ) == 1, "nPage not valid" ); + DBG_ASSERT( nPage == 0 || rPrintData.GetPrintUIOptions().GetValidPagesSet().count( nPage ) == 1, "nPage not valid" ); #endif - const SwPrintUIOptions::ValidStartFramesMap_t &rFrms = rPrintData.GetPrintUIOptions().GetValidStartFrms(); - SwPrintUIOptions::ValidStartFramesMap_t::const_iterator aIt( rFrms.find( nPage ) ); - DBG_ASSERT( aIt != rFrms.end(), "failed to find start frame" ); - const SwPageFrm *pStPage = aIt->second; + const SwPageFrm *pStPage = 0; + if (nPage > 0) // a 'regular' page, not one from the post-it document + { + const SwPrintUIOptions::ValidStartFramesMap_t &rFrms = rPrintData.GetPrintUIOptions().GetValidStartFrms(); + SwPrintUIOptions::ValidStartFramesMap_t::const_iterator aIt( rFrms.find( nPage ) ); + DBG_ASSERT( aIt != rFrms.end(), "failed to find start frame" ); + pStPage = aIt->second; + } + else // a page from the post-its document ... + { + DBG_ASSERT( nPage == 0, "unexpected page number. 0 for post-it pages expected" ); + pStPage = rPrintData.GetPrintUIOptions().GetPostItStartFrame()[ nRenderer ]; + } + DBG_ASSERT( pStPage, "failed to get start page" ); /* TLPDF neu: end */ - // ben�tigte Seiten fuers Drucken formatieren + // benoetigte Seiten fuers Drucken formatieren pShell->CalcPagesForPrint( (USHORT)nPage, 0 /*TLPDF*/, pStr, 0, 0 /* TLPDF, there is no progressbar right now nMergeAct, nMergeCnt */ ); @@ -1435,6 +1232,7 @@ sal_Bool ViewShell::PrintOrPDFExport( _SetGetExpFlds aPostItFields; SwDoc* pPostItDoc = 0; ViewShell* pPostItShell = 0; +#ifdef TL_NOT_NOW /*TLPDF*/ if( rPrintData.nPrintPostIts != POSTITS_NONE ) { lcl_GetPostIts( pDoc, aPostItFields ); @@ -1454,6 +1252,7 @@ sal_Bool ViewShell::PrintOrPDFExport( rPrintData.bPrintRightPage, rPrintData.bPrintLeftPage, TRUE ); } +#endif // TL_NOT_NOW /*TLPDF*/ // aOldMapMode wird fuer das Drucken von Umschlaegen gebraucht. MapMode aOldMapMode; @@ -1463,11 +1262,14 @@ sal_Bool ViewShell::PrintOrPDFExport( // BOOL bSetPaperSz = FALSE; BOOL bSetPrt = FALSE; - if ( rPrintData.nPrintPostIts != POSTITS_ONLY ) +//TLPDF if ( rPrintData.nPrintPostIts != POSTITS_ONLY ) { //TLPDF while( pStPage && !bStop ) { - ::SetSwVisArea( pShell, pStPage->Frm(), bIsPDFExport ); + if (nPage == 0) // post-it page + ::SetSwVisArea( rPrintData.GetPrintUIOptions().m_pPostItShell , pStPage->Frm() ); + else + ::SetSwVisArea( pShell, pStPage->Frm(), bIsPDFExport ); // wenn wir einen Umschlag drucken wird ein Offset beachtet if( pStPage->GetFmt()->GetPoolFmtId() == RES_POOLPAGE_JAKET ) @@ -1528,6 +1330,7 @@ sal_Bool ViewShell::PrintOrPDFExport( } } +#ifdef TL_NOT_NOW /*TLPDF*/ // Wenn PostIts nach Seite gedruckt werden sollen, // jedoch Reverse eingestellt ist ... if( rPrintData.bPrintReverse && @@ -1536,16 +1339,20 @@ sal_Bool ViewShell::PrintOrPDFExport( nPage /* TLPDF nPageNo*/, aMulti, sJobName, bStartJob, nJobStartError, rPrintData.bPrintRightPage, rPrintData.bPrintLeftPage, rPrintData.bPrintReverse ); +#endif // TL_NOT_NOW /*TLPDF*/ - if( !bStartJob && JOBSET_ERR_DEFAULT == nJobStartError - && sJobName.Len() ) +// TLPDF if( !bStartJob && JOBSET_ERR_DEFAULT == nJobStartError +// TLPDF && sJobName.Len() ) { // TLPDF pShell->InitPrt( pOutDev, bIsPDFExport ? pOutDev : 0 ); pShell->InitPrt( pOutDev ); - ::SetSwVisArea( pShell, pStPage->Frm(), bIsPDFExport ); // TLPDF + if (nPage == 0) // post-it page + ::SetSwVisArea( rPrintData.GetPrintUIOptions().m_pPostItShell , pStPage->Frm() ); + else + ::SetSwVisArea( pShell, pStPage->Frm(), bIsPDFExport ); // TLPDF nJobStartError = JOBSET_ERR_ISSTARTET; } // --> FME 2005-12-12 #b6354161# Feature - Print empty pages @@ -1556,6 +1363,7 @@ sal_Bool ViewShell::PrintOrPDFExport( } SwPaintQueue::Repaint(); +#ifdef TL_NOT_NOW /*TLPDF*/ // Wenn PostIts nach Seite gedruckt werden sollen ... if( (!rPrintData.bPrintReverse) && rPrintData.nPrintPostIts == POSTITS_ENDPAGE ) @@ -1563,6 +1371,7 @@ sal_Bool ViewShell::PrintOrPDFExport( nPage /* TLPDF nPageNo */, aMulti, sJobName, bStartJob, nJobStartError, rPrintData.bPrintRightPage, rPrintData.bPrintLeftPage, rPrintData.bPrintReverse ); +#endif // TL_NOT_NOW /*TLPDF*/ } // den eventl. fuer Umschlaege modifizierte OutDevOffset wieder @@ -1573,6 +1382,7 @@ sal_Bool ViewShell::PrintOrPDFExport( } // TLPDF loop end: while( pStPage && !bStop ) } +#ifdef TL_NOT_NOW /*TLPDF*/ if (!bStop) // TLPDF: see break above { // Wenn PostIts am Dokumentenende gedruckt werden sollen, dann hier machen @@ -1592,6 +1402,7 @@ sal_Bool ViewShell::PrintOrPDFExport( //TLPDF if( bStartJob ) //TLPDF rPrintData.bJobStartet = TRUE; } // TLPDF: if (!bStop) see break above +#endif // TL_NOT_NOW /*TLPDF*/ } delete pStr; diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index aa50d3f71372..f93d3c9400ef 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -2544,6 +2544,24 @@ SwViewOptionAdjust_Impl::~SwViewOptionAdjust_Impl() /* -----------------------------23.08.02 16:00-------------------------------- ---------------------------------------------------------------------------*/ + +static OutputDevice * lcl_GetOutputDevice( const SwPrintUIOptions &rPrintUIOptions ) +{ + OutputDevice *pOut = 0; + + uno::Any aAny( rPrintUIOptions.getValue( C2U( "RenderDevice" ) )); + uno::Reference< awt::XDevice > xRenderDevice; + aAny >>= xRenderDevice; + if (xRenderDevice.is()) + { + VCLXDevice* pDevice = VCLXDevice::GetImplementation( xRenderDevice ); + pOut = pDevice ? pDevice->GetOutputDevice() : 0; + } + + return pOut; +} + + /* * GetRenderDoc: * returns the document to be rendered, usually this will be the 'regular' @@ -2656,31 +2674,9 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount( const sal_Int32 nPageCount = pDoc->GetPageCount(); - // get PageRange value to use - OUString aPageRange; - if (bIsPDFExport) - { -// TLPDF ?? m_pPrintUIOptions->getValue( C2U("Selection") ); - aPageRange = m_pPrintUIOptions->getStringValue( "PageRange", OUString() ); - } - else - { - // PageContent : - // 0 -> print all pages - // 1 -> print range according to PageRange - // 2 -> print selection - if (1 == m_pPrintUIOptions->getIntValue( "PrintContent", 0 )) - aPageRange = m_pPrintUIOptions->getStringValue( "PageRange", OUString() ); - } - if (aPageRange.getLength() == 0) // empty string -> print all - { - // set page range to print to 'all pages' - aPageRange = OUString::valueOf( (sal_Int32)1 ); - aPageRange += OUString::valueOf( (sal_Unicode)'-'); - aPageRange += OUString::valueOf( nPageCount ); - } - + // // get number of pages to be rendered + // const bool bPrintProspect = m_pPrintUIOptions->getBoolValue( "PrintProspect", false ); if (bPrintProspect) { @@ -2689,16 +2685,22 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount( } else { - // get set of valid pages (according to the current settings) + const sal_Int16 nPostItMode = (sal_Int16) m_pPrintUIOptions->getIntValue( "PrintAnnotationMode", 0 ); + if (nPostItMode != POSTITS_NONE) + { + OutputDevice *pOutDev = lcl_GetOutputDevice( *m_pPrintUIOptions ); + m_pPrintUIOptions->CreatePostItData( pDoc, pWrtShell->GetViewOptions(), pOutDev ); + } + + // get set of valid document pages (according to the current settings) // and their start frames - pDoc->CalculatePagesForPrinting( bIsPDFExport, *m_pPrintUIOptions, nPageCount ); - DBG_ASSERT( nPageCount >= 1, "valid pages count is 0! Should not happen." ); + pDoc->CalculatePagesForPrinting( *m_pPrintUIOptions, bIsPDFExport, nPageCount ); - // get vector of pages to print according to PageRange and valid pages from above - // (result may be an empty vector, for example if the range string is not correct) - StringRangeEnumerator::getRangesFromString( - aPageRange, m_pPrintUIOptions->GetPagesToPrint(), - 1, nPageCount, 0, &m_pPrintUIOptions->GetValidPagesSet() ); + if (nPostItMode != POSTITS_NONE) + { + pDoc->UpdatePagesForPrintingWithPostItData( + *m_pPrintUIOptions, bIsPDFExport, nPageCount ); + } nRet = m_pPrintUIOptions->GetPagesToPrint().size(); } @@ -2862,16 +2864,8 @@ void SAL_CALL SwXTextDocument::render( ((SwPagePreView*)pView)->GetViewShell(); } - uno::Any aAny( m_pPrintUIOptions->getValue( C2U( "RenderDevice" ) )); - uno::Reference< awt::XDevice > xRenderDevice; - aAny >>= xRenderDevice; - - OutputDevice* pOut = 0; - if (xRenderDevice.is()) - { - VCLXDevice* pDevice = VCLXDevice::GetImplementation( xRenderDevice ); - pOut = pDevice ? pDevice->GetOutputDevice() : 0; - } + // get output device to use + OutputDevice* pOut = lcl_GetOutputDevice( *m_pPrintUIOptions ); if(pVwSh && pOut) { @@ -2974,6 +2968,9 @@ void SAL_CALL SwXTextDocument::render( if (bLastPage) { + if (m_pPrintUIOptions->HasPostItData()) + m_pPrintUIOptions->DeletePostItData(); + if (m_pHiddenViewFrame) { lcl_DisposeView( m_pHiddenViewFrame, pDocShell ); -- cgit From 3d9480a5cb3ba8fb8af49731e86b2eb9d69f980c Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Fri, 21 Aug 2009 06:44:00 +0000 Subject: #i101242# new print UI in sw --- sw/source/core/doc/doc.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sw') diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index 2abd783cc9f6..78e0f2cedb3a 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -1414,7 +1414,7 @@ void SwDoc::CalculatePagePairsForProspectPrinting( // TLPDF, TODO: remove bPrintReverse, should be handled by PLs framework now //TLPDF bool bPrintReverse = rOptions.getBoolValue( C2U( "PrintReverseOrder" ), false ); // TLPDF: this one seems not to be used in prospect printing: bool bPrintEmptyPages = rOptions.getBoolValue( C2U( "PrintEmptyPages" ), false ); - bool bPrintProspect_RTL = rOptions.getIntValue( "PrintBrochureRTL", 0 ) ? true : false; + bool bPrintProspect_RTL = rOptions.getIntValue( "PrintProspectRTL", 0 ) ? true : false; // get pages for prospect printing according to the 'PageRange' // (duplicates and any order allowed!) -- cgit From 88f90d83a9a285e7739e29ecaf28f1937e3abcbf Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Fri, 21 Aug 2009 11:30:53 +0000 Subject: #i101242# new print UI in sw --- sw/inc/printdata.hxx | 2 +- sw/source/core/doc/doc.cxx | 83 +++++++++++++++++++++++++++++++++++++----- sw/source/core/view/vprint.cxx | 12 +++--- 3 files changed, 81 insertions(+), 16 deletions(-) (limited to 'sw') diff --git a/sw/inc/printdata.hxx b/sw/inc/printdata.hxx index ed463a6cb28c..d9be041ded8c 100644 --- a/sw/inc/printdata.hxx +++ b/sw/inc/printdata.hxx @@ -75,7 +75,7 @@ class SwPrintUIOptions : public vcl::PrinterOptionsHelper public: // PostIt relevant data - _SetGetExpFlds * m_pPostItFields; + _SetGetExpFlds * m_pPostItFields; // an array of "_SetGetExpFld *" sorted by page and line numbers SwDoc * m_pPostItDoc; ViewShell * m_pPostItShell; diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index 78e0f2cedb3a..9791de575914 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -114,6 +114,7 @@ #include #include +#include #include #include @@ -1086,13 +1087,23 @@ static void lcl_FormatPostIt( IDocumentContentOperations* pIDCO, SwPaM& aPam, SwPostItField* pField, + bool bNewPage, bool bIsFirstPostIt, USHORT nPageNo, USHORT nLineNo ) { static char __READONLY_DATA sTmp[] = " : "; DBG_ASSERT( ViewShell::GetShellRes(), "missing ShellRes" ); - String aStr( ViewShell::GetShellRes()->aPostItPage ); + if (bNewPage) + pIDCO->Insert( aPam, SvxFmtBreakItem( SVX_BREAK_PAGE_BEFORE, RES_BREAK ), 0 ); + else if (!bIsFirstPostIt) + { + // add an empty line between different notes + pIDCO->SplitNode( *aPam.GetPoint(), false ); + pIDCO->SplitNode( *aPam.GetPoint(), false ); + } + + String aStr( ViewShell::GetShellRes()->aPostItPage ); aStr.AppendAscii(sTmp); aStr += XubString::CreateFromInt32( nPageNo ); @@ -1118,8 +1129,6 @@ static void lcl_FormatPostIt( aStr.EraseAllChars( '\r' ); #endif pIDCO->Insert( aPam, aStr, true ); - pIDCO->SplitNode( *aPam.GetPoint(), false ); - pIDCO->SplitNode( *aPam.GetPoint(), false ); } @@ -1313,26 +1322,56 @@ void SwDoc::UpdatePagesForPrintingWithPostItData( const StringRangeEnumerator aRangeEnum( rOptions.GetPageRange(), 1, nDocPageCount, 0 ); - USHORT nVirtPg = 0, nLineNo = 0; + // For mode POSTITS_ENDPAGE: + // maps a physical page number to the page number in post-it document that holds + // the first post-it for that physical page . Needed to relate the correct start frames + // from the post-it doc to the physical page of the document + std::map< sal_Int32, sal_Int32 > aPostItStartPageNum; + + // add all post-its on valid pages within the the page range to the + // temporary post-it document. + // Since the array of post-it fileds is sorted by page and line number we will + // already get them in the correct order + USHORT nVirtPg = 0, nLineNo = 0, nLastPageNum = 0, nPhyPageNum = 0; + bool bIsFirstPostIt = true; for (USHORT i = 0; i < nPostItCount; ++i) { _PostItFld& rPostIt = (_PostItFld&)*(*rOptions.m_pPostItFields)[ i ]; - const USHORT nPhyPageNum = rPostIt.GetPageNo( + nLastPageNum = nPhyPageNum; + nPhyPageNum = rPostIt.GetPageNo( aRangeEnum, rOptions.GetValidPagesSet(), true /*TLPDF bRgt*/, true /*TLPDF bLft*/, nVirtPg, nLineNo ); if (nPhyPageNum) + { + // need to insert a page break? + // In POSTITS_ENDPAGE mode for each document page the following + // post-it page needs to start on a new page + const bool bNewPage = nPostItMode == POSTITS_ENDPAGE && + !bIsFirstPostIt && nPhyPageNum != nLastPageNum; + lcl_FormatPostIt( rOptions.m_pPostItShell->GetDoc(), aPam, - rPostIt.GetPostIt(), nVirtPg, nLineNo ); + rPostIt.GetPostIt(), bNewPage, bIsFirstPostIt, nVirtPg, nLineNo ); + bIsFirstPostIt = false; + + if (nPostItMode == POSTITS_ENDPAGE) + { + // get the correct number of current pages for the post-it document + rOptions.m_pPostItShell->CalcLayout(); + const sal_Int32 nPages = rOptions.m_pPostItDoc->GetPageCount(); + aPostItStartPageNum[ nPhyPageNum ] = nPages; + } + } } // format post-it doc to get correct number of pages rOptions.m_pPostItShell->CalcLayout(); const sal_Int32 nPostItDocPageCount = rOptions.m_pPostItDoc->GetPageCount(); - // now add those post-it pages to the vector of pages to print - // or replace them if only post-its should be printed if (nPostItMode == POSTITS_ONLY || nPostItMode == POSTITS_ENDDOC) { + // now add those post-it pages to the vector of pages to print + // or replace them if only post-its should be printed + rOptions.GetPostItStartFrame().clear(); if (nPostItMode == POSTITS_ENDDOC) { @@ -1351,7 +1390,7 @@ void SwDoc::UpdatePagesForPrintingWithPostItData( // of the vector of pages to print and keep the GetPostItStartFrame // data conform with it sal_Int32 nPageNum = 0; - const SwPageFrm *pPageFrm = (SwPageFrm*)rOptions.m_pPostItShell->GetLayout()->Lower(); + const SwPageFrm * pPageFrm = (SwPageFrm*)rOptions.m_pPostItShell->GetLayout()->Lower(); while( pPageFrm && nPageNum < nPostItDocPageCount ) { DBG_ASSERT( pPageFrm, "Empty page frame. How are we going to print this?" ); @@ -1362,6 +1401,32 @@ void SwDoc::UpdatePagesForPrintingWithPostItData( } DBG_ASSERT( nPageNum == nPostItDocPageCount, "unexpected number of pages" ); } + else if (nPostItMode == POSTITS_ENDPAGE) + { + // the next step is to find all the start frames from the post-it + // document that should be printed for a given physical page of the document + std::map< sal_Int32, std::vector< const SwPageFrm * > > aPhysPageToPostItFrames; + + // collect all post-it doc start frames in a vector + std::vector< const SwPageFrm * > aAllPostItStartFrames; + const SwPageFrm * pPageFrm = (SwPageFrm*)rOptions.m_pPostItShell->GetLayout()->Lower(); + while( pPageFrm && aAllPostItStartFrames.size() < nPostItDocPageCount ) + { + DBG_ASSERT( pPageFrm, "Empty page frame. How are we going to print this?" ); + pPageFrm = (SwPageFrm*)pPageFrm->GetNext(); + aAllPostItStartFrames.push_back( pPageFrm ); + } + DBG_ASSERT( aAllPostItStartFrames.size() == nPostItDocPageCount, + "unexpected number of frames; does not match number of pages" ); + + std::map< sal_Int32, sal_Int32 >::const_iterator aIt; + for (aIt = aPostItStartPageNum.begin(); aIt != aPostItStartPageNum.end(); ++aIt) + { + const sal_Int32 nStartPageNum = aIt->second; + std::vector< const SwPageFrm * > aStartFrames; + aPhysPageToPostItFrames[ aIt->first ] = aStartFrames; + } + } } } diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index 8e647db8fff7..168da78f51ed 100644 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -528,9 +528,9 @@ bool SwPrintUIOptions::processPropertiesAndCheckFormat( const com::sun::star::un void SwPrintUIOptions::CreatePostItData( SwDoc *pDoc, const SwViewOption *pViewOpt, OutputDevice *pOutDev ) { - m_pPostItFields = new _SetGetExpFlds; + m_pPostItFields = new _SetGetExpFlds; lcl_GetPostIts( pDoc, *m_pPostItFields ); - m_pPostItDoc = new SwDoc; + m_pPostItDoc = new SwDoc; //!! Disable spell and grammar checking in the temporary document. //!! Otherwise the grammar checker might process it and crash if we later on @@ -538,7 +538,7 @@ void SwPrintUIOptions::CreatePostItData( SwDoc *pDoc, const SwViewOption *pViewO SwViewOption aViewOpt( *pViewOpt ); aViewOpt.SetOnlineSpell( FALSE ); - m_pPostItShell = new ViewShell( *m_pPostItDoc, 0, &aViewOpt, pOutDev ); + m_pPostItShell = new ViewShell( *m_pPostItDoc, 0, &aViewOpt, pOutDev ); } @@ -549,9 +549,9 @@ void SwPrintUIOptions::DeletePostItData() m_pPostItDoc->setPrinter( 0, false, false ); //damit am echten DOC der Drucker bleibt delete m_pPostItShell; //Nimmt das PostItDoc mit ins Grab. delete m_pPostItFields; - m_pPostItDoc = 0; - m_pPostItShell = 0; - m_pPostItFields = 0; + m_pPostItDoc = 0; + m_pPostItShell = 0; + m_pPostItFields = 0; } } -- cgit From 5eb7986ababc2f9f45417bd28ad2af78f29e8828 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Fri, 21 Aug 2009 13:32:05 +0000 Subject: #i92516# notes changes --- sw/source/core/doc/doc.cxx | 57 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 53 insertions(+), 4 deletions(-) (limited to 'sw') diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index 9791de575914..0f471c3c82f3 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -1095,7 +1095,10 @@ static void lcl_FormatPostIt( DBG_ASSERT( ViewShell::GetShellRes(), "missing ShellRes" ); if (bNewPage) - pIDCO->Insert( aPam, SvxFmtBreakItem( SVX_BREAK_PAGE_BEFORE, RES_BREAK ), 0 ); + { + pIDCO->Insert( aPam, SvxFmtBreakItem( SVX_BREAK_PAGE_AFTER, RES_BREAK ), 0 ); + pIDCO->SplitNode( *aPam.GetPoint(), false ); + } else if (!bIsFirstPostIt) { // add an empty line between different notes @@ -1407,25 +1410,71 @@ void SwDoc::UpdatePagesForPrintingWithPostItData( // document that should be printed for a given physical page of the document std::map< sal_Int32, std::vector< const SwPageFrm * > > aPhysPageToPostItFrames; - // collect all post-it doc start frames in a vector + // ... thus, first collect all post-it doc start frames in a vector std::vector< const SwPageFrm * > aAllPostItStartFrames; const SwPageFrm * pPageFrm = (SwPageFrm*)rOptions.m_pPostItShell->GetLayout()->Lower(); while( pPageFrm && aAllPostItStartFrames.size() < nPostItDocPageCount ) { DBG_ASSERT( pPageFrm, "Empty page frame. How are we going to print this?" ); - pPageFrm = (SwPageFrm*)pPageFrm->GetNext(); aAllPostItStartFrames.push_back( pPageFrm ); + pPageFrm = (SwPageFrm*)pPageFrm->GetNext(); } DBG_ASSERT( aAllPostItStartFrames.size() == nPostItDocPageCount, "unexpected number of frames; does not match number of pages" ); + // get a map that holds all post-it frames to be printed for a + // given physical page from the document std::map< sal_Int32, sal_Int32 >::const_iterator aIt; for (aIt = aPostItStartPageNum.begin(); aIt != aPostItStartPageNum.end(); ++aIt) { const sal_Int32 nStartPageNum = aIt->second; + DBG_ASSERT( 1 <= nStartPageNum && nStartPageNum <= nPostItDocPageCount, + "page number for first frame out of range" ); + const sal_Int32 nFrames = 1; // TLPDF2DO: get the correct number of frames std::vector< const SwPageFrm * > aStartFrames; - aPhysPageToPostItFrames[ aIt->first ] = aStartFrames; + for (sal_Int32 i = 0; i < nFrames; ++i) + { + const sal_Int32 nIdx = nStartPageNum - 1 + i; // -1 because lowest page num is 1 + DBG_ASSERT( 0 <= nIdx && nIdx < aAllPostItStartFrames.size(), + "index out of range" ); + aStartFrames.push_back( aAllPostItStartFrames[ nIdx ] ); + } + aPhysPageToPostItFrames[ aIt->first /* phys page num */ ] = aStartFrames; } + + + // ok, now that aPhysPageToPostItFrames can give the start frames for all + // post-it pages to be printed we need to merge those at the correct + // position into the GetPagesToPrint vector and build and maintain the + // GetPostItStartFrame vector as well. + // Since inserting a larger number of entries in the middle of a vector + // isn't that efficient we will create new vectors by copying the required data + std::vector< sal_Int32 > aTmpPagesToPrint; + std::vector< const SwPageFrm * > aTmpPostItStartFrames; + const size_t nNum = rOptions.GetPagesToPrint().size(); + for (size_t i = 0 ; i < nNum; ++i) + { + // add the physical page to print from the document + const sal_Int32 nPhysPage = rOptions.GetPagesToPrint()[i]; + aTmpPagesToPrint.push_back( nPhysPage ); + aTmpPostItStartFrames.push_back( NULL ); + + // add the post-it document pages to print, i.e those + // post-it pages that have the data for the above physical page + const std::vector< const SwPageFrm * > &rPostItFrames = aPhysPageToPostItFrames[ nPhysPage ]; + const size_t nPostItFrames = rPostItFrames.size(); + for (size_t k = 0; k < nPostItFrames; ++k) + { + aTmpPagesToPrint.push_back( 0 ); + aTmpPostItStartFrames.push_back( rPostItFrames[k] ); + } + } + + // finally we need to assign those vectors to the resulting ones. + // swapping the data should be more efficient than assigning since + // we won't need the temporary vectors anymore + rOptions.GetPagesToPrint().swap( aTmpPagesToPrint ); + rOptions.GetPostItStartFrame().swap( aTmpPostItStartFrames ); } } } -- cgit From ff0c53640ac0a74134b625791fb48b29d90f4fcb Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Fri, 21 Aug 2009 15:30:14 +0000 Subject: resolve conflicts --- sw/inc/unotxdoc.hxx | 30 +++++++++++++++++------------- sw/source/ui/uno/unotxdoc.cxx | 20 ++++++++++++++++++++ 2 files changed, 37 insertions(+), 13 deletions(-) (limited to 'sw') diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx index 216516d0d879..67270d15d392 100644 --- a/sw/inc/unotxdoc.hxx +++ b/sw/inc/unotxdoc.hxx @@ -69,9 +69,8 @@ #include #include #include -#ifndef _COM_SUN_STAR_DOCUMENT_XDOCUMENTLANGUAGES_HPP #include -#endif +#include #include #include #include @@ -80,22 +79,22 @@ #include // helper for implementations #include -#define __IFC31 Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12, Ifc13, Ifc14, Ifc15, Ifc16, \ -Ifc17, Ifc18, Ifc19, Ifc20, Ifc21, Ifc22, Ifc23, Ifc24, Ifc25, Ifc26, Ifc27, Ifc28, Ifc29, Ifc30, Ifc31 +#define __IFC32 Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12, Ifc13, Ifc14, Ifc15, Ifc16, \ +Ifc17, Ifc18, Ifc19, Ifc20, Ifc21, Ifc22, Ifc23, Ifc24, Ifc25, Ifc26, Ifc27, Ifc28, Ifc29, Ifc30, Ifc31, Ifc32 -#define __CLASS_IFC31 class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, \ +#define __CLASS_IFC32 class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, \ class Ifc8, class Ifc9, class Ifc10, class Ifc11, class Ifc12, class Ifc13, class Ifc14, class Ifc15, class Ifc16, \ class Ifc17, class Ifc18, class Ifc19, class Ifc20, class Ifc21, class Ifc22, class Ifc23, class Ifc24,\ -class Ifc25, class Ifc26, class Ifc27, class Ifc28, class Ifc29, class Ifc30, class Ifc31 +class Ifc25, class Ifc26, class Ifc27, class Ifc28, class Ifc29, class Ifc30, class Ifc31 , class Ifc32 -#define __PUBLIC_IFC31 public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9, public Ifc10, public Ifc11, public Ifc12, \ +#define __PUBLIC_IFC32 public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9, public Ifc10, public Ifc11, public Ifc12, \ public Ifc13, public Ifc14, public Ifc15, public Ifc16, public Ifc17, public Ifc18, \ public Ifc19, public Ifc20, public Ifc21, public Ifc22, public Ifc23, public Ifc24, \ public Ifc25, public Ifc26, public Ifc27, public Ifc28, public Ifc29, public Ifc30, \ -public Ifc31 +public Ifc31, public Ifc32 #include #include -#define __IFC_EX_TYPE_INIT31( class_cast ) \ +#define __IFC_EX_TYPE_INIT32( class_cast ) \ __IFC_EX_TYPE_INIT( class_cast, 1 ), __IFC_EX_TYPE_INIT( class_cast, 2 ), \ __IFC_EX_TYPE_INIT( class_cast, 3 ), __IFC_EX_TYPE_INIT( class_cast, 4 ), \ __IFC_EX_TYPE_INIT( class_cast, 5 ), __IFC_EX_TYPE_INIT( class_cast, 6 ), \ @@ -111,12 +110,12 @@ public Ifc31 __IFC_EX_TYPE_INIT( class_cast, 25 ), __IFC_EX_TYPE_INIT( class_cast, 26 ), \ __IFC_EX_TYPE_INIT( class_cast, 27 ), __IFC_EX_TYPE_INIT( class_cast, 28 ), \ __IFC_EX_TYPE_INIT( class_cast, 29 ), __IFC_EX_TYPE_INIT( class_cast, 30 ), \ - __IFC_EX_TYPE_INIT( class_cast, 31) + __IFC_EX_TYPE_INIT( class_cast, 31 ), __IFC_EX_TYPE_INIT( class_cast, 32) #include -__DEF_IMPLHELPER_EX( 31 ) +__DEF_IMPLHELPER_EX( 32 ) -namespace css = ::com::sun::star; +namespace css = ::com::sun::star; class SwDoc; class SwDocShell; @@ -137,7 +136,7 @@ SV_DECL_PTRARR(ActionContextArr, UnoActionContextPtr, 4, 4) ******************************************************************************/ -typedef cppu::WeakImplHelper31 +typedef cppu::WeakImplHelper32 < css::text::XTextDocument, css::text::XLineNumberingProperties, @@ -170,6 +169,7 @@ typedef cppu::WeakImplHelper31 css::xforms::XFormsSupplier, css::text::XFlatParagraphIteratorProvider, css::document::XDocumentLanguages + css::util::XCloneable > SwXTextDocumentBaseClass; @@ -409,6 +409,10 @@ public: // css::text::XFlatParagraphIteratorProvider: virtual css::uno::Reference< css::text::XFlatParagraphIterator > SAL_CALL getFlatParagraphIterator(::sal_Int32 nTextMarkupType, sal_Bool bAutomatic ) throw (css::uno::RuntimeException); + // ::com::sun::star::util::XCloneable + virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL createClone( ) throw (::com::sun::star::uno::RuntimeException); + + // void Invalidate(); void Reactivate(SwDocShell* pNewDocShell); diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index f93d3c9400ef..83d03bbbea8f 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -3002,7 +3002,27 @@ uno::Reference< text::XFlatParagraphIterator > SAL_CALL SwXTextDocument::getFlat { return new SwXFlatParagraphIterator( *pDocShell->GetDoc(), nTextMarkupType, bAutomatic ); } +/*-- 07.05.2009 09:21:12--------------------------------------------------- + -----------------------------------------------------------------------*/ +uno::Reference< util::XCloneable > SwXTextDocument::createClone( ) throw (uno::RuntimeException) +{ + ::vos::OGuard aGuard(Application::GetSolarMutex()); + if(!IsValid()) + throw RuntimeException(); + //create a new document - hidden - copy the storage and return it + SwDoc* pCopyDoc = pDocShell->GetDoc()->CreateCopy(); + SfxObjectShell* pShell = new SwDocShell( pCopyDoc, SFX_CREATE_MODE_STANDARD ); + pShell->DoInitNew(); + + uno::Reference< embed::XStorage > xSourceStorage = getDocumentStorage(); + uno::Reference< frame::XModel > xNewModel = pShell->GetModel(); + //copy this storage + uno::Reference< document::XStorageBasedDocument > xStorageDoc( xNewModel, uno::UNO_QUERY ); + uno::Reference< embed::XStorage > xNewStorage = xStorageDoc->getDocumentStorage(); + xSourceStorage->copyToStorage( xNewStorage ); + return uno::Reference< util::XCloneable >( xNewModel, UNO_QUERY ); +} /* -----------------------------20.06.00 09:54-------------------------------- ---------------------------------------------------------------------------*/ -- cgit From 1fc2beb42390e44b04d933db3df5c0db792350e8 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Sat, 22 Aug 2009 08:55:14 +0000 Subject: #i92516# make compile --- sw/source/core/doc/doc.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'sw') diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index 572fbeb5cc7f..e09fc5a84888 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -110,7 +110,7 @@ #include // _SetGetExpFld #include // SwPostItField #include -#include +#include #include #include @@ -1304,7 +1304,7 @@ void SwDoc::CalculatePagesForPrinting( void SwDoc::UpdatePagesForPrintingWithPostItData( /* out */ SwPrintUIOptions &rOptions, - bool bIsPDFExport, + bool /*bIsPDFExport*/, sal_Int32 nDocPageCount ) { @@ -1413,7 +1413,7 @@ void SwDoc::UpdatePagesForPrintingWithPostItData( // ... thus, first collect all post-it doc start frames in a vector std::vector< const SwPageFrm * > aAllPostItStartFrames; const SwPageFrm * pPageFrm = (SwPageFrm*)rOptions.m_pPostItShell->GetLayout()->Lower(); - while( pPageFrm && aAllPostItStartFrames.size() < nPostItDocPageCount ) + while( pPageFrm && aAllPostItStartFrames.size() < size_t(nPostItDocPageCount) ) { DBG_ASSERT( pPageFrm, "Empty page frame. How are we going to print this?" ); aAllPostItStartFrames.push_back( pPageFrm ); -- cgit From d428cc7df23f37115463419ead90af99395a7456 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Sat, 22 Aug 2009 09:03:24 +0000 Subject: make compile --- sw/source/core/doc/doc.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sw') diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index e09fc5a84888..703cb740e99a 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -1419,7 +1419,7 @@ void SwDoc::UpdatePagesForPrintingWithPostItData( aAllPostItStartFrames.push_back( pPageFrm ); pPageFrm = (SwPageFrm*)pPageFrm->GetNext(); } - DBG_ASSERT( aAllPostItStartFrames.size() == nPostItDocPageCount, + DBG_ASSERT( aAllPostItStartFrames.size() == size_t(nPostItDocPageCount), "unexpected number of frames; does not match number of pages" ); // get a map that holds all post-it frames to be printed for a @@ -1435,7 +1435,7 @@ void SwDoc::UpdatePagesForPrintingWithPostItData( for (sal_Int32 i = 0; i < nFrames; ++i) { const sal_Int32 nIdx = nStartPageNum - 1 + i; // -1 because lowest page num is 1 - DBG_ASSERT( 0 <= nIdx && nIdx < aAllPostItStartFrames.size(), + DBG_ASSERT( 0 <= nIdx && size_t(nIdx) < aAllPostItStartFrames.size(), "index out of range" ); aStartFrames.push_back( aAllPostItStartFrames[ nIdx ] ); } -- cgit From 8e24d60a844f03e6ff664a5c5ceddfbd95cd75d7 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Sat, 22 Aug 2009 10:11:49 +0000 Subject: make compile --- sw/inc/unotxdoc.hxx | 2 +- sw/source/core/view/vprint.cxx | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'sw') diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx index 67270d15d392..19b32df6c255 100644 --- a/sw/inc/unotxdoc.hxx +++ b/sw/inc/unotxdoc.hxx @@ -168,7 +168,7 @@ typedef cppu::WeakImplHelper32 css::view::XRenderable, css::xforms::XFormsSupplier, css::text::XFlatParagraphIteratorProvider, - css::document::XDocumentLanguages + css::document::XDocumentLanguages, css::util::XCloneable > SwXTextDocumentBaseClass; diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index b2f33dd5a152..1e60f6783b56 100644 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -529,8 +529,8 @@ bool SwPrintUIOptions::processPropertiesAndCheckFormat( const com::sun::star::un void SwPrintUIOptions::CreatePostItData( SwDoc *pDoc, const SwViewOption *pViewOpt, OutputDevice *pOutDev ) { m_pPostItFields = new _SetGetExpFlds; - lcl_GetPostIts( pDoc, *m_pPostItFields ); - m_pPostItDoc = new SwDoc; + lcl_GetPostIts( pDoc, *m_pPostItFields ); + m_pPostItDoc = new SwDoc; //!! Disable spell and grammar checking in the temporary document. //!! Otherwise the grammar checker might process it and crash if we later on @@ -538,7 +538,7 @@ void SwPrintUIOptions::CreatePostItData( SwDoc *pDoc, const SwViewOption *pViewO SwViewOption aViewOpt( *pViewOpt ); aViewOpt.SetOnlineSpell( FALSE ); - m_pPostItShell = new ViewShell( *m_pPostItDoc, 0, &aViewOpt, pOutDev ); + m_pPostItShell = new ViewShell( *m_pPostItDoc, 0, &aViewOpt, pOutDev ); } @@ -1200,7 +1200,7 @@ sal_Bool ViewShell::PrintOrPDFExport( if( /*!pShell->Imp()->IsStopOutDev() && */ ( bIsPDFExport || rPrintData.GetJobName().Len() /*TLPDF|| pOutDev->IsJobActive()*/) ) { - BOOL bStop = FALSE; +// TLPDF BOOL bStop = FALSE; int nJobStartError = JOBSET_ERR_DEFAULT; XubString sJobName( rPrintData.GetJobName() ); @@ -1230,8 +1230,8 @@ sal_Bool ViewShell::PrintOrPDFExport( // PostitListe holen _SetGetExpFlds aPostItFields; - SwDoc* pPostItDoc = 0; - ViewShell* pPostItShell = 0; +// TLPDF SwDoc* pPostItDoc = 0; +// TLPDF ViewShell* pPostItShell = 0; #ifdef TL_NOT_NOW /*TLPDF*/ if( rPrintData.nPrintPostIts != POSTITS_NONE ) { -- cgit From f8775840347067a54bd90c906b31e5fb258293d6 Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Tue, 25 Aug 2009 13:10:30 +0000 Subject: #i101242# changes for printing of notes --- sw/inc/printdata.hxx | 18 ++++++------- sw/source/core/doc/doc.cxx | 58 ++++++++++++++++++++++-------------------- sw/source/core/view/viewpg.cxx | 2 +- sw/source/core/view/vprint.cxx | 22 ++++++++-------- 4 files changed, 53 insertions(+), 47 deletions(-) (limited to 'sw') diff --git a/sw/inc/printdata.hxx b/sw/inc/printdata.hxx index d9be041ded8c..e00ef66c977d 100644 --- a/sw/inc/printdata.hxx +++ b/sw/inc/printdata.hxx @@ -57,14 +57,14 @@ class SwPrintUIOptions : public vcl::PrinterOptionsHelper // pages valid for printing (according to the current settings) // and their respective start frames (see getRendererCount in unotxdoc.cxx) // This set of pages does NOT depend on the 'PageRange' that is used as a printing option! - std::set< sal_Int32 > m_aValidPages; // the set of possible pages (see StringRangeEnumerator::getRangesFromString ) - std::map< sal_Int32, const SwPageFrm * > m_aValidStartFrms; // the map of start frames for those pages + std::set< sal_Int32 > m_aValidPages; // the set of possible pages (see StringRangeEnumerator::getRangesFromString ) + std::map< sal_Int32, const SwPageFrm * > m_aValidStartFrames; // the map of start frames for those pages // vector of pages and their order to be printed (duplicates and any order allowed!) // (see 'render' in unotxdoc.cxx) - std::vector< sal_Int32 > m_aPagesToPrint; + std::vector< sal_Int32 > m_aPagesToPrint; - std::vector< const SwPageFrm * > m_aPostItStartFrame; + std::vector< const SwPageFrm * > m_aPostItStartFrames; // for prospect printing: the pairs of pages to be printed together on a single prospect page. // -1 indicates a half page to be left empty. @@ -102,8 +102,8 @@ public: std::set< sal_Int32 > & GetValidPagesSet() { return m_aValidPages; } const std::set< sal_Int32 > & GetValidPagesSet() const { return m_aValidPages; } - ValidStartFramesMap_t & GetValidStartFrms() { return m_aValidStartFrms; } - const ValidStartFramesMap_t & GetValidStartFrms() const { return m_aValidStartFrms; } + ValidStartFramesMap_t & GetValidStartFrames() { return m_aValidStartFrames; } + const ValidStartFramesMap_t & GetValidStartFrames() const { return m_aValidStartFrames; } // used for 'normal' printing // A page value of 0 as entry indicates that this page is not from the document but @@ -112,14 +112,14 @@ public: const std::vector< sal_Int32 > & GetPagesToPrint() const { return m_aPagesToPrint; } // used for 'normal' printing with post-its - // - if the vector entry will be NULL then the respective page to be printed is from + // - if the map entry will be NULL then the respective page to be printed is from // the document. In that case use the value from GetPagesToPrint at the same index to // get the phys. page number to be printed, and then retrieve the start frame to use // from GetValidStartFrms. // - If the entry is not NULL it is the start frame of the page from the post-it document // that is to be printed - std::vector< const SwPageFrm * > & GetPostItStartFrame() { return m_aPostItStartFrame; } - const std::vector< const SwPageFrm * > & GetPostItStartFrame() const { return m_aPostItStartFrame; } + std::vector< const SwPageFrm * > & GetPostItStartFrames() { return m_aPostItStartFrames; } + const std::vector< const SwPageFrm * > & GetPostItStartFrames() const { return m_aPostItStartFrames; } // used for prospect printing only PagePairsVec_t & GetPagePairsForProspectPrinting() { return m_aPagePairs; } diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index 703cb740e99a..2f10f585cf15 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -110,7 +110,7 @@ #include // _SetGetExpFld #include // SwPostItField #include -#include +#include #include #include @@ -1223,7 +1223,7 @@ void SwDoc::CalculatePagesForPrinting( nPageNo = nFirstPageNo; std::set< sal_Int32 > &rValidPages = rOptions.GetValidPagesSet(); - std::map< sal_Int32, const SwPageFrm * > &rValidStartFrms = rOptions.GetValidStartFrms(); + std::map< sal_Int32, const SwPageFrm * > &rValidStartFrms = rOptions.GetValidStartFrames(); rValidPages.clear(); rValidStartFrms.clear(); while ( pStPage ) @@ -1304,7 +1304,7 @@ void SwDoc::CalculatePagesForPrinting( void SwDoc::UpdatePagesForPrintingWithPostItData( /* out */ SwPrintUIOptions &rOptions, - bool /*bIsPDFExport*/, + bool bIsPDFExport, sal_Int32 nDocPageCount ) { @@ -1329,7 +1329,7 @@ void SwDoc::UpdatePagesForPrintingWithPostItData( // maps a physical page number to the page number in post-it document that holds // the first post-it for that physical page . Needed to relate the correct start frames // from the post-it doc to the physical page of the document - std::map< sal_Int32, sal_Int32 > aPostItStartPageNum; + std::map< sal_Int32, sal_Int32 > aPostItLastStartPageNum; // add all post-its on valid pages within the the page range to the // temporary post-it document. @@ -1361,7 +1361,7 @@ void SwDoc::UpdatePagesForPrintingWithPostItData( // get the correct number of current pages for the post-it document rOptions.m_pPostItShell->CalcLayout(); const sal_Int32 nPages = rOptions.m_pPostItDoc->GetPageCount(); - aPostItStartPageNum[ nPhyPageNum ] = nPages; + aPostItLastStartPageNum[ nPhyPageNum ] = nPages; } } } @@ -1375,13 +1375,13 @@ void SwDoc::UpdatePagesForPrintingWithPostItData( // now add those post-it pages to the vector of pages to print // or replace them if only post-its should be printed - rOptions.GetPostItStartFrame().clear(); + rOptions.GetPostItStartFrames().clear(); if (nPostItMode == POSTITS_ENDDOC) { // set all values up to number of pages to print currently known to NULL, // meaning none of the pages currently in the vector is from the // post-it document, they are the documents pages. - rOptions.GetPostItStartFrame().resize( rOptions.GetPagesToPrint().size() ); + rOptions.GetPostItStartFrames().resize( rOptions.GetPagesToPrint().size() ); } else if (nPostItMode == POSTITS_ONLY) { @@ -1390,7 +1390,7 @@ void SwDoc::UpdatePagesForPrintingWithPostItData( } // now we just need to add the post-it pages to be printed to the end - // of the vector of pages to print and keep the GetPostItStartFrame + // of the vector of pages to print and keep the GetValidStartFrames // data conform with it sal_Int32 nPageNum = 0; const SwPageFrm * pPageFrm = (SwPageFrm*)rOptions.m_pPostItShell->GetLayout()->Lower(); @@ -1399,7 +1399,8 @@ void SwDoc::UpdatePagesForPrintingWithPostItData( DBG_ASSERT( pPageFrm, "Empty page frame. How are we going to print this?" ); ++nPageNum; rOptions.GetPagesToPrint().push_back( 0 ); // a page number of 0 indicates this page is from the post-it doc - rOptions.GetPostItStartFrame().push_back( pPageFrm ); + DBG_ASSERT( pPageFrm, "pPageFrm is NULL!" ); + rOptions.GetPostItStartFrames().push_back( pPageFrm ); pPageFrm = (SwPageFrm*)pPageFrm->GetNext(); } DBG_ASSERT( nPageNum == nPostItDocPageCount, "unexpected number of pages" ); @@ -1411,42 +1412,47 @@ void SwDoc::UpdatePagesForPrintingWithPostItData( std::map< sal_Int32, std::vector< const SwPageFrm * > > aPhysPageToPostItFrames; // ... thus, first collect all post-it doc start frames in a vector + sal_Int32 nPostItPageNum = 0; std::vector< const SwPageFrm * > aAllPostItStartFrames; const SwPageFrm * pPageFrm = (SwPageFrm*)rOptions.m_pPostItShell->GetLayout()->Lower(); - while( pPageFrm && aAllPostItStartFrames.size() < size_t(nPostItDocPageCount) ) + while( pPageFrm && aAllPostItStartFrames.size() < nPostItDocPageCount ) { DBG_ASSERT( pPageFrm, "Empty page frame. How are we going to print this?" ); + ++nPostItPageNum; aAllPostItStartFrames.push_back( pPageFrm ); pPageFrm = (SwPageFrm*)pPageFrm->GetNext(); } - DBG_ASSERT( aAllPostItStartFrames.size() == size_t(nPostItDocPageCount), + DBG_ASSERT( aAllPostItStartFrames.size() == nPostItDocPageCount, "unexpected number of frames; does not match number of pages" ); // get a map that holds all post-it frames to be printed for a // given physical page from the document + sal_Int32 nLastStartPageNum = 0; std::map< sal_Int32, sal_Int32 >::const_iterator aIt; - for (aIt = aPostItStartPageNum.begin(); aIt != aPostItStartPageNum.end(); ++aIt) + for (aIt = aPostItLastStartPageNum.begin(); aIt != aPostItLastStartPageNum.end(); ++aIt) { - const sal_Int32 nStartPageNum = aIt->second; - DBG_ASSERT( 1 <= nStartPageNum && nStartPageNum <= nPostItDocPageCount, + const sal_Int32 nFrames = aIt->second - nLastStartPageNum; + const sal_Int32 nFirstStartPageNum = aIt == aPostItLastStartPageNum.begin() ? + 1 : aIt->second - nFrames + 1; + DBG_ASSERT( 1 <= nFirstStartPageNum && nFirstStartPageNum <= nPostItDocPageCount, "page number for first frame out of range" ); - const sal_Int32 nFrames = 1; // TLPDF2DO: get the correct number of frames std::vector< const SwPageFrm * > aStartFrames; for (sal_Int32 i = 0; i < nFrames; ++i) { - const sal_Int32 nIdx = nStartPageNum - 1 + i; // -1 because lowest page num is 1 - DBG_ASSERT( 0 <= nIdx && size_t(nIdx) < aAllPostItStartFrames.size(), + const sal_Int32 nIdx = nFirstStartPageNum - 1 + i; // -1 because lowest page num is 1 + DBG_ASSERT( 0 <= nIdx && nIdx < aAllPostItStartFrames.size(), "index out of range" ); aStartFrames.push_back( aAllPostItStartFrames[ nIdx ] ); } aPhysPageToPostItFrames[ aIt->first /* phys page num */ ] = aStartFrames; + nLastStartPageNum = aIt->second; } // ok, now that aPhysPageToPostItFrames can give the start frames for all // post-it pages to be printed we need to merge those at the correct // position into the GetPagesToPrint vector and build and maintain the - // GetPostItStartFrame vector as well. + // GetValidStartFrames vector as well. // Since inserting a larger number of entries in the middle of a vector // isn't that efficient we will create new vectors by copying the required data std::vector< sal_Int32 > aTmpPagesToPrint; @@ -1474,7 +1480,7 @@ void SwDoc::UpdatePagesForPrintingWithPostItData( // swapping the data should be more efficient than assigning since // we won't need the temporary vectors anymore rOptions.GetPagesToPrint().swap( aTmpPagesToPrint ); - rOptions.GetPostItStartFrame().swap( aTmpPostItStartFrames ); + rOptions.GetPostItStartFrames().swap( aTmpPostItStartFrames ); } } } @@ -1485,7 +1491,7 @@ void SwDoc::CalculatePagePairsForProspectPrinting( sal_Int32 nDocPageCount ) { std::set< sal_Int32 > &rValidPagesSet = rOptions.GetValidPagesSet(); - std::map< sal_Int32, const SwPageFrm * > &rValidStartFrms = rOptions.GetValidStartFrms(); + std::map< sal_Int32, const SwPageFrm * > &rValidStartFrms = rOptions.GetValidStartFrames(); std::vector< std::pair< sal_Int32, sal_Int32 > > &rPagePairs = rOptions.GetPagePairsForProspectPrinting(); rPagePairs.clear(); @@ -2367,13 +2373,11 @@ BOOL SwDoc::ConvertFieldsToText() sText.Erase(); //now remove the field and insert the string - SwPaM aPam1(*pTxtFld->GetpTxtNode(), *pTxtFld->GetStart()); - aPam1.Move(); - Insert( aPam1, sText, true );//insert first to keep the field's attributes - SwPaM aPam2(*pTxtFld->GetpTxtNode(), *pTxtFld->GetStart()); - aPam2.SetMark(); - aPam2.Move(); - DeleteAndJoin(aPam2);//remove the field + SwPaM aPam(*pTxtFld->GetpTxtNode(), *pTxtFld->GetStart()); + aPam.SetMark(); + aPam.Move(); + DeleteAndJoin(aPam); + Insert( aPam, sText, true ); } } ++aBegin; diff --git a/sw/source/core/view/viewpg.cxx b/sw/source/core/view/viewpg.cxx index 353e4483fd12..79dbdfc1f962 100644 --- a/sw/source/core/view/viewpg.cxx +++ b/sw/source/core/view/viewpg.cxx @@ -703,7 +703,7 @@ void ViewShell::PrintProspect( /* TLPDF neu: start */ const SwPageFrm *pStPage = 0; const SwPageFrm *pNxtPage = 0; - const SwPrintUIOptions::ValidStartFramesMap_t &rFrms = rPrintData.GetPrintUIOptions().GetValidStartFrms(); + const SwPrintUIOptions::ValidStartFramesMap_t &rFrms = rPrintData.GetPrintUIOptions().GetValidStartFrames(); if (rPagesToPrint.first > 0) { SwPrintUIOptions::ValidStartFramesMap_t::const_iterator aIt( rFrms.find( rPagesToPrint.first ) ); diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index 1e60f6783b56..e5250d192b80 100644 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -529,8 +529,8 @@ bool SwPrintUIOptions::processPropertiesAndCheckFormat( const com::sun::star::un void SwPrintUIOptions::CreatePostItData( SwDoc *pDoc, const SwViewOption *pViewOpt, OutputDevice *pOutDev ) { m_pPostItFields = new _SetGetExpFlds; - lcl_GetPostIts( pDoc, *m_pPostItFields ); - m_pPostItDoc = new SwDoc; + lcl_GetPostIts( pDoc, *m_pPostItFields ); + m_pPostItDoc = new SwDoc; //!! Disable spell and grammar checking in the temporary document. //!! Otherwise the grammar checker might process it and crash if we later on @@ -538,7 +538,7 @@ void SwPrintUIOptions::CreatePostItData( SwDoc *pDoc, const SwViewOption *pViewO SwViewOption aViewOpt( *pViewOpt ); aViewOpt.SetOnlineSpell( FALSE ); - m_pPostItShell = new ViewShell( *m_pPostItDoc, 0, &aViewOpt, pOutDev ); + m_pPostItShell = new ViewShell( *m_pPostItDoc, 0, &aViewOpt, pOutDev ); } @@ -823,7 +823,7 @@ SwDoc * ViewShell::CreatePrtDoc( /*Printer* pPrt,*/ SfxObjectShellRef &rDocShell // Wir bauen uns ein neues Dokument SwDoc *pPrtDoc = new SwDoc; pPrtDoc->acquire(); - pPrtDoc->SetRefForDocShell( boost::addressof(rDocShellRef) ); + pPrtDoc->SetRefForDocShell( (SfxObjectShellRef*)&(long&)rDocShellRef ); pPrtDoc->LockExpFlds(); /* TLPDF @@ -913,7 +913,7 @@ SwDoc * ViewShell::FillPrtDoc( SwDoc *pPrtDoc, const SfxPrinter* pPrt) // Wir bauen uns ein neues Dokument // SwDoc *pPrtDoc = new SwDoc; // pPrtDoc->acquire(); -// pPrtDoc->SetRefForDocShell( boost::addressof(rDocShellRef) ); +// pPrtDoc->SetRefForDocShell( (SvEmbeddedObjectRef*)&(long&)rDocShellRef ); pPrtDoc->LockExpFlds(); // Der Drucker wird uebernommen @@ -1167,15 +1167,17 @@ sal_Bool ViewShell::PrintOrPDFExport( const SwPageFrm *pStPage = 0; if (nPage > 0) // a 'regular' page, not one from the post-it document { - const SwPrintUIOptions::ValidStartFramesMap_t &rFrms = rPrintData.GetPrintUIOptions().GetValidStartFrms(); + const SwPrintUIOptions::ValidStartFramesMap_t &rFrms = rPrintData.GetPrintUIOptions().GetValidStartFrames(); SwPrintUIOptions::ValidStartFramesMap_t::const_iterator aIt( rFrms.find( nPage ) ); DBG_ASSERT( aIt != rFrms.end(), "failed to find start frame" ); + if (aIt == rFrms.end()) + return sal_False; pStPage = aIt->second; } else // a page from the post-its document ... { DBG_ASSERT( nPage == 0, "unexpected page number. 0 for post-it pages expected" ); - pStPage = rPrintData.GetPrintUIOptions().GetPostItStartFrame()[ nRenderer ]; + pStPage = rPrintData.GetPrintUIOptions().GetPostItStartFrames()[ nRenderer ]; } DBG_ASSERT( pStPage, "failed to get start page" ); /* TLPDF neu: end */ @@ -1200,7 +1202,7 @@ sal_Bool ViewShell::PrintOrPDFExport( if( /*!pShell->Imp()->IsStopOutDev() && */ ( bIsPDFExport || rPrintData.GetJobName().Len() /*TLPDF|| pOutDev->IsJobActive()*/) ) { -// TLPDF BOOL bStop = FALSE; + BOOL bStop = FALSE; int nJobStartError = JOBSET_ERR_DEFAULT; XubString sJobName( rPrintData.GetJobName() ); @@ -1230,8 +1232,8 @@ sal_Bool ViewShell::PrintOrPDFExport( // PostitListe holen _SetGetExpFlds aPostItFields; -// TLPDF SwDoc* pPostItDoc = 0; -// TLPDF ViewShell* pPostItShell = 0; + SwDoc* pPostItDoc = 0; + ViewShell* pPostItShell = 0; #ifdef TL_NOT_NOW /*TLPDF*/ if( rPrintData.nPrintPostIts != POSTITS_NONE ) { -- cgit From b457c6a75b61c58bcf72ebdf2282a164c09803d6 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Wed, 26 Aug 2009 17:36:02 +0000 Subject: remove warnings --- sw/source/core/doc/doc.cxx | 10 +++++----- sw/source/core/view/vprint.cxx | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'sw') diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index 2f10f585cf15..9a730106ea80 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -110,7 +110,7 @@ #include // _SetGetExpFld #include // SwPostItField #include -#include +#include #include #include @@ -1304,7 +1304,7 @@ void SwDoc::CalculatePagesForPrinting( void SwDoc::UpdatePagesForPrintingWithPostItData( /* out */ SwPrintUIOptions &rOptions, - bool bIsPDFExport, + bool /*bIsPDFExport*/, sal_Int32 nDocPageCount ) { @@ -1415,14 +1415,14 @@ void SwDoc::UpdatePagesForPrintingWithPostItData( sal_Int32 nPostItPageNum = 0; std::vector< const SwPageFrm * > aAllPostItStartFrames; const SwPageFrm * pPageFrm = (SwPageFrm*)rOptions.m_pPostItShell->GetLayout()->Lower(); - while( pPageFrm && aAllPostItStartFrames.size() < nPostItDocPageCount ) + while( pPageFrm && sal_Int32(aAllPostItStartFrames.size()) < nPostItDocPageCount ) { DBG_ASSERT( pPageFrm, "Empty page frame. How are we going to print this?" ); ++nPostItPageNum; aAllPostItStartFrames.push_back( pPageFrm ); pPageFrm = (SwPageFrm*)pPageFrm->GetNext(); } - DBG_ASSERT( aAllPostItStartFrames.size() == nPostItDocPageCount, + DBG_ASSERT( sal_Int32(aAllPostItStartFrames.size()) == nPostItDocPageCount, "unexpected number of frames; does not match number of pages" ); // get a map that holds all post-it frames to be printed for a @@ -1440,7 +1440,7 @@ void SwDoc::UpdatePagesForPrintingWithPostItData( for (sal_Int32 i = 0; i < nFrames; ++i) { const sal_Int32 nIdx = nFirstStartPageNum - 1 + i; // -1 because lowest page num is 1 - DBG_ASSERT( 0 <= nIdx && nIdx < aAllPostItStartFrames.size(), + DBG_ASSERT( 0 <= nIdx && nIdx < sal_Int32(aAllPostItStartFrames.size()), "index out of range" ); aStartFrames.push_back( aAllPostItStartFrames[ nIdx ] ); } diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index e5250d192b80..98c58a66121a 100644 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -1202,7 +1202,7 @@ sal_Bool ViewShell::PrintOrPDFExport( if( /*!pShell->Imp()->IsStopOutDev() && */ ( bIsPDFExport || rPrintData.GetJobName().Len() /*TLPDF|| pOutDev->IsJobActive()*/) ) { - BOOL bStop = FALSE; +// TLPDF BOOL bStop = FALSE; int nJobStartError = JOBSET_ERR_DEFAULT; XubString sJobName( rPrintData.GetJobName() ); @@ -1232,8 +1232,8 @@ sal_Bool ViewShell::PrintOrPDFExport( // PostitListe holen _SetGetExpFlds aPostItFields; - SwDoc* pPostItDoc = 0; - ViewShell* pPostItShell = 0; +// TLPDF SwDoc* pPostItDoc = 0; +// TLPDF ViewShell* pPostItShell = 0; #ifdef TL_NOT_NOW /*TLPDF*/ if( rPrintData.nPrintPostIts != POSTITS_NONE ) { -- cgit From 9420cb434f1c878d780f8f0c736d1df1339fa265 Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Thu, 27 Aug 2009 10:11:34 +0000 Subject: #101242# getRenderer fixed (adding of additional proerties; e.g. PageSize --- sw/source/ui/uno/unotxdoc.cxx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'sw') diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index 83d03bbbea8f..3b774180dd63 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -2750,11 +2750,10 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SwXTextDocument::getRenderer( if (m_pPrintUIOptions->getBoolValue( "PrintProspect", sal_False )) aPageSize = awt::Size( aPageSize.Height, aPageSize.Width ); uno::Sequence< beans::PropertyValue > aRenderer(2); - PropertyValue &rValue = aRenderer.getArray()[0]; - rValue.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "PageSize" ) ); - rValue.Value <<= aPageSize; - rValue.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "PageIncludesNonprintableArea" ) ); - rValue.Value <<= sal_False; + aRenderer[0].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "PageSize" ) ); + aRenderer[0].Value <<= aPageSize; + aRenderer[1].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "PageIncludesNonprintableArea" ) ); + aRenderer[1].Value <<= sal_True; m_pPrintUIOptions->appendPrintUIOptions( aRenderer ); -- cgit From b3211d979c4aa6e8d50d10efb94fc639a6431d6d Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Thu, 27 Aug 2009 10:13:00 +0000 Subject: #101242# minor changes --- sw/source/core/view/vprint.cxx | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'sw') diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index 98c58a66121a..7f5201c5e46d 100644 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -1268,10 +1268,9 @@ sal_Bool ViewShell::PrintOrPDFExport( { //TLPDF while( pStPage && !bStop ) { - if (nPage == 0) // post-it page - ::SetSwVisArea( rPrintData.GetPrintUIOptions().m_pPostItShell , pStPage->Frm() ); - else - ::SetSwVisArea( pShell, pStPage->Frm(), bIsPDFExport ); + ViewShell *pViewSh2 = nPage == 0 ? /* post-it page? */ + rPrintData.GetPrintUIOptions().m_pPostItShell : pShell; + ::SetSwVisArea( pViewSh2, pStPage->Frm() ); // TLPDF // wenn wir einen Umschlag drucken wird ein Offset beachtet if( pStPage->GetFmt()->GetPoolFmtId() == RES_POOLPAGE_JAKET ) @@ -1351,11 +1350,10 @@ sal_Bool ViewShell::PrintOrPDFExport( // TLPDF pShell->InitPrt( pOutDev, bIsPDFExport ? pOutDev : 0 ); pShell->InitPrt( pOutDev ); - if (nPage == 0) // post-it page - ::SetSwVisArea( rPrintData.GetPrintUIOptions().m_pPostItShell , pStPage->Frm() ); - else - ::SetSwVisArea( pShell, pStPage->Frm(), bIsPDFExport ); // TLPDF - nJobStartError = JOBSET_ERR_ISSTARTET; + ViewShell *pViewSh2 = nPage == 0 ? /* post-it page? */ + rPrintData.GetPrintUIOptions().m_pPostItShell : pShell; + ::SetSwVisArea( pViewSh2, pStPage->Frm() ); // TLPDF +// TLPDF nJobStartError = JOBSET_ERR_ISSTARTET; } // --> FME 2005-12-12 #b6354161# Feature - Print empty pages // TLPDF if ( rPrintData.bPrintEmptyPages || pStPage->Frm().Height() ) -- cgit From bc18988ff86ca83d850fba993a669ff6b8253b5a Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Thu, 27 Aug 2009 12:29:52 +0000 Subject: #101242# SwRenderData introduced; minor name changes --- sw/inc/doc.hxx | 7 +-- sw/inc/printdata.hxx | 78 ++++++++++++++++++++------------- sw/inc/unotxdoc.hxx | 4 +- sw/source/core/doc/doc.cxx | 77 +++++++++++++++++---------------- sw/source/core/view/viewpg.cxx | 16 +++---- sw/source/core/view/vprint.cxx | 95 +++++++++++++++++++++++------------------ sw/source/ui/config/optpage.cxx | 22 +++++----- sw/source/ui/config/prtopt.cxx | 12 +++--- sw/source/ui/dbui/dbmgr.cxx | 62 +++++++++++++++++++-------- sw/source/ui/inc/cfgitems.hxx | 8 ++-- sw/source/ui/uiview/view.cxx | 2 +- sw/source/ui/uiview/viewprt.cxx | 7 +-- sw/source/ui/uno/unotxdoc.cxx | 47 ++++++++++++-------- 13 files changed, 253 insertions(+), 184 deletions(-) (limited to 'sw') diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index 3f5ef569376b..52898ad0d1ad 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -218,6 +218,7 @@ class SwChartDataProvider; class SwChartLockController_Helper; class IGrammarContact; class SwPrintData; +class SwRenderData; class SwPageFrm; class SwViewOption; @@ -1339,11 +1340,11 @@ public: // get the set of printable pages for the XRenderable API by // evaluating the respective settings (see implementation) - void CalculatePagesForPrinting( /* out */ SwPrintUIOptions &rOptions, bool bIsPDFExport, + void CalculatePagesForPrinting( SwRenderData &rData, const SwPrintUIOptions &rOptions, bool bIsPDFExport, sal_Int32 nDocPageCount ); - void UpdatePagesForPrintingWithPostItData( /* out */ SwPrintUIOptions &rOptions, bool bIsPDFExport, + void UpdatePagesForPrintingWithPostItData( SwRenderData &rData, const SwPrintUIOptions &rOptions, bool bIsPDFExport, sal_Int32 nDocPageCount ); - void CalculatePagePairsForProspectPrinting( /* out */ SwPrintUIOptions &rOptions, + void CalculatePagePairsForProspectPrinting( SwRenderData &rData, const SwPrintUIOptions &rOptions, sal_Int32 nDocPageCount ); sal_uInt16 GetPageCount() const; diff --git a/sw/inc/printdata.hxx b/sw/inc/printdata.hxx index e00ef66c977d..085121060c8e 100644 --- a/sw/inc/printdata.hxx +++ b/sw/inc/printdata.hxx @@ -50,10 +50,11 @@ class OutputDevice; //////////////////////////////////////////////////////////// -class SwPrintUIOptions : public vcl::PrinterOptionsHelper +// A class that stores temporary data that is needed for rendering the document. +// Usually this data is created when 'getRendererCount' is called and +// and it is used in the 'render' function of that same interface +class SwRenderData { - OutputDevice* m_pLast; - // pages valid for printing (according to the current settings) // and their respective start frames (see getRendererCount in unotxdoc.cxx) // This set of pages does NOT depend on the 'PageRange' that is used as a printing option! @@ -79,19 +80,10 @@ public: SwDoc * m_pPostItDoc; ViewShell * m_pPostItShell; - public: - SwPrintUIOptions( BOOL bWeb = FALSE ); - ~SwPrintUIOptions(); - - bool processPropertiesAndCheckFormat( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& i_rNewProp ); + SwRenderData(); + ~SwRenderData(); - bool IsPrintLeftPages() const; - bool IsPrintRightPages() const; - bool IsPrintEmptyPages( bool bIsPDFExport ) const; - bool IsPrintTables() const; - bool IsPrintGraphics() const; - bool IsPrintDrawings() const; bool HasPostItData() const { return m_pPostItShell != 0 && m_pPostItDoc != 0 && m_pPostItShell != 0; } void CreatePostItData( SwDoc *pDoc, const SwViewOption *pViewOpt, OutputDevice *pOutDev ); @@ -133,9 +125,32 @@ public: //////////////////////////////////////////////////////////// +class SwPrintUIOptions : public vcl::PrinterOptionsHelper +{ + OutputDevice* m_pLast; + +public: + SwPrintUIOptions( BOOL bWeb = FALSE ); + ~SwPrintUIOptions(); + + bool processPropertiesAndCheckFormat( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& i_rNewProp ); + + bool IsPrintLeftPages() const; + bool IsPrintRightPages() const; + bool IsPrintEmptyPages( bool bIsPDFExport ) const; + bool IsPrintTables() const; + bool IsPrintGraphics() const; + bool IsPrintDrawings() const; +}; + + +//////////////////////////////////////////////////////////// + + class SwPrintData { - const SwPrintUIOptions * m_pPrintUIOptions; + const SwPrintUIOptions * m_pPrintUIOptions; // not owner + const SwRenderData * m_pRenderData; // not owner public: @@ -143,8 +158,8 @@ public: bPrintBlackFont, //#i81434# - printing of hidden text bPrintHiddenText, bPrintTextPlaceholder, - bPrintLeftPage, bPrintRightPage, bPrintReverse, bPrintProspect, - bPrintProspect_RTL, + bPrintLeftPages, bPrintRightPages, bPrintReverse, bPrintProspect, + bPrintProspectRTL, bPrintSingleJobs, bPaperFromSetup, // --> FME 2005-12-13 #b6354161# Print empty pages bPrintEmptyPages, @@ -159,13 +174,14 @@ public: SwPrintData() { m_pPrintUIOptions = NULL; + m_pRenderData = NULL; bPrintGraphic = bPrintTable = bPrintDraw = bPrintControl = - bPrintLeftPage = - bPrintRightPage = + bPrintLeftPages = + bPrintRightPages = bPrintPageBackground = bPrintEmptyPages = bUpdateFieldsInPrinting = sal_True; @@ -173,7 +189,7 @@ public: bPaperFromSetup = bPrintReverse = bPrintProspect = - bPrintProspect_RTL = + bPrintProspectRTL = bPrintSingleJobs = bModified = bPrintBlackFont = @@ -194,11 +210,11 @@ public: bPrintControl == rData.bPrintControl && bPrintPageBackground== rData.bPrintPageBackground&& bPrintBlackFont == rData.bPrintBlackFont && - bPrintLeftPage == rData.bPrintLeftPage && - bPrintRightPage == rData.bPrintRightPage && + bPrintLeftPages == rData.bPrintLeftPages && + bPrintRightPages == rData.bPrintRightPages && bPrintReverse == rData.bPrintReverse && bPrintProspect == rData.bPrintProspect && - bPrintProspect_RTL == rData.bPrintProspect_RTL && + bPrintProspectRTL == rData.bPrintProspectRTL && bPrintSingleJobs == rData.bPrintSingleJobs && bPaperFromSetup == rData.bPaperFromSetup && bPrintEmptyPages == rData.bPrintEmptyPages && @@ -209,22 +225,24 @@ public: bPrintTextPlaceholder == rData.bPrintTextPlaceholder; } - // Note: int the conntext where this class ist used the pointer should always be valid + // Note: in the context where this class ist used the pointers should always be valid // during the lifetime of this object const SwPrintUIOptions & GetPrintUIOptions() const { return *m_pPrintUIOptions; } - void SetPrintUIOptions( const SwPrintUIOptions *pOpt ) { m_pPrintUIOptions = pOpt; } + void SetPrintUIOptions( const SwPrintUIOptions *pOpt ) { m_pPrintUIOptions = pOpt; } + const SwRenderData & GetRenderData() const { return *m_pRenderData; } + void SetRenderData( const SwRenderData *pData ) { m_pRenderData = pData; } sal_Bool IsPrintGraphic() const { return bPrintGraphic; } sal_Bool IsPrintTable() const { return bPrintTable; } sal_Bool IsPrintDraw() const { return bPrintDraw; } sal_Bool IsPrintControl() const { return bPrintControl; } - sal_Bool IsPrintLeftPage() const { return bPrintLeftPage; } - sal_Bool IsPrintRightPage() const { return bPrintRightPage; } + sal_Bool IsPrintLeftPage() const { return bPrintLeftPages; } + sal_Bool IsPrintRightPage() const { return bPrintRightPages; } sal_Bool IsPrintReverse() const { return bPrintReverse; } sal_Bool IsPaperFromSetup() const { return bPaperFromSetup; } sal_Bool IsPrintEmptyPages() const{ return bPrintEmptyPages; } sal_Bool IsPrintProspect() const { return bPrintProspect; } - sal_Bool IsPrintProspect_RTL() const { return bPrintProspect_RTL; } + sal_Bool IsPrintProspectRTL() const { return bPrintProspectRTL; } sal_Bool IsPrintPageBackground() const { return bPrintPageBackground; } sal_Bool IsPrintBlackFont() const { return bPrintBlackFont;} sal_Bool IsPrintSingleJobs() const { return bPrintSingleJobs;} @@ -237,8 +255,8 @@ public: void SetPrintTable ( sal_Bool b ) { doSetModified(); bPrintTable = b;} void SetPrintDraw ( sal_Bool b ) { doSetModified(); bPrintDraw = b;} void SetPrintControl ( sal_Bool b ) { doSetModified(); bPrintControl = b; } - void SetPrintLeftPage ( sal_Bool b ) { doSetModified(); bPrintLeftPage = b;} - void SetPrintRightPage( sal_Bool b ) { doSetModified(); bPrintRightPage = b;} + void SetPrintLeftPage ( sal_Bool b ) { doSetModified(); bPrintLeftPages = b;} + void SetPrintRightPage( sal_Bool b ) { doSetModified(); bPrintRightPages = b;} void SetPrintReverse ( sal_Bool b ) { doSetModified(); bPrintReverse = b;} void SetPaperFromSetup( sal_Bool b ) { doSetModified(); bPaperFromSetup = b;} void SetPrintEmptyPages(sal_Bool b ) { doSetModified(); bPrintEmptyPages = b;} diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx index 19b32df6c255..f2ec7fc21d01 100644 --- a/sw/inc/unotxdoc.hxx +++ b/sw/inc/unotxdoc.hxx @@ -127,6 +127,7 @@ class SwXDocumentPropertyHelper; class SfxViewFrame; class SwPrintUIOptions; class SwPrintData; +class SwRenderData; typedef UnoActionContext* UnoActionContextPtr; SV_DECL_PTRARR(ActionContextArr, UnoActionContextPtr, 4, 4) @@ -221,7 +222,8 @@ class SwXTextDocument : public SwXTextDocumentBaseClass, css::uno::Reference< css::uno::XInterface> xPropertyHelper; SwXDocumentPropertyHelper* pPropertyHelper; - SwPrintUIOptions* m_pPrintUIOptions; + SwPrintUIOptions * m_pPrintUIOptions; + SwRenderData * m_pRenderData; void GetBodyText(); void GetNumberFormatter(); diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index 9a730106ea80..daefe8fef56f 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -1136,7 +1136,8 @@ static void lcl_FormatPostIt( void SwDoc::CalculatePagesForPrinting( - /* out */ SwPrintUIOptions &rOptions, + /* out */ SwRenderData &rData, + const SwPrintUIOptions &rOptions, bool bIsPDFExport, sal_Int32 nDocPageCount ) { @@ -1222,8 +1223,8 @@ void SwDoc::CalculatePagesForPrinting( #endif // TL_NOT_NOW /*TLPDF*/ nPageNo = nFirstPageNo; - std::set< sal_Int32 > &rValidPages = rOptions.GetValidPagesSet(); - std::map< sal_Int32, const SwPageFrm * > &rValidStartFrms = rOptions.GetValidStartFrames(); + std::set< sal_Int32 > &rValidPages = rData.GetValidPagesSet(); + std::map< sal_Int32, const SwPageFrm * > &rValidStartFrms = rData.GetValidStartFrames(); rValidPages.clear(); rValidStartFrms.clear(); while ( pStPage ) @@ -1292,38 +1293,39 @@ void SwDoc::CalculatePagesForPrinting( aPageRange += OUString::valueOf( (sal_Unicode)'-'); aPageRange += OUString::valueOf( nDocPageCount ); } - rOptions.SetPageRange( aPageRange ); + rData.SetPageRange( aPageRange ); // get vector of pages to print according to PageRange and valid pages set from above // (result may be an empty vector, for example if the range string is not correct) StringRangeEnumerator::getRangesFromString( - aPageRange, rOptions.GetPagesToPrint(), - 1, nDocPageCount, 0, &rOptions.GetValidPagesSet() ); + aPageRange, rData.GetPagesToPrint(), + 1, nDocPageCount, 0, &rData.GetValidPagesSet() ); } void SwDoc::UpdatePagesForPrintingWithPostItData( - /* out */ SwPrintUIOptions &rOptions, + /* out */ SwRenderData &rData, + const SwPrintUIOptions &rOptions, bool /*bIsPDFExport*/, sal_Int32 nDocPageCount ) { sal_Int16 nPostItMode = (sal_Int16) rOptions.getIntValue( "PrintAnnotationMode", 0 ); - DBG_ASSERT(nPostItMode == POSTITS_NONE || rOptions.HasPostItData(), + DBG_ASSERT(nPostItMode == POSTITS_NONE || rData.HasPostItData(), "print post-its without post-it data?" ); - const USHORT nPostItCount = rOptions.HasPostItData() ? rOptions.m_pPostItFields->Count() : 0; + const USHORT nPostItCount = rData.HasPostItData() ? rData.m_pPostItFields->Count() : 0; if (nPostItMode != POSTITS_NONE && nPostItCount > 0) { - SET_CURR_SHELL( rOptions.m_pPostItShell ); + SET_CURR_SHELL( rData.m_pPostItShell ); // clear document and move to end of it - SwPaM aPam( rOptions.m_pPostItDoc->GetNodes().GetEndOfContent() ); + SwPaM aPam( rData.m_pPostItDoc->GetNodes().GetEndOfContent() ); aPam.Move( fnMoveBackward, fnGoDoc ); aPam.SetMark(); aPam.Move( fnMoveForward, fnGoDoc ); - rOptions.m_pPostItDoc->Delete( aPam ); + rData.m_pPostItDoc->Delete( aPam ); - const StringRangeEnumerator aRangeEnum( rOptions.GetPageRange(), 1, nDocPageCount, 0 ); + const StringRangeEnumerator aRangeEnum( rData.GetPageRange(), 1, nDocPageCount, 0 ); // For mode POSTITS_ENDPAGE: // maps a physical page number to the page number in post-it document that holds @@ -1339,10 +1341,10 @@ void SwDoc::UpdatePagesForPrintingWithPostItData( bool bIsFirstPostIt = true; for (USHORT i = 0; i < nPostItCount; ++i) { - _PostItFld& rPostIt = (_PostItFld&)*(*rOptions.m_pPostItFields)[ i ]; + _PostItFld& rPostIt = (_PostItFld&)*(*rData.m_pPostItFields)[ i ]; nLastPageNum = nPhyPageNum; nPhyPageNum = rPostIt.GetPageNo( - aRangeEnum, rOptions.GetValidPagesSet(), + aRangeEnum, rData.GetValidPagesSet(), true /*TLPDF bRgt*/, true /*TLPDF bLft*/, nVirtPg, nLineNo ); if (nPhyPageNum) { @@ -1352,55 +1354,55 @@ void SwDoc::UpdatePagesForPrintingWithPostItData( const bool bNewPage = nPostItMode == POSTITS_ENDPAGE && !bIsFirstPostIt && nPhyPageNum != nLastPageNum; - lcl_FormatPostIt( rOptions.m_pPostItShell->GetDoc(), aPam, + lcl_FormatPostIt( rData.m_pPostItShell->GetDoc(), aPam, rPostIt.GetPostIt(), bNewPage, bIsFirstPostIt, nVirtPg, nLineNo ); bIsFirstPostIt = false; if (nPostItMode == POSTITS_ENDPAGE) { // get the correct number of current pages for the post-it document - rOptions.m_pPostItShell->CalcLayout(); - const sal_Int32 nPages = rOptions.m_pPostItDoc->GetPageCount(); + rData.m_pPostItShell->CalcLayout(); + const sal_Int32 nPages = rData.m_pPostItDoc->GetPageCount(); aPostItLastStartPageNum[ nPhyPageNum ] = nPages; } } } // format post-it doc to get correct number of pages - rOptions.m_pPostItShell->CalcLayout(); - const sal_Int32 nPostItDocPageCount = rOptions.m_pPostItDoc->GetPageCount(); + rData.m_pPostItShell->CalcLayout(); + const sal_Int32 nPostItDocPageCount = rData.m_pPostItDoc->GetPageCount(); if (nPostItMode == POSTITS_ONLY || nPostItMode == POSTITS_ENDDOC) { // now add those post-it pages to the vector of pages to print // or replace them if only post-its should be printed - rOptions.GetPostItStartFrames().clear(); + rData.GetPostItStartFrames().clear(); if (nPostItMode == POSTITS_ENDDOC) { // set all values up to number of pages to print currently known to NULL, // meaning none of the pages currently in the vector is from the // post-it document, they are the documents pages. - rOptions.GetPostItStartFrames().resize( rOptions.GetPagesToPrint().size() ); + rData.GetPostItStartFrames().resize( rData.GetPagesToPrint().size() ); } else if (nPostItMode == POSTITS_ONLY) { // no document page to be printed - rOptions.GetPagesToPrint().clear(); + rData.GetPagesToPrint().clear(); } // now we just need to add the post-it pages to be printed to the end // of the vector of pages to print and keep the GetValidStartFrames // data conform with it sal_Int32 nPageNum = 0; - const SwPageFrm * pPageFrm = (SwPageFrm*)rOptions.m_pPostItShell->GetLayout()->Lower(); + const SwPageFrm * pPageFrm = (SwPageFrm*)rData.m_pPostItShell->GetLayout()->Lower(); while( pPageFrm && nPageNum < nPostItDocPageCount ) { DBG_ASSERT( pPageFrm, "Empty page frame. How are we going to print this?" ); ++nPageNum; - rOptions.GetPagesToPrint().push_back( 0 ); // a page number of 0 indicates this page is from the post-it doc + rData.GetPagesToPrint().push_back( 0 ); // a page number of 0 indicates this page is from the post-it doc DBG_ASSERT( pPageFrm, "pPageFrm is NULL!" ); - rOptions.GetPostItStartFrames().push_back( pPageFrm ); + rData.GetPostItStartFrames().push_back( pPageFrm ); pPageFrm = (SwPageFrm*)pPageFrm->GetNext(); } DBG_ASSERT( nPageNum == nPostItDocPageCount, "unexpected number of pages" ); @@ -1414,7 +1416,7 @@ void SwDoc::UpdatePagesForPrintingWithPostItData( // ... thus, first collect all post-it doc start frames in a vector sal_Int32 nPostItPageNum = 0; std::vector< const SwPageFrm * > aAllPostItStartFrames; - const SwPageFrm * pPageFrm = (SwPageFrm*)rOptions.m_pPostItShell->GetLayout()->Lower(); + const SwPageFrm * pPageFrm = (SwPageFrm*)rData.m_pPostItShell->GetLayout()->Lower(); while( pPageFrm && sal_Int32(aAllPostItStartFrames.size()) < nPostItDocPageCount ) { DBG_ASSERT( pPageFrm, "Empty page frame. How are we going to print this?" ); @@ -1457,11 +1459,11 @@ void SwDoc::UpdatePagesForPrintingWithPostItData( // isn't that efficient we will create new vectors by copying the required data std::vector< sal_Int32 > aTmpPagesToPrint; std::vector< const SwPageFrm * > aTmpPostItStartFrames; - const size_t nNum = rOptions.GetPagesToPrint().size(); + const size_t nNum = rData.GetPagesToPrint().size(); for (size_t i = 0 ; i < nNum; ++i) { // add the physical page to print from the document - const sal_Int32 nPhysPage = rOptions.GetPagesToPrint()[i]; + const sal_Int32 nPhysPage = rData.GetPagesToPrint()[i]; aTmpPagesToPrint.push_back( nPhysPage ); aTmpPostItStartFrames.push_back( NULL ); @@ -1479,20 +1481,21 @@ void SwDoc::UpdatePagesForPrintingWithPostItData( // finally we need to assign those vectors to the resulting ones. // swapping the data should be more efficient than assigning since // we won't need the temporary vectors anymore - rOptions.GetPagesToPrint().swap( aTmpPagesToPrint ); - rOptions.GetPostItStartFrames().swap( aTmpPostItStartFrames ); + rData.GetPagesToPrint().swap( aTmpPagesToPrint ); + rData.GetPostItStartFrames().swap( aTmpPostItStartFrames ); } } } void SwDoc::CalculatePagePairsForProspectPrinting( - SwPrintUIOptions &rOptions, + /* out */ SwRenderData &rData, + const SwPrintUIOptions &rOptions, sal_Int32 nDocPageCount ) { - std::set< sal_Int32 > &rValidPagesSet = rOptions.GetValidPagesSet(); - std::map< sal_Int32, const SwPageFrm * > &rValidStartFrms = rOptions.GetValidStartFrames(); - std::vector< std::pair< sal_Int32, sal_Int32 > > &rPagePairs = rOptions.GetPagePairsForProspectPrinting(); + std::set< sal_Int32 > &rValidPagesSet = rData.GetValidPagesSet(); + std::map< sal_Int32, const SwPageFrm * > &rValidStartFrms = rData.GetValidStartFrames(); + std::vector< std::pair< sal_Int32, sal_Int32 > > &rPagePairs = rData.GetPagePairsForProspectPrinting(); rPagePairs.clear(); rValidPagesSet.clear(); @@ -1534,7 +1537,7 @@ void SwDoc::CalculatePagePairsForProspectPrinting( // TLPDF, TODO: remove bPrintReverse, should be handled by PLs framework now //TLPDF bool bPrintReverse = rOptions.getBoolValue( C2U( "PrintReverseOrder" ), false ); // TLPDF: this one seems not to be used in prospect printing: bool bPrintEmptyPages = rOptions.getBoolValue( C2U( "PrintEmptyPages" ), false ); - bool bPrintProspect_RTL = rOptions.getIntValue( "PrintProspectRTL", 0 ) ? true : false; + bool bPrintProspectRTL = rOptions.getIntValue( "PrintProspectRTL", 0 ) ? true : false; // get pages for prospect printing according to the 'PageRange' // (duplicates and any order allowed!) @@ -1621,7 +1624,7 @@ void SwDoc::CalculatePagePairsForProspectPrinting( pStPage = aVec[ nSPg ]; const SwPageFrm* pNxtPage = nEPg < aVec.size() ? aVec[ nEPg ] : 0; - short nRtlOfs = bPrintProspect_RTL ? 1 : 0; + short nRtlOfs = bPrintProspectRTL ? 1 : 0; if ( 0 == (( nSPg + nRtlOfs) & 1 ) ) // switch for odd number in LTR, even number in RTL { const SwPageFrm* pTmp = pStPage; diff --git a/sw/source/core/view/viewpg.cxx b/sw/source/core/view/viewpg.cxx index 79dbdfc1f962..c0b5987e0046 100644 --- a/sw/source/core/view/viewpg.cxx +++ b/sw/source/core/view/viewpg.cxx @@ -481,7 +481,7 @@ void ViewShell::PrintProspect( { // TLPDF if( !rOptions.aMulti.GetSelectCount() ) Printer *pPrinter = dynamic_cast< Printer * >(pOutDev); - if (!pPrinter || rPrintData.GetPrintUIOptions().GetPagePairsForProspectPrinting().size() <= 0) + if (!pPrinter || rPrintData.GetRenderData().GetPagePairsForProspectPrinting().size() <= 0) return; #ifdef TL_NOT_NOW /*TLPDF*/ @@ -498,15 +498,15 @@ void ViewShell::PrintProspect( /* TLPDF neu: start */ #if OSL_DEBUG_LEVEL > 1 - DBG_ASSERT( 0 <= nRenderer && nRenderer < (sal_Int32)rPrintData.GetPrintUIOptions().GetPagePairsForProspectPrinting().size(), "nRenderer out of bounds"); + DBG_ASSERT( 0 <= nRenderer && nRenderer < (sal_Int32)rPrintData.GetRenderData().GetPagePairsForProspectPrinting().size(), "nRenderer out of bounds"); #endif std::pair< sal_Int32, sal_Int32 > rPagesToPrint = - rPrintData.GetPrintUIOptions().GetPagePairsForProspectPrinting()[ nRenderer ]; + rPrintData.GetRenderData().GetPagePairsForProspectPrinting()[ nRenderer ]; const USHORT nPageMax = static_cast< USHORT >(rPagesToPrint.first > rPagesToPrint.second ? rPagesToPrint.first : rPagesToPrint.second); #if OSL_DEBUG_LEVEL > 1 - DBG_ASSERT( rPagesToPrint.first == -1 || rPrintData.GetPrintUIOptions().GetValidPagesSet().count( rPagesToPrint.first ) == 1, "first Page not valid" ); - DBG_ASSERT( rPagesToPrint.second == -1 || rPrintData.GetPrintUIOptions().GetValidPagesSet().count( rPagesToPrint.second ) == 1, "second Page not valid" ); + DBG_ASSERT( rPagesToPrint.first == -1 || rPrintData.GetRenderData().GetValidPagesSet().count( rPagesToPrint.first ) == 1, "first Page not valid" ); + DBG_ASSERT( rPagesToPrint.second == -1 || rPrintData.GetRenderData().GetValidPagesSet().count( rPagesToPrint.second ) == 1, "second Page not valid" ); #endif /* TLPDF neu: end */ @@ -703,16 +703,16 @@ void ViewShell::PrintProspect( /* TLPDF neu: start */ const SwPageFrm *pStPage = 0; const SwPageFrm *pNxtPage = 0; - const SwPrintUIOptions::ValidStartFramesMap_t &rFrms = rPrintData.GetPrintUIOptions().GetValidStartFrames(); + const SwRenderData::ValidStartFramesMap_t &rFrms = rPrintData.GetRenderData().GetValidStartFrames(); if (rPagesToPrint.first > 0) { - SwPrintUIOptions::ValidStartFramesMap_t::const_iterator aIt( rFrms.find( rPagesToPrint.first ) ); + SwRenderData::ValidStartFramesMap_t::const_iterator aIt( rFrms.find( rPagesToPrint.first ) ); DBG_ASSERT( aIt != rFrms.end(), "failed to find start frame" ); pStPage = aIt->second; } if (rPagesToPrint.second > 0) { - SwPrintUIOptions::ValidStartFramesMap_t::const_iterator aIt( rFrms.find( rPagesToPrint.second ) ); + SwRenderData::ValidStartFramesMap_t::const_iterator aIt( rFrms.find( rPagesToPrint.second ) ); DBG_ASSERT( aIt != rFrms.end(), "failed to find start frame" ); pNxtPage = aIt->second; } diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index 7f5201c5e46d..08a19e307ae5 100644 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -237,6 +237,52 @@ const XubString& SwPrtOptions::MakeNextJobName() return sJobName += XubString::CreateFromInt32( ++nJobNo ); } +/*****************************************************************************/ + + +SwRenderData::SwRenderData() +{ + m_pPostItFields = 0; + m_pPostItDoc = 0; + m_pPostItShell = 0; +} + + +SwRenderData::~SwRenderData() +{ +} + + +void SwRenderData::CreatePostItData( SwDoc *pDoc, const SwViewOption *pViewOpt, OutputDevice *pOutDev ) +{ + m_pPostItFields = new _SetGetExpFlds; + lcl_GetPostIts( pDoc, *m_pPostItFields ); + m_pPostItDoc = new SwDoc; + + //!! Disable spell and grammar checking in the temporary document. + //!! Otherwise the grammar checker might process it and crash if we later on + //!! simply delete this document while he is still at it. + SwViewOption aViewOpt( *pViewOpt ); + aViewOpt.SetOnlineSpell( FALSE ); + + m_pPostItShell = new ViewShell( *m_pPostItDoc, 0, &aViewOpt, pOutDev ); +} + + +void SwRenderData::DeletePostItData() +{ + if (HasPostItData()) + { + m_pPostItDoc->setPrinter( 0, false, false ); //damit am echten DOC der Drucker bleibt + delete m_pPostItShell; //Nimmt das PostItDoc mit ins Grab. + delete m_pPostItFields; + m_pPostItDoc = 0; + m_pPostItShell = 0; + m_pPostItFields = 0; + } +} + + /*****************************************************************************/ SwPrintUIOptions::SwPrintUIOptions( BOOL bWeb ) : @@ -428,10 +474,6 @@ SwPrintUIOptions::SwPrintUIOptions( BOOL bWeb ) : DBG_ASSERT( nIdx == nNumProps, "number of added properties is not as expected" ); - - m_pPostItFields = 0; - m_pPostItDoc = 0; - m_pPostItShell = 0; } @@ -526,35 +568,6 @@ bool SwPrintUIOptions::processPropertiesAndCheckFormat( const com::sun::star::un } -void SwPrintUIOptions::CreatePostItData( SwDoc *pDoc, const SwViewOption *pViewOpt, OutputDevice *pOutDev ) -{ - m_pPostItFields = new _SetGetExpFlds; - lcl_GetPostIts( pDoc, *m_pPostItFields ); - m_pPostItDoc = new SwDoc; - - //!! Disable spell and grammar checking in the temporary document. - //!! Otherwise the grammar checker might process it and crash if we later on - //!! simply delete this document while he is still at it. - SwViewOption aViewOpt( *pViewOpt ); - aViewOpt.SetOnlineSpell( FALSE ); - - m_pPostItShell = new ViewShell( *m_pPostItDoc, 0, &aViewOpt, pOutDev ); -} - - -void SwPrintUIOptions::DeletePostItData() -{ - if (HasPostItData()) - { - m_pPostItDoc->setPrinter( 0, false, false ); //damit am echten DOC der Drucker bleibt - delete m_pPostItShell; //Nimmt das PostItDoc mit ins Grab. - delete m_pPostItFields; - m_pPostItDoc = 0; - m_pPostItShell = 0; - m_pPostItFields = 0; - } -} - /****************************************************************************** * Methode : void SetSwVisArea( ViewShell *pSh, Point aPrtOffset, ... * Beschreibung: @@ -1158,17 +1171,17 @@ sal_Bool ViewShell::PrintOrPDFExport( /* TLPDF neu: start */ #if OSL_DEBUG_LEVEL > 1 - DBG_ASSERT( 0 <= nRenderer && nRenderer < (sal_Int32)rPrintData.GetPrintUIOptions().GetPagesToPrint().size(), "nRenderer out of bounds"); + DBG_ASSERT( 0 <= nRenderer && nRenderer < (sal_Int32)rPrintData.GetRenderData().GetPagesToPrint().size(), "nRenderer out of bounds"); #endif - const sal_Int32 nPage = rPrintData.GetPrintUIOptions().GetPagesToPrint()[ nRenderer ]; /* TLPDF */ + const sal_Int32 nPage = rPrintData.GetRenderData().GetPagesToPrint()[ nRenderer ]; /* TLPDF */ #if OSL_DEBUG_LEVEL > 1 - DBG_ASSERT( nPage == 0 || rPrintData.GetPrintUIOptions().GetValidPagesSet().count( nPage ) == 1, "nPage not valid" ); + DBG_ASSERT( nPage == 0 || rPrintData.GetRenderData().GetValidPagesSet().count( nPage ) == 1, "nPage not valid" ); #endif const SwPageFrm *pStPage = 0; if (nPage > 0) // a 'regular' page, not one from the post-it document { - const SwPrintUIOptions::ValidStartFramesMap_t &rFrms = rPrintData.GetPrintUIOptions().GetValidStartFrames(); - SwPrintUIOptions::ValidStartFramesMap_t::const_iterator aIt( rFrms.find( nPage ) ); + const SwRenderData::ValidStartFramesMap_t &rFrms = rPrintData.GetRenderData().GetValidStartFrames(); + SwRenderData::ValidStartFramesMap_t::const_iterator aIt( rFrms.find( nPage ) ); DBG_ASSERT( aIt != rFrms.end(), "failed to find start frame" ); if (aIt == rFrms.end()) return sal_False; @@ -1177,7 +1190,7 @@ sal_Bool ViewShell::PrintOrPDFExport( else // a page from the post-its document ... { DBG_ASSERT( nPage == 0, "unexpected page number. 0 for post-it pages expected" ); - pStPage = rPrintData.GetPrintUIOptions().GetPostItStartFrames()[ nRenderer ]; + pStPage = rPrintData.GetRenderData().GetPostItStartFrames()[ nRenderer ]; } DBG_ASSERT( pStPage, "failed to get start page" ); /* TLPDF neu: end */ @@ -1269,7 +1282,7 @@ sal_Bool ViewShell::PrintOrPDFExport( //TLPDF while( pStPage && !bStop ) { ViewShell *pViewSh2 = nPage == 0 ? /* post-it page? */ - rPrintData.GetPrintUIOptions().m_pPostItShell : pShell; + rPrintData.GetRenderData().m_pPostItShell : pShell; ::SetSwVisArea( pViewSh2, pStPage->Frm() ); // TLPDF // wenn wir einen Umschlag drucken wird ein Offset beachtet @@ -1351,7 +1364,7 @@ sal_Bool ViewShell::PrintOrPDFExport( pShell->InitPrt( pOutDev ); ViewShell *pViewSh2 = nPage == 0 ? /* post-it page? */ - rPrintData.GetPrintUIOptions().m_pPostItShell : pShell; + rPrintData.GetRenderData().m_pPostItShell : pShell; ::SetSwVisArea( pViewSh2, pStPage->Frm() ); // TLPDF // TLPDF nJobStartError = JOBSET_ERR_ISSTARTET; } diff --git a/sw/source/ui/config/optpage.cxx b/sw/source/ui/config/optpage.cxx index 4b85042d0003..3c529263f66d 100644 --- a/sw/source/ui/config/optpage.cxx +++ b/sw/source/ui/config/optpage.cxx @@ -473,14 +473,14 @@ BOOL SwAddPrinterTabPage::FillItemSet( SfxItemSet& rCoreSet ) aAddPrinterAttr.bPrintHiddenText = aPrintHiddenTextCB.IsChecked(); aAddPrinterAttr.bPrintTextPlaceholder = aPrintTextPlaceholderCB.IsChecked(); - aAddPrinterAttr.bPrintLeftPage = aLeftPageCB.IsChecked(); - aAddPrinterAttr.bPrintRightPage = aRightPageCB.IsChecked(); - aAddPrinterAttr.bPrintReverse = aReverseCB.IsChecked(); - aAddPrinterAttr.bPrintProspect = aProspectCB.IsChecked(); - aAddPrinterAttr.bPrintProspect_RTL = aProspectCB_RTL.IsChecked(); - aAddPrinterAttr.bPaperFromSetup = aPaperFromSetupCB.IsChecked(); - aAddPrinterAttr.bPrintEmptyPages = aPrintEmptyPagesCB.IsChecked(); - aAddPrinterAttr.bPrintSingleJobs = aSingleJobsCB.IsChecked(); + aAddPrinterAttr.bPrintLeftPages = aLeftPageCB.IsChecked(); + aAddPrinterAttr.bPrintRightPages = aRightPageCB.IsChecked(); + aAddPrinterAttr.bPrintReverse = aReverseCB.IsChecked(); + aAddPrinterAttr.bPrintProspect = aProspectCB.IsChecked(); + aAddPrinterAttr.bPrintProspectRTL = aProspectCB_RTL.IsChecked(); + aAddPrinterAttr.bPaperFromSetup = aPaperFromSetupCB.IsChecked(); + aAddPrinterAttr.bPrintEmptyPages = aPrintEmptyPagesCB.IsChecked(); + aAddPrinterAttr.bPrintSingleJobs = aSingleJobsCB.IsChecked(); if (aNoRB.IsChecked()) aAddPrinterAttr.nPrintPostIts = POSTITS_NONE; @@ -516,13 +516,13 @@ void SwAddPrinterTabPage::Reset( const SfxItemSet& ) aBlackFontCB.Check( pAddPrinterAttr->bPrintBlackFont); aPrintHiddenTextCB.Check( pAddPrinterAttr->bPrintHiddenText); aPrintTextPlaceholderCB.Check(pAddPrinterAttr->bPrintTextPlaceholder); - aLeftPageCB.Check( pAddPrinterAttr->bPrintLeftPage); - aRightPageCB.Check( pAddPrinterAttr->bPrintRightPage); + aLeftPageCB.Check( pAddPrinterAttr->bPrintLeftPages); + aRightPageCB.Check( pAddPrinterAttr->bPrintRightPages); aReverseCB.Check( pAddPrinterAttr->bPrintReverse); aPaperFromSetupCB.Check(pAddPrinterAttr->bPaperFromSetup); aPrintEmptyPagesCB.Check(pAddPrinterAttr->bPrintEmptyPages); aProspectCB.Check( pAddPrinterAttr->bPrintProspect); - aProspectCB_RTL.Check( pAddPrinterAttr->bPrintProspect_RTL); + aProspectCB_RTL.Check( pAddPrinterAttr->bPrintProspectRTL); aSingleJobsCB.Check( pAddPrinterAttr->bPrintSingleJobs); aNoRB.Check (pAddPrinterAttr->nPrintPostIts== POSTITS_NONE ) ; diff --git a/sw/source/ui/config/prtopt.cxx b/sw/source/ui/config/prtopt.cxx index 41a118614b95..ceb48b6adefe 100644 --- a/sw/source/ui/config/prtopt.cxx +++ b/sw/source/ui/config/prtopt.cxx @@ -119,13 +119,13 @@ SwPrintOptions::SwPrintOptions(sal_Bool bWeb) : break; case 6: bPrintReverse = *(sal_Bool*)pValues[nProp].getValue(); break; case 7: bPrintProspect = *(sal_Bool*)pValues[nProp].getValue(); break; - case 8: bPrintProspect_RTL = *(sal_Bool*)pValues[nProp].getValue(); break; + case 8: bPrintProspectRTL = *(sal_Bool*)pValues[nProp].getValue(); break; case 9: bPrintSingleJobs = *(sal_Bool*)pValues[nProp].getValue(); break; case 10: pValues[nProp] >>= sFaxName; break; case 11: bPaperFromSetup = *(sal_Bool*)pValues[nProp].getValue(); break; case 12: bPrintDraw = *(sal_Bool*)pValues[nProp].getValue() ; break; - case 13: bPrintLeftPage = *(sal_Bool*)pValues[nProp].getValue(); break; - case 14: bPrintRightPage = *(sal_Bool*)pValues[nProp].getValue(); break; + case 13: bPrintLeftPages = *(sal_Bool*)pValues[nProp].getValue(); break; + case 14: bPrintRightPages = *(sal_Bool*)pValues[nProp].getValue(); break; case 15: bPrintEmptyPages = *(sal_Bool*)pValues[nProp].getValue(); break; case 16: bPrintTextPlaceholder = *(sal_Bool*)pValues[nProp].getValue(); break; case 17: bPrintHiddenText = *(sal_Bool*)pValues[nProp].getValue(); break; @@ -164,13 +164,13 @@ void SwPrintOptions::Commit() case 5: pValues[nProp] <<= (sal_Int32)nPrintPostIts ; break; case 6: bVal = bPrintReverse ; pValues[nProp].setValue(&bVal, rType); break; case 7: bVal = bPrintProspect ; pValues[nProp].setValue(&bVal, rType); break; - case 8: bVal = bPrintProspect_RTL ; pValues[nProp].setValue(&bVal, rType); break; + case 8: bVal = bPrintProspectRTL ; pValues[nProp].setValue(&bVal, rType); break; case 9: bVal = bPrintSingleJobs ; pValues[nProp].setValue(&bVal, rType); break; case 10: pValues[nProp] <<= sFaxName; break; case 11: bVal = bPaperFromSetup ; pValues[nProp].setValue(&bVal, rType); break; case 12: bVal = bPrintDraw ; pValues[nProp].setValue(&bVal, rType); break; - case 13: bVal = bPrintLeftPage ; pValues[nProp].setValue(&bVal, rType); break; - case 14: bVal = bPrintRightPage ; pValues[nProp].setValue(&bVal, rType); break; + case 13: bVal = bPrintLeftPages ; pValues[nProp].setValue(&bVal, rType); break; + case 14: bVal = bPrintRightPages ; pValues[nProp].setValue(&bVal, rType); break; case 15: bVal = bPrintEmptyPages ; pValues[nProp].setValue(&bVal, rType); break; case 16: bVal = bPrintTextPlaceholder; pValues[nProp].setValue(&bVal, rType); break; case 17: bVal = bPrintHiddenText; pValues[nProp].setValue(&bVal, rType); break; diff --git a/sw/source/ui/dbui/dbmgr.cxx b/sw/source/ui/dbui/dbmgr.cxx index a5cfd66a740a..ff29ca8638e2 100644 --- a/sw/source/ui/dbui/dbmgr.cxx +++ b/sw/source/ui/dbui/dbmgr.cxx @@ -458,6 +458,7 @@ BOOL SwNewDBMgr::MergeNew(const SwMergeDescriptor& rMergeDesc ) case DBMGR_MERGE_MAILMERGE: // Serienbrief { SwView& rView = rMergeDesc.rSh.GetView(); +#ifdef TL_NOT_NOW /*TLPDF*/ SfxDispatcher *pDis = rView.GetViewFrame()->GetDispatcher(); SfxItemSet aPrintArgs( rView.GetPool(), SID_SILENT, SID_SILENT, //5528 @@ -522,9 +523,42 @@ BOOL SwNewDBMgr::MergeNew(const SwMergeDescriptor& rMergeDesc ) } } - pDis->Execute( SID_PRINTDOC, - SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD, - aPrintArgs ); +#endif //def TL_NOT_NOW /*TLPDF*/ + +// TLPDF pDis->Execute( SID_PRINTDOC, +// TLPDF SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD, +// TLPDF aPrintArgs ); +#if OSL_DEBUG_LEVEL > 1 + sal_Bool _bVal; + sal_Int16 _nVal; + rtl::OUString _sVal; + const beans::PropertyValue* pPrintOptions = rMergeDesc.aPrintOptions.getConstArray(); + for( sal_Int32 nOption = 0; nOption < rMergeDesc.aPrintOptions.getLength(); ++nOption) + { + rtl::OUString aName( pPrintOptions[nOption].Name ); + uno::Any aVal( pPrintOptions[nOption].Value ); + aVal >>= _bVal; + aVal >>= _nVal; + aVal >>= _sVal; + } +#endif + + // printing should be done synchronous otherwise the document + // might already become invalid during the process + uno::Sequence< beans::PropertyValue > aOptions( rMergeDesc.aPrintOptions ); + const sal_Int32 nOpts = aOptions.getLength(); + aOptions.realloc( nOpts + 1 ); + aOptions[ nOpts ].Name = rtl::OUString::createFromAscii( "Wait" ); + aOptions[ nOpts ].Value <<= sal_True ; + + const SwModuleOptions * pModOpt = SW_MOD()->GetModuleConfig(); + if (pModOpt->IsSinglePrintJob()) + { + } + else + { + rView.ExecPrint( aOptions, sal_False, sal_False ); + } } break; @@ -858,12 +892,9 @@ SwNewDBMgr::~SwNewDBMgr() --------------------------------------------------------------------*/ -BOOL SwNewDBMgr::MergePrint( SwView& /*rView*/, - SwPrtOptions& /*rOpt*/, SfxProgress& /*rProgress*/, BOOL /*bIsAPI*/ ) +BOOL SwNewDBMgr::MergePrint( SwView& rView, + SwPrtOptions& rOpt, SfxProgress& rProgress, BOOL bIsAPI ) { - DBG_ASSERT( 0, "not implemented" ); - return FALSE; -#ifdef TL_NOT_NOW /* TLPDF */ SwWrtShell* pSh = &rView.GetWrtShell(); //check if the doc is synchronized and contains at least one linked section BOOL bSynchronizedDoc = pSh->IsLabelDoc() && pSh->GetSectionFmtCount() > 1; @@ -971,11 +1002,11 @@ BOOL SwNewDBMgr::MergePrint( SwView& /*rView*/, } if( pPrt->IsJobActive() ) { - pSh->PrintProspectMM( aPrtAdaptor, aViewProperties, rOpt, rOpt.IsPrintProspect_RTL() ); /* TLPDF */ + pSh->PrintProspectMM( aPrtAdaptor, aViewProperties, rOpt, rOpt.IsPrintProspectRTL() ); /* TLPDF */ bRet = TRUE; } #endif // TL_NOT_NOW /*TLPDF*/ - pSh->PrintProspectMM( aPrtAdaptor, aViewProperties, rOpt, rOpt.IsPrintProspect_RTL() ); // TLPDF + pSh->PrintProspectMM( aPrtAdaptor, aViewProperties, rOpt, rOpt.IsPrintProspectRTL() ); // TLPDF bRet = TRUE; // TLPDF } else if( pSh->PrintOrPDFExportMM( aPrtAdaptor, aViewProperties, rOpt ) /* TLPDF */ ) @@ -1027,17 +1058,13 @@ BOOL SwNewDBMgr::MergePrint( SwView& /*rView*/, } return bRet; -#endif // TL_NOT_NOW /* TLPDF */ } /*-- 21.06.2004 09:08:16--------------------------------------------------- -----------------------------------------------------------------------*/ -BOOL SwNewDBMgr::MergePrintDocuments( SwView& /*rView*/, - SwPrtOptions& /*rOpt*/, SfxProgress& /*rProgress*/, BOOL /*bIsAPI*/ ) +BOOL SwNewDBMgr::MergePrintDocuments( SwView& rView, + SwPrtOptions& rOpt, SfxProgress& rProgress, BOOL bIsAPI ) { - DBG_ASSERT( 0, "not implemented" ); - return FALSE; -#ifdef TL_NOT_NOW /* TLPDF */ SwWrtShell* pSh = &rView.GetWrtShell(); //check if the doc is synchronized and contains at least one linked section //merge source is already open @@ -1144,7 +1171,7 @@ BOOL SwNewDBMgr::MergePrintDocuments( SwView& /*rView*/, { //TLPDF if( pPrt->IsJobActive() || pPrt->StartJob( rOpt.GetJobName() )) //TLPDF { - pSh->PrintProspectMM( aPrtAdaptor, aAddViewProperties, rOpt, rOpt.IsPrintProspect_RTL() ); + pSh->PrintProspectMM( aPrtAdaptor, aAddViewProperties, rOpt, rOpt.IsPrintProspectRTL() ); bRet = TRUE; //TLPDF } } @@ -1192,7 +1219,6 @@ BOOL SwNewDBMgr::MergePrintDocuments( SwView& /*rView*/, } return bRet; -#endif // TL_NOT_NOW /* TLPDF */ } diff --git a/sw/source/ui/inc/cfgitems.hxx b/sw/source/ui/inc/cfgitems.hxx index 620d3ac52b23..bb301283a005 100644 --- a/sw/source/ui/inc/cfgitems.hxx +++ b/sw/source/ui/inc/cfgitems.hxx @@ -155,15 +155,15 @@ public: BOOL IsPrintProspect() const { return bPrintProspect; } - BOOL IsPrintProspect_RTL() const { return bPrintProspect_RTL; } + BOOL IsPrintProspectRTL() const { return bPrintProspectRTL; } void SetPrintProspect(BOOL bFlag ){ bPrintProspect = bFlag; } - void SetPrintProspect_RTL(BOOL bFlag ){ bPrintProspect_RTL = bFlag; } + void SetPrintProspectRTL(BOOL bFlag ){ bPrintProspectRTL = bFlag; } BOOL IsPrintGraphic () const { return bPrintGraphic; } BOOL IsPrintTable () const { return bPrintTable; } BOOL IsPrintDraw () const { return bPrintDraw; } BOOL IsPrintControl () const { return bPrintControl; } - BOOL IsPrintLeftPage () const { return bPrintLeftPage; } - BOOL IsPrintRightPage() const { return bPrintRightPage; } + BOOL IsPrintLeftPage () const { return bPrintLeftPages; } + BOOL IsPrintRightPage() const { return bPrintRightPages; } BOOL IsPrintReverse () const { return bPrintReverse; } BOOL IsPaperFromSetup() const { return bPaperFromSetup; } BOOL IsPrintEmptyPages() const { return bPrintEmptyPages; } diff --git a/sw/source/ui/uiview/view.cxx b/sw/source/ui/uiview/view.cxx index 5e3afd2ed8fa..642c34352a0e 100644 --- a/sw/source/ui/uiview/view.cxx +++ b/sw/source/ui/uiview/view.cxx @@ -1975,7 +1975,7 @@ void SwView::MakeOptions( PrintDialog* pDlg, SwPrtOptions& rOpts, if( pPrtProspect ) *pPrtProspect = pData->bPrintProspect; if( pPrtProspect_RTL ) - *pPrtProspect_RTL = pData->bPrintProspect_RTL; + *pPrtProspect_RTL = pData->bPrintProspectRTL; rOpts.aMulti.SetTotalRange( Range( 0, RANGE_MAX ) ); rOpts.aMulti.SelectAll( FALSE ); rOpts.nCopyCount = 1; diff --git a/sw/source/ui/uiview/viewprt.cxx b/sw/source/ui/uiview/viewprt.cxx index b6f2308d9888..4a7e6477aa7f 100644 --- a/sw/source/ui/uiview/viewprt.cxx +++ b/sw/source/ui/uiview/viewprt.cxx @@ -178,10 +178,6 @@ USHORT __EXPORT SwView::SetPrinter(SfxPrinter* pNew, USHORT nDiffFlags, bool ) ErrCode SwView::DoPrint( SfxPrinter* pPrinter, PrintDialog* pDlg, BOOL bSilent, BOOL bIsAPI ) { - (void) pPrinter; (void) pDlg; (void) bSilent; (void) bIsAPI; - DBG_ASSERT( 0, "not implemented" ); - return 0; -#ifdef TL_NOT_NOW /* TLPDF */ // First test SwWrtShell* pSh = &GetWrtShell(); SwNewDBMgr* pMgr = pSh->GetNewDBMgr(); @@ -376,7 +372,7 @@ ErrCode SwView::DoPrint( SfxPrinter* pPrinter, PrintDialog* pDlg, BOOL bSilent, pViewProperties[10].Value <<= (text::NotePrintMode) aOpts.GetPrintPostIts(); pViewProperties[11].Name = C2U("PrintProspect"); pViewProperties[11].Value <<= (sal_Bool)aOpts.IsPrintProspect(); - pViewProperties[12].Name = C2U("PrintPageBackground"); + pViewProperties[12].Name = C2U("PrintPageBackground"); pViewProperties[12].Value <<= (sal_Bool)aOpts.IsPrintPageBackground(); pViewProperties[13].Name = C2U("PrintBlackFonts"); pViewProperties[13].Value <<= (sal_Bool)aOpts.IsPrintBlackFont(); @@ -447,7 +443,6 @@ ErrCode SwView::DoPrint( SfxPrinter* pPrinter, PrintDialog* pDlg, BOOL bSilent, //TLPDF pProgress->DeleteOnEndPrint(); //TLPDF pPrinter->EndJob(); return pPrinter->GetError(); -#endif // TL_NOT_NOW /* TLPDF */ } diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index 3b774180dd63..46696961dca4 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -360,7 +360,8 @@ SwXTextDocument::SwXTextDocument(SwDocShell* pShell) : pxLinkTargetSupplier(0), pxXRedlines(0), m_pHiddenViewFrame(0), - m_pPrintUIOptions( NULL ) + m_pPrintUIOptions( NULL ), + m_pRenderData( NULL ) { } /*-- 18.12.98 11:53:00--------------------------------------------------- @@ -376,6 +377,7 @@ SwXTextDocument::~SwXTextDocument() xNumFmtAgg = 0; } delete m_pPrintUIOptions; + delete m_pRenderData; } @@ -2626,6 +2628,8 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount( if(!IsValid()) throw RuntimeException(); + if( ! m_pRenderData ) + m_pRenderData = new SwRenderData; if( ! m_pPrintUIOptions ) { const BOOL bWebDoc = (0 != PTR_CAST(SwWebDocShell, pDocShell)); @@ -2680,8 +2684,8 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount( const bool bPrintProspect = m_pPrintUIOptions->getBoolValue( "PrintProspect", false ); if (bPrintProspect) { - pDoc->CalculatePagePairsForProspectPrinting( *m_pPrintUIOptions, nPageCount ); - nRet = m_pPrintUIOptions->GetPagePairsForProspectPrinting().size(); + pDoc->CalculatePagePairsForProspectPrinting( *m_pRenderData, *m_pPrintUIOptions, nPageCount ); + nRet = m_pRenderData->GetPagePairsForProspectPrinting().size(); } else { @@ -2689,20 +2693,20 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount( if (nPostItMode != POSTITS_NONE) { OutputDevice *pOutDev = lcl_GetOutputDevice( *m_pPrintUIOptions ); - m_pPrintUIOptions->CreatePostItData( pDoc, pWrtShell->GetViewOptions(), pOutDev ); + m_pRenderData->CreatePostItData( pDoc, pWrtShell->GetViewOptions(), pOutDev ); } // get set of valid document pages (according to the current settings) // and their start frames - pDoc->CalculatePagesForPrinting( *m_pPrintUIOptions, bIsPDFExport, nPageCount ); + pDoc->CalculatePagesForPrinting( *m_pRenderData, *m_pPrintUIOptions, bIsPDFExport, nPageCount ); if (nPostItMode != POSTITS_NONE) { - pDoc->UpdatePagesForPrintingWithPostItData( + pDoc->UpdatePagesForPrintingWithPostItData( *m_pRenderData, *m_pPrintUIOptions, bIsPDFExport, nPageCount ); } - nRet = m_pPrintUIOptions->GetPagesToPrint().size(); + nRet = m_pRenderData->GetPagesToPrint().size(); } DBG_ASSERT( nRet >= 0, "negative number of pages???" ); @@ -2721,6 +2725,8 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SwXTextDocument::getRenderer( if(!IsValid()) throw RuntimeException(); + if( ! m_pRenderData ) + m_pRenderData = new SwRenderData; if( ! m_pPrintUIOptions ) { const BOOL bWebDoc = (0 != PTR_CAST(SwWebDocShell, pDocShell)); @@ -2812,6 +2818,8 @@ void SAL_CALL SwXTextDocument::render( if(!IsValid()) throw RuntimeException(); + if (!m_pRenderData) + m_pRenderData = new SwRenderData; if (!m_pPrintUIOptions) { const BOOL bWebDoc = (0 != PTR_CAST(SwWebDocShell, pDocShell)); @@ -2846,8 +2854,8 @@ void SAL_CALL SwXTextDocument::render( // Thus instead of throwing the exception we silently return. if (0 > nRenderer) throw IllegalArgumentException(); - if ( (bPrintProspect && size_t(nRenderer) >= m_pPrintUIOptions->GetPagePairsForProspectPrinting().size()) - || (!bPrintProspect && size_t(nRenderer) >= m_pPrintUIOptions->GetPagesToPrint().size())) + if ( (bPrintProspect && size_t(nRenderer) >= m_pRenderData->GetPagePairsForProspectPrinting().size()) + || (!bPrintProspect && size_t(nRenderer) >= m_pRenderData->GetPagesToPrint().size())) return; // the view shell should be SwView for documents PDF export @@ -2885,15 +2893,15 @@ void SAL_CALL SwXTextDocument::render( aOptions.bPrintTable = m_pPrintUIOptions->IsPrintTables(); aOptions.bPrintDraw = m_pPrintUIOptions->IsPrintDrawings(); aOptions.bPrintControl = m_pPrintUIOptions->getBoolValue( "PrintControls", aOptions.bPrintControl ); - aOptions.bPrintLeftPage = m_pPrintUIOptions->IsPrintLeftPages(); - aOptions.bPrintRightPage = m_pPrintUIOptions->IsPrintRightPages(); + aOptions.bPrintLeftPages = m_pPrintUIOptions->IsPrintLeftPages(); + aOptions.bPrintRightPages = m_pPrintUIOptions->IsPrintRightPages(); aOptions.bPrintPageBackground = m_pPrintUIOptions->getBoolValue( "PrintPageBackground", aOptions.bPrintPageBackground ); aOptions.bPrintEmptyPages = !bIsSkipEmptyPages; // bUpdateFieldsInPrinting <-- not set here // TLPDF: TODO: remove this from SwPrintData?? Get rid of SwPrtOptions?? aOptions.bPaperFromSetup = m_pPrintUIOptions->getBoolValue( "PrintPaperFromSetup", aOptions.bPaperFromSetup ); aOptions.bPrintReverse = m_pPrintUIOptions->getBoolValue( "PrintReversed", aOptions.bPrintReverse ); aOptions.bPrintProspect = m_pPrintUIOptions->getBoolValue( "PrintProspect", aOptions.bPrintProspect ); - aOptions.bPrintProspect_RTL = m_pPrintUIOptions->getIntValue( "PrintProspectRTL", aOptions.bPrintProspect_RTL ) ? true : false; + aOptions.bPrintProspectRTL = m_pPrintUIOptions->getIntValue( "PrintProspectRTL", aOptions.bPrintProspectRTL ) ? true : false; // bPrintSingleJobs <-- not set here // TLPDF: TODO: remove this from SwPrintData?? Get rid of SwPrtOptions?? // bModified <-- not set here // TLPDF: TODO: remove this from SwPrintData?? Get rid of SwPrtOptions?? aOptions.bPrintBlackFont = m_pPrintUIOptions->getBoolValue( "PrintBlackFonts", aOptions.bPrintBlackFont ); @@ -2901,9 +2909,10 @@ void SAL_CALL SwXTextDocument::render( aOptions.bPrintTextPlaceholder = m_pPrintUIOptions->getBoolValue( "PrintTextPlaceholder", aOptions.bPrintTextPlaceholder ); aOptions.nPrintPostIts = static_cast< sal_Int16 >(m_pPrintUIOptions->getIntValue( "PrintAnnotationMode", aOptions.nPrintPostIts )); - //! needs to be set after MakeOptions since the assingment operation in that - //! function will destroy this pointer + //! needs to be set after MakeOptions since the assignment operation in that + //! function will destroy the pointers aOptions.SetPrintUIOptions( m_pPrintUIOptions ); + aOptions.SetRenderData( m_pRenderData ); Range aRange( nRenderer+1, nRenderer+1 ); MultiSelection aPages( aRange ); @@ -2967,16 +2976,18 @@ void SAL_CALL SwXTextDocument::render( if (bLastPage) { - if (m_pPrintUIOptions->HasPostItData()) - m_pPrintUIOptions->DeletePostItData(); - + if (m_pRenderData && m_pRenderData->HasPostItData()) + m_pRenderData->DeletePostItData(); if (m_pHiddenViewFrame) { lcl_DisposeView( m_pHiddenViewFrame, pDocShell ); m_pHiddenViewFrame = 0; } + + aOptions.SetRenderData( NULL ); aOptions.SetPrintUIOptions( NULL ); - delete m_pPrintUIOptions, m_pPrintUIOptions = NULL; + delete m_pRenderData; m_pRenderData = NULL; + delete m_pPrintUIOptions; m_pPrintUIOptions = NULL; } } } -- cgit From 0dbda8a93911a7bbed0faa078626036fb3077499 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Fri, 28 Aug 2009 13:54:50 +0000 Subject: fix warning --- sw/source/core/view/vprint.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'sw') diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index 08a19e307ae5..b1f3c8e88eaf 100644 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -256,8 +256,8 @@ SwRenderData::~SwRenderData() void SwRenderData::CreatePostItData( SwDoc *pDoc, const SwViewOption *pViewOpt, OutputDevice *pOutDev ) { m_pPostItFields = new _SetGetExpFlds; - lcl_GetPostIts( pDoc, *m_pPostItFields ); - m_pPostItDoc = new SwDoc; + lcl_GetPostIts( pDoc, *m_pPostItFields ); + m_pPostItDoc = new SwDoc; //!! Disable spell and grammar checking in the temporary document. //!! Otherwise the grammar checker might process it and crash if we later on @@ -265,7 +265,7 @@ void SwRenderData::CreatePostItData( SwDoc *pDoc, const SwViewOption *pViewOpt, SwViewOption aViewOpt( *pViewOpt ); aViewOpt.SetOnlineSpell( FALSE ); - m_pPostItShell = new ViewShell( *m_pPostItDoc, 0, &aViewOpt, pOutDev ); + m_pPostItShell = new ViewShell( *m_pPostItDoc, 0, &aViewOpt, pOutDev ); } @@ -1216,7 +1216,7 @@ sal_Bool ViewShell::PrintOrPDFExport( ( bIsPDFExport || rPrintData.GetJobName().Len() /*TLPDF|| pOutDev->IsJobActive()*/) ) { // TLPDF BOOL bStop = FALSE; - int nJobStartError = JOBSET_ERR_DEFAULT; +// TLPDF int nJobStartError = JOBSET_ERR_DEFAULT; XubString sJobName( rPrintData.GetJobName() ); -- cgit From d9d92875a62f7c2142f4c851f10eccdf896cc4ee Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Fri, 28 Aug 2009 14:15:32 +0000 Subject: fix warning --- sw/source/core/view/vprint.cxx | 4 ++-- sw/source/ui/dbui/dbmgr.cxx | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'sw') diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index b1f3c8e88eaf..24ea49b78eef 100644 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -1363,9 +1363,9 @@ sal_Bool ViewShell::PrintOrPDFExport( // TLPDF pShell->InitPrt( pOutDev, bIsPDFExport ? pOutDev : 0 ); pShell->InitPrt( pOutDev ); - ViewShell *pViewSh2 = nPage == 0 ? /* post-it page? */ + ViewShell *pViewSh3 = nPage == 0 ? /* post-it page? */ rPrintData.GetRenderData().m_pPostItShell : pShell; - ::SetSwVisArea( pViewSh2, pStPage->Frm() ); // TLPDF + ::SetSwVisArea( pViewSh3, pStPage->Frm() ); // TLPDF // TLPDF nJobStartError = JOBSET_ERR_ISSTARTET; } // --> FME 2005-12-12 #b6354161# Feature - Print empty pages diff --git a/sw/source/ui/dbui/dbmgr.cxx b/sw/source/ui/dbui/dbmgr.cxx index ff29ca8638e2..034429f39ca7 100644 --- a/sw/source/ui/dbui/dbmgr.cxx +++ b/sw/source/ui/dbui/dbmgr.cxx @@ -458,7 +458,7 @@ BOOL SwNewDBMgr::MergeNew(const SwMergeDescriptor& rMergeDesc ) case DBMGR_MERGE_MAILMERGE: // Serienbrief { SwView& rView = rMergeDesc.rSh.GetView(); -#ifdef TL_NOT_NOW /*TLPDF*/ +#ifdef TL_NOT_NOW /*TLPDF*/ SfxDispatcher *pDis = rView.GetViewFrame()->GetDispatcher(); SfxItemSet aPrintArgs( rView.GetPool(), SID_SILENT, SID_SILENT, //5528 @@ -523,7 +523,7 @@ BOOL SwNewDBMgr::MergeNew(const SwMergeDescriptor& rMergeDesc ) } } -#endif //def TL_NOT_NOW /*TLPDF*/ +#endif //def TL_NOT_NOW /*TLPDF*/ // TLPDF pDis->Execute( SID_PRINTDOC, // TLPDF SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD, @@ -540,8 +540,8 @@ BOOL SwNewDBMgr::MergeNew(const SwMergeDescriptor& rMergeDesc ) aVal >>= _bVal; aVal >>= _nVal; aVal >>= _sVal; - } -#endif + } +#endif // printing should be done synchronous otherwise the document // might already become invalid during the process @@ -550,8 +550,8 @@ BOOL SwNewDBMgr::MergeNew(const SwMergeDescriptor& rMergeDesc ) aOptions.realloc( nOpts + 1 ); aOptions[ nOpts ].Name = rtl::OUString::createFromAscii( "Wait" ); aOptions[ nOpts ].Value <<= sal_True ; - - const SwModuleOptions * pModOpt = SW_MOD()->GetModuleConfig(); + + const SwModuleOptions * pModOpt = SW_MOD()->GetModuleConfig(); if (pModOpt->IsSinglePrintJob()) { } @@ -925,8 +925,8 @@ BOOL SwNewDBMgr::MergePrint( SwView& rView, //TLPDF if( rOpt.IsPrintSingleJobs() ) //TLPDF pPrt->SetEndPrintHdl( Link() ); - BOOL bUserBreak = FALSE, - bRet = FALSE; +//TLPDF BOOL bUserBreak = FALSE; + BOOL bRet = FALSE; long nStartRow, nEndRow; //calculate number of data sets to be printed -- cgit From 49722c743ab79cb01c4932c894549d8db9bb9426 Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Mon, 31 Aug 2009 08:59:41 +0000 Subject: #i101242# minor clean-up --- sw/source/core/view/viewpg.cxx | 419 ++++++++++------------------------------- sw/source/core/view/vprint.cxx | 365 ++++++++--------------------------- sw/source/ui/dbui/dbmgr.cxx | 5 +- sw/source/ui/uno/unotxdoc.cxx | 3 +- 4 files changed, 183 insertions(+), 609 deletions(-) (limited to 'sw') diff --git a/sw/source/core/view/viewpg.cxx b/sw/source/core/view/viewpg.cxx index c0b5987e0046..cc97ae5ef3ed 100644 --- a/sw/source/core/view/viewpg.cxx +++ b/sw/source/core/view/viewpg.cxx @@ -474,32 +474,23 @@ void ViewShell::PrintProspectMM( // OD 05.05.2003 #i14016# - consider empty pages on calculation of the scaling // for a page to be printed. void ViewShell::PrintProspect( - OutputDevice* pOutDev, - const SwPrintData & rPrintData, + OutputDevice *pOutDev, + const SwPrintData &rPrintData, sal_Int32 nRenderer // the index in the vector of prospect pages to be printed ) { -// TLPDF if( !rOptions.aMulti.GetSelectCount() ) + const sal_Int32 nMaxRenderer = rPrintData.GetRenderData().GetPagePairsForProspectPrinting().size() - 1; +#if OSL_DEBUG_LEVEL > 1 + DBG_ASSERT( 0 <= nRenderer && nRenderer < nMaxRenderer, "nRenderer out of bounds"); +#endif Printer *pPrinter = dynamic_cast< Printer * >(pOutDev); - if (!pPrinter || rPrintData.GetRenderData().GetPagePairsForProspectPrinting().size() <= 0) + if (!pPrinter || nMaxRenderer <= 0 || nRenderer < 0 || nRenderer > nMaxRenderer) return; -#ifdef TL_NOT_NOW /*TLPDF*/ - // wenn kein Drucker vorhanden ist, wird nicht gedruckt - SfxPrinter* pPrt = getIDocumentDeviceAccess()->getPrinter(false); - if( !pPrt || !pPrt->GetName().Len() || - ( !rOptions.bPrintLeftPage && !rOptions.bPrintRightPage )) - return; -#endif // TL_NOT_NOW /*TLPDF*/ - - // save settings of OutputDevice (should be done always now since the + // save settings of OutputDevice (should be done always since the // output device is now provided by a call from outside the Writer) pPrinter->Push(); -/* TLPDF neu: start */ -#if OSL_DEBUG_LEVEL > 1 - DBG_ASSERT( 0 <= nRenderer && nRenderer < (sal_Int32)rPrintData.GetRenderData().GetPagePairsForProspectPrinting().size(), "nRenderer out of bounds"); -#endif std::pair< sal_Int32, sal_Int32 > rPagesToPrint = rPrintData.GetRenderData().GetPagePairsForProspectPrinting()[ nRenderer ]; const USHORT nPageMax = static_cast< USHORT >(rPagesToPrint.first > rPagesToPrint.second ? @@ -508,27 +499,9 @@ void ViewShell::PrintProspect( DBG_ASSERT( rPagesToPrint.first == -1 || rPrintData.GetRenderData().GetValidPagesSet().count( rPagesToPrint.first ) == 1, "first Page not valid" ); DBG_ASSERT( rPagesToPrint.second == -1 || rPrintData.GetRenderData().GetValidPagesSet().count( rPagesToPrint.second ) == 1, "second Page not valid" ); #endif -/* TLPDF neu: end */ - -#ifdef TL_NOT_NOW /*TLPDF*/ - MultiSelection aMulti( rOptions.aMulti ); - Range aPages( aMulti.FirstSelected(), aMulti.LastSelected() ); - if ( aPages.Max() > USHRT_MAX ) - aPages.Max() = USHRT_MAX; - - ASSERT( aPages.Min() > 0, - "Seite 0 Drucken?" ); - ASSERT( aPages.Min() <= aPages.Max(), - "MinSeite groesser MaxSeite." ); -#endif // TL_NOT_NOW /*TLPDF*/ // eine neue Shell fuer den Printer erzeugen -// TLPDF ViewShell aShell( *this, 0 ); ViewShell aShell( *this, 0, pPrinter ); -#ifdef TL_NOT_NOW /*TLPDF*/ - if ( &GetRefDev() == pPrt ) - aShell.mpTmpRef = new SfxPrinter( *pPrt ); -#endif // TL_NOT_NOW /*TLPDF*/ SET_CURR_SHELL( &aShell ); @@ -552,315 +525,131 @@ void ViewShell::PrintProspect( // Seiten fuers Drucken formatieren aShell.CalcPagesForPrint( nPageMax, 0 /*(USHORT)aPages.Max(), &rProgress*/ ); -#ifdef TL_NOT_NOW /*TLPDF*/ - USHORT nCopyCnt = rOptions.bCollate ? rOptions.nCopyCount : 1; - - const SwPageFrm *pStPage = (SwPageFrm*)GetLayout()->Lower(); - USHORT i; + MapMode aMapMode( MAP_TWIP ); + Size aPrtSize( pPrinter->PixelToLogic( pPrinter->GetPaperSizePixel(), aMapMode ) ); /* TLPDF */ - for( i = 1; pStPage && i < (USHORT)aPages.Min(); ++i ) - pStPage = (SwPageFrm*)pStPage->GetNext(); -#endif // TL_NOT_NOW /*TLPDF*/ + SwTwips nMaxRowSz, nMaxColSz; -#ifdef TL_NOT_NOW /*TLPDF*/ - should not happen any more since the test - rPrintData.GetPagePairsForProspectPrinting().size() <= 0 - above should have taken care that there is at least one page to print - if( !pStPage ) // dann wars das + const SwPageFrm *pStPage = 0; + const SwPageFrm *pNxtPage = 0; + const SwRenderData::ValidStartFramesMap_t &rFrms = rPrintData.GetRenderData().GetValidStartFrames(); + if (rPagesToPrint.first > 0) { - if( bHiddenFlds ) - { - SwMsgPoolItem aHnt( RES_HIDDENPARA_PRINT ); - pFldType->Modify( &aHnt, 0); - CalcPagesForPrint( nPageMax /*(USHORT)aPages.Max()*/ ); - } - return; + SwRenderData::ValidStartFramesMap_t::const_iterator aIt( rFrms.find( rPagesToPrint.first ) ); + DBG_ASSERT( aIt != rFrms.end(), "failed to find start frame" ); + pStPage = aIt->second; } -#endif // TL_NOT_NOW /*TLPDF*/ - -#ifdef TL_NOT_NOW /*TLPDF*/ - // unsere SttPage haben wir, dann die EndPage suchen - SvPtrarr aArr( 255, 255 ); - aArr.Insert( (void*)pStPage, aArr.Count() ); - - while( pStPage->GetNext() && i < nPageMax (USHORT)aPages.Max() ) + if (rPagesToPrint.second > 0) { - pStPage = (SwPageFrm*)pStPage->GetNext(); - if( aMulti.IsSelected( ++i ) ) - aArr.Insert( (void*)pStPage, aArr.Count() ); + SwRenderData::ValidStartFramesMap_t::const_iterator aIt( rFrms.find( rPagesToPrint.second ) ); + DBG_ASSERT( aIt != rFrms.end(), "failed to find start frame" ); + pNxtPage = aIt->second; } - // auf Doppelseiten auffuellen - if( 1 == aArr.Count() ) // eine Seite ist ein Sonderfall - aArr.Insert( (void*)0, 1 ); - else + // OD 05.05.2003 #i14016# - consider empty pages on calculation + // of page size, used for calculation of scaling. + Size aSttPageSize; + if ( pStPage ) { - while( aArr.Count() & 3 ) - aArr.Insert( (void*)0, aArr.Count() ); - - if( rOptions.bPrintReverse && 4 < aArr.Count() ) + if ( pStPage->IsEmptyPage() ) { - // das Array umsortieren - // Array: 1 2 3 4 5 6 7 8 - // soll: 3 4 1 2 7 8 5 6 - // Algorhytmus: - // vordere Haelfte: Austausch von 2 Pointer von Vorne vor die Haelfte - // hintere Haelfte: Austausch von 2 Pointer von der Haelfte nach hinten - - USHORT nHalf = aArr.Count() / 2; - USHORT nSwapCount = nHalf / 4; - - VoidPtr* ppArrStt = (VoidPtr*)aArr.GetData(); - VoidPtr* ppArrHalf = (VoidPtr*)aArr.GetData() + nHalf; - - for( int nLoop = 0; nLoop < 2; ++nLoop ) - { - for( USHORT n = 0; n < nSwapCount; ++n ) - { - void* pTmp = *ppArrStt; - *ppArrStt++ = *(ppArrHalf-2); - *(ppArrHalf-2) = pTmp; - - pTmp = *ppArrStt; - *ppArrStt++ = *--ppArrHalf; - *ppArrHalf-- = pTmp; - } - ppArrStt = (VoidPtr*)aArr.GetData() + nHalf; - ppArrHalf = (VoidPtr*)aArr.GetData() + aArr.Count(); - } + if ( pStPage->GetPhyPageNum() % 2 == 0 ) + aSttPageSize = pStPage->GetPrev()->Frm().SSize(); + else + aSttPageSize = pStPage->GetNext()->Frm().SSize(); + } + else + { + aSttPageSize = pStPage->Frm().SSize(); } } -#endif // TL_NOT_NOW /*TLPDF*/ - -//TLPDF BOOL bStartJob = FALSE; - - for( USHORT nCnt = 0; nCnt <= 0 /*< 1 TLPDF nCopyCnt*/; nCnt++ ) + Size aNxtPageSize; + if ( pNxtPage ) { -#ifdef TL_NOT_NOW /*TLPDF*/ - if( rOptions.IsPrintSingleJobs() && rOptions.GetJobName().Len() && - ( bStartJob || rOptions.bJobStartet ) ) + if ( pNxtPage->IsEmptyPage() ) { - pPrt->EndJob(); - rOptions.bJobStartet = TRUE; - - // Reschedule statt Yield, da Yield keine Events abarbeitet - // und es sonst eine Endlosschleife gibt. - while( pPrt->IsPrinting() ) - rProgress.Reschedule(); - - rOptions.MakeNextJobName(); - DBG_ERROR( "StartJob does not exist anymore" ); - // bStartJob = pPrt->StartJob( rOptions.GetJobName() ); + if ( pNxtPage->GetPhyPageNum() % 2 == 0 ) + aNxtPageSize = pNxtPage->GetPrev()->Frm().SSize(); + else + aNxtPageSize = pNxtPage->GetNext()->Frm().SSize(); } - - // dann sorge mal dafuer, das alle Seiten in der richtigen - // Reihenfolge stehen: - USHORT nSPg = 0, nEPg = aArr.Count(), nStep = 1; - if( 0 == (nEPg & 1 )) // ungerade gibt es nicht! - --nEPg; - - if( !rOptions.bPrintLeftPage ) - ++nStep; - else if( !rOptions.bPrintRightPage ) + else { - ++nStep; - ++nSPg, --nEPg; + aNxtPageSize = pNxtPage->Frm().SSize(); } + } - USHORT nCntPage = (( nEPg - nSPg ) / ( 2 * nStep )) + 1; -#endif // TL_NOT_NOW /*TLPDF*/ - - MapMode aOld( /*TLPDF pPrt*/pPrinter->GetMapMode() ); - MapMode aMapMode( MAP_TWIP ); -// TLPDF Size aPrtSize( pPrt->PixelToLogic( pPrt->GetPaperSizePixel(), aMapMode ) ); - Size aPrtSize( pPrinter->PixelToLogic( pPrinter->GetPaperSizePixel(), aMapMode ) ); /* TLPDF */ + if( !pStPage ) + { + nMaxColSz = 2 * aNxtPageSize.Width(); + nMaxRowSz = aNxtPageSize.Height(); + } + else if( !pNxtPage ) + { + nMaxColSz = 2 * aSttPageSize.Width(); + nMaxRowSz = aSttPageSize.Height(); + } + else + { + nMaxColSz = aNxtPageSize.Width() + aSttPageSize.Width(); + nMaxRowSz = Max( aNxtPageSize.Height(), aSttPageSize.Height() ); + } -#ifdef TL_NOT_NOW /*TLPDF*/ - const XubString aTmp( SW_RES( STR_STATSTR_PRINT ) ); - rProgress.SetText( aTmp ); - //HACK, damit die Anzeige nicht durcheinander kommt: - rProgress.SetState( 1, nCntPage ); - rProgress.SetText( aTmp ); -#endif // TL_NOT_NOW /*TLPDF*/ + // den MapMode einstellen + aMapMode.SetOrigin( Point() ); + { + Fraction aScX( aPrtSize.Width(), nMaxColSz ); + Fraction aScY( aPrtSize.Height(), nMaxRowSz ); + if( aScX < aScY ) + aScY = aScX; - for( USHORT nPrintCount = 0; nPrintCount <= 0 /*nSPg < nEPg && nPrintCount < nCntPage*/; ++nPrintCount ) { -#ifdef TL_NOT_NOW /*TLPDF*/ - // Mag der Anwender noch ? - rProgress.Reschedule(); - - if ( !pPrt->IsJobActive() ) - break; - - pStPage = (SwPageFrm*)aArr[ nSPg ]; - const SwPageFrm* pNxtPage = nEPg < aArr.Count() - ? (SwPageFrm*)aArr[ nEPg ] - : 0; -#endif // TL_NOT_NOW /*TLPDF*/ - - SwTwips nMaxRowSz, nMaxColSz; - -/* TLPDF neu: start */ - const SwPageFrm *pStPage = 0; - const SwPageFrm *pNxtPage = 0; - const SwRenderData::ValidStartFramesMap_t &rFrms = rPrintData.GetRenderData().GetValidStartFrames(); - if (rPagesToPrint.first > 0) - { - SwRenderData::ValidStartFramesMap_t::const_iterator aIt( rFrms.find( rPagesToPrint.first ) ); - DBG_ASSERT( aIt != rFrms.end(), "failed to find start frame" ); - pStPage = aIt->second; - } - if (rPagesToPrint.second > 0) - { - SwRenderData::ValidStartFramesMap_t::const_iterator aIt( rFrms.find( rPagesToPrint.second ) ); - DBG_ASSERT( aIt != rFrms.end(), "failed to find start frame" ); - pNxtPage = aIt->second; - } -/* TLPDF neu: end */ - - // OD 05.05.2003 #i14016# - consider empty pages on calculation - // of page size, used for calculation of scaling. - Size aSttPageSize; - if ( pStPage ) - { - if ( pStPage->IsEmptyPage() ) - { - if ( pStPage->GetPhyPageNum() % 2 == 0 ) - aSttPageSize = pStPage->GetPrev()->Frm().SSize(); - else - aSttPageSize = pStPage->GetNext()->Frm().SSize(); - } - else - { - aSttPageSize = pStPage->Frm().SSize(); - } - } - Size aNxtPageSize; - if ( pNxtPage ) - { - if ( pNxtPage->IsEmptyPage() ) - { - if ( pNxtPage->GetPhyPageNum() % 2 == 0 ) - aNxtPageSize = pNxtPage->GetPrev()->Frm().SSize(); - else - aNxtPageSize = pNxtPage->GetNext()->Frm().SSize(); - } - else - { - aNxtPageSize = pNxtPage->Frm().SSize(); - } - } - - if( !pStPage ) - { - nMaxColSz = 2 * aNxtPageSize.Width(); - nMaxRowSz = aNxtPageSize.Height(); - } - else if( !pNxtPage ) - { - nMaxColSz = 2 * aSttPageSize.Width(); - nMaxRowSz = aSttPageSize.Height(); - } + // fuer Drawing, damit diese ihre Objecte vernuenftig Painten + // koennen, auf "glatte" Prozentwerte setzen + aScY *= Fraction( 1000, 1 ); + long nTmp = (long)aScY; + if( 1 < nTmp ) + --nTmp; else - { - nMaxColSz = aNxtPageSize.Width() + - aSttPageSize.Width(); - nMaxRowSz = Max( aNxtPageSize.Height(), - aSttPageSize.Height() ); - } - -#ifdef TL_NOT_NOW /*TLPDF*/ - short nRtlOfs = bRTL ? 1 : 0; - if( 0 == (( nSPg + nRtlOfs) & 1 ) ) // switch for odd number in LTR, even number in RTL - { - const SwPageFrm* pTmp = pStPage; - pStPage = pNxtPage; - pNxtPage = pTmp; - } -#endif // TL_NOT_NOW /*TLPDF*/ - - // den MapMode einstellen - aMapMode.SetOrigin( Point() ); - { - Fraction aScX( aPrtSize.Width(), nMaxColSz ); - Fraction aScY( aPrtSize.Height(), nMaxRowSz ); - if( aScX < aScY ) - aScY = aScX; - - { - // fuer Drawing, damit diese ihre Objecte vernuenftig Painten - // koennen, auf "glatte" Prozentwerte setzen - aScY *= Fraction( 1000, 1 ); - long nTmp = (long)aScY; - if( 1 < nTmp ) - --nTmp; - else - nTmp = 1; - aScY = Fraction( nTmp, 1000 ); - } - - aMapMode.SetScaleY( aScY ); - aMapMode.SetScaleX( aScY ); - } - -// TLPDF Point aPrtOff( pPrt->PixelToLogic( pPrt->GetPageOffsetPixel(), aMapMode ) ); -// TLPDF Size aTmpPrtSize( pPrt->PixelToLogic( pPrt->GetPaperSizePixel(), aMapMode ) ); -// TLPDF Point aPrtOff( pPrinter->PixelToLogic( pPrinter->GetPageOffsetPixel(), aMapMode ) ); /* TLPDF */ - Size aTmpPrtSize( pPrinter->PixelToLogic( pPrinter->GetPaperSizePixel(), aMapMode ) ); /* TLPDF */ + nTmp = 1; + aScY = Fraction( nTmp, 1000 ); + } - // dann kann das drucken losgehen -//TLPDF bStartJob = TRUE; -//TLPDF rProgress.SetState( nPrintCount, nCntPage ); + aMapMode.SetScaleY( aScY ); + aMapMode.SetScaleX( aScY ); + } -#ifdef TL_NOT_NOW /*TLPDF*/ - pPrt->StartPage(); -#endif + Size aTmpPrtSize( pPrinter->PixelToLogic( pPrinter->GetPaperSizePixel(), aMapMode ) ); /* TLPDF */ - // calculate start point for equal border on all sides - Point aSttPt( (aTmpPrtSize.Width() - nMaxColSz) / 2, - (aTmpPrtSize.Height() - nMaxRowSz) / 2 ); - for( int nC = 0; nC < 2; ++nC ) - { - if( pStPage ) - { - aShell.Imp()->SetFirstVisPageInvalid(); - aShell.aVisArea = pStPage->Frm(); + // calculate start point for equal border on all sides + Point aSttPt( (aTmpPrtSize.Width() - nMaxColSz) / 2, + (aTmpPrtSize.Height() - nMaxRowSz) / 2 ); + for( int nC = 0; nC < 2; ++nC ) + { + if( pStPage ) + { + aShell.Imp()->SetFirstVisPageInvalid(); + aShell.aVisArea = pStPage->Frm(); - Point aPos( aSttPt ); - aPos -= aShell.aVisArea.Pos(); + Point aPos( aSttPt ); + aPos -= aShell.aVisArea.Pos(); // TLPDF aPos -= aPrtOff; - aMapMode.SetOrigin( aPos ); - pPrinter->SetMapMode( aMapMode ); - pStPage->GetUpper()->Paint( pStPage->Frm() ); - } - - pStPage = pNxtPage; - aSttPt.X() += aTmpPrtSize.Width() / 2; - } - -#ifdef TL_NOT_NOW /*TLPDF*/ - pPrt->EndPage(); -#endif - SwPaintQueue::Repaint(); - -#ifdef TL_NOT_NOW /*TLPDF*/ - nSPg = nSPg + nStep; - nEPg = nEPg - nStep; -#endif // TL_NOT_NOW /*TLPDF*/ + aMapMode.SetOrigin( aPos ); + pPrinter->SetMapMode( aMapMode ); + pStPage->GetUpper()->Paint( pStPage->Frm() ); } - pPrinter->SetMapMode( aOld ); - if( bHiddenFlds ) - { - SwMsgPoolItem aHnt( RES_HIDDENPARA_PRINT ); - pFldType->Modify( &aHnt, 0); - CalcPagesForPrint( nPageMax /*(USHORT)aPages.Max()*/ ); - } + pStPage = pNxtPage; + aSttPt.X() += aTmpPrtSize.Width() / 2; + } -#ifdef TL_NOT_NOW /*TLPDF*/ - if( bStartJob ) - rOptions.bJobStartet = TRUE; -#endif // TL_NOT_NOW /*TLPDF*/ + SwPaintQueue::Repaint(); + + if( bHiddenFlds ) + { + SwMsgPoolItem aHnt( RES_HIDDENPARA_PRINT ); + pFldType->Modify( &aHnt, 0); + CalcPagesForPrint( nPageMax /*(USHORT)aPages.Max()*/ ); } pFntCache->Flush(); diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index 24ea49b78eef..1e399b2ee3f7 100644 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -1070,8 +1070,8 @@ sal_Bool ViewShell::PrintOrPDFExportMM( sal_Bool ViewShell::PrintOrPDFExport( - OutputDevice* pOutDev, - const SwPrtOptions &rPrintData, /* TLPDF can't we make use of just SwPrintData only as it is the case in PrintProspect??? */ + OutputDevice *pOutDev, + const SwPrtOptions &rPrintData, sal_Int32 nRenderer, // the index in the vector of pages to be printed bool bIsPDFExport ) { @@ -1079,37 +1079,17 @@ sal_Bool ViewShell::PrintOrPDFExport( //Immer die Druckroutinen in viewpg.cxx (PrintPreViewPage und PrintProspect) mitpflegen!! //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - BOOL bStartJob = FALSE; - //! Note: Since for PDF export of (multi-)selection a temporary - //! document is created that contains only the selects parts, - //! and thus that document is to printed in whole the, - //! rPrintData.bPrintSelection parameter will be false. - BOOL bSelection = rPrintData.bPrintSelection; - -// TLPDF: this one should hold just one page now. Thus clean-up should be possible - MultiSelection aMulti( rPrintData.aMulti ); - - if ( !pOutDev || !aMulti.GetSelectCount() ) - return bStartJob; + const sal_Int32 nMaxRenderer = rPrintData.GetRenderData().GetPagesToPrint().size() - 1; +#if OSL_DEBUG_LEVEL > 1 + DBG_ASSERT( 0 <= nRenderer && nRenderer < nMaxRenderer, "nRenderer out of bounds"); +#endif + if (!pOutDev || nMaxRenderer <= 0 || nRenderer < 0 || nRenderer > nMaxRenderer) + return sal_False; - // save settings of OutputDevice (should be done always now since the + // save settings of OutputDevice (should be done always since the // output device is now provided by a call from outside the Writer) pOutDev->Push(); - Range aPages( aMulti.FirstSelected(), aMulti.LastSelected() ); - if ( aPages.Max() > USHRT_MAX ) - aPages.Max() = USHRT_MAX; - - ASSERT( aPages.Min() > 0, - "Seite 0 Drucken?" ); - ASSERT( aPages.Min() <= aPages.Max(), - "MinSeite groesser MaxSeite." ); - -// TLPDF - ASSERT( aPages.Min() == aPages.Max(), "Min page should be equal to Max page now" ); /* TLPDF */ -// TLPDF TODO: clean-up aPage.Min/Max which should be identical now - - // Einstellungen am Drucker merken // SwPrtOptSave aPrtSave( pOutDev ); /* TLPDF wo dann heutzutage ??? */ @@ -1121,6 +1101,12 @@ sal_Bool ViewShell::PrintOrPDFExport( //!! (h?ngt mit OLE Objekten im Dokument zusammen.) SfxObjectShellRef aDocShellRef; + //! Note: Since for PDF export of (multi-)selection a temporary + //! document is created that contains only the selects parts, + //! and thus that document is to printed in whole the, + //! rPrintData.bPrintSelection parameter will be false. + BOOL bSelection = rPrintData.bPrintSelection; + // PDF export for (multi-)selection has already generated a temporary document // with the selected text. (see XRenderable implementation in unotxdoc.cxx) // Thus we like to go in the 'else' part here in that case. @@ -1132,18 +1118,15 @@ sal_Bool ViewShell::PrintOrPDFExport( pOutDevDoc = CreatePrtDoc( /*TLPDF pOutDev,*/ aDocShellRef ); // eine ViewShell darauf -// TLPDF OutputDevice *pTmpDev = bIsPDFExport ? pOutDev : 0; -// TLPDF pShell = new ViewShell( *pOutDevDoc, 0, pOpt, pTmpDev ); pShell = new ViewShell( *pOutDevDoc, 0, pOpt, pOutDev ); pOutDevDoc->SetRefForDocShell( 0 ); } else { pOutDevDoc = GetDoc(); -// TLPDF OutputDevice *pTmpDev = bIsPDFExport ? pOutDev : 0; -// TLPDF pShell = new ViewShell( *this, 0, pTmpDev ); pShell = new ViewShell( *this, 0, pOutDev ); } + SdrView *pDrawView = pShell->GetDrawView(); if (pDrawView) { @@ -1154,281 +1137,81 @@ sal_Bool ViewShell::PrintOrPDFExport( { //Zusaetzlicher Scope, damit die CurrShell vor dem zerstoeren der //Shell zurueckgesetzt wird. - SET_CURR_SHELL( pShell ); - - //JP 01.02.99: das ReadOnly Flag wird NIE mitkopiert; Bug 61335 - if( pOpt->IsReadonly() ) - pShell->pOpt->SetReadonly( TRUE ); + SET_CURR_SHELL( pShell ); - // save options at draw view: - SwDrawViewSave aDrawViewSave( pShell->GetDrawView() ); + //JP 01.02.99: das ReadOnly Flag wird NIE mitkopiert; Bug 61335 + if( pOpt->IsReadonly() ) + pShell->pOpt->SetReadonly( TRUE ); - pShell->PrepareForPrint( rPrintData ); + // save options at draw view: + SwDrawViewSave aDrawViewSave( pShell->GetDrawView() ); - XubString* pStr = 0; -//TLPDF ULONG nMergeAct = rPrintData.nMergeAct, nMergeCnt = rPrintData.nMergeCnt; + pShell->PrepareForPrint( rPrintData ); - -/* TLPDF neu: start */ + const sal_Int32 nPage = rPrintData.GetRenderData().GetPagesToPrint()[ nRenderer ]; /* TLPDF */ #if OSL_DEBUG_LEVEL > 1 - DBG_ASSERT( 0 <= nRenderer && nRenderer < (sal_Int32)rPrintData.GetRenderData().GetPagesToPrint().size(), "nRenderer out of bounds"); -#endif - const sal_Int32 nPage = rPrintData.GetRenderData().GetPagesToPrint()[ nRenderer ]; /* TLPDF */ -#if OSL_DEBUG_LEVEL > 1 - DBG_ASSERT( nPage == 0 || rPrintData.GetRenderData().GetValidPagesSet().count( nPage ) == 1, "nPage not valid" ); -#endif - const SwPageFrm *pStPage = 0; - if (nPage > 0) // a 'regular' page, not one from the post-it document - { - const SwRenderData::ValidStartFramesMap_t &rFrms = rPrintData.GetRenderData().GetValidStartFrames(); - SwRenderData::ValidStartFramesMap_t::const_iterator aIt( rFrms.find( nPage ) ); - DBG_ASSERT( aIt != rFrms.end(), "failed to find start frame" ); - if (aIt == rFrms.end()) - return sal_False; - pStPage = aIt->second; - } - else // a page from the post-its document ... - { - DBG_ASSERT( nPage == 0, "unexpected page number. 0 for post-it pages expected" ); - pStPage = rPrintData.GetRenderData().GetPostItStartFrames()[ nRenderer ]; - } - DBG_ASSERT( pStPage, "failed to get start page" ); -/* TLPDF neu: end */ - - - // benoetigte Seiten fuers Drucken formatieren - pShell->CalcPagesForPrint( (USHORT)nPage, 0 /*TLPDF*/, pStr, - 0, 0 /* TLPDF, there is no progressbar right now nMergeAct, nMergeCnt */ ); - - // Some field types, can require a valid layout - // (expression fields in tables). For these we do an UpdateFlds - // here after calculation of the pages. - // --> FME 2004-06-21 #i9684# For performance reasons, we do not update - // the fields during pdf export. - // #i56195# prevent update of fields (for mail merge) - if ( !bIsPDFExport && rPrintData.bUpdateFieldsInPrinting ) - // <-- - pShell->UpdateFlds(TRUE); - -// TLPDF if( !pShell->Imp()->IsStopOutDev() && -// TLPDF ( bIsPDFExport || rPrintData.GetJobName().Len() || pOutDev->IsJobActive()) ) - if( /*!pShell->Imp()->IsStopOutDev() && */ - ( bIsPDFExport || rPrintData.GetJobName().Len() /*TLPDF|| pOutDev->IsJobActive()*/) ) - { -// TLPDF BOOL bStop = FALSE; -// TLPDF int nJobStartError = JOBSET_ERR_DEFAULT; - - XubString sJobName( rPrintData.GetJobName() ); - -// HACK: Hier muss von der MultiSelection noch eine akzeptable Moeglichkeit -// geschaffen werden, alle Seiten von Seite x an zu deselektieren. -// Z.B. durch SetTotalRange .... - -// aMulti.Select( Range( nLastPageNo+1, SELECTION_MAX ), FALSE ); -// TLPDF MultiSelection aTmpMulti( Range( 1, nLastPageNo ) ); - MultiSelection aTmpMulti( Range( 1, nPage ) ); - long nTmpIdx = aMulti.FirstSelected(); - static long nEndOfSelection = SFX_ENDOFSELECTION; -// TLPDF while ( nEndOfSelection != nTmpIdx && nTmpIdx <= long(nLastPageNo) ) - while ( nEndOfSelection != nTmpIdx && nTmpIdx <= long(nPage) ) - { - aTmpMulti.Select( nTmpIdx ); - nTmpIdx = aMulti.NextSelected(); - } - aMulti = aTmpMulti; -// Ende des HACKs - -#if 0 - const USHORT nSelCount = USHORT(aMulti.GetSelectCount() - /* * nCopyCnt*/); -#endif - - // PostitListe holen - _SetGetExpFlds aPostItFields; -// TLPDF SwDoc* pPostItDoc = 0; -// TLPDF ViewShell* pPostItShell = 0; -#ifdef TL_NOT_NOW /*TLPDF*/ - if( rPrintData.nPrintPostIts != POSTITS_NONE ) - { - lcl_GetPostIts( pDoc, aPostItFields ); - pPostItDoc = new SwDoc; -/* TLPDF - if (pOutDev) - pPostItDoc->setPrinter( pOutDev, true, true ); -*/ - pPostItShell = new ViewShell( *pPostItDoc, 0, - pShell->GetViewOptions() ); - // Wenn PostIts am Dokumentenende gedruckt werden sollen, - // die Druckreihenfolge allerdings umgekehrt ist, dann hier - if ( ( rPrintData.nPrintPostIts == POSTITS_ENDDOC ) && - rPrintData.bPrintReverse ) - lcl_PrintPostItsEndDoc( pPostItShell, aPostItFields, - aMulti, sJobName, bStartJob, nJobStartError, - rPrintData.bPrintRightPage, rPrintData.bPrintLeftPage, TRUE ); - - } -#endif // TL_NOT_NOW /*TLPDF*/ - - // aOldMapMode wird fuer das Drucken von Umschlaegen gebraucht. - MapMode aOldMapMode; - - const SwPageDesc *pLastPageDesc = NULL; - // BOOL bSetOrient = FALSE; - // BOOL bSetPaperSz = FALSE; - BOOL bSetPrt = FALSE; - -//TLPDF if ( rPrintData.nPrintPostIts != POSTITS_ONLY ) - { -//TLPDF while( pStPage && !bStop ) - { - ViewShell *pViewSh2 = nPage == 0 ? /* post-it page? */ - rPrintData.GetRenderData().m_pPostItShell : pShell; - ::SetSwVisArea( pViewSh2, pStPage->Frm() ); // TLPDF - - // wenn wir einen Umschlag drucken wird ein Offset beachtet - if( pStPage->GetFmt()->GetPoolFmtId() == RES_POOLPAGE_JAKET ) - { - aOldMapMode = pOutDev->GetMapMode(); - Point aNewOrigin = pOutDev->GetMapMode().GetOrigin(); - aNewOrigin += rPrintData.aOffset; - MapMode aTmp( pOutDev->GetMapMode() ); - aTmp.SetOrigin( aNewOrigin ); - pOutDev->SetMapMode( aTmp ); - } - - { - if ( bSetPrt ) - { - // check for empty page - const SwPageFrm& rFormatPage = pStPage->GetFormatPage(); - - if ( pLastPageDesc != rFormatPage.GetPageDesc() ) - { - pLastPageDesc = rFormatPage.GetPageDesc(); -#if 0 // TL_PDF - const BOOL bLandScp = rFormatPage.GetPageDesc()->GetLandscape(); - - if( bSetPaperBin ) // Schacht einstellen. - pPrt->SetPaperBin( rFormatPage.GetFmt()-> - GetPaperBin().GetValue() ); - - if (bSetOrient ) - { - // Orientation einstellen: Breiter als Hoch - // -> Landscape, sonst -> Portrait. - if( bLandScp ) - pPrt->SetOrientation(ORIENTATION_LANDSCAPE); - else - pPrt->SetOrientation(ORIENTATION_PORTRAIT); - } - - if (bSetPaperSz ) - { - Size aSize = pStPage->Frm().SSize(); - if ( bLandScp && bSetOrient ) - { - // landscape is always interpreted as a rotation by 90 degrees ! - // this leads to non WYSIWIG but at least it prints! - // #i21775# - long nWidth = aSize.Width(); - aSize.Width() = aSize.Height(); - aSize.Height() = nWidth; - } - Paper ePaper = SvxPaperInfo::GetSvxPaper(aSize,MAP_TWIP,TRUE); - if ( PAPER_USER == ePaper ) - pPrt->SetPaperSizeUser( aSize ); - else - pPrt->SetPaper( ePaper ); - } + DBG_ASSERT( nPage == 0 || rPrintData.GetRenderData().GetValidPagesSet().count( nPage ) == 1, "nPage not valid" ); #endif - } - } - -#ifdef TL_NOT_NOW /*TLPDF*/ - // Wenn PostIts nach Seite gedruckt werden sollen, - // jedoch Reverse eingestellt ist ... - if( rPrintData.bPrintReverse && - rPrintData.nPrintPostIts == POSTITS_ENDPAGE ) - lcl_PrintPostItsEndPage( pPostItShell, aPostItFields, - nPage /* TLPDF nPageNo*/, aMulti, sJobName, bStartJob, nJobStartError, - rPrintData.bPrintRightPage, rPrintData.bPrintLeftPage, - rPrintData.bPrintReverse ); -#endif // TL_NOT_NOW /*TLPDF*/ - - -// TLPDF if( !bStartJob && JOBSET_ERR_DEFAULT == nJobStartError -// TLPDF && sJobName.Len() ) - { - -// TLPDF pShell->InitPrt( pOutDev, bIsPDFExport ? pOutDev : 0 ); - pShell->InitPrt( pOutDev ); - - ViewShell *pViewSh3 = nPage == 0 ? /* post-it page? */ - rPrintData.GetRenderData().m_pPostItShell : pShell; - ::SetSwVisArea( pViewSh3, pStPage->Frm() ); // TLPDF -// TLPDF nJobStartError = JOBSET_ERR_ISSTARTET; - } - // --> FME 2005-12-12 #b6354161# Feature - Print empty pages -// TLPDF if ( rPrintData.bPrintEmptyPages || pStPage->Frm().Height() ) - // <-- - { - pStPage->GetUpper()->Paint( pStPage->Frm() ); - } - SwPaintQueue::Repaint(); - -#ifdef TL_NOT_NOW /*TLPDF*/ - // Wenn PostIts nach Seite gedruckt werden sollen ... - if( (!rPrintData.bPrintReverse) && - rPrintData.nPrintPostIts == POSTITS_ENDPAGE ) - lcl_PrintPostItsEndPage( pPostItShell, aPostItFields, - nPage /* TLPDF nPageNo */, aMulti, sJobName, bStartJob, nJobStartError, - rPrintData.bPrintRightPage, rPrintData.bPrintLeftPage, - rPrintData.bPrintReverse ); -#endif // TL_NOT_NOW /*TLPDF*/ - } + const SwPageFrm *pStPage = 0; + if (nPage > 0) // a 'regular' page, not one from the post-it document + { + const SwRenderData::ValidStartFramesMap_t &rFrms = rPrintData.GetRenderData().GetValidStartFrames(); + SwRenderData::ValidStartFramesMap_t::const_iterator aIt( rFrms.find( nPage ) ); + DBG_ASSERT( aIt != rFrms.end(), "failed to find start frame" ); + if (aIt == rFrms.end()) + return sal_False; + pStPage = aIt->second; + } + else // a page from the post-its document ... + { + DBG_ASSERT( nPage == 0, "unexpected page number. 0 for post-it pages expected" ); + pStPage = rPrintData.GetRenderData().GetPostItStartFrames()[ nRenderer ]; + } + DBG_ASSERT( pStPage, "failed to get start page" ); + + // benoetigte Seiten fuers Drucken formatieren + pShell->CalcPagesForPrint( (USHORT)nPage, 0 /*TLPDF*/, 0 /*TLPDFpStr*/, + 0, 0 /* TLPDF, there is no progressbar right now nMergeAct, nMergeCnt */ ); + + // Some field types, can require a valid layout + // (expression fields in tables). For these we do an UpdateFlds + // here after calculation of the pages. + // --> FME 2004-06-21 #i9684# For performance reasons, we do not update + // the fields during pdf export. + // #i56195# prevent update of fields (for mail merge) + if ( !bIsPDFExport && rPrintData.bUpdateFieldsInPrinting ) + pShell->UpdateFlds(TRUE); + // <-- - // den eventl. fuer Umschlaege modifizierte OutDevOffset wieder - // zuruecksetzen. - if( pStPage->GetFmt()->GetPoolFmtId() == RES_POOLPAGE_JAKET ) - pOutDev->SetMapMode( aOldMapMode ); + ViewShell *pViewSh2 = nPage == 0 ? /* post-it page? */ + rPrintData.GetRenderData().m_pPostItShell : pShell; + ::SetSwVisArea( pViewSh2, pStPage->Frm() ); // TLPDF - } // TLPDF loop end: while( pStPage && !bStop ) - } + // wenn wir einen Umschlag drucken wird ein Offset beachtet + if( pStPage->GetFmt()->GetPoolFmtId() == RES_POOLPAGE_JAKET ) + { + Point aNewOrigin = pOutDev->GetMapMode().GetOrigin(); + aNewOrigin += rPrintData.aOffset; + MapMode aTmp( pOutDev->GetMapMode() ); + aTmp.SetOrigin( aNewOrigin ); + pOutDev->SetMapMode( aTmp ); + } -#ifdef TL_NOT_NOW /*TLPDF*/ - if (!bStop) // TLPDF: see break above - { - // Wenn PostIts am Dokumentenende gedruckt werden sollen, dann hier machen - if( ((rPrintData.nPrintPostIts == POSTITS_ENDDOC) && !rPrintData.bPrintReverse) - || (rPrintData.nPrintPostIts == POSTITS_ONLY) ) - lcl_PrintPostItsEndDoc( pPostItShell, aPostItFields, aMulti, - sJobName, bStartJob, nJobStartError, - rPrintData.bPrintRightPage, rPrintData.bPrintLeftPage, - rPrintData.bPrintReverse ); - - if( pPostItShell ) - { - pPostItDoc->setPrinter( 0, false, false ); //damit am echten DOC der Drucker bleibt - delete pPostItShell; //Nimmt das PostItDoc mit ins Grab. - } + pShell->InitPrt( pOutDev ); -//TLPDF if( bStartJob ) -//TLPDF rPrintData.bJobStartet = TRUE; - } // TLPDF: if (!bStop) see break above -#endif // TL_NOT_NOW /*TLPDF*/ + pViewSh2 = nPage == 0 ? /* post-it page? */ + rPrintData.GetRenderData().m_pPostItShell : pShell; + ::SetSwVisArea( pViewSh2, pStPage->Frm() ); // TLPDF - } - delete pStr; + pStPage->GetUpper()->Paint( pStPage->Frm() ); + SwPaintQueue::Repaint(); } //Zus. Scope wg. CurShell! delete pShell; if (bSelection ) { - // damit das Dokument nicht den Drucker mit ins Grab nimmt -// pOutDevDoc->setPrinter( 0, false, false ); /*TLPDF should not be needed anymore*/ - if ( !pOutDevDoc->release() ) delete pOutDevDoc; } @@ -1437,7 +1220,7 @@ sal_Bool ViewShell::PrintOrPDFExport( // output device is now provided by a call from outside the Writer) pOutDev->Pop(); - return bStartJob; + return sal_True; } /****************************************************************************** diff --git a/sw/source/ui/dbui/dbmgr.cxx b/sw/source/ui/dbui/dbmgr.cxx index 034429f39ca7..8ca8463a379a 100644 --- a/sw/source/ui/dbui/dbmgr.cxx +++ b/sw/source/ui/dbui/dbmgr.cxx @@ -552,12 +552,13 @@ BOOL SwNewDBMgr::MergeNew(const SwMergeDescriptor& rMergeDesc ) aOptions[ nOpts ].Value <<= sal_True ; const SwModuleOptions * pModOpt = SW_MOD()->GetModuleConfig(); - if (pModOpt->IsSinglePrintJob()) + if (pModOpt->IsSinglePrintJob()) // single print job per document? { + rView.ExecPrint( aOptions, sal_False, sal_False ); } else { - rView.ExecPrint( aOptions, sal_False, sal_False ); + // here use the print adaptor top get just one print job } } break; diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index 46696961dca4..eafa1127afe5 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -2753,7 +2753,8 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SwXTextDocument::getRenderer( awt::Size aPageSize( TWIP_TO_MM100( aPgSize.Width() ), TWIP_TO_MM100( aPgSize.Height() )); // prospect printing should be landscape, thus switching width and height - if (m_pPrintUIOptions->getBoolValue( "PrintProspect", sal_False )) + if (m_pPrintUIOptions->getBoolValue( "PrintProspect", sal_False ) && + aPageSize.Height > aPageSize.Width) aPageSize = awt::Size( aPageSize.Height, aPageSize.Width ); uno::Sequence< beans::PropertyValue > aRenderer(2); aRenderer[0].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "PageSize" ) ); -- cgit From 0d2b77c567c563b19ae4ed32a31d927282860129 Mon Sep 17 00:00:00 2001 From: Oliver Specht Date: Tue, 1 Sep 2009 07:59:10 +0000 Subject: #i101242# DoPrint removed --- sw/source/ui/inc/view.hxx | 4 +- sw/source/ui/uiview/viewprt.cxx | 276 ---------------------------------------- 2 files changed, 1 insertion(+), 279 deletions(-) (limited to 'sw') diff --git a/sw/source/ui/inc/view.hxx b/sw/source/ui/inc/view.hxx index 0fb458573a61..92788e714c4f 100644 --- a/sw/source/ui/inc/view.hxx +++ b/sw/source/ui/inc/view.hxx @@ -424,8 +424,6 @@ public: virtual USHORT SetPrinter( SfxPrinter* pNew, USHORT nDiff = SFX_PRINTER_ALL, bool bIsAPI=false); - virtual ErrCode DoPrint( SfxPrinter *pPrinter, PrintDialog *pPrintDialog, - BOOL bSilent, BOOL bIsAPI ); ShellModes GetShellMode(); com::sun::star::view::XSelectionSupplier* GetUNOObject(); @@ -691,4 +689,4 @@ SfxTabPage* CreatePrintOptionsPage( Window *pParent, const SfxItemSet &rOptions, BOOL bPreview); -#endif +#endif \ No newline at end of file diff --git a/sw/source/ui/uiview/viewprt.cxx b/sw/source/ui/uiview/viewprt.cxx index 4a7e6477aa7f..54c00ea8313e 100644 --- a/sw/source/ui/uiview/viewprt.cxx +++ b/sw/source/ui/uiview/viewprt.cxx @@ -172,281 +172,6 @@ USHORT __EXPORT SwView::SetPrinter(SfxPrinter* pNew, USHORT nDiffFlags, bool ) return 0; } -/*-------------------------------------------------------------------- - Beschreibung: - --------------------------------------------------------------------*/ - -ErrCode SwView::DoPrint( SfxPrinter* pPrinter, PrintDialog* pDlg, BOOL bSilent, BOOL bIsAPI ) -{ - // First test - SwWrtShell* pSh = &GetWrtShell(); - SwNewDBMgr* pMgr = pSh->GetNewDBMgr(); - - int bPrintSelection = -1; - USHORT nMergeType = pMgr->GetMergeType(); - if( DBMGR_MERGE_MAILMERGE != nMergeType && - DBMGR_MERGE_DOCUMENTS != nMergeType && - !pDlg && - !bIsAPI && ( pSh->IsSelection() || pSh->IsFrmSelected() || - pSh->IsObjSelected() ) ) - { - short nBtn = SvxPrtQryBox(&GetEditWin()).Execute(); - if( RET_CANCEL == nBtn ) - return ERRCODE_IO_ABORT; - - if( RET_OK == nBtn ) - bPrintSelection = 1; - else - bPrintSelection = 0; - } - -// Der PrintProgress stellt Handler am Printer der ViewShell ein. -// Das kann natuerlich erst nach dem evtl. Umschalten des Druckers korrekt -// funktionieren. #55210# -// SfxPrintProgress *pProgress = new SfxPrintProgress( this, !bSilent ); - /* TLPDF SfxPrintProgress */ SfxProgress *pProgress = 0; - SfxPrinter *pDocPrinter = GetPrinter(TRUE); - if ( !pPrinter ) - pPrinter = pDocPrinter; - else if ( pDocPrinter != pPrinter ) - { - //Da der Doc-Drucker beim SetPrinter geloescht wird, - // muss man ihn vorher clonen -//TLPDF SfxPrinter* pClone = pDocPrinter->Clone(); -//TLPDF SetPrinter( pPrinter, SFX_PRINTER_PRINTER ); -//TLPDF pProgress = new SfxPrintProgress( this, !bSilent ); -//TLPDF pProgress->RestoreOnEndPrint( pClone ); - } - if(!pProgress) -//TLPDF pProgress = new SfxPrintProgress( this, !bSilent ); - { - SfxObjectShell *pObjShell = GetViewFrame()->GetObjectShell(); // TLPDF ?? - pProgress = new SfxProgress( pObjShell, String(), 1 ); // TLPDF ?? - } - pProgress->SetWaitMode(FALSE); - - BOOL bStartJob = pPrinter->InitJob( &GetEditWin(), - !bIsAPI && pSh->HasDrawView() && pSh->GetDrawView()->GetModel()->HasTransparentObjects()); - if( bStartJob ) - { - // Drucker starten - PreparePrint( pDlg ); - SfxObjectShell *pObjShell = GetViewFrame()->GetObjectShell(); - //#i82625# GetTitle( 0 ) doesn't work for 'embedded' documents like forms or reports - String sDocumentTitle( pObjShell->GetTitle(SFX_TITLE_APINAME)); - SwPrtOptions aOpts( sDocumentTitle ); - BOOL bWeb = 0 != PTR_CAST(SwWebView, this); - nMergeType = pMgr->GetMergeType(); - - BOOL bPrtPros; - BOOL bPrtPros_RTL; - SwView::MakeOptions( pDlg, aOpts, &bPrtPros, &bPrtPros_RTL, bWeb, GetPrinter(), - pSh->getIDocumentDeviceAccess()->getPrintData() ); - - //set the appropriate view options to print - //on silent mode the field commands have to be switched off always - //on default print the user is asked what to do - const SwViewOption* pCurrentViewOptions = pSh->GetViewOptions(); - bool bSwitchOff_IsFldName = pCurrentViewOptions->IsFldName() && pSh->IsAnyFieldInDoc(); - - if(!bSilent && bSwitchOff_IsFldName) - { - QueryBox aBox( &GetEditWin(), SW_RES( DLG_PRT_FIELDNAME ) ); - USHORT nRet = aBox.Execute(); - if( RET_CANCEL == nRet) - return ERRCODE_IO_ABORT; - // disable field commands - if( RET_NO != nRet ) - { - bSwitchOff_IsFldName = false; - } - } - bool bApplyViewOptions = bSwitchOff_IsFldName; - //switch off display of hidden characters if on and hidden characters are in use - const sal_Bool bOldShowHiddenChar = pCurrentViewOptions->IsShowHiddenChar(); - const sal_Bool bOldMetaChars = pCurrentViewOptions->IsViewMetaChars(); - if( bOldShowHiddenChar != aOpts.IsPrintHiddenText() - && pSh->GetDoc()->ContainsHiddenChars()) - bApplyViewOptions |= true; - //switch off display of hidden paragraphs if on and hidden paragraphs are in use - const sal_Bool bOldShowHiddenPara = pCurrentViewOptions->IsShowHiddenPara(); - if( aOpts.IsPrintHiddenText() != bOldShowHiddenPara ) - { - const SwFieldType* pFldType = pSh->GetDoc()->GetSysFldType(RES_HIDDENPARAFLD); - if( pFldType && pFldType->GetDepends()) - bApplyViewOptions |= true; - } - const sal_Bool bOldShowHiddenField = pCurrentViewOptions->IsShowHiddenField(); - if( aOpts.IsPrintHiddenText() != bOldShowHiddenField ) - { - const SwFieldType* pFldType = pSh->GetDoc()->GetSysFldType(RES_HIDDENTXTFLD); - if( pFldType || pFldType->GetDepends()) - bApplyViewOptions |= true; - } - - SwViewOption* pOrgViewOption = 0; - bApplyViewOptions |= !aOpts.IsPrintTextPlaceholder(); - if(bApplyViewOptions) - { - pOrgViewOption = new SwViewOption(*pSh->GetViewOptions()); - if(bSwitchOff_IsFldName) - pOrgViewOption->SetFldName(aOpts.IsPrintHiddenText()); - - pOrgViewOption->SetShowHiddenChar(aOpts.IsPrintHiddenText()); - pOrgViewOption->SetViewMetaChars(sal_True); - pOrgViewOption->SetShowHiddenPara(aOpts.IsPrintHiddenText()); - pOrgViewOption->SetShowHiddenField(aOpts.IsPrintHiddenText()); - pOrgViewOption->SetShowPlaceHolderFields( aOpts.bPrintTextPlaceholder ); - - SW_MOD()->ApplyUsrPref(*pOrgViewOption, this, VIEWOPT_DEST_VIEW_ONLY ); - } - - if( nMergeType == DBMGR_MERGE_MAILMERGE || - DBMGR_MERGE_DOCUMENTS == nMergeType ) - { - if(DBMGR_MERGE_DOCUMENTS == nMergeType) - bStartJob = pMgr->MergePrintDocuments( *this, aOpts, *pProgress, bIsAPI ); - else - bStartJob = pMgr->MergePrint( *this, aOpts, *pProgress, bIsAPI ); - } - else - { - const BOOL bLockedView = pSh->IsViewLocked(); - pSh->LockView( TRUE ); - - //BrowseView abschalten und die View gegen alle Paints locken. - BOOL bBrowse = pSh->getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE); - SfxAllItemSet aSet( SFX_APP()->GetPool() ); - SfxBoolItem aBrowse( SID_BROWSER_MODE, FALSE ); - if ( bBrowse ) - { - if ( pSh->GetWin() ) - pSh->GetWin()->Update(); - pSh->LockPaint(); - aSet.Put( aBrowse, aBrowse.Which() ); - SfxRequest aReq( SID_BROWSER_MODE, 0, aSet ); - GetDocShell()->Execute( aReq ); - } - - // die Felder aktualisieren - BOOL bIsModified = pSh->IsModified(); - pSh->StartAllAction(); - SwDocStat aDocStat; - pSh->UpdateDocStat( aDocStat ); - pSh->EndAllTblBoxEdit(); - pSh->ViewShell::UpdateFlds(TRUE); - if( pSh->IsCrsrInTbl() ) - { - pSh->ClearTblBoxCntnt(); - pSh->SaveTblBoxCntnt(); - } - pSh->EndAllAction(); - - if( !bIsModified ) - pSh->ResetModified(); - - if( -1 != bPrintSelection ) - aOpts.bPrintSelection = 0 != bPrintSelection; - - uno::Sequence< beans::PropertyValue> aViewProperties(18); - beans::PropertyValue* pViewProperties = aViewProperties.getArray(); - pViewProperties[1].Name = C2U("PrintGraphics"); - pViewProperties[1].Value <<= (sal_Bool)aOpts.IsPrintGraphic(); - pViewProperties[2].Name = C2U("PrintTables"); - pViewProperties[2].Value <<= (sal_Bool)aOpts.IsPrintTable(); - pViewProperties[3].Name = C2U("PrintDrawings"); - pViewProperties[3].Value <<= (sal_Bool)aOpts.IsPrintDraw(); - pViewProperties[4].Name = C2U("PrintLeftPages"); - pViewProperties[4].Value <<= (sal_Bool)aOpts.IsPrintLeftPage(); - pViewProperties[5].Name = C2U("PrintRightPages"); - pViewProperties[5].Value <<= (sal_Bool)aOpts.IsPrintRightPage(); - pViewProperties[6].Name = C2U("PrintControls"); - pViewProperties[6].Value <<= (sal_Bool)aOpts.IsPrintControl(); - pViewProperties[7].Name = C2U("PrintReversed"); - pViewProperties[7].Value <<= (sal_Bool)aOpts.IsPrintReverse(); - pViewProperties[8].Name = C2U("PrintPaperFromSetup"); - pViewProperties[8].Value <<= (sal_Bool)aOpts.IsPaperFromSetup(); - pViewProperties[9].Name = C2U("PrintFaxName"); - pViewProperties[9].Value <<= aOpts.GetFaxName(); - pViewProperties[10].Name = C2U("PrintAnnotationMode"); - pViewProperties[10].Value <<= (text::NotePrintMode) aOpts.GetPrintPostIts(); - pViewProperties[11].Name = C2U("PrintProspect"); - pViewProperties[11].Value <<= (sal_Bool)aOpts.IsPrintProspect(); - pViewProperties[12].Name = C2U("PrintPageBackground"); - pViewProperties[12].Value <<= (sal_Bool)aOpts.IsPrintPageBackground(); - pViewProperties[13].Name = C2U("PrintBlackFonts"); - pViewProperties[13].Value <<= (sal_Bool)aOpts.IsPrintBlackFont(); - pViewProperties[0].Name = C2U("IsSinglePrintJob"); - pViewProperties[0].Value <<= (sal_Bool)aOpts.IsPrintSingleJobs(); - pViewProperties[14].Name = C2U("Selection"); - pViewProperties[14].Value <<= (sal_Bool)aOpts.bPrintSelection; - pViewProperties[15].Name = C2U("PrintEmptyPages"); - pViewProperties[15].Value <<= (sal_Bool)aOpts.bPrintEmptyPages; - pViewProperties[16].Name = C2U("PrintHiddenText"); - pViewProperties[16].Value <<= (sal_Bool)aOpts.bPrintHiddenText; - pViewProperties[17].Name = C2U("PrintTextPlaceholder"); - pViewProperties[17].Value <<= (sal_Bool)aOpts.bPrintTextPlaceholder; - SetAdditionalPrintOptions(aViewProperties); - - SfxViewShell::Print(*pProgress, bIsAPI ); -//TLPDF if ( !pProgress->IsAborted() ) - { - const boost::shared_ptr< Printer > pPrt( pPrinter ); // TLPDF - vcl::OldStylePrintAdaptor aPrtAdaptor( pPrt ); // TLPDF - - if( bPrtPros ) - { -//TLPDF bStartJob = pPrinter->StartJob( aOpts.GetJobName() ); -//TLPDF if( bStartJob ) - pSh->PrintProspectMM( aPrtAdaptor, aViewProperties, aOpts, bPrtPros_RTL ); /* TLPDF */ - } - else - bStartJob = pSh->PrintOrPDFExportMM( aPrtAdaptor, aViewProperties, aOpts ); /*TLPDF*/ - - if ( bBrowse ) - { - aBrowse.SetValue( TRUE ); - aSet.Put( aBrowse, aBrowse.Which() ); - SfxRequest aReq( SID_BROWSER_MODE, 0, aSet ); - GetDocShell()->Execute( aReq ); - pSh->UnlockPaint(); - } - } -//TLPDF else -//TLPDF bStartJob = FALSE; - - pSh->LockView( bLockedView ); - } - if(pOrgViewOption) - { - if(bSwitchOff_IsFldName) - pOrgViewOption->SetFldName(TRUE); - pOrgViewOption->SetShowHiddenChar(bOldShowHiddenChar); - pOrgViewOption->SetViewMetaChars(bOldMetaChars); - pOrgViewOption->SetShowHiddenField(bOldShowHiddenField); - pOrgViewOption->SetShowHiddenPara(bOldShowHiddenPara); - //must to be set to sal_True anyway - pOrgViewOption->SetShowPlaceHolderFields( sal_True ); - SW_MOD()->ApplyUsrPref(*pOrgViewOption, this, VIEWOPT_DEST_VIEW_ONLY ); - delete pOrgViewOption; - } - } - - if( !bStartJob ) - { - // Printer konnte nicht gestartet werden - delete pProgress; - return pPrinter->GetError(); - } - - pProgress->Stop(); -//TLPDF pProgress->DeleteOnEndPrint(); -//TLPDF pPrinter->EndJob(); - return pPrinter->GetError(); -} - - - /*-------------------------------------------------------------------- Beschreibung: TabPage fuer applikationsspezifische Druckoptionen --------------------------------------------------------------------*/ @@ -629,4 +354,3 @@ void SetAppPrintOptions( ViewShell* pSh, BOOL bWeb ) } } - -- cgit From 24e7c7a3173bf1612c9903466e88508852bce390 Mon Sep 17 00:00:00 2001 From: Oliver Specht Date: Tue, 1 Sep 2009 08:22:04 +0000 Subject: #i101242# mail merge printing --- sw/source/ui/dbui/dbmgr.cxx | 371 ++++++++++---------------------------------- 1 file changed, 79 insertions(+), 292 deletions(-) (limited to 'sw') diff --git a/sw/source/ui/dbui/dbmgr.cxx b/sw/source/ui/dbui/dbmgr.cxx index 8ca8463a379a..c1884e7ccbfc 100644 --- a/sw/source/ui/dbui/dbmgr.cxx +++ b/sw/source/ui/dbui/dbmgr.cxx @@ -455,114 +455,7 @@ BOOL SwNewDBMgr::MergeNew(const SwMergeDescriptor& rMergeDesc ) bRet = Merge(&rMergeDesc.rSh); // Mischen break; - case DBMGR_MERGE_MAILMERGE: // Serienbrief - { - SwView& rView = rMergeDesc.rSh.GetView(); -#ifdef TL_NOT_NOW /*TLPDF*/ - SfxDispatcher *pDis = rView.GetViewFrame()->GetDispatcher(); - SfxItemSet aPrintArgs( rView.GetPool(), - SID_SILENT, SID_SILENT, //5528 - SID_ASYNCHRON, SID_ASYNCHRON, //5811 - SID_PRINT_FIRST_PAGE, SID_PRINT_FIRST_PAGE, // 5001 - SID_PRINT_LAST_PAGE, SID_PRINT_LAST_PAGE, // 5002 - SID_PRINT_COPIES, SID_PRINT_COPIES, // 5003 - SID_PRINTER_NAME, SID_PRINTER_NAME, //5322 - SID_SELECTION, SID_SELECTION, //5346 - SID_FILE_NAME, SID_FILE_NAME, // 5507 - SID_PRINT_PAGES, SID_PRINT_PAGES, //6589 - SID_PRINT_COLLATE, SID_PRINT_COLLATE, //6590 - FN_QRY_MERGE, FN_QRY_MERGE, - 0 ); - aPrintArgs.Put(SfxBoolItem(FN_QRY_MERGE, TRUE) ); - - // !! Currently (Jan-2003) silent is defined by supplying *any* - // !! item!! (Thus according to OS it would be silent even when - // !! other items then SID_SILENT would be supplied!) - // !! Therefore it has to be the 0 pointer when not silent. - if(IsMergeSilent()) - { - aPrintArgs.Put( SfxBoolItem(SID_SILENT, TRUE) ); - } - // #i52629# aynchronous printing should only be done in silent mode - otherwise - // the printer dialog does not come up - aPrintArgs.Put( SfxBoolItem( SID_ASYNCHRON, rMergeDesc.bPrintAsync )); - - // convert PropertyValues - const beans::PropertyValue* pPrintOptions = rMergeDesc.aPrintOptions.getConstArray(); - for( sal_Int32 nOption = 0; nOption < rMergeDesc.aPrintOptions.getLength(); ++nOption) - { - if( pPrintOptions[nOption].Name.equalsAscii( "CopyCount" )) - { - sal_Int16 nCopies = 0; - if((pPrintOptions[nOption].Value >>= nCopies) && nCopies > 0) - aPrintArgs.Put( SfxInt16Item( SID_PRINT_COPIES, nCopies )); - } - else if( pPrintOptions[nOption].Name.equalsAscii( "FileName" )) - { - ::rtl::OUString sFileName; - if( (pPrintOptions[nOption].Value >>= sFileName) && sFileName.getLength() > 0) - aPrintArgs.Put( SfxStringItem( SID_FILE_NAME, sFileName )); - } - else if( pPrintOptions[nOption].Name.equalsAscii( "Collate" )) - { - sal_Bool bCollate = sal_False; - if( pPrintOptions[nOption].Value >>= bCollate ) - aPrintArgs.Put( SfxBoolItem( SID_PRINT_COLLATE, bCollate )); - } - else if( pPrintOptions[nOption].Name.equalsAscii( "Pages" )) - { - ::rtl::OUString sPages; - if( (pPrintOptions[nOption].Value >>= sPages) && sPages.getLength() ) - aPrintArgs.Put( SfxStringItem( SID_PRINT_PAGES, sPages )); - } - else if( pPrintOptions[nOption].Name.equalsAscii( "Wait" )) - { - sal_Bool bWait = sal_False; - if( pPrintOptions[nOption].Value >>= bWait ) - aPrintArgs.Put( SfxBoolItem( SID_ASYNCHRON, !bWait )); - } - - } -#endif //def TL_NOT_NOW /*TLPDF*/ - -// TLPDF pDis->Execute( SID_PRINTDOC, -// TLPDF SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD, -// TLPDF aPrintArgs ); -#if OSL_DEBUG_LEVEL > 1 - sal_Bool _bVal; - sal_Int16 _nVal; - rtl::OUString _sVal; - const beans::PropertyValue* pPrintOptions = rMergeDesc.aPrintOptions.getConstArray(); - for( sal_Int32 nOption = 0; nOption < rMergeDesc.aPrintOptions.getLength(); ++nOption) - { - rtl::OUString aName( pPrintOptions[nOption].Name ); - uno::Any aVal( pPrintOptions[nOption].Value ); - aVal >>= _bVal; - aVal >>= _nVal; - aVal >>= _sVal; - } -#endif - - // printing should be done synchronous otherwise the document - // might already become invalid during the process - uno::Sequence< beans::PropertyValue > aOptions( rMergeDesc.aPrintOptions ); - const sal_Int32 nOpts = aOptions.getLength(); - aOptions.realloc( nOpts + 1 ); - aOptions[ nOpts ].Name = rtl::OUString::createFromAscii( "Wait" ); - aOptions[ nOpts ].Value <<= sal_True ; - - const SwModuleOptions * pModOpt = SW_MOD()->GetModuleConfig(); - if (pModOpt->IsSinglePrintJob()) // single print job per document? - { - rView.ExecPrint( aOptions, sal_False, sal_False ); - } - else - { - // here use the print adaptor top get just one print job - } - } - break; - + case DBMGR_MERGE_MAILMERGE: // printing merge from 'old' merge dialog or from UNO-component case DBMGR_MERGE_MAILING: case DBMGR_MERGE_MAILFILES: case DBMGR_MERGE_SINGLE_FILE: @@ -1060,169 +953,6 @@ BOOL SwNewDBMgr::MergePrint( SwView& rView, return bRet; } -/*-- 21.06.2004 09:08:16--------------------------------------------------- - - -----------------------------------------------------------------------*/ -BOOL SwNewDBMgr::MergePrintDocuments( SwView& rView, - SwPrtOptions& rOpt, SfxProgress& rProgress, BOOL bIsAPI ) -{ - SwWrtShell* pSh = &rView.GetWrtShell(); - //check if the doc is synchronized and contains at least one linked section - //merge source is already open - rOpt.nMergeCnt = 0; - rOpt.SetPrintSingleJobs( sal_True ); - -//TLPDF SfxPrinter *pPrt = pSh->getIDocumentDeviceAccess()->getPrinter( false ); - const boost::shared_ptr< Printer > pPrt( new Printer /* Printer( const JobSetup& rJobSetup ) */ ); // TLPDF - vcl::OldStylePrintAdaptor aPrtAdaptor( pPrt ); // TLPDF - const boost::shared_ptr< vcl::PrinterController > pPrtController( &aPrtAdaptor ); -//TLPDF Link aSfxSaveLnk = pPrt->GetEndPrintHdl(); -//TLPDF if( rOpt.IsPrintSingleJobs() ) -//TLPDF pPrt->SetEndPrintHdl( Link() ); - - BOOL bUserBreak = FALSE, - bRet = FALSE; - //calculate number of data sets to be printed - - Sequence aViewProperties(16); - PropertyValue* pViewProperties = aViewProperties.getArray(); - pViewProperties[0].Name = C2U("MailMergeCount"); - pViewProperties[0].Value <<= (sal_Int32)rOpt.nMergeCnt; - pViewProperties[1].Name = C2U("PrintGraphics"); - pViewProperties[1].Value <<= (sal_Bool)rOpt.IsPrintGraphic(); - pViewProperties[2].Name = C2U("PrintTables"); - pViewProperties[2].Value <<= (sal_Bool)rOpt.IsPrintTable(); - pViewProperties[3].Name = C2U("PrintDrawings"); - pViewProperties[3].Value <<= (sal_Bool)rOpt.IsPrintDraw(); - pViewProperties[4].Name = C2U("PrintLeftPages"); - pViewProperties[4].Value <<= (sal_Bool)rOpt.IsPrintLeftPage(); - pViewProperties[5].Name = C2U("PrintRightPages"); - pViewProperties[5].Value <<= (sal_Bool)rOpt.IsPrintRightPage(); - pViewProperties[6].Name = C2U("PrintControls"); - pViewProperties[6].Value <<= (sal_Bool)rOpt.IsPrintControl(); - pViewProperties[7].Name = C2U("PrintReversed"); - pViewProperties[7].Value <<= (sal_Bool)rOpt.IsPrintReverse(); - pViewProperties[8].Name = C2U("PrintPaperFromSetup"); - pViewProperties[8].Value <<= (sal_Bool)rOpt.IsPaperFromSetup(); - pViewProperties[9].Name = C2U("PrintFaxName"); - pViewProperties[9].Value <<= rOpt.GetFaxName(); - pViewProperties[10].Name = C2U("PrintAnnotationMode"); - pViewProperties[10].Value <<= (text::NotePrintMode) rOpt.GetPrintPostIts(); - pViewProperties[11].Name = C2U("PrintProspect"); - pViewProperties[11].Value <<= (sal_Bool)rOpt.IsPrintProspect(); - pViewProperties[12].Name = C2U("PrintPageBackground"); - pViewProperties[12].Value <<= (sal_Bool)rOpt.IsPrintPageBackground(); - pViewProperties[13].Name = C2U("PrintBlackFonts"); - pViewProperties[13].Value <<= (sal_Bool)rOpt.IsPrintBlackFont(); - pViewProperties[14].Name = C2U("IsSinglePrintJob"); - pViewProperties[14].Value <<= (sal_Bool)rOpt.IsPrintSingleJobs(); - pViewProperties[15].Name = C2U("PrintEmptyPages"); - pViewProperties[15].Value <<= (sal_Bool)rOpt.IsPrintEmptyPages(); - - rView.SetAdditionalPrintOptions(aViewProperties); - - SwMailMergeConfigItem* pConfigItem = rView.GetMailMergeConfigItem(); - DBG_ASSERT(pConfigItem, "mail merge config item is missing"); - if(!pConfigItem) - return sal_False; - - USHORT nDocStart = pConfigItem->GetPrintRangeStart(); - USHORT nDocEnd = pConfigItem->GetPrintRangeEnd(); - DBG_ASSERT(nDocStart < nDocEnd && nDocEnd <= pConfigItem->GetMergedDocumentCount(), - "merge print settings are not correct"); - - for( sal_uInt32 nPrintDocument = nDocStart; nPrintDocument < nDocEnd; ++nPrintDocument) - { - SwDocMergeInfo& rDocInfo = pConfigItem->GetDocumentMergeInfo(nPrintDocument); - rOpt.aMulti.SelectAll(FALSE); - rOpt.aMulti.Select(Range( rDocInfo.nStartPageInTarget, rDocInfo.nEndPageInTarget ), TRUE ); - - ++rOpt.nMergeAct; - - // launch MailMergeEvent if required - const SwXMailMerge *pEvtSrc = GetMailMergeEvtSrc(); - if (pEvtSrc) - { - uno::Reference< XInterface > xRef( (XMailMergeBroadcaster *) pEvtSrc ); - text::MailMergeEvent aEvt( xRef, rView.GetDocShell()->GetModel() ); - pEvtSrc->LaunchMailMergeEvent( aEvt ); - } - - String aTmp; - aTmp += String::CreateFromInt32( rDocInfo.nStartPageInTarget ); - aTmp += '-'; - aTmp += String::CreateFromInt32( rDocInfo.nEndPageInTarget ); - - Sequence aAddViewProperties(1); - PropertyValue* pAddViewProperties = aAddViewProperties.getArray(); - pAddViewProperties[0].Name = C2U("Pages"); - pAddViewProperties[0].Value <<= ::rtl::OUString( aTmp ); - rView.SetAdditionalPrintOptions(aAddViewProperties); - - // TLPDF: What abou this line ??? - rView.SfxViewShell::Print( rProgress, bIsAPI ); // ggf Basic-Macro ausfuehren - if( rOpt.IsPrintSingleJobs() && bRet ) - { - //rOpt.bJobStartet = FALSE; - bRet = FALSE; - } - - bMergeLock = TRUE; - if(rOpt.IsPrintProspect()) - { -//TLPDF if( pPrt->IsJobActive() || pPrt->StartJob( rOpt.GetJobName() )) -//TLPDF { - pSh->PrintProspectMM( aPrtAdaptor, aAddViewProperties, rOpt, rOpt.IsPrintProspectRTL() ); - bRet = TRUE; -//TLPDF } - } - else if( pSh->PrintOrPDFExportMM( aPrtAdaptor, aAddViewProperties, rOpt ) /* TLPDF */ ) - bRet = TRUE; - bMergeLock = FALSE; - - if( !pPrt->IsJobActive() ) - { - bUserBreak = TRUE; - bRet = FALSE; - break; - } - if( !rOpt.IsPrintSingleJobs() ) - { - String& rJNm = (String&)rOpt.GetJobName(); - rJNm.Erase(); - } - } - - if( rOpt.IsPrintSingleJobs() ) - { -#ifdef TL_NOT_NOW /*TLPDF*/ - SfxPrinter* pTmpPrinter = pSh->getIDocumentDeviceAccess()->getPrinter( true ); - pTmpPrinter->SetEndPrintHdl( aSfxSaveLnk ); - if ( !bUserBreak && !pTmpPrinter->IsJobActive() ) //Schon zu spaet? - aSfxSaveLnk.Call( pTmpPrinter ); -#endif // TL_NOT_NOW /*TLPDF*/ - } - - rOpt.nMergeCnt = 0; - rOpt.nMergeAct = 0; - - nMergeType = DBMGR_INSERT; - - SwDocShell* pDocSh = rView.GetDocShell(); - SfxViewFrame *pTmpFrm = SfxViewFrame::GetFirst(pDocSh); - - while (pTmpFrm) // Alle Views Invalidieren - { - SwView *pVw = PTR_CAST(SwView, pTmpFrm->GetViewShell()); - if (pVw) - pVw->GetEditWin().Invalidate(); - pTmpFrm = pTmpFrm->GetNext(*pTmpFrm, pDocSh); - } - - return bRet; -} - - /*-------------------------------------------------------------------- Beschreibung: Serienbriefe als einzelne Dokumente speichern @@ -1370,6 +1100,7 @@ BOOL SwNewDBMgr::MergeMailFiles(SwWrtShell* pSourceShell, // in case of creating a single resulting file this has to be created here SwWrtShell* pTargetShell = 0; SfxObjectShellRef xTargetDocShell; + SwView* pTargetView = 0; std::auto_ptr< utl::TempFile > aTempFile; String sModifiedStartingPageDesc; String sStartingPageDesc; @@ -1382,7 +1113,7 @@ BOOL SwNewDBMgr::MergeMailFiles(SwWrtShell* pSourceShell, xTargetDocShell->DoInitNew( 0 ); SfxViewFrame* pTargetFrame = SfxViewFrame::CreateViewFrame( *xTargetDocShell, 0, TRUE ); - SwView* pTargetView = static_cast( pTargetFrame->GetViewShell() ); + pTargetView = static_cast( pTargetFrame->GetViewShell() ); //initiate SelectShell() to create sub shells pTargetView->AttrChangedNotify( &pTargetView->GetWrtShell() ); @@ -1703,27 +1434,83 @@ BOOL SwNewDBMgr::MergeMailFiles(SwWrtShell* pSourceShell, // save the single output document if(rMergeDescriptor.bCreateSingleFile || bAsSingleFile) { - DBG_ASSERT( aTempFile.get(), "Temporary file not available" ); - INetURLObject aTempFileURL(bAsSingleFile ? sSubject : aTempFile->GetURL()); - SfxMedium* pDstMed = new SfxMedium( - aTempFileURL.GetMainURL( INetURLObject::NO_DECODE ), - STREAM_STD_READWRITE, TRUE ); - pDstMed->SetFilter( pStoreToFilter ); - if(pDstMed->GetItemSet()) + if( rMergeDescriptor.nMergeType != DBMGR_MERGE_MAILMERGE ) { - if(pStoreToFilterOptions ) - pDstMed->GetItemSet()->Put(SfxStringItem(SID_FILE_FILTEROPTIONS, *pStoreToFilterOptions)); - if(rMergeDescriptor.aSaveToFilterData.getLength()) - pDstMed->GetItemSet()->Put(SfxUsrAnyItem(SID_FILTER_DATA, makeAny(rMergeDescriptor.aSaveToFilterData))); - } + DBG_ASSERT( aTempFile.get(), "Temporary file not available" ); + INetURLObject aTempFileURL(bAsSingleFile ? sSubject : aTempFile->GetURL()); + SfxMedium* pDstMed = new SfxMedium( + aTempFileURL.GetMainURL( INetURLObject::NO_DECODE ), + STREAM_STD_READWRITE, TRUE ); + pDstMed->SetFilter( pStoreToFilter ); + if(pDstMed->GetItemSet()) + { + if(pStoreToFilterOptions ) + pDstMed->GetItemSet()->Put(SfxStringItem(SID_FILE_FILTEROPTIONS, *pStoreToFilterOptions)); + if(rMergeDescriptor.aSaveToFilterData.getLength()) + pDstMed->GetItemSet()->Put(SfxUsrAnyItem(SID_FILTER_DATA, makeAny(rMergeDescriptor.aSaveToFilterData))); + } - xTargetDocShell->DoSaveAs(*pDstMed); - xTargetDocShell->DoSaveCompleted(pDstMed); - if( xTargetDocShell->GetError() ) + xTargetDocShell->DoSaveAs(*pDstMed); + xTargetDocShell->DoSaveCompleted(pDstMed); + if( xTargetDocShell->GetError() ) + { + // error message ?? + ErrorHandler::HandleError( xTargetDocShell->GetError() ); + bLoop = FALSE; + } + } + else if( pTargetView ) // must be available! { - // error message ?? - ErrorHandler::HandleError( xTargetDocShell->GetError() ); - bLoop = FALSE; + //print the target document + #if OSL_DEBUG_LEVEL > 1 + sal_Bool _bVal; + sal_Int16 _nVal; + rtl::OUString _sVal; + const beans::PropertyValue* pDbgPrintOptions = rMergeDescriptor.aPrintOptions.getConstArray(); + for( sal_Int32 nOption = 0; nOption < rMergeDescriptor.aPrintOptions.getLength(); ++nOption) + { + rtl::OUString aName( pDbgPrintOptions[nOption].Name ); + uno::Any aVal( pDbgPrintOptions[nOption].Value ); + aVal >>= _bVal; + aVal >>= _nVal; + aVal >>= _sVal; + } + #endif + // printing should be done synchronously otherwise the document + // might already become invalid during the process + uno::Sequence< beans::PropertyValue > aOptions( rMergeDescriptor.aPrintOptions ); + const sal_Int32 nOpts = aOptions.getLength(); + aOptions.realloc( nOpts + 1 ); + aOptions[ nOpts ].Name = rtl::OUString::createFromAscii( "Wait" ); + aOptions[ nOpts ].Value <<= sal_True ; +// aPrintArgs.Put(SfxBoolItem(FN_QRY_MERGE, TRUE) ); +// // #i52629# aynchronous printing should only be done in silent mode - otherwise +// // the printer dialog does not come up +// aPrintArgs.Put( SfxBoolItem( SID_ASYNCHRON, rMergeDescriptor.bPrintAsync )); + // move print options + const beans::PropertyValue* pPrintOptions = rMergeDescriptor.aPrintOptions.getConstArray(); + for( sal_Int32 nOption = 0; nOption < rMergeDescriptor.aPrintOptions.getLength(); ++nOption) + { + if( pPrintOptions[nOption].Name.equalsAscii( "CopyCount" ) + ||( pPrintOptions[nOption].Name.equalsAscii( "FileName" )) + ||( pPrintOptions[nOption].Name.equalsAscii( "Collate" )) + ||( pPrintOptions[nOption].Name.equalsAscii( "Pages" )) + ||( pPrintOptions[nOption].Name.equalsAscii( "Wait" ))) + { + aOptions.realloc( nOpts + 1 ); + aOptions[ nOpts ].Name = pPrintOptions[nOption].Name; + aOptions[ nOpts ].Value = pPrintOptions[nOption].Value ; + } + } + + const SwModuleOptions * pModOpt = SW_MOD()->GetModuleConfig(); +// if (pModOpt->IsSinglePrintJob()) +// { +// } +// else +// { + pTargetView->ExecPrint( aOptions, IsMergeSilent(), rMergeDescriptor.bPrintAsync ); +// } } xTargetDocShell->DoClose(); } @@ -2955,6 +2742,7 @@ void SwNewDBMgr::ExecuteFormLetter( SwWrtShell& rSh, SwMergeDescriptor aMergeDesc( pImpl->pMergeDialog->GetMergeType(), pView->GetWrtShell(), aDescriptor ); aMergeDesc.sSaveToFilter = pImpl->pMergeDialog->GetSaveFilter(); + aMergeDesc.bCreateSingleFile= true; MergeNew(aMergeDesc); pWorkDoc->SetNewDBMgr( pWorkDBMgr ); @@ -3448,5 +3236,4 @@ void SwConnectionDisposedListener_Impl::disposing( const EventObject& rSource ) rDBMgr.aDataSourceParams.DeleteAndDestroy(nPos - 1); } } -} - +} \ No newline at end of file -- cgit From 9582d9a634f47f3f8fe75f3ac67835bbd154d016 Mon Sep 17 00:00:00 2001 From: Oliver Specht Date: Tue, 1 Sep 2009 08:22:22 +0000 Subject: #i101242# mail merge printing --- sw/source/ui/dbui/mmoutputpage.cxx | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'sw') diff --git a/sw/source/ui/dbui/mmoutputpage.cxx b/sw/source/ui/dbui/mmoutputpage.cxx index 72fc1e122a8e..bcf6b6409744 100644 --- a/sw/source/ui/dbui/mmoutputpage.cxx +++ b/sw/source/ui/dbui/mmoutputpage.cxx @@ -991,6 +991,13 @@ IMPL_LINK(SwMailMergeOutputPage, PrintHdl_Impl, PushButton*, EMPTYARG) nEnd = rConfigItem.GetMergedDocumentCount(); } rConfigItem.SetPrintRange( (USHORT)nBegin, (USHORT)nEnd ); + SwDocMergeInfo& rStartInfo = rConfigItem.GetDocumentMergeInfo(nBegin); + SwDocMergeInfo& rEndInfo = rConfigItem.GetDocumentMergeInfo(nEnd - 1); + + rtl::OUString sPages(rtl::OUString::valueOf( rStartInfo.nStartPageInTarget )); + sPages += rtl::OUString::createFromAscii( " - "); + sPages += rtl::OUString::valueOf( rEndInfo.nEndPageInTarget ); + SwWrtShell& rSh = pTargetView->GetWrtShell(); pTargetView->SetMailMergeConfigItem(&rConfigItem, 0, sal_False); if(m_pTempPrinter) @@ -1005,8 +1012,14 @@ IMPL_LINK(SwMailMergeOutputPage, PrintHdl_Impl, PushButton*, EMPTYARG) SfxDispatcher *pDis = pTargetView->GetViewFrame()->GetDispatcher(); SfxBoolItem aMergeSilent(SID_SILENT, sal_False); m_pWizard->enableButtons(WZB_CANCEL, sal_False); - pDis->Execute(SID_PRINTDOCDIRECT, - SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD, &aMergeSilent, 0L); + + uno::Sequence < beans::PropertyValue > aProps( 2 ); + aProps[0]. Name = rtl::OUString::createFromAscii("MonitorVisible"); + aProps[0].Value <<= sal_True; + aProps[1]. Name = rtl::OUString::createFromAscii("Pages"); + aProps[1]. Value <<= sPages; + + pTargetView->ExecPrint( aProps, false, true ); SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_MAIL_MERGE_END, pObjSh)); pTargetView->SetMailMergeConfigItem(0, 0, sal_False); -- cgit From ba1e298590c503608e5c0b792288e0ef28186e90 Mon Sep 17 00:00:00 2001 From: Oliver Specht Date: Tue, 1 Sep 2009 08:23:11 +0000 Subject: #i101242# print after creation of full output document --- sw/source/ui/uno/unomailmerge.cxx | 1 + 1 file changed, 1 insertion(+) (limited to 'sw') diff --git a/sw/source/ui/uno/unomailmerge.cxx b/sw/source/ui/uno/unomailmerge.cxx index 3acb1e25bd31..effee6426d45 100644 --- a/sw/source/ui/uno/unomailmerge.cxx +++ b/sw/source/ui/uno/unomailmerge.cxx @@ -725,6 +725,7 @@ uno::Any SAL_CALL SwXMailMerge::execute( // when mail merge is called as command line macro aMergeDesc.bPrintAsync = sal_False; aMergeDesc.aPrintOptions = aPrintSettings; + aMergeDesc.bCreateSingleFile = true; } else /* FILE and MAIL*/ { -- cgit From 467351957174c318a81fede4937d0a21fda7828e Mon Sep 17 00:00:00 2001 From: Oliver Specht Date: Tue, 1 Sep 2009 08:26:48 +0000 Subject: #i101242# single print jobs not supported anymore --- sw/source/ui/envelp/mailmrge.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sw') diff --git a/sw/source/ui/envelp/mailmrge.cxx b/sw/source/ui/envelp/mailmrge.cxx index fd9caec98c24..97c5a208ec45 100644 --- a/sw/source/ui/envelp/mailmrge.cxx +++ b/sw/source/ui/envelp/mailmrge.cxx @@ -227,6 +227,7 @@ SwMailMergeDlg::SwMailMergeDlg(Window* pParent, SwWrtShell& rShell, m_aDialogSize( GetSizePixel() ) { FreeResource(); + aSingleJobsCB.Show(sal_False); // not supported in since cws printerpullpages anymore //task #97066# mailing of form letters is currently not supported aMailingRB.Show(FALSE); aSubjectFT.Show(FALSE); @@ -347,7 +348,7 @@ SwMailMergeDlg::SwMailMergeDlg(Window* pParent, SwWrtShell& rShell, pModOpt = SW_MOD()->GetModuleConfig(); - aSingleJobsCB.Check(pModOpt->IsSinglePrintJob()); + //aSingleJobsCB.Check(pModOpt->IsSinglePrintJob());// not supported in since cws printerpullpages anymore sal_Int16 nMailingMode(pModOpt->GetMailingFormats()); aFormatSwCB.Check((nMailingMode & TXTFORMAT_OFFICE) != 0); @@ -941,4 +942,3 @@ SwMailMergeFieldConnectionsDlg::~SwMailMergeFieldConnectionsDlg() { } - -- cgit From 8b9588e75bd53b64fa3d1cd0a006a14e74578f96 Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Tue, 1 Sep 2009 15:16:12 +0000 Subject: #i101242# applying view options and formatting doc now only done in getRendererCount --- sw/inc/printdata.hxx | 72 +++++---- sw/inc/swprtopt.hxx | 18 ++- sw/inc/unotxdoc.hxx | 31 ++++ sw/inc/viewsh.hxx | 14 +- sw/source/core/view/viewpg.cxx | 20 +-- sw/source/core/view/vprint.cxx | 145 +++++++++++------- sw/source/ui/inc/view.hxx | 4 - sw/source/ui/uiview/pview.cxx | 2 +- sw/source/ui/uiview/view.cxx | 96 ++++++------ sw/source/ui/uno/unotxdoc.cxx | 333 ++++++++++++++++++----------------------- 10 files changed, 383 insertions(+), 352 deletions(-) (limited to 'sw') diff --git a/sw/inc/printdata.hxx b/sw/inc/printdata.hxx index 085121060c8e..14303ad40d5d 100644 --- a/sw/inc/printdata.hxx +++ b/sw/inc/printdata.hxx @@ -42,10 +42,36 @@ class SwPageFrm; class SwDoc; +class SwDocShell; class ViewShell; class _SetGetExpFlds; class SwViewOption; class OutputDevice; +class SwViewOptionAdjust_Impl; +class SwPrtOptions; +class SwWrtShell; + + +//////////////////////////////////////////////////////////// + + +class SwPrintUIOptions : public vcl::PrinterOptionsHelper +{ + OutputDevice* m_pLast; + +public: + SwPrintUIOptions( BOOL bWeb = FALSE ); + ~SwPrintUIOptions(); + + bool processPropertiesAndCheckFormat( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& i_rNewProp ); + + bool IsPrintLeftPages() const; + bool IsPrintRightPages() const; + bool IsPrintEmptyPages( bool bIsPDFExport ) const; + bool IsPrintTables() const; + bool IsPrintGraphics() const; + bool IsPrintDrawings() const; +}; //////////////////////////////////////////////////////////// @@ -71,7 +97,12 @@ class SwRenderData // -1 indicates a half page to be left empty. std::vector< std::pair< sal_Int32, sal_Int32 > > m_aPagePairs; - rtl::OUString m_PageRange; + rtl::OUString m_aPageRange; + + // the view options to be applied for printing + SwViewOptionAdjust_Impl * m_pViewOptionAdjust; + + SwPrtOptions * m_pPrtOptions; public: @@ -89,6 +120,19 @@ public: void CreatePostItData( SwDoc *pDoc, const SwViewOption *pViewOpt, OutputDevice *pOutDev ); void DeletePostItData(); + bool IsViewOptionAdjust() const { return m_pViewOptionAdjust != 0; } + void ViewOptionAdjustStart( SwWrtShell& rSh ); + void ViewOptionAdjustStop(); + + bool HasSwPrtOptions() const { return m_pPrtOptions != 0; } + void SetSwPrtOptions( SwPrtOptions * pOpt ) { m_pPrtOptions = pOpt; } + const SwPrtOptions * GetSwPrtOptions() const { return m_pPrtOptions; } + SwPrtOptions & GetSwPrtOptionsRef() { return *m_pPrtOptions; } + void MakeSwPrtOptions( SwPrtOptions &rOptions, const SwDocShell *pDocShell, + const SwPrintUIOptions *pOpt, const SwRenderData *pData, + bool bIsSkipEmptyPages, bool bIsPDFExport ); + + typedef std::map< sal_Int32, const SwPageFrm * > ValidStartFramesMap_t; typedef std::vector< std::pair< sal_Int32, sal_Int32 > > PagePairsVec_t; @@ -117,30 +161,8 @@ public: PagePairsVec_t & GetPagePairsForProspectPrinting() { return m_aPagePairs; } const PagePairsVec_t & GetPagePairsForProspectPrinting() const { return m_aPagePairs; } - rtl::OUString GetPageRange() const { return m_PageRange; } - void SetPageRange( const rtl::OUString &rRange ) { m_PageRange = rRange; } -}; - - -//////////////////////////////////////////////////////////// - - -class SwPrintUIOptions : public vcl::PrinterOptionsHelper -{ - OutputDevice* m_pLast; - -public: - SwPrintUIOptions( BOOL bWeb = FALSE ); - ~SwPrintUIOptions(); - - bool processPropertiesAndCheckFormat( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& i_rNewProp ); - - bool IsPrintLeftPages() const; - bool IsPrintRightPages() const; - bool IsPrintEmptyPages( bool bIsPDFExport ) const; - bool IsPrintTables() const; - bool IsPrintGraphics() const; - bool IsPrintDrawings() const; + rtl::OUString GetPageRange() const { return m_aPageRange; } + void SetPageRange( const rtl::OUString &rRange ) { m_aPageRange = rRange; } }; diff --git a/sw/inc/swprtopt.hxx b/sw/inc/swprtopt.hxx index 86bcefa5d455..76930675eb6c 100644 --- a/sw/inc/swprtopt.hxx +++ b/sw/inc/swprtopt.hxx @@ -45,6 +45,10 @@ #define POSTITS_ENDPAGE 3 +class PrintDialog; +class SfxPrinter; + + //////////////////////////////////////////////////////////// @@ -84,11 +88,15 @@ public: #endif - SwPrtOptions& operator=(const SwPrintData& rData) - { - SwPrintData::operator=(rData); - return *this; - } + SwPrtOptions& operator=(const SwPrintData& rData) + { + SwPrintData::operator=(rData); + return *this; + } + + // get print options + void MakeOptions( PrintDialog* pDlg, + BOOL* pPrtProspect, BOOL* pPrtProspect_RTL, BOOL bWeb, SfxPrinter* pPrt, SwPrintData* pData ); }; diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx index f2ec7fc21d01..e0fa90de0ac7 100644 --- a/sw/inc/unotxdoc.hxx +++ b/sw/inc/unotxdoc.hxx @@ -128,10 +128,15 @@ class SfxViewFrame; class SwPrintUIOptions; class SwPrintData; class SwRenderData; +class SwPrtOptions; +class SwViewOption; +class SwWrtShell; + typedef UnoActionContext* UnoActionContextPtr; SV_DECL_PTRARR(ActionContextArr, UnoActionContextPtr, 4, 4) + /****************************************************************************** * ******************************************************************************/ @@ -231,6 +236,7 @@ class SwXTextDocument : public SwXTextDocumentBaseClass, // used for XRenderable implementation SfxViewShell * GuessViewShell( const css::uno::Reference< css::frame::XController > xController = css::uno::Reference< css::frame::XController >() ); SwDoc * GetRenderDoc( SfxViewShell *&rpView, const css::uno::Any& rSelection, bool bIsPDFExport ); + SfxViewShell * GetRenderView( const SwPrintUIOptions &rOpt, bool bIsPDFExport ); rtl::OUString maBuildId; @@ -432,6 +438,7 @@ public: SwXDrawPage* GetDrawPage(); SwDocShell* GetDocShell() {return pDocShell;} + void * SAL_CALL operator new( size_t ) throw(); void SAL_CALL operator delete( void * ) throw(); @@ -579,3 +586,27 @@ public: virtual void onChange(); }; + + +/*-- 06.01.2004 15:08:34--------------------------------------------------- + The class SwViewOptionAdjust_Impl is used to adjust the SwViewOption of + the current ViewShell so that fields are not printed as commands and + hidden text and hidden characters are always invisible. + After printing the view options are restored + -----------------------------------------------------------------------*/ +class SwViewOptionAdjust_Impl +{ + bool m_bSwitchOff_IsFldName; + bool m_bSwitchOff_PlaceHolderView; + bool m_bSwitchOff_HiddenChar; + bool m_bSwitchOff_HiddenParagraphs; + bool m_bSwitchOff_IsShowHiddenField; + + SwViewOption* m_pViewOption; + SwWrtShell& m_rShell; +public: + SwViewOptionAdjust_Impl(SwWrtShell& rSh); + ~SwViewOptionAdjust_Impl(); +}; + + diff --git a/sw/inc/viewsh.hxx b/sw/inc/viewsh.hxx index 1e09bbde33de..636608279dbb 100644 --- a/sw/inc/viewsh.hxx +++ b/sw/inc/viewsh.hxx @@ -218,8 +218,7 @@ public: const SwNodes& GetNodes() const; //Nach Druckerwechsel, vom Doc - //pPDFOut != NULL is used for PDF export. - void InitPrt( /*TLPDF Printer * ,*/ OutputDevice *pOutDev /* = NULL */ ); + void InitPrt( OutputDevice *pOutDev ); //Klammerung von zusammengehoerenden Aktionen. inline void StartAction(); @@ -380,17 +379,6 @@ public: void PrintProspect( OutputDevice *pOutDev, const SwPrintData &rPrintData, sal_Int32 nRenderer /* offset in vector of page pairs for prospect printing */ ); - // printing of a complete document for mail merge - // bIsPDFExport == true is: do PDF Export (no printing!) - sal_Bool PrintOrPDFExportMM( vcl::OldStylePrintAdaptor &rAdaptor, - const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > &rOptions, - const SwPrtOptions &rPrintData, bool bIsPDFExport = sal_False ); - - // printing of a complete brochure for mail merge - void PrintProspectMM( vcl::OldStylePrintAdaptor &rAdaptor, - const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > &rOptions, - const SwPrintData &rPrintData, bool bProspectRTL ); - // printing for OLE 2.0 static void PrtOle2( SwDoc *pDoc, const SwViewOption *pOpt, const SwPrintData& rOptions, OutputDevice* pOleOut, const Rectangle& rRect ); diff --git a/sw/source/core/view/viewpg.cxx b/sw/source/core/view/viewpg.cxx index cc97ae5ef3ed..360593897084 100644 --- a/sw/source/core/view/viewpg.cxx +++ b/sw/source/core/view/viewpg.cxx @@ -454,22 +454,6 @@ void ViewShell::PrintPreViewPage( SwPrtOptions& rOptions, } -void ViewShell::PrintProspectMM( - vcl::OldStylePrintAdaptor &rAdaptor, - const uno::Sequence< beans::PropertyValue > &rOptions, /* TLPDF: this or the above ? */ - const SwPrintData & rPrintData, - bool bProspectRTL ) -{ - (void) rOptions; (void) rAdaptor; (void) rPrintData; (void) bProspectRTL; - // to be removed (not needed) -#ifdef TL_NOT_NOW /* TLPDF */ - - const boost::shared_ptr< vcl::PrinterController > pPrtController( &rAdaptor ); - Printer::PrintJob( pPrtController, JobSetup() ); -#endif // TL_NOT_NOW /* TLPDF */ -} - - // print brochure // OD 05.05.2003 #i14016# - consider empty pages on calculation of the scaling // for a page to be printed. @@ -507,6 +491,7 @@ void ViewShell::PrintProspect( aShell.PrepareForPrint( rPrintData ); +#ifdef TL_NOT_NOW // TLPDF: applying view options and formatting the dcoument should now only be done in getRendererCount! // gibt es versteckte Absatzfelder, unnoetig wenn die Absaetze bereits // ausgeblendet sind. int bHiddenFlds = FALSE; @@ -524,6 +509,7 @@ void ViewShell::PrintProspect( // Seiten fuers Drucken formatieren aShell.CalcPagesForPrint( nPageMax, 0 /*(USHORT)aPages.Max(), &rProgress*/ ); +#endif // TL_NOT_NOW // TLPDF MapMode aMapMode( MAP_TWIP ); Size aPrtSize( pPrinter->PixelToLogic( pPrinter->GetPaperSizePixel(), aMapMode ) ); /* TLPDF */ @@ -645,12 +631,14 @@ void ViewShell::PrintProspect( SwPaintQueue::Repaint(); +#ifdef TL_NOT_NOW // TLPDF: applying view options and formatting the dcoument should now only be done in getRendererCount! if( bHiddenFlds ) { SwMsgPoolItem aHnt( RES_HIDDENPARA_PRINT ); pFldType->Modify( &aHnt, 0); CalcPagesForPrint( nPageMax /*(USHORT)aPages.Max()*/ ); } +#endif // TL_NOT_NOW // TLPDF pFntCache->Flush(); // restore settings of OutputDevice (should be done always now since the diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index 1e399b2ee3f7..3016075d1002 100644 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -69,6 +69,7 @@ #include #include #include +#include #include #include #include // Imp->SetFirstVisPageInvalid() @@ -239,22 +240,30 @@ const XubString& SwPrtOptions::MakeNextJobName() /*****************************************************************************/ - SwRenderData::SwRenderData() { m_pPostItFields = 0; m_pPostItDoc = 0; m_pPostItShell = 0; + + m_pViewOptionAdjust = 0; + m_pPrtOptions = 0; } SwRenderData::~SwRenderData() { + delete m_pViewOptionAdjust; m_pViewOptionAdjust = 0; + delete m_pPrtOptions; m_pPrtOptions = 0; + DBG_ASSERT( !m_pPostItShell, "m_pPostItShell should already have been deleted" ); + DBG_ASSERT( !m_pPostItDoc, "m_pPostItDoc should already have been deleted" ); + DBG_ASSERT( !m_pPostItFields, " should already have been deleted" ); } void SwRenderData::CreatePostItData( SwDoc *pDoc, const SwViewOption *pViewOpt, OutputDevice *pOutDev ) { + DBG_ASSERT( !m_pPostItFields && !m_pPostItDoc && !m_pPostItShell, "some post-it data already exists" ); m_pPostItFields = new _SetGetExpFlds; lcl_GetPostIts( pDoc, *m_pPostItFields ); m_pPostItDoc = new SwDoc; @@ -283,6 +292,81 @@ void SwRenderData::DeletePostItData() } +void SwRenderData::ViewOptionAdjustStart( SwWrtShell& rSh ) +{ + DBG_ASSERT( !m_pViewOptionAdjust, "m_pViewOptionAdjust already exists" ); + m_pViewOptionAdjust = new SwViewOptionAdjust_Impl( rSh ); +} + + +void SwRenderData::ViewOptionAdjustStop() +{ + if (IsViewOptionAdjust()) + { + delete m_pViewOptionAdjust; + m_pViewOptionAdjust = 0; + } +} + + +void SwRenderData::MakeSwPrtOptions( + SwPrtOptions &rOptions, + const SwDocShell *pDocShell, + const SwPrintUIOptions *pOpt, + const SwRenderData *pData, + bool bIsSkipEmptyPages, + bool bIsPDFExport ) +{ + if (!pDocShell || !pOpt || !pData) + return; + + // get default print options + const TypeId aSwWebDocShellTypeId = TYPE(SwWebDocShell); + BOOL bWeb = pDocShell->IsA( aSwWebDocShellTypeId ); + rOptions.MakeOptions( NULL, NULL, NULL, bWeb, NULL, NULL ); + + // get print options to use from provided properties + rOptions.bPrintGraphic = pOpt->IsPrintGraphics(); + rOptions.bPrintTable = pOpt->IsPrintTables(); + rOptions.bPrintDraw = pOpt->IsPrintDrawings(); + rOptions.bPrintControl = pOpt->getBoolValue( "PrintControls", rOptions.bPrintControl ); + rOptions.bPrintLeftPages = pOpt->IsPrintLeftPages(); + rOptions.bPrintRightPages = pOpt->IsPrintRightPages(); + rOptions.bPrintPageBackground = pOpt->getBoolValue( "PrintPageBackground", rOptions.bPrintPageBackground ); + rOptions.bPrintEmptyPages = !bIsSkipEmptyPages; + // bUpdateFieldsInPrinting <-- not set here // TLPDF: TODO: remove this from SwPrintData?? Get rid of SwPrtOptions?? + rOptions.bPaperFromSetup = pOpt->getBoolValue( "PrintPaperFromSetup", rOptions.bPaperFromSetup ); + rOptions.bPrintReverse = pOpt->getBoolValue( "PrintReversed", rOptions.bPrintReverse ); + rOptions.bPrintProspect = pOpt->getBoolValue( "PrintProspect", rOptions.bPrintProspect ); + rOptions.bPrintProspectRTL = pOpt->getIntValue( "PrintProspectRTL", rOptions.bPrintProspectRTL ) ? true : false; + // bPrintSingleJobs <-- not set here // TLPDF: TODO: remove this from SwPrintData?? Get rid of SwPrtOptions?? + // bModified <-- not set here // TLPDF: TODO: remove this from SwPrintData?? Get rid of SwPrtOptions?? + rOptions.bPrintBlackFont = pOpt->getBoolValue( "PrintBlackFonts", rOptions.bPrintBlackFont ); + rOptions.bPrintHiddenText = pOpt->getBoolValue( "PrintHiddenText", rOptions.bPrintHiddenText ); + rOptions.bPrintTextPlaceholder = pOpt->getBoolValue( "PrintTextPlaceholder", rOptions.bPrintTextPlaceholder ); + rOptions.nPrintPostIts = static_cast< sal_Int16 >(pOpt->getIntValue( "PrintAnnotationMode", rOptions.nPrintPostIts )); + + //! needs to be set after MakeOptions since the assignment operation in that + //! function will destroy the pointers + rOptions.SetPrintUIOptions( pOpt ); + rOptions.SetRenderData( pData ); + + // rOptions.aMulti is not used anymore in the XRenderable API but it is still + // used in ViewShell::PrintPreViewPage. Thus we set it to a dummy value here. + MultiSelection aPages( Range( 1, 1 ) ); +// aPages.SetTotalRange( Range( 0, RANGE_MAX ) ); +// aPages.Select( aRange ); + rOptions.aMulti = aPages; + + //! Note: Since for PDF export of (multi-)selection a temporary + //! document is created that contains only the selects parts, + //! and thus that document is to printed in whole the, + //! rOptions.bPrintSelection parameter will be false. + if (bIsPDFExport) + rOptions.bPrintSelection = FALSE; +} + + /*****************************************************************************/ SwPrintUIOptions::SwPrintUIOptions( BOOL bWeb ) : @@ -1012,63 +1096,6 @@ SwDoc * ViewShell::FillPrtDoc( SwDoc *pPrtDoc, const SfxPrinter* pPrt) } -sal_Bool ViewShell::PrintOrPDFExportMM( - vcl::OldStylePrintAdaptor &/*rAdaptor*/, - const uno::Sequence< beans::PropertyValue > &/*rOptions*/, /* TLPDF: this or the above ? */ - const SwPrtOptions &/*rPrintData*/, /* TLPDF can't we make use of just SwPrintData only as it is the case in PrintProspect??? */ - bool /*bIsPDFExport*/ ) -{ - return false; - // to be removed (not needed) -#ifdef TL_NOT_NOW /* TLPDF */ - (void) rPrintData; (void) bIsPDFExport; - - uno::Reference< frame::XModel > xModel( GetDoc()->GetDocShell()->GetModel() ); - uno::Reference< view::XRenderable > xTextDoc( xModel, uno::UNO_QUERY ); - if (!xModel.is() || xTextDoc.is()) - return sal_False; - - bool bRes = sal_True; - try - { - // print the whole document and not just a selection - uno::Any aSelection; - aSelection <<= xModel; - - const sal_Int32 nPages = xTextDoc->getRendererCount( aSelection, rOptions ); - for (sal_Int32 i = 0; i < nPages; ++i) - { - uno::Sequence< beans::PropertyValue > aRenderProps( xTextDoc->getRenderer( i, aSelection, rOptions ) ); - if (i == 0 || i == nPages - 1) - { - rtl::OUString aName( rtl::OUString::createFromAscii( i == 0 ? "IsFirstPage" : "IsLastPage" ) ); - const sal_Int32 nProps = aRenderProps.getLength(); - aRenderProps.realloc( nProps + 1 ); - aRenderProps[ nProps ].Name = aName; - aRenderProps[ nProps ].Value <<= sal_True; - } - - rAdaptor.StartPage(); - xTextDoc->render( i, aSelection, aRenderProps ); - rAdaptor.EndPage(); - } - } - catch (uno::Exception &r) - { - (void) r; - bRes = sal_False; - } - - if (bRes) - { - const boost::shared_ptr< vcl::PrinterController > pPrtController( &rAdaptor ); - Printer::PrintJob( pPrtController, JobSetup() ); - } - return bRes; -#endif // TL_NOT_NOW /* TLPDF */ -} - - sal_Bool ViewShell::PrintOrPDFExport( OutputDevice *pOutDev, const SwPrtOptions &rPrintData, @@ -1169,6 +1196,7 @@ sal_Bool ViewShell::PrintOrPDFExport( } DBG_ASSERT( pStPage, "failed to get start page" ); +#ifdef TL_NOT_NOW // TLPDF: applying view options and formatting the dcoument should now only be done in getRendererCount! // benoetigte Seiten fuers Drucken formatieren pShell->CalcPagesForPrint( (USHORT)nPage, 0 /*TLPDF*/, 0 /*TLPDFpStr*/, 0, 0 /* TLPDF, there is no progressbar right now nMergeAct, nMergeCnt */ ); @@ -1182,6 +1210,7 @@ sal_Bool ViewShell::PrintOrPDFExport( if ( !bIsPDFExport && rPrintData.bUpdateFieldsInPrinting ) pShell->UpdateFlds(TRUE); // <-- +#endif // TL_NOT_NOW // TLPDF ViewShell *pViewSh2 = nPage == 0 ? /* post-it page? */ rPrintData.GetRenderData().m_pPostItShell : pShell; diff --git a/sw/source/ui/inc/view.hxx b/sw/source/ui/inc/view.hxx index 92788e714c4f..d122df20c408 100644 --- a/sw/source/ui/inc/view.hxx +++ b/sw/source/ui/inc/view.hxx @@ -630,10 +630,6 @@ public: //apply Accessiblity options void ApplyAccessiblityOptions(SvtAccessibilityOptions& rAccessibilityOptions); - // get print options (SwPrtOptions) - static void MakeOptions( PrintDialog* pDlg, SwPrtOptions& rOpts, - BOOL* pPrtProspect, BOOL* pPrtProspect_RTL, BOOL bWeb, SfxPrinter* pPrt, SwPrintData* pData ); - SwView(SfxViewFrame* pFrame, SfxViewShell*); ~SwView(); diff --git a/sw/source/ui/uiview/pview.cxx b/sw/source/ui/uiview/pview.cxx index 1dc6c393dfcf..81958e19be19 100644 --- a/sw/source/ui/uiview/pview.cxx +++ b/sw/source/ui/uiview/pview.cxx @@ -1779,7 +1779,7 @@ void SwPagePreView::Init(const SwViewOption * pPrefs) // OD 09.01.2003 #i6467# - adjust view shell option to the same as for print SwPrtOptions aPrintOptions( GetViewFrame()->GetObjectShell()->GetTitle(0) ); - SwView::MakeOptions( 0, aPrintOptions, 0, 0, false, 0, 0 ); + aPrintOptions.MakeOptions( 0, 0, 0, false, 0, 0 ); GetViewShell()->AdjustOptionsForPagePreview( aPrintOptions ); IDocumentSettingAccess* pIDSA = pESh->getIDocumentSettingAccess(); diff --git a/sw/source/ui/uiview/view.cxx b/sw/source/ui/uiview/view.cxx index 642c34352a0e..1dedc5c67487 100644 --- a/sw/source/ui/uiview/view.cxx +++ b/sw/source/ui/uiview/view.cxx @@ -1958,8 +1958,40 @@ void SwView::NotifyDBChanged() Beschreibung: Drucken --------------------------------------------------------------------*/ -void SwView::MakeOptions( PrintDialog* pDlg, SwPrtOptions& rOpts, - BOOL* pPrtProspect, BOOL* pPrtProspect_RTL, BOOL bWeb, SfxPrinter* pPrt, SwPrintData* pData ) +/* -----------------------------28.10.02 13:25-------------------------------- + + ---------------------------------------------------------------------------*/ +SfxObjectShellRef & SwView::GetTmpSelectionDoc() +{ + return GetViewImpl()->GetTmpSelectionDoc(); +} +/* -----------------------------31.10.02 13:25-------------------------------- + + ---------------------------------------------------------------------------*/ +SfxObjectShellRef & SwView::GetOrCreateTmpSelectionDoc() +{ + SfxObjectShellRef &rxTmpDoc = GetViewImpl()->GetTmpSelectionDoc(); + if (!rxTmpDoc.Is()) + { + SwXTextView *pImpl = GetViewImpl()->GetUNOObject_Impl(); + rxTmpDoc = pImpl->BuildTmpSelectionDoc( + GetViewImpl()->GetEmbeddedObjRef() ); + } + return rxTmpDoc; +} +/* -----------------3/31/2003 12:39PM---------------- + + --------------------------------------------------*/ +void SwView::AddTransferable(SwTransferable& rTransferable) +{ + GetViewImpl()->AddTransferable(rTransferable); +} + +/* --------------------------------------------------*/ + +void SwPrtOptions::MakeOptions( PrintDialog* pDlg, + BOOL* pPrtProspect, BOOL* pPrtProspect_RTL, BOOL bWeb, + SfxPrinter* pPrt, SwPrintData* pData ) { SwAddPrinterItem* pAddPrinterAttr; if( pPrt && SFX_ITEM_SET == pPrt->GetOptions().GetItemState( @@ -1971,65 +2003,37 @@ void SwView::MakeOptions( PrintDialog* pDlg, SwPrtOptions& rOpts, { pData = SW_MOD()->GetPrtOptions(bWeb); } - rOpts = *pData; + *this = *pData; if( pPrtProspect ) *pPrtProspect = pData->bPrintProspect; if( pPrtProspect_RTL ) *pPrtProspect_RTL = pData->bPrintProspectRTL; - rOpts.aMulti.SetTotalRange( Range( 0, RANGE_MAX ) ); - rOpts.aMulti.SelectAll( FALSE ); - rOpts.nCopyCount = 1; - rOpts.bCollate = FALSE; - rOpts.bPrintSelection = FALSE; - rOpts.bJobStartet = FALSE; + aMulti.SetTotalRange( Range( 0, RANGE_MAX ) ); + aMulti.SelectAll( FALSE ); + nCopyCount = 1; + bCollate = FALSE; + bPrintSelection = FALSE; + bJobStartet = FALSE; if ( pDlg ) { - rOpts.nCopyCount = pDlg->GetCopyCount(); - rOpts.bCollate = pDlg->IsCollateChecked(); + nCopyCount = pDlg->GetCopyCount(); + bCollate = pDlg->IsCollateChecked(); if ( pDlg->GetCheckedRange() == PRINTDIALOG_SELECTION ) { - rOpts.aMulti.SelectAll(); - rOpts.bPrintSelection = TRUE; + aMulti.SelectAll(); + bPrintSelection = TRUE; } else if ( PRINTDIALOG_ALL == pDlg->GetCheckedRange() ) - rOpts.aMulti.SelectAll(); + aMulti.SelectAll(); else { - rOpts.aMulti = MultiSelection( pDlg->GetRangeText() ); - rOpts.aMulti.SetTotalRange( Range( 0, RANGE_MAX ) ); + aMulti = MultiSelection( pDlg->GetRangeText() ); + aMulti.SetTotalRange( Range( 0, RANGE_MAX ) ); } } else - rOpts.aMulti.SelectAll(); - rOpts.aMulti.Select( 0, FALSE ); + aMulti.SelectAll(); + aMulti.Select( 0, FALSE ); } -/* -----------------------------28.10.02 13:25-------------------------------- - - ---------------------------------------------------------------------------*/ -SfxObjectShellRef & SwView::GetTmpSelectionDoc() -{ - return GetViewImpl()->GetTmpSelectionDoc(); -} -/* -----------------------------31.10.02 13:25-------------------------------- - - ---------------------------------------------------------------------------*/ -SfxObjectShellRef & SwView::GetOrCreateTmpSelectionDoc() -{ - SfxObjectShellRef &rxTmpDoc = GetViewImpl()->GetTmpSelectionDoc(); - if (!rxTmpDoc.Is()) - { - SwXTextView *pImpl = GetViewImpl()->GetUNOObject_Impl(); - rxTmpDoc = pImpl->BuildTmpSelectionDoc( - GetViewImpl()->GetEmbeddedObjRef() ); - } - return rxTmpDoc; -} -/* -----------------3/31/2003 12:39PM---------------- - - --------------------------------------------------*/ -void SwView::AddTransferable(SwTransferable& rTransferable) -{ - GetViewImpl()->AddTransferable(rTransferable); -} diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index eafa1127afe5..82411d62bdb5 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -2452,100 +2452,6 @@ Any SAL_CALL SwXTextDocument::getPropertyDefault( const OUString& rPropertyName } return aAny; } -/*-- 06.01.2004 15:08:34--------------------------------------------------- - The class SwViewOptionAdjust_Impl is used to adjust the SwViewOption of - the current ViewShell so that fields are not printed as commands and - hidden text and hidden characters are always invisible. - After printing the view options are restored - -----------------------------------------------------------------------*/ -class SwViewOptionAdjust_Impl -{ - bool m_bSwitchOff_IsFldName; - bool m_bSwitchOff_PlaceHolderView; - bool m_bSwitchOff_HiddenChar; - bool m_bSwitchOff_HiddenParagraphs; - bool m_bSwitchOff_IsShowHiddenField; - - SwViewOption* m_pViewOption; - SwWrtShell& m_rShell; -public: - SwViewOptionAdjust_Impl(SwWrtShell& rSh); - ~SwViewOptionAdjust_Impl(); -}; -/*-- 06.01.2004 15:08:34--------------------------------------------------- - - -----------------------------------------------------------------------*/ -SwViewOptionAdjust_Impl::SwViewOptionAdjust_Impl(SwWrtShell& rSh) : - m_pViewOption(0), - m_rShell(rSh) -{ - const SwViewOption* pCurrentViewOptions = m_rShell.GetViewOptions(); - m_bSwitchOff_IsFldName = pCurrentViewOptions->IsFldName() && m_rShell.IsAnyFieldInDoc(); - bool bApplyViewOptions = m_bSwitchOff_IsFldName; - //switch off painting of placeholder fields - m_bSwitchOff_PlaceHolderView = pCurrentViewOptions->IsShowPlaceHolderFields(); - //switch off display of hidden characters if on and hidden characters are in use - m_bSwitchOff_HiddenChar = pCurrentViewOptions->IsShowHiddenChar() && m_rShell.GetDoc()->ContainsHiddenChars(); - //switch off display of hidden paragraphs if on and hidden paragraphs are in use - m_bSwitchOff_HiddenParagraphs = pCurrentViewOptions->IsShowHiddenPara(); - if(m_bSwitchOff_HiddenParagraphs) - { - const SwFieldType* pFldType = m_rShell.GetDoc()->GetSysFldType(RES_HIDDENPARAFLD); - if(!pFldType || !pFldType->GetDepends()) - m_bSwitchOff_HiddenParagraphs = false; - } - m_bSwitchOff_IsShowHiddenField = pCurrentViewOptions->IsShowHiddenField(); - if(m_bSwitchOff_IsShowHiddenField) - { - const SwFieldType* pFldType = m_rShell.GetDoc()->GetSysFldType(RES_HIDDENTXTFLD); - if( !pFldType || !pFldType->GetDepends()) - m_bSwitchOff_IsShowHiddenField = false; - } - - bApplyViewOptions |= m_bSwitchOff_PlaceHolderView; - bApplyViewOptions |= m_bSwitchOff_HiddenChar; - bApplyViewOptions |= m_bSwitchOff_HiddenParagraphs; - bApplyViewOptions |= m_bSwitchOff_IsShowHiddenField; - if(bApplyViewOptions) - { - m_pViewOption = new SwViewOption(*m_rShell.GetViewOptions()); - if(m_bSwitchOff_IsFldName) - m_pViewOption->SetFldName(FALSE); - if(m_bSwitchOff_PlaceHolderView) - m_pViewOption->SetShowPlaceHolderFields(FALSE); - if(m_bSwitchOff_HiddenChar) - m_pViewOption->SetShowHiddenChar(FALSE); - if(m_bSwitchOff_HiddenParagraphs) - m_pViewOption->SetShowHiddenPara(FALSE); - if(m_bSwitchOff_IsShowHiddenField) - m_pViewOption->SetShowHiddenField(FALSE); - SW_MOD()->ApplyUsrPref(*m_pViewOption, &m_rShell.GetView(), VIEWOPT_DEST_VIEW_ONLY ); - } -} -/*-- 06.01.2004 15:08:34--------------------------------------------------- - - -----------------------------------------------------------------------*/ -SwViewOptionAdjust_Impl::~SwViewOptionAdjust_Impl() -{ - if(m_pViewOption) - { - if(m_bSwitchOff_IsFldName) - m_pViewOption->SetFldName(TRUE); - if(m_bSwitchOff_PlaceHolderView) - m_pViewOption->SetShowPlaceHolderFields(TRUE); - if(m_bSwitchOff_HiddenChar) - m_pViewOption->SetShowHiddenChar(TRUE); - if(m_bSwitchOff_HiddenParagraphs) - m_pViewOption->SetShowHiddenPara(TRUE); - if(m_bSwitchOff_IsShowHiddenField) - m_pViewOption->SetShowHiddenField(TRUE); - SW_MOD()->ApplyUsrPref(*m_pViewOption, &m_rShell.GetView(), VIEWOPT_DEST_VIEW_ONLY ); - delete m_pViewOption; - } -} -/* -----------------------------23.08.02 16:00-------------------------------- - - ---------------------------------------------------------------------------*/ static OutputDevice * lcl_GetOutputDevice( const SwPrintUIOptions &rPrintUIOptions ) { @@ -2564,6 +2470,26 @@ static OutputDevice * lcl_GetOutputDevice( const SwPrintUIOptions &rPrintUIOptio } +SfxViewShell * SwXTextDocument::GetRenderView( const SwPrintUIOptions &rOpt, bool bIsPDFExport ) +{ + // get view shell to use + SfxViewShell *pView = 0; + if (bIsPDFExport) + pView = GuessViewShell(); + else + { + uno::Any aTmp( rOpt.getValue( C2U( "View" ) )); + uno::Reference< frame::XController > xController; + if (aTmp >>= xController) + { + DBG_ASSERT( xController.is(), "controller is empty!" ); + pView = GuessViewShell( xController ); + } + } + return pView; +} + + /* * GetRenderDoc: * returns the document to be rendered, usually this will be the 'regular' @@ -2628,19 +2554,27 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount( if(!IsValid()) throw RuntimeException(); - if( ! m_pRenderData ) + // actually m_pRenderData and m_pPrintUIOptions should have already been + // destroyed in 'render' when IsLastPage was set (or should have been set) + if (m_pRenderData) + delete m_pRenderData, m_pRenderData = 0; + if (m_pPrintUIOptions) + delete m_pPrintUIOptions, m_pPrintUIOptions = 0; + + if (! m_pRenderData) m_pRenderData = new SwRenderData; - if( ! m_pPrintUIOptions ) + if (! m_pPrintUIOptions) { const BOOL bWebDoc = (0 != PTR_CAST(SwWebDocShell, pDocShell)); m_pPrintUIOptions = new SwPrintUIOptions( bWebDoc ); } bool bFormat = m_pPrintUIOptions->processPropertiesAndCheckFormat( rxOptions ); - const bool bIsPDFExport = !m_pPrintUIOptions->hasProperty( "IsPrinter" ); + const bool bIsPDFExport = !m_pPrintUIOptions->hasProperty( "IsPrinter" ); + const bool bIsSkipEmptyPages = !m_pPrintUIOptions->IsPrintEmptyPages( bIsPDFExport ); - SfxViewShell *pView = 0; + SfxViewShell *pView = GetRenderView( *m_pPrintUIOptions, bIsPDFExport ); SwDoc *pDoc = GetRenderDoc( pView, rSelection, bIsPDFExport ); - if (!pDoc) + if (!pDoc || !pView) throw RuntimeException(); SwDocShell *pRenderDocShell = pDoc->GetDocShell(); @@ -2661,7 +2595,15 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount( pWrtShell = pSwView->GetWrtShellPtr(); } - SwViewOptionAdjust_Impl aAdjust(*pWrtShell); + m_pRenderData->SetSwPrtOptions( new SwPrtOptions( C2U( bIsPDFExport ? "PDF export" : "Printing" ) ) ); + m_pRenderData->MakeSwPrtOptions( m_pRenderData->GetSwPrtOptionsRef(), pRenderDocShell, + m_pPrintUIOptions, m_pRenderData, bIsSkipEmptyPages, bIsPDFExport ); + + //SwViewOptionAdjust_Impl aAdjust(*pWrtShell); + const TypeId aSwViewTypeId = TYPE(SwView); + if (pView->IsA(aSwViewTypeId)) + m_pRenderData->ViewOptionAdjustStart( *((SwView*)pView)->GetWrtShellPtr() ); + if( bFormat ) { // since printing now also use the API for PDF export this option @@ -2671,7 +2613,12 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount( // --> FME 2005-05-23 #122919# Force field update before PDF export: pWrtShell->ViewShell::UpdateFlds(TRUE); // <-- + + // there is some redundancy between those two fucntion calls, but right now + // there is no time to sort this out. + //TODO: check what exatly needs to be done and make just one function for that pWrtShell->CalcLayout(); + pWrtShell->CalcPagesForPrint( pDoc->GetPageCount() ); pWrtShell->SetPDFExportOption( sal_False ); } @@ -2725,8 +2672,10 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SwXTextDocument::getRenderer( if(!IsValid()) throw RuntimeException(); - if( ! m_pRenderData ) - m_pRenderData = new SwRenderData; + DBG_ASSERT( m_pRenderData, "data should have been created already in getRendererCount..." ); + DBG_ASSERT( m_pPrintUIOptions, "data should have been created already in getRendererCount..." ); +// if( ! m_pRenderData ) +// m_pRenderData = new SwRenderData; if( ! m_pPrintUIOptions ) { const BOOL bWebDoc = (0 != PTR_CAST(SwWebDocShell, pDocShell)); @@ -2735,9 +2684,9 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SwXTextDocument::getRenderer( m_pPrintUIOptions->processProperties( rxOptions ); const bool bIsPDFExport = !m_pPrintUIOptions->hasProperty( "IsPrinter" ); - SfxViewShell *pView = 0; + SfxViewShell *pView = GetRenderView( *m_pPrintUIOptions, bIsPDFExport ); SwDoc *pDoc = GetRenderDoc( pView, rSelection, bIsPDFExport ); - if (!pDoc) + if (!pDoc || !pView) throw RuntimeException(); // due to #110067# (document page count changes sometimes during @@ -2805,9 +2754,6 @@ SfxViewShell * SwXTextDocument::GuessViewShell( dynamic_cast< SfxViewShell * >(pSwPagePreView); } -/* -----------------------------23.08.02 16:00-------------------------------- - - ---------------------------------------------------------------------------*/ void SAL_CALL SwXTextDocument::render( sal_Int32 nRenderer, @@ -2819,6 +2765,8 @@ void SAL_CALL SwXTextDocument::render( if(!IsValid()) throw RuntimeException(); + DBG_ASSERT( m_pRenderData, "data should have been created already in getRendererCount..." ); + DBG_ASSERT( m_pPrintUIOptions, "data should have been created already in getRendererCount..." ); if (!m_pRenderData) m_pRenderData = new SwRenderData; if (!m_pPrintUIOptions) @@ -2830,21 +2778,7 @@ void SAL_CALL SwXTextDocument::render( const bool bPrintProspect = m_pPrintUIOptions->getBoolValue( "PrintProspect", false ); const bool bIsPDFExport = !m_pPrintUIOptions->hasProperty( "IsPrinter" ); - // get view shell to use - SfxViewShell *pView = 0; - if (bIsPDFExport) - pView = GuessViewShell(); - else - { - uno::Any aTmp( m_pPrintUIOptions->getValue( C2U( "View" ) )); - uno::Reference< frame::XController > xController; - if (aTmp >>= xController) - { - DBG_ASSERT( xController.is(), "controller is empty!" ); - pView = GuessViewShell( xController ); - } - } - + SfxViewShell *pView = GetRenderView( *m_pPrintUIOptions, bIsPDFExport ); SwDoc *pDoc = GetRenderDoc( pView, rSelection, bIsPDFExport ); if (!pDoc || !pView) @@ -2873,63 +2807,18 @@ void SAL_CALL SwXTextDocument::render( } // get output device to use - OutputDevice* pOut = lcl_GetOutputDevice( *m_pPrintUIOptions ); + OutputDevice * pOut = lcl_GetOutputDevice( *m_pPrintUIOptions ); - if(pVwSh && pOut) + if(pVwSh && pOut && m_pRenderData->HasSwPrtOptions()) { - // TLPDF2DO: clean-up, need to check if only one of aOptions and m_pPrintUIOptions should be used - SwPrtOptions aOptions( C2U( bIsPDFExport ? "PDF export" : "Printing" ) ); - - // get default print options - const TypeId aSwWebDocShellTypeId = TYPE(SwWebDocShell); - BOOL bWeb = pDocShell->IsA( aSwWebDocShellTypeId ); - SwView::MakeOptions( NULL, aOptions, NULL, NULL, bWeb, NULL, NULL ); - - // get print options to use from provided properties const rtl::OUString aPageRange = m_pPrintUIOptions->getStringValue( "PageRange", OUString() ); const bool bFirstPage = m_pPrintUIOptions->getBoolValue( "IsFirstPage", sal_False ); const bool bLastPage = m_pPrintUIOptions->getBoolValue( "IsLastPage", sal_False ); bool bIsSkipEmptyPages = !m_pPrintUIOptions->IsPrintEmptyPages( bIsPDFExport ); - aOptions.bPrintGraphic = m_pPrintUIOptions->IsPrintGraphics(); - aOptions.bPrintTable = m_pPrintUIOptions->IsPrintTables(); - aOptions.bPrintDraw = m_pPrintUIOptions->IsPrintDrawings(); - aOptions.bPrintControl = m_pPrintUIOptions->getBoolValue( "PrintControls", aOptions.bPrintControl ); - aOptions.bPrintLeftPages = m_pPrintUIOptions->IsPrintLeftPages(); - aOptions.bPrintRightPages = m_pPrintUIOptions->IsPrintRightPages(); - aOptions.bPrintPageBackground = m_pPrintUIOptions->getBoolValue( "PrintPageBackground", aOptions.bPrintPageBackground ); - aOptions.bPrintEmptyPages = !bIsSkipEmptyPages; - // bUpdateFieldsInPrinting <-- not set here // TLPDF: TODO: remove this from SwPrintData?? Get rid of SwPrtOptions?? - aOptions.bPaperFromSetup = m_pPrintUIOptions->getBoolValue( "PrintPaperFromSetup", aOptions.bPaperFromSetup ); - aOptions.bPrintReverse = m_pPrintUIOptions->getBoolValue( "PrintReversed", aOptions.bPrintReverse ); - aOptions.bPrintProspect = m_pPrintUIOptions->getBoolValue( "PrintProspect", aOptions.bPrintProspect ); - aOptions.bPrintProspectRTL = m_pPrintUIOptions->getIntValue( "PrintProspectRTL", aOptions.bPrintProspectRTL ) ? true : false; - // bPrintSingleJobs <-- not set here // TLPDF: TODO: remove this from SwPrintData?? Get rid of SwPrtOptions?? - // bModified <-- not set here // TLPDF: TODO: remove this from SwPrintData?? Get rid of SwPrtOptions?? - aOptions.bPrintBlackFont = m_pPrintUIOptions->getBoolValue( "PrintBlackFonts", aOptions.bPrintBlackFont ); - aOptions.bPrintHiddenText = m_pPrintUIOptions->getBoolValue( "PrintHiddenText", aOptions.bPrintHiddenText ); - aOptions.bPrintTextPlaceholder = m_pPrintUIOptions->getBoolValue( "PrintTextPlaceholder", aOptions.bPrintTextPlaceholder ); - aOptions.nPrintPostIts = static_cast< sal_Int16 >(m_pPrintUIOptions->getIntValue( "PrintAnnotationMode", aOptions.nPrintPostIts )); - - //! needs to be set after MakeOptions since the assignment operation in that - //! function will destroy the pointers - aOptions.SetPrintUIOptions( m_pPrintUIOptions ); - aOptions.SetRenderData( m_pRenderData ); - - Range aRange( nRenderer+1, nRenderer+1 ); - MultiSelection aPages( aRange ); - aPages.SetTotalRange( Range( 0, RANGE_MAX ) ); - aPages.Select( aRange ); - aOptions.aMulti = aPages; - - //! Note: Since for PDF export of (multi-)selection a temporary - //! document is created that contains only the selects parts, - //! and thus that document is to printed in whole the, - //! aOptions.bPrintSelection parameter will be false. - if (bIsPDFExport) - aOptions.bPrintSelection = FALSE; - - SwViewOptionAdjust_Impl* pViewOptionAdjust = pView->IsA(aSwViewTypeId) ? - new SwViewOptionAdjust_Impl(*((SwView*)pView)->GetWrtShellPtr()) : 0; + + DBG_ASSERT(( pView->IsA(aSwViewTypeId) && m_pRenderData->IsViewOptionAdjust()) + || (!pView->IsA(aSwViewTypeId) && !m_pRenderData->IsViewOptionAdjust()), + "SwView / SwViewOptionAdjust_Impl availability mismatch" ); // since printing now also use the API for PDF export this option // should be set for printing as well ... @@ -2945,17 +2834,17 @@ void SAL_CALL SwXTextDocument::render( ((SwView*)pView)->GetWrtShellPtr() : 0; - if (bIsPDFExport && bFirstPage && pWrtShell) /*TLPDF*/ + if (bIsPDFExport && bFirstPage && pWrtShell) { SwEnhancedPDFExportHelper aHelper( *pWrtShell, *pOut, aPageRange, bIsSkipEmptyPages, sal_False ); } // <-- - // TLPDF OutputDevice *pOldDev = pVwSh->GetOut(); // TLPDF + const SwPrtOptions &rSwPrtOptions = *m_pRenderData->GetSwPrtOptions(); if (bPrintProspect) - pVwSh->PrintProspect( pOut, aOptions, nRenderer ); + pVwSh->PrintProspect( pOut, rSwPrtOptions, nRenderer ); else // normal printing and PDF export - pVwSh->PrintOrPDFExport( pOut, aOptions, nRenderer, bIsPDFExport ); + pVwSh->PrintOrPDFExport( pOut, rSwPrtOptions, nRenderer, bIsPDFExport ); // --> FME 2004-10-08 #i35176# // @@ -2963,7 +2852,7 @@ void SAL_CALL SwXTextDocument::render( // from the EditEngine. The links are generated during the painting // process, but the destinations are still missing. // - if (bIsPDFExport && bLastPage && pWrtShell) /*TLPDF*/ + if (bIsPDFExport && bLastPage && pWrtShell) { SwEnhancedPDFExportHelper aHelper( *pWrtShell, *pOut, aPageRange, bIsSkipEmptyPages, sal_True ); } @@ -2971,12 +2860,15 @@ void SAL_CALL SwXTextDocument::render( pVwSh->SetPDFExportOption( sal_False ); - // #i96167# haggai: delete pViewOptionsAdjust here because it makes use - // of the shell, which might get destroyed in lcl_DisposeView! - delete pViewOptionAdjust; - + // last page to be rendered? (not necessarily the last page of the document) + // -> do clean-up of data if (bLastPage) { + // #i96167# haggai: delete pViewOptionsAdjust here because it makes use + // of the shell, which might get destroyed in lcl_DisposeView! + if (m_pRenderData && m_pRenderData->IsViewOptionAdjust()) + m_pRenderData->ViewOptionAdjustStop(); + if (m_pRenderData && m_pRenderData->HasPostItData()) m_pRenderData->DeletePostItData(); if (m_pHiddenViewFrame) @@ -2985,8 +2877,6 @@ void SAL_CALL SwXTextDocument::render( m_pHiddenViewFrame = 0; } - aOptions.SetRenderData( NULL ); - aOptions.SetPrintUIOptions( NULL ); delete m_pRenderData; m_pRenderData = NULL; delete m_pPrintUIOptions; m_pPrintUIOptions = NULL; } @@ -3948,3 +3838,78 @@ void SwXDocumentPropertyHelper::onChange() if(m_pDoc) m_pDoc->SetModified(); } + + +/*****************************************************************************/ + +SwViewOptionAdjust_Impl::SwViewOptionAdjust_Impl(SwWrtShell& rSh) : + m_pViewOption(0), + m_rShell(rSh) +{ + const SwViewOption* pCurrentViewOptions = m_rShell.GetViewOptions(); + m_bSwitchOff_IsFldName = pCurrentViewOptions->IsFldName() && m_rShell.IsAnyFieldInDoc(); + bool bApplyViewOptions = m_bSwitchOff_IsFldName; + //switch off painting of placeholder fields + m_bSwitchOff_PlaceHolderView = pCurrentViewOptions->IsShowPlaceHolderFields(); + //switch off display of hidden characters if on and hidden characters are in use + m_bSwitchOff_HiddenChar = pCurrentViewOptions->IsShowHiddenChar() && m_rShell.GetDoc()->ContainsHiddenChars(); + //switch off display of hidden paragraphs if on and hidden paragraphs are in use + m_bSwitchOff_HiddenParagraphs = pCurrentViewOptions->IsShowHiddenPara(); + if(m_bSwitchOff_HiddenParagraphs) + { + const SwFieldType* pFldType = m_rShell.GetDoc()->GetSysFldType(RES_HIDDENPARAFLD); + if(!pFldType || !pFldType->GetDepends()) + m_bSwitchOff_HiddenParagraphs = false; + } + m_bSwitchOff_IsShowHiddenField = pCurrentViewOptions->IsShowHiddenField(); + if(m_bSwitchOff_IsShowHiddenField) + { + const SwFieldType* pFldType = m_rShell.GetDoc()->GetSysFldType(RES_HIDDENTXTFLD); + if( !pFldType || !pFldType->GetDepends()) + m_bSwitchOff_IsShowHiddenField = false; + } + + bApplyViewOptions |= m_bSwitchOff_PlaceHolderView; + bApplyViewOptions |= m_bSwitchOff_HiddenChar; + bApplyViewOptions |= m_bSwitchOff_HiddenParagraphs; + bApplyViewOptions |= m_bSwitchOff_IsShowHiddenField; + if(bApplyViewOptions) + { + m_pViewOption = new SwViewOption(*m_rShell.GetViewOptions()); + if(m_bSwitchOff_IsFldName) + m_pViewOption->SetFldName(FALSE); + if(m_bSwitchOff_PlaceHolderView) + m_pViewOption->SetShowPlaceHolderFields(FALSE); + if(m_bSwitchOff_HiddenChar) + m_pViewOption->SetShowHiddenChar(FALSE); + if(m_bSwitchOff_HiddenParagraphs) + m_pViewOption->SetShowHiddenPara(FALSE); + if(m_bSwitchOff_IsShowHiddenField) + m_pViewOption->SetShowHiddenField(FALSE); + SW_MOD()->ApplyUsrPref(*m_pViewOption, &m_rShell.GetView(), VIEWOPT_DEST_VIEW_ONLY ); + } +} + + +SwViewOptionAdjust_Impl::~SwViewOptionAdjust_Impl() +{ + if(m_pViewOption) + { + if(m_bSwitchOff_IsFldName) + m_pViewOption->SetFldName(TRUE); + if(m_bSwitchOff_PlaceHolderView) + m_pViewOption->SetShowPlaceHolderFields(TRUE); + if(m_bSwitchOff_HiddenChar) + m_pViewOption->SetShowHiddenChar(TRUE); + if(m_bSwitchOff_HiddenParagraphs) + m_pViewOption->SetShowHiddenPara(TRUE); + if(m_bSwitchOff_IsShowHiddenField) + m_pViewOption->SetShowHiddenField(TRUE); + SW_MOD()->ApplyUsrPref(*m_pViewOption, &m_rShell.GetView(), VIEWOPT_DEST_VIEW_ONLY ); + delete m_pViewOption; + } +} + +/*****************************************************************************/ + + -- cgit From b4c51335262a4f3ad88d15d3b13d5442e90b142b Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Tue, 1 Sep 2009 15:41:59 +0000 Subject: #i101242# applying view options and formatting doc now only done in getRendererCount --- sw/source/core/doc/doc.cxx | 55 +----------------------------------------- sw/source/core/view/vprint.cxx | 29 ---------------------- sw/source/ui/dbui/dbmgr.cxx | 6 ++--- 3 files changed, 4 insertions(+), 86 deletions(-) (limited to 'sw') diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index daefe8fef56f..2c125bcb98e4 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -1149,8 +1149,6 @@ void SwDoc::CalculatePagesForPrinting( // (PDF export UI does not allow for selecting left or right pages only) bool bPrintLeftPages = bIsPDFExport ? true : rOptions.IsPrintLeftPages(); bool bPrintRightPages = bIsPDFExport ? true : rOptions.IsPrintRightPages(); - // TLPDF, TODO: remove bPrintReverse, should be handled by PLs framework now -//TLPDF bool bPrintReverse = rOptions.getBoolValue( C2U( "PrintReverseOrder" ), false ); bool bPrintEmptyPages = rOptions.IsPrintEmptyPages( bIsPDFExport ); Range aPages( 1, nDocPageCount ); @@ -1211,17 +1209,7 @@ void SwDoc::CalculatePagesForPrinting( aMulti = aTmpMulti; // Ende des HACKs -#ifdef TL_NOT_NOW /*TLPDF*/ - if (bPrintReverse) - { - const SwFrm *pTmp = pStPage; - pStPage = (SwPageFrm*)pEndPage; - pEndPage = pTmp; - nPageNo = nLastPageNo; - } - else -#endif // TL_NOT_NOW /*TLPDF*/ - nPageNo = nFirstPageNo; + nPageNo = nFirstPageNo; std::set< sal_Int32 > &rValidPages = rData.GetValidPagesSet(); std::map< sal_Int32, const SwPageFrm * > &rValidStartFrms = rData.GetValidStartFrames(); @@ -1248,13 +1236,6 @@ void SwDoc::CalculatePagesForPrinting( { pStPage = 0; } -#ifdef TL_NOT_NOW /*TLPDF*/ - else if ( bPrintReverse ) - { - --nPageNo; - pStPage = (SwPageFrm*)pStPage->GetPrev(); - } -#endif // TL_NOT_NOW /*TLPDF*/ else { ++nPageNo; pStPage = (SwPageFrm*)pStPage->GetNext(); @@ -1565,40 +1546,6 @@ void SwDoc::CalculatePagePairsForProspectPrinting( // with back and front) while( aVec.size() & 3 ) aVec.push_back( 0 ); - -#ifdef TL_NOT_NOW /*TLPDF*/ - if ( bPrintReverse && 4 < aVec.size() ) - { - // das Array umsortieren - // Array: 1 2 3 4 5 6 7 8 - // soll: 3 4 1 2 7 8 5 6 - // Algorhitmus: - // vordere Haelfte: Austausch von 2 Pointer von Vorne vor die Haelfte - // hintere Haelfte: Austausch von 2 Pointer von der Haelfte nach hinten - - USHORT nHalf = aVec.size() / 2; - USHORT nSwapCount = nHalf / 4; - - const SwPageFrm ** ppArrStt = &aVec[ 0 ]; - const SwPageFrm ** ppArrHalf = &aVec[ nHalf ]; - - for ( int k = 0; k < 2; ++k ) - { - for ( USHORT n = 0; n < nSwapCount; ++n ) - { - const SwPageFrm * pTmp = *ppArrStt; - *ppArrStt++ = *(ppArrHalf-2); - *(ppArrHalf-2) = pTmp; - - pTmp = *ppArrStt; - *ppArrStt++ = *--ppArrHalf; - *ppArrHalf-- = pTmp; - } - ppArrStt = &aVec[ nHalf ]; - ppArrHalf = &aVec[ 0 ] + aVec.size(); - } - } -#endif // TL_NOT_NOW /*TLPDF*/ } // dann sorge mal dafuer, das alle Seiten in der richtigen diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index 3016075d1002..4a6eb22134d3 100644 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -851,36 +851,12 @@ void ViewShell::CalcPagesForPrint( USHORT nMax, SfxProgress* pProgress, const SwFrm *pPage = pLayout->Lower(); SwLayAction aAction( pLayout, Imp() ); -#ifdef TL_NOT_NOW /*TLPDF*/ -//Currently we have no progress bar here. It is handled in the new Print UI now. -//Not year clear: what about Progressbar in MailMerge - if( pProgress ) - { - // HACK, damit die Anzeige sich nicht verschluckt. - const XubString aTmp( SW_RES( STR_STATSTR_FORMAT ) ); - pProgress->SetText( aTmp ); - lcl_SetState( *pProgress, 1, nStatMax, pStr, nMergeAct, nMergeCnt, 0, 1 ); - pProgress->Reschedule(); //Mag der Anwender noch oder hat er genug? - aAction.SetProgress(pProgress); - } -#endif // TL_NOT_NOW /*TLPDF*/ - pLayout->StartAllAction(); for ( USHORT i = 1; pPage && i <= nMax; pPage = pPage->GetNext(), ++i ) { if ( ( bPrtJob && !pPrt->IsJobActive() ) || Imp()->IsStopPrt() ) break; -#ifdef TL_NOT_NOW /*TLPDF*/ - if( pProgress ) - { - //HACK, damit die Anzeige sich nicht verschluckt. - if ( i > nStatMax ) nStatMax = i; - lcl_SetState( *pProgress, i, nStatMax, pStr, nMergeAct, nMergeCnt, 0, i ); - pProgress->Reschedule(); //Mag der Anwender noch oder hat er genug? - } -#endif // TL_NOT_NOW /*TLPDF*/ - if ( ( bPrtJob && !pPrt->IsJobActive() ) || Imp()->IsStopPrt() ) break; @@ -898,11 +874,6 @@ void ViewShell::CalcPagesForPrint( USHORT nMax, SfxProgress* pProgress, aVisArea = aOldVis; //Zuruecksetzen wg. der Paints! Imp()->SetFirstVisPageInvalid(); SwPaintQueue::Repaint(); - -#ifdef TL_NOT_NOW /*TLPDF*/ - if ( pProgress ) - pProgress->Reschedule(); //Mag der Anwender noch oder hat er genug? -#endif // TL_NOT_NOW /*TLPDF*/ } if (pProgress) diff --git a/sw/source/ui/dbui/dbmgr.cxx b/sw/source/ui/dbui/dbmgr.cxx index c1884e7ccbfc..2e2b43339124 100644 --- a/sw/source/ui/dbui/dbmgr.cxx +++ b/sw/source/ui/dbui/dbmgr.cxx @@ -900,10 +900,10 @@ BOOL SwNewDBMgr::MergePrint( SwView& rView, bRet = TRUE; } #endif // TL_NOT_NOW /*TLPDF*/ - pSh->PrintProspectMM( aPrtAdaptor, aViewProperties, rOpt, rOpt.IsPrintProspectRTL() ); // TLPDF +//TLPDFXX pSh->PrintProspectMM( aPrtAdaptor, aViewProperties, rOpt, rOpt.IsPrintProspectRTL() ); // TLPDF bRet = TRUE; // TLPDF } - else if( pSh->PrintOrPDFExportMM( aPrtAdaptor, aViewProperties, rOpt ) /* TLPDF */ ) + else if( 1 /*TLPDFXX pSh->PrintOrPDFExportMM( aPrtAdaptor, aViewProperties, rOpt ) */ ) bRet = TRUE; bMergeLock = FALSE; @@ -3236,4 +3236,4 @@ void SwConnectionDisposedListener_Impl::disposing( const EventObject& rSource ) rDBMgr.aDataSourceParams.DeleteAndDestroy(nPos - 1); } } -} \ No newline at end of file +} -- cgit From 65756e786d115472d3607724456888d325608a95 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Tue, 1 Sep 2009 16:31:53 +0000 Subject: remove warnings --- sw/source/core/view/viewpg.cxx | 4 ++-- sw/source/core/view/vprint.cxx | 2 +- sw/source/ui/dbui/dbmgr.cxx | 2 +- sw/source/ui/dbui/mmoutputpage.cxx | 2 +- sw/source/ui/inc/view.hxx | 3 ++- 5 files changed, 7 insertions(+), 6 deletions(-) (limited to 'sw') diff --git a/sw/source/core/view/viewpg.cxx b/sw/source/core/view/viewpg.cxx index 360593897084..8f33348afc31 100644 --- a/sw/source/core/view/viewpg.cxx +++ b/sw/source/core/view/viewpg.cxx @@ -477,8 +477,8 @@ void ViewShell::PrintProspect( std::pair< sal_Int32, sal_Int32 > rPagesToPrint = rPrintData.GetRenderData().GetPagePairsForProspectPrinting()[ nRenderer ]; - const USHORT nPageMax = static_cast< USHORT >(rPagesToPrint.first > rPagesToPrint.second ? - rPagesToPrint.first : rPagesToPrint.second); +// const USHORT nPageMax = static_cast< USHORT >(rPagesToPrint.first > rPagesToPrint.second ? +// rPagesToPrint.first : rPagesToPrint.second); #if OSL_DEBUG_LEVEL > 1 DBG_ASSERT( rPagesToPrint.first == -1 || rPrintData.GetRenderData().GetValidPagesSet().count( rPagesToPrint.first ) == 1, "first Page not valid" ); DBG_ASSERT( rPagesToPrint.second == -1 || rPrintData.GetRenderData().GetValidPagesSet().count( rPagesToPrint.second ) == 1, "second Page not valid" ); diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index 4a6eb22134d3..ec5a7900fc4e 100644 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -1071,7 +1071,7 @@ sal_Bool ViewShell::PrintOrPDFExport( OutputDevice *pOutDev, const SwPrtOptions &rPrintData, sal_Int32 nRenderer, // the index in the vector of pages to be printed - bool bIsPDFExport ) + bool /* TLPDF bIsPDFExport*/ ) { //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! //Immer die Druckroutinen in viewpg.cxx (PrintPreViewPage und PrintProspect) mitpflegen!! diff --git a/sw/source/ui/dbui/dbmgr.cxx b/sw/source/ui/dbui/dbmgr.cxx index 2e2b43339124..dee7803a9798 100644 --- a/sw/source/ui/dbui/dbmgr.cxx +++ b/sw/source/ui/dbui/dbmgr.cxx @@ -1503,7 +1503,7 @@ BOOL SwNewDBMgr::MergeMailFiles(SwWrtShell* pSourceShell, } } - const SwModuleOptions * pModOpt = SW_MOD()->GetModuleConfig(); +// const SwModuleOptions * pModOpt = SW_MOD()->GetModuleConfig(); // if (pModOpt->IsSinglePrintJob()) // { // } diff --git a/sw/source/ui/dbui/mmoutputpage.cxx b/sw/source/ui/dbui/mmoutputpage.cxx index bcf6b6409744..dd88026ce204 100644 --- a/sw/source/ui/dbui/mmoutputpage.cxx +++ b/sw/source/ui/dbui/mmoutputpage.cxx @@ -1009,7 +1009,7 @@ IMPL_LINK(SwMailMergeOutputPage, PrintHdl_Impl, PushButton*, EMPTYARG) SfxObjectShell* pObjSh = pTargetView->GetViewFrame()->GetObjectShell(); SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_MAIL_MERGE, pObjSh)); rSh.GetNewDBMgr()->SetMergeType( DBMGR_MERGE_DOCUMENTS ); - SfxDispatcher *pDis = pTargetView->GetViewFrame()->GetDispatcher(); + //SfxDispatcher *pDis = pTargetView->GetViewFrame()->GetDispatcher(); SfxBoolItem aMergeSilent(SID_SILENT, sal_False); m_pWizard->enableButtons(WZB_CANCEL, sal_False); diff --git a/sw/source/ui/inc/view.hxx b/sw/source/ui/inc/view.hxx index d122df20c408..b181c85fa5ae 100644 --- a/sw/source/ui/inc/view.hxx +++ b/sw/source/ui/inc/view.hxx @@ -685,4 +685,5 @@ SfxTabPage* CreatePrintOptionsPage( Window *pParent, const SfxItemSet &rOptions, BOOL bPreview); -#endif \ No newline at end of file +#endif + -- cgit From ffdf4f75143bbcc0061cbf8479490d9b6cb7d5f2 Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Tue, 1 Sep 2009 17:48:55 +0000 Subject: #i101242# applying view options and formatting doc now only done in getRendererCount --- sw/source/core/view/viewpg.cxx | 2 +- sw/source/core/view/vprint.cxx | 2 +- sw/source/ui/uno/unotxdoc.cxx | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'sw') diff --git a/sw/source/core/view/viewpg.cxx b/sw/source/core/view/viewpg.cxx index 8f33348afc31..c3da2df6cf37 100644 --- a/sw/source/core/view/viewpg.cxx +++ b/sw/source/core/view/viewpg.cxx @@ -468,7 +468,7 @@ void ViewShell::PrintProspect( DBG_ASSERT( 0 <= nRenderer && nRenderer < nMaxRenderer, "nRenderer out of bounds"); #endif Printer *pPrinter = dynamic_cast< Printer * >(pOutDev); - if (!pPrinter || nMaxRenderer <= 0 || nRenderer < 0 || nRenderer > nMaxRenderer) + if (!pPrinter || nMaxRenderer < 0 || nRenderer < 0 || nRenderer > nMaxRenderer) return; // save settings of OutputDevice (should be done always since the diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index ec5a7900fc4e..081017f1aeb3 100644 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -1081,7 +1081,7 @@ sal_Bool ViewShell::PrintOrPDFExport( #if OSL_DEBUG_LEVEL > 1 DBG_ASSERT( 0 <= nRenderer && nRenderer < nMaxRenderer, "nRenderer out of bounds"); #endif - if (!pOutDev || nMaxRenderer <= 0 || nRenderer < 0 || nRenderer > nMaxRenderer) + if (!pOutDev || nMaxRenderer < 0 || nRenderer < 0 || nRenderer > nMaxRenderer) return sal_False; // save settings of OutputDevice (should be done always since the diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index 82411d62bdb5..fb765915f5b0 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -2556,10 +2556,10 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount( // actually m_pRenderData and m_pPrintUIOptions should have already been // destroyed in 'render' when IsLastPage was set (or should have been set) - if (m_pRenderData) - delete m_pRenderData, m_pRenderData = 0; - if (m_pPrintUIOptions) - delete m_pPrintUIOptions, m_pPrintUIOptions = 0; +// if (m_pRenderData) +// delete m_pRenderData, m_pRenderData = 0; +// if (m_pPrintUIOptions) +// delete m_pPrintUIOptions, m_pPrintUIOptions = 0; if (! m_pRenderData) m_pRenderData = new SwRenderData; -- cgit From 4c0bd776257fb1ad287e34b4e1bcf4bb6cd2f822 Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Thu, 3 Sep 2009 15:12:37 +0000 Subject: #i101242# printing from HTML source view --- sw/inc/dbmgr.hxx | 3 - sw/inc/printdata.hxx | 2 +- sw/inc/unotxdoc.hxx | 4 +- sw/inc/viewsh.hxx | 3 +- sw/source/core/view/viewpg.cxx | 4 +- sw/source/core/view/vprint.cxx | 20 +- sw/source/ui/dbui/dbmgr.cxx | 172 -------------- sw/source/ui/inc/srcview.hxx | 8 +- sw/source/ui/uiview/srcview.cxx | 170 ++++++-------- sw/source/ui/uno/unotxdoc.cxx | 482 ++++++++++++++++++++++++---------------- 10 files changed, 390 insertions(+), 478 deletions(-) (limited to 'sw') diff --git a/sw/inc/dbmgr.hxx b/sw/inc/dbmgr.hxx index 9e13058e90e6..51242f33f224 100644 --- a/sw/inc/dbmgr.hxx +++ b/sw/inc/dbmgr.hxx @@ -252,9 +252,6 @@ public: // Mischen von Datensaetzen in Felder BOOL MergeNew( const SwMergeDescriptor& rMergeDesc ); BOOL Merge(SwWrtShell* pSh); - // Mischen von Datensaetzen in Felder, dann drucken - BOOL MergePrint( SwView& rView, - SwPrtOptions& rOpt, SfxProgress& rProgress, BOOL bIsAPI ); // printing parts of a merge result document BOOL MergePrintDocuments( SwView& rView, SwPrtOptions& rOpt, SfxProgress& rProgress, BOOL bIsAPI ); diff --git a/sw/inc/printdata.hxx b/sw/inc/printdata.hxx index 14303ad40d5d..345546deabec 100644 --- a/sw/inc/printdata.hxx +++ b/sw/inc/printdata.hxx @@ -60,7 +60,7 @@ class SwPrintUIOptions : public vcl::PrinterOptionsHelper OutputDevice* m_pLast; public: - SwPrintUIOptions( BOOL bWeb = FALSE ); + SwPrintUIOptions( bool bWeb, bool bSwSrcView ); ~SwPrintUIOptions(); bool processPropertiesAndCheckFormat( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& i_rNewProp ); diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx index e0fa90de0ac7..8e56039cd53e 100644 --- a/sw/inc/unotxdoc.hxx +++ b/sw/inc/unotxdoc.hxx @@ -234,9 +234,9 @@ class SwXTextDocument : public SwXTextDocumentBaseClass, void GetNumberFormatter(); // used for XRenderable implementation - SfxViewShell * GuessViewShell( const css::uno::Reference< css::frame::XController > xController = css::uno::Reference< css::frame::XController >() ); + SfxViewShell * GuessViewShell( /* out */ bool &rbIsSwSrcView, const css::uno::Reference< css::frame::XController > xController = css::uno::Reference< css::frame::XController >() ); SwDoc * GetRenderDoc( SfxViewShell *&rpView, const css::uno::Any& rSelection, bool bIsPDFExport ); - SfxViewShell * GetRenderView( const SwPrintUIOptions &rOpt, bool bIsPDFExport ); + SfxViewShell * GetRenderView( bool &rbIsSwSrcView, const css::uno::Sequence< css::beans::PropertyValue >& rxOptions, bool bIsPDFExport ); rtl::OUString maBuildId; diff --git a/sw/inc/viewsh.hxx b/sw/inc/viewsh.hxx index 636608279dbb..36da231f1832 100644 --- a/sw/inc/viewsh.hxx +++ b/sw/inc/viewsh.hxx @@ -388,8 +388,7 @@ public: SwDoc * FillPrtDoc( SwDoc* pPrtDoc, const SfxPrinter* pPrt ); //Wird intern fuer die Shell gerufen die Druckt. Formatiert die Seiten. - void CalcPagesForPrint( sal_uInt16 nMax, SfxProgress* pProgress = 0, - const String* pStr = NULL, ULONG nMergeAct = 0, ULONG nMergeCnt = 0 ); + void CalcPagesForPrint( sal_uInt16 nMax, SfxProgress* pProgress = 0 ); //All about fields. void UpdateFlds(sal_Bool bCloseDB = sal_False); diff --git a/sw/source/core/view/viewpg.cxx b/sw/source/core/view/viewpg.cxx index c3da2df6cf37..a9ab62df38fc 100644 --- a/sw/source/core/view/viewpg.cxx +++ b/sw/source/core/view/viewpg.cxx @@ -508,7 +508,7 @@ void ViewShell::PrintProspect( } // Seiten fuers Drucken formatieren - aShell.CalcPagesForPrint( nPageMax, 0 /*(USHORT)aPages.Max(), &rProgress*/ ); + aShell.CalcPagesForPrint( nPageMax, 0 ); #endif // TL_NOT_NOW // TLPDF MapMode aMapMode( MAP_TWIP ); @@ -636,7 +636,7 @@ void ViewShell::PrintProspect( { SwMsgPoolItem aHnt( RES_HIDDENPARA_PRINT ); pFldType->Modify( &aHnt, 0); - CalcPagesForPrint( nPageMax /*(USHORT)aPages.Max()*/ ); + CalcPagesForPrint( nPageMax ); } #endif // TL_NOT_NOW // TLPDF pFntCache->Flush(); diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index 081017f1aeb3..d811c12d02c5 100644 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -369,7 +369,7 @@ void SwRenderData::MakeSwPrtOptions( /*****************************************************************************/ -SwPrintUIOptions::SwPrintUIOptions( BOOL bWeb ) : +SwPrintUIOptions::SwPrintUIOptions( bool bWeb, bool bSwSrcView ) : m_pLast( NULL ) { ResStringArray aLocalizedStrings( SW_RES( STR_PRINTOPTUI ) ); @@ -378,6 +378,14 @@ SwPrintUIOptions::SwPrintUIOptions( BOOL bWeb ) : if( aLocalizedStrings.Count() < 44 ) // bad resource ? return; + // printing HTML sources does not have any valid UI options. + // Its just the source code that gets printed ... + if (bSwSrcView) + { + m_aUIProperties.realloc( 0 ); + return; + } + // create sequence of print UI options // (5 options are not available for Writer-Web) const int nNumProps = bWeb? 17 : 21; @@ -502,12 +510,14 @@ SwPrintUIOptions::SwPrintUIOptions( BOOL bWeb ) : aHelpText.realloc( 2 ); aHelpText[0] = aLocalizedStrings.GetString( 25 ); aHelpText[1] = aLocalizedStrings.GetString( 25 ); + vcl::PrinterOptionsHelper::UIControlOptions aAnnotOpt( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintProspect" ) ), 1, sal_False ); m_aUIProperties[ nIdx++ ].Value = getChoiceControlOpt( aLocalizedStrings.GetString( 26 ), aHelpText, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintAnnotationMode" ) ), aChoices, 0, - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "List" ) ) + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "List" ) ), + aAnnotOpt ); // create subsection for Page settings @@ -834,8 +844,7 @@ void lcl_SetState( SfxProgress& rProgress, ULONG nPage, ULONG nMax, -void ViewShell::CalcPagesForPrint( USHORT nMax, SfxProgress* pProgress, - const XubString* /*TLPDF pStr*/, ULONG /*TLPDF nMergeAct*/, ULONG /*TLPDF nMergeCnt*/ ) +void ViewShell::CalcPagesForPrint( USHORT nMax, SfxProgress* pProgress ) { SET_CURR_SHELL( this ); @@ -1169,8 +1178,7 @@ sal_Bool ViewShell::PrintOrPDFExport( #ifdef TL_NOT_NOW // TLPDF: applying view options and formatting the dcoument should now only be done in getRendererCount! // benoetigte Seiten fuers Drucken formatieren - pShell->CalcPagesForPrint( (USHORT)nPage, 0 /*TLPDF*/, 0 /*TLPDFpStr*/, - 0, 0 /* TLPDF, there is no progressbar right now nMergeAct, nMergeCnt */ ); + pShell->CalcPagesForPrint( (USHORT)nPage, 0 ); // Some field types, can require a valid layout // (expression fields in tables). For these we do an UpdateFlds diff --git a/sw/source/ui/dbui/dbmgr.cxx b/sw/source/ui/dbui/dbmgr.cxx index dee7803a9798..487bc744e9eb 100644 --- a/sw/source/ui/dbui/dbmgr.cxx +++ b/sw/source/ui/dbui/dbmgr.cxx @@ -781,178 +781,6 @@ SwNewDBMgr::~SwNewDBMgr() } delete pImpl; } -/*-------------------------------------------------------------------- - Beschreibung: Serienbrief drucken - --------------------------------------------------------------------*/ - - -BOOL SwNewDBMgr::MergePrint( SwView& rView, - SwPrtOptions& rOpt, SfxProgress& rProgress, BOOL bIsAPI ) -{ - SwWrtShell* pSh = &rView.GetWrtShell(); - //check if the doc is synchronized and contains at least one linked section - BOOL bSynchronizedDoc = pSh->IsLabelDoc() && pSh->GetSectionFmtCount() > 1; - //merge source is already open - rOpt.nMergeCnt = 0; - //#i56195# no field update while printing mail merge documents - rOpt.bUpdateFieldsInPrinting = sal_False; - if(pImpl->pMergeData) - { - if(pImpl->pMergeData->aSelection.getLength()) - rOpt.nMergeCnt = pImpl->pMergeData->aSelection.getLength(); - else if(pImpl->pMergeData->xResultSet.is()) - { - sal_Int32 nCount; - if( lcl_getCountFromResultSet( nCount, pImpl->pMergeData->xResultSet ) ) - rOpt.nMergeCnt = (ULONG)nCount; - } - } - - SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig(); - pModOpt->SetSinglePrintJob(rOpt.IsPrintSingleJobs()); - -//TLPDF SfxPrinter *pPrt = pSh->getIDocumentDeviceAccess()->getPrinter( false ); - const boost::shared_ptr< Printer > pPrt( new Printer /* Printer( const JobSetup& rJobSetup ) */ ); // TLPDF - vcl::OldStylePrintAdaptor aPrtAdaptor( pPrt ); // TLPDF - const boost::shared_ptr< vcl::PrinterController > pPrtController( &aPrtAdaptor ); -//TLPDF Link aSfxSaveLnk = pPrt->GetEndPrintHdl(); -//TLPDF if( rOpt.IsPrintSingleJobs() ) -//TLPDF pPrt->SetEndPrintHdl( Link() ); - -//TLPDF BOOL bUserBreak = FALSE; - BOOL bRet = FALSE; - long nStartRow, nEndRow; - //calculate number of data sets to be printed - - Sequence aViewProperties(16); - PropertyValue* pViewProperties = aViewProperties.getArray(); - pViewProperties[0].Name = C2U("MailMergeCount"); - pViewProperties[0].Value <<= (sal_Int32)rOpt.nMergeCnt; - pViewProperties[1].Name = C2U("PrintGraphics"); - pViewProperties[1].Value <<= (sal_Bool)rOpt.IsPrintGraphic(); - pViewProperties[2].Name = C2U("PrintTables"); - pViewProperties[2].Value <<= (sal_Bool)rOpt.IsPrintTable(); - pViewProperties[3].Name = C2U("PrintDrawings"); - pViewProperties[3].Value <<= (sal_Bool)rOpt.IsPrintDraw(); - pViewProperties[4].Name = C2U("PrintLeftPages"); - pViewProperties[4].Value <<= (sal_Bool)rOpt.IsPrintLeftPage(); - pViewProperties[5].Name = C2U("PrintRightPages"); - pViewProperties[5].Value <<= (sal_Bool)rOpt.IsPrintRightPage(); - pViewProperties[6].Name = C2U("PrintControls"); - pViewProperties[6].Value <<= (sal_Bool)rOpt.IsPrintControl(); - pViewProperties[7].Name = C2U("PrintReversed"); - pViewProperties[7].Value <<= (sal_Bool)rOpt.IsPrintReverse(); - pViewProperties[8].Name = C2U("PrintPaperFromSetup"); - pViewProperties[8].Value <<= (sal_Bool)rOpt.IsPaperFromSetup(); - pViewProperties[9].Name = C2U("PrintFaxName"); - pViewProperties[9].Value <<= rOpt.GetFaxName(); - pViewProperties[10].Name = C2U("PrintAnnotationMode"); - pViewProperties[10].Value <<= (text::NotePrintMode) rOpt.GetPrintPostIts(); - pViewProperties[11].Name = C2U("PrintProspect"); - pViewProperties[11].Value <<= (sal_Bool)rOpt.IsPrintProspect(); - pViewProperties[12].Name = C2U("PrintPageBackground"); - pViewProperties[12].Value <<= (sal_Bool)rOpt.IsPrintPageBackground(); - pViewProperties[13].Name = C2U("PrintBlackFonts"); - pViewProperties[13].Value <<= (sal_Bool)rOpt.IsPrintBlackFont(); - pViewProperties[14].Name = C2U("IsSinglePrintJob"); - pViewProperties[14].Value <<= (sal_Bool)rOpt.IsPrintSingleJobs(); - pViewProperties[15].Name = C2U("PrintEmptyPages"); - pViewProperties[15].Value <<= (sal_Bool)rOpt.IsPrintEmptyPages(); - - rView.SetAdditionalPrintOptions(aViewProperties); - do { - nStartRow = pImpl->pMergeData ? pImpl->pMergeData->xResultSet->getRow() : 0; - { - SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE, pSh->GetView().GetViewFrame()->GetObjectShell())); - pSh->ViewShell::UpdateFlds(); - SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE_FINISHED, pSh->GetView().GetViewFrame()->GetObjectShell())); - ++rOpt.nMergeAct; - - // launch MailMergeEvent if required - const SwXMailMerge *pEvtSrc = GetMailMergeEvtSrc(); - if (pEvtSrc) - { - uno::Reference< XInterface > xRef( (XMailMergeBroadcaster *) pEvtSrc ); - text::MailMergeEvent aEvt( xRef, rView.GetDocShell()->GetModel() ); - pEvtSrc->LaunchMailMergeEvent( aEvt ); - } - - rView.SfxViewShell::Print( rProgress, bIsAPI ); // ggf Basic-Macro ausfuehren - if( rOpt.IsPrintSingleJobs() && bRet ) - { - //rOpt.bJobStartet = FALSE; - bRet = FALSE; - } - - bMergeLock = TRUE; - if(rOpt.IsPrintProspect()) - { -#ifdef TL_NOT_NOW /*TLPDF*/ - if( ! pPrt->IsJobActive() ) - { - pPrt->SetJobValue( String( RTL_CONSTASCII_USTRINGPARAM( "IsQuickJob" ) ), - String( RTL_CONSTASCII_USTRINGPARAM( "true" ) ) ); - pPrt->StartJob( rOpt.GetJobName() ); - } - if( pPrt->IsJobActive() ) - { - pSh->PrintProspectMM( aPrtAdaptor, aViewProperties, rOpt, rOpt.IsPrintProspectRTL() ); /* TLPDF */ - bRet = TRUE; - } -#endif // TL_NOT_NOW /*TLPDF*/ -//TLPDFXX pSh->PrintProspectMM( aPrtAdaptor, aViewProperties, rOpt, rOpt.IsPrintProspectRTL() ); // TLPDF - bRet = TRUE; // TLPDF - } - else if( 1 /*TLPDFXX pSh->PrintOrPDFExportMM( aPrtAdaptor, aViewProperties, rOpt ) */ ) - bRet = TRUE; - bMergeLock = FALSE; - -#ifdef TL_NOT_NOW /*TLPDF*/ - if( !pPrt->IsJobActive() ) - { - bUserBreak = TRUE; - bRet = FALSE; - break; - } -#endif // TL_NOT_NOW /*TLPDF*/ - if( !rOpt.IsPrintSingleJobs() ) - { - String& rJNm = (String&)rOpt.GetJobName(); - rJNm.Erase(); - } - } - nEndRow = pImpl->pMergeData ? pImpl->pMergeData->xResultSet->getRow() : 0; - } while( bSynchronizedDoc && (nStartRow != nEndRow)? ExistsNextRecord() : ToNextMergeRecord()); - - if( rOpt.IsPrintSingleJobs() ) - { -//TLPDF SfxPrinter* pTmpPrinter = pSh->getIDocumentDeviceAccess()->getPrinter( true ); -//TLPDF const boost::shared_ptr< Printer > pTmpPrinter( new Printer /* Printer( const JobSetup& rJobSetup ) */ ); // TLPDF -//TLPDF vcl::OldStylePrintAdaptor aPrtAdaptor( pTmpPrinter ); - // TLPDF -//TLPDF pTmpPrinter->SetEndPrintHdl( aSfxSaveLnk ); -//TLPDF if ( !bUserBreak && !pTmpPrinter->IsJobActive() ) //Schon zu spaet? -//TLPDF aSfxSaveLnk.Call( pTmpPrinter ); - } - - rOpt.nMergeCnt = 0; - rOpt.nMergeAct = 0; - - nMergeType = DBMGR_INSERT; - - SwDocShell* pDocSh = rView.GetDocShell(); - SfxViewFrame *pTmpFrm = SfxViewFrame::GetFirst(pDocSh); - - while (pTmpFrm) // Alle Views Invalidieren - { - SwView *pVw = PTR_CAST(SwView, pTmpFrm->GetViewShell()); - if (pVw) - pVw->GetEditWin().Invalidate(); - pTmpFrm = pTmpFrm->GetNext(*pTmpFrm, pDocSh); - } - - return bRet; -} /*-------------------------------------------------------------------- Beschreibung: Serienbriefe als einzelne Dokumente speichern diff --git a/sw/source/ui/inc/srcview.hxx b/sw/source/ui/inc/srcview.hxx index 996aab82b446..d66096d4418b 100644 --- a/sw/source/ui/inc/srcview.hxx +++ b/sw/source/ui/inc/srcview.hxx @@ -32,6 +32,8 @@ #include #include +#include + #include "srcedtw.hxx" #include "shellid.hxx" @@ -92,11 +94,11 @@ public: void Load(SwDocShell* pDocShell); - virtual USHORT SetPrinter( SfxPrinter* pNew, - USHORT nDiff = SFX_PRINTER_ALL, bool bIsAPI=false ); - virtual ErrCode DoPrint( SfxPrinter *pPrinter, PrintDialog *pPrintDialog, BOOL bSilent, BOOL bIsAPI ); + virtual USHORT SetPrinter( SfxPrinter* pNew, USHORT nDiff = SFX_PRINTER_ALL, bool bIsAPI=false ); virtual SfxPrinter* GetPrinter( BOOL bCreate = FALSE ); + sal_Int32 PrintSource( OutputDevice *pOutDev, sal_Int32 nPage, bool bCalcNumPagesOnly ); + void SourceSaved() {bSourceSaved = TRUE;} BOOL HasSourceSaved() const {return bSourceSaved;} diff --git a/sw/source/ui/uiview/srcview.cxx b/sw/source/ui/uiview/srcview.cxx index 1b496b3b4fae..d1e0ab8e3bec 100644 --- a/sw/source/ui/uiview/srcview.cxx +++ b/sw/source/ui/uiview/srcview.cxx @@ -151,23 +151,23 @@ TYPEINIT1(SwSrcView, SfxViewShell) --------------------------------------------------*/ -void lcl_PrintHeader( Printer* pPrinter, USHORT nPages, USHORT nCurPage, const String& rTitle ) +void lcl_PrintHeader( OutputDevice &rOutDev, USHORT nPages, USHORT nCurPage, const String& rTitle ) { short nLeftMargin = LMARGPRN; - Size aSz = pPrinter->GetOutputSize(); + Size aSz = rOutDev.GetOutputSize(); short nBorder = BORDERPRN; - Color aOldFillColor( pPrinter->GetFillColor() ); - Font aOldFont( pPrinter->GetFont() ); + Color aOldFillColor( rOutDev.GetFillColor() ); + Font aOldFont( rOutDev.GetFont() ); - pPrinter->SetFillColor( Color(COL_TRANSPARENT) ); + rOutDev.SetFillColor( Color(COL_TRANSPARENT) ); Font aFont( aOldFont ); aFont.SetWeight( WEIGHT_BOLD ); aFont.SetAlign( ALIGN_BOTTOM ); - pPrinter->SetFont( aFont ); + rOutDev.SetFont( aFont ); - long nFontHeight = pPrinter->GetTextHeight(); + long nFontHeight = rOutDev.GetTextHeight(); // 1.Border => Strich, 2+3 Border = Freiraum. long nYTop = TMARGPRN-3*nBorder-nFontHeight; @@ -175,34 +175,34 @@ void lcl_PrintHeader( Printer* pPrinter, USHORT nPages, USHORT nCurPage, const S long nXLeft = nLeftMargin-nBorder; long nXRight = aSz.Width()-RMARGPRN+nBorder; - pPrinter->DrawRect( Rectangle( + rOutDev.DrawRect( Rectangle( Point( nXLeft, nYTop ), Size( nXRight-nXLeft, aSz.Height() - nYTop - BMARGPRN + nBorder ) ) ); long nY = TMARGPRN-2*nBorder; Point aPos( nLeftMargin, nY ); - pPrinter->DrawText( aPos, rTitle ); + rOutDev.DrawText( aPos, rTitle ); if ( nPages != 1 ) { aFont.SetWeight( WEIGHT_NORMAL ); - pPrinter->SetFont( aFont ); + rOutDev.SetFont( aFont ); String aPageStr( C2S(" [") ); aPageStr += String( SW_RES( STR_PAGE ) ); aPageStr += ' '; aPageStr += String::CreateFromInt32( nCurPage ); aPageStr += ']'; - aPos.X() += pPrinter->GetTextWidth( rTitle ); - pPrinter->DrawText( aPos, aPageStr ); + aPos.X() += rOutDev.GetTextWidth( rTitle ); + rOutDev.DrawText( aPos, aPageStr ); } nY = TMARGPRN-nBorder; - pPrinter->DrawLine( Point( nXLeft, nY ), Point( nXRight, nY ) ); + rOutDev.DrawLine( Point( nXLeft, nY ), Point( nXRight, nY ) ); - pPrinter->SetFont( aOldFont ); - pPrinter->SetFillColor( aOldFillColor ); + rOutDev.SetFont( aOldFont ); + rOutDev.SetFillColor( aOldFillColor ); } /* -----------------13.11.2003 16:24----------------- @@ -725,9 +725,10 @@ USHORT SwSrcView::StartSearchAndReplace(const SvxSearchItem& rSearchItem, return nFound; } -/*-----------------02.07.97 09:29------------------- +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ ---------------------------------------------------*/ USHORT SwSrcView::SetPrinter(SfxPrinter* pNew, USHORT nDiffFlags, bool ) { SwDocShell* pDocSh = GetDocShell(); @@ -753,114 +754,87 @@ USHORT SwSrcView::SetPrinter(SfxPrinter* pNew, USHORT nDiffFlags, bool ) Beschreibung: --------------------------------------------------------------------*/ -ErrCode SwSrcView::DoPrint( SfxPrinter * /*pPrinter*/, PrintDialog * /*pDlg*/, BOOL /*bSilent*/, BOOL /*bIsAPI*/ ) +SfxPrinter* SwSrcView::GetPrinter( BOOL bCreate ) { - #if 0 - SfxPrintProgress *pProgress = new SfxPrintProgress( this, !bSilent ); - SfxPrinter *pDocPrinter = GetPrinter(TRUE); - if ( !pPrinter ) - pPrinter = pDocPrinter; - else if ( pDocPrinter != pPrinter ) - { - pProgress->RestoreOnEndPrint( pDocPrinter->Clone() ); - SetPrinter( pPrinter, SFX_PRINTER_PRINTER ); - } - pProgress->SetWaitMode(FALSE); + return GetDocShell()->GetDoc()->getPrinter( bCreate ); +} - // Drucker starten - PreparePrint( pDlg ); +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ +sal_Int32 SwSrcView::PrintSource( + OutputDevice *pOutDev, + sal_Int32 nPage, + bool bCalcNumPagesOnly ) +{ + if (!pOutDev || nPage <= 0) + return 0; - SfxViewShell::Print(*pProgress, bIsAPI, pDlg ); //??? + //! this a lgorithm for printing the n-th page is very poor since it + //! needs to go over the text of all previous pages to get to the correct one. + //! But since HTML source code is expected to be just a small number of pages + //! even this poor algorithm should be enough... - MapMode eOldMapMode( pPrinter->GetMapMode() ); - Font aOldFont( pPrinter->Printer::GetFont() ); + pOutDev->Push(); TextEngine* pTextEngine = aEditWin.GetTextEngine(); - pPrinter->SetMapMode(MAP_100TH_MM); - Font aFont(aEditWin.GetOutWin()->GetFont()); - Size aSize(aFont.GetSize()); - aSize = aEditWin.GetOutWin()->PixelToLogic(aSize, MAP_100TH_MM); - aFont.SetSize(aSize); - aFont.SetColor(COL_BLACK); - pPrinter->SetFont( aFont ); + pOutDev->SetMapMode( MAP_100TH_MM ); + Font aFont( aEditWin.GetOutWin()->GetFont() ); + Size aSize( aFont.GetSize() ); + aSize = aEditWin.GetOutWin()->PixelToLogic( aSize, MAP_100TH_MM ); + aFont.SetSize( aSize ); + aFont.SetColor( COL_BLACK ); + pOutDev->SetFont( aFont ); String aTitle( GetViewFrame()->GetWindow().GetText() ); - USHORT nLineHeight = (USHORT) pPrinter->GetTextHeight(); // etwas mehr. + USHORT nLineHeight = (USHORT) pOutDev->GetTextHeight(); // etwas mehr. USHORT nParaSpace = 10; - Size aPaperSz = pPrinter->GetOutputSize(); - aPaperSz.Width() -= (LMARGPRN+RMARGPRN); - aPaperSz.Height() -= (TMARGPRN+BMARGPRN); + Size aPaperSz = pOutDev->GetOutputSize(); + aPaperSz.Width() -= (LMARGPRN + RMARGPRN); + aPaperSz.Height() -= (TMARGPRN + BMARGPRN); // nLinepPage stimmt nicht, wenn Zeilen umgebrochen werden muessen... - USHORT nLinespPage = (USHORT) (aPaperSz.Height()/nLineHeight); - USHORT nCharspLine = (USHORT) (aPaperSz.Width() / pPrinter->GetTextWidth( 'X' )); + USHORT nLinespPage = (USHORT) (aPaperSz.Height() / nLineHeight); + USHORT nCharspLine = (USHORT) (aPaperSz.Width() / pOutDev->GetTextWidth( 'X' )); USHORT nParas = static_cast< USHORT >( pTextEngine->GetParagraphCount() ); - USHORT nPages = (USHORT) (nParas/nLinespPage+1 ); + USHORT nPages = (USHORT) (nParas / nLinespPage + 1 ); USHORT nCurPage = 1; - BOOL bStartJob = pPrinter->StartJob( aTitle ); - if( bStartJob ) + // Header drucken... + if (!bCalcNumPagesOnly && nPage == nCurPage) + lcl_PrintHeader( *pOutDev, nPages, nCurPage, aTitle ); + Point aPos( LMARGPRN, TMARGPRN ); + for ( USHORT nPara = 0; nPara < nParas; ++nPara ) { - pPrinter->StartPage(); - // Header drucken... - lcl_PrintHeader( pPrinter, nPages, nCurPage, aTitle ); - Point aPos( LMARGPRN, TMARGPRN ); - for ( USHORT nPara = 0; nPara < nParas; nPara++ ) + String aLine( pTextEngine->GetText( nPara ) ); + lcl_ConvertTabsToSpaces( aLine ); + USHORT nLines = aLine.Len() / nCharspLine + 1; + for ( USHORT nLine = 0; nLine < nLines; ++nLine ) { - String aLine( pTextEngine->GetText( nPara ) ); - lcl_ConvertTabsToSpaces( aLine ); - USHORT nLines = aLine.Len()/nCharspLine+1; - for ( USHORT nLine = 0; nLine < nLines; nLine++ ) + String aTmpLine( aLine, nLine * nCharspLine, nCharspLine ); + aPos.Y() += nLineHeight; + if ( aPos.Y() > ( aPaperSz.Height() + TMARGPRN ) ) { - String aTmpLine( aLine, nLine*nCharspLine, nCharspLine ); - aPos.Y() += nLineHeight; - if ( aPos.Y() > ( aPaperSz.Height()+TMARGPRN ) ) - { - nCurPage++; - pPrinter->EndPage(); - pPrinter->StartPage(); - lcl_PrintHeader( pPrinter, nPages, nCurPage, aTitle ); - aPos = Point( LMARGPRN, TMARGPRN+nLineHeight ); - } - pPrinter->DrawText( aPos, aTmpLine ); + ++nCurPage; + if (!bCalcNumPagesOnly && nPage == nCurPage) + lcl_PrintHeader( *pOutDev, nPages, nCurPage, aTitle ); + aPos = Point( LMARGPRN, TMARGPRN + nLineHeight ); } - aPos.Y() += nParaSpace; + if (!bCalcNumPagesOnly && nPage == nCurPage) + pOutDev->DrawText( aPos, aTmpLine ); } - pPrinter->EndPage(); + aPos.Y() += nParaSpace; } - pPrinter->SetFont( aOldFont ); - pPrinter->SetMapMode( eOldMapMode ); - - if ( !bStartJob ) - { - // Printer konnte nicht gestartet werden - delete pProgress; - return ERRCODE_IO_ABORT; - } + pOutDev->Pop(); - pProgress->Stop(); - pProgress->DeleteOnEndPrint(); - pPrinter->EndJob(); - return pPrinter->GetError(); - #else - DBG_ERROR( "dead code" ); - return ERRCODE_IO_NOTSUPPORTED; - #endif + DBG_ASSERT( bCalcNumPagesOnly || nPage <= nCurPage, "page number out of range" ); + return nCurPage; } -/*-------------------------------------------------------------------- - Beschreibung: - --------------------------------------------------------------------*/ - - -SfxPrinter* SwSrcView::GetPrinter( BOOL bCreate ) -{ - return GetDocShell()->GetDoc()->getPrinter( bCreate ); -} /*-------------------------------------------------------------------- Beschreibung: diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index fb765915f5b0..65bc181133e2 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -2470,20 +2470,50 @@ static OutputDevice * lcl_GetOutputDevice( const SwPrintUIOptions &rPrintUIOptio } -SfxViewShell * SwXTextDocument::GetRenderView( const SwPrintUIOptions &rOpt, bool bIsPDFExport ) +static bool lcl_SeqHasProperty( + const uno::Sequence< beans::PropertyValue >& rOptions, + const sal_Char *pPropName ) +{ + bool bRes = false; + const sal_Int32 nLen = rOptions.getLength(); + const beans::PropertyValue *pProps = rOptions.getConstArray(); + for (sal_Int32 i = 0; i < nLen && !bRes; ++i) + { + if (pProps[i].Name.equalsAscii( pPropName )) + bRes = true; + } + return bRes; +} + + +SfxViewShell * SwXTextDocument::GetRenderView( + bool &rbIsSwSrcView, + const uno::Sequence< beans::PropertyValue >& rOptions, + bool bIsPDFExport ) { // get view shell to use SfxViewShell *pView = 0; if (bIsPDFExport) - pView = GuessViewShell(); + pView = GuessViewShell( rbIsSwSrcView ); else { - uno::Any aTmp( rOpt.getValue( C2U( "View" ) )); + uno::Any aTmp; + const sal_Int32 nLen = rOptions.getLength(); + const beans::PropertyValue *pProps = rOptions.getConstArray(); + for (sal_Int32 i = 0; i < nLen; ++i) + { + if (pProps[i].Name.equalsAscii( "View" )) + { + aTmp = pProps[i].Value; + break; + } + } + uno::Reference< frame::XController > xController; if (aTmp >>= xController) { DBG_ASSERT( xController.is(), "controller is empty!" ); - pView = GuessViewShell( xController ); + pView = GuessViewShell( rbIsSwSrcView, xController ); } } return pView; @@ -2499,7 +2529,10 @@ SfxViewShell * SwXTextDocument::GetRenderView( const SwPrintUIOptions &rOpt, boo * SfxViewShell. */ -SwDoc * SwXTextDocument::GetRenderDoc( SfxViewShell *&rpView, const uno::Any& rSelection, bool bIsPDFExport ) +SwDoc * SwXTextDocument::GetRenderDoc( + SfxViewShell *&rpView, + const uno::Any& rSelection, + bool bIsPDFExport ) { SwDoc *pDoc = 0; @@ -2518,8 +2551,9 @@ SwDoc * SwXTextDocument::GetRenderDoc( SfxViewShell *&rpView, const uno::Any& rS // used for PDF export of (multi-)selection if (rSelection.hasValue()) // is anything selected ? { + bool bIsSwSrcView = false; if (!rpView) - rpView = GuessViewShell(); + rpView = GuessViewShell( bIsSwSrcView ); DBG_ASSERT( rpView, "ViewShell missing" ); // the view shell should be SwView for documents PDF export. // for the page preview no selection should be possible @@ -2554,106 +2588,111 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount( if(!IsValid()) throw RuntimeException(); - // actually m_pRenderData and m_pPrintUIOptions should have already been - // destroyed in 'render' when IsLastPage was set (or should have been set) -// if (m_pRenderData) -// delete m_pRenderData, m_pRenderData = 0; -// if (m_pPrintUIOptions) -// delete m_pPrintUIOptions, m_pPrintUIOptions = 0; + const bool bIsPDFExport = !lcl_SeqHasProperty( rxOptions, "IsPrinter" ); + bool bIsSwSrcView = false; + SfxViewShell *pView = GetRenderView( bIsSwSrcView, rxOptions, bIsPDFExport ); if (! m_pRenderData) m_pRenderData = new SwRenderData; if (! m_pPrintUIOptions) { - const BOOL bWebDoc = (0 != PTR_CAST(SwWebDocShell, pDocShell)); - m_pPrintUIOptions = new SwPrintUIOptions( bWebDoc ); + const BOOL bWebDoc = (0 != PTR_CAST(SwWebDocShell, pDocShell)); + m_pPrintUIOptions = new SwPrintUIOptions( bWebDoc, bIsSwSrcView ); } bool bFormat = m_pPrintUIOptions->processPropertiesAndCheckFormat( rxOptions ); - const bool bIsPDFExport = !m_pPrintUIOptions->hasProperty( "IsPrinter" ); const bool bIsSkipEmptyPages = !m_pPrintUIOptions->IsPrintEmptyPages( bIsPDFExport ); - SfxViewShell *pView = GetRenderView( *m_pPrintUIOptions, bIsPDFExport ); SwDoc *pDoc = GetRenderDoc( pView, rSelection, bIsPDFExport ); + DBG_ASSERT( pDoc && pView, "doc or view shell missing!" ); if (!pDoc || !pView) - throw RuntimeException(); - - SwDocShell *pRenderDocShell = pDoc->GetDocShell(); - // #i38289 - if(pDoc->get(IDocumentSettingAccess::BROWSE_MODE) /*TLPDF for printing as well?*/) - { - pRenderDocShell->ToggleBrowserMode(false,NULL); - } - - SwWrtShell *pWrtShell = pRenderDocShell->GetWrtShell(); + return 0; sal_Int32 nRet = 0; - if( !pWrtShell ) + if (bIsSwSrcView) { - //create a hidden view to be able to export as PDF also in print preview - m_pHiddenViewFrame = SfxViewFrame::CreateViewFrame( *pRenderDocShell, 2, TRUE ); - SwView* pSwView = (SwView*) m_pHiddenViewFrame->GetViewShell(); - pWrtShell = pSwView->GetWrtShellPtr(); + SwSrcView *pSwSrcView = dynamic_cast< SwSrcView * >(pView); + OutputDevice *pOutDev = lcl_GetOutputDevice( *m_pPrintUIOptions ); + nRet = pSwSrcView->PrintSource( pOutDev, 1 /* dummy */, true /* get page count only */ ); } + else + { + SwDocShell *pRenderDocShell = pDoc->GetDocShell(); + // #i38289 + if(pDoc->get(IDocumentSettingAccess::BROWSE_MODE)) + { + pRenderDocShell->ToggleBrowserMode(false,NULL); + } - m_pRenderData->SetSwPrtOptions( new SwPrtOptions( C2U( bIsPDFExport ? "PDF export" : "Printing" ) ) ); - m_pRenderData->MakeSwPrtOptions( m_pRenderData->GetSwPrtOptionsRef(), pRenderDocShell, - m_pPrintUIOptions, m_pRenderData, bIsSkipEmptyPages, bIsPDFExport ); + SwWrtShell *pWrtShell = pRenderDocShell->GetWrtShell(); - //SwViewOptionAdjust_Impl aAdjust(*pWrtShell); - const TypeId aSwViewTypeId = TYPE(SwView); - if (pView->IsA(aSwViewTypeId)) - m_pRenderData->ViewOptionAdjustStart( *((SwView*)pView)->GetWrtShellPtr() ); + if( !pWrtShell ) + { + //create a hidden view to be able to export as PDF also in print preview + m_pHiddenViewFrame = SfxViewFrame::CreateViewFrame( *pRenderDocShell, 2, TRUE ); + SwView* pSwView = (SwView*) m_pHiddenViewFrame->GetViewShell(); + pWrtShell = pSwView->GetWrtShellPtr(); + } - if( bFormat ) - { - // since printing now also use the API for PDF export this option - // should be set for printing as well ... - pWrtShell->SetPDFExportOption( sal_True ); + m_pRenderData->SetSwPrtOptions( new SwPrtOptions( C2U( bIsPDFExport ? "PDF export" : "Printing" ) ) ); + m_pRenderData->MakeSwPrtOptions( m_pRenderData->GetSwPrtOptionsRef(), pRenderDocShell, + m_pPrintUIOptions, m_pRenderData, bIsSkipEmptyPages, bIsPDFExport ); - // --> FME 2005-05-23 #122919# Force field update before PDF export: - pWrtShell->ViewShell::UpdateFlds(TRUE); - // <-- + //SwViewOptionAdjust_Impl aAdjust(*pWrtShell); + const TypeId aSwViewTypeId = TYPE(SwView); + if (pView->IsA(aSwViewTypeId)) + m_pRenderData->ViewOptionAdjustStart( *((SwView*)pView)->GetWrtShellPtr() ); - // there is some redundancy between those two fucntion calls, but right now - // there is no time to sort this out. - //TODO: check what exatly needs to be done and make just one function for that - pWrtShell->CalcLayout(); - pWrtShell->CalcPagesForPrint( pDoc->GetPageCount() ); + if( bFormat ) + { + // since printing now also use the API for PDF export this option + // should be set for printing as well ... + pWrtShell->SetPDFExportOption( sal_True ); - pWrtShell->SetPDFExportOption( sal_False ); - } + // --> FME 2005-05-23 #122919# Force field update before PDF export: + pWrtShell->ViewShell::UpdateFlds(TRUE); + // <-- - const sal_Int32 nPageCount = pDoc->GetPageCount(); + // there is some redundancy between those two function calls, but right now + // there is no time to sort this out. + //TODO: check what exatly needs to be done and make just one function for that + pWrtShell->CalcLayout(); + pWrtShell->CalcPagesForPrint( pDoc->GetPageCount() ); - // - // get number of pages to be rendered - // - const bool bPrintProspect = m_pPrintUIOptions->getBoolValue( "PrintProspect", false ); - if (bPrintProspect) - { - pDoc->CalculatePagePairsForProspectPrinting( *m_pRenderData, *m_pPrintUIOptions, nPageCount ); - nRet = m_pRenderData->GetPagePairsForProspectPrinting().size(); - } - else - { - const sal_Int16 nPostItMode = (sal_Int16) m_pPrintUIOptions->getIntValue( "PrintAnnotationMode", 0 ); - if (nPostItMode != POSTITS_NONE) - { - OutputDevice *pOutDev = lcl_GetOutputDevice( *m_pPrintUIOptions ); - m_pRenderData->CreatePostItData( pDoc, pWrtShell->GetViewOptions(), pOutDev ); + pWrtShell->SetPDFExportOption( sal_False ); } - // get set of valid document pages (according to the current settings) - // and their start frames - pDoc->CalculatePagesForPrinting( *m_pRenderData, *m_pPrintUIOptions, bIsPDFExport, nPageCount ); + const sal_Int32 nPageCount = pDoc->GetPageCount(); - if (nPostItMode != POSTITS_NONE) + // + // get number of pages to be rendered + // + const bool bPrintProspect = m_pPrintUIOptions->getBoolValue( "PrintProspect", false ); + if (bPrintProspect) { - pDoc->UpdatePagesForPrintingWithPostItData( *m_pRenderData, - *m_pPrintUIOptions, bIsPDFExport, nPageCount ); + pDoc->CalculatePagePairsForProspectPrinting( *m_pRenderData, *m_pPrintUIOptions, nPageCount ); + nRet = m_pRenderData->GetPagePairsForProspectPrinting().size(); } + else + { + const sal_Int16 nPostItMode = (sal_Int16) m_pPrintUIOptions->getIntValue( "PrintAnnotationMode", 0 ); + if (nPostItMode != POSTITS_NONE) + { + OutputDevice *pOutDev = lcl_GetOutputDevice( *m_pPrintUIOptions ); + m_pRenderData->CreatePostItData( pDoc, pWrtShell->GetViewOptions(), pOutDev ); + } - nRet = m_pRenderData->GetPagesToPrint().size(); + // get set of valid document pages (according to the current settings) + // and their start frames + pDoc->CalculatePagesForPrinting( *m_pRenderData, *m_pPrintUIOptions, bIsPDFExport, nPageCount ); + + if (nPostItMode != POSTITS_NONE) + { + pDoc->UpdatePagesForPrintingWithPostItData( *m_pRenderData, + *m_pPrintUIOptions, bIsPDFExport, nPageCount ); + } + + nRet = m_pRenderData->GetPagesToPrint().size(); + } } DBG_ASSERT( nRet >= 0, "negative number of pages???" ); @@ -2672,44 +2711,83 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SwXTextDocument::getRenderer( if(!IsValid()) throw RuntimeException(); - DBG_ASSERT( m_pRenderData, "data should have been created already in getRendererCount..." ); - DBG_ASSERT( m_pPrintUIOptions, "data should have been created already in getRendererCount..." ); + const bool bIsPDFExport = !lcl_SeqHasProperty( rxOptions, "IsPrinter" ); + bool bIsSwSrcView = false; + SfxViewShell *pView = GetRenderView( bIsSwSrcView, rxOptions, bIsPDFExport ); + + // m_pRenderData should NOT be created here! + // That should only be done in getRendererCount. If this function is called before + // getRendererCount was called then the caller will probably just retrieve the extra UI options + // and is not interested in getting valid information about the other data that would + // otherwise be provided here! // if( ! m_pRenderData ) // m_pRenderData = new SwRenderData; if( ! m_pPrintUIOptions ) { - const BOOL bWebDoc = (0 != PTR_CAST(SwWebDocShell, pDocShell)); - m_pPrintUIOptions = new SwPrintUIOptions( bWebDoc ); + const BOOL bWebDoc = (0 != PTR_CAST(SwWebDocShell, pDocShell)); + m_pPrintUIOptions = new SwPrintUIOptions( bWebDoc, bIsSwSrcView ); } m_pPrintUIOptions->processProperties( rxOptions ); - const bool bIsPDFExport = !m_pPrintUIOptions->hasProperty( "IsPrinter" ); + const bool bPrintProspect = m_pPrintUIOptions->getBoolValue( "PrintProspect", false ); - SfxViewShell *pView = GetRenderView( *m_pPrintUIOptions, bIsPDFExport ); SwDoc *pDoc = GetRenderDoc( pView, rSelection, bIsPDFExport ); + DBG_ASSERT( pDoc && pView, "doc or view shell missing!" ); if (!pDoc || !pView) - throw RuntimeException(); + return uno::Sequence< beans::PropertyValue >(); // due to #110067# (document page count changes sometimes during // PDF export/printing) we can not check for the upper bound properly. // Thus instead of throwing the exception we silently return. - if (!(0 <= nRenderer /* && nRenderer < pDoc->GetPageCount()*/)) - throw IllegalArgumentException(); - if (nRenderer >= pDoc->GetPageCount()) - return uno::Sequence< beans::PropertyValue >(); + if (0 > nRenderer) + throw IllegalArgumentException(); + sal_Int32 nMaxRenderer = 0; + if (!bIsSwSrcView && m_pRenderData) + { + DBG_ASSERT( m_pRenderData, "m_pRenderData missing!!" ); + nMaxRenderer = bPrintProspect? + m_pRenderData->GetPagePairsForProspectPrinting().size() - 1 : + m_pRenderData->GetPagesToPrint().size() - 1; + } + // since SwSrcView::PrintSource is a poor implementation to get the number of pages to print + // we obmit checking of the upper bound in this case. + if (!bIsSwSrcView && m_pRenderData && nRenderer > nMaxRenderer) + return uno::Sequence< beans::PropertyValue >(); + + uno::Sequence< beans::PropertyValue > aRenderer; + if (m_pRenderData) + { + Size aPgSize; + if (bIsSwSrcView || m_pPrintUIOptions->getBoolValue( "PrintProspect", sal_False )) + { + // for printing of HTML source code and prospect printing we should use + // the printers paper size since + // a) HTML source view has no page size + // b) prospect printing has a different page size from the documents page + // since two document pages will get rendered on one printer page + + // since PageIncludesNonprintableArea will be set to true we can return the + // printers paper size here. + // Sometimes 'getRenderer' is only called to get "ExtraPrintUIOptions", in this + // case we won't get an OutputDevice here, but then the caller also has no need + // for the correct PageSisze right now... + Printer *pPrinter = dynamic_cast< Printer * >(lcl_GetOutputDevice( *m_pPrintUIOptions )); + if (pPrinter) + aPgSize = pPrinter->GetPaperSize(); + } + else + { + bool bIsSkipEmptyPages = !m_pPrintUIOptions->IsPrintEmptyPages( bIsPDFExport ); + aPgSize = pDoc->GetPageSize( sal_uInt16(nRenderer + 1), bIsSkipEmptyPages ); + } + awt::Size aPageSize( TWIP_TO_MM100( aPgSize.Width() ), + TWIP_TO_MM100( aPgSize.Height() )); - bool bIsSkipEmptyPages = !m_pPrintUIOptions->IsPrintEmptyPages( bIsPDFExport ); - Size aPgSize( pDoc->GetPageSize( sal_uInt16(nRenderer + 1), bIsSkipEmptyPages ) ); - awt::Size aPageSize( TWIP_TO_MM100( aPgSize.Width() ), - TWIP_TO_MM100( aPgSize.Height() )); - // prospect printing should be landscape, thus switching width and height - if (m_pPrintUIOptions->getBoolValue( "PrintProspect", sal_False ) && - aPageSize.Height > aPageSize.Width) - aPageSize = awt::Size( aPageSize.Height, aPageSize.Width ); - uno::Sequence< beans::PropertyValue > aRenderer(2); - aRenderer[0].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "PageSize" ) ); - aRenderer[0].Value <<= aPageSize; - aRenderer[1].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "PageIncludesNonprintableArea" ) ); - aRenderer[1].Value <<= sal_True; + aRenderer.realloc(2); + aRenderer[0].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "PageSize" ) ); + aRenderer[0].Value <<= aPageSize; + aRenderer[1].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "PageIncludesNonprintableArea" ) ); + aRenderer[1].Value <<= sal_True; + } m_pPrintUIOptions->appendPrintUIOptions( aRenderer ); @@ -2719,6 +2797,7 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SwXTextDocument::getRenderer( ---------------------------------------------------------------------------*/ SfxViewShell * SwXTextDocument::GuessViewShell( + /* out */ bool &rbIsSwSrcView, const uno::Reference< css::frame::XController > xController ) { // #130810# SfxViewShell::Current() / SfxViewShell::GetObjectShell() @@ -2727,6 +2806,7 @@ SfxViewShell * SwXTextDocument::GuessViewShell( SfxViewShell *pView = 0; SwView *pSwView = 0; SwPagePreView *pSwPagePreView = 0; + SwSrcView *pSwSrcView = 0; SfxViewFrame *pFrame = SfxViewFrame::GetFirst( pDocShell, 0, sal_False ); // look for the view shell with the same controller in use, @@ -2736,6 +2816,7 @@ SfxViewShell * SwXTextDocument::GuessViewShell( { pView = pFrame->GetViewShell(); pSwView = dynamic_cast< SwView * >(pView); + pSwSrcView = dynamic_cast< SwSrcView * >(pView); if (!pSwPagePreView) pSwPagePreView = dynamic_cast< SwPagePreView * >(pView); if (xController.is()) @@ -2743,15 +2824,18 @@ SfxViewShell * SwXTextDocument::GuessViewShell( if (pView && pView->GetController() == xController) break; } - else if (pSwView) + else if (pSwView || pSwSrcView) break; pFrame = SfxViewFrame::GetNext( *pFrame, pDocShell, 0, sal_False ); } - DBG_ASSERT( pSwView || pSwPagePreView, "failed to get view shell" ); - return pSwView ? - dynamic_cast< SfxViewShell * >(pSwView) : - dynamic_cast< SfxViewShell * >(pSwPagePreView); + DBG_ASSERT( pSwView || pSwPagePreView || pSwSrcView, "failed to get view shell" ); + if (pView) + rbIsSwSrcView = pSwSrcView != 0; + return pView; +// return pSwView ? dynamic_cast< SfxViewShell * >(pSwView) : +// (pSwSrcView ? dynamic_cast< SfxViewShell * >(pSwSrcView) : +// dynamic_cast< SfxViewShell * >(pSwPagePreView) ); } @@ -2765,120 +2849,140 @@ void SAL_CALL SwXTextDocument::render( if(!IsValid()) throw RuntimeException(); + const bool bIsPDFExport = !lcl_SeqHasProperty( rxOptions, "IsPrinter" ); + bool bIsSwSrcView = false; + SfxViewShell *pView = GetRenderView( bIsSwSrcView, rxOptions, bIsPDFExport ); + DBG_ASSERT( m_pRenderData, "data should have been created already in getRendererCount..." ); DBG_ASSERT( m_pPrintUIOptions, "data should have been created already in getRendererCount..." ); if (!m_pRenderData) m_pRenderData = new SwRenderData; if (!m_pPrintUIOptions) { - const BOOL bWebDoc = (0 != PTR_CAST(SwWebDocShell, pDocShell)); - m_pPrintUIOptions = new SwPrintUIOptions( bWebDoc ); + const BOOL bWebDoc = (0 != PTR_CAST(SwWebDocShell, pDocShell)); + m_pPrintUIOptions = new SwPrintUIOptions( bWebDoc, bIsSwSrcView ); } m_pPrintUIOptions->processProperties( rxOptions ); const bool bPrintProspect = m_pPrintUIOptions->getBoolValue( "PrintProspect", false ); - const bool bIsPDFExport = !m_pPrintUIOptions->hasProperty( "IsPrinter" ); - SfxViewShell *pView = GetRenderView( *m_pPrintUIOptions, bIsPDFExport ); SwDoc *pDoc = GetRenderDoc( pView, rSelection, bIsPDFExport ); - + DBG_ASSERT( pDoc && pView, "doc or view shell missing!" ); if (!pDoc || !pView) - throw RuntimeException(); + return; // due to #110067# (document page count changes sometimes during // PDF export/printing) we can not check for the upper bound properly. // Thus instead of throwing the exception we silently return. if (0 > nRenderer) throw IllegalArgumentException(); - if ( (bPrintProspect && size_t(nRenderer) >= m_pRenderData->GetPagePairsForProspectPrinting().size()) - || (!bPrintProspect && size_t(nRenderer) >= m_pRenderData->GetPagesToPrint().size())) - return; - - // the view shell should be SwView for documents PDF export - // or SwPagePreView for PDF export of the page preview - //!! (check for SwView first as in GuessViewShell) !! - DBG_ASSERT( pView, "!! view missing !!" ); - const TypeId aSwViewTypeId = TYPE(SwView); - ViewShell* pVwSh = 0; - if (pView) - { - pVwSh = pView->IsA(aSwViewTypeId) ? - ((SwView*)pView)->GetWrtShellPtr() : - ((SwPagePreView*)pView)->GetViewShell(); + sal_Int32 nMaxRenderer = 0; + if (!bIsSwSrcView) + { + DBG_ASSERT( m_pRenderData, "m_pRenderData missing!!" ); + nMaxRenderer = bPrintProspect? + m_pRenderData->GetPagePairsForProspectPrinting().size() - 1 : + m_pRenderData->GetPagesToPrint().size() - 1; + } + // since SwSrcView::PrintSource is a poor implementation to get the number of pages to print + // we obmit checking of the upper bound in this case. + if (!bIsSwSrcView && nRenderer > nMaxRenderer) + return; + + if (bIsSwSrcView) + { + SwSrcView *pSwSrcView = dynamic_cast< SwSrcView * >(pView); + OutputDevice *pOutDev = lcl_GetOutputDevice( *m_pPrintUIOptions ); + pSwSrcView->PrintSource( pOutDev, nRenderer + 1, false ); } - - // get output device to use - OutputDevice * pOut = lcl_GetOutputDevice( *m_pPrintUIOptions ); - - if(pVwSh && pOut && m_pRenderData->HasSwPrtOptions()) + else { - const rtl::OUString aPageRange = m_pPrintUIOptions->getStringValue( "PageRange", OUString() ); - const bool bFirstPage = m_pPrintUIOptions->getBoolValue( "IsFirstPage", sal_False ); - const bool bLastPage = m_pPrintUIOptions->getBoolValue( "IsLastPage", sal_False ); - bool bIsSkipEmptyPages = !m_pPrintUIOptions->IsPrintEmptyPages( bIsPDFExport ); - - DBG_ASSERT(( pView->IsA(aSwViewTypeId) && m_pRenderData->IsViewOptionAdjust()) - || (!pView->IsA(aSwViewTypeId) && !m_pRenderData->IsViewOptionAdjust()), - "SwView / SwViewOptionAdjust_Impl availability mismatch" ); - - // since printing now also use the API for PDF export this option - // should be set for printing as well ... - pVwSh->SetPDFExportOption( sal_True ); - - // --> FME 2004-06-08 #i12836# enhanced pdf export - // - // First, we have to export hyperlinks, notes, and outline to pdf. - // During this process, additional information required for tagging - // the pdf file are collected, which are evaulated during painting. - // - SwWrtShell* pWrtShell = pView->IsA(aSwViewTypeId) ? - ((SwView*)pView)->GetWrtShellPtr() : - 0; - - if (bIsPDFExport && bFirstPage && pWrtShell) + // the view shell should be SwView for documents PDF export + // or SwPagePreView for PDF export of the page preview + //!! (check for SwView first as in GuessViewShell) !! + DBG_ASSERT( pView, "!! view missing !!" ); + const TypeId aSwViewTypeId = TYPE(SwView); + ViewShell* pVwSh = 0; + if (pView) { - SwEnhancedPDFExportHelper aHelper( *pWrtShell, *pOut, aPageRange, bIsSkipEmptyPages, sal_False ); + pVwSh = pView->IsA(aSwViewTypeId) ? + ((SwView*)pView)->GetWrtShellPtr() : + ((SwPagePreView*)pView)->GetViewShell(); } - // <-- - const SwPrtOptions &rSwPrtOptions = *m_pRenderData->GetSwPrtOptions(); - if (bPrintProspect) - pVwSh->PrintProspect( pOut, rSwPrtOptions, nRenderer ); - else // normal printing and PDF export - pVwSh->PrintOrPDFExport( pOut, rSwPrtOptions, nRenderer, bIsPDFExport ); + // get output device to use + OutputDevice * pOut = lcl_GetOutputDevice( *m_pPrintUIOptions ); - // --> FME 2004-10-08 #i35176# - // - // After printing the last page, we take care for the links coming - // from the EditEngine. The links are generated during the painting - // process, but the destinations are still missing. - // - if (bIsPDFExport && bLastPage && pWrtShell) + if(pVwSh && pOut && m_pRenderData->HasSwPrtOptions()) { - SwEnhancedPDFExportHelper aHelper( *pWrtShell, *pOut, aPageRange, bIsSkipEmptyPages, sal_True ); - } - // <-- + const rtl::OUString aPageRange = m_pPrintUIOptions->getStringValue( "PageRange", OUString() ); + const bool bFirstPage = m_pPrintUIOptions->getBoolValue( "IsFirstPage", sal_False ); + const bool bLastPage = m_pPrintUIOptions->getBoolValue( "IsLastPage", sal_False ); + bool bIsSkipEmptyPages = !m_pPrintUIOptions->IsPrintEmptyPages( bIsPDFExport ); - pVwSh->SetPDFExportOption( sal_False ); + DBG_ASSERT(( pView->IsA(aSwViewTypeId) && m_pRenderData->IsViewOptionAdjust()) + || (!pView->IsA(aSwViewTypeId) && !m_pRenderData->IsViewOptionAdjust()), + "SwView / SwViewOptionAdjust_Impl availability mismatch" ); - // last page to be rendered? (not necessarily the last page of the document) - // -> do clean-up of data - if (bLastPage) - { - // #i96167# haggai: delete pViewOptionsAdjust here because it makes use - // of the shell, which might get destroyed in lcl_DisposeView! - if (m_pRenderData && m_pRenderData->IsViewOptionAdjust()) - m_pRenderData->ViewOptionAdjustStop(); + // since printing now also use the API for PDF export this option + // should be set for printing as well ... + pVwSh->SetPDFExportOption( sal_True ); - if (m_pRenderData && m_pRenderData->HasPostItData()) - m_pRenderData->DeletePostItData(); - if (m_pHiddenViewFrame) + // --> FME 2004-06-08 #i12836# enhanced pdf export + // + // First, we have to export hyperlinks, notes, and outline to pdf. + // During this process, additional information required for tagging + // the pdf file are collected, which are evaulated during painting. + // + SwWrtShell* pWrtShell = pView->IsA(aSwViewTypeId) ? + ((SwView*)pView)->GetWrtShellPtr() : + 0; + + if (bIsPDFExport && bFirstPage && pWrtShell) + { + SwEnhancedPDFExportHelper aHelper( *pWrtShell, *pOut, aPageRange, bIsSkipEmptyPages, sal_False ); + } + // <-- + + const SwPrtOptions &rSwPrtOptions = *m_pRenderData->GetSwPrtOptions(); + if (bPrintProspect) + pVwSh->PrintProspect( pOut, rSwPrtOptions, nRenderer ); + else // normal printing and PDF export + pVwSh->PrintOrPDFExport( pOut, rSwPrtOptions, nRenderer, bIsPDFExport ); + + // --> FME 2004-10-08 #i35176# + // + // After printing the last page, we take care for the links coming + // from the EditEngine. The links are generated during the painting + // process, but the destinations are still missing. + // + if (bIsPDFExport && bLastPage && pWrtShell) { - lcl_DisposeView( m_pHiddenViewFrame, pDocShell ); - m_pHiddenViewFrame = 0; + SwEnhancedPDFExportHelper aHelper( *pWrtShell, *pOut, aPageRange, bIsSkipEmptyPages, sal_True ); } + // <-- - delete m_pRenderData; m_pRenderData = NULL; - delete m_pPrintUIOptions; m_pPrintUIOptions = NULL; + pVwSh->SetPDFExportOption( sal_False ); + + // last page to be rendered? (not necessarily the last page of the document) + // -> do clean-up of data + if (bLastPage) + { + // #i96167# haggai: delete pViewOptionsAdjust here because it makes use + // of the shell, which might get destroyed in lcl_DisposeView! + if (m_pRenderData && m_pRenderData->IsViewOptionAdjust()) + m_pRenderData->ViewOptionAdjustStop(); + + if (m_pRenderData && m_pRenderData->HasPostItData()) + m_pRenderData->DeletePostItData(); + if (m_pHiddenViewFrame) + { + lcl_DisposeView( m_pHiddenViewFrame, pDocShell ); + m_pHiddenViewFrame = 0; + } + + delete m_pRenderData; m_pRenderData = NULL; + delete m_pPrintUIOptions; m_pPrintUIOptions = NULL; + } } } } -- cgit From c746ad70065a31b1ef8147dc198dbe96b8ea60c7 Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Fri, 4 Sep 2009 07:52:16 +0000 Subject: #i101242# don't create SwRenderData for printing from the HTML source view; will crash on second execute of print direct --- sw/source/ui/uno/unotxdoc.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'sw') diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index 65bc181133e2..d6a9aa4326a8 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -2592,9 +2592,9 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount( bool bIsSwSrcView = false; SfxViewShell *pView = GetRenderView( bIsSwSrcView, rxOptions, bIsPDFExport ); - if (! m_pRenderData) + if (!bIsSwSrcView && !m_pRenderData) m_pRenderData = new SwRenderData; - if (! m_pPrintUIOptions) + if (!m_pPrintUIOptions) { const BOOL bWebDoc = (0 != PTR_CAST(SwWebDocShell, pDocShell)); m_pPrintUIOptions = new SwPrintUIOptions( bWebDoc, bIsSwSrcView ); @@ -2855,7 +2855,7 @@ void SAL_CALL SwXTextDocument::render( DBG_ASSERT( m_pRenderData, "data should have been created already in getRendererCount..." ); DBG_ASSERT( m_pPrintUIOptions, "data should have been created already in getRendererCount..." ); - if (!m_pRenderData) + if (!bIsSwSrcView && !m_pRenderData) m_pRenderData = new SwRenderData; if (!m_pPrintUIOptions) { -- cgit From aacdff37a8696ddcbe0094e7b3fcd650eb311eb5 Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Fri, 4 Sep 2009 09:03:29 +0000 Subject: #i101242# printing of HTML source won't cross the border frame anymore --- sw/source/ui/uiview/srcview.cxx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'sw') diff --git a/sw/source/ui/uiview/srcview.cxx b/sw/source/ui/uiview/srcview.cxx index d1e0ab8e3bec..a36c4b553128 100644 --- a/sw/source/ui/uiview/srcview.cxx +++ b/sw/source/ui/uiview/srcview.cxx @@ -806,7 +806,8 @@ sal_Int32 SwSrcView::PrintSource( // Header drucken... if (!bCalcNumPagesOnly && nPage == nCurPage) lcl_PrintHeader( *pOutDev, nPages, nCurPage, aTitle ); - Point aPos( LMARGPRN, TMARGPRN ); + const Point aStartPos( LMARGPRN, TMARGPRN ); + Point aPos( aStartPos ); for ( USHORT nPara = 0; nPara < nParas; ++nPara ) { String aLine( pTextEngine->GetText( nPara ) ); @@ -816,12 +817,12 @@ sal_Int32 SwSrcView::PrintSource( { String aTmpLine( aLine, nLine * nCharspLine, nCharspLine ); aPos.Y() += nLineHeight; - if ( aPos.Y() > ( aPaperSz.Height() + TMARGPRN ) ) + if ( aPos.Y() > ( aPaperSz.Height() + TMARGPRN - nLineHeight/2 ) ) { ++nCurPage; if (!bCalcNumPagesOnly && nPage == nCurPage) lcl_PrintHeader( *pOutDev, nPages, nCurPage, aTitle ); - aPos = Point( LMARGPRN, TMARGPRN + nLineHeight ); + aPos = aStartPos; } if (!bCalcNumPagesOnly && nPage == nCurPage) pOutDev->DrawText( aPos, aTmpLine ); -- cgit From 3450d32cff473715e2a7d5a44e5cefde6a4a1872 Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Fri, 4 Sep 2009 10:12:00 +0000 Subject: #i101242# assertion in ViewOptionAdjustStart fixed --- sw/source/core/view/viewpg.cxx | 2 +- sw/source/core/view/vprint.cxx | 5 +++-- sw/source/ui/uno/unotxdoc.cxx | 43 +++++++++++++++++++++--------------------- 3 files changed, 25 insertions(+), 25 deletions(-) (limited to 'sw') diff --git a/sw/source/core/view/viewpg.cxx b/sw/source/core/view/viewpg.cxx index a9ab62df38fc..f15284839682 100644 --- a/sw/source/core/view/viewpg.cxx +++ b/sw/source/core/view/viewpg.cxx @@ -465,7 +465,7 @@ void ViewShell::PrintProspect( { const sal_Int32 nMaxRenderer = rPrintData.GetRenderData().GetPagePairsForProspectPrinting().size() - 1; #if OSL_DEBUG_LEVEL > 1 - DBG_ASSERT( 0 <= nRenderer && nRenderer < nMaxRenderer, "nRenderer out of bounds"); + DBG_ASSERT( 0 <= nRenderer && nRenderer <= nMaxRenderer, "nRenderer out of bounds"); #endif Printer *pPrinter = dynamic_cast< Printer * >(pOutDev); if (!pPrinter || nMaxRenderer < 0 || nRenderer < 0 || nRenderer > nMaxRenderer) diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index d811c12d02c5..8cb7f7874a79 100644 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -294,7 +294,8 @@ void SwRenderData::DeletePostItData() void SwRenderData::ViewOptionAdjustStart( SwWrtShell& rSh ) { - DBG_ASSERT( !m_pViewOptionAdjust, "m_pViewOptionAdjust already exists" ); + if (m_pViewOptionAdjust) + delete m_pViewOptionAdjust; m_pViewOptionAdjust = new SwViewOptionAdjust_Impl( rSh ); } @@ -1088,7 +1089,7 @@ sal_Bool ViewShell::PrintOrPDFExport( const sal_Int32 nMaxRenderer = rPrintData.GetRenderData().GetPagesToPrint().size() - 1; #if OSL_DEBUG_LEVEL > 1 - DBG_ASSERT( 0 <= nRenderer && nRenderer < nMaxRenderer, "nRenderer out of bounds"); + DBG_ASSERT( 0 <= nRenderer && nRenderer <= nMaxRenderer, "nRenderer out of bounds"); #endif if (!pOutDev || nMaxRenderer < 0 || nRenderer < 0 || nRenderer > nMaxRenderer) return sal_False; diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index d6a9aa4326a8..f9fff177a788 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -2617,33 +2617,32 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount( else { SwDocShell *pRenderDocShell = pDoc->GetDocShell(); - // #i38289 - if(pDoc->get(IDocumentSettingAccess::BROWSE_MODE)) - { - pRenderDocShell->ToggleBrowserMode(false,NULL); - } - SwWrtShell *pWrtShell = pRenderDocShell->GetWrtShell(); - - if( !pWrtShell ) + if (bFormat) { - //create a hidden view to be able to export as PDF also in print preview - m_pHiddenViewFrame = SfxViewFrame::CreateViewFrame( *pRenderDocShell, 2, TRUE ); - SwView* pSwView = (SwView*) m_pHiddenViewFrame->GetViewShell(); - pWrtShell = pSwView->GetWrtShellPtr(); - } + // #i38289 + if(pDoc->get(IDocumentSettingAccess::BROWSE_MODE)) + { + pRenderDocShell->ToggleBrowserMode(false,NULL); + } - m_pRenderData->SetSwPrtOptions( new SwPrtOptions( C2U( bIsPDFExport ? "PDF export" : "Printing" ) ) ); - m_pRenderData->MakeSwPrtOptions( m_pRenderData->GetSwPrtOptionsRef(), pRenderDocShell, - m_pPrintUIOptions, m_pRenderData, bIsSkipEmptyPages, bIsPDFExport ); + if (!pWrtShell) + { + //create a hidden view to be able to export as PDF also in print preview + m_pHiddenViewFrame = SfxViewFrame::CreateViewFrame( *pRenderDocShell, 2, TRUE ); + SwView* pSwView = (SwView*) m_pHiddenViewFrame->GetViewShell(); + pWrtShell = pSwView->GetWrtShellPtr(); + } - //SwViewOptionAdjust_Impl aAdjust(*pWrtShell); - const TypeId aSwViewTypeId = TYPE(SwView); - if (pView->IsA(aSwViewTypeId)) - m_pRenderData->ViewOptionAdjustStart( *((SwView*)pView)->GetWrtShellPtr() ); + m_pRenderData->SetSwPrtOptions( new SwPrtOptions( C2U( bIsPDFExport ? "PDF export" : "Printing" ) ) ); + m_pRenderData->MakeSwPrtOptions( m_pRenderData->GetSwPrtOptionsRef(), pRenderDocShell, + m_pPrintUIOptions, m_pRenderData, bIsSkipEmptyPages, bIsPDFExport ); + + //SwViewOptionAdjust_Impl aAdjust(*pWrtShell); + const TypeId aSwViewTypeId = TYPE(SwView); + if (pView->IsA(aSwViewTypeId)) + m_pRenderData->ViewOptionAdjustStart( *((SwView*)pView)->GetWrtShellPtr() ); - if( bFormat ) - { // since printing now also use the API for PDF export this option // should be set for printing as well ... pWrtShell->SetPDFExportOption( sal_True ); -- cgit From 4f2690960ace7b79ef45b07f3fb81a208d97636a Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Fri, 4 Sep 2009 14:41:56 +0000 Subject: #i101242# clean-up --- sw/inc/printdata.hxx | 46 ++--- sw/inc/swprtopt.hxx | 3 +- sw/inc/viewsh.hxx | 10 +- sw/source/core/doc/doc.cxx | 13 +- sw/source/core/view/viewpg.cxx | 374 +---------------------------------------- sw/source/core/view/vnew.cxx | 7 - sw/source/core/view/vprint.cxx | 141 ++++------------ sw/source/ui/inc/pview.hxx | 2 - sw/source/ui/uiview/pview.cxx | 16 +- sw/source/ui/uiview/view.cxx | 44 +---- sw/source/ui/uno/unotxdoc.cxx | 2 +- 11 files changed, 72 insertions(+), 586 deletions(-) (limited to 'sw') diff --git a/sw/inc/printdata.hxx b/sw/inc/printdata.hxx index 345546deabec..17b9e3cefc9a 100644 --- a/sw/inc/printdata.hxx +++ b/sw/inc/printdata.hxx @@ -211,11 +211,11 @@ public: bPaperFromSetup = bPrintReverse = bPrintProspect = - bPrintProspectRTL = + bPrintProspectRTL = bPrintSingleJobs = bModified = bPrintBlackFont = - bPrintHiddenText = + bPrintHiddenText = bPrintTextPlaceholder = sal_False; nPrintPostIts = 0; @@ -226,24 +226,24 @@ public: sal_Bool operator==(const SwPrintData& rData)const { return - bPrintGraphic == rData.bPrintGraphic && - bPrintTable == rData.bPrintTable && - bPrintDraw == rData.bPrintDraw && - bPrintControl == rData.bPrintControl && - bPrintPageBackground== rData.bPrintPageBackground&& - bPrintBlackFont == rData.bPrintBlackFont && - bPrintLeftPages == rData.bPrintLeftPages && - bPrintRightPages == rData.bPrintRightPages && - bPrintReverse == rData.bPrintReverse && - bPrintProspect == rData.bPrintProspect && - bPrintProspectRTL == rData.bPrintProspectRTL && - bPrintSingleJobs == rData.bPrintSingleJobs && - bPaperFromSetup == rData.bPaperFromSetup && - bPrintEmptyPages == rData.bPrintEmptyPages && + bPrintGraphic == rData.bPrintGraphic && + bPrintTable == rData.bPrintTable && + bPrintDraw == rData.bPrintDraw && + bPrintControl == rData.bPrintControl && + bPrintPageBackground== rData.bPrintPageBackground && + bPrintBlackFont == rData.bPrintBlackFont && + bPrintLeftPages == rData.bPrintLeftPages && + bPrintRightPages == rData.bPrintRightPages && + bPrintReverse == rData.bPrintReverse && + bPrintProspect == rData.bPrintProspect && + bPrintProspectRTL == rData.bPrintProspectRTL && + bPrintSingleJobs == rData.bPrintSingleJobs && + bPaperFromSetup == rData.bPaperFromSetup && + bPrintEmptyPages == rData.bPrintEmptyPages && bUpdateFieldsInPrinting == rData.bUpdateFieldsInPrinting && - nPrintPostIts == rData.nPrintPostIts && - sFaxName == rData.sFaxName && - bPrintHiddenText == rData.bPrintHiddenText && + nPrintPostIts == rData.nPrintPostIts && + sFaxName == rData.sFaxName && + bPrintHiddenText == rData.bPrintHiddenText && bPrintTextPlaceholder == rData.bPrintTextPlaceholder; } @@ -266,12 +266,12 @@ public: sal_Bool IsPrintProspect() const { return bPrintProspect; } sal_Bool IsPrintProspectRTL() const { return bPrintProspectRTL; } sal_Bool IsPrintPageBackground() const { return bPrintPageBackground; } - sal_Bool IsPrintBlackFont() const { return bPrintBlackFont;} - sal_Bool IsPrintSingleJobs() const { return bPrintSingleJobs;} + sal_Bool IsPrintBlackFont() const { return bPrintBlackFont; } + sal_Bool IsPrintSingleJobs() const { return bPrintSingleJobs; } sal_Int16 GetPrintPostIts() const { return nPrintPostIts; } - const rtl::OUString GetFaxName() const{return sFaxName;} + const rtl::OUString GetFaxName() const{return sFaxName; } sal_Bool IsPrintHiddenText() const {return bPrintHiddenText;} - sal_Bool IsPrintTextPlaceholder() const {return bPrintTextPlaceholder;} + sal_Bool IsPrintTextPlaceholder() const {return bPrintTextPlaceholder; } void SetPrintGraphic ( sal_Bool b ) { doSetModified(); bPrintGraphic = b;} void SetPrintTable ( sal_Bool b ) { doSetModified(); bPrintTable = b;} diff --git a/sw/inc/swprtopt.hxx b/sw/inc/swprtopt.hxx index 76930675eb6c..dbf2898c481e 100644 --- a/sw/inc/swprtopt.hxx +++ b/sw/inc/swprtopt.hxx @@ -95,8 +95,7 @@ public: } // get print options - void MakeOptions( PrintDialog* pDlg, - BOOL* pPrtProspect, BOOL* pPrtProspect_RTL, BOOL bWeb, SfxPrinter* pPrt, SwPrintData* pData ); + void MakeOptions( BOOL bWeb ); }; diff --git a/sw/inc/viewsh.hxx b/sw/inc/viewsh.hxx index 36da231f1832..03d1c9d64184 100644 --- a/sw/inc/viewsh.hxx +++ b/sw/inc/viewsh.hxx @@ -372,8 +372,7 @@ public: // printing of one page. // bIsPDFExport == true is: do PDF Export (no printing!) sal_Bool PrintOrPDFExport( OutputDevice *pOutDev, const SwPrtOptions &rPrintData, - sal_Int32 nRenderer, /* offset in vector of pages to print */ - bool bIsPDFExport = sal_False ); + sal_Int32 nRenderer /* offset in vector of pages to print */ ); // printing of one brochure page void PrintProspect( OutputDevice *pOutDev, const SwPrintData &rPrintData, @@ -384,7 +383,7 @@ public: OutputDevice* pOleOut, const Rectangle& rRect ); // creates temporary doc with selected text for PDF export - SwDoc * CreatePrtDoc( /*Printer* pPrt,*/ SfxObjectShellRef& ); + SwDoc * CreatePrtDoc( SfxObjectShellRef& ); SwDoc * FillPrtDoc( SwDoc* pPrtDoc, const SfxPrinter* pPrt ); //Wird intern fuer die Shell gerufen die Druckt. Formatiert die Seiten. @@ -487,11 +486,6 @@ public: */ void AdjustOptionsForPagePreview( const SwPrtOptions &_rPrintOptions ); - // print page/print preview - void PrintPreViewPage( SwPrtOptions& rOptions, sal_uInt16 nRowCol, - SfxProgress& rProgress, - const SwPagePreViewPrtData* = 0 ); - sal_Bool IsViewLocked() const { return bViewLocked; } void LockView( sal_Bool b ) { bViewLocked = b; } diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index 2c125bcb98e4..4aabbc29b693 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -1011,7 +1011,6 @@ struct _PostItFld : public _SetGetExpFld USHORT GetPageNo( const StringRangeEnumerator &rRangeEnum, const std::set< sal_Int32 > &rPossiblePages, - BOOL bRgt, BOOL bLft, USHORT& rVirtPgNo, USHORT& rLineNo ); SwPostItField* GetPostIt() const @@ -1024,7 +1023,6 @@ struct _PostItFld : public _SetGetExpFld USHORT _PostItFld::GetPageNo( const StringRangeEnumerator &rRangeEnum, const std::set< sal_Int32 > &rPossiblePages, - BOOL bRgt, BOOL bLft, /* TLPDF both should not be needed since rMulti should only include the correct pages as stored in GetValidPagesSet */ /* out */ USHORT& rVirtPgNo, /* out */ USHORT& rLineNo ) { //Problem: Wenn ein PostItFld in einem Node steht, der von mehr als @@ -1044,8 +1042,7 @@ USHORT _PostItFld::GetPageNo( continue; USHORT nPgNo = pFrm->GetPhyPageNum(); BOOL bRight = pFrm->OnRightPage(); - if( rRangeEnum.hasValue( nPgNo, &rPossiblePages ) && - ( (bRight && bRgt) || (!bRight && bLft) ) ) + if( rRangeEnum.hasValue( nPgNo, &rPossiblePages )) { rLineNo = (USHORT)(pFrm->GetLineCount( nPos ) + pFrm->GetAllLines() - pFrm->GetThisLines()); @@ -1255,7 +1252,7 @@ void SwDoc::CalculatePagesForPrinting( OUString aPageRange; if (bIsPDFExport) { -// TLPDF ?? m_pPrintUIOptions->getValue( C2U("Selection") ); + // ?? rOptions.getValue( C2U("Selection") ); aPageRange = rOptions.getStringValue( "PageRange", OUString() ); } else @@ -1325,8 +1322,7 @@ void SwDoc::UpdatePagesForPrintingWithPostItData( _PostItFld& rPostIt = (_PostItFld&)*(*rData.m_pPostItFields)[ i ]; nLastPageNum = nPhyPageNum; nPhyPageNum = rPostIt.GetPageNo( - aRangeEnum, rData.GetValidPagesSet(), - true /*TLPDF bRgt*/, true /*TLPDF bLft*/, nVirtPg, nLineNo ); + aRangeEnum, rData.GetValidPagesSet(), nVirtPg, nLineNo ); if (nPhyPageNum) { // need to insert a page break? @@ -1515,9 +1511,6 @@ void SwDoc::CalculatePagePairsForProspectPrinting( // of the prospect! bool bPrintLeftPages = rOptions.IsPrintLeftPages(); bool bPrintRightPages = rOptions.IsPrintRightPages(); - // TLPDF, TODO: remove bPrintReverse, should be handled by PLs framework now -//TLPDF bool bPrintReverse = rOptions.getBoolValue( C2U( "PrintReverseOrder" ), false ); - // TLPDF: this one seems not to be used in prospect printing: bool bPrintEmptyPages = rOptions.getBoolValue( C2U( "PrintEmptyPages" ), false ); bool bPrintProspectRTL = rOptions.getIntValue( "PrintProspectRTL", 0 ) ? true : false; // get pages for prospect printing according to the 'PageRange' diff --git a/sw/source/core/view/viewpg.cxx b/sw/source/core/view/viewpg.cxx index f15284839682..379f8b42d0c5 100644 --- a/sw/source/core/view/viewpg.cxx +++ b/sw/source/core/view/viewpg.cxx @@ -93,366 +93,6 @@ void ViewShell::AdjustOptionsForPagePreview( const SwPrtOptions &_rPrintOptions return; } -// output print preview on printer -// OD 05.05.2003 #i14016# - consider empty pages on calculation of scaling -// and on calculation of paint offset. -void ViewShell::PrintPreViewPage( SwPrtOptions& rOptions, - USHORT nRowCol, SfxProgress& rProgress, - const SwPagePreViewPrtData* pPrtData ) -{ - if( !rOptions.aMulti.GetSelectCount() ) - return; - - // wenn kein Drucker vorhanden ist, wird nicht gedruckt - SfxPrinter* pPrt = getIDocumentDeviceAccess()->getPrinter(false); - if( !pPrt || !pPrt->GetName().Len() ) - return; - -// schoen waers gewesen !!! const MultiSelection& rMulti = rOptions.aMulti; - MultiSelection aMulti( rOptions.aMulti ); - Range aPages( aMulti.FirstSelected(), aMulti.LastSelected() ); - if ( aPages.Max() > USHRT_MAX ) - aPages.Max() = USHRT_MAX; - - ASSERT( aPages.Min() > 0, - "Seite 0 Drucken?" ); - ASSERT( aPages.Min() <= aPages.Max(), - "MinSeite groesser MaxSeite." ); - - // eine neue Shell fuer den Printer erzeugen - ViewShell aShell( *this, 0 ); - if ( &GetRefDev() == pPrt ) - aShell.mpTmpRef = new SfxPrinter( *pPrt ); - - SET_CURR_SHELL( &aShell ); - - aShell.PrepareForPrint( rOptions ); - - // gibt es versteckte Absatzfelder, unnoetig wenn die Absaetze bereits - // ausgeblendet sind. - int bHiddenFlds = FALSE; - SwFieldType* pFldType = 0; - if ( GetViewOptions()->IsShowHiddenPara() ) - { - pFldType = getIDocumentFieldsAccess()->GetSysFldType( RES_HIDDENPARAFLD ); - bHiddenFlds = 0 != pFldType->GetDepends(); - if( bHiddenFlds ) - { - SwMsgPoolItem aHnt( RES_HIDDENPARA_PRINT ); - pFldType->Modify( &aHnt, 0); - } - } - - // Seiten fuers Drucken formatieren - aShell.CalcPagesForPrint( (USHORT)aPages.Max(), &rProgress ); - - USHORT nCopyCnt = rOptions.bCollate ? rOptions.nCopyCount : 1; - BOOL bStartJob = FALSE; - - const bool bPrintEmptyPages = rOptions.IsPrintEmptyPages(); - - for ( USHORT nCnt = 0; nCnt < nCopyCnt; nCnt++ ) - { - if( rOptions.IsPrintSingleJobs() && rOptions.GetJobName().Len() && - ( bStartJob || rOptions.bJobStartet ) ) - { -#ifdef TL_NOT_NOW /*TLPDF*/ - pPrt->EndJob(); -#endif - rOptions.bJobStartet = TRUE; - - // Reschedule statt Yield, da Yield keine Events abarbeitet - // und es sonst eine Endlosschleife gibt. - while( pPrt->IsPrinting() ) - rProgress.Reschedule(); - - rOptions.MakeNextJobName(); -#ifdef TL_NOT_NOW /*TLPDF*/ - // bStartJob = pPrt->StartJob( rOptions.GetJobName() ); -#endif - } - - const SwPageFrm *pStPage = (SwPageFrm*)GetLayout()->Lower(); - const SwFrm *pEndPage = pStPage; - USHORT i; - - for( i = 1; pStPage && i < (USHORT)aPages.Min(); ++i ) - pStPage = (SwPageFrm*)pStPage->GetNext(); - - if( !pStPage ) // dann wars das - { - if( bHiddenFlds ) - { - SwMsgPoolItem aHnt( RES_HIDDENPARA_PRINT ); - pFldType->Modify( &aHnt, 0); - CalcPagesForPrint( (USHORT)aPages.Max() ); - } - return; - } - - // unsere SttPage haben wir, dann die EndPage suchen - USHORT nFirstPageNo = i; - USHORT nLastPageNo = i; - USHORT nPageNo = 1; - - pEndPage = pStPage; - - if( pStPage->GetNext() && (i != (USHORT)aPages.Max()) ) - { - pEndPage = pEndPage->GetNext(); - for( ++i,++nLastPageNo; - pEndPage->GetNext() && i < (USHORT)aPages.Max(); ++i ) - { - pEndPage = pEndPage->GetNext(); - ++nLastPageNo; - } - } - - if( rOptions.bPrintReverse ) - { - const SwFrm *pTmp = pStPage; - pStPage = (SwPageFrm*)pEndPage; - pEndPage = pTmp; - nPageNo = nLastPageNo; - } - else - nPageNo = nFirstPageNo; - - // ein Array fuer die Seiten anlegen, die auf eine Drucker-Seite - // gedruckt werden sollen. - BYTE nRow = BYTE(nRowCol >> 8), nCol = BYTE(nRowCol & 0xff); - USHORT nPages = nRow * nCol; - SwPageFrm** aPageArr = new SwPageFrm* [ nPages ]; - memset( aPageArr, 0, sizeof( SwPageFrm* ) * nPages ); - USHORT nCntPage = 0; - - SwTwips nCalcW = 0, nCalcH = 0, nMaxRowSz = 0, nMaxColSz = 0; - - MapMode aOld( pPrt->GetMapMode() ); - MapMode aMapMode( MAP_TWIP ); - Size aPrtSize( pPrt->PixelToLogic( pPrt->GetPaperSizePixel(), aMapMode )); - if( pPrtData ) - { - aPrtSize.Width() -= pPrtData->GetLeftSpace() + - pPrtData->GetRightSpace() + - ( pPrtData->GetHorzSpace() * (nCol - 1)); - aPrtSize.Height() -= pPrtData->GetTopSpace() + - pPrtData->GetBottomSpace() + - ( pPrtData->GetVertSpace() * (nRow - 1)); - } - - aMulti.Select( Range( nLastPageNo+1, USHRT_MAX ), FALSE ); - USHORT nSelCount = USHORT((aMulti.GetSelectCount()+nPages-1) / nPages); - nSelCount = nSelCount * nCopyCnt; - USHORT nPrintCount = 1; - - const XubString aTmp( SW_RES( STR_STATSTR_PRINT ) ); - rProgress.SetText( aTmp ); - //HACK, damit die Anzeige nicht durcheinander kommt: - rProgress.SetState( 1, nSelCount ); - rProgress.SetText( aTmp ); - bStartJob = TRUE; - - while( pStPage ) - { - // Mag der Anwender noch ? - rProgress.Reschedule(); - - if ( !pPrt->IsJobActive() ) - break; - - // --> FME 2005-12-12 #b6354161# Feature - Print empty pages - // --> OD 2007-10-22 #i79738# - correct condition: - // always consider, if page is selected for print. - if( aMulti.IsSelected( nPageNo ) && - ( bPrintEmptyPages || !pStPage->IsEmptyPage() ) ) - // <-- - { - if( rOptions.bPrintReverse ) - aPageArr[ nPages - ++nCntPage ] = (SwPageFrm*)pStPage; - else - aPageArr[ nCntPage++ ] = (SwPageFrm*)pStPage; - - // OD 05.05.2003 #i14016# - consider empty pages on calculation - // of page size, used for calculation of scaling. - Size aPageSize; - if ( pStPage->IsEmptyPage() ) - { - if ( pStPage->GetPhyPageNum() % 2 == 0 ) - aPageSize = pStPage->GetPrev()->Frm().SSize(); - else - aPageSize = pStPage->GetNext()->Frm().SSize(); - } - else - { - aPageSize = pStPage->Frm().SSize(); - } - nCalcW += aPageSize.Width(); - if( nCalcH < aPageSize.Height() ) - nCalcH = aPageSize.Height(); - - if( 0 == (nCntPage % nCol ) || // neue Zeile - nCntPage == nPages || pStPage == pEndPage ) - { - // sollte die Seite nicht gefuellt sein, so erweiter - // anhand der letzen Seite. Dadurch hat auch die - // letze Seite die richtigen Spalten/Reihen. - // BUG: 17695 - if( pStPage == pEndPage && nCntPage != nPages ) - { - // dann Werte mit der letzen Seite auffuellen - if( nCntPage < nCol ) - nCalcW += aPageSize.Width() * (nCol - nCntPage); - - BYTE nRows = (BYTE) ( nCntPage / nCol + 1 ); - if( nRows < nRow ) - nCalcH += ( nRow - nRows ) * nCalcH; - } - - if( nMaxColSz < nCalcW ) - nMaxColSz = nCalcW; - nCalcW = 0; - nMaxRowSz += nCalcH; - } - - if( nCntPage == nPages || pStPage == pEndPage ) - { - // den MapMode einstellen - aMapMode.SetOrigin( Point() ); - { - Fraction aScX( aPrtSize.Width(), nMaxColSz ); - Fraction aScY( aPrtSize.Height(), nMaxRowSz ); - - { - if( aScX < aScY ) - aScY = aScX; - - // fuer Drawing, damit diese ihre Objecte vernuenftig Painten - // koennen, auf "glatte" Prozentwerte setzen - aScY *= Fraction( 1000, 1 ); - long nTmp = (long)aScY; - if( 1 < nTmp ) - --nTmp; - else - nTmp = 1; - aScY = Fraction( nTmp, 1000 ); - aScX = aScY; - } - - aMapMode.SetScaleY( aScY ); - aMapMode.SetScaleX( aScX ); - } - - Point aPrtOff( pPrt->PixelToLogic( - pPrt->GetPageOffsetPixel(), aMapMode ) ); - long nPageHeight = (nMaxRowSz / nRow); - - // dann kann das drucken losgehen - rProgress.SetState( nPrintCount++, nSelCount ); - -#ifdef TL_NOT_NOW /*TLPDF*/ - pPrt->StartPage(); -#endif - Point aCalcPt; - SwPageFrm** ppTmpPg = aPageArr; - - // ist das Array nicht vollsteandig gefuellt ? - if( rOptions.bPrintReverse && nCntPage != nPages ) - { - // beim Rueckwaertsdruck alle Seiten nach vorne - // verschieben! - memmove( ppTmpPg, ppTmpPg + (nPages - nCntPage), - nCntPage * sizeof( SwPageFrm*) ); - aPageArr[ nCntPage ] = 0; // Endekennung - } - - long nHOffs = 0, nVOffs = 0, nXStt = 0; - if( pPrtData ) - { - const Fraction& rScaleX = aMapMode.GetScaleX(); - const Fraction& rScaleY = aMapMode.GetScaleY(); - Fraction aF( pPrtData->GetTopSpace(), 1 ); - aCalcPt.Y() = aF /= rScaleY; - aF = Fraction( pPrtData->GetLeftSpace(), 1 ); - nXStt = aF /= rScaleX; - aF = Fraction( pPrtData->GetVertSpace(), 1 ); - nVOffs = aF /= rScaleY; - aF = Fraction( pPrtData->GetHorzSpace(), 1 ); - nHOffs = aF /= rScaleX; - } - - for( BYTE nR = 0; *ppTmpPg && nR < nRow; ++nR ) - { - aCalcPt.X() = nXStt; - for( BYTE nC = 0; *ppTmpPg && nC < nCol; ++nC ) - { - aShell.Imp()->SetFirstVisPageInvalid(); - aShell.aVisArea = (*ppTmpPg)->Frm(); - - Point aPos( aCalcPt ); - aPos -= aShell.aVisArea.Pos(); - aPos -= aPrtOff; - aMapMode.SetOrigin( aPos ); - pPrt->SetMapMode( aMapMode ); - (*ppTmpPg)->GetUpper()->Paint( (*ppTmpPg)->Frm() ); - // OD 05.05.2003 #i14016# - consider empty pages - // on calculation of the paint offset for the next page. - aCalcPt.X() += nHOffs; - if ( (*ppTmpPg)->IsEmptyPage() ) - { - if ( (*ppTmpPg)->GetPhyPageNum() % 2 == 0 ) - aCalcPt.X() += (*ppTmpPg)->GetPrev()->Frm().SSize().Width(); - else - aCalcPt.X() += (*ppTmpPg)->GetNext()->Frm().SSize().Width(); - } - else - { - aCalcPt.X() += (*ppTmpPg)->Frm().Width(); - } - ++ppTmpPg; - } - aCalcPt.Y() += nVOffs + nPageHeight; - } -#ifdef TL_NOT_NOW /*TLPDF*/ - pPrt->EndPage(); -#endif - SwPaintQueue::Repaint(); - - memset( aPageArr, 0, sizeof( SwPageFrm* ) * nPages ); - nCntPage = 0; - nMaxRowSz = nMaxColSz = nCalcH = nCalcW = 0; - } - } - - if( pStPage == pEndPage ) - pStPage = 0; - else if( rOptions.bPrintReverse ) - { - --nPageNo; - pStPage = (SwPageFrm*)pStPage->GetPrev(); - } - else - { - ++nPageNo; - pStPage = (SwPageFrm*)pStPage->GetNext(); - } - } - pPrt->SetMapMode( aOld ); - - if( bHiddenFlds ) - { - SwMsgPoolItem aHnt( RES_HIDDENPARA_PRINT ); - pFldType->Modify( &aHnt, 0); - CalcPagesForPrint( (USHORT)aPages.Max() ); - } - delete[] aPageArr; - - if( bStartJob ) - rOptions.bJobStartet = TRUE; - } - pFntCache->Flush(); -} - // print brochure // OD 05.05.2003 #i14016# - consider empty pages on calculation of the scaling @@ -491,7 +131,7 @@ void ViewShell::PrintProspect( aShell.PrepareForPrint( rPrintData ); -#ifdef TL_NOT_NOW // TLPDF: applying view options and formatting the dcoument should now only be done in getRendererCount! +#if 0 // applying view options and formatting the dcoument should now only be done in getRendererCount! // gibt es versteckte Absatzfelder, unnoetig wenn die Absaetze bereits // ausgeblendet sind. int bHiddenFlds = FALSE; @@ -509,10 +149,10 @@ void ViewShell::PrintProspect( // Seiten fuers Drucken formatieren aShell.CalcPagesForPrint( nPageMax, 0 ); -#endif // TL_NOT_NOW // TLPDF +#endif MapMode aMapMode( MAP_TWIP ); - Size aPrtSize( pPrinter->PixelToLogic( pPrinter->GetPaperSizePixel(), aMapMode ) ); /* TLPDF */ + Size aPrtSize( pPrinter->PixelToLogic( pPrinter->GetPaperSizePixel(), aMapMode ) ); SwTwips nMaxRowSz, nMaxColSz; @@ -605,7 +245,7 @@ void ViewShell::PrintProspect( aMapMode.SetScaleX( aScY ); } - Size aTmpPrtSize( pPrinter->PixelToLogic( pPrinter->GetPaperSizePixel(), aMapMode ) ); /* TLPDF */ + Size aTmpPrtSize( pPrinter->PixelToLogic( pPrinter->GetPaperSizePixel(), aMapMode ) ); // calculate start point for equal border on all sides Point aSttPt( (aTmpPrtSize.Width() - nMaxColSz) / 2, @@ -619,7 +259,7 @@ void ViewShell::PrintProspect( Point aPos( aSttPt ); aPos -= aShell.aVisArea.Pos(); -// TLPDF aPos -= aPrtOff; +// aPos -= aPrtOff; aMapMode.SetOrigin( aPos ); pPrinter->SetMapMode( aMapMode ); pStPage->GetUpper()->Paint( pStPage->Frm() ); @@ -631,14 +271,14 @@ void ViewShell::PrintProspect( SwPaintQueue::Repaint(); -#ifdef TL_NOT_NOW // TLPDF: applying view options and formatting the dcoument should now only be done in getRendererCount! +#if 0 // applying view options and formatting the dcoument should now only be done in getRendererCount! if( bHiddenFlds ) { SwMsgPoolItem aHnt( RES_HIDDENPARA_PRINT ); pFldType->Modify( &aHnt, 0); CalcPagesForPrint( nPageMax ); } -#endif // TL_NOT_NOW // TLPDF +#endif pFntCache->Flush(); // restore settings of OutputDevice (should be done always now since the diff --git a/sw/source/core/view/vnew.cxx b/sw/source/core/view/vnew.cxx index f5a132284021..99c16d68f2bd 100644 --- a/sw/source/core/view/vnew.cxx +++ b/sw/source/core/view/vnew.cxx @@ -108,8 +108,6 @@ void ViewShell::Init( const SwViewOption *pNewOpt ) // --> FME 2007-11-06 #i82967# OutputDevice* pPDFOut = 0; -// TLPDF if ( pOut && pOut->GetPDFWriter() ) -// TLPDF pPDFOut = pOut; if ( pOut && pOut->GetPDFWriter() ) pPDFOut = pOut; // <-- @@ -118,11 +116,6 @@ void ViewShell::Init( const SwViewOption *pNewOpt ) // Only setup the printer if we need one: const IDocumentSettingAccess* pIDSA = getIDocumentSettingAccess(); const bool bBrowseMode = pIDSA->get(IDocumentSettingAccess::BROWSE_MODE); -// TLPDF const bool bCreatePrinter = !bBrowseMode && -// TLPDF !pIDSA->get(IDocumentSettingAccess::USE_VIRTUAL_DEVICE); -// TLPDF SfxPrinter* pPrinter = getIDocumentDeviceAccess()->getPrinter( bCreatePrinter ); -// TLPDF if( pPrinter ) -// TLPDF InitPrt( pPrinter, pPDFOut ); if( pPDFOut ) InitPrt( pPDFOut ); // <-- diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index 8cb7f7874a79..05af84c67f06 100644 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -122,19 +122,6 @@ public: SwQueuedPaint *SwPaintQueue::pQueue = 0; -//Klasse zum Speichern einiger Druckereinstellungen -class SwPrtOptSave -{ - Printer *pPrt; - Size aSize; - Paper ePaper; - Orientation eOrientation; - USHORT nPaperBin; -public: - SwPrtOptSave( Printer *pPrinter ); - ~SwPrtOptSave(); -}; - // saves some settings from the draw view class SwDrawViewSave { @@ -324,7 +311,7 @@ void SwRenderData::MakeSwPrtOptions( // get default print options const TypeId aSwWebDocShellTypeId = TYPE(SwWebDocShell); BOOL bWeb = pDocShell->IsA( aSwWebDocShellTypeId ); - rOptions.MakeOptions( NULL, NULL, NULL, bWeb, NULL, NULL ); + rOptions.MakeOptions( bWeb ); // get print options to use from provided properties rOptions.bPrintGraphic = pOpt->IsPrintGraphics(); @@ -335,13 +322,13 @@ void SwRenderData::MakeSwPrtOptions( rOptions.bPrintRightPages = pOpt->IsPrintRightPages(); rOptions.bPrintPageBackground = pOpt->getBoolValue( "PrintPageBackground", rOptions.bPrintPageBackground ); rOptions.bPrintEmptyPages = !bIsSkipEmptyPages; - // bUpdateFieldsInPrinting <-- not set here // TLPDF: TODO: remove this from SwPrintData?? Get rid of SwPrtOptions?? + // bUpdateFieldsInPrinting <-- not set here; mail merge only rOptions.bPaperFromSetup = pOpt->getBoolValue( "PrintPaperFromSetup", rOptions.bPaperFromSetup ); rOptions.bPrintReverse = pOpt->getBoolValue( "PrintReversed", rOptions.bPrintReverse ); rOptions.bPrintProspect = pOpt->getBoolValue( "PrintProspect", rOptions.bPrintProspect ); rOptions.bPrintProspectRTL = pOpt->getIntValue( "PrintProspectRTL", rOptions.bPrintProspectRTL ) ? true : false; - // bPrintSingleJobs <-- not set here // TLPDF: TODO: remove this from SwPrintData?? Get rid of SwPrtOptions?? - // bModified <-- not set here // TLPDF: TODO: remove this from SwPrintData?? Get rid of SwPrtOptions?? + // bPrintSingleJobs <-- not set here; mail merge and or configuration + // bModified <-- not set here; mail merge only rOptions.bPrintBlackFont = pOpt->getBoolValue( "PrintBlackFonts", rOptions.bPrintBlackFont ); rOptions.bPrintHiddenText = pOpt->getBoolValue( "PrintHiddenText", rOptions.bPrintHiddenText ); rOptions.bPrintTextPlaceholder = pOpt->getBoolValue( "PrintTextPlaceholder", rOptions.bPrintTextPlaceholder ); @@ -352,12 +339,9 @@ void SwRenderData::MakeSwPrtOptions( rOptions.SetPrintUIOptions( pOpt ); rOptions.SetRenderData( pData ); - // rOptions.aMulti is not used anymore in the XRenderable API but it is still - // used in ViewShell::PrintPreViewPage. Thus we set it to a dummy value here. - MultiSelection aPages( Range( 1, 1 ) ); -// aPages.SetTotalRange( Range( 0, RANGE_MAX ) ); -// aPages.Select( aRange ); - rOptions.aMulti = aPages; + // rOptions.aMulti is not used anymore in the XRenderable API + // Thus we set it to a dummy value here. + rOptions.aMulti = MultiSelection( Range( 1, 1 ) ); //! Note: Since for PDF export of (multi-)selection a temporary //! document is created that contains only the selects parts, @@ -681,13 +665,8 @@ void SetSwVisArea( ViewShell *pSh, const SwRect &rRect, BOOL /*bPDFExport*/ ) // move the start point of the output operation to a position // such that in the output device all pages will be painted // at the same position -// TLPDF if (!bPDFExport) -// TLPDF aPt += pSh->aPrtOffst; aPt.X() = -aPt.X(); aPt.Y() = -aPt.Y(); -// TLPDF OutputDevice *pOut = bPDFExport ? -// TLPDF pSh->GetOut() : -// TLPDF pSh->getIDocumentDeviceAccess()->getPrinter( false ); OutputDevice *pOut = pSh->GetOut(); MapMode aMapMode( pOut->GetMapMode() ); @@ -695,38 +674,31 @@ void SetSwVisArea( ViewShell *pSh, const SwRect &rRect, BOOL /*bPDFExport*/ ) pOut->SetMapMode( aMapMode ); } -/****************************************************************************** - * Methode : void ViewShell::InitPrt( Printer *pNew, OutputDevice *pPDFOut ) - * Beschreibung: - * Erstellt : OK 07.11.94 10:22 - * Aenderung : - ******************************************************************************/ +/******************************************************************************/ -void ViewShell::InitPrt( /*Printer *pPrt,*/ OutputDevice *pOutDev ) /* TLPDF */ +void ViewShell::InitPrt( OutputDevice *pOutDev ) { //Fuer den Printer merken wir uns einen negativen Offset, der //genau dem Offset de OutputSize entspricht. Das ist notwendig, //weil unser Ursprung der linken ober Ecke der physikalischen //Seite ist, die Ausgaben (SV) aber den Outputoffset als Urstprung //betrachten. - OutputDevice *pTmpDev = pOutDev; // TLPDF pPDFOut ? pPDFOut : (OutputDevice *) pPrt; - if ( pTmpDev ) + if ( pOutDev ) { -// TLPDF aPrtOffst = pPrt ? pPrt->GetPageOffset() : Point(); aPrtOffst = Point(); - aPrtOffst += pTmpDev->GetMapMode().GetOrigin(); - MapMode aMapMode( pTmpDev->GetMapMode() ); + aPrtOffst += pOutDev->GetMapMode().GetOrigin(); + MapMode aMapMode( pOutDev->GetMapMode() ); aMapMode.SetMapUnit( MAP_TWIP ); - pTmpDev->SetMapMode( aMapMode ); - pTmpDev->SetLineColor(); - pTmpDev->SetFillColor(); + pOutDev->SetMapMode( aMapMode ); + pOutDev->SetLineColor(); + pOutDev->SetFillColor(); } else aPrtOffst.X() = aPrtOffst.Y() = 0; if ( !pWin ) - pOut = pTmpDev; //Oder was sonst? + pOut = pOutDev; //Oder was sonst? } /****************************************************************************** @@ -894,7 +866,7 @@ void ViewShell::CalcPagesForPrint( USHORT nMax, SfxProgress* pProgress ) /******************************************************************************/ -SwDoc * ViewShell::CreatePrtDoc( /*Printer* pPrt,*/ SfxObjectShellRef &rDocShellRef) // TLPDF +SwDoc * ViewShell::CreatePrtDoc( SfxObjectShellRef &rDocShellRef) { ASSERT( this->IsA( TYPE(SwFEShell) ),"ViewShell::Prt for FEShell only"); SwFEShell* pFESh = (SwFEShell*)this; @@ -904,11 +876,6 @@ SwDoc * ViewShell::CreatePrtDoc( /*Printer* pPrt,*/ SfxObjectShellRef &rDocShell pPrtDoc->SetRefForDocShell( (SfxObjectShellRef*)&(long&)rDocShellRef ); pPrtDoc->LockExpFlds(); -/* TLPDF - // Der Drucker wird uebernommen - if (pPrt) - pPrtDoc->setPrinter( pPrt, true, true ); -*/ const SfxPoolItem* pCpyItem; const SfxItemPool& rPool = GetAttrPool(); for( USHORT nWh = POOLATTR_BEGIN; nWh < POOLATTR_END; ++nWh ) @@ -1080,12 +1047,11 @@ SwDoc * ViewShell::FillPrtDoc( SwDoc *pPrtDoc, const SfxPrinter* pPrt) sal_Bool ViewShell::PrintOrPDFExport( OutputDevice *pOutDev, const SwPrtOptions &rPrintData, - sal_Int32 nRenderer, // the index in the vector of pages to be printed - bool /* TLPDF bIsPDFExport*/ ) + sal_Int32 nRenderer /* the index in the vector of pages to be printed */ ) { -//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -//Immer die Druckroutinen in viewpg.cxx (PrintPreViewPage und PrintProspect) mitpflegen!! -//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +//Immer die Druckroutinen in viewpg.cxx (PrintProspect) mitpflegen!! +//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! const sal_Int32 nMaxRenderer = rPrintData.GetRenderData().GetPagesToPrint().size() - 1; #if OSL_DEBUG_LEVEL > 1 @@ -1098,9 +1064,6 @@ sal_Bool ViewShell::PrintOrPDFExport( // output device is now provided by a call from outside the Writer) pOutDev->Push(); - // Einstellungen am Drucker merken -// SwPrtOptSave aPrtSave( pOutDev ); /* TLPDF wo dann heutzutage ??? */ - // eine neue Shell fuer den Printer erzeugen ViewShell *pShell; SwDoc *pOutDevDoc; @@ -1123,7 +1086,7 @@ sal_Bool ViewShell::PrintOrPDFExport( // to be created that often here in the 'then' part. if ( bSelection ) { - pOutDevDoc = CreatePrtDoc( /*TLPDF pOutDev,*/ aDocShellRef ); + pOutDevDoc = CreatePrtDoc( aDocShellRef ); // eine ViewShell darauf pShell = new ViewShell( *pOutDevDoc, 0, pOpt, pOutDev ); @@ -1138,8 +1101,8 @@ sal_Bool ViewShell::PrintOrPDFExport( SdrView *pDrawView = pShell->GetDrawView(); if (pDrawView) { - pDrawView->SetBufferedOutputAllowed( false ); // TLPDF - pDrawView->SetBufferedOverlayAllowed( false ); // TLPDF + pDrawView->SetBufferedOutputAllowed( false ); + pDrawView->SetBufferedOverlayAllowed( false ); } { //Zusaetzlicher Scope, damit die CurrShell vor dem zerstoeren der @@ -1156,7 +1119,7 @@ sal_Bool ViewShell::PrintOrPDFExport( pShell->PrepareForPrint( rPrintData ); - const sal_Int32 nPage = rPrintData.GetRenderData().GetPagesToPrint()[ nRenderer ]; /* TLPDF */ + const sal_Int32 nPage = rPrintData.GetRenderData().GetPagesToPrint()[ nRenderer ]; #if OSL_DEBUG_LEVEL > 1 DBG_ASSERT( nPage == 0 || rPrintData.GetRenderData().GetValidPagesSet().count( nPage ) == 1, "nPage not valid" ); #endif @@ -1177,7 +1140,7 @@ sal_Bool ViewShell::PrintOrPDFExport( } DBG_ASSERT( pStPage, "failed to get start page" ); -#ifdef TL_NOT_NOW // TLPDF: applying view options and formatting the dcoument should now only be done in getRendererCount! +#if 0 // applying view options and formatting the dcoument should now only be done in getRendererCount! // benoetigte Seiten fuers Drucken formatieren pShell->CalcPagesForPrint( (USHORT)nPage, 0 ); @@ -1190,11 +1153,11 @@ sal_Bool ViewShell::PrintOrPDFExport( if ( !bIsPDFExport && rPrintData.bUpdateFieldsInPrinting ) pShell->UpdateFlds(TRUE); // <-- -#endif // TL_NOT_NOW // TLPDF +#endif ViewShell *pViewSh2 = nPage == 0 ? /* post-it page? */ rPrintData.GetRenderData().m_pPostItShell : pShell; - ::SetSwVisArea( pViewSh2, pStPage->Frm() ); // TLPDF + ::SetSwVisArea( pViewSh2, pStPage->Frm() ); // wenn wir einen Umschlag drucken wird ein Offset beachtet if( pStPage->GetFmt()->GetPoolFmtId() == RES_POOLPAGE_JAKET ) @@ -1210,7 +1173,7 @@ sal_Bool ViewShell::PrintOrPDFExport( pViewSh2 = nPage == 0 ? /* post-it page? */ rPrintData.GetRenderData().m_pPostItShell : pShell; - ::SetSwVisArea( pViewSh2, pStPage->Frm() ); // TLPDF + ::SetSwVisArea( pViewSh2, pStPage->Frm() ); pStPage->GetUpper()->Paint( pStPage->Frm() ); @@ -1316,52 +1279,6 @@ BOOL ViewShell::IsAnyFieldInDoc() const -/****************************************************************************** - * Klasse : SwPrtOptSave - * Erstellt : AMA 12.07.95 - * Aenderung : AMA 12.07.95 - * Holt sich im Ctor folgende Einstellungen des Druckers, die im Dtor dann - * wieder im Drucker gesetzt werden (falls sie sich ueberhaupt geaendert haben) - * - PaperBin - Orientation - PaperSize - - ******************************************************************************/ - - - -SwPrtOptSave::SwPrtOptSave( Printer *pPrinter ) - : pPrt( pPrinter ) -{ - if ( pPrt ) - { - ePaper = pPrt->GetPaper(); - if ( PAPER_USER == ePaper ) - aSize = pPrt->GetPaperSize(); - eOrientation = pPrt->GetOrientation(); - nPaperBin = pPrt->GetPaperBin(); - - } -} - - - -SwPrtOptSave::~SwPrtOptSave() -{ - if ( pPrt ) - { - if ( PAPER_USER == ePaper ) - { - if( pPrt->GetPaperSize() != aSize ) - pPrt->SetPaperSizeUser( aSize ); - } - else if ( pPrt->GetPaper() != ePaper ) - pPrt->SetPaper( ePaper ); - if ( pPrt->GetOrientation() != eOrientation) - pPrt->SetOrientation( eOrientation ); - if ( pPrt->GetPaperBin() != nPaperBin ) - pPrt->SetPaperBin( nPaperBin ); - } -} - - /****************************************************************************** * SwDrawViewSave * diff --git a/sw/source/ui/inc/pview.hxx b/sw/source/ui/inc/pview.hxx index bcb96a26cb3d..9fe9e61e2d6f 100644 --- a/sw/source/ui/inc/pview.hxx +++ b/sw/source/ui/inc/pview.hxx @@ -222,8 +222,6 @@ class SW_DLLPUBLIC SwPagePreView: public SfxViewShell SW_DLLPRIVATE int ChgPage( int eMvMode, int bUpdateScrollbar = TRUE ); - SW_DLLPRIVATE virtual USHORT Print( SfxProgress &rProgress, BOOL bIsAPI, - PrintDialog *pPrintDialog = 0 ); SW_DLLPRIVATE virtual SfxPrinter* GetPrinter( BOOL bCreate = FALSE ); SW_DLLPRIVATE virtual USHORT SetPrinter( SfxPrinter *pNewPrinter, USHORT nDiffFlags = SFX_PRINTER_ALL, bool bIsAPI=false ); SW_DLLPRIVATE virtual SfxTabPage* CreatePrintOptionsPage( Window *pParent, diff --git a/sw/source/ui/uiview/pview.cxx b/sw/source/ui/uiview/pview.cxx index 81958e19be19..ac10369d241c 100644 --- a/sw/source/ui/uiview/pview.cxx +++ b/sw/source/ui/uiview/pview.cxx @@ -1779,7 +1779,7 @@ void SwPagePreView::Init(const SwViewOption * pPrefs) // OD 09.01.2003 #i6467# - adjust view shell option to the same as for print SwPrtOptions aPrintOptions( GetViewFrame()->GetObjectShell()->GetTitle(0) ); - aPrintOptions.MakeOptions( 0, 0, 0, false, 0, 0 ); + aPrintOptions.MakeOptions( false ); GetViewShell()->AdjustOptionsForPagePreview( aPrintOptions ); IDocumentSettingAccess* pIDSA = pESh->getIDocumentSettingAccess(); @@ -2408,20 +2408,6 @@ void SwPagePreView::ScrollDocSzChg() // alles zum Thema Drucken -USHORT SwPagePreView::Print( SfxProgress &rProgress, BOOL bIsAPI, PrintDialog *pDlg ) -{ - (void) rProgress; (void) bIsAPI; (void) pDlg; - // TLPDF no longer needed in new print UI - // TLPDF TODO: clean-up - - return 0; // OK -} - -/*-------------------------------------------------------------------- - Beschreibung: - --------------------------------------------------------------------*/ - - SfxPrinter* SwPagePreView::GetPrinter( BOOL bCreate ) { return aViewWin.GetViewShell()->getIDocumentDeviceAccess()->getPrinter( bCreate ); diff --git a/sw/source/ui/uiview/view.cxx b/sw/source/ui/uiview/view.cxx index 1dedc5c67487..594387f062f1 100644 --- a/sw/source/ui/uiview/view.cxx +++ b/sw/source/ui/uiview/view.cxx @@ -1989,51 +1989,17 @@ void SwView::AddTransferable(SwTransferable& rTransferable) /* --------------------------------------------------*/ -void SwPrtOptions::MakeOptions( PrintDialog* pDlg, - BOOL* pPrtProspect, BOOL* pPrtProspect_RTL, BOOL bWeb, - SfxPrinter* pPrt, SwPrintData* pData ) +void SwPrtOptions::MakeOptions( BOOL bWeb ) { - SwAddPrinterItem* pAddPrinterAttr; - if( pPrt && SFX_ITEM_SET == pPrt->GetOptions().GetItemState( - FN_PARAM_ADDPRINTER, FALSE, (const SfxPoolItem**)&pAddPrinterAttr )) - { - pData = pAddPrinterAttr; - } - else if(!pData) - { - pData = SW_MOD()->GetPrtOptions(bWeb); - } - *this = *pData; - if( pPrtProspect ) - *pPrtProspect = pData->bPrintProspect; - if( pPrtProspect_RTL ) - *pPrtProspect_RTL = pData->bPrintProspectRTL; - aMulti.SetTotalRange( Range( 0, RANGE_MAX ) ); - aMulti.SelectAll( FALSE ); + *this = *SW_MOD()->GetPrtOptions(bWeb); + nCopyCount = 1; bCollate = FALSE; bPrintSelection = FALSE; bJobStartet = FALSE; - if ( pDlg ) - { - nCopyCount = pDlg->GetCopyCount(); - bCollate = pDlg->IsCollateChecked(); - if ( pDlg->GetCheckedRange() == PRINTDIALOG_SELECTION ) - { - aMulti.SelectAll(); - bPrintSelection = TRUE; - } - else if ( PRINTDIALOG_ALL == pDlg->GetCheckedRange() ) - aMulti.SelectAll(); - else - { - aMulti = MultiSelection( pDlg->GetRangeText() ); - aMulti.SetTotalRange( Range( 0, RANGE_MAX ) ); - } - } - else - aMulti.SelectAll(); + aMulti.SetTotalRange( Range( 0, RANGE_MAX ) ); + aMulti.SelectAll(); aMulti.Select( 0, FALSE ); } diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index f9fff177a788..ad63882100ec 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -2946,7 +2946,7 @@ void SAL_CALL SwXTextDocument::render( if (bPrintProspect) pVwSh->PrintProspect( pOut, rSwPrtOptions, nRenderer ); else // normal printing and PDF export - pVwSh->PrintOrPDFExport( pOut, rSwPrtOptions, nRenderer, bIsPDFExport ); + pVwSh->PrintOrPDFExport( pOut, rSwPrtOptions, nRenderer ); // --> FME 2004-10-08 #i35176# // -- cgit From 99db98914d9a700541cd138ab5a705119d2a9480 Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Fri, 4 Sep 2009 14:50:39 +0000 Subject: #i101242# start grammar checking only for docs with visible views --- sw/source/core/doc/docnew.cxx | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) (limited to 'sw') diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx index 67c64e27b9d0..d7a12d52aacd 100644 --- a/sw/source/core/doc/docnew.cxx +++ b/sw/source/core/doc/docnew.cxx @@ -46,6 +46,7 @@ #include #include #include +#include #include #include @@ -168,15 +169,30 @@ SV_IMPL_PTRARR( SwGrfFmtColls, SwGrfFmtCollPtr) void StartGrammarChecking( SwDoc &rDoc ) { - uno::Reference< linguistic2::XProofreadingIterator > xGCIterator( rDoc.GetGCIterator() ); - if ( xGCIterator.is() ) + // check for a visible view + bool bVisible = false; + const SwDocShell *pDocShell = rDoc.GetDocShell(); + SfxViewFrame *pFrame = SfxViewFrame::GetFirst( pDocShell, 0, sal_False ); + while (pFrame && !bVisible) { - uno::Reference< lang::XComponent > xDoc( rDoc.GetDocShell()->GetBaseModel(), uno::UNO_QUERY ); - uno::Reference< text::XFlatParagraphIteratorProvider > xFPIP( xDoc, uno::UNO_QUERY ); + if (pFrame->IsVisible()) + bVisible = true; + pFrame = SfxViewFrame::GetNext( *pFrame, pDocShell, 0, sal_False ); + } - // start automatic background checking if not active already - if ( xFPIP.is() && !xGCIterator->isProofreading( xDoc ) ) - xGCIterator->startProofreading( xDoc, xFPIP ); + // only documents with visible views need to be checked + if (bVisible) + { + uno::Reference< linguistic2::XProofreadingIterator > xGCIterator( rDoc.GetGCIterator() ); + if ( xGCIterator.is() ) + { + uno::Reference< lang::XComponent > xDoc( rDoc.GetDocShell()->GetBaseModel(), uno::UNO_QUERY ); + uno::Reference< text::XFlatParagraphIteratorProvider > xFPIP( xDoc, uno::UNO_QUERY ); + + // start automatic background checking if not active already + if ( xFPIP.is() && !xGCIterator->isProofreading( xDoc ) ) + xGCIterator->startProofreading( xDoc, xFPIP ); + } } } -- cgit From 3c4cf485fa3f4efb4f9c3548c4b5acb441bd0f50 Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Mon, 7 Sep 2009 08:12:29 +0000 Subject: #i101242# start grammar checking only for docs with visible views --- sw/source/core/doc/docnew.cxx | 1 + 1 file changed, 1 insertion(+) (limited to 'sw') diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx index d7a12d52aacd..ad0a124e6b74 100644 --- a/sw/source/core/doc/docnew.cxx +++ b/sw/source/core/doc/docnew.cxx @@ -181,6 +181,7 @@ void StartGrammarChecking( SwDoc &rDoc ) } // only documents with visible views need to be checked + //(E.g. don't check temporary documents created for printing, see printing of notes and selections) if (bVisible) { uno::Reference< linguistic2::XProofreadingIterator > xGCIterator( rDoc.GetGCIterator() ); -- cgit From 01c741ee90f41de09410413d81f779d88bb050a8 Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Mon, 7 Sep 2009 09:14:38 +0000 Subject: #i101242# start grammar checking only for docs with visible views --- sw/source/core/doc/docnew.cxx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'sw') diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx index ad0a124e6b74..aab5ca48ed7d 100644 --- a/sw/source/core/doc/docnew.cxx +++ b/sw/source/core/doc/docnew.cxx @@ -180,8 +180,10 @@ void StartGrammarChecking( SwDoc &rDoc ) pFrame = SfxViewFrame::GetNext( *pFrame, pDocShell, 0, sal_False ); } - // only documents with visible views need to be checked - //(E.g. don't check temporary documents created for printing, see printing of notes and selections) + //!! only documents with visible views need to be checked + //!! (E.g. don't check temporary documents created for printing, see printing of notes and selections. + //!! Those get created on the fly and get hard deleted a bit later as well, and no one should have + //!! a uno reference to them) if (bVisible) { uno::Reference< linguistic2::XProofreadingIterator > xGCIterator( rDoc.GetGCIterator() ); -- cgit From 37de7b4f82272ea2fe43d3d39cc7a59995ba0f87 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Mon, 7 Sep 2009 10:38:39 +0000 Subject: remove unused variable --- sw/source/core/doc/doc.cxx | 1 - 1 file changed, 1 deletion(-) (limited to 'sw') diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index 4aabbc29b693..2d0f9c6115ed 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -1041,7 +1041,6 @@ USHORT _PostItFld::GetPageNo( (pFrm->HasFollow() && pFrm->GetFollow()->GetOfst() <= nPos) ) continue; USHORT nPgNo = pFrm->GetPhyPageNum(); - BOOL bRight = pFrm->OnRightPage(); if( rRangeEnum.hasValue( nPgNo, &rPossiblePages )) { rLineNo = (USHORT)(pFrm->GetLineCount( nPos ) + -- cgit From fbfff407749fbec15066d74fb34aae9c274431af Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Mon, 7 Sep 2009 11:19:30 +0000 Subject: #104693# fixed page size and map mode unit conversion problem for brochure printing --- sw/source/ui/uno/unotxdoc.cxx | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'sw') diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index ad63882100ec..201d7900053f 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -2755,7 +2755,8 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SwXTextDocument::getRenderer( uno::Sequence< beans::PropertyValue > aRenderer; if (m_pRenderData) { - Size aPgSize; + awt::Size aPageSize; + Size aTmpSize; if (bIsSwSrcView || m_pPrintUIOptions->getBoolValue( "PrintProspect", sal_False )) { // for printing of HTML source code and prospect printing we should use @@ -2771,15 +2772,20 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SwXTextDocument::getRenderer( // for the correct PageSisze right now... Printer *pPrinter = dynamic_cast< Printer * >(lcl_GetOutputDevice( *m_pPrintUIOptions )); if (pPrinter) - aPgSize = pPrinter->GetPaperSize(); + { + aTmpSize = pPrinter->GetPaperSize(); + aTmpSize = pPrinter->LogicToLogic( aTmpSize, + pPrinter->GetMapMode(), MapMode( MAP_100TH_MM )); + aPageSize = awt::Size( aTmpSize.Width(), aTmpSize.Height() ); + } } else { bool bIsSkipEmptyPages = !m_pPrintUIOptions->IsPrintEmptyPages( bIsPDFExport ); - aPgSize = pDoc->GetPageSize( sal_uInt16(nRenderer + 1), bIsSkipEmptyPages ); + aTmpSize = pDoc->GetPageSize( sal_uInt16(nRenderer + 1), bIsSkipEmptyPages ); + aPageSize = awt::Size ( TWIP_TO_MM100( aTmpSize.Width() ), + TWIP_TO_MM100( aTmpSize.Height() )); } - awt::Size aPageSize( TWIP_TO_MM100( aPgSize.Width() ), - TWIP_TO_MM100( aPgSize.Height() )); aRenderer.realloc(2); aRenderer[0].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "PageSize" ) ); -- cgit From 22377e630acfe8339dd760db2b223d6700705888 Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Mon, 7 Sep 2009 12:11:46 +0000 Subject: #104693# assertion fixed --- sw/source/ui/uno/unotxdoc.cxx | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'sw') diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index 201d7900053f..8e2d8336738d 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -2542,18 +2542,22 @@ SwDoc * SwXTextDocument::GetRenderDoc( pDoc = pDocShell->GetDoc(); else { - // important check since GuessViewShell below should only get called for PDF export. - // Otherwise the View should be obtained from the "View" property passed on in the - // calls to the XRenderable functions. - DBG_ASSERT( bIsPDFExport, "code should have been called for PDF export only..." ); - (void)bIsPDFExport; // avoid warning in non dbg case + DBG_ASSERT( !xModel.is(), "unexpected model found" ); - // used for PDF export of (multi-)selection if (rSelection.hasValue()) // is anything selected ? { + // this part should only be called when a temporary document needs to be created, + // for example for PDF export or printing of (multi-)selection only. + bool bIsSwSrcView = false; if (!rpView) + { + (void) bIsPDFExport; + // aside from maybe PDF export the view should always have been provided! + DBG_ASSERT( bIsPDFExport, "view is missing, guessing one..." ); + rpView = GuessViewShell( bIsSwSrcView ); + } DBG_ASSERT( rpView, "ViewShell missing" ); // the view shell should be SwView for documents PDF export. // for the page preview no selection should be possible @@ -2568,7 +2572,8 @@ SwDoc * SwXTextDocument::GetRenderDoc( rpView = pDoc->GetDocShell()->GetView(); } } - else { + else + { DBG_ERROR( "unexpected ViewShell" ); } } -- cgit From 3ed5b6c9c6530c75a5ae9f6d60f6149451701001 Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Mon, 7 Sep 2009 14:50:54 +0000 Subject: #104693# brochure printing with different page formats --- sw/source/core/view/vprint.cxx | 2 +- sw/source/ui/uno/unotxdoc.cxx | 30 ++++++++++++++++++++++-------- 2 files changed, 23 insertions(+), 9 deletions(-) (limited to 'sw') diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index 05af84c67f06..a59bfc714fa5 100644 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -495,7 +495,7 @@ SwPrintUIOptions::SwPrintUIOptions( bool bWeb, bool bSwSrcView ) : aHelpText.realloc( 2 ); aHelpText[0] = aLocalizedStrings.GetString( 25 ); aHelpText[1] = aLocalizedStrings.GetString( 25 ); - vcl::PrinterOptionsHelper::UIControlOptions aAnnotOpt( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintProspect" ) ), 1, sal_False ); + vcl::PrinterOptionsHelper::UIControlOptions aAnnotOpt( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintProspect" ) ), 0, sal_False ); m_aUIProperties[ nIdx++ ].Value = getChoiceControlOpt( aLocalizedStrings.GetString( 26 ), aHelpText, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintAnnotationMode" ) ), diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index 8e2d8336738d..33c1b97483f7 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -2732,7 +2732,8 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SwXTextDocument::getRenderer( m_pPrintUIOptions = new SwPrintUIOptions( bWebDoc, bIsSwSrcView ); } m_pPrintUIOptions->processProperties( rxOptions ); - const bool bPrintProspect = m_pPrintUIOptions->getBoolValue( "PrintProspect", false ); + const bool bPrintProspect = m_pPrintUIOptions->getBoolValue( "PrintProspect", false ); + const bool bIsSkipEmptyPages = !m_pPrintUIOptions->IsPrintEmptyPages( bIsPDFExport ); SwDoc *pDoc = GetRenderDoc( pView, rSelection, bIsPDFExport ); DBG_ASSERT( pDoc && pView, "doc or view shell missing!" ); @@ -2762,7 +2763,7 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SwXTextDocument::getRenderer( { awt::Size aPageSize; Size aTmpSize; - if (bIsSwSrcView || m_pPrintUIOptions->getBoolValue( "PrintProspect", sal_False )) + if (bIsSwSrcView || bPrintProspect) { // for printing of HTML source code and prospect printing we should use // the printers paper size since @@ -2778,16 +2779,29 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SwXTextDocument::getRenderer( Printer *pPrinter = dynamic_cast< Printer * >(lcl_GetOutputDevice( *m_pPrintUIOptions )); if (pPrinter) { - aTmpSize = pPrinter->GetPaperSize(); - aTmpSize = pPrinter->LogicToLogic( aTmpSize, - pPrinter->GetMapMode(), MapMode( MAP_100TH_MM )); - aPageSize = awt::Size( aTmpSize.Width(), aTmpSize.Height() ); + if (bPrintProspect) + { + aTmpSize = pDoc->GetPageSize( USHORT(nRenderer + 1), bIsSkipEmptyPages ); + // we just state what output size we would need + // the rest is now up to vcl + long nWidth = 2 * aTmpSize.Width(); + long nHeight = aTmpSize.Height(); + aPageSize = awt::Size ( TWIP_TO_MM100( nWidth ), + TWIP_TO_MM100( nHeight )); + } + else + { + // printing HTML source view + aTmpSize = pPrinter->GetPaperSize(); + aTmpSize = pPrinter->LogicToLogic( aTmpSize, + pPrinter->GetMapMode(), MapMode( MAP_100TH_MM )); + aPageSize = awt::Size( aTmpSize.Width(), aTmpSize.Height() ); + } } } else { - bool bIsSkipEmptyPages = !m_pPrintUIOptions->IsPrintEmptyPages( bIsPDFExport ); - aTmpSize = pDoc->GetPageSize( sal_uInt16(nRenderer + 1), bIsSkipEmptyPages ); + aTmpSize = pDoc->GetPageSize( USHORT(nRenderer + 1), bIsSkipEmptyPages ); aPageSize = awt::Size ( TWIP_TO_MM100( aTmpSize.Width() ), TWIP_TO_MM100( aTmpSize.Height() )); } -- cgit From 222ce842dbdbdad1d50cba06fc26968b9363bf0b Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Mon, 7 Sep 2009 14:52:54 +0000 Subject: #104693# brochure printing with different page formats --- sw/source/ui/uno/unotxdoc.cxx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'sw') diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index 33c1b97483f7..b41a496bc6c4 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -2783,11 +2783,9 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SwXTextDocument::getRenderer( { aTmpSize = pDoc->GetPageSize( USHORT(nRenderer + 1), bIsSkipEmptyPages ); // we just state what output size we would need - // the rest is now up to vcl - long nWidth = 2 * aTmpSize.Width(); - long nHeight = aTmpSize.Height(); - aPageSize = awt::Size ( TWIP_TO_MM100( nWidth ), - TWIP_TO_MM100( nHeight )); + // the rest is nowadays up to vcl + aPageSize = awt::Size ( TWIP_TO_MM100( 2 * aTmpSize.Width() ), + TWIP_TO_MM100( aTmpSize.Height() )); } else { -- cgit From fdb61865536ef1dfaf08c8600958432846c50f57 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Tue, 8 Sep 2009 17:17:32 +0000 Subject: merge strings from string review --- sw/source/ui/config/optdlg.src | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'sw') diff --git a/sw/source/ui/config/optdlg.src b/sw/source/ui/config/optdlg.src index 736cbd881212..48a88ceb58c2 100644 --- a/sw/source/ui/config/optdlg.src +++ b/sw/source/ui/config/optdlg.src @@ -956,15 +956,15 @@ StringArray STR_PRINTOPTUI < "Print text in blac~k"; >; < "Specifies whether to always print text in black."; >; < "Pages"; >; - < "~Add blank pages for page breaks"; >; + < "Print ~automatically inserted blank pages"; >; < "If this option is enabled automatically inserted blank pages are printed. This is best if you are printing double-sided. For example, in a book, a \"chapter\" paragraph style has been set to always start with an odd numbered page. If the previous chapter ends on an odd page, %PRODUCTNAME inserts an even numbered blank page. This option controls whether to print that even numbered page or not"; >; < "~Use only paper tray from printer preferences"; >; < "For printers with multiple trays this option specifies whether the paper tray used is specified by the system settings of the printer."; >; < "Print"; >; - < "Document only"; >; + < "None (document only)"; >; < "Notes only"; >; - < " at end of document"; >; - < " at end of page"; >; + < "Place at end of document"; >; + < "Place at end of page"; >; < "Specify where to print notes (if any)."; >; < "~Notes"; >; < "Page sides";>; -- cgit From dac4275c1bb031c2f52b5069493bea2100a12701 Mon Sep 17 00:00:00 2001 From: Armin Le Grand Date: Tue, 15 Sep 2009 16:06:13 +0200 Subject: #i97509# seperated base and buffered classes for 2D and 3D, adapted aqll usages --- sw/source/core/draw/dflyobj.cxx | 12 ++++++------ sw/source/ui/docvw/postit.cxx | 16 ++++++++-------- 2 files changed, 14 insertions(+), 14 deletions(-) (limited to 'sw') diff --git a/sw/source/core/draw/dflyobj.cxx b/sw/source/core/draw/dflyobj.cxx index 15ca46ca2456..e1033aa3d818 100644 --- a/sw/source/core/draw/dflyobj.cxx +++ b/sw/source/core/draw/dflyobj.cxx @@ -196,7 +196,7 @@ namespace drawinglayer { namespace primitive2d { - class SwVirtFlyDrawObjPrimitive : public BasePrimitive2D + class SwVirtFlyDrawObjPrimitive : public BufDecPrimitive2D { private: const SwVirtFlyDrawObj& mrSwVirtFlyDrawObj; @@ -204,13 +204,13 @@ namespace drawinglayer protected: // method which is to be used to implement the local decomposition of a 2D primitive - virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const; + virtual Primitive2DSequence createLocal2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; public: SwVirtFlyDrawObjPrimitive( const SwVirtFlyDrawObj& rSwVirtFlyDrawObj, const basegfx::B2DRange &rOuterRange) - : BasePrimitive2D(), + : BufDecPrimitive2D(), mrSwVirtFlyDrawObj(rSwVirtFlyDrawObj), maOuterRange(rOuterRange) { @@ -239,7 +239,7 @@ namespace drawinglayer { namespace primitive2d { - Primitive2DSequence SwVirtFlyDrawObjPrimitive::createLocalDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const + Primitive2DSequence SwVirtFlyDrawObjPrimitive::createLocal2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const { Primitive2DSequence aRetval; @@ -269,7 +269,7 @@ namespace drawinglayer bool SwVirtFlyDrawObjPrimitive::operator==(const BasePrimitive2D& rPrimitive) const { - if(BasePrimitive2D::operator==(rPrimitive)) + if(BufDecPrimitive2D::operator==(rPrimitive)) { const SwVirtFlyDrawObjPrimitive& rCompare = (SwVirtFlyDrawObjPrimitive&)rPrimitive; @@ -295,7 +295,7 @@ namespace drawinglayer getSwVirtFlyDrawObj().wrap_DoPaintObject(); // call parent - return BasePrimitive2D::get2DDecomposition(rViewInformation); + return BufDecPrimitive2D::get2DDecomposition(rViewInformation); } // provide unique ID diff --git a/sw/source/ui/docvw/postit.cxx b/sw/source/ui/docvw/postit.cxx index a9809e07e496..c2754f18acd0 100644 --- a/sw/source/ui/docvw/postit.cxx +++ b/sw/source/ui/docvw/postit.cxx @@ -1990,7 +1990,7 @@ private: ShadowState maShadowState; protected: - virtual drawinglayer::primitive2d::Primitive2DSequence createLocalDecomposition( + virtual drawinglayer::primitive2d::Primitive2DSequence createLocal2DDecomposition( const drawinglayer::geometry::ViewInformation2D& rViewInformation) const; public: @@ -2009,12 +2009,12 @@ public: const basegfx::B2DPoint& getSecondPosition() const { return maSecondPosition; } ShadowState getShadowState() const { return maShadowState; } - virtual bool operator==( const drawinglayer::primitive2d::BasePrimitive2D& rPrimitive ) const; + virtual bool operator==( const drawinglayer::primitive2d::BufDecPrimitive2D& rPrimitive ) const; DeclPrimitrive2DIDBlock() }; -drawinglayer::primitive2d::Primitive2DSequence SwPostItShadowPrimitive::createLocalDecomposition( +drawinglayer::primitive2d::Primitive2DSequence SwPostItShadowPrimitive::createLocal2DDecomposition( const drawinglayer::geometry::ViewInformation2D& /*rViewInformation*/) const { // get logic sizes in object coordinate system @@ -2095,7 +2095,7 @@ drawinglayer::primitive2d::Primitive2DSequence SwPostItShadowPrimitive::createLo return xRetval; } -bool SwPostItShadowPrimitive::operator==( const drawinglayer::primitive2d::BasePrimitive2D& rPrimitive ) const +bool SwPostItShadowPrimitive::operator==( const drawinglayer::primitive2d::BufDecPrimitive2D& rPrimitive ) const { if(drawinglayer::primitive2d::DiscreteMetricDependentPrimitive2D::operator==(rPrimitive)) { @@ -2177,7 +2177,7 @@ private: bool mbLineSolid : 1; protected: - virtual drawinglayer::primitive2d::Primitive2DSequence createLocalDecomposition( + virtual drawinglayer::primitive2d::Primitive2DSequence createLocal2DDecomposition( const drawinglayer::geometry::ViewInformation2D& rViewInformation) const; public: @@ -2211,12 +2211,12 @@ public: bool getShadow() const { return mbShadow; } bool getLineSolid() const { return mbLineSolid; } - virtual bool operator==( const drawinglayer::primitive2d::BasePrimitive2D& rPrimitive ) const; + virtual bool operator==( const drawinglayer::primitive2d::BufDecPrimitive2D& rPrimitive ) const; DeclPrimitrive2DIDBlock() }; -drawinglayer::primitive2d::Primitive2DSequence SwPostItAnkorPrimitive::createLocalDecomposition( +drawinglayer::primitive2d::Primitive2DSequence SwPostItAnkorPrimitive::createLocal2DDecomposition( const drawinglayer::geometry::ViewInformation2D& /*rViewInformation*/) const { drawinglayer::primitive2d::Primitive2DSequence aRetval; @@ -2331,7 +2331,7 @@ drawinglayer::primitive2d::Primitive2DSequence SwPostItAnkorPrimitive::createLoc return aRetval; } -bool SwPostItAnkorPrimitive::operator==( const drawinglayer::primitive2d::BasePrimitive2D& rPrimitive ) const +bool SwPostItAnkorPrimitive::operator==( const drawinglayer::primitive2d::BufDecPrimitive2D& rPrimitive ) const { if(drawinglayer::primitive2d::DiscreteMetricDependentPrimitive2D::operator==(rPrimitive)) { -- cgit From 795cd663c621fdecd0f313f76afe06ce3342bb12 Mon Sep 17 00:00:00 2001 From: Armin Le Grand Date: Tue, 15 Sep 2009 19:08:28 +0200 Subject: #i97509# changed base classes for primitives which need no buffering --- sw/source/core/draw/dflyobj.cxx | 8 ++++---- sw/source/ui/docvw/postit.cxx | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'sw') diff --git a/sw/source/core/draw/dflyobj.cxx b/sw/source/core/draw/dflyobj.cxx index e1033aa3d818..7d25656de299 100644 --- a/sw/source/core/draw/dflyobj.cxx +++ b/sw/source/core/draw/dflyobj.cxx @@ -196,7 +196,7 @@ namespace drawinglayer { namespace primitive2d { - class SwVirtFlyDrawObjPrimitive : public BufDecPrimitive2D + class SwVirtFlyDrawObjPrimitive : public BufferedDecompositionPrimitive2D { private: const SwVirtFlyDrawObj& mrSwVirtFlyDrawObj; @@ -210,7 +210,7 @@ namespace drawinglayer SwVirtFlyDrawObjPrimitive( const SwVirtFlyDrawObj& rSwVirtFlyDrawObj, const basegfx::B2DRange &rOuterRange) - : BufDecPrimitive2D(), + : BufferedDecompositionPrimitive2D(), mrSwVirtFlyDrawObj(rSwVirtFlyDrawObj), maOuterRange(rOuterRange) { @@ -269,7 +269,7 @@ namespace drawinglayer bool SwVirtFlyDrawObjPrimitive::operator==(const BasePrimitive2D& rPrimitive) const { - if(BufDecPrimitive2D::operator==(rPrimitive)) + if(BufferedDecompositionPrimitive2D::operator==(rPrimitive)) { const SwVirtFlyDrawObjPrimitive& rCompare = (SwVirtFlyDrawObjPrimitive&)rPrimitive; @@ -295,7 +295,7 @@ namespace drawinglayer getSwVirtFlyDrawObj().wrap_DoPaintObject(); // call parent - return BufDecPrimitive2D::get2DDecomposition(rViewInformation); + return BufferedDecompositionPrimitive2D::get2DDecomposition(rViewInformation); } // provide unique ID diff --git a/sw/source/ui/docvw/postit.cxx b/sw/source/ui/docvw/postit.cxx index c2754f18acd0..7d421b49b867 100644 --- a/sw/source/ui/docvw/postit.cxx +++ b/sw/source/ui/docvw/postit.cxx @@ -2009,7 +2009,7 @@ public: const basegfx::B2DPoint& getSecondPosition() const { return maSecondPosition; } ShadowState getShadowState() const { return maShadowState; } - virtual bool operator==( const drawinglayer::primitive2d::BufDecPrimitive2D& rPrimitive ) const; + virtual bool operator==( const drawinglayer::primitive2d::BufferedDecompositionPrimitive2D& rPrimitive ) const; DeclPrimitrive2DIDBlock() }; @@ -2095,7 +2095,7 @@ drawinglayer::primitive2d::Primitive2DSequence SwPostItShadowPrimitive::createLo return xRetval; } -bool SwPostItShadowPrimitive::operator==( const drawinglayer::primitive2d::BufDecPrimitive2D& rPrimitive ) const +bool SwPostItShadowPrimitive::operator==( const drawinglayer::primitive2d::BufferedDecompositionPrimitive2D& rPrimitive ) const { if(drawinglayer::primitive2d::DiscreteMetricDependentPrimitive2D::operator==(rPrimitive)) { @@ -2211,7 +2211,7 @@ public: bool getShadow() const { return mbShadow; } bool getLineSolid() const { return mbLineSolid; } - virtual bool operator==( const drawinglayer::primitive2d::BufDecPrimitive2D& rPrimitive ) const; + virtual bool operator==( const drawinglayer::primitive2d::BufferedDecompositionPrimitive2D& rPrimitive ) const; DeclPrimitrive2DIDBlock() }; @@ -2331,7 +2331,7 @@ drawinglayer::primitive2d::Primitive2DSequence SwPostItAnkorPrimitive::createLoc return aRetval; } -bool SwPostItAnkorPrimitive::operator==( const drawinglayer::primitive2d::BufDecPrimitive2D& rPrimitive ) const +bool SwPostItAnkorPrimitive::operator==( const drawinglayer::primitive2d::BufferedDecompositionPrimitive2D& rPrimitive ) const { if(drawinglayer::primitive2d::DiscreteMetricDependentPrimitive2D::operator==(rPrimitive)) { -- cgit From 290947b519dc9a3ac89406075d7988f4e772c10d Mon Sep 17 00:00:00 2001 From: Armin Le Grand Date: Thu, 17 Sep 2009 17:20:13 +0200 Subject: #i97509# added base class for 3d primitive, re-structured group primitives, added documentation --- sw/source/core/draw/dflyobj.cxx | 4 ++-- sw/source/ui/docvw/postit.cxx | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'sw') diff --git a/sw/source/core/draw/dflyobj.cxx b/sw/source/core/draw/dflyobj.cxx index 7d25656de299..cda428f124eb 100644 --- a/sw/source/core/draw/dflyobj.cxx +++ b/sw/source/core/draw/dflyobj.cxx @@ -204,7 +204,7 @@ namespace drawinglayer protected: // method which is to be used to implement the local decomposition of a 2D primitive - virtual Primitive2DSequence createLocal2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; + virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; public: SwVirtFlyDrawObjPrimitive( @@ -239,7 +239,7 @@ namespace drawinglayer { namespace primitive2d { - Primitive2DSequence SwVirtFlyDrawObjPrimitive::createLocal2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const + Primitive2DSequence SwVirtFlyDrawObjPrimitive::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const { Primitive2DSequence aRetval; diff --git a/sw/source/ui/docvw/postit.cxx b/sw/source/ui/docvw/postit.cxx index 7d421b49b867..c306e73ba695 100644 --- a/sw/source/ui/docvw/postit.cxx +++ b/sw/source/ui/docvw/postit.cxx @@ -1990,7 +1990,7 @@ private: ShadowState maShadowState; protected: - virtual drawinglayer::primitive2d::Primitive2DSequence createLocal2DDecomposition( + virtual drawinglayer::primitive2d::Primitive2DSequence create2DDecomposition( const drawinglayer::geometry::ViewInformation2D& rViewInformation) const; public: @@ -2009,12 +2009,12 @@ public: const basegfx::B2DPoint& getSecondPosition() const { return maSecondPosition; } ShadowState getShadowState() const { return maShadowState; } - virtual bool operator==( const drawinglayer::primitive2d::BufferedDecompositionPrimitive2D& rPrimitive ) const; + virtual bool operator==( const drawinglayer::primitive2d::BasePrimitive2D& rPrimitive ) const; DeclPrimitrive2DIDBlock() }; -drawinglayer::primitive2d::Primitive2DSequence SwPostItShadowPrimitive::createLocal2DDecomposition( +drawinglayer::primitive2d::Primitive2DSequence SwPostItShadowPrimitive::create2DDecomposition( const drawinglayer::geometry::ViewInformation2D& /*rViewInformation*/) const { // get logic sizes in object coordinate system @@ -2095,7 +2095,7 @@ drawinglayer::primitive2d::Primitive2DSequence SwPostItShadowPrimitive::createLo return xRetval; } -bool SwPostItShadowPrimitive::operator==( const drawinglayer::primitive2d::BufferedDecompositionPrimitive2D& rPrimitive ) const +bool SwPostItShadowPrimitive::operator==( const drawinglayer::primitive2d::BasePrimitive2D& rPrimitive ) const { if(drawinglayer::primitive2d::DiscreteMetricDependentPrimitive2D::operator==(rPrimitive)) { @@ -2177,7 +2177,7 @@ private: bool mbLineSolid : 1; protected: - virtual drawinglayer::primitive2d::Primitive2DSequence createLocal2DDecomposition( + virtual drawinglayer::primitive2d::Primitive2DSequence create2DDecomposition( const drawinglayer::geometry::ViewInformation2D& rViewInformation) const; public: @@ -2211,12 +2211,12 @@ public: bool getShadow() const { return mbShadow; } bool getLineSolid() const { return mbLineSolid; } - virtual bool operator==( const drawinglayer::primitive2d::BufferedDecompositionPrimitive2D& rPrimitive ) const; + virtual bool operator==( const drawinglayer::primitive2d::BasePrimitive2D& rPrimitive ) const; DeclPrimitrive2DIDBlock() }; -drawinglayer::primitive2d::Primitive2DSequence SwPostItAnkorPrimitive::createLocal2DDecomposition( +drawinglayer::primitive2d::Primitive2DSequence SwPostItAnkorPrimitive::create2DDecomposition( const drawinglayer::geometry::ViewInformation2D& /*rViewInformation*/) const { drawinglayer::primitive2d::Primitive2DSequence aRetval; @@ -2331,7 +2331,7 @@ drawinglayer::primitive2d::Primitive2DSequence SwPostItAnkorPrimitive::createLoc return aRetval; } -bool SwPostItAnkorPrimitive::operator==( const drawinglayer::primitive2d::BufferedDecompositionPrimitive2D& rPrimitive ) const +bool SwPostItAnkorPrimitive::operator==( const drawinglayer::primitive2d::BasePrimitive2D& rPrimitive ) const { if(drawinglayer::primitive2d::DiscreteMetricDependentPrimitive2D::operator==(rPrimitive)) { -- cgit From b0a85159e5f99baee901adad447a157f65e507b4 Mon Sep 17 00:00:00 2001 From: Armin Le Grand Date: Tue, 22 Sep 2009 18:14:05 +0200 Subject: #i97509# continued matrix tooling and adapting the usages now to all the ooo code --- sw/source/core/draw/dcontact.cxx | 29 +++++------------------------ sw/source/core/unocore/unodraw.cxx | 15 ++++----------- 2 files changed, 9 insertions(+), 35 deletions(-) (limited to 'sw') diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx index aa20281038da..5d9b90a2f9e0 100644 --- a/sw/source/core/draw/dcontact.cxx +++ b/sw/source/core/draw/dcontact.cxx @@ -44,7 +44,6 @@ #include #include #include -// AW, OD 2004-04-30 #i28501# #include #include #include @@ -69,31 +68,17 @@ #include #include #include - -// OD 2004-02-11 #110582#-2 #include - -// OD 18.06.2003 #108784# -#include -// OD 2004-05-24 #i28701# #include #include - -// AW: For VCOfDrawVirtObj and stuff -#ifndef _SDR_CONTACT_VIEWCONTACTOFVIRTOBJ_HXX +#include #include -#endif - -#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_TRANSFORMPRIMITIVE2D_HXX #include -#endif - -#ifndef _SDR_CONTACT_VIEWOBJECTCONTACTOFSDROBJ_HXX #include -#endif - #include +#include + using namespace ::com::sun::star; @@ -2605,9 +2590,7 @@ void SwDrawVirtObj::RecalcBoundRect() basegfx::B2DPolyPolygon SwDrawVirtObj::TakeXorPoly() const { basegfx::B2DPolyPolygon aRetval(rRefObj.TakeXorPoly()); - basegfx::B2DHomMatrix aMatrix; - aMatrix.translate(GetOffset().X(), GetOffset().Y()); - aRetval.transform(aMatrix); + aRetval.transform(basegfx::tools::createTranslateB2DHomMatrix(GetOffset().X(), GetOffset().Y())); return aRetval; } @@ -2615,9 +2598,7 @@ basegfx::B2DPolyPolygon SwDrawVirtObj::TakeXorPoly() const basegfx::B2DPolyPolygon SwDrawVirtObj::TakeContour() const { basegfx::B2DPolyPolygon aRetval(rRefObj.TakeContour()); - basegfx::B2DHomMatrix aMatrix; - aMatrix.translate(GetOffset().X(), GetOffset().Y()); - aRetval.transform(aMatrix); + aRetval.transform(basegfx::tools::createTranslateB2DHomMatrix(GetOffset().X(), GetOffset().Y())); return aRetval; } diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx index 1989c74df6ed..c75e4b691b51 100644 --- a/sw/source/core/unocore/unodraw.cxx +++ b/sw/source/core/unocore/unodraw.cxx @@ -75,19 +75,12 @@ #include #include #include -// OD 2004-05-05 #i28701# +#include #include -// --> OD 2004-11-10 #i35007# #include -// <-- -// --> OD 2005-03-10 #i44334#, #i44681# -// --> OD 2007-01-03 #i73079# - use correct matrix type #include -// <-- -// --> OD 2009-01-16 #i59051 +#include #include -// <-- - #include #include #include @@ -2844,8 +2837,8 @@ void SwXShape::_AdjustPositionProperties( const awt::Point _aPosition ) // apply translation difference to PolyPolygonBezier. if ( aTranslateDiff.X != 0 || aTranslateDiff.Y != 0 ) { - basegfx::B2DHomMatrix aMatrix; - aMatrix.translate( aTranslateDiff.X, aTranslateDiff.Y ); + const basegfx::B2DHomMatrix aMatrix(basegfx::tools::createTranslateB2DHomMatrix( + aTranslateDiff.X, aTranslateDiff.Y)); const sal_Int32 nOuterSequenceCount(aConvertedPath.Coordinates.getLength()); drawing::PointSequence* pInnerSequence = aConvertedPath.Coordinates.getArray(); -- cgit From c9bcf9f449b11e500cf5261dcc75f768463af69f Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Wed, 7 Oct 2009 15:58:05 +0000 Subject: #i105596# Notes are nowadays called Comments --- sw/source/ui/config/optdlg.src | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'sw') diff --git a/sw/source/ui/config/optdlg.src b/sw/source/ui/config/optdlg.src index 48a88ceb58c2..81acd9c97d76 100644 --- a/sw/source/ui/config/optdlg.src +++ b/sw/source/ui/config/optdlg.src @@ -962,11 +962,11 @@ StringArray STR_PRINTOPTUI < "For printers with multiple trays this option specifies whether the paper tray used is specified by the system settings of the printer."; >; < "Print"; >; < "None (document only)"; >; - < "Notes only"; >; + < "Comments only"; >; < "Place at end of document"; >; < "Place at end of page"; >; - < "Specify where to print notes (if any)."; >; - < "~Notes"; >; + < "Specify where to print comments (if any)."; >; + < "~Comments"; >; < "Page sides";>; < "All pages"; >; < "Back sides / left pages"; >; -- cgit From 280c91547547808fae0def1eeb47079c65570a0b Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Wed, 7 Oct 2009 16:44:04 +0000 Subject: #i105265# pass correct number of options --- sw/source/core/view/vprint.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sw') diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index a59bfc714fa5..764e9d72a8bd 100644 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -539,7 +539,7 @@ SwPrintUIOptions::SwPrintUIOptions( bool bWeb, bool bSwSrcView ) : ); // create a bool option for brochure RTL dependent on brochure - uno::Sequence< rtl::OUString > aBRTLChoices( 3 ); + uno::Sequence< rtl::OUString > aBRTLChoices( 2 ); aBRTLChoices[0] = aLocalizedStrings.GetString( 35 ); aBRTLChoices[1] = aLocalizedStrings.GetString( 36 ); vcl::PrinterOptionsHelper::UIControlOptions aBrochureRTLOpt( aBrochurePropertyName, -1, sal_True ); -- cgit From c991f55f85fc9b448d9741726bffbdebc4344605 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Wed, 7 Oct 2009 17:59:15 +0000 Subject: #i105695# do not miss cleanup of m_pPrintUIOptions and m_pRenderData --- sw/source/ui/uno/unotxdoc.cxx | 261 +++++++++++++++++++++--------------------- 1 file changed, 132 insertions(+), 129 deletions(-) (limited to 'sw') diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index b41a496bc6c4..ae216c9aff5f 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -2615,8 +2615,8 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount( sal_Int32 nRet = 0; if (bIsSwSrcView) { - SwSrcView *pSwSrcView = dynamic_cast< SwSrcView * >(pView); - OutputDevice *pOutDev = lcl_GetOutputDevice( *m_pPrintUIOptions ); + SwSrcView *pSwSrcView = dynamic_cast< SwSrcView * >(pView); + OutputDevice *pOutDev = lcl_GetOutputDevice( *m_pPrintUIOptions ); nRet = pSwSrcView->PrintSource( pOutDev, 1 /* dummy */, true /* get page count only */ ); } else @@ -2743,20 +2743,20 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SwXTextDocument::getRenderer( // due to #110067# (document page count changes sometimes during // PDF export/printing) we can not check for the upper bound properly. // Thus instead of throwing the exception we silently return. - if (0 > nRenderer) - throw IllegalArgumentException(); - sal_Int32 nMaxRenderer = 0; - if (!bIsSwSrcView && m_pRenderData) - { - DBG_ASSERT( m_pRenderData, "m_pRenderData missing!!" ); - nMaxRenderer = bPrintProspect? - m_pRenderData->GetPagePairsForProspectPrinting().size() - 1 : - m_pRenderData->GetPagesToPrint().size() - 1; - } - // since SwSrcView::PrintSource is a poor implementation to get the number of pages to print - // we obmit checking of the upper bound in this case. - if (!bIsSwSrcView && m_pRenderData && nRenderer > nMaxRenderer) - return uno::Sequence< beans::PropertyValue >(); + if (0 > nRenderer) + throw IllegalArgumentException(); + sal_Int32 nMaxRenderer = 0; + if (!bIsSwSrcView && m_pRenderData) + { + DBG_ASSERT( m_pRenderData, "m_pRenderData missing!!" ); + nMaxRenderer = bPrintProspect? + m_pRenderData->GetPagePairsForProspectPrinting().size() - 1 : + m_pRenderData->GetPagesToPrint().size() - 1; + } + // since SwSrcView::PrintSource is a poor implementation to get the number of pages to print + // we obmit checking of the upper bound in this case. + if (!bIsSwSrcView && m_pRenderData && nRenderer > nMaxRenderer) + return uno::Sequence< beans::PropertyValue >(); uno::Sequence< beans::PropertyValue > aRenderer; if (m_pRenderData) @@ -2776,20 +2776,20 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SwXTextDocument::getRenderer( // Sometimes 'getRenderer' is only called to get "ExtraPrintUIOptions", in this // case we won't get an OutputDevice here, but then the caller also has no need // for the correct PageSisze right now... - Printer *pPrinter = dynamic_cast< Printer * >(lcl_GetOutputDevice( *m_pPrintUIOptions )); - if (pPrinter) - { - if (bPrintProspect) - { + Printer *pPrinter = dynamic_cast< Printer * >(lcl_GetOutputDevice( *m_pPrintUIOptions )); + if (pPrinter) + { + if (bPrintProspect) + { aTmpSize = pDoc->GetPageSize( USHORT(nRenderer + 1), bIsSkipEmptyPages ); // we just state what output size we would need // the rest is nowadays up to vcl aPageSize = awt::Size ( TWIP_TO_MM100( 2 * aTmpSize.Width() ), TWIP_TO_MM100( aTmpSize.Height() )); - } - else - { - // printing HTML source view + } + else + { + // printing HTML source view aTmpSize = pPrinter->GetPaperSize(); aTmpSize = pPrinter->LogicToLogic( aTmpSize, pPrinter->GetMapMode(), MapMode( MAP_100TH_MM )); @@ -2871,6 +2871,12 @@ void SAL_CALL SwXTextDocument::render( if(!IsValid()) throw RuntimeException(); + // due to #110067# (document page count changes sometimes during + // PDF export/printing) we can not check for the upper bound properly. + // Thus instead of throwing the exception we silently return. + if (0 > nRenderer) + throw IllegalArgumentException(); + const bool bIsPDFExport = !lcl_SeqHasProperty( rxOptions, "IsPrinter" ); bool bIsSwSrcView = false; SfxViewShell *pView = GetRenderView( bIsSwSrcView, rxOptions, bIsPDFExport ); @@ -2886,127 +2892,124 @@ void SAL_CALL SwXTextDocument::render( } m_pPrintUIOptions->processProperties( rxOptions ); const bool bPrintProspect = m_pPrintUIOptions->getBoolValue( "PrintProspect", false ); + const bool bLastPage = m_pPrintUIOptions->getBoolValue( "IsLastPage", sal_False ); SwDoc *pDoc = GetRenderDoc( pView, rSelection, bIsPDFExport ); DBG_ASSERT( pDoc && pView, "doc or view shell missing!" ); - if (!pDoc || !pView) - return; - - // due to #110067# (document page count changes sometimes during - // PDF export/printing) we can not check for the upper bound properly. - // Thus instead of throwing the exception we silently return. - if (0 > nRenderer) - throw IllegalArgumentException(); - sal_Int32 nMaxRenderer = 0; - if (!bIsSwSrcView) - { - DBG_ASSERT( m_pRenderData, "m_pRenderData missing!!" ); - nMaxRenderer = bPrintProspect? - m_pRenderData->GetPagePairsForProspectPrinting().size() - 1 : - m_pRenderData->GetPagesToPrint().size() - 1; - } - // since SwSrcView::PrintSource is a poor implementation to get the number of pages to print - // we obmit checking of the upper bound in this case. - if (!bIsSwSrcView && nRenderer > nMaxRenderer) - return; - - if (bIsSwSrcView) - { - SwSrcView *pSwSrcView = dynamic_cast< SwSrcView * >(pView); - OutputDevice *pOutDev = lcl_GetOutputDevice( *m_pPrintUIOptions ); - pSwSrcView->PrintSource( pOutDev, nRenderer + 1, false ); - } - else + if (pDoc && pView) { - // the view shell should be SwView for documents PDF export - // or SwPagePreView for PDF export of the page preview - //!! (check for SwView first as in GuessViewShell) !! - DBG_ASSERT( pView, "!! view missing !!" ); - const TypeId aSwViewTypeId = TYPE(SwView); - ViewShell* pVwSh = 0; - if (pView) + sal_Int32 nMaxRenderer = 0; + if (!bIsSwSrcView) { - pVwSh = pView->IsA(aSwViewTypeId) ? - ((SwView*)pView)->GetWrtShellPtr() : - ((SwPagePreView*)pView)->GetViewShell(); + DBG_ASSERT( m_pRenderData, "m_pRenderData missing!!" ); + nMaxRenderer = bPrintProspect? + m_pRenderData->GetPagePairsForProspectPrinting().size() - 1 : + m_pRenderData->GetPagesToPrint().size() - 1; } - - // get output device to use - OutputDevice * pOut = lcl_GetOutputDevice( *m_pPrintUIOptions ); - - if(pVwSh && pOut && m_pRenderData->HasSwPrtOptions()) + // since SwSrcView::PrintSource is a poor implementation to get the number of pages to print + // we obmit checking of the upper bound in this case. + if (bIsSwSrcView || nRenderer <= nMaxRenderer) { - const rtl::OUString aPageRange = m_pPrintUIOptions->getStringValue( "PageRange", OUString() ); - const bool bFirstPage = m_pPrintUIOptions->getBoolValue( "IsFirstPage", sal_False ); - const bool bLastPage = m_pPrintUIOptions->getBoolValue( "IsLastPage", sal_False ); - bool bIsSkipEmptyPages = !m_pPrintUIOptions->IsPrintEmptyPages( bIsPDFExport ); - - DBG_ASSERT(( pView->IsA(aSwViewTypeId) && m_pRenderData->IsViewOptionAdjust()) - || (!pView->IsA(aSwViewTypeId) && !m_pRenderData->IsViewOptionAdjust()), - "SwView / SwViewOptionAdjust_Impl availability mismatch" ); - - // since printing now also use the API for PDF export this option - // should be set for printing as well ... - pVwSh->SetPDFExportOption( sal_True ); - - // --> FME 2004-06-08 #i12836# enhanced pdf export - // - // First, we have to export hyperlinks, notes, and outline to pdf. - // During this process, additional information required for tagging - // the pdf file are collected, which are evaulated during painting. - // - SwWrtShell* pWrtShell = pView->IsA(aSwViewTypeId) ? - ((SwView*)pView)->GetWrtShellPtr() : - 0; - - if (bIsPDFExport && bFirstPage && pWrtShell) + if (bIsSwSrcView) { - SwEnhancedPDFExportHelper aHelper( *pWrtShell, *pOut, aPageRange, bIsSkipEmptyPages, sal_False ); + SwSrcView *pSwSrcView = dynamic_cast< SwSrcView * >(pView); + OutputDevice *pOutDev = lcl_GetOutputDevice( *m_pPrintUIOptions ); + pSwSrcView->PrintSource( pOutDev, nRenderer + 1, false ); } - // <-- - - const SwPrtOptions &rSwPrtOptions = *m_pRenderData->GetSwPrtOptions(); - if (bPrintProspect) - pVwSh->PrintProspect( pOut, rSwPrtOptions, nRenderer ); - else // normal printing and PDF export - pVwSh->PrintOrPDFExport( pOut, rSwPrtOptions, nRenderer ); - - // --> FME 2004-10-08 #i35176# - // - // After printing the last page, we take care for the links coming - // from the EditEngine. The links are generated during the painting - // process, but the destinations are still missing. - // - if (bIsPDFExport && bLastPage && pWrtShell) + else { - SwEnhancedPDFExportHelper aHelper( *pWrtShell, *pOut, aPageRange, bIsSkipEmptyPages, sal_True ); - } - // <-- + // the view shell should be SwView for documents PDF export + // or SwPagePreView for PDF export of the page preview + //!! (check for SwView first as in GuessViewShell) !! + DBG_ASSERT( pView, "!! view missing !!" ); + const TypeId aSwViewTypeId = TYPE(SwView); + ViewShell* pVwSh = 0; + if (pView) + { + pVwSh = pView->IsA(aSwViewTypeId) ? + ((SwView*)pView)->GetWrtShellPtr() : + ((SwPagePreView*)pView)->GetViewShell(); + } - pVwSh->SetPDFExportOption( sal_False ); + // get output device to use + OutputDevice * pOut = lcl_GetOutputDevice( *m_pPrintUIOptions ); - // last page to be rendered? (not necessarily the last page of the document) - // -> do clean-up of data - if (bLastPage) - { - // #i96167# haggai: delete pViewOptionsAdjust here because it makes use - // of the shell, which might get destroyed in lcl_DisposeView! - if (m_pRenderData && m_pRenderData->IsViewOptionAdjust()) - m_pRenderData->ViewOptionAdjustStop(); - - if (m_pRenderData && m_pRenderData->HasPostItData()) - m_pRenderData->DeletePostItData(); - if (m_pHiddenViewFrame) + if(pVwSh && pOut && m_pRenderData->HasSwPrtOptions()) { - lcl_DisposeView( m_pHiddenViewFrame, pDocShell ); - m_pHiddenViewFrame = 0; - } + const rtl::OUString aPageRange = m_pPrintUIOptions->getStringValue( "PageRange", OUString() ); + const bool bFirstPage = m_pPrintUIOptions->getBoolValue( "IsFirstPage", sal_False ); + bool bIsSkipEmptyPages = !m_pPrintUIOptions->IsPrintEmptyPages( bIsPDFExport ); + + DBG_ASSERT(( pView->IsA(aSwViewTypeId) && m_pRenderData->IsViewOptionAdjust()) + || (!pView->IsA(aSwViewTypeId) && !m_pRenderData->IsViewOptionAdjust()), + "SwView / SwViewOptionAdjust_Impl availability mismatch" ); + + // since printing now also use the API for PDF export this option + // should be set for printing as well ... + pVwSh->SetPDFExportOption( sal_True ); + + // --> FME 2004-06-08 #i12836# enhanced pdf export + // + // First, we have to export hyperlinks, notes, and outline to pdf. + // During this process, additional information required for tagging + // the pdf file are collected, which are evaulated during painting. + // + SwWrtShell* pWrtShell = pView->IsA(aSwViewTypeId) ? + ((SwView*)pView)->GetWrtShellPtr() : + 0; + + if (bIsPDFExport && bFirstPage && pWrtShell) + { + SwEnhancedPDFExportHelper aHelper( *pWrtShell, *pOut, aPageRange, bIsSkipEmptyPages, sal_False ); + } + // <-- + + const SwPrtOptions &rSwPrtOptions = *m_pRenderData->GetSwPrtOptions(); + if (bPrintProspect) + pVwSh->PrintProspect( pOut, rSwPrtOptions, nRenderer ); + else // normal printing and PDF export + pVwSh->PrintOrPDFExport( pOut, rSwPrtOptions, nRenderer ); + + // --> FME 2004-10-08 #i35176# + // + // After printing the last page, we take care for the links coming + // from the EditEngine. The links are generated during the painting + // process, but the destinations are still missing. + // + if (bIsPDFExport && bLastPage && pWrtShell) + { + SwEnhancedPDFExportHelper aHelper( *pWrtShell, *pOut, aPageRange, bIsSkipEmptyPages, sal_True ); + } + // <-- + + pVwSh->SetPDFExportOption( sal_False ); - delete m_pRenderData; m_pRenderData = NULL; - delete m_pPrintUIOptions; m_pPrintUIOptions = NULL; + // last page to be rendered? (not necessarily the last page of the document) + // -> do clean-up of data + if (bLastPage) + { + // #i96167# haggai: delete pViewOptionsAdjust here because it makes use + // of the shell, which might get destroyed in lcl_DisposeView! + if (m_pRenderData && m_pRenderData->IsViewOptionAdjust()) + m_pRenderData->ViewOptionAdjustStop(); + + if (m_pRenderData && m_pRenderData->HasPostItData()) + m_pRenderData->DeletePostItData(); + if (m_pHiddenViewFrame) + { + lcl_DisposeView( m_pHiddenViewFrame, pDocShell ); + m_pHiddenViewFrame = 0; + } + } + } } } } + if( bLastPage ) + { + delete m_pRenderData; m_pRenderData = NULL; + delete m_pPrintUIOptions; m_pPrintUIOptions = NULL; + } } /* -----------------------------03.10.04 ------------------------------------- -- cgit From 1f8c7028f642e995945eb0d3f70a13ac5267aad1 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Mon, 12 Oct 2009 11:36:38 +0200 Subject: solve rebase problems --- sw/inc/printdata.hxx | 2 +- sw/sdi/swriter.sdi | 25 ------------------------- sw/source/core/doc/doc.cxx | 12 +++++++----- sw/source/ui/uno/unomod.cxx | 2 +- 4 files changed, 9 insertions(+), 32 deletions(-) (limited to 'sw') diff --git a/sw/inc/printdata.hxx b/sw/inc/printdata.hxx index 11e2deed24ba..1d7841953edc 100644 --- a/sw/inc/printdata.hxx +++ b/sw/inc/printdata.hxx @@ -284,7 +284,7 @@ public: void SetPrintEmptyPages(sal_Bool b ) { doSetModified(); bPrintEmptyPages = b;} void SetPrintPostIts ( sal_Int16 n){ doSetModified(); nPrintPostIts = n; } void SetPrintProspect ( sal_Bool b ) { doSetModified(); bPrintProspect = b; } - void SetPrintProspect_RTL ( sal_Bool b ) { doSetModified(); bPrintProspect_RTL = b; } + void SetPrintProspect_RTL ( sal_Bool b ) { doSetModified(); bPrintProspectRTL = b; } void SetPrintPageBackground(sal_Bool b){ doSetModified(); bPrintPageBackground = b;} void SetPrintBlackFont(sal_Bool b){ doSetModified(); bPrintBlackFont = b;} void SetPrintSingleJobs(sal_Bool b){ doSetModified(); bPrintSingleJobs = b;} diff --git a/sw/sdi/swriter.sdi b/sw/sdi/swriter.sdi index 315d34197715..aede24688e1e 100644 --- a/sw/sdi/swriter.sdi +++ b/sw/sdi/swriter.sdi @@ -6508,31 +6508,6 @@ SfxVoidItem PageUpSel FN_PAGEUP_SEL GroupId = GID_NAVIGATOR; ] -//-------------------------------------------------------------------------- -SfxVoidItem PreviewPrintOptions FN_PREVIEW_PRINT_OPTIONS -() -[ - /* flags: */ - AutoUpdate = TRUE, - Cachable = Cachable, - FastCall = TRUE, - HasCoreId = FALSE, - HasDialog = TRUE, - ReadOnlyDoc = FALSE, - Toggle = FALSE, - Container = FALSE, - RecordAbsolute = FALSE, - RecordPerSet; - Synchron; - - /* config: */ - AccelConfig = TRUE, - MenuConfig = TRUE, - StatusBarConfig = FALSE, - ToolBoxConfig = TRUE, - GroupId = GID_DOC; -] - //-------------------------------------------------------------------------- SfxVoidItem PreviewZoom FN_PREVIEW_ZOOM ( SfxUInt16Item PreviewZoom FN_PREVIEW_ZOOM ) diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index 51115501c91a..6750dd266080 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -50,6 +50,7 @@ #include #include #include +#include #include #include #include @@ -1116,7 +1117,7 @@ static void lcl_FormatPostIt( if (bNewPage) { - pIDCO->Insert( aPam, SvxFmtBreakItem( SVX_BREAK_PAGE_AFTER, RES_BREAK ), 0 ); + pIDCO->InsertPoolItem( aPam, SvxFmtBreakItem( SVX_BREAK_PAGE_AFTER, RES_BREAK ), 0 ); pIDCO->SplitNode( *aPam.GetPoint(), false ); } else if (!bIsFirstPostIt) @@ -1142,8 +1143,9 @@ static void lcl_FormatPostIt( aStr.AppendAscii(sTmp); aStr += pField->GetPar1(); aStr += ' '; - aStr += GetAppLocaleData().getDate( pField->GetDate() ); - pIDCO->Insert( aPam, aStr, true ); + SvtSysLocale aSysLocale; + aStr += /*(LocaleDataWrapper&)*/aSysLocale.GetLocaleData().getDate( pField->GetDate() ); + pIDCO->InsertString( aPam, aStr ); pIDCO->SplitNode( *aPam.GetPoint(), false ); aStr = pField->GetPar2(); @@ -1151,7 +1153,7 @@ static void lcl_FormatPostIt( // Bei Windows und Co alle CR rausschmeissen aStr.EraseAllChars( '\r' ); #endif - pIDCO->Insert( aPam, aStr, true ); + pIDCO->InsertString( aPam, aStr ); } @@ -1324,7 +1326,7 @@ void SwDoc::UpdatePagesForPrintingWithPostItData( aPam.Move( fnMoveBackward, fnGoDoc ); aPam.SetMark(); aPam.Move( fnMoveForward, fnGoDoc ); - rData.m_pPostItDoc->Delete( aPam ); + rData.m_pPostItDoc->DeleteRange( aPam ); const StringRangeEnumerator aRangeEnum( rData.GetPageRange(), 1, nDocPageCount, 0 ); diff --git a/sw/source/ui/uno/unomod.cxx b/sw/source/ui/uno/unomod.cxx index bfdb2b1d2460..b701edd514e0 100644 --- a/sw/source/ui/uno/unomod.cxx +++ b/sw/source/ui/uno/unomod.cxx @@ -576,7 +576,7 @@ void SwXPrintSettings::_getSingleValue( const comphelper::PropertyInfo & rInfo, break; case HANDLE_PRINTSET_PROSPECT_RTL: { - rValue <<= mpPrtOpt->IsPrintProspect_RTL(); + rValue <<= mpPrtOpt->IsPrintProspectRTL(); } break; case HANDLE_PRINTSET_PLACEHOLDER: -- cgit From 021c0f0b52d7893d9497a509d3eb70b5777e1406 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Wed, 14 Oct 2009 11:15:39 +0200 Subject: fix a windows build problem --- sw/inc/unotxdoc.hxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sw') diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx index 4f2c444195d7..bea720e592bf 100644 --- a/sw/inc/unotxdoc.hxx +++ b/sw/inc/unotxdoc.hxx @@ -258,7 +258,7 @@ public: virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) throw(css::uno::RuntimeException); - SW_DLLPUBLIC static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId(); + static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId(); //XUnoTunnel virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) throw(css::uno::RuntimeException); -- cgit From d697a028c4796e00afd2cfdef6e246c80c560749 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Fri, 16 Oct 2009 15:26:42 +0200 Subject: #i105860# allow choice between selection and whole document when printing directly --- sw/source/core/view/vprint.cxx | 1 + sw/source/ui/uiview/viewprt.cxx | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) (limited to 'sw') diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index ec58b1dc7927..eafa9b8462c9 100644 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -335,6 +335,7 @@ void SwRenderData::MakeSwPrtOptions( rOptions.bPrintHiddenText = pOpt->getBoolValue( "PrintHiddenText", rOptions.bPrintHiddenText ); rOptions.bPrintTextPlaceholder = pOpt->getBoolValue( "PrintTextPlaceholder", rOptions.bPrintTextPlaceholder ); rOptions.nPrintPostIts = static_cast< sal_Int16 >(pOpt->getIntValue( "PrintAnnotationMode", rOptions.nPrintPostIts )); + rOptions.bPrintSelection |= pOpt->getBoolValue( "PrintSelectionOnly", false ); //! needs to be set after MakeOptions since the assignment operation in that //! function will destroy the pointers diff --git a/sw/source/ui/uiview/viewprt.cxx b/sw/source/ui/uiview/viewprt.cxx index 485799b28b00..2f78c63b285b 100644 --- a/sw/source/ui/uiview/viewprt.cxx +++ b/sw/source/ui/uiview/viewprt.cxx @@ -270,6 +270,7 @@ void __EXPORT SwView::ExecutePrint(SfxRequest& rReq) rReq.RemoveItem(FN_QRY_MERGE); BOOL bFromMerge = pPrintFromMergeItem ? pPrintFromMergeItem->GetValue() : FALSE; SwMiscConfig aMiscConfig; + bool bPrintSelection = false; if(!bSilent && !bFromMerge && SW_MOD()->GetModuleConfig()->IsAskForMailMerge() && pSh->IsAnyDatabaseFieldInDoc()) { @@ -284,12 +285,29 @@ void __EXPORT SwView::ExecutePrint(SfxRequest& rReq) return; } } + else if( rReq.GetSlot() == SID_PRINTDOCDIRECT && ! bSilent ) + { + if( /*!bIsAPI && */ + ( pSh->IsSelection() || pSh->IsFrmSelected() || pSh->IsObjSelected() ) ) + { + short nBtn = SvxPrtQryBox(&GetEditWin()).Execute(); + if( RET_CANCEL == nBtn ) + return;; + + if( RET_OK == nBtn ) + bPrintSelection = true; + } + } + //#i61455# if master documentes are printed silently without loaded links then update the links now if( bSilent && pSh->IsGlobalDoc() && !pSh->IsGlblDocSaveLinks() ) { pSh->GetLinkManager().UpdateAllLinks( sal_False, sal_False, sal_False, 0 ); } - SfxViewShell::ExecuteSlot( rReq, SfxViewShell::GetInterface() ); + SfxRequest aReq( rReq ); + SfxBoolItem aBool(SID_SELECTION, bPrintSelection); + aReq.AppendItem( aBool ); + SfxViewShell::ExecuteSlot( aReq, SfxViewShell::GetInterface() ); return; } default: -- cgit From 5a6b0cd17195ce1b0fbe9e020d7972c2e708a95d Mon Sep 17 00:00:00 2001 From: tl93732 Date: Tue, 20 Oct 2009 13:05:12 +0200 Subject: #i105730# selection printing --- sw/source/core/view/vprint.cxx | 1 - 1 file changed, 1 deletion(-) (limited to 'sw') diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index eafa9b8462c9..ec58b1dc7927 100644 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -335,7 +335,6 @@ void SwRenderData::MakeSwPrtOptions( rOptions.bPrintHiddenText = pOpt->getBoolValue( "PrintHiddenText", rOptions.bPrintHiddenText ); rOptions.bPrintTextPlaceholder = pOpt->getBoolValue( "PrintTextPlaceholder", rOptions.bPrintTextPlaceholder ); rOptions.nPrintPostIts = static_cast< sal_Int16 >(pOpt->getIntValue( "PrintAnnotationMode", rOptions.nPrintPostIts )); - rOptions.bPrintSelection |= pOpt->getBoolValue( "PrintSelectionOnly", false ); //! needs to be set after MakeOptions since the assignment operation in that //! function will destroy the pointers -- cgit From fd67b046624ff95b39950b8af30ad3ff90d26fe8 Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Tue, 20 Oct 2009 15:26:15 +0200 Subject: #i105730# comment edit --- sw/source/core/doc/doc.cxx | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) mode change 100644 => 100755 sw/source/core/doc/doc.cxx (limited to 'sw') diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx old mode 100644 new mode 100755 index 6750dd266080..9b736d851381 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -1283,11 +1283,22 @@ void SwDoc::CalculatePagesForPrinting( else { // PageContent : - // 0 -> print all pages + // 0 -> print all pages (default if aPageRange is empty) // 1 -> print range according to PageRange // 2 -> print selection - if (1 == rOptions.getIntValue( "PrintContent", 0 )) + const sal_Int32 nContent = rOptions.getIntValue( "PrintContent", 0 ); + if (1 == nContent) aPageRange = rOptions.getStringValue( "PageRange", OUString() ); + if (2 == nContent) + { + // note that printing selections is actually implemented by copying + // the selection to a new temporary document and printing all of that one. + // Thus for Writer "PrintContent" must never be 2. + // See SwXTextDocument::GetRenderDoc for evaluating if a selection is to be + // printed and for creating the temporary document. + } + + // please note } if (aPageRange.getLength() == 0) // empty string -> print all { -- cgit From 0eb60a412f3ba46dd33915a3aaadd01d31717b8b Mon Sep 17 00:00:00 2001 From: Frank Schönheit Date: Fri, 23 Oct 2009 09:46:03 +0200 Subject: step 0 of an UNOization of the css.form.(X)FormController implementation: move the API to css.form.runtime, so we can later add new API chunks without breaking compatibility of the existing API in css.form --- sw/source/filter/html/htmlform.cxx | 3 +++ sw/source/ui/inc/unotxvw.hxx | 2 +- sw/source/ui/uno/unotxvw.cxx | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-) (limited to 'sw') diff --git a/sw/source/filter/html/htmlform.cxx b/sw/source/filter/html/htmlform.cxx index dd93a4e60b92..3a17ba7c257e 100644 --- a/sw/source/filter/html/htmlform.cxx +++ b/sw/source/filter/html/htmlform.cxx @@ -76,6 +76,9 @@ #include #include #include +#include +#include +#include #include #include #include diff --git a/sw/source/ui/inc/unotxvw.hxx b/sw/source/ui/inc/unotxvw.hxx index 4db18720cf87..5900eeb42638 100644 --- a/sw/source/ui/inc/unotxvw.hxx +++ b/sw/source/ui/inc/unotxvw.hxx @@ -109,7 +109,7 @@ public: virtual void SAL_CALL removeSelectionChangeListener(const ::com::sun::star::uno::Reference< ::com::sun::star::view::XSelectionChangeListener > & xListener) throw( ::com::sun::star::uno::RuntimeException ); // XFormLayerAccess - virtual ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController > SAL_CALL getFormController( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& Form ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > SAL_CALL getFormController( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& Form ) throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Bool SAL_CALL isFormDesignMode( ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setFormDesignMode( ::sal_Bool DesignMode ) throw (::com::sun::star::uno::RuntimeException); diff --git a/sw/source/ui/uno/unotxvw.cxx b/sw/source/ui/uno/unotxvw.cxx index 6197bb489d61..9c7df7ecb479 100644 --- a/sw/source/ui/uno/unotxvw.cxx +++ b/sw/source/ui/uno/unotxvw.cxx @@ -721,7 +721,7 @@ uno::Reference< awt::XControl > SwXTextView::getControl(const uno::Reference< a /*-- 08.03.07 13:55------------------------------------------------------ -----------------------------------------------------------------------*/ -uno::Reference< form::XFormController > SAL_CALL SwXTextView::getFormController( const uno::Reference< form::XForm >& _Form ) throw (RuntimeException) +uno::Reference< form::runtime::XFormController > SAL_CALL SwXTextView::getFormController( const uno::Reference< form::XForm >& _Form ) throw (RuntimeException) { ::vos::OGuard aGuard( Application::GetSolarMutex() ); @@ -731,7 +731,7 @@ uno::Reference< form::XFormController > SAL_CALL SwXTextView::getFormController( Window* pWindow = pView2 ? pView2->GetWrtShell().GetWin() : NULL; DBG_ASSERT( pFormShell && pDrawView && pWindow, "SwXTextView::GetControl: how could I?" ); - uno::Reference< form::XFormController > xController; + uno::Reference< form::runtime::XFormController > xController; if ( pFormShell && pDrawView && pWindow ) xController = pFormShell->GetFormController( _Form, *pDrawView, *pWindow ); return xController; -- cgit From c635b740e00d1762c905cdd787fdb31753dab932 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 30 Oct 2009 17:42:00 +0100 Subject: #i105295#: fix various uninitialized variables reported by valgrind in: SwTxtFormatter::CtorInitTxtFormatter(), SwArrowPortion::SwArrowPortion(), SwAccessiblePage::SwAccessiblePage(), SwXShape::_AdjustPositionProperties(), SwFrm::SwFrm(), SwGlosDocShell::SwGlosDocShell(), SwXPrintSettings::_getSingleValue() --- sw/source/core/access/accpage.cxx | 5 +++-- sw/source/core/layout/wsfrm.cxx | 5 +++++ sw/source/core/text/itrform2.cxx | 1 + sw/source/core/text/porrst.cxx | 1 + sw/source/core/unocore/unodraw.cxx | 24 ++++++++++++++---------- sw/source/ui/misc/glshell.cxx | 8 ++++---- sw/source/ui/uno/unomod.cxx | 32 +++++++++++++------------------- 7 files changed, 41 insertions(+), 35 deletions(-) (limited to 'sw') diff --git a/sw/source/core/access/accpage.cxx b/sw/source/core/access/accpage.cxx index 9d1f39acfc5b..bc2a74809420 100644 --- a/sw/source/core/access/accpage.cxx +++ b/sw/source/core/access/accpage.cxx @@ -129,8 +129,9 @@ void SwAccessiblePage::_InvalidateFocus() } SwAccessiblePage::SwAccessiblePage( SwAccessibleMap* pInitMap, - const SwFrm* pFrame ) : - SwAccessibleContext( pInitMap, AccessibleRole::PANEL, pFrame ) + const SwFrm* pFrame ) + : SwAccessibleContext( pInitMap, AccessibleRole::PANEL, pFrame ) + , bIsSelected( sal_False ) { DBG_ASSERT( pFrame != NULL, "need frame" ); DBG_ASSERT( pInitMap != NULL, "need map" ); diff --git a/sw/source/core/layout/wsfrm.cxx b/sw/source/core/layout/wsfrm.cxx index af97063da6e3..9225942c5f93 100644 --- a/sw/source/core/layout/wsfrm.cxx +++ b/sw/source/core/layout/wsfrm.cxx @@ -101,6 +101,11 @@ SwFrm::SwFrm( SwModify *pMod ) : pNext( 0 ), pPrev( 0 ), pDrawObjs( 0 ) + , bInfBody( FALSE ) + , bInfTab ( FALSE ) + , bInfFly ( FALSE ) + , bInfFtn ( FALSE ) + , bInfSct ( FALSE ) { #ifndef PRODUCT bFlag01 = bFlag02 = bFlag03 = bFlag04 = bFlag05 = 0; diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx index cb54872d19e2..dc02f416de0c 100644 --- a/sw/source/core/text/itrform2.cxx +++ b/sw/source/core/text/itrform2.cxx @@ -101,6 +101,7 @@ void SwTxtFormatter::CtorInitTxtFormatter( SwTxtFrm *pNewFrm, SwTxtFormatInfo *p pMulti = NULL; bOnceMore = sal_False; + bFlyInCntBase = sal_False; bChanges = sal_False; bTruncLines = sal_False; nCntEndHyph = 0; diff --git a/sw/source/core/text/porrst.cxx b/sw/source/core/text/porrst.cxx index a0b859cf0e12..fe39264e416b 100644 --- a/sw/source/core/text/porrst.cxx +++ b/sw/source/core/text/porrst.cxx @@ -219,6 +219,7 @@ SwArrowPortion::SwArrowPortion( const SwTxtPaintInfo &rInf ) rInf.GetTxtFrm()->Prt().Right(); aPos.Y() = rInf.GetTxtFrm()->Frm().Top() + rInf.GetTxtFrm()->Prt().Bottom(); + SetWhichPor( POR_ARROW ); } void SwArrowPortion::Paint( const SwTxtPaintInfo &rInf ) const diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx index 11b3eae5a16a..b9e537279ada 100644 --- a/sw/source/core/unocore/unodraw.cxx +++ b/sw/source/core/unocore/unodraw.cxx @@ -2739,12 +2739,14 @@ void SwXShape::_AdjustPositionProperties( const awt::Point _aPosition ) rtl::OUString aHoriOrientPropStr( RTL_CONSTASCII_USTRINGPARAM("HoriOrient") ); uno::Any aHoriOrient( getPropertyValue( aHoriOrientPropStr ) ); sal_Int16 eHoriOrient; - aHoriOrient >>= eHoriOrient; - if ( eHoriOrient != text::HoriOrientation::NONE ) + if (aHoriOrient >>= eHoriOrient) // may be void { - eHoriOrient = text::HoriOrientation::NONE; - aHoriOrient <<= eHoriOrient; - setPropertyValue( aHoriOrientPropStr, aHoriOrient ); + if ( eHoriOrient != text::HoriOrientation::NONE ) + { + eHoriOrient = text::HoriOrientation::NONE; + aHoriOrient <<= eHoriOrient; + setPropertyValue( aHoriOrientPropStr, aHoriOrient ); + } } // set x-position attribute aHoriPos <<= _aPosition.X; @@ -2767,12 +2769,14 @@ void SwXShape::_AdjustPositionProperties( const awt::Point _aPosition ) rtl::OUString aVertOrientPropStr( RTL_CONSTASCII_USTRINGPARAM("VertOrient") ); uno::Any aVertOrient( getPropertyValue( aVertOrientPropStr ) ); sal_Int16 eVertOrient; - aVertOrient >>= eVertOrient; - if ( eVertOrient != text::VertOrientation::NONE ) + if (aVertOrient >>= eVertOrient) // may be void { - eVertOrient = text::VertOrientation::NONE; - aVertOrient <<= eVertOrient; - setPropertyValue( aVertOrientPropStr, aVertOrient ); + if ( eVertOrient != text::VertOrientation::NONE ) + { + eVertOrient = text::VertOrientation::NONE; + aVertOrient <<= eVertOrient; + setPropertyValue( aVertOrientPropStr, aVertOrient ); + } } // set y-position attribute aVertPos <<= _aPosition.Y; diff --git a/sw/source/ui/misc/glshell.cxx b/sw/source/ui/misc/glshell.cxx index a79e67eec31c..402d6306784c 100644 --- a/sw/source/ui/misc/glshell.cxx +++ b/sw/source/ui/misc/glshell.cxx @@ -154,10 +154,10 @@ BOOL lcl_Save( SwWrtShell& rSh, const String& rGroupName, --------------------------------------------------------------------*/ -SwGlosDocShell::SwGlosDocShell( sal_Bool bNewShow) - : - SwDocShell( bShow ? SFX_CREATE_MODE_STANDARD : SFX_CREATE_MODE_INTERNAL ) - ,bShow ( bNewShow ) +SwGlosDocShell::SwGlosDocShell(sal_Bool bNewShow) + : SwDocShell( (bNewShow) + ? SFX_CREATE_MODE_STANDARD : SFX_CREATE_MODE_INTERNAL ) + , bShow ( bNewShow ) { SetHelpId(SW_GLOSDOCSHELL); } diff --git a/sw/source/ui/uno/unomod.cxx b/sw/source/ui/uno/unomod.cxx index bfdb2b1d2460..6a67cb3dee29 100644 --- a/sw/source/ui/uno/unomod.cxx +++ b/sw/source/ui/uno/unomod.cxx @@ -519,58 +519,54 @@ void SwXPrintSettings::_preGetValues () void SwXPrintSettings::_getSingleValue( const comphelper::PropertyInfo & rInfo, uno::Any & rValue ) throw(UnknownPropertyException, WrappedTargetException ) { - sal_Bool bBool = TRUE; - sal_Bool bBoolVal; switch( rInfo.mnHandle ) { case HANDLE_PRINTSET_LEFT_PAGES: - bBoolVal = mpPrtOpt->IsPrintLeftPage(); + rValue <<= mpPrtOpt->IsPrintLeftPage(); break; case HANDLE_PRINTSET_RIGHT_PAGES: - bBoolVal = mpPrtOpt->IsPrintRightPage(); + rValue <<= mpPrtOpt->IsPrintRightPage(); break; case HANDLE_PRINTSET_REVERSED: - bBoolVal = mpPrtOpt->IsPrintReverse(); + rValue <<= mpPrtOpt->IsPrintReverse(); break; case HANDLE_PRINTSET_PROSPECT: - bBoolVal = mpPrtOpt->IsPrintProspect(); + rValue <<= mpPrtOpt->IsPrintProspect(); break; case HANDLE_PRINTSET_GRAPHICS: - bBoolVal = mpPrtOpt->IsPrintGraphic(); + rValue <<= mpPrtOpt->IsPrintGraphic(); break; case HANDLE_PRINTSET_TABLES: - bBoolVal = mpPrtOpt->IsPrintTable(); + rValue <<= mpPrtOpt->IsPrintTable(); break; case HANDLE_PRINTSET_DRAWINGS: - bBoolVal = mpPrtOpt->IsPrintDraw(); + rValue <<= mpPrtOpt->IsPrintDraw(); break; case HANDLE_PRINTSET_CONTROLS: - bBoolVal = mpPrtOpt->IsPrintControl(); + rValue <<= mpPrtOpt->IsPrintControl(); break; case HANDLE_PRINTSET_PAGE_BACKGROUND: - bBoolVal = mpPrtOpt->IsPrintPageBackground(); + rValue <<= mpPrtOpt->IsPrintPageBackground(); break; case HANDLE_PRINTSET_BLACK_FONTS: - bBoolVal = mpPrtOpt->IsPrintBlackFont(); + rValue <<= mpPrtOpt->IsPrintBlackFont(); break; case HANDLE_PRINTSET_SINGLE_JOBS: - bBoolVal = mpPrtOpt->IsPrintSingleJobs(); + rValue <<= mpPrtOpt->IsPrintSingleJobs(); break; case HANDLE_PRINTSET_EMPTY_PAGES: - bBoolVal = mpPrtOpt->IsPrintEmptyPages(); + rValue <<= mpPrtOpt->IsPrintEmptyPages(); break; case HANDLE_PRINTSET_PAPER_FROM_SETUP: - bBoolVal = mpPrtOpt->IsPaperFromSetup(); + rValue <<= mpPrtOpt->IsPaperFromSetup(); break; case HANDLE_PRINTSET_ANNOTATION_MODE: { - bBool = FALSE; rValue <<= static_cast < sal_Int16 > ( mpPrtOpt->GetPrintPostIts() ); } break; case HANDLE_PRINTSET_FAX_NAME : { - bBool = FALSE; rValue <<= mpPrtOpt->GetFaxName(); } break; @@ -592,8 +588,6 @@ void SwXPrintSettings::_getSingleValue( const comphelper::PropertyInfo & rInfo, default: throw UnknownPropertyException(); } - if(bBool) - rValue.setValue(&bBoolVal, ::getBooleanCppuType()); } void SwXPrintSettings::_postGetValues () throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException ) -- cgit From 296fef7e82f0bf842428eaa97dff207399dc563e Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Mon, 2 Nov 2009 19:08:00 +0100 Subject: #i105745#: tools/stream.hxx: API change: make SvMemoryStream::GetSize() private introduce new public SvMemoryStream::GetEndOfData() --- sw/source/filter/rtf/rtfatr.cxx | 2 +- sw/source/ui/app/docsh2.cxx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'sw') diff --git a/sw/source/filter/rtf/rtfatr.cxx b/sw/source/filter/rtf/rtfatr.cxx index fc60c857aedb..e699cd64f0cb 100644 --- a/sw/source/filter/rtf/rtfatr.cxx +++ b/sw/source/filter/rtf/rtfatr.cxx @@ -530,7 +530,7 @@ void OutRTF_SwFlyFrmFmt( SwRTFWriter& rRTFWrt ) rRTFWrt.SetStrm( *pSaveStrm ); // Stream-Pointer wieder zurueck - if( aTmpStrm.GetSize() ) // gibt es SWG spezifische Attribute ?? + if ( aTmpStrm.GetEndOfData() ) // gibt es SWG spezifische Attribute? { aTmpStrm.Seek( 0L ); rRTFWrt.Strm() << '{' << OOO_STRING_SVTOOLS_RTF_IGNORE << aTmpStrm << '}'; diff --git a/sw/source/ui/app/docsh2.cxx b/sw/source/ui/app/docsh2.cxx index 3fd1e879b063..a967799be78e 100644 --- a/sw/source/ui/app/docsh2.cxx +++ b/sw/source/ui/app/docsh2.cxx @@ -1134,7 +1134,7 @@ void SwDocShell::Execute(SfxRequest& rReq) xRef( pClipCntnr ); pClipCntnr->CopyAnyData( FORMAT_RTF, (sal_Char*) - pStrm->GetData(), pStrm->GetSize() ); + pStrm->GetData(), pStrm->GetEndOfData() ); pClipCntnr->CopyToClipboard( GetView()? (Window*)&GetView()->GetEditWin() : 0 ); delete pStrm; -- cgit From 5847cb59f3e70fa0cc800ce2f5e5eb7ded7b671c Mon Sep 17 00:00:00 2001 From: sb Date: Fri, 13 Nov 2009 11:04:06 +0100 Subject: sb116: #i106845# removed obsolete IRIX port --- sw/source/ui/chrdlg/ccoll.cxx | 8 -------- sw/util/makefile.mk | 4 ---- 2 files changed, 12 deletions(-) (limited to 'sw') diff --git a/sw/source/ui/chrdlg/ccoll.cxx b/sw/source/ui/chrdlg/ccoll.cxx index 25276c2cc4bc..e0e4826a93d4 100644 --- a/sw/source/ui/chrdlg/ccoll.cxx +++ b/sw/source/ui/chrdlg/ccoll.cxx @@ -209,11 +209,7 @@ int SwCondCollItem::operator==( const SfxPoolItem& rItem) const const String& SwCondCollItem::GetStyle(USHORT nPos) const { -#ifndef IRIX return nPos < COND_COMMAND_COUNT ? sStyles[nPos] : aEmptyStr; -#else - return nPos < COND_COMMAND_COUNT ? (String)sStyles[nPos] : aEmptyStr; -#endif } /**************************************************************************** @@ -224,11 +220,7 @@ const String& SwCondCollItem::GetStyle(USHORT nPos) const void SwCondCollItem::SetStyle(const String* pStyle, USHORT nPos) { if( nPos < COND_COMMAND_COUNT ) -#ifndef IRIX sStyles[nPos] = pStyle ? *pStyle : aEmptyStr; -#else - sStyles[nPos] = pStyle ? (String)*pStyle : aEmptyStr; -#endif } diff --git a/sw/util/makefile.mk b/sw/util/makefile.mk index 4b3abf042b8e..ca81fa868510 100644 --- a/sw/util/makefile.mk +++ b/sw/util/makefile.mk @@ -43,10 +43,6 @@ USE_DEFFILE=TRUE # --- Allgemein ----------------------------------------------------------- -.IF "$(OS)"=="IRIX" -LINKFLAGS+=-Wl,-LD_LAYOUT:lgot_buffer=40 -.ENDIF - sw_res_files= \ $(SRS)$/app.srs \ $(SRS)$/dialog.srs \ -- cgit From 1b9308fe40e222d3a2262c7c0e399e8c6aa6ffde Mon Sep 17 00:00:00 2001 From: "Philipp Lohmann [pl]" Date: Wed, 18 Nov 2009 20:23:30 +0100 Subject: printerpullpages: #i106505# brochure RTL only if CTL is enabled --- sw/source/core/view/vprint.cxx | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) (limited to 'sw') diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index ec58b1dc7927..92838db105ee 100644 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -55,6 +55,7 @@ #include #include +#include #include #include @@ -373,17 +374,22 @@ SwPrintUIOptions::SwPrintUIOptions( bool bWeb, bool bSwSrcView ) : return; } + // check if CTL is enabled + SvtLanguageOptions aLangOpt; + bool bCTL = aLangOpt.IsCTLFontEnabled(); + // create sequence of print UI options // (5 options are not available for Writer-Web) - const int nNumProps = bWeb? 17 : 21; + const int nCTLOpts = bCTL ? 1 : 0; + const int nNumProps = nCTLOpts + (bWeb ? 16 : 20); m_aUIProperties.realloc( nNumProps ); int nIdx = 0; // create "writer" section (new tab page in dialog) - SvtModuleOptions aOpt; + SvtModuleOptions aModOpt; String aAppGroupname( aLocalizedStrings.GetString( 0 ) ); aAppGroupname.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "%s" ) ), - aOpt.GetModuleName( SvtModuleOptions::E_SWRITER ) ); + aModOpt.GetModuleName( SvtModuleOptions::E_SWRITER ) ); m_aUIProperties[ nIdx++ ].Value = getGroupControlOpt( aAppGroupname, rtl::OUString() ); // create sub section for Contents @@ -540,18 +546,21 @@ SwPrintUIOptions::SwPrintUIOptions( bool bWeb, bool bSwSrcView ) : aPageSetOpt ); - // create a bool option for brochure RTL dependent on brochure - uno::Sequence< rtl::OUString > aBRTLChoices( 2 ); - aBRTLChoices[0] = aLocalizedStrings.GetString( 35 ); - aBRTLChoices[1] = aLocalizedStrings.GetString( 36 ); - vcl::PrinterOptionsHelper::UIControlOptions aBrochureRTLOpt( aBrochurePropertyName, -1, sal_True ); - aBrochureRTLOpt.maGroupHint = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutPage" ) ); - m_aUIProperties[ nIdx++ ].Value = getChoiceControlOpt( rtl::OUString(), - uno::Sequence< rtl::OUString >(), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintProspectRTL" ) ), - aBRTLChoices, 0, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "List" ) ), - aBrochureRTLOpt - ); + if( bCTL ) + { + // create a bool option for brochure RTL dependent on brochure + uno::Sequence< rtl::OUString > aBRTLChoices( 2 ); + aBRTLChoices[0] = aLocalizedStrings.GetString( 35 ); + aBRTLChoices[1] = aLocalizedStrings.GetString( 36 ); + vcl::PrinterOptionsHelper::UIControlOptions aBrochureRTLOpt( aBrochurePropertyName, -1, sal_True ); + aBrochureRTLOpt.maGroupHint = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutPage" ) ); + m_aUIProperties[ nIdx++ ].Value = getChoiceControlOpt( rtl::OUString(), + uno::Sequence< rtl::OUString >(), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintProspectRTL" ) ), + aBRTLChoices, 0, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "List" ) ), + aBrochureRTLOpt + ); + } DBG_ASSERT( nIdx == nNumProps, "number of added properties is not as expected" ); -- cgit From 9a506d302bcf497b58684e1ab9b1e4da50572469 Mon Sep 17 00:00:00 2001 From: "Ocke Janssen [oj]" Date: Tue, 24 Nov 2009 11:34:17 +0100 Subject: dba33d: #i104949# show cell value when set field text nodes exits --- sw/source/core/table/swtable.cxx | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'sw') diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx index 070e8eb625f9..99e8948d4afb 100644 --- a/sw/source/core/table/swtable.cxx +++ b/sw/source/core/table/swtable.cxx @@ -50,6 +50,8 @@ #include #include #include +#include +#include #include #include #include // fuer RedlineTbl() @@ -101,6 +103,8 @@ SV_IMPL_REF( SwServerObject ) #define COLFUZZY 20 +void ChgTextToNum( SwTableBox& rBox, const String& rTxt, const Color* pCol, + BOOL bChgAlign,ULONG nNdPos ); //---------------------------------- class SwTableBox_Impl @@ -2087,11 +2091,16 @@ void SwTable::SetHTMLTableLayout( SwHTMLTableLayout *p ) pHTMLLayout = p; } - void ChgTextToNum( SwTableBox& rBox, const String& rTxt, const Color* pCol, BOOL bChgAlign ) { ULONG nNdPos = rBox.IsValidNumTxtNd( TRUE ); + ChgTextToNum( rBox,rTxt,pCol,bChgAlign,nNdPos); +} +void ChgTextToNum( SwTableBox& rBox, const String& rTxt, const Color* pCol, + BOOL bChgAlign,ULONG nNdPos ) +{ + if( ULONG_MAX != nNdPos ) { SwDoc* pDoc = rBox.GetFrmFmt()->GetDoc(); @@ -2159,6 +2168,8 @@ void ChgTextToNum( SwTableBox& rBox, const String& rTxt, const Color* pCol, for( n = 0; n < rOrig.Len() && '\x9' == rOrig.GetChar( n ); ++n ) ; + for( ; n < rOrig.Len() && '\x01' == rOrig.GetChar( n ); ++n ) + ; SwIndex aIdx( pTNd, n ); for( n = rOrig.Len(); n && '\x9' == rOrig.GetChar( --n ); ) ; @@ -2637,6 +2648,14 @@ ULONG SwTableBox::IsValidNumTxtNd( BOOL bCheckAttr ) const *pAttr->GetStart() || *pAttr->GetAnyEnd() < rTxt.Len() ) { + if ( pAttr->Which() == RES_TXTATR_FIELD ) + { + const SwField* pField = pAttr->GetFld().GetFld(); + if ( pField && pField->GetTypeId() == TYP_SETFLD ) + { + continue; + } + } nPos = ULONG_MAX; break; } @@ -2691,7 +2710,7 @@ void SwTableBox::ActualiseValueBox() const String& rTxt = pSttNd->GetNodes()[ nNdPos ]->GetTxtNode()->GetTxt(); if( rTxt != sNewTxt ) - ChgTextToNum( *this, sNewTxt, pCol, FALSE ); + ChgTextToNum( *this, sNewTxt, pCol, FALSE ,nNdPos); } } } -- cgit From 0b7a663872f6377fced80cdd6368174f1f28eddb Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Thu, 3 Dec 2009 15:25:10 +0100 Subject: #i106926# printing of hidden text fixed --- sw/inc/printdata.hxx | 2 +- sw/inc/unotxdoc.hxx | 19 ++++-- sw/inc/viewopt.hxx | 9 ++- sw/source/core/fields/docufld.cxx | 3 +- sw/source/core/text/itrform2.cxx | 5 +- sw/source/core/view/vprint.cxx | 4 +- sw/source/ui/uno/unotxdoc.cxx | 123 ++++++++++++++++++++++++-------------- 7 files changed, 107 insertions(+), 58 deletions(-) mode change 100644 => 100755 sw/inc/printdata.hxx mode change 100644 => 100755 sw/inc/unotxdoc.hxx mode change 100644 => 100755 sw/inc/viewopt.hxx mode change 100644 => 100755 sw/source/core/view/vprint.cxx mode change 100644 => 100755 sw/source/ui/uno/unotxdoc.cxx (limited to 'sw') diff --git a/sw/inc/printdata.hxx b/sw/inc/printdata.hxx old mode 100644 new mode 100755 index 1d7841953edc..2df487f69838 --- a/sw/inc/printdata.hxx +++ b/sw/inc/printdata.hxx @@ -121,7 +121,7 @@ public: void DeletePostItData(); bool IsViewOptionAdjust() const { return m_pViewOptionAdjust != 0; } - void ViewOptionAdjustStart( SwWrtShell& rSh ); + void ViewOptionAdjustStart( SwWrtShell& rSh, const SwPrtOptions *pPrtOptions ); void ViewOptionAdjustStop(); bool HasSwPrtOptions() const { return m_pPrtOptions != 0; } diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx old mode 100644 new mode 100755 index bea720e592bf..a5c39b2d928d --- a/sw/inc/unotxdoc.hxx +++ b/sw/inc/unotxdoc.hxx @@ -591,21 +591,28 @@ public: /*-- 06.01.2004 15:08:34--------------------------------------------------- The class SwViewOptionAdjust_Impl is used to adjust the SwViewOption of the current ViewShell so that fields are not printed as commands and - hidden text and hidden characters are always invisible. + hidden characters are always invisible. Hidden text and place holders + should be printed according to the current print options. After printing the view options are restored -----------------------------------------------------------------------*/ class SwViewOptionAdjust_Impl { + // options not available in the File/Print UI, should be turned off for + // printing and PDF export if they are enabled bool m_bSwitchOff_IsFldName; - bool m_bSwitchOff_PlaceHolderView; - bool m_bSwitchOff_HiddenChar; - bool m_bSwitchOff_HiddenParagraphs; - bool m_bSwitchOff_IsShowHiddenField; + + // options available in the File/Print UI, should be turned of for PDF export + // and otherwise set (or not) according to + // pPrtOptions->bPrintHiddenText and pPrtOptions->bPrintTextPlaceholder + bool m_bToggle_HiddenChar; + bool m_bToggle_HiddenField; + bool m_bToggle_HiddenParagraphs; + bool m_bToggle_PlaceHolderView; SwViewOption* m_pViewOption; SwWrtShell& m_rShell; public: - SwViewOptionAdjust_Impl(SwWrtShell& rSh); + SwViewOptionAdjust_Impl( SwWrtShell& rSh, const SwPrtOptions *pPrtOptions ); ~SwViewOptionAdjust_Impl(); }; diff --git a/sw/inc/viewopt.hxx b/sw/inc/viewopt.hxx old mode 100644 new mode 100755 index d650d90cf08e..2ac47e284b49 --- a/sw/inc/viewopt.hxx +++ b/sw/inc/viewopt.hxx @@ -82,8 +82,7 @@ namespace svtools{ class ColorConfig;} #define VIEWOPT_CORE2_SMOOTHSCROLL 0x00000004L #define VIEWOPT_CORE2_CRSR_IN_PROT 0x00000008L #define VIEWOPT_CORE2_PDF_EXPORT 0x00000010L - - +#define VIEWOPT_CORE2_PRINTING 0x00000020L #define VIEWOPT_CORE2_BIGMARKHDL 0x00000040L #define VIEWOPT_2_UNUSED1 0x00000100L @@ -381,6 +380,12 @@ public: inline void SetPDFExport(BOOL b) { (b != 0) ? (nCore2Options |= VIEWOPT_CORE2_PDF_EXPORT) : (nCore2Options &= ~VIEWOPT_CORE2_PDF_EXPORT);} + inline BOOL IsPrinting() const + {return nCore2Options & VIEWOPT_CORE2_PRINTING ? TRUE : FALSE;} + + inline void SetPrinting(BOOL b) + { (b != 0) ? (nCore2Options |= VIEWOPT_CORE2_PRINTING) : (nCore2Options &= ~VIEWOPT_CORE2_PRINTING);} + /*--------------------------------------------------------------------------- ----------------------------------------------------------------------------*/ diff --git a/sw/source/core/fields/docufld.cxx b/sw/source/core/fields/docufld.cxx index 6bb8ff4902ea..6d451ed01f41 100644 --- a/sw/source/core/fields/docufld.cxx +++ b/sw/source/core/fields/docufld.cxx @@ -1335,7 +1335,8 @@ BOOL SwDocInfoField::PutValue( const uno::Any& rAny, USHORT nWhichId ) SwHiddenTxtFieldType::SwHiddenTxtFieldType( sal_Bool bSetHidden ) : SwFieldType( RES_HIDDENTXTFLD ), bHidden( bSetHidden ) -{} +{ +} SwFieldType* SwHiddenTxtFieldType::Copy() const { diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx index cb54872d19e2..ab15998f86aa 100644 --- a/sw/source/core/text/itrform2.cxx +++ b/sw/source/core/text/itrform2.cxx @@ -2106,7 +2106,10 @@ long SwTxtFormatter::CalcOptRepaint( xub_StrLen nOldLineEnd, bool lcl_BuildHiddenPortion( const SwTxtSizeInfo& rInf, xub_StrLen &rPos ) { // Only if hidden text should not be shown: - if ( rInf.GetVsh() && rInf.GetVsh()->GetWin() && rInf.GetOpt().IsShowHiddenChar() ) +// if ( rInf.GetVsh() && rInf.GetVsh()->GetWin() && rInf.GetOpt().IsShowHiddenChar() ) + const bool bShowInDocView = rInf.GetVsh() && rInf.GetVsh()->GetWin() && rInf.GetOpt().IsShowHiddenChar(); + const bool bShowForPrinting = rInf.GetOpt().IsShowHiddenChar( TRUE ) && rInf.GetOpt().IsPrinting(); + if (bShowInDocView || bShowForPrinting) return false; const SwScriptInfo& rSI = rInf.GetParaPortion()->GetScriptInfo(); diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx old mode 100644 new mode 100755 index 92838db105ee..715c74870f2f --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -282,11 +282,11 @@ void SwRenderData::DeletePostItData() } -void SwRenderData::ViewOptionAdjustStart( SwWrtShell& rSh ) +void SwRenderData::ViewOptionAdjustStart( SwWrtShell& rSh, const SwPrtOptions *pPrtOptions ) { if (m_pViewOptionAdjust) delete m_pViewOptionAdjust; - m_pViewOptionAdjust = new SwViewOptionAdjust_Impl( rSh ); + m_pViewOptionAdjust = new SwViewOptionAdjust_Impl( rSh, pPrtOptions ); } diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx old mode 100644 new mode 100755 index 2e0ecf2eb155..51fdb6779778 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -2653,6 +2653,11 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount( pWrtShell = pSwView->GetWrtShellPtr(); } + // reformating the document for printing will show the changes in the view + // which is likely to produce many unwanted and not nice to view actions. + // We don't want that! Thus we disable updating of the view. + pWrtShell->StartAction(); + m_pRenderData->SetSwPrtOptions( new SwPrtOptions( C2U( bIsPDFExport ? "PDF export" : "Printing" ) ) ); m_pRenderData->MakeSwPrtOptions( m_pRenderData->GetSwPrtOptionsRef(), pRenderDocShell, m_pPrintUIOptions, m_pRenderData, bIsSkipEmptyPages, bIsPDFExport ); @@ -2660,7 +2665,11 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount( //SwViewOptionAdjust_Impl aAdjust(*pWrtShell); const TypeId aSwViewTypeId = TYPE(SwView); if (pView->IsA(aSwViewTypeId)) - m_pRenderData->ViewOptionAdjustStart( *((SwView*)pView)->GetWrtShellPtr() ); + { + // PDF export should not make use of the SwPrtOptions + const SwPrtOptions *pPrtOptions = bIsPDFExport? NULL : m_pRenderData->GetSwPrtOptions(); + m_pRenderData->ViewOptionAdjustStart( *((SwView*)pView)->GetWrtShellPtr(), pPrtOptions ); + } // since printing now also use the API for PDF export this option // should be set for printing as well ... @@ -2677,6 +2686,10 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount( pWrtShell->CalcPagesForPrint( pDoc->GetPageCount() ); pWrtShell->SetPDFExportOption( sal_False ); + + + // enable view again + pWrtShell->EndAction(); } const sal_Int32 nPageCount = pDoc->GetPageCount(); @@ -3985,52 +3998,69 @@ void SwXDocumentPropertyHelper::onChange() /*****************************************************************************/ -SwViewOptionAdjust_Impl::SwViewOptionAdjust_Impl(SwWrtShell& rSh) : +SwViewOptionAdjust_Impl::SwViewOptionAdjust_Impl( SwWrtShell& rSh, const SwPrtOptions *pPrtOptions ) : m_pViewOption(0), m_rShell(rSh) { const SwViewOption* pCurrentViewOptions = m_rShell.GetViewOptions(); - m_bSwitchOff_IsFldName = pCurrentViewOptions->IsFldName() && m_rShell.IsAnyFieldInDoc(); + + const bool bContainsHiddenChars = m_rShell.GetDoc()->ContainsHiddenChars(); + const SwFieldType* pFldType = m_rShell.GetDoc()->GetSysFldType( RES_HIDDENTXTFLD ); + const bool bContainsHiddenFields = pFldType && pFldType->GetDepends(); + pFldType = m_rShell.GetDoc()->GetSysFldType( RES_HIDDENPARAFLD ); + const bool bContainsHiddenParagraphs = pFldType && pFldType->GetDepends(); + pFldType = m_rShell.GetDoc()->GetSysFldType( RES_JUMPEDITFLD ); + const bool bContainsPlaceHolders = pFldType && pFldType->GetDepends(); + + m_bSwitchOff_IsFldName = m_rShell.IsAnyFieldInDoc() && pCurrentViewOptions->IsFldName(); + + // for printing only (not PDF export) take print options into account + if (pPrtOptions) + { + m_bToggle_PlaceHolderView = bContainsPlaceHolders && pPrtOptions->bPrintTextPlaceholder != pCurrentViewOptions->IsShowPlaceHolderFields(); + m_bToggle_HiddenChar = bContainsHiddenChars && pPrtOptions->bPrintHiddenText != pCurrentViewOptions->IsShowHiddenChar( TRUE ); + m_bToggle_HiddenField = bContainsHiddenFields && pPrtOptions->bPrintHiddenText != pCurrentViewOptions->IsShowHiddenField(); + m_bToggle_HiddenParagraphs = bContainsHiddenParagraphs && pPrtOptions->bPrintHiddenText != pCurrentViewOptions->IsShowHiddenPara(); + } + else + { + //toggle painting of placeholder fields + m_bToggle_PlaceHolderView = bContainsPlaceHolders && pCurrentViewOptions->IsShowPlaceHolderFields(); + //toggle display of hidden characters if on and hidden characters are in use + m_bToggle_HiddenChar = bContainsHiddenChars && pCurrentViewOptions->IsShowHiddenChar( FALSE ); + //toggle display of hidden fields if on and hidden fields are in use + m_bToggle_HiddenField = bContainsHiddenFields && pCurrentViewOptions->IsShowHiddenField(); + //toggle display of hidden paragraphs if on and hidden paragraphs are in use + m_bToggle_HiddenParagraphs = bContainsHiddenParagraphs && pCurrentViewOptions->IsShowHiddenPara(); + } + + // bApplyViewOptions should only be true if necessary to avoid reformating if not required, bool bApplyViewOptions = m_bSwitchOff_IsFldName; - //switch off painting of placeholder fields - m_bSwitchOff_PlaceHolderView = pCurrentViewOptions->IsShowPlaceHolderFields(); - //switch off display of hidden characters if on and hidden characters are in use - m_bSwitchOff_HiddenChar = pCurrentViewOptions->IsShowHiddenChar() && m_rShell.GetDoc()->ContainsHiddenChars(); - //switch off display of hidden paragraphs if on and hidden paragraphs are in use - m_bSwitchOff_HiddenParagraphs = pCurrentViewOptions->IsShowHiddenPara(); - if(m_bSwitchOff_HiddenParagraphs) - { - const SwFieldType* pFldType = m_rShell.GetDoc()->GetSysFldType(RES_HIDDENPARAFLD); - if(!pFldType || !pFldType->GetDepends()) - m_bSwitchOff_HiddenParagraphs = false; - } - m_bSwitchOff_IsShowHiddenField = pCurrentViewOptions->IsShowHiddenField(); - if(m_bSwitchOff_IsShowHiddenField) - { - const SwFieldType* pFldType = m_rShell.GetDoc()->GetSysFldType(RES_HIDDENTXTFLD); - if( !pFldType || !pFldType->GetDepends()) - m_bSwitchOff_IsShowHiddenField = false; - } - - bApplyViewOptions |= m_bSwitchOff_PlaceHolderView; - bApplyViewOptions |= m_bSwitchOff_HiddenChar; - bApplyViewOptions |= m_bSwitchOff_HiddenParagraphs; - bApplyViewOptions |= m_bSwitchOff_IsShowHiddenField; + bApplyViewOptions |= m_bToggle_PlaceHolderView; + bApplyViewOptions |= m_bToggle_HiddenChar; + bApplyViewOptions |= m_bToggle_HiddenField; + bApplyViewOptions |= m_bToggle_HiddenParagraphs; if(bApplyViewOptions) { - m_pViewOption = new SwViewOption(*m_rShell.GetViewOptions()); + m_pViewOption = new SwViewOption( *pCurrentViewOptions ); + + // set flag to hint that everything should be formatted for printing, + // (needed at some places to print hidden text if that option is set in the dialog, etc.) + m_pViewOption->SetPrinting( TRUE ); + if(m_bSwitchOff_IsFldName) m_pViewOption->SetFldName(FALSE); - if(m_bSwitchOff_PlaceHolderView) - m_pViewOption->SetShowPlaceHolderFields(FALSE); - if(m_bSwitchOff_HiddenChar) - m_pViewOption->SetShowHiddenChar(FALSE); - if(m_bSwitchOff_HiddenParagraphs) - m_pViewOption->SetShowHiddenPara(FALSE); - if(m_bSwitchOff_IsShowHiddenField) - m_pViewOption->SetShowHiddenField(FALSE); + if(m_bToggle_PlaceHolderView) + m_pViewOption->SetShowPlaceHolderFields( !pCurrentViewOptions->IsShowPlaceHolderFields() ); + if(m_bToggle_HiddenChar) + m_pViewOption->SetShowHiddenChar( !pCurrentViewOptions->IsShowHiddenChar( TRUE ) ); + if(m_bToggle_HiddenField) + m_pViewOption->SetShowHiddenField( !pCurrentViewOptions->IsShowHiddenField() ); + if(m_bToggle_HiddenParagraphs) + m_pViewOption->SetShowHiddenPara( !pCurrentViewOptions->IsShowHiddenPara() ); SW_MOD()->ApplyUsrPref(*m_pViewOption, &m_rShell.GetView(), VIEWOPT_DEST_VIEW_ONLY ); } + } @@ -4038,18 +4068,21 @@ SwViewOptionAdjust_Impl::~SwViewOptionAdjust_Impl() { if(m_pViewOption) { + m_pViewOption->SetPrinting( FALSE ); + + const SwViewOption* pCurrentViewOptions = m_rShell.GetViewOptions(); if(m_bSwitchOff_IsFldName) m_pViewOption->SetFldName(TRUE); - if(m_bSwitchOff_PlaceHolderView) - m_pViewOption->SetShowPlaceHolderFields(TRUE); - if(m_bSwitchOff_HiddenChar) - m_pViewOption->SetShowHiddenChar(TRUE); - if(m_bSwitchOff_HiddenParagraphs) - m_pViewOption->SetShowHiddenPara(TRUE); - if(m_bSwitchOff_IsShowHiddenField) - m_pViewOption->SetShowHiddenField(TRUE); + if(m_bToggle_HiddenChar) + m_pViewOption->SetShowHiddenChar( !pCurrentViewOptions->IsShowHiddenChar() ); + if(m_bToggle_HiddenField) + m_pViewOption->SetShowHiddenField( !pCurrentViewOptions->IsShowHiddenField() ); + if(m_bToggle_HiddenParagraphs) + m_pViewOption->SetShowHiddenPara( !pCurrentViewOptions->IsShowHiddenPara() ); + if(m_bToggle_PlaceHolderView) + m_pViewOption->SetShowPlaceHolderFields( !pCurrentViewOptions->IsShowPlaceHolderFields() ); SW_MOD()->ApplyUsrPref(*m_pViewOption, &m_rShell.GetView(), VIEWOPT_DEST_VIEW_ONLY ); - delete m_pViewOption; + delete m_pViewOption; m_pViewOption = NULL; } } -- cgit From ff016bd9d3e87d93db950c60ad7ccb5c31b5fa7a Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Thu, 3 Dec 2009 17:24:39 +0000 Subject: cmcfixes68: #i107420# remove trivial warnings from sw with newer gcc --- sw/source/core/unocore/unotext.cxx | 4 ++-- sw/source/ui/uiview/srcview.cxx | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'sw') diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index 7ae4b209f49f..ee1055b276c9 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -270,8 +270,8 @@ void SwXText::insertString(const uno::Reference< text::XTextRange >& xTextRange, sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( OTextCursorHelper::getUnoTunnelId()) )); } - if(pRange && pRange->GetDoc() == GetDoc() || - pCursor && pCursor->GetDoc() == GetDoc()) + if( (pRange && pRange->GetDoc() == GetDoc()) || + (pCursor && pCursor->GetDoc() == GetDoc()) ) { const SwStartNode* pOwnStartNode = GetStartNode(); if(pCursor) diff --git a/sw/source/ui/uiview/srcview.cxx b/sw/source/ui/uiview/srcview.cxx index d30e85c5ee71..e93abdf73b15 100644 --- a/sw/source/ui/uiview/srcview.cxx +++ b/sw/source/ui/uiview/srcview.cxx @@ -717,6 +717,7 @@ USHORT SwSrcView::StartSearchAndReplace(const SvxSearchItem& rSearchItem, if(!bApi) + { if(bNotFoundMessage) { InfoBox( 0, SW_RES(MSG_NOT_FOUND)).Execute(); @@ -728,6 +729,7 @@ USHORT SwSrcView::StartSearchAndReplace(const SvxSearchItem& rSearchItem, pTextView->SetSelection( TextSelection( aPaM, aPaM ) ); StartSearchAndReplace( rSearchItem, FALSE, FALSE, TRUE ); } + } } return nFound; } -- cgit From 8a75134b7668c04ee8b8bab2d49a84d3540a702a Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Mon, 7 Dec 2009 14:11:32 +0100 Subject: #i104312# fixed print objetcs for pictures and graphics; nopw works for drawing objects as well and does not effect form controls --- sw/source/core/doc/notxtfrm.cxx | 2 +- sw/source/core/inc/cellfrm.hxx | 2 +- sw/source/core/inc/flyfrm.hxx | 2 +- sw/source/core/inc/frame.hxx | 3 ++- sw/source/core/inc/layfrm.hxx | 2 +- sw/source/core/inc/notxtfrm.hxx | 2 +- sw/source/core/inc/rootfrm.hxx | 2 +- sw/source/core/inc/tabfrm.hxx | 2 +- sw/source/core/inc/txtfrm.hxx | 2 +- sw/source/core/inc/viewimp.hxx | 10 ++++++---- sw/source/core/layout/paintfrm.cxx | 22 +++++++++++----------- sw/source/core/layout/unusedf.cxx | 2 +- sw/source/core/text/frmpaint.cxx | 2 +- sw/source/core/view/vdraw.cxx | 8 ++++++++ sw/source/core/view/vprint.cxx | 16 +++++++++------- sw/source/ui/config/optdlg.src | 2 +- sw/source/ui/uno/unotxdoc.cxx | 4 +++- 17 files changed, 50 insertions(+), 35 deletions(-) mode change 100644 => 100755 sw/source/ui/config/optdlg.src (limited to 'sw') diff --git a/sw/source/core/doc/notxtfrm.cxx b/sw/source/core/doc/notxtfrm.cxx index 9f464aac5424..4a8ecf7ff09a 100644 --- a/sw/source/core/doc/notxtfrm.cxx +++ b/sw/source/core/doc/notxtfrm.cxx @@ -269,7 +269,7 @@ void lcl_ClearArea( const SwFrm &rFrm, |* *************************************************************************/ -void SwNoTxtFrm::Paint( const SwRect &rRect ) const +void SwNoTxtFrm::Paint( const SwRect &rRect, const SwPrtOptions * /*pPrintData*/ ) const { if ( Frm().IsEmpty() ) return; diff --git a/sw/source/core/inc/cellfrm.hxx b/sw/source/core/inc/cellfrm.hxx index c8bbc7be70c6..0825ccc2dfd7 100644 --- a/sw/source/core/inc/cellfrm.hxx +++ b/sw/source/core/inc/cellfrm.hxx @@ -51,7 +51,7 @@ public: virtual BOOL GetCrsrOfst( SwPosition *, Point&, SwCrsrMoveState* = 0 ) const; virtual void Modify( SfxPoolItem*, SfxPoolItem* ); - virtual void Paint( const SwRect& ) const; + virtual void Paint( const SwRect&, const SwPrtOptions *pPrintData = NULL ) const; virtual void CheckDirection( BOOL bVert ); const SwTableBox *GetTabBox() const { return pTabBox; } diff --git a/sw/source/core/inc/flyfrm.hxx b/sw/source/core/inc/flyfrm.hxx index dc8975f3fd47..031b93e7ce21 100644 --- a/sw/source/core/inc/flyfrm.hxx +++ b/sw/source/core/inc/flyfrm.hxx @@ -161,7 +161,7 @@ public: virtual void Modify( SfxPoolItem*, SfxPoolItem* ); // erfrage vom Client Informationen virtual BOOL GetInfo( SfxPoolItem& ) const; - virtual void Paint( const SwRect& ) const; + virtual void Paint( const SwRect&, const SwPrtOptions *pPrintData = NULL ) const; virtual Size ChgSize( const Size& aNewSize ); virtual BOOL GetCrsrOfst( SwPosition *, Point&, SwCrsrMoveState* = 0 ) const; diff --git a/sw/source/core/inc/frame.hxx b/sw/source/core/inc/frame.hxx index 02c8040b83c3..1fe6e00af3e5 100644 --- a/sw/source/core/inc/frame.hxx +++ b/sw/source/core/inc/frame.hxx @@ -56,6 +56,7 @@ class SvxBrushItem; class SwSelectionList; struct SwPosition; struct SwCrsrMoveState; +class SwPrtOptions; // --> OD 2004-07-06 #i28701# class SwSortedObjs; @@ -828,7 +829,7 @@ public: SwCrsrMoveState* = 0 ) const; virtual BOOL GetCharRect( SwRect &, const SwPosition&, SwCrsrMoveState* = 0 ) const; - virtual void Paint( const SwRect& ) const; + virtual void Paint( const SwRect&, const SwPrtOptions *pPrintData = NULL ) const; // der "kurze Dienstweg" zwischen den Frames und der Formatierung. // Wer den void* falsch Casted ist selbst schuld! diff --git a/sw/source/core/inc/layfrm.hxx b/sw/source/core/inc/layfrm.hxx index 76262d18a894..e3ee5edf60c1 100644 --- a/sw/source/core/inc/layfrm.hxx +++ b/sw/source/core/inc/layfrm.hxx @@ -108,7 +108,7 @@ public: SwLayoutFrm( SwFrmFmt* ); ~SwLayoutFrm(); - virtual void Paint( const SwRect& ) const; + virtual void Paint( const SwRect&, const SwPrtOptions *pPrintData = NULL ) const; const SwFrm *Lower() const { return pLower; } SwFrm *Lower() { return pLower; } const SwCntntFrm *ContainsCntnt() const; diff --git a/sw/source/core/inc/notxtfrm.hxx b/sw/source/core/inc/notxtfrm.hxx index 81d63e733f9c..ff739b530758 100644 --- a/sw/source/core/inc/notxtfrm.hxx +++ b/sw/source/core/inc/notxtfrm.hxx @@ -59,7 +59,7 @@ public: ~SwNoTxtFrm(); virtual void Modify( SfxPoolItem*, SfxPoolItem* ); - virtual void Paint(const SwRect& ) const; + virtual void Paint(const SwRect&, const SwPrtOptions *pPrintData = NULL ) const; virtual BOOL GetCharRect( SwRect &, const SwPosition&, SwCrsrMoveState* = 0) const; BOOL GetCrsrOfst(SwPosition* pPos, Point& aPoint, diff --git a/sw/source/core/inc/rootfrm.hxx b/sw/source/core/inc/rootfrm.hxx index c04b30792b53..7e9b0eeb61d9 100644 --- a/sw/source/core/inc/rootfrm.hxx +++ b/sw/source/core/inc/rootfrm.hxx @@ -200,7 +200,7 @@ public: virtual BOOL GetCrsrOfst( SwPosition *, Point&, SwCrsrMoveState* = 0 ) const; - virtual void Paint( const SwRect& ) const; + virtual void Paint( const SwRect&, const SwPrtOptions *pPrintData = NULL ) const; virtual SwTwips ShrinkFrm( SwTwips, BOOL bTst = FALSE, BOOL bInfo = FALSE ); virtual SwTwips GrowFrm ( SwTwips, BOOL bTst = FALSE, BOOL bInfo = FALSE ); #ifndef PRODUCT diff --git a/sw/source/core/inc/tabfrm.hxx b/sw/source/core/inc/tabfrm.hxx index b41ba4214aa0..bbd2931d7839 100644 --- a/sw/source/core/inc/tabfrm.hxx +++ b/sw/source/core/inc/tabfrm.hxx @@ -132,7 +132,7 @@ public: virtual void Modify( SfxPoolItem*, SfxPoolItem* ); virtual BOOL GetInfo( SfxPoolItem &rHnt ) const; - virtual void Paint( const SwRect& ) const; + virtual void Paint( const SwRect&, const SwPrtOptions *pPrintData = NULL ) const; virtual void CheckDirection( BOOL bVert ); virtual void Cut(); diff --git a/sw/source/core/inc/txtfrm.hxx b/sw/source/core/inc/txtfrm.hxx index b0b2b807ab43..bdfdf3efde74 100644 --- a/sw/source/core/inc/txtfrm.hxx +++ b/sw/source/core/inc/txtfrm.hxx @@ -296,7 +296,7 @@ public: void PaintExtraData( const SwRect & rRect ) const; //Seitennummer usw. SwRect Paint(); - virtual void Paint( const SwRect & ) const; + virtual void Paint( const SwRect &, const SwPrtOptions *pPrintData = NULL ) const; virtual void Modify( SfxPoolItem*, SfxPoolItem* ); virtual sal_Bool GetInfo( SfxPoolItem & ) const; diff --git a/sw/source/core/inc/viewimp.hxx b/sw/source/core/inc/viewimp.hxx index eba323bd52a2..026b293a827c 100644 --- a/sw/source/core/inc/viewimp.hxx +++ b/sw/source/core/inc/viewimp.hxx @@ -57,6 +57,7 @@ struct SdrPaintProcRec; class SwAccessibleMap; class SdrObject; class Fraction; +class SwPrtOptions; // OD 12.12.2002 #103492# class SwPagePreviewLayout; // OD 15.01.2003 #103492# @@ -270,10 +271,11 @@ public: // direction at the outliner of the draw view for painting layers // and . // OD 25.06.2003 #108784# - correct type of 1st parameter - void PaintLayer ( const SdrLayerID _nLayerID, - const SwRect& _rRect, - const Color* _pPageBackgrdColor = 0, - const bool _bIsPageRightToLeft = false ) const; + void PaintLayer( const SdrLayerID _nLayerID, + const SwPrtOptions *pPrintData, + const SwRect& _rRect, + const Color* _pPageBackgrdColor = 0, + const bool _bIsPageRightToLeft = false ) const; //wird als Link an die DrawEngine uebergeben, entscheidet was wie //gepaintet wird oder nicht. diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx index 7dcbc4ef80a9..6181269b96b8 100644 --- a/sw/source/core/layout/paintfrm.cxx +++ b/sw/source/core/layout/paintfrm.cxx @@ -2740,7 +2740,7 @@ void SwTabFrmPainter::Insert( SwLineEntry& rNew, bool bHori ) |* |*************************************************************************/ -void SwRootFrm::Paint( const SwRect& rRect ) const +void SwRootFrm::Paint( const SwRect& rRect, const SwPrtOptions *pPrintData ) const { ASSERT( Lower() && Lower()->IsPageFrm(), "Lower der Root keine Seite." ); @@ -2939,7 +2939,7 @@ void SwRootFrm::Paint( const SwRect& rRect ) const // OD 29.08.2002 #102450# - add 3rd parameter // OD 09.12.2002 #103045# - add 4th parameter for horizontal text direction. const IDocumentDrawModelAccess* pIDDMA = pSh->getIDocumentDrawModelAccess(); - pSh->Imp()->PaintLayer( pIDDMA->GetHellId(), aPaintRect, + pSh->Imp()->PaintLayer( pIDDMA->GetHellId(), pPrintData, aPaintRect, &aPageBackgrdColor, (pPage->IsRightToLeft() ? true : false) ); pLines->PaintLines( pSh->GetOut() ); pLines->LockLines( FALSE ); @@ -2972,7 +2972,7 @@ void SwRootFrm::Paint( const SwRect& rRect ) const { /// OD 29.08.2002 #102450# - add 3rd parameter // OD 09.12.2002 #103045# - add 4th parameter for horizontal text direction. - pSh->Imp()->PaintLayer( pSh->GetDoc()->GetHeavenId(), aPaintRect, + pSh->Imp()->PaintLayer( pSh->GetDoc()->GetHeavenId(), pPrintData, aPaintRect, &aPageBackgrdColor, (pPage->IsRightToLeft() ? true : false) ); } @@ -3190,7 +3190,7 @@ SwShortCut::SwShortCut( const SwFrm& rFrm, const SwRect& rRect ) } } -void SwLayoutFrm::Paint( const SwRect& rRect ) const +void SwLayoutFrm::Paint( const SwRect& rRect, const SwPrtOptions *pPrintData ) const { ViewShell *pSh = GetShell(); @@ -3478,7 +3478,7 @@ BOOL SwFlyFrm::IsPaint( SdrObject *pObj, const ViewShell *pSh ) /************************************************************************* |* SwCellFrm::Paint( const SwRect& ) const |*************************************************************************/ -void SwCellFrm::Paint( const SwRect& rRect ) const +void SwCellFrm::Paint( const SwRect& rRect, const SwPrtOptions *pPrintData ) const { if ( GetLayoutRowSpan() >= 1 ) SwLayoutFrm::Paint( rRect ); @@ -3497,7 +3497,7 @@ void SwCellFrm::Paint( const SwRect& rRect ) const void MA_FASTCALL lcl_PaintLowerBorders( const SwLayoutFrm *pLay, const SwRect &rRect, const SwPageFrm *pPage ); -void SwFlyFrm::Paint( const SwRect& rRect ) const +void SwFlyFrm::Paint( const SwRect& rRect, const SwPrtOptions *pPrintData ) const { //wegen der Ueberlappung von Rahmen und Zeichenobjekten muessen die //Flys ihre Umrandung (und die der Innenliegenden) direkt ausgeben. @@ -3732,7 +3732,7 @@ void SwFlyFrm::Paint( const SwRect& rRect ) const |* |*************************************************************************/ -void SwTabFrm::Paint( const SwRect& rRect ) const +void SwTabFrm::Paint( const SwRect& rRect, const SwPrtOptions *pPrintData ) const { if ( pGlobalShell->GetViewOptions()->IsTable() ) { @@ -6438,10 +6438,10 @@ void SwFrm::Retouche( const SwPageFrm * pPage, const SwRect &rRect ) const // OD 09.12.2002 #103045# - add 4th parameter for horizontal text direction. const IDocumentDrawModelAccess* pIDDMA = pSh->getIDocumentDrawModelAccess(); - pSh->Imp()->PaintLayer( pIDDMA->GetHellId(), + pSh->Imp()->PaintLayer( pIDDMA->GetHellId(), 0, aRetouchePart, &aPageBackgrdColor, (pPage->IsRightToLeft() ? true : false) ); - pSh->Imp()->PaintLayer( pIDDMA->GetHeavenId(), + pSh->Imp()->PaintLayer( pIDDMA->GetHeavenId(), 0, aRetouchePart, &aPageBackgrdColor, (pPage->IsRightToLeft() ? true : false) ); } @@ -6691,14 +6691,14 @@ Graphic SwFlyFrmFmt::MakeGraphic( ImageMap* pMap ) // OD 30.08.2002 #102450# - add 3rd parameter // OD 09.12.2002 #103045# - add 4th parameter for horizontal text direction. const IDocumentDrawModelAccess* pIDDMA = pSh->getIDocumentDrawModelAccess(); - pImp->PaintLayer( pIDDMA->GetHellId(), aOut, &aPageBackgrdColor, + pImp->PaintLayer( pIDDMA->GetHellId(), 0, aOut, &aPageBackgrdColor, (pFlyPage->IsRightToLeft() ? true : false) ); pLines->PaintLines( &aDev ); if ( pFly->IsFlyInCntFrm() ) pFly->Paint( aOut ); pLines->PaintLines( &aDev ); /// OD 30.08.2002 #102450# - add 3rd parameter - pImp->PaintLayer( pIDDMA->GetHeavenId(), aOut, &aPageBackgrdColor, + pImp->PaintLayer( pIDDMA->GetHeavenId(), 0, aOut, &aPageBackgrdColor, (pFlyPage->IsRightToLeft() ? true : false) ); pLines->PaintLines( &aDev ); DELETEZ( pLines ); diff --git a/sw/source/core/layout/unusedf.cxx b/sw/source/core/layout/unusedf.cxx index e7d602ae5aba..5eb230f0b3ba 100644 --- a/sw/source/core/layout/unusedf.cxx +++ b/sw/source/core/layout/unusedf.cxx @@ -44,7 +44,7 @@ void SwFrm::Format( const SwBorderAttrs * ) ASSERT( FALSE, "Format() der Basisklasse gerufen." ); } -void SwFrm::Paint(const SwRect &) const +void SwFrm::Paint(const SwRect &, const SwPrtOptions * ) const { ASSERT( FALSE, "Paint() der Basisklasse gerufen." ); } diff --git a/sw/source/core/text/frmpaint.cxx b/sw/source/core/text/frmpaint.cxx index 5a88599c6e35..1492f1167f38 100644 --- a/sw/source/core/text/frmpaint.cxx +++ b/sw/source/core/text/frmpaint.cxx @@ -600,7 +600,7 @@ sal_Bool SwTxtFrm::PaintEmpty( const SwRect &rRect, sal_Bool bCheck ) const * SwTxtFrm::Paint() *************************************************************************/ -void SwTxtFrm::Paint( const SwRect &rRect ) const +void SwTxtFrm::Paint( const SwRect &rRect, const SwPrtOptions * /*pPrintData*/ ) const { ResetRepaint(); diff --git a/sw/source/core/view/vdraw.cxx b/sw/source/core/view/vdraw.cxx index 7429eb5c444d..b58026e33a72 100644 --- a/sw/source/core/view/vdraw.cxx +++ b/sw/source/core/view/vdraw.cxx @@ -57,6 +57,7 @@ #include "viewimp.hxx" #include "dflyobj.hxx" #include "viewopt.hxx" +#include "swprtopt.hxx" #include "dcontact.hxx" #include "dview.hxx" #include "flyfrm.hxx" @@ -184,6 +185,7 @@ void SwViewImp::UnlockPaint() // outliner of the draw view for painting layers and . // OD 25.06.2003 #108784# - correct type of 1st parameter void SwViewImp::PaintLayer( const SdrLayerID _nLayerID, + const SwPrtOptions * _pPrintData, const SwRect& , const Color* _pPageBackgrdColor, const bool _bIsPageRightToLeft ) const @@ -230,6 +232,12 @@ void SwViewImp::PaintLayer( const SdrLayerID _nLayerID, } pOutDev->Push( PUSH_LINECOLOR ); // #114231# + if (_pPrintData) + { + // hide drawings but not form controls (form controls are handled elsewhere) + SdrView &rSdrView = const_cast< SdrView & >(GetPageView()->GetView()); + rSdrView.setHideDraw( !_pPrintData->IsPrintDraw() ); + } GetPageView()->DrawLayer(_nLayerID, pOutDev); pOutDev->Pop(); diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index 715c74870f2f..ed23a7b251e6 100755 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -404,7 +404,7 @@ SwPrintUIOptions::SwPrintUIOptions( bool bWeb, bool bSwSrcView ) : // create a bool option for graphics m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 4 ), aLocalizedStrings.GetString( 5 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintTablesGraphicsAndDiagrams" ) ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintPicturesAndObjects" ) ), sal_True ); if (!bWeb) { @@ -611,9 +611,11 @@ bool SwPrintUIOptions::IsPrintTables() const // take care of different property names for the option. // for compatibility the old name should win - bool bRes = getBoolValue( "PrintTablesGraphicsAndDiagrams", sal_True ); - bRes = getBoolValue( "PrintTables", bRes ); - return bRes; +// bool bRes = getBoolValue( "PrintTablesGraphicsAndDiagrams", sal_True ); +// bRes = getBoolValue( "PrintTables", bRes ); +// return bRes; + // for now it was decided that tables should always be printed + return true; } bool SwPrintUIOptions::IsPrintGraphics() const @@ -621,7 +623,7 @@ bool SwPrintUIOptions::IsPrintGraphics() const // take care of different property names for the option. // for compatibility the old name should win - bool bRes = getBoolValue( "PrintTablesGraphicsAndDiagrams", sal_True ); + bool bRes = getBoolValue( "PrintPicturesAndObjects", sal_True ); bRes = getBoolValue( "PrintGraphics", bRes ); return bRes; } @@ -631,7 +633,7 @@ bool SwPrintUIOptions::IsPrintDrawings() const // take care of different property names for the option. // for compatibility the old name should win - bool bRes = getBoolValue( "PrintTablesGraphicsAndDiagrams", sal_True ); + bool bRes = getBoolValue( "PrintPicturesAndObjects", sal_True ); bRes = getBoolValue( "PrintDrawings", bRes ); return bRes; } @@ -1186,7 +1188,7 @@ sal_Bool ViewShell::PrintOrPDFExport( rPrintData.GetRenderData().m_pPostItShell : pShell; ::SetSwVisArea( pViewSh2, pStPage->Frm() ); - pStPage->GetUpper()->Paint( pStPage->Frm() ); + pStPage->GetUpper()->Paint( pStPage->Frm(), &rPrintData ); SwPaintQueue::Repaint(); } //Zus. Scope wg. CurShell! diff --git a/sw/source/ui/config/optdlg.src b/sw/source/ui/config/optdlg.src old mode 100644 new mode 100755 index 7c839834234f..ce1d9ae22942 --- a/sw/source/ui/config/optdlg.src +++ b/sw/source/ui/config/optdlg.src @@ -944,7 +944,7 @@ StringArray STR_PRINTOPTUI < "Contents"; >; < "Page ba~ckground"; >; < "Specifies whether to include colors and objects that are inserted to the background of the page (Format - Page - Background) in the printed document."; >; - < "~Graphics and diagrams"; >; + < "~Pictures and objects"; >; < "Specifies whether the graphics of your text document are printed"; >; < "Hidden te~xt"; >; < "Enable this option to print text that is marked as hidden."; >; diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index 51fdb6779778..c7888f754ff0 100755 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -3998,7 +3998,9 @@ void SwXDocumentPropertyHelper::onChange() /*****************************************************************************/ -SwViewOptionAdjust_Impl::SwViewOptionAdjust_Impl( SwWrtShell& rSh, const SwPrtOptions *pPrtOptions ) : +SwViewOptionAdjust_Impl::SwViewOptionAdjust_Impl( + SwWrtShell& rSh, + const SwPrtOptions *pPrtOptions ) : m_pViewOption(0), m_rShell(rSh) { -- cgit From 34b5a53a562ac9bb3387e1e5603cd04165a268ae Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Tue, 8 Dec 2009 13:00:42 +0100 Subject: #i105728#, #i105730#, #i105727# intelli UI thingies --- sw/inc/docsh.hxx | 1 + sw/inc/printdata.hxx | 3 ++- sw/inc/viewsh.hxx | 2 +- sw/source/core/doc/doc.cxx | 22 +++++++++++++---- sw/source/core/view/viewpg.cxx | 30 +++-------------------- sw/source/core/view/vprint.cxx | 55 ++++++++++++------------------------------ sw/source/ui/inc/srcview.hxx | 2 +- sw/source/ui/uno/unotxdoc.cxx | 38 +++++++++++++++++++---------- 8 files changed, 65 insertions(+), 88 deletions(-) mode change 100644 => 100755 sw/inc/docsh.hxx mode change 100644 => 100755 sw/inc/viewsh.hxx mode change 100644 => 100755 sw/source/core/view/viewpg.cxx mode change 100644 => 100755 sw/source/ui/inc/srcview.hxx (limited to 'sw') diff --git a/sw/inc/docsh.hxx b/sw/inc/docsh.hxx old mode 100644 new mode 100755 index 6ed3f6d652bd..df06af8a8a36 --- a/sw/inc/docsh.hxx +++ b/sw/inc/docsh.hxx @@ -183,6 +183,7 @@ public: // Doc rausreichen aber VORSICHT inline SwDoc* GetDoc() { return pDoc; } + inline const SwDoc* GetDoc() const { return pDoc; } IDocumentDeviceAccess* getIDocumentDeviceAccess(); const IDocumentSettingAccess* getIDocumentSettingAccess() const; IDocumentChartDataProviderAccess* getIDocumentChartDataProviderAccess(); diff --git a/sw/inc/printdata.hxx b/sw/inc/printdata.hxx index 2df487f69838..356ecb30b79e 100755 --- a/sw/inc/printdata.hxx +++ b/sw/inc/printdata.hxx @@ -50,6 +50,7 @@ class OutputDevice; class SwViewOptionAdjust_Impl; class SwPrtOptions; class SwWrtShell; +class SfxViewShell; //////////////////////////////////////////////////////////// @@ -60,7 +61,7 @@ class SwPrintUIOptions : public vcl::PrinterOptionsHelper OutputDevice* m_pLast; public: - SwPrintUIOptions( bool bWeb, bool bSwSrcView ); + SwPrintUIOptions( bool bWeb, bool bSwSrcView, bool bHasSelection, bool bHasPostIts ); ~SwPrintUIOptions(); bool processPropertiesAndCheckFormat( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& i_rNewProp ); diff --git a/sw/inc/viewsh.hxx b/sw/inc/viewsh.hxx old mode 100644 new mode 100755 index 03d1c9d64184..30624f23c2ef --- a/sw/inc/viewsh.hxx +++ b/sw/inc/viewsh.hxx @@ -387,7 +387,7 @@ public: SwDoc * FillPrtDoc( SwDoc* pPrtDoc, const SfxPrinter* pPrt ); //Wird intern fuer die Shell gerufen die Druckt. Formatiert die Seiten. - void CalcPagesForPrint( sal_uInt16 nMax, SfxProgress* pProgress = 0 ); + void CalcPagesForPrint( sal_uInt16 nMax ); //All about fields. void UpdateFlds(sal_Bool bCloseDB = sal_False); diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index e2b94926380b..89323951c7e2 100755 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -1078,10 +1078,12 @@ USHORT _PostItFld::GetPageNo( } -void lcl_GetPostIts( +bool lcl_GetPostIts( IDocumentFieldsAccess* pIDFA, - _SetGetExpFlds& rSrtLst ) + _SetGetExpFlds * pSrtLst ) { + bool bHasPostIts = false; + SwFieldType* pFldType = pIDFA->GetSysFldType( RES_POSTITFLD ); DBG_ASSERT( pFldType, "kein PostItType ? "); @@ -1093,14 +1095,24 @@ void lcl_GetPostIts( const SwTxtFld* pTxtFld; for( pLast = aIter.First( TYPE(SwFmtFld)); pLast; pLast = aIter.Next() ) + { if( 0 != ( pTxtFld = ((SwFmtFld*)pLast)->GetTxtFld() ) && pTxtFld->GetTxtNode().GetNodes().IsDocNodes() ) { - SwNodeIndex aIdx( pTxtFld->GetTxtNode() ); - _PostItFld* pNew = new _PostItFld( aIdx, pTxtFld ); - rSrtLst.Insert( pNew ); + bHasPostIts = true; + if (pSrtLst) + { + SwNodeIndex aIdx( pTxtFld->GetTxtNode() ); + _PostItFld* pNew = new _PostItFld( aIdx, pTxtFld ); + pSrtLst->Insert( pNew ); + } + else + break; // we just wanted to check for the existence of postits ... } + } } + + return bHasPostIts; } diff --git a/sw/source/core/view/viewpg.cxx b/sw/source/core/view/viewpg.cxx old mode 100644 new mode 100755 index 379f8b42d0c5..61594065c3db --- a/sw/source/core/view/viewpg.cxx +++ b/sw/source/core/view/viewpg.cxx @@ -131,25 +131,7 @@ void ViewShell::PrintProspect( aShell.PrepareForPrint( rPrintData ); -#if 0 // applying view options and formatting the dcoument should now only be done in getRendererCount! - // gibt es versteckte Absatzfelder, unnoetig wenn die Absaetze bereits - // ausgeblendet sind. - int bHiddenFlds = FALSE; - SwFieldType* pFldType = 0; - if ( GetViewOptions()->IsShowHiddenPara() ) - { - pFldType = getIDocumentFieldsAccess()->GetSysFldType( RES_HIDDENPARAFLD ); - bHiddenFlds = 0 != pFldType->GetDepends(); - if( bHiddenFlds ) - { - SwMsgPoolItem aHnt( RES_HIDDENPARA_PRINT ); - pFldType->Modify( &aHnt, 0); - } - } - - // Seiten fuers Drucken formatieren - aShell.CalcPagesForPrint( nPageMax, 0 ); -#endif + //!! applying view options and formatting the dcoument should now only be done in getRendererCount! MapMode aMapMode( MAP_TWIP ); Size aPrtSize( pPrinter->PixelToLogic( pPrinter->GetPaperSizePixel(), aMapMode ) ); @@ -271,14 +253,8 @@ void ViewShell::PrintProspect( SwPaintQueue::Repaint(); -#if 0 // applying view options and formatting the dcoument should now only be done in getRendererCount! - if( bHiddenFlds ) - { - SwMsgPoolItem aHnt( RES_HIDDENPARA_PRINT ); - pFldType->Modify( &aHnt, 0); - CalcPagesForPrint( nPageMax ); - } -#endif + //!! applying/modifying view options and formatting the dcoument should now only be done in getRendererCount! + pFntCache->Flush(); // restore settings of OutputDevice (should be done always now since the diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index ed23a7b251e6..66aa3741148f 100755 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -102,7 +102,7 @@ #define JOBSET_ERR_ISSTARTET 2 -extern void lcl_GetPostIts( IDocumentFieldsAccess* pIDFA, _SetGetExpFlds& rSrtLst ); +extern bool lcl_GetPostIts( IDocumentFieldsAccess* pIDFA, _SetGetExpFlds * pSrtLst ); using namespace ::com::sun::star; @@ -255,7 +255,7 @@ void SwRenderData::CreatePostItData( SwDoc *pDoc, const SwViewOption *pViewOpt, { DBG_ASSERT( !m_pPostItFields && !m_pPostItDoc && !m_pPostItShell, "some post-it data already exists" ); m_pPostItFields = new _SetGetExpFlds; - lcl_GetPostIts( pDoc, *m_pPostItFields ); + lcl_GetPostIts( pDoc, m_pPostItFields ); m_pPostItDoc = new SwDoc; //!! Disable spell and grammar checking in the temporary document. @@ -357,7 +357,7 @@ void SwRenderData::MakeSwPrtOptions( /*****************************************************************************/ -SwPrintUIOptions::SwPrintUIOptions( bool bWeb, bool bSwSrcView ) : +SwPrintUIOptions::SwPrintUIOptions( bool bWeb, bool bSwSrcView, bool bHasSelection, bool bHasPostIts ) : m_pLast( NULL ) { ResStringArray aLocalizedStrings( SW_RES( STR_PRINTOPTUI ) ); @@ -466,19 +466,22 @@ SwPrintUIOptions::SwPrintUIOptions( bool bWeb, bool bSwSrcView ) : // create a choice for the content to create rtl::OUString aPrintRangeName( RTL_CONSTASCII_USTRINGPARAM( "PrintContent" ) ); - uno::Sequence< rtl::OUString > aChoices( 3 ); - uno::Sequence< rtl::OUString > aHelpText( 3 ); + uno::Sequence< rtl::OUString > aChoices( bHasSelection ? 3 : 2 ); + uno::Sequence< rtl::OUString > aHelpText( bHasSelection ? 3 : 2 ); aChoices[0] = aLocalizedStrings.GetString( 38 ); aHelpText[0] = aLocalizedStrings.GetString( 39 ); aChoices[1] = aLocalizedStrings.GetString( 40 ); aHelpText[1] = aLocalizedStrings.GetString( 41 ); - aChoices[2] = aLocalizedStrings.GetString( 42 ); - aHelpText[2] = aLocalizedStrings.GetString( 43 ); + if (bHasSelection) + { + aChoices[2] = aLocalizedStrings.GetString( 42 ); + aHelpText[2] = aLocalizedStrings.GetString( 43 ); + } m_aUIProperties[nIdx++].Value = getChoiceControlOpt( rtl::OUString(), aHelpText, aPrintRangeName, aChoices, - 0 ); + bHasSelection ? 2 /*enable 'Selection' radio button*/ : 0 /* enable 'All pages' */); // create a an Edit dependent on "Pages" selected vcl::PrinterOptionsHelper::UIControlOptions aPageRangeOpt( aPrintRangeName, 1, sal_True ); m_aUIProperties[nIdx++].Value = getEditControlOpt( rtl::OUString(), @@ -504,6 +507,7 @@ SwPrintUIOptions::SwPrintUIOptions( bool bWeb, bool bSwSrcView ) : aHelpText[0] = aLocalizedStrings.GetString( 25 ); aHelpText[1] = aLocalizedStrings.GetString( 25 ); vcl::PrinterOptionsHelper::UIControlOptions aAnnotOpt( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintProspect" ) ), 0, sal_False ); + aAnnotOpt.mbEnabled = bHasPostIts; m_aUIProperties[ nIdx++ ].Value = getChoiceControlOpt( aLocalizedStrings.GetString( 26 ), aHelpText, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintAnnotationMode" ) ), @@ -830,16 +834,10 @@ void lcl_SetState( SfxProgress& rProgress, ULONG nPage, ULONG nMax, -void ViewShell::CalcPagesForPrint( USHORT nMax, SfxProgress* pProgress ) +void ViewShell::CalcPagesForPrint( USHORT nMax ) { SET_CURR_SHELL( this ); - //Seitenweise durchformatieren, by the way kann die Statusleiste - //angetriggert werden, damit der Anwender sieht worauf er wartet. - //Damit der Vorgang moeglichst transparent gestaltet werden kann - //Versuchen wir mal eine Schaetzung. - SfxPrinter* pPrt = getIDocumentDeviceAccess()->getPrinter( false ); - BOOL bPrtJob = pPrt ? pPrt->IsJobActive() : FALSE; SwRootFrm* pLayout = GetLayout(); // ULONG nStatMax = pLayout->GetPageNum(); @@ -849,12 +847,6 @@ void ViewShell::CalcPagesForPrint( USHORT nMax, SfxProgress* pProgress ) pLayout->StartAllAction(); for ( USHORT i = 1; pPage && i <= nMax; pPage = pPage->GetNext(), ++i ) { - if ( ( bPrtJob && !pPrt->IsJobActive() ) || Imp()->IsStopPrt() ) - break; - - if ( ( bPrtJob && !pPrt->IsJobActive() ) || Imp()->IsStopPrt() ) - break; - pPage->Calc(); SwRect aOldVis( VisArea() ); aVisArea = pPage->Frm(); @@ -868,12 +860,8 @@ void ViewShell::CalcPagesForPrint( USHORT nMax, SfxProgress* pProgress ) aVisArea = aOldVis; //Zuruecksetzen wg. der Paints! Imp()->SetFirstVisPageInvalid(); - SwPaintQueue::Repaint(); +// SwPaintQueue::Repaint(); } - - if (pProgress) - aAction.SetProgress( NULL ); - pLayout->EndAllAction(); } @@ -1153,20 +1141,7 @@ sal_Bool ViewShell::PrintOrPDFExport( } DBG_ASSERT( pStPage, "failed to get start page" ); -#if 0 // applying view options and formatting the dcoument should now only be done in getRendererCount! - // benoetigte Seiten fuers Drucken formatieren - pShell->CalcPagesForPrint( (USHORT)nPage, 0 ); - - // Some field types, can require a valid layout - // (expression fields in tables). For these we do an UpdateFlds - // here after calculation of the pages. - // --> FME 2004-06-21 #i9684# For performance reasons, we do not update - // the fields during pdf export. - // #i56195# prevent update of fields (for mail merge) - if ( !bIsPDFExport && rPrintData.bUpdateFieldsInPrinting ) - pShell->UpdateFlds(TRUE); - // <-- -#endif + //!! applying view options and formatting the dcoument should now only be done in getRendererCount! ViewShell *pViewSh2 = nPage == 0 ? /* post-it page? */ rPrintData.GetRenderData().m_pPostItShell : pShell; diff --git a/sw/source/ui/inc/srcview.hxx b/sw/source/ui/inc/srcview.hxx old mode 100644 new mode 100755 index d66096d4418b..687015759243 --- a/sw/source/ui/inc/srcview.hxx +++ b/sw/source/ui/inc/srcview.hxx @@ -28,7 +28,7 @@ * ************************************************************************/ #ifndef _SRCVIEW_HXX -#define _SRCIEW_HXX +#define _SRCVIEW_HXX #include #include diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index c7888f754ff0..9377f7182b18 100755 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -135,6 +135,8 @@ #include #include +#include +#include //#include #include @@ -178,6 +180,25 @@ using ::osl::FileBase; * ******************************************************************************/ +extern bool lcl_GetPostIts( IDocumentFieldsAccess* pIDFA, _SetGetExpFlds * pSrtLst ); + +SwPrintUIOptions * lcl_GetPrintUIOptions( + SwDocShell * pDocShell, + const SfxViewShell * pView ) +{ + if (!pDocShell) + return NULL; + + const BOOL bWebDoc = NULL != dynamic_cast< const SwWebDocShell * >(pDocShell); + const bool bSwSrcView = NULL != dynamic_cast< const SwSrcView * >(pView); + const SwView * pSwView = dynamic_cast< const SwView * >(pView); + const bool bHasSelection = pSwView ? pSwView->HasSelection( sal_False ) : false; // check for any selection, not just text selection + const bool bHasPostIts = lcl_GetPostIts( pDocShell->GetDoc(), 0 ); + return new SwPrintUIOptions( bWebDoc, bSwSrcView, bHasSelection, bHasPostIts ); +} + +//////////////////////////////////////////////////////////// + SwTxtFmtColl *lcl_GetParaStyle(const String& rCollName, SwDoc* pDoc) { @@ -2614,10 +2635,7 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount( if (!bIsSwSrcView && !m_pRenderData) m_pRenderData = new SwRenderData; if (!m_pPrintUIOptions) - { - const BOOL bWebDoc = (0 != PTR_CAST(SwWebDocShell, pDocShell)); - m_pPrintUIOptions = new SwPrintUIOptions( bWebDoc, bIsSwSrcView ); - } + m_pPrintUIOptions = lcl_GetPrintUIOptions( pDocShell, pView ); bool bFormat = m_pPrintUIOptions->processPropertiesAndCheckFormat( rxOptions ); const bool bIsSkipEmptyPages = !m_pPrintUIOptions->IsPrintEmptyPages( bIsPDFExport ); @@ -2753,11 +2771,8 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SwXTextDocument::getRenderer( // otherwise be provided here! // if( ! m_pRenderData ) // m_pRenderData = new SwRenderData; - if( ! m_pPrintUIOptions ) - { - const BOOL bWebDoc = (0 != PTR_CAST(SwWebDocShell, pDocShell)); - m_pPrintUIOptions = new SwPrintUIOptions( bWebDoc, bIsSwSrcView ); - } + if (!m_pPrintUIOptions) + m_pPrintUIOptions = lcl_GetPrintUIOptions( pDocShell, pView ); m_pPrintUIOptions->processProperties( rxOptions ); const bool bPrintProspect = m_pPrintUIOptions->getBoolValue( "PrintProspect", false ); const bool bIsSkipEmptyPages = !m_pPrintUIOptions->IsPrintEmptyPages( bIsPDFExport ); @@ -2913,10 +2928,7 @@ void SAL_CALL SwXTextDocument::render( if (!bIsSwSrcView && !m_pRenderData) m_pRenderData = new SwRenderData; if (!m_pPrintUIOptions) - { - const BOOL bWebDoc = (0 != PTR_CAST(SwWebDocShell, pDocShell)); - m_pPrintUIOptions = new SwPrintUIOptions( bWebDoc, bIsSwSrcView ); - } + m_pPrintUIOptions = lcl_GetPrintUIOptions( pDocShell, pView ); m_pPrintUIOptions->processProperties( rxOptions ); const bool bPrintProspect = m_pPrintUIOptions->getBoolValue( "PrintProspect", false ); const bool bLastPage = m_pPrintUIOptions->getBoolValue( "IsLastPage", sal_False ); -- cgit From af1e3ee0d10c10d6f30d8700ddc677a86dbf82c3 Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Thu, 10 Dec 2009 11:14:28 +0100 Subject: #i106914# apply configuration settings in UI --- sw/inc/printdata.hxx | 281 +++++++++++++++++++++------------------- sw/source/core/view/vprint.cxx | 105 ++++++++++----- sw/source/ui/config/optdlg.hrc | 8 +- sw/source/ui/config/optdlg.src | 53 +++++--- sw/source/ui/config/optpage.cxx | 50 +++---- sw/source/ui/inc/optpage.hxx | 8 +- sw/source/ui/uno/unotxdoc.cxx | 48 ++++++- 7 files changed, 328 insertions(+), 225 deletions(-) (limited to 'sw') diff --git a/sw/inc/printdata.hxx b/sw/inc/printdata.hxx index 356ecb30b79e..75f16d01ace3 100755 --- a/sw/inc/printdata.hxx +++ b/sw/inc/printdata.hxx @@ -52,6 +52,139 @@ class SwPrtOptions; class SwWrtShell; class SfxViewShell; +// forward declarations +class SwPrintUIOptions; +class SwRenderData; + +//////////////////////////////////////////////////////////// + + +class SwPrintData +{ + const SwPrintUIOptions * m_pPrintUIOptions; // not owner + const SwRenderData * m_pRenderData; // not owner + +public: + + sal_Bool bPrintGraphic, bPrintTable, bPrintDraw, bPrintControl, bPrintPageBackground, + bPrintBlackFont, + //#i81434# - printing of hidden text + bPrintHiddenText, bPrintTextPlaceholder, + bPrintLeftPages, bPrintRightPages, bPrintReverse, bPrintProspect, + bPrintProspectRTL, + bPrintSingleJobs, bPaperFromSetup, + // --> FME 2005-12-13 #b6354161# Print empty pages + bPrintEmptyPages, + // <-- + // #i56195# no field update while printing mail merge documents + bUpdateFieldsInPrinting, + bModified; + + sal_Int16 nPrintPostIts; + rtl::OUString sFaxName; + + SwPrintData() + { + m_pPrintUIOptions = NULL; + m_pRenderData = NULL; + + bPrintGraphic = + bPrintTable = + bPrintDraw = + bPrintControl = + bPrintLeftPages = + bPrintRightPages = + bPrintPageBackground = + bPrintEmptyPages = + bUpdateFieldsInPrinting = sal_True; + + bPaperFromSetup = + bPrintReverse = + bPrintProspect = + bPrintProspectRTL = + bPrintSingleJobs = + bModified = + bPrintBlackFont = + bPrintHiddenText = + bPrintTextPlaceholder = sal_False; + + nPrintPostIts = 0; + } + + virtual ~SwPrintData() {} + + sal_Bool operator==(const SwPrintData& rData)const + { + return + bPrintGraphic == rData.bPrintGraphic && + bPrintTable == rData.bPrintTable && + bPrintDraw == rData.bPrintDraw && + bPrintControl == rData.bPrintControl && + bPrintPageBackground== rData.bPrintPageBackground && + bPrintBlackFont == rData.bPrintBlackFont && + bPrintLeftPages == rData.bPrintLeftPages && + bPrintRightPages == rData.bPrintRightPages && + bPrintReverse == rData.bPrintReverse && + bPrintProspect == rData.bPrintProspect && + bPrintProspectRTL == rData.bPrintProspectRTL && + bPrintSingleJobs == rData.bPrintSingleJobs && + bPaperFromSetup == rData.bPaperFromSetup && + bPrintEmptyPages == rData.bPrintEmptyPages && + bUpdateFieldsInPrinting == rData.bUpdateFieldsInPrinting && + nPrintPostIts == rData.nPrintPostIts && + sFaxName == rData.sFaxName && + bPrintHiddenText == rData.bPrintHiddenText && + bPrintTextPlaceholder == rData.bPrintTextPlaceholder; + } + + // Note: in the context where this class ist used the pointers should always be valid + // during the lifetime of this object + const SwPrintUIOptions & GetPrintUIOptions() const { return *m_pPrintUIOptions; } + const SwRenderData & GetRenderData() const { return *m_pRenderData; } + void SetPrintUIOptions( const SwPrintUIOptions *pOpt ) { m_pPrintUIOptions = pOpt; } + void SetRenderData( const SwRenderData *pData ) { m_pRenderData = pData; } + + sal_Bool IsPrintGraphic() const { return bPrintGraphic; } + sal_Bool IsPrintTable() const { return bPrintTable; } + sal_Bool IsPrintDraw() const { return bPrintDraw; } + sal_Bool IsPrintControl() const { return bPrintControl; } + sal_Bool IsPrintLeftPage() const { return bPrintLeftPages; } + sal_Bool IsPrintRightPage() const { return bPrintRightPages; } + sal_Bool IsPrintReverse() const { return bPrintReverse; } + sal_Bool IsPaperFromSetup() const { return bPaperFromSetup; } + sal_Bool IsPrintEmptyPages() const { return bPrintEmptyPages; } + sal_Bool IsPrintProspect() const { return bPrintProspect; } + sal_Bool IsPrintProspectRTL() const { return bPrintProspectRTL; } + sal_Bool IsPrintPageBackground() const { return bPrintPageBackground; } + sal_Bool IsPrintBlackFont() const { return bPrintBlackFont; } + sal_Bool IsPrintSingleJobs() const { return bPrintSingleJobs; } + sal_Int16 GetPrintPostIts() const { return nPrintPostIts; } + const rtl::OUString GetFaxName() const { return sFaxName; } + sal_Bool IsPrintHiddenText() const { return bPrintHiddenText; } + sal_Bool IsPrintTextPlaceholder() const { return bPrintTextPlaceholder; } + + void SetPrintGraphic( sal_Bool b ) { doSetModified(); bPrintGraphic = b; } + void SetPrintTable( sal_Bool b ) { doSetModified(); bPrintTable = b; } + void SetPrintDraw( sal_Bool b ) { doSetModified(); bPrintDraw = b; } + void SetPrintControl( sal_Bool b ) { doSetModified(); bPrintControl = b; } + void SetPrintLeftPage( sal_Bool b ) { doSetModified(); bPrintLeftPages = b; } + void SetPrintRightPage( sal_Bool b ) { doSetModified(); bPrintRightPages = b; } + void SetPrintReverse( sal_Bool b ) { doSetModified(); bPrintReverse = b; } + void SetPaperFromSetup( sal_Bool b ) { doSetModified(); bPaperFromSetup = b; } + void SetPrintEmptyPages( sal_Bool b ) { doSetModified(); bPrintEmptyPages = b; } + void SetPrintPostIts( sal_Int16 n ) { doSetModified(); nPrintPostIts = n; } + void SetPrintProspect( sal_Bool b ) { doSetModified(); bPrintProspect = b; } + void SetPrintProspect_RTL( sal_Bool b ) { doSetModified(); bPrintProspectRTL = b; } + void SetPrintPageBackground( sal_Bool b ) { doSetModified(); bPrintPageBackground = b; } + void SetPrintBlackFont( sal_Bool b ) { doSetModified(); bPrintBlackFont = b; } + void SetPrintSingleJobs( sal_Bool b ) { doSetModified(); bPrintSingleJobs = b; } + void SetFaxName( const rtl::OUString& rSet ) { sFaxName = rSet; } + void SetPrintHiddenText( sal_Bool b ) { doSetModified(); bPrintHiddenText = b; } + void SetPrintTextPlaceholder( sal_Bool b ) { doSetModified(); bPrintTextPlaceholder = b; } + + virtual void doSetModified () { bModified = sal_True;} +}; + //////////////////////////////////////////////////////////// @@ -59,13 +192,25 @@ class SfxViewShell; class SwPrintUIOptions : public vcl::PrinterOptionsHelper { OutputDevice* m_pLast; + const SwPrintData & m_rDefaultPrintData; public: - SwPrintUIOptions( bool bWeb, bool bSwSrcView, bool bHasSelection, bool bHasPostIts ); - ~SwPrintUIOptions(); + SwPrintUIOptions( bool bWeb, bool bSwSrcView, bool bHasSelection, bool bHasPostIts, const SwPrintData &rDefaultPrintData ); + virtual ~SwPrintUIOptions(); bool processPropertiesAndCheckFormat( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& i_rNewProp ); + bool IsPrintFormControls() const { return getBoolValue( "PrintControls", m_rDefaultPrintData.bPrintControl ); } + bool IsPrintPageBackground() const { return getBoolValue( "PrintPageBackground", m_rDefaultPrintData.bPrintPageBackground ); } + bool IsPrintProspect() const { return getBoolValue( "PrintProspect", m_rDefaultPrintData.bPrintProspect ); } + bool IsPrintProspectRTL() const { return getIntValue( "PrintProspectRTL", m_rDefaultPrintData.bPrintProspectRTL ) ? true : false; } + bool IsPrintTextPlaceholders() const { return getBoolValue( "PrintTextPlaceholder", m_rDefaultPrintData.bPrintTextPlaceholder ); } + bool IsPrintHiddenText() const { return getBoolValue( "PrintHiddenText", m_rDefaultPrintData.bPrintHiddenText ); } + bool IsPrintWithBlackTextColor() const { return getBoolValue( "PrintBlackFonts", m_rDefaultPrintData.bPrintBlackFont ); } + sal_Int16 GetPrintPostItsType() const { return static_cast< sal_Int16 >(getIntValue( "PrintAnnotationMode", m_rDefaultPrintData.nPrintPostIts )); } + bool IsPaperFromSetup() const { return getBoolValue( "PrintPaperFromSetup", m_rDefaultPrintData.bPaperFromSetup ); } + bool IsPrintReverse() const { return false; /*handled by print dialog now*/ /*getBoolValue( "PrintReversed", m_rDefaultPrintData.bPrintReverse );*/ } + bool IsPrintLeftPages() const; bool IsPrintRightPages() const; bool IsPrintEmptyPages( bool bIsPDFExport ) const; @@ -130,8 +275,7 @@ public: const SwPrtOptions * GetSwPrtOptions() const { return m_pPrtOptions; } SwPrtOptions & GetSwPrtOptionsRef() { return *m_pPrtOptions; } void MakeSwPrtOptions( SwPrtOptions &rOptions, const SwDocShell *pDocShell, - const SwPrintUIOptions *pOpt, const SwRenderData *pData, - bool bIsSkipEmptyPages, bool bIsPDFExport ); + const SwPrintUIOptions *pOpt, const SwRenderData *pData, bool bIsPDFExport ); typedef std::map< sal_Int32, const SwPageFrm * > ValidStartFramesMap_t; @@ -167,135 +311,6 @@ public: }; -//////////////////////////////////////////////////////////// - - -class SwPrintData -{ - const SwPrintUIOptions * m_pPrintUIOptions; // not owner - const SwRenderData * m_pRenderData; // not owner - -public: - - sal_Bool bPrintGraphic, bPrintTable, bPrintDraw, bPrintControl, bPrintPageBackground, - bPrintBlackFont, - //#i81434# - printing of hidden text - bPrintHiddenText, bPrintTextPlaceholder, - bPrintLeftPages, bPrintRightPages, bPrintReverse, bPrintProspect, - bPrintProspectRTL, - bPrintSingleJobs, bPaperFromSetup, - // --> FME 2005-12-13 #b6354161# Print empty pages - bPrintEmptyPages, - // <-- - // #i56195# no field update while printing mail merge documents - bUpdateFieldsInPrinting, - bModified; - - sal_Int16 nPrintPostIts; - rtl::OUString sFaxName; - - SwPrintData() - { - m_pPrintUIOptions = NULL; - m_pRenderData = NULL; - - bPrintGraphic = - bPrintTable = - bPrintDraw = - bPrintControl = - bPrintLeftPages = - bPrintRightPages = - bPrintPageBackground = - bPrintEmptyPages = - bUpdateFieldsInPrinting = sal_True; - - bPaperFromSetup = - bPrintReverse = - bPrintProspect = - bPrintProspectRTL = - bPrintSingleJobs = - bModified = - bPrintBlackFont = - bPrintHiddenText = - bPrintTextPlaceholder = sal_False; - - nPrintPostIts = 0; - } - - virtual ~SwPrintData() {} - - sal_Bool operator==(const SwPrintData& rData)const - { - return - bPrintGraphic == rData.bPrintGraphic && - bPrintTable == rData.bPrintTable && - bPrintDraw == rData.bPrintDraw && - bPrintControl == rData.bPrintControl && - bPrintPageBackground== rData.bPrintPageBackground && - bPrintBlackFont == rData.bPrintBlackFont && - bPrintLeftPages == rData.bPrintLeftPages && - bPrintRightPages == rData.bPrintRightPages && - bPrintReverse == rData.bPrintReverse && - bPrintProspect == rData.bPrintProspect && - bPrintProspectRTL == rData.bPrintProspectRTL && - bPrintSingleJobs == rData.bPrintSingleJobs && - bPaperFromSetup == rData.bPaperFromSetup && - bPrintEmptyPages == rData.bPrintEmptyPages && - bUpdateFieldsInPrinting == rData.bUpdateFieldsInPrinting && - nPrintPostIts == rData.nPrintPostIts && - sFaxName == rData.sFaxName && - bPrintHiddenText == rData.bPrintHiddenText && - bPrintTextPlaceholder == rData.bPrintTextPlaceholder; - } - - // Note: in the context where this class ist used the pointers should always be valid - // during the lifetime of this object - const SwPrintUIOptions & GetPrintUIOptions() const { return *m_pPrintUIOptions; } - void SetPrintUIOptions( const SwPrintUIOptions *pOpt ) { m_pPrintUIOptions = pOpt; } - const SwRenderData & GetRenderData() const { return *m_pRenderData; } - void SetRenderData( const SwRenderData *pData ) { m_pRenderData = pData; } - - sal_Bool IsPrintGraphic() const { return bPrintGraphic; } - sal_Bool IsPrintTable() const { return bPrintTable; } - sal_Bool IsPrintDraw() const { return bPrintDraw; } - sal_Bool IsPrintControl() const { return bPrintControl; } - sal_Bool IsPrintLeftPage() const { return bPrintLeftPages; } - sal_Bool IsPrintRightPage() const { return bPrintRightPages; } - sal_Bool IsPrintReverse() const { return bPrintReverse; } - sal_Bool IsPaperFromSetup() const { return bPaperFromSetup; } - sal_Bool IsPrintEmptyPages() const{ return bPrintEmptyPages; } - sal_Bool IsPrintProspect() const { return bPrintProspect; } - sal_Bool IsPrintProspectRTL() const { return bPrintProspectRTL; } - sal_Bool IsPrintPageBackground() const { return bPrintPageBackground; } - sal_Bool IsPrintBlackFont() const { return bPrintBlackFont; } - sal_Bool IsPrintSingleJobs() const { return bPrintSingleJobs; } - sal_Int16 GetPrintPostIts() const { return nPrintPostIts; } - const rtl::OUString GetFaxName() const{return sFaxName; } - sal_Bool IsPrintHiddenText() const {return bPrintHiddenText;} - sal_Bool IsPrintTextPlaceholder() const {return bPrintTextPlaceholder; } - - void SetPrintGraphic ( sal_Bool b ) { doSetModified(); bPrintGraphic = b;} - void SetPrintTable ( sal_Bool b ) { doSetModified(); bPrintTable = b;} - void SetPrintDraw ( sal_Bool b ) { doSetModified(); bPrintDraw = b;} - void SetPrintControl ( sal_Bool b ) { doSetModified(); bPrintControl = b; } - void SetPrintLeftPage ( sal_Bool b ) { doSetModified(); bPrintLeftPages = b;} - void SetPrintRightPage( sal_Bool b ) { doSetModified(); bPrintRightPages = b;} - void SetPrintReverse ( sal_Bool b ) { doSetModified(); bPrintReverse = b;} - void SetPaperFromSetup( sal_Bool b ) { doSetModified(); bPaperFromSetup = b;} - void SetPrintEmptyPages(sal_Bool b ) { doSetModified(); bPrintEmptyPages = b;} - void SetPrintPostIts ( sal_Int16 n){ doSetModified(); nPrintPostIts = n; } - void SetPrintProspect ( sal_Bool b ) { doSetModified(); bPrintProspect = b; } - void SetPrintProspect_RTL ( sal_Bool b ) { doSetModified(); bPrintProspectRTL = b; } - void SetPrintPageBackground(sal_Bool b){ doSetModified(); bPrintPageBackground = b;} - void SetPrintBlackFont(sal_Bool b){ doSetModified(); bPrintBlackFont = b;} - void SetPrintSingleJobs(sal_Bool b){ doSetModified(); bPrintSingleJobs = b;} - void SetFaxName(const rtl::OUString& rSet){sFaxName = rSet;} - void SetPrintHiddenText(sal_Bool b){ doSetModified(); bPrintHiddenText = b;} - void SetPrintTextPlaceholder(sal_Bool b){ doSetModified(); bPrintTextPlaceholder = b;} - - virtual void doSetModified () { bModified = sal_True;} -}; - //////////////////////////////////////////////////////////// #endif //_SW_PRINTDATA_HXX diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index 66aa3741148f..87b8c5177e26 100755 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -305,7 +305,6 @@ void SwRenderData::MakeSwPrtOptions( const SwDocShell *pDocShell, const SwPrintUIOptions *pOpt, const SwRenderData *pData, - bool bIsSkipEmptyPages, bool bIsPDFExport ) { if (!pDocShell || !pOpt || !pData) @@ -320,22 +319,22 @@ void SwRenderData::MakeSwPrtOptions( rOptions.bPrintGraphic = pOpt->IsPrintGraphics(); rOptions.bPrintTable = pOpt->IsPrintTables(); rOptions.bPrintDraw = pOpt->IsPrintDrawings(); - rOptions.bPrintControl = pOpt->getBoolValue( "PrintControls", rOptions.bPrintControl ); + rOptions.bPrintControl = pOpt->IsPrintFormControls(); rOptions.bPrintLeftPages = pOpt->IsPrintLeftPages(); rOptions.bPrintRightPages = pOpt->IsPrintRightPages(); - rOptions.bPrintPageBackground = pOpt->getBoolValue( "PrintPageBackground", rOptions.bPrintPageBackground ); - rOptions.bPrintEmptyPages = !bIsSkipEmptyPages; + rOptions.bPrintPageBackground = pOpt->IsPrintPageBackground(); + rOptions.bPrintEmptyPages = pOpt->IsPrintEmptyPages( bIsPDFExport ); // bUpdateFieldsInPrinting <-- not set here; mail merge only - rOptions.bPaperFromSetup = pOpt->getBoolValue( "PrintPaperFromSetup", rOptions.bPaperFromSetup ); - rOptions.bPrintReverse = pOpt->getBoolValue( "PrintReversed", rOptions.bPrintReverse ); - rOptions.bPrintProspect = pOpt->getBoolValue( "PrintProspect", rOptions.bPrintProspect ); - rOptions.bPrintProspectRTL = pOpt->getIntValue( "PrintProspectRTL", rOptions.bPrintProspectRTL ) ? true : false; + rOptions.bPaperFromSetup = pOpt->IsPaperFromSetup(); + rOptions.bPrintReverse = pOpt->IsPrintReverse(); + rOptions.bPrintProspect = pOpt->IsPrintProspect(); + rOptions.bPrintProspectRTL = pOpt->IsPrintProspectRTL(); // bPrintSingleJobs <-- not set here; mail merge and or configuration // bModified <-- not set here; mail merge only - rOptions.bPrintBlackFont = pOpt->getBoolValue( "PrintBlackFonts", rOptions.bPrintBlackFont ); - rOptions.bPrintHiddenText = pOpt->getBoolValue( "PrintHiddenText", rOptions.bPrintHiddenText ); - rOptions.bPrintTextPlaceholder = pOpt->getBoolValue( "PrintTextPlaceholder", rOptions.bPrintTextPlaceholder ); - rOptions.nPrintPostIts = static_cast< sal_Int16 >(pOpt->getIntValue( "PrintAnnotationMode", rOptions.nPrintPostIts )); + rOptions.bPrintBlackFont = pOpt->IsPrintWithBlackTextColor(); + rOptions.bPrintHiddenText = pOpt->IsPrintHiddenText(); + rOptions.bPrintTextPlaceholder = pOpt->IsPrintTextPlaceholders(); + rOptions.nPrintPostIts = pOpt->GetPrintPostItsType(); //! needs to be set after MakeOptions since the assignment operation in that //! function will destroy the pointers @@ -357,8 +356,14 @@ void SwRenderData::MakeSwPrtOptions( /*****************************************************************************/ -SwPrintUIOptions::SwPrintUIOptions( bool bWeb, bool bSwSrcView, bool bHasSelection, bool bHasPostIts ) : - m_pLast( NULL ) +SwPrintUIOptions::SwPrintUIOptions( + bool bWeb, + bool bSwSrcView, + bool bHasSelection, + bool bHasPostIts, + const SwPrintData &rDefaultPrintData ) : + m_pLast( NULL ), + m_rDefaultPrintData( rDefaultPrintData ) { ResStringArray aLocalizedStrings( SW_RES( STR_PRINTOPTUI ) ); @@ -396,62 +401,70 @@ SwPrintUIOptions::SwPrintUIOptions( bool bWeb, bool bSwSrcView, bool bHasSelect m_aUIProperties[ nIdx++ ].Value = getSubgroupControlOpt( aLocalizedStrings.GetString( 1 ), rtl::OUString() ); // create a bool option for background + bool bDefaultVal = rDefaultPrintData.IsPrintPageBackground(); m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 2 ), aLocalizedStrings.GetString( 3 ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintPageBackground" ) ), - sal_True ); + bDefaultVal ); - // create a bool option for graphics + // create a bool option for pictures/graphics AND OLE and drawing objects as well + bDefaultVal = rDefaultPrintData.IsPrintGraphic() || rDefaultPrintData.IsPrintDraw(); m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 4 ), aLocalizedStrings.GetString( 5 ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintPicturesAndObjects" ) ), - sal_True ); + bDefaultVal ); if (!bWeb) { // create a bool option for hidden text + bDefaultVal = rDefaultPrintData.IsPrintHiddenText(); m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 6 ), aLocalizedStrings.GetString( 7 ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintHiddenText" ) ), - sal_False ); + bDefaultVal ); // create a bool option for place holder + bDefaultVal = rDefaultPrintData.IsPrintTextPlaceholder(); m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 8 ), aLocalizedStrings.GetString( 9 ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintTextPlaceholder" ) ), - sal_False ); + bDefaultVal ); } // create a bool option for controls + bDefaultVal = rDefaultPrintData.IsPrintControl(); m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 10 ), aLocalizedStrings.GetString( 11 ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintControls" ) ), - sal_True ); + bDefaultVal ); // create sub section for Color m_aUIProperties[ nIdx++ ].Value = getSubgroupControlOpt( aLocalizedStrings.GetString( 12 ), rtl::OUString() ); - // create a bool option for black + // create a bool option for printing text with black font color + bDefaultVal = rDefaultPrintData.IsPrintBlackFont(); m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 13 ), aLocalizedStrings.GetString( 14 ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintBlackFonts" ) ), - sal_False ); + bDefaultVal ); // create subgroup for misc options m_aUIProperties[ nIdx++ ].Value = getSubgroupControlOpt( rtl::OUString( aLocalizedStrings.GetString( 15 ) ), rtl::OUString() ); - // create a bool option for blank pages + // create a bool option for printing automatically inserted blank pages + bDefaultVal = rDefaultPrintData.IsPrintEmptyPages(); m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 16 ), aLocalizedStrings.GetString( 17 ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintEmptyPages" ) ), - sal_True ); + bDefaultVal ); // create a bool option for paper tray + bDefaultVal = rDefaultPrintData.IsPaperFromSetup(); vcl::PrinterOptionsHelper::UIControlOptions aPaperTrayOpt; aPaperTrayOpt.maGroupHint = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OptionsPageOptGroup" ) ); m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 18 ), aLocalizedStrings.GetString( 19 ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintPaperFromSetup" ) ), - sal_False, + bDefaultVal, aPaperTrayOpt ); @@ -498,6 +511,7 @@ SwPrintUIOptions::SwPrintUIOptions( bool bWeb, bool bSwSrcView, bool bHasSelect aContentsOpt ); // create a list box for notes content + const sal_Int16 nPrintPostIts = rDefaultPrintData.GetPrintPostIts(); aChoices.realloc( 4 ); aChoices[0] = aLocalizedStrings.GetString( 21 ); aChoices[1] = aLocalizedStrings.GetString( 22 ); @@ -512,7 +526,7 @@ SwPrintUIOptions::SwPrintUIOptions( bool bWeb, bool bSwSrcView, bool bHasSelect aHelpText, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintAnnotationMode" ) ), aChoices, - 0, + nPrintPostIts, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "List" ) ), aAnnotOpt ); @@ -534,23 +548,36 @@ SwPrintUIOptions::SwPrintUIOptions( bool bWeb, bool bSwSrcView, bool bHasSelect uno::Sequence< rtl::OUString > aRLHelp( 1 ); aRLHelp[0] = aLocalizedStrings.GetString( 31 ); // create a choice option for all/left/right pages + // 0 : all pages (left & right) + // 1 : left pages + // 2 : right pages + DBG_ASSERT( rDefaultPrintData.IsPrintLeftPage() || rDefaultPrintData.IsPrintRigthPage(), + "unexpected value combination" ); + sal_Int16 nPagesChoice = 0; + if (rDefaultPrintData.IsPrintLeftPage() && !rDefaultPrintData.IsPrintRightPage()) + nPagesChoice = 1; + else if (!rDefaultPrintData.IsPrintLeftPage() && rDefaultPrintData.IsPrintRightPage()) + nPagesChoice = 2; m_aUIProperties[ nIdx++ ].Value = getChoiceControlOpt( aLocalizedStrings.GetString( 32 ), aRLHelp, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintLeftRightPages" ) ), - aRLChoices, 0, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "List" ) ) + aRLChoices, + nPagesChoice, + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "List" ) ) ); } // create a bool option for brochure + bDefaultVal = rDefaultPrintData.IsPrintProspect(); rtl::OUString aBrochurePropertyName( RTL_CONSTASCII_USTRINGPARAM( "PrintProspect" ) ); m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 33 ), aLocalizedStrings.GetString( 34 ), aBrochurePropertyName, - sal_False, + bDefaultVal, aPageSetOpt ); - if( bCTL ) + if (bCTL) { // create a bool option for brochure RTL dependent on brochure uno::Sequence< rtl::OUString > aBRTLChoices( 2 ); @@ -558,10 +585,16 @@ SwPrintUIOptions::SwPrintUIOptions( bool bWeb, bool bSwSrcView, bool bHasSelect aBRTLChoices[1] = aLocalizedStrings.GetString( 36 ); vcl::PrinterOptionsHelper::UIControlOptions aBrochureRTLOpt( aBrochurePropertyName, -1, sal_True ); aBrochureRTLOpt.maGroupHint = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutPage" ) ); + // RTL brochure choices + // 0 : left-to-right + // 1 : right-to-left + const sal_Int16 nBRTLChoice = rDefaultPrintData.IsPrintProspectRTL() ? 1 : 0; m_aUIProperties[ nIdx++ ].Value = getChoiceControlOpt( rtl::OUString(), uno::Sequence< rtl::OUString >(), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintProspectRTL" ) ), - aBRTLChoices, 0, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "List" ) ), + aBRTLChoices, + nBRTLChoice, + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "List" ) ), aBrochureRTLOpt ); } @@ -578,7 +611,7 @@ SwPrintUIOptions::~SwPrintUIOptions() bool SwPrintUIOptions::IsPrintLeftPages() const { // take care of different property names for the option. - // for compatibility the old name should win + // for compatibility the old name should win (may still be used for PDF export or via Uno API) // 0: left and right pages // 1: left pages only @@ -592,7 +625,7 @@ bool SwPrintUIOptions::IsPrintLeftPages() const bool SwPrintUIOptions::IsPrintRightPages() const { // take care of different property names for the option. - // for compatibility the old name should win + // for compatibility the old name should win (may still be used for PDF export or via Uno API) sal_Int64 nLRPages = getIntValue( "PrintLeftRightPages", 0 /* default: all */ ); bool bRes = nLRPages == 0 || nLRPages == 2; @@ -612,8 +645,8 @@ bool SwPrintUIOptions::IsPrintEmptyPages( bool bIsPDFExport ) const bool SwPrintUIOptions::IsPrintTables() const { - // take care of different property names for the option. - // for compatibility the old name should win + // take care of different property names currently in use for this option. + // for compatibility the old name should win (may still be used for PDF export or via Uno API) // bool bRes = getBoolValue( "PrintTablesGraphicsAndDiagrams", sal_True ); // bRes = getBoolValue( "PrintTables", bRes ); @@ -625,7 +658,7 @@ bool SwPrintUIOptions::IsPrintTables() const bool SwPrintUIOptions::IsPrintGraphics() const { // take care of different property names for the option. - // for compatibility the old name should win + // for compatibility the old name should win (may still be used for PDF export or via Uno API) bool bRes = getBoolValue( "PrintPicturesAndObjects", sal_True ); bRes = getBoolValue( "PrintGraphics", bRes ); @@ -635,7 +668,7 @@ bool SwPrintUIOptions::IsPrintGraphics() const bool SwPrintUIOptions::IsPrintDrawings() const { // take care of different property names for the option. - // for compatibility the old name should win + // for compatibility the old name should win (may still be used for PDF export or via Uno API) bool bRes = getBoolValue( "PrintPicturesAndObjects", sal_True ); bRes = getBoolValue( "PrintDrawings", bRes ); diff --git a/sw/source/ui/config/optdlg.hrc b/sw/source/ui/config/optdlg.hrc index 2ada884e48c7..63ad384c7bd9 100644 --- a/sw/source/ui/config/optdlg.hrc +++ b/sw/source/ui/config/optdlg.hrc @@ -96,13 +96,13 @@ #define CB_CHAR_HIDDEN 61 // Print-Extra-Page #define CB_PGRF 61 -#define CB_PTAB 62 -#define CB_PDRAW 63 +//#define CB_PTAB 62 merged with CB_PGRF in printerpullpages +//#define CB_PDRAW 63 removed in printerpullpages #define CB_LEFTP 64 #define CB_RIGHTP 65 -#define CB_REVERSE 66 +//#define CB_REVERSE 66 removed in printerpullpages #define CB_PROSPECT 67 -#define CB_SINGLEJOBS 68 +//#define CB_SINGLEJOBS 68 removed in printerpullpages #define CB_CTRLFLD 69 #define CB_PAPERFROMSETUP 70 #define FL_1 71 diff --git a/sw/source/ui/config/optdlg.src b/sw/source/ui/config/optdlg.src index ce1d9ae22942..f509b1cdcc5c 100755 --- a/sw/source/ui/config/optdlg.src +++ b/sw/source/ui/config/optdlg.src @@ -215,60 +215,66 @@ TabPage TP_OPTPRINT_PAGE Text [ en-US ] = "Contents" ; Group = TRUE ; }; - CheckBox CB_PGRF + CheckBox CB_PGRF /*functionally merged with CB_PDRAW*/ { Pos = MAP_APPFONT ( 12 , 14 ) ; Size = MAP_APPFONT ( 70 , 10 ) ; - Text [ en-US ] = "~Graphics" ; + Text [ en-US ] = "~Pictures and objects" ; TabStop = TRUE ; Group = TRUE ; }; +/* + removed, tables now always get printed CheckBox CB_PTAB { Pos = MAP_APPFONT ( 12 , 27 ) ; Size = MAP_APPFONT ( 70 , 10 ) ; Text [ en-US ] = "~Tables" ; }; +*/ +/* + functionally merged with CB_PGRF (pictures and graphics) CheckBox CB_PDRAW { Pos = MAP_APPFONT ( 12 , 40 ) ; Size = MAP_APPFONT ( 70 , 10 ) ; Text [ en-US ] = "Dra~wings" ; }; +*/ CheckBox CB_CTRLFLD { - Pos = MAP_APPFONT ( 12 , 53 ) ; + Pos = MAP_APPFONT ( 12 , 27 ) ; Size = MAP_APPFONT ( 70 , 10 ) ; - Text [ en-US ] = "Control~s" ; + Text [ en-US ] = "Form control~s" ; }; CheckBox CB_BACKGROUND { - Pos = MAP_APPFONT ( 12 , 66 ) ; + Pos = MAP_APPFONT ( 12 , 40 ) ; Size = MAP_APPFONT ( 70 , 10 ) ; - Text [ en-US ] = "Ba~ckground" ; + Text [ en-US ] = "Page ba~ckground" ; }; CheckBox CB_BLACK_FONT { - Pos = MAP_APPFONT ( 12 , 79 ) ; + Pos = MAP_APPFONT ( 12 , 53 ) ; Size = MAP_APPFONT ( 70 , 10 ) ; - Text [ en-US ] = "Print blac~k" ; + Text [ en-US ] = "Print text in blac~k" ; }; CheckBox CB_HIDDEN_TEXT { - Pos = MAP_APPFONT ( 12 , 92 ) ; + Pos = MAP_APPFONT ( 12 , 66 ) ; Size = MAP_APPFONT ( 70 , 10 ) ; Text [ en-US ] = "Hidden te~xt" ; }; CheckBox CB_TEXT_PLACEHOLDER { - Pos = MAP_APPFONT ( 12 , 105 ) ; + Pos = MAP_APPFONT ( 12 , 79 ) ; Size = MAP_APPFONT ( 70 , 10 ) ; Text [ en-US ] = "Text ~placeholder" ; }; FixedLine FL_SEP_PRT_LEFT { Pos = MAP_APPFONT ( 85 , 14 ) ; - Size = MAP_APPFONT ( 4 , 104 ) ; + Size = MAP_APPFONT ( 4 , 78 ) ; Vert = TRUE; }; FixedLine FL_2 @@ -292,21 +298,24 @@ TabPage TP_OPTPRINT_PAGE Size = MAP_APPFONT ( 70 , 10 ) ; Text [ en-US ] = "~Right pages" ; }; +/* + removed, noe handled by the new print dialog (i.e. vcl) itself CheckBox CB_REVERSE { Pos = MAP_APPFONT ( 96 , 40 ) ; Size = MAP_APPFONT ( 70 , 10 ) ; Text [ en-US ] = "Re~versed" ; }; +*/ CheckBox CB_PROSPECT { - Pos = MAP_APPFONT ( 96 , 53 ) ; + Pos = MAP_APPFONT ( 96 , 40 ) ; Size = MAP_APPFONT ( 70 , 10 ) ; Text [ en-US ] = "Broch~ure" ; }; CheckBox CB_PROSPECT_RTL { - Pos = MAP_APPFONT ( 103 , 66 ) ; + Pos = MAP_APPFONT ( 103 , 53 ) ; Size = MAP_APPFONT ( 70 , 10 ) ; Text [ en-US ] = "Right to Left" ; Text [ x-comment ] = " "; @@ -340,7 +349,7 @@ TabPage TP_OPTPRINT_PAGE FixedLine FL_SEP_PRT_RIGHT { Pos = MAP_APPFONT ( 169 , 14 ) ; - Size = MAP_APPFONT ( 4 , 104 ) ; + Size = MAP_APPFONT ( 4 , 78 ) ; Vert = TRUE; }; FixedLine FL_3 @@ -352,35 +361,37 @@ TabPage TP_OPTPRINT_PAGE }; FixedLine FL_4 { - Pos = MAP_APPFONT ( 6 , 121 ) ; + Pos = MAP_APPFONT ( 6 , 95 ) ; Size = MAP_APPFONT ( 248 , 8 ) ; Group = TRUE ; Text [ en-US ] = "Other"; }; CheckBox CB_PRINTEMPTYPAGES { - Pos = MAP_APPFONT ( 12 , 132 ) ; + Pos = MAP_APPFONT ( 12 , 106 ) ; Size = MAP_APPFONT ( 200 , 10 ) ; TabStop = TRUE ; Text [ en-US ] = "Print ~automatically inserted blank pages"; }; +/* CheckBox CB_SINGLEJOBS { - Pos = MAP_APPFONT ( 12 , 145 ) ; + Pos = MAP_APPFONT ( 12 , 119 ) ; Size = MAP_APPFONT ( 200 , 10 ) ; TabStop = TRUE ; Text [ en-US ] = "Create s~ingle print jobs" ; }; +*/ CheckBox CB_PAPERFROMSETUP { - Pos = MAP_APPFONT ( 12 , 158 ) ; + Pos = MAP_APPFONT ( 12 , 119 ) ; Size = MAP_APPFONT ( 200 , 10 ) ; TabStop = TRUE ; Text [ en-US ] = "~Paper tray from printer settings"; }; FixedText FT_FAX { - Pos = MAP_APPFONT ( 12 , 173 ) ; + Pos = MAP_APPFONT ( 12 , 134 ) ; Size = MAP_APPFONT ( 50 , 8 ) ; Group = TRUE ; Text [ en-US ] = "~Fax"; @@ -388,7 +399,7 @@ TabPage TP_OPTPRINT_PAGE ListBox LB_FAX { Border = TRUE ; - Pos = MAP_APPFONT ( 70 , 171 ) ; + Pos = MAP_APPFONT ( 70 , 132 ) ; Size = MAP_APPFONT ( 184 , 70 ) ; TabStop = TRUE ; DropDown = TRUE ; @@ -945,7 +956,7 @@ StringArray STR_PRINTOPTUI < "Page ba~ckground"; >; < "Specifies whether to include colors and objects that are inserted to the background of the page (Format - Page - Background) in the printed document."; >; < "~Pictures and objects"; >; - < "Specifies whether the graphics of your text document are printed"; >; + < "Specifies whether the graphics and drawing or OLE objects of your text document are printed"; >; < "Hidden te~xt"; >; < "Enable this option to print text that is marked as hidden."; >; < "~Text placeholder"; >; diff --git a/sw/source/ui/config/optpage.cxx b/sw/source/ui/config/optpage.cxx index 3c529263f66d..d609f1ed28cc 100644 --- a/sw/source/ui/config/optpage.cxx +++ b/sw/source/ui/config/optpage.cxx @@ -350,8 +350,8 @@ SwAddPrinterTabPage::SwAddPrinterTabPage( Window* pParent, SfxTabPage( pParent, SW_RES( TP_OPTPRINT_PAGE ), rCoreSet), aFL1 (this, SW_RES(FL_1)), aGrfCB (this, SW_RES(CB_PGRF)), - aTabCB (this, SW_RES(CB_PTAB)), - aDrawCB (this, SW_RES(CB_PDRAW)), +// aTabCB (this, SW_RES(CB_PTAB)), +// aDrawCB (this, SW_RES(CB_PDRAW)), aCtrlFldCB (this, SW_RES(CB_CTRLFLD)), aBackgroundCB (this, SW_RES(CB_BACKGROUND)), aBlackFontCB (this, SW_RES(CB_BLACK_FONT)), @@ -361,7 +361,7 @@ SwAddPrinterTabPage::SwAddPrinterTabPage( Window* pParent, aFL2 (this, SW_RES(FL_2)), aLeftPageCB (this, SW_RES(CB_LEFTP)), aRightPageCB (this, SW_RES(CB_RIGHTP)), - aReverseCB (this, SW_RES(CB_REVERSE)), +// aReverseCB (this, SW_RES(CB_REVERSE)), aProspectCB (this, SW_RES(CB_PROSPECT)), aProspectCB_RTL (this, SW_RES(CB_PROSPECT_RTL)), aSeparatorRFL (this, SW_RES(FL_SEP_PRT_RIGHT)), @@ -372,7 +372,7 @@ SwAddPrinterTabPage::SwAddPrinterTabPage( Window* pParent, aFL3 (this, SW_RES(FL_3)), aFL4 (this, SW_RES(FL_4)), aPrintEmptyPagesCB(this, SW_RES(CB_PRINTEMPTYPAGES)), - aSingleJobsCB (this, SW_RES(CB_SINGLEJOBS)), +// aSingleJobsCB (this, SW_RES(CB_SINGLEJOBS)), aPaperFromSetupCB(this, SW_RES(CB_PAPERFROMSETUP)), aFaxFT (this, SW_RES(FT_FAX)), aFaxLB (this, SW_RES(LB_FAX)), @@ -386,14 +386,14 @@ SwAddPrinterTabPage::SwAddPrinterTabPage( Window* pParent, aGrfCB.SetClickHdl( aLk ); aRightPageCB.SetClickHdl( aLk ); aLeftPageCB.SetClickHdl( aLk ); - aTabCB.SetClickHdl( aLk ); - aDrawCB.SetClickHdl( aLk ); +// aTabCB.SetClickHdl( aLk ); +// aDrawCB.SetClickHdl( aLk ); aCtrlFldCB.SetClickHdl( aLk ); aBackgroundCB.SetClickHdl( aLk ); aBlackFontCB.SetClickHdl( aLk ); aPrintHiddenTextCB.SetClickHdl( aLk ); aPrintTextPlaceholderCB.SetClickHdl( aLk ); - aReverseCB.SetClickHdl( aLk ); +// aReverseCB.SetClickHdl( aLk ); aProspectCB.SetClickHdl( aLk ); aProspectCB_RTL.SetClickHdl( aLk ); aPaperFromSetupCB.SetClickHdl( aLk ); @@ -402,27 +402,27 @@ SwAddPrinterTabPage::SwAddPrinterTabPage( Window* pParent, aEndRB.SetClickHdl( aLk ); aOnlyRB.SetClickHdl( aLk ); aNoRB.SetClickHdl( aLk ); - aSingleJobsCB.SetClickHdl( aLk ); +// aSingleJobsCB.SetClickHdl( aLk ); aFaxLB.SetSelectHdl( LINK( this, SwAddPrinterTabPage, SelectHdl ) ); const SfxPoolItem* pItem; if(SFX_ITEM_SET == rCoreSet.GetItemState(SID_HTML_MODE, FALSE, &pItem ) && ((SfxUInt16Item*)pItem)->GetValue() & HTMLMODE_ON) { - aDrawCB .Hide(); +// aDrawCB .Hide(); aLeftPageCB .Hide(); aRightPageCB .Hide(); aPrintHiddenTextCB.Hide(); aPrintTextPlaceholderCB.Hide(); - Point rPt(aReverseCB .GetPosPixel()); +// aReverseCB.SetPosPixel(aLeftPageCB.GetPosPixel()); + aProspectCB.SetPosPixel(aLeftPageCB.GetPosPixel()); + Point rPt( aRightPageCB.GetPosPixel() ); rPt.setX(rPt.getX() + 15); // indent aProspectCB_RTL.SetPosPixel(rPt); - aReverseCB.SetPosPixel(aLeftPageCB .GetPosPixel()); - aProspectCB.SetPosPixel(aRightPageCB .GetPosPixel()); - aPrintHiddenTextCB.SetPosPixel(aBlackFontCB.GetPosPixel()); - aBlackFontCB.SetPosPixel(aBackgroundCB.GetPosPixel()); - aBackgroundCB.SetPosPixel(aCtrlFldCB.GetPosPixel()); - aCtrlFldCB.SetPosPixel(aDrawCB.GetPosPixel()); +// aBlackFontCB.SetPosPixel(aBackgroundCB.GetPosPixel()); +// aPrintHiddenTextCB.SetPosPixel(aBlackFontCB.GetPosPixel()); +// aBackgroundCB.SetPosPixel(aCtrlFldCB.GetPosPixel()); +// aCtrlFldCB.SetPosPixel(aDrawCB.GetPosPixel()); } aProspectCB_RTL.Disable(); SvtCTLOptions aCTLOptions; @@ -465,8 +465,8 @@ BOOL SwAddPrinterTabPage::FillItemSet( SfxItemSet& rCoreSet ) { SwAddPrinterItem aAddPrinterAttr (FN_PARAM_ADDPRINTER); aAddPrinterAttr.bPrintGraphic = aGrfCB.IsChecked(); - aAddPrinterAttr.bPrintTable = aTabCB.IsChecked(); - aAddPrinterAttr.bPrintDraw = aDrawCB.IsChecked(); + aAddPrinterAttr.bPrintTable = TRUE; // always enabled since CWS printerpullgpages /*aTabCB.IsChecked();*/ + aAddPrinterAttr.bPrintDraw = aGrfCB.IsChecked(); // UI merged with aGrfCB in CWS printerpullgpages /*aDrawCB.IsChecked()*/; aAddPrinterAttr.bPrintControl = aCtrlFldCB.IsChecked(); aAddPrinterAttr.bPrintPageBackground = aBackgroundCB.IsChecked(); aAddPrinterAttr.bPrintBlackFont = aBlackFontCB.IsChecked(); @@ -475,12 +475,12 @@ BOOL SwAddPrinterTabPage::FillItemSet( SfxItemSet& rCoreSet ) aAddPrinterAttr.bPrintLeftPages = aLeftPageCB.IsChecked(); aAddPrinterAttr.bPrintRightPages = aRightPageCB.IsChecked(); - aAddPrinterAttr.bPrintReverse = aReverseCB.IsChecked(); + aAddPrinterAttr.bPrintReverse = FALSE; // handled by vcl itself since CWS printerpullpages /*aReverseCB.IsChecked()*/; aAddPrinterAttr.bPrintProspect = aProspectCB.IsChecked(); aAddPrinterAttr.bPrintProspectRTL = aProspectCB_RTL.IsChecked(); aAddPrinterAttr.bPaperFromSetup = aPaperFromSetupCB.IsChecked(); aAddPrinterAttr.bPrintEmptyPages = aPrintEmptyPagesCB.IsChecked(); - aAddPrinterAttr.bPrintSingleJobs = aSingleJobsCB.IsChecked(); + aAddPrinterAttr.bPrintSingleJobs = TRUE; // handled by vcl in new print dialog since CWS printerpullpages /*aSingleJobsCB.IsChecked()*/; if (aNoRB.IsChecked()) aAddPrinterAttr.nPrintPostIts = POSTITS_NONE; @@ -508,9 +508,9 @@ void SwAddPrinterTabPage::Reset( const SfxItemSet& ) if( SFX_ITEM_SET == rSet.GetItemState( FN_PARAM_ADDPRINTER , FALSE, (const SfxPoolItem**)&pAddPrinterAttr )) { - aGrfCB.Check( pAddPrinterAttr->bPrintGraphic); - aTabCB.Check( pAddPrinterAttr->bPrintTable); - aDrawCB.Check( pAddPrinterAttr->bPrintDraw); + aGrfCB.Check( pAddPrinterAttr->bPrintGraphic || pAddPrinterAttr->bPrintDraw ); +// aTabCB.Check( pAddPrinterAttr->bPrintTable); +// aDrawCB.Check( pAddPrinterAttr->bPrintDraw); aCtrlFldCB.Check( pAddPrinterAttr->bPrintControl); aBackgroundCB.Check( pAddPrinterAttr->bPrintPageBackground); aBlackFontCB.Check( pAddPrinterAttr->bPrintBlackFont); @@ -518,12 +518,12 @@ void SwAddPrinterTabPage::Reset( const SfxItemSet& ) aPrintTextPlaceholderCB.Check(pAddPrinterAttr->bPrintTextPlaceholder); aLeftPageCB.Check( pAddPrinterAttr->bPrintLeftPages); aRightPageCB.Check( pAddPrinterAttr->bPrintRightPages); - aReverseCB.Check( pAddPrinterAttr->bPrintReverse); +// aReverseCB.Check( pAddPrinterAttr->bPrintReverse); aPaperFromSetupCB.Check(pAddPrinterAttr->bPaperFromSetup); aPrintEmptyPagesCB.Check(pAddPrinterAttr->bPrintEmptyPages); aProspectCB.Check( pAddPrinterAttr->bPrintProspect); aProspectCB_RTL.Check( pAddPrinterAttr->bPrintProspectRTL); - aSingleJobsCB.Check( pAddPrinterAttr->bPrintSingleJobs); +// aSingleJobsCB.Check( pAddPrinterAttr->bPrintSingleJobs); aNoRB.Check (pAddPrinterAttr->nPrintPostIts== POSTITS_NONE ) ; aOnlyRB.Check (pAddPrinterAttr->nPrintPostIts== POSTITS_ONLY ) ; diff --git a/sw/source/ui/inc/optpage.hxx b/sw/source/ui/inc/optpage.hxx index 592c581f4aa3..b2fe407964c4 100644 --- a/sw/source/ui/inc/optpage.hxx +++ b/sw/source/ui/inc/optpage.hxx @@ -119,8 +119,8 @@ class SwAddPrinterTabPage : public SfxTabPage { FixedLine aFL1; CheckBox aGrfCB; - CheckBox aTabCB; - CheckBox aDrawCB; +// CheckBox aTabCB; +// CheckBox aDrawCB; CheckBox aCtrlFldCB; CheckBox aBackgroundCB; CheckBox aBlackFontCB; @@ -132,7 +132,7 @@ class SwAddPrinterTabPage : public SfxTabPage FixedLine aFL2; CheckBox aLeftPageCB; CheckBox aRightPageCB; - CheckBox aReverseCB; +// CheckBox aReverseCB; CheckBox aProspectCB; CheckBox aProspectCB_RTL; @@ -145,7 +145,7 @@ class SwAddPrinterTabPage : public SfxTabPage FixedLine aFL3; FixedLine aFL4; CheckBox aPrintEmptyPagesCB; - CheckBox aSingleJobsCB; +// CheckBox aSingleJobsCB; CheckBox aPaperFromSetupCB; FixedText aFaxFT; ListBox aFaxLB; diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index 9377f7182b18..2ac3e7f64508 100755 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -194,7 +194,12 @@ SwPrintUIOptions * lcl_GetPrintUIOptions( const SwView * pSwView = dynamic_cast< const SwView * >(pView); const bool bHasSelection = pSwView ? pSwView->HasSelection( sal_False ) : false; // check for any selection, not just text selection const bool bHasPostIts = lcl_GetPostIts( pDocShell->GetDoc(), 0 ); - return new SwPrintUIOptions( bWebDoc, bSwSrcView, bHasSelection, bHasPostIts ); + + // 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" ); + + return new SwPrintUIOptions( bWebDoc, bSwSrcView, bHasSelection, bHasPostIts, *pPrintData ); } //////////////////////////////////////////////////////////// @@ -2619,6 +2624,42 @@ SwDoc * SwXTextDocument::GetRenderDoc( /* -----------------------------23.08.02 16:00-------------------------------- ---------------------------------------------------------------------------*/ + +static void lcl_SavePrintUIOptionsToDocumentPrintData( + SwDoc &rDoc, + 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(); + + 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() ); +} + + sal_Int32 SAL_CALL SwXTextDocument::getRendererCount( const uno::Any& rSelection, const uno::Sequence< beans::PropertyValue >& rxOptions ) @@ -2644,6 +2685,9 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount( if (!pDoc || !pView) return 0; + // save current UI options from the print dialog for the next call to that dialog + lcl_SavePrintUIOptionsToDocumentPrintData( *pDoc, *m_pPrintUIOptions, bIsPDFExport ); + sal_Int32 nRet = 0; if (bIsSwSrcView) { @@ -2678,7 +2722,7 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount( m_pRenderData->SetSwPrtOptions( new SwPrtOptions( C2U( bIsPDFExport ? "PDF export" : "Printing" ) ) ); m_pRenderData->MakeSwPrtOptions( m_pRenderData->GetSwPrtOptionsRef(), pRenderDocShell, - m_pPrintUIOptions, m_pRenderData, bIsSkipEmptyPages, bIsPDFExport ); + m_pPrintUIOptions, m_pRenderData, bIsPDFExport ); //SwViewOptionAdjust_Impl aAdjust(*pWrtShell); const TypeId aSwViewTypeId = TYPE(SwView); -- cgit From fe74c5cb8d987483b67cfa153102e16d7dc95a96 Mon Sep 17 00:00:00 2001 From: "Philipp Lohmann [pl]" Date: Thu, 10 Dec 2009 18:01:55 +0100 Subject: fix warnings --- sw/source/core/layout/paintfrm.cxx | 8 ++++---- sw/source/ui/uno/unotxdoc.cxx | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'sw') diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx index 6181269b96b8..94bafc442117 100644 --- a/sw/source/core/layout/paintfrm.cxx +++ b/sw/source/core/layout/paintfrm.cxx @@ -3190,7 +3190,7 @@ SwShortCut::SwShortCut( const SwFrm& rFrm, const SwRect& rRect ) } } -void SwLayoutFrm::Paint( const SwRect& rRect, const SwPrtOptions *pPrintData ) const +void SwLayoutFrm::Paint( const SwRect& rRect, const SwPrtOptions* /* pPrintData */ ) const { ViewShell *pSh = GetShell(); @@ -3478,7 +3478,7 @@ BOOL SwFlyFrm::IsPaint( SdrObject *pObj, const ViewShell *pSh ) /************************************************************************* |* SwCellFrm::Paint( const SwRect& ) const |*************************************************************************/ -void SwCellFrm::Paint( const SwRect& rRect, const SwPrtOptions *pPrintData ) const +void SwCellFrm::Paint( const SwRect& rRect, const SwPrtOptions* /* pPrintData */ ) const { if ( GetLayoutRowSpan() >= 1 ) SwLayoutFrm::Paint( rRect ); @@ -3497,7 +3497,7 @@ void SwCellFrm::Paint( const SwRect& rRect, const SwPrtOptions *pPrintData ) con void MA_FASTCALL lcl_PaintLowerBorders( const SwLayoutFrm *pLay, const SwRect &rRect, const SwPageFrm *pPage ); -void SwFlyFrm::Paint( const SwRect& rRect, const SwPrtOptions *pPrintData ) const +void SwFlyFrm::Paint( const SwRect& rRect, const SwPrtOptions* /* pPrintData */ ) const { //wegen der Ueberlappung von Rahmen und Zeichenobjekten muessen die //Flys ihre Umrandung (und die der Innenliegenden) direkt ausgeben. @@ -3732,7 +3732,7 @@ void SwFlyFrm::Paint( const SwRect& rRect, const SwPrtOptions *pPrintData ) cons |* |*************************************************************************/ -void SwTabFrm::Paint( const SwRect& rRect, const SwPrtOptions *pPrintData ) const +void SwTabFrm::Paint( const SwRect& rRect, const SwPrtOptions* /* pPrintData */ ) const { if ( pGlobalShell->GetViewOptions()->IsTable() ) { diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index 2ac3e7f64508..e689306262f4 100755 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -2678,7 +2678,7 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount( if (!m_pPrintUIOptions) m_pPrintUIOptions = lcl_GetPrintUIOptions( pDocShell, pView ); bool bFormat = m_pPrintUIOptions->processPropertiesAndCheckFormat( rxOptions ); - const bool bIsSkipEmptyPages = !m_pPrintUIOptions->IsPrintEmptyPages( bIsPDFExport ); + // const bool bIsSkipEmptyPages = !m_pPrintUIOptions->IsPrintEmptyPages( bIsPDFExport ); SwDoc *pDoc = GetRenderDoc( pView, rSelection, bIsPDFExport ); DBG_ASSERT( pDoc && pView, "doc or view shell missing!" ); -- cgit From 9195c2b45eb5488e939bb88281d45cb45fbe4861 Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Fri, 11 Dec 2009 11:34:10 +0100 Subject: #i106926# fixed hidden text in view when cancelling print to file --- sw/inc/unotxdoc.hxx | 24 +++----- sw/inc/viewopt.hxx | 3 +- sw/source/core/view/vprint.cxx | 6 +- sw/source/ui/uno/unotxdoc.cxx | 121 ++++++++++++++++++----------------------- 4 files changed, 68 insertions(+), 86 deletions(-) (limited to 'sw') diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx index a5c39b2d928d..45a890aeab7d 100755 --- a/sw/inc/unotxdoc.hxx +++ b/sw/inc/unotxdoc.hxx @@ -29,9 +29,11 @@ ************************************************************************/ #ifndef _UNOTXDOC_HXX #define _UNOTXDOC_HXX + #include "swdllapi.h" #include #include + #include #include #include @@ -79,6 +81,8 @@ #include // helper for implementations #include +#include + #define __IFC32 Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12, Ifc13, Ifc14, Ifc15, Ifc16, \ Ifc17, Ifc18, Ifc19, Ifc20, Ifc21, Ifc22, Ifc23, Ifc24, Ifc25, Ifc26, Ifc27, Ifc28, Ifc29, Ifc30, Ifc31, Ifc32 @@ -129,7 +133,6 @@ class SwPrintUIOptions; class SwPrintData; class SwRenderData; class SwPrtOptions; -class SwViewOption; class SwWrtShell; @@ -597,20 +600,11 @@ public: -----------------------------------------------------------------------*/ class SwViewOptionAdjust_Impl { - // options not available in the File/Print UI, should be turned off for - // printing and PDF export if they are enabled - bool m_bSwitchOff_IsFldName; - - // options available in the File/Print UI, should be turned of for PDF export - // and otherwise set (or not) according to - // pPrtOptions->bPrintHiddenText and pPrtOptions->bPrintTextPlaceholder - bool m_bToggle_HiddenChar; - bool m_bToggle_HiddenField; - bool m_bToggle_HiddenParagraphs; - bool m_bToggle_PlaceHolderView; - - SwViewOption* m_pViewOption; - SwWrtShell& m_rShell; + SwWrtShell & m_rShell; + SwViewOption m_aOldViewOptions; + SwViewOption m_aRenderViewOptions; // view options to use when rendering for PDF export or printing + bool m_bRestoreViewOptions; + public: SwViewOptionAdjust_Impl( SwWrtShell& rSh, const SwPrtOptions *pPrtOptions ); ~SwViewOptionAdjust_Impl(); diff --git a/sw/inc/viewopt.hxx b/sw/inc/viewopt.hxx index 2ac47e284b49..8b2e4d5aa6fa 100755 --- a/sw/inc/viewopt.hxx +++ b/sw/inc/viewopt.hxx @@ -455,7 +455,8 @@ public: SwViewOption& operator=( const SwViewOption &rOpt ); // Vergleichsmethoden BOOL IsEqualFlags ( const SwViewOption &rOpt ) const; - inline BOOL operator==( const SwViewOption &rOpt ) const; + inline BOOL operator == ( const SwViewOption &rOpt ) const; + inline BOOL operator != ( const SwViewOption &rOpt ) const { return !(*this == rOpt); } /*--------------------------------------------------------------------------- diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index 87b8c5177e26..0de4da31370d 100755 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -285,14 +285,16 @@ void SwRenderData::DeletePostItData() void SwRenderData::ViewOptionAdjustStart( SwWrtShell& rSh, const SwPrtOptions *pPrtOptions ) { if (m_pViewOptionAdjust) - delete m_pViewOptionAdjust; + { + DBG_ASSERT( 0, "error: there should be no ViewOptionAdjustStart active when calling it again" ); + } m_pViewOptionAdjust = new SwViewOptionAdjust_Impl( rSh, pPrtOptions ); } void SwRenderData::ViewOptionAdjustStop() { - if (IsViewOptionAdjust()) + if (m_pViewOptionAdjust) { delete m_pViewOptionAdjust; m_pViewOptionAdjust = 0; diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index 2ac3e7f64508..4c3a86b97dce 100755 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -2720,12 +2720,19 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount( // We don't want that! Thus we disable updating of the view. pWrtShell->StartAction(); + const TypeId aSwViewTypeId = TYPE(SwView); + if (pView->IsA(aSwViewTypeId)) + { + // if there already is a not stopped view options adjustment we should return to + // the original values before calculating the new ones. + if (m_pRenderData->IsViewOptionAdjust()) + m_pRenderData->ViewOptionAdjustStop(); + } + m_pRenderData->SetSwPrtOptions( new SwPrtOptions( C2U( bIsPDFExport ? "PDF export" : "Printing" ) ) ); m_pRenderData->MakeSwPrtOptions( m_pRenderData->GetSwPrtOptionsRef(), pRenderDocShell, m_pPrintUIOptions, m_pRenderData, bIsPDFExport ); - //SwViewOptionAdjust_Impl aAdjust(*pWrtShell); - const TypeId aSwViewTypeId = TYPE(SwView); if (pView->IsA(aSwViewTypeId)) { // PDF export should not make use of the SwPrtOptions @@ -4057,11 +4064,12 @@ void SwXDocumentPropertyHelper::onChange() SwViewOptionAdjust_Impl::SwViewOptionAdjust_Impl( SwWrtShell& rSh, const SwPrtOptions *pPrtOptions ) : - m_pViewOption(0), - m_rShell(rSh) + m_rShell(rSh), + m_aOldViewOptions( *rSh.GetViewOptions() ), + m_bRestoreViewOptions( false ) { - const SwViewOption* pCurrentViewOptions = m_rShell.GetViewOptions(); - + // to avoid unnecessary reformatting the view options related to the content + // below should only change if necessary, that is if respective content is present const bool bContainsHiddenChars = m_rShell.GetDoc()->ContainsHiddenChars(); const SwFieldType* pFldType = m_rShell.GetDoc()->GetSysFldType( RES_HIDDENTXTFLD ); const bool bContainsHiddenFields = pFldType && pFldType->GetDepends(); @@ -4069,54 +4077,47 @@ SwViewOptionAdjust_Impl::SwViewOptionAdjust_Impl( const bool bContainsHiddenParagraphs = pFldType && pFldType->GetDepends(); pFldType = m_rShell.GetDoc()->GetSysFldType( RES_JUMPEDITFLD ); const bool bContainsPlaceHolders = pFldType && pFldType->GetDepends(); - - m_bSwitchOff_IsFldName = m_rShell.IsAnyFieldInDoc() && pCurrentViewOptions->IsFldName(); - - // for printing only (not PDF export) take print options into account - if (pPrtOptions) - { - m_bToggle_PlaceHolderView = bContainsPlaceHolders && pPrtOptions->bPrintTextPlaceholder != pCurrentViewOptions->IsShowPlaceHolderFields(); - m_bToggle_HiddenChar = bContainsHiddenChars && pPrtOptions->bPrintHiddenText != pCurrentViewOptions->IsShowHiddenChar( TRUE ); - m_bToggle_HiddenField = bContainsHiddenFields && pPrtOptions->bPrintHiddenText != pCurrentViewOptions->IsShowHiddenField(); - m_bToggle_HiddenParagraphs = bContainsHiddenParagraphs && pPrtOptions->bPrintHiddenText != pCurrentViewOptions->IsShowHiddenPara(); - } - else + const bool bContainsFields = m_rShell.IsAnyFieldInDoc(); + + // disable anything in the view that should not be printed (or exported to PDF) by default + // (see also dialog "Tools/Options - StarOffice Writer - Formatting Aids" + // in section "Display of ...") + m_aRenderViewOptions = m_aOldViewOptions; + m_aRenderViewOptions.SetParagraph( FALSE ); // paragraph end + m_aRenderViewOptions.SetSoftHyph( FALSE ); // aka custom hyphens + m_aRenderViewOptions.SetBlank( FALSE ); // spaces + m_aRenderViewOptions.SetHardBlank( FALSE ); // non-breaking spaces + m_aRenderViewOptions.SetTab( FALSE ); // tabs + m_aRenderViewOptions.SetLineBreak( FALSE ); // breaks (type 1) + m_aRenderViewOptions.SetPageBreak( FALSE ); // breaks (type 2) + m_aRenderViewOptions.SetColumnBreak( FALSE ); // breaks (type 3) + BOOL bVal = pPrtOptions? pPrtOptions->bPrintHiddenText : FALSE; + if (bContainsHiddenChars) + m_aRenderViewOptions.SetShowHiddenChar( bVal ); // hidden text + if (bContainsHiddenFields) + m_aRenderViewOptions.SetShowHiddenField( bVal ); + if (bContainsHiddenParagraphs) + m_aRenderViewOptions.SetShowHiddenPara( bVal ); + + if (bContainsPlaceHolders) { - //toggle painting of placeholder fields - m_bToggle_PlaceHolderView = bContainsPlaceHolders && pCurrentViewOptions->IsShowPlaceHolderFields(); - //toggle display of hidden characters if on and hidden characters are in use - m_bToggle_HiddenChar = bContainsHiddenChars && pCurrentViewOptions->IsShowHiddenChar( FALSE ); - //toggle display of hidden fields if on and hidden fields are in use - m_bToggle_HiddenField = bContainsHiddenFields && pCurrentViewOptions->IsShowHiddenField(); - //toggle display of hidden paragraphs if on and hidden paragraphs are in use - m_bToggle_HiddenParagraphs = bContainsHiddenParagraphs && pCurrentViewOptions->IsShowHiddenPara(); + // should always be printed in PDF export! + bVal = pPrtOptions ? pPrtOptions->bPrintTextPlaceholder : TRUE; + m_aRenderViewOptions.SetShowPlaceHolderFields( bVal ); } - // bApplyViewOptions should only be true if necessary to avoid reformating if not required, - bool bApplyViewOptions = m_bSwitchOff_IsFldName; - bApplyViewOptions |= m_bToggle_PlaceHolderView; - bApplyViewOptions |= m_bToggle_HiddenChar; - bApplyViewOptions |= m_bToggle_HiddenField; - bApplyViewOptions |= m_bToggle_HiddenParagraphs; - if(bApplyViewOptions) + if (bContainsFields) + m_aRenderViewOptions.SetFldName( FALSE ); + + // we don't want to print those. + // Also this flag has effect on printing of other content e.g. hidden text + m_aRenderViewOptions.SetViewMetaChars( FALSE ); + + if (m_aOldViewOptions != m_aRenderViewOptions) // check if reformatting is necessary { - m_pViewOption = new SwViewOption( *pCurrentViewOptions ); - - // set flag to hint that everything should be formatted for printing, - // (needed at some places to print hidden text if that option is set in the dialog, etc.) - m_pViewOption->SetPrinting( TRUE ); - - if(m_bSwitchOff_IsFldName) - m_pViewOption->SetFldName(FALSE); - if(m_bToggle_PlaceHolderView) - m_pViewOption->SetShowPlaceHolderFields( !pCurrentViewOptions->IsShowPlaceHolderFields() ); - if(m_bToggle_HiddenChar) - m_pViewOption->SetShowHiddenChar( !pCurrentViewOptions->IsShowHiddenChar( TRUE ) ); - if(m_bToggle_HiddenField) - m_pViewOption->SetShowHiddenField( !pCurrentViewOptions->IsShowHiddenField() ); - if(m_bToggle_HiddenParagraphs) - m_pViewOption->SetShowHiddenPara( !pCurrentViewOptions->IsShowHiddenPara() ); - SW_MOD()->ApplyUsrPref(*m_pViewOption, &m_rShell.GetView(), VIEWOPT_DEST_VIEW_ONLY ); + m_aRenderViewOptions.SetPrinting( pPrtOptions != NULL ); + m_bRestoreViewOptions = true; + SW_MOD()->ApplyUsrPref( m_aRenderViewOptions, &m_rShell.GetView(), VIEWOPT_DEST_VIEW_ONLY ); } } @@ -4124,24 +4125,8 @@ SwViewOptionAdjust_Impl::SwViewOptionAdjust_Impl( SwViewOptionAdjust_Impl::~SwViewOptionAdjust_Impl() { - if(m_pViewOption) - { - m_pViewOption->SetPrinting( FALSE ); - - const SwViewOption* pCurrentViewOptions = m_rShell.GetViewOptions(); - if(m_bSwitchOff_IsFldName) - m_pViewOption->SetFldName(TRUE); - if(m_bToggle_HiddenChar) - m_pViewOption->SetShowHiddenChar( !pCurrentViewOptions->IsShowHiddenChar() ); - if(m_bToggle_HiddenField) - m_pViewOption->SetShowHiddenField( !pCurrentViewOptions->IsShowHiddenField() ); - if(m_bToggle_HiddenParagraphs) - m_pViewOption->SetShowHiddenPara( !pCurrentViewOptions->IsShowHiddenPara() ); - if(m_bToggle_PlaceHolderView) - m_pViewOption->SetShowPlaceHolderFields( !pCurrentViewOptions->IsShowPlaceHolderFields() ); - SW_MOD()->ApplyUsrPref(*m_pViewOption, &m_rShell.GetView(), VIEWOPT_DEST_VIEW_ONLY ); - delete m_pViewOption; m_pViewOption = NULL; - } + if (m_bRestoreViewOptions) + SW_MOD()->ApplyUsrPref( m_aOldViewOptions, &m_rShell.GetView(), VIEWOPT_DEST_VIEW_ONLY ); } /*****************************************************************************/ -- cgit From af8a4cf23931e9b26d31683292dfe56cec2e97cb Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Fri, 11 Dec 2009 16:17:51 +0100 Subject: #i106926# fixing view settings after rendering --- sw/inc/printdata.hxx | 3 +- sw/inc/unotxdoc.hxx | 8 +++-- sw/source/core/view/vprint.cxx | 12 +++++-- sw/source/ui/uno/unotxdoc.cxx | 80 +++++++++++++++++++++--------------------- 4 files changed, 56 insertions(+), 47 deletions(-) (limited to 'sw') diff --git a/sw/inc/printdata.hxx b/sw/inc/printdata.hxx index 75f16d01ace3..3368418354cf 100755 --- a/sw/inc/printdata.hxx +++ b/sw/inc/printdata.hxx @@ -267,7 +267,8 @@ public: void DeletePostItData(); bool IsViewOptionAdjust() const { return m_pViewOptionAdjust != 0; } - void ViewOptionAdjustStart( SwWrtShell& rSh, const SwPrtOptions *pPrtOptions ); + void ViewOptionAdjustStart( SwWrtShell &rSh, const SwViewOption &rViewOptions ); + void ViewOptionAdjust( const SwPrtOptions *pPrtOptions ); void ViewOptionAdjustStop(); bool HasSwPrtOptions() const { return m_pPrtOptions != 0; } diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx index 45a890aeab7d..39438bbc3add 100755 --- a/sw/inc/unotxdoc.hxx +++ b/sw/inc/unotxdoc.hxx @@ -602,12 +602,14 @@ class SwViewOptionAdjust_Impl { SwWrtShell & m_rShell; SwViewOption m_aOldViewOptions; - SwViewOption m_aRenderViewOptions; // view options to use when rendering for PDF export or printing - bool m_bRestoreViewOptions; +// SwViewOption m_aRenderViewOptions; // view options to use when rendering for PDF export or printing +// bool m_bRestoreViewOptions; public: - SwViewOptionAdjust_Impl( SwWrtShell& rSh, const SwPrtOptions *pPrtOptions ); + SwViewOptionAdjust_Impl( SwWrtShell& rSh, const SwViewOption &rViewOptions ); ~SwViewOptionAdjust_Impl(); + + void AdjustViewOptions( const SwPrtOptions *pPrtOptions ); }; diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index 0de4da31370d..bab2428c0b67 100755 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -282,13 +282,19 @@ void SwRenderData::DeletePostItData() } -void SwRenderData::ViewOptionAdjustStart( SwWrtShell& rSh, const SwPrtOptions *pPrtOptions ) +void SwRenderData::ViewOptionAdjustStart( SwWrtShell &rSh, const SwViewOption &rViewOptions ) { if (m_pViewOptionAdjust) { - DBG_ASSERT( 0, "error: there should be no ViewOptionAdjustStart active when calling it again" ); + DBG_ASSERT( 0, "error: there should be no ViewOptionAdjust active when calling this function" ); } - m_pViewOptionAdjust = new SwViewOptionAdjust_Impl( rSh, pPrtOptions ); + m_pViewOptionAdjust = new SwViewOptionAdjust_Impl( rSh, rViewOptions ); +} + + +void SwRenderData::ViewOptionAdjust( const SwPrtOptions *pPrtOptions ) +{ + m_pViewOptionAdjust->AdjustViewOptions( pPrtOptions ); } diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index 1917228b347b..6c6194555559 100755 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -2723,10 +2723,8 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount( const TypeId aSwViewTypeId = TYPE(SwView); if (pView->IsA(aSwViewTypeId)) { - // if there already is a not stopped view options adjustment we should return to - // the original values before calculating the new ones. - if (m_pRenderData->IsViewOptionAdjust()) - m_pRenderData->ViewOptionAdjustStop(); + if (m_pRenderData && !m_pRenderData->IsViewOptionAdjust()) + m_pRenderData->ViewOptionAdjustStart( *pWrtShell, *pWrtShell->GetViewOptions() ); } m_pRenderData->SetSwPrtOptions( new SwPrtOptions( C2U( bIsPDFExport ? "PDF export" : "Printing" ) ) ); @@ -2737,7 +2735,7 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount( { // PDF export should not make use of the SwPrtOptions const SwPrtOptions *pPrtOptions = bIsPDFExport? NULL : m_pRenderData->GetSwPrtOptions(); - m_pRenderData->ViewOptionAdjustStart( *((SwView*)pView)->GetWrtShellPtr(), pPrtOptions ); + m_pRenderData->ViewOptionAdjust( pPrtOptions ); } // since printing now also use the API for PDF export this option @@ -3078,7 +3076,7 @@ void SAL_CALL SwXTextDocument::render( // -> do clean-up of data if (bLastPage) { - // #i96167# haggai: delete pViewOptionsAdjust here because it makes use + // #i96167# haggai: delete ViewOptionsAdjust here because it makes use // of the shell, which might get destroyed in lcl_DisposeView! if (m_pRenderData && m_pRenderData->IsViewOptionAdjust()) m_pRenderData->ViewOptionAdjustStop(); @@ -4061,12 +4059,21 @@ void SwXDocumentPropertyHelper::onChange() /*****************************************************************************/ -SwViewOptionAdjust_Impl::SwViewOptionAdjust_Impl( - SwWrtShell& rSh, - const SwPrtOptions *pPrtOptions ) : - m_rShell(rSh), - m_aOldViewOptions( *rSh.GetViewOptions() ), - m_bRestoreViewOptions( false ) +SwViewOptionAdjust_Impl::SwViewOptionAdjust_Impl( SwWrtShell& rSh, const SwViewOption &rViewOptions ) : + m_rShell( rSh ), + m_aOldViewOptions( rViewOptions ) +{ +} + + +SwViewOptionAdjust_Impl::~SwViewOptionAdjust_Impl() +{ + m_rShell.ApplyViewOptions( m_aOldViewOptions ); +} + + +void SwViewOptionAdjust_Impl::AdjustViewOptions( + const SwPrtOptions *pPrtOptions ) { // to avoid unnecessary reformatting the view options related to the content // below should only change if necessary, that is if respective content is present @@ -4079,56 +4086,49 @@ SwViewOptionAdjust_Impl::SwViewOptionAdjust_Impl( const bool bContainsPlaceHolders = pFldType && pFldType->GetDepends(); const bool bContainsFields = m_rShell.IsAnyFieldInDoc(); + SwViewOption aRenderViewOptions( m_aOldViewOptions ); + // disable anything in the view that should not be printed (or exported to PDF) by default // (see also dialog "Tools/Options - StarOffice Writer - Formatting Aids" // in section "Display of ...") - m_aRenderViewOptions = m_aOldViewOptions; - m_aRenderViewOptions.SetParagraph( FALSE ); // paragraph end - m_aRenderViewOptions.SetSoftHyph( FALSE ); // aka custom hyphens - m_aRenderViewOptions.SetBlank( FALSE ); // spaces - m_aRenderViewOptions.SetHardBlank( FALSE ); // non-breaking spaces - m_aRenderViewOptions.SetTab( FALSE ); // tabs - m_aRenderViewOptions.SetLineBreak( FALSE ); // breaks (type 1) - m_aRenderViewOptions.SetPageBreak( FALSE ); // breaks (type 2) - m_aRenderViewOptions.SetColumnBreak( FALSE ); // breaks (type 3) + aRenderViewOptions.SetParagraph( FALSE ); // paragraph end + aRenderViewOptions.SetSoftHyph( FALSE ); // aka custom hyphens + aRenderViewOptions.SetBlank( FALSE ); // spaces + aRenderViewOptions.SetHardBlank( FALSE ); // non-breaking spaces + aRenderViewOptions.SetTab( FALSE ); // tabs + aRenderViewOptions.SetLineBreak( FALSE ); // breaks (type 1) + aRenderViewOptions.SetPageBreak( FALSE ); // breaks (type 2) + aRenderViewOptions.SetColumnBreak( FALSE ); // breaks (type 3) BOOL bVal = pPrtOptions? pPrtOptions->bPrintHiddenText : FALSE; if (bContainsHiddenChars) - m_aRenderViewOptions.SetShowHiddenChar( bVal ); // hidden text + aRenderViewOptions.SetShowHiddenChar( bVal ); // hidden text if (bContainsHiddenFields) - m_aRenderViewOptions.SetShowHiddenField( bVal ); + aRenderViewOptions.SetShowHiddenField( bVal ); if (bContainsHiddenParagraphs) - m_aRenderViewOptions.SetShowHiddenPara( bVal ); + aRenderViewOptions.SetShowHiddenPara( bVal ); if (bContainsPlaceHolders) { // should always be printed in PDF export! bVal = pPrtOptions ? pPrtOptions->bPrintTextPlaceholder : TRUE; - m_aRenderViewOptions.SetShowPlaceHolderFields( bVal ); + aRenderViewOptions.SetShowPlaceHolderFields( bVal ); } if (bContainsFields) - m_aRenderViewOptions.SetFldName( FALSE ); + aRenderViewOptions.SetFldName( FALSE ); - // we don't want to print those. - // Also this flag has effect on printing of other content e.g. hidden text - m_aRenderViewOptions.SetViewMetaChars( FALSE ); + // we need to set this flag in order to get to see the visible effect of + // some of the above settings (needed for correct rendering) + aRenderViewOptions.SetViewMetaChars( TRUE ); - if (m_aOldViewOptions != m_aRenderViewOptions) // check if reformatting is necessary + if (m_aOldViewOptions != aRenderViewOptions) // check if reformatting is necessary { - m_aRenderViewOptions.SetPrinting( pPrtOptions != NULL ); - m_bRestoreViewOptions = true; - SW_MOD()->ApplyUsrPref( m_aRenderViewOptions, &m_rShell.GetView(), VIEWOPT_DEST_VIEW_ONLY ); + aRenderViewOptions.SetPrinting( pPrtOptions != NULL ); + m_rShell.ApplyViewOptions( aRenderViewOptions ); } - } -SwViewOptionAdjust_Impl::~SwViewOptionAdjust_Impl() -{ - if (m_bRestoreViewOptions) - SW_MOD()->ApplyUsrPref( m_aOldViewOptions, &m_rShell.GetView(), VIEWOPT_DEST_VIEW_ONLY ); -} - /*****************************************************************************/ -- cgit From b610fe1983c35ea9073418ebb5cc2e6f056f039a Mon Sep 17 00:00:00 2001 From: Henning Brinkmann Date: Mon, 14 Dec 2009 12:25:38 +0000 Subject: #161286# applied patch and solved crash --- sw/source/filter/ww8/ww8graf.cxx | 5 ++-- sw/source/filter/ww8/ww8par.cxx | 15 ++++++----- sw/source/filter/ww8/ww8par2.cxx | 31 ++++++++++++++-------- sw/source/filter/ww8/ww8scan.cxx | 55 ++++++++++++++++++++++++++++------------ sw/source/filter/ww8/ww8scan.hxx | 2 ++ 5 files changed, 73 insertions(+), 35 deletions(-) (limited to 'sw') diff --git a/sw/source/filter/ww8/ww8graf.cxx b/sw/source/filter/ww8/ww8graf.cxx index 0553267d12ed..e1c5b2509228 100644 --- a/sw/source/filter/ww8/ww8graf.cxx +++ b/sw/source/filter/ww8/ww8graf.cxx @@ -506,14 +506,15 @@ ESelection SwWW8ImplReader::GetESelection( long nCpStart, long nCpEnd ) // ItemSet gestopft. void SwWW8ImplReader::InsertTxbxStyAttrs( SfxItemSet& rS, USHORT nColl ) { - if( nColl < nColls && pCollA[nColl].pFmt && pCollA[nColl].bColl ) + SwWW8StyInf * pStyInf = GetStyle(nColl); + if( pStyInf != NULL && pStyInf->pFmt && pStyInf->bColl ) { const SfxPoolItem* pItem; for( USHORT i = POOLATTR_BEGIN; i < POOLATTR_END; i++ ) { //If we are set in the source and not set in the destination //then add it in. - if ( SFX_ITEM_SET == pCollA[nColl].pFmt->GetItemState( + if ( SFX_ITEM_SET == pStyInf->pFmt->GetItemState( i, true, &pItem ) ) { SfxItemPool *pEditPool = rS.GetPool(); diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index b92f80c85290..05d79c7d6abf 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -989,7 +989,7 @@ const SfxPoolItem* SwWW8FltControlStack::GetFmtAttr(const SwPosition& rPos, SfxItemState eState = SFX_ITEM_DEFAULT; if (const SfxItemSet *pSet = pNd->GetpSwAttrSet()) eState = pSet->GetItemState(RES_LR_SPACE, false); - if (eState != SFX_ITEM_SET) + if (eState != SFX_ITEM_SET && rReader.pCollA != NULL) pItem = &(rReader.pCollA[rReader.nAktColl].maWordLR); } @@ -2163,7 +2163,7 @@ CharSet SwWW8ImplReader::GetCurrentCharSet() eSrcCharSet = maFontSrcCharSets.top(); if ((eSrcCharSet == RTL_TEXTENCODING_DONTKNOW) && (nCharFmt != -1)) eSrcCharSet = pCollA[nCharFmt].GetCharSet(); - if (eSrcCharSet == RTL_TEXTENCODING_DONTKNOW) + if ((eSrcCharSet == RTL_TEXTENCODING_DONTKNOW) && StyleExists(nAktColl)) eSrcCharSet = pCollA[nAktColl].GetCharSet(); if (eSrcCharSet == RTL_TEXTENCODING_DONTKNOW) { // patch from cmc for #i52786# @@ -2221,10 +2221,13 @@ CharSet SwWW8ImplReader::GetCurrentCJKCharSet() { if (!maFontSrcCJKCharSets.empty()) eSrcCharSet = maFontSrcCJKCharSets.top(); - if ((eSrcCharSet == RTL_TEXTENCODING_DONTKNOW) && (nCharFmt != -1)) - eSrcCharSet = pCollA[nCharFmt].GetCJKCharSet(); - if (eSrcCharSet == RTL_TEXTENCODING_DONTKNOW) - eSrcCharSet = pCollA[nAktColl].GetCJKCharSet(); + if (pCollA != NULL) + { + if ((eSrcCharSet == RTL_TEXTENCODING_DONTKNOW) && (nCharFmt != -1)) + eSrcCharSet = pCollA[nCharFmt].GetCJKCharSet(); + if (eSrcCharSet == RTL_TEXTENCODING_DONTKNOW) + eSrcCharSet = pCollA[nAktColl].GetCJKCharSet(); + } if (eSrcCharSet == RTL_TEXTENCODING_DONTKNOW) { // patch from cmc for #i52786# /* diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx index 795cfb749531..afbf4b3593c1 100644 --- a/sw/source/filter/ww8/ww8par2.cxx +++ b/sw/source/filter/ww8/ww8par2.cxx @@ -827,7 +827,8 @@ void SwWW8ImplReader::Read_ANLevelNo( USHORT, const BYTE* pData, short nLen ) { // nur fuer SwTxtFmtColl, nicht CharFmt // WW: 0 = no Numbering - if (pCollA[nAktColl].bColl && *pData) + SwWW8StyInf * pColl = GetStyle(nAktColl); + if (pColl != NULL && pColl->bColl && *pData) { // Bereich WW:1..9 -> SW:0..8 keine Aufzaehlung / Nummerierung @@ -861,12 +862,16 @@ void SwWW8ImplReader::Read_ANLevelNo( USHORT, const BYTE* pData, short nLen ) void SwWW8ImplReader::Read_ANLevelDesc( USHORT, const BYTE* pData, short nLen ) // Sprm 12 { - if( !pAktColl || nLen <= 0 // nur bei Styledef - || !pCollA[nAktColl].bColl // CharFmt -> ignorieren - || ( nIniFlags & WW8FL_NO_OUTLINE ) ){ - nSwNumLevel = 0xff; - return; + { + SwWW8StyInf * pStyInf = GetStyle(nAktColl); + if( !pAktColl || nLen <= 0 // nur bei Styledef + || (pStyInf && !pStyInf->bColl) // CharFmt -> ignorieren + || ( nIniFlags & WW8FL_NO_OUTLINE ) ){ + nSwNumLevel = 0xff; + return; + } } + if( nSwNumLevel <= MAXLEVEL // Bereich WW:1..9 -> SW:0..8 && nSwNumLevel <= 9 ){ // keine Aufzaehlung / Nummerierung @@ -892,7 +897,10 @@ void SwWW8ImplReader::Read_ANLevelDesc( USHORT, const BYTE* pData, short nLen ) SwNumRule* pNR = GetStyRule(); SetAnld(pNR, (WW8_ANLD*)pData, 0, false); pAktColl->SetFmtAttr( SwNumRuleItem( pNR->GetName() ) ); - pCollA[nAktColl].bHasStyNumRule = true; + + SwWW8StyInf * pStyInf = GetStyle(nAktColl); + if (pStyInf != NULL) + pStyInf->bHasStyNumRule = true; } } @@ -1007,9 +1015,10 @@ void SwWW8ImplReader::StartAnl(const BYTE* pSprm13) } } - if (!sNumRule.Len() && pCollA[nAktColl].bHasStyNumRule) + SwWW8StyInf * pStyInf = GetStyle(nAktColl); + if (!sNumRule.Len() && pStyInf->bHasStyNumRule) { - sNumRule = pCollA[nAktColl].pFmt->GetNumRule().GetValue(); + sNumRule = pStyInf->pFmt->GetNumRule().GetValue(); pNumRule = rDoc.FindNumRulePtr(sNumRule); if (!pNumRule) sNumRule.Erase(); @@ -3918,8 +3927,8 @@ WW8RStyle::WW8RStyle(WW8Fib& _rFib, SwWW8ImplReader* pI) : WW8Style(*pI->pTableStream, _rFib), maSprmParser(_rFib.GetFIBVersion()), pIo(pI), pStStrm(pI->pTableStream), pStyRule(0), nWwNumLevel(0) { - pIo->pCollA = new SwWW8StyInf[ cstd ]; // Style-UEbersetzung WW->SW pIo->nColls = cstd; + pIo->pCollA = cstd ? new SwWW8StyInf[ cstd ] : NULL; // Style-UEbersetzung WW->SW } void WW8RStyle::Set1StyleDefaults() @@ -4691,7 +4700,7 @@ void WW8RStyle::Import() // // fuer z.B. Tabellen wird ein immer gueltiger Std-Style gebraucht - if( pIo->pCollA[0].pFmt && pIo->pCollA[0].bColl && pIo->pCollA[0].bValid ) + if( pIo->StyleExists(0) && pIo->pCollA[0].pFmt && pIo->pCollA[0].bColl && pIo->pCollA[0].bValid ) pIo->pDfltTxtFmtColl = (SwTxtFmtColl*)pIo->pCollA[0].pFmt; else pIo->pDfltTxtFmtColl = pIo->rDoc.GetDfltTxtFmtColl(); diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx index f20c13889f27..0f3acfaabb4e 100644 --- a/sw/source/filter/ww8/ww8scan.cxx +++ b/sw/source/filter/ww8/ww8scan.cxx @@ -2281,22 +2281,48 @@ WW8PLCF::WW8PLCF( SvStream* pSt, WW8_FC nFilePos, INT32 nPLCF, int nStruct, void WW8PLCF::ReadPLCF( SvStream* pSt, WW8_FC nFilePos, INT32 nPLCF ) { + bool failure = false; + // Pointer auf Pos-Array pPLCF_PosArray = new WW8_CP[ ( nPLCF + 3 ) / 4 ]; sal_Size nOldPos = pSt->Tell(); pSt->Seek( nFilePos ); - pSt->Read( pPLCF_PosArray, nPLCF ); + failure = pSt->GetError(); + + if (!failure) + { + pSt->Read( pPLCF_PosArray, nPLCF ); + failure = pSt->GetError(); + } + + if (!failure) + { #ifdef OSL_BIGENDIAN - for( nIdx = 0; nIdx <= nIMax; nIdx++ ) - pPLCF_PosArray[nIdx] = SWAPLONG( pPLCF_PosArray[nIdx] ); - nIdx = 0; + for( nIdx = 0; nIdx <= nIMax; nIdx++ ) + pPLCF_PosArray[nIdx] = SWAPLONG( pPLCF_PosArray[nIdx] ); + nIdx = 0; #endif // OSL_BIGENDIAN - // Pointer auf Inhalts-Array - pPLCF_Contents = (BYTE*)&pPLCF_PosArray[nIMax + 1]; + // Pointer auf Inhalts-Array + pPLCF_Contents = (BYTE*)&pPLCF_PosArray[nIMax + 1]; + } pSt->Seek( nOldPos ); + + ASSERT( !failure, "Document has corrupt PLCF, ignoring it" ); + + if (failure) + MakeFailedPLCF(); +} + +void WW8PLCF::MakeFailedPLCF() +{ + nIMax = 0; + delete[] pPLCF_PosArray; + pPLCF_PosArray = new INT32[2]; + pPLCF_PosArray[0] = pPLCF_PosArray[1] = WW8_CP_MAX; + pPLCF_Contents = (BYTE*)&pPLCF_PosArray[nIMax + 1]; } void WW8PLCF::GeneratePLCF( SvStream* pSt, INT32 nPN, INT32 ncpN ) @@ -2359,13 +2385,7 @@ void WW8PLCF::GeneratePLCF( SvStream* pSt, INT32 nPN, INT32 ncpN ) ASSERT( !failure, "Document has corrupt PLCF, ignoring it" ); if (failure) - { - nIMax = 0; - delete[] pPLCF_PosArray; - pPLCF_PosArray = new INT32[2]; - pPLCF_PosArray[0] = pPLCF_PosArray[1] = WW8_CP_MAX; - pPLCF_Contents = (BYTE*)&pPLCF_PosArray[nIMax + 1]; - } + MakeFailedPLCF(); } bool WW8PLCF::SeekPos(WW8_CP nPos) @@ -6240,8 +6260,11 @@ WW8Fonts::WW8Fonts( SvStream& rSt, WW8Fib& rFib ) rSt.Seek( rFib.fcSttbfffn ); + INT32 nFFn = rFib.lcbSttbfffn - 2; + // allocate Font Array - BYTE* pA = new BYTE[ rFib.lcbSttbfffn - 2 ]; + BYTE* pA = new BYTE[ nFFn ]; + memset(pA, 0, nFFn); WW8_FFN* p = (WW8_FFN*)pA; ww::WordVersion eVersion = rFib.GetFIBVersion(); @@ -6258,13 +6281,13 @@ WW8Fonts::WW8Fonts( SvStream& rSt, WW8Fib& rFib ) rSt.SeekRel( 2 ); // read all font information - rSt.Read( pA, rFib.lcbSttbfffn - 2 ); + nFFn = rSt.Read( pA, nFFn ); if( eVersion < ww::eWW8 ) { // try to figure out how many fonts are defined here nMax = 0; - long nLeft = rFib.lcbSttbfffn - 2; + long nLeft = nFFn; for(;;) { short nNextSiz; diff --git a/sw/source/filter/ww8/ww8scan.hxx b/sw/source/filter/ww8/ww8scan.hxx index 3547eaf99391..85c80ba51025 100644 --- a/sw/source/filter/ww8/ww8scan.hxx +++ b/sw/source/filter/ww8/ww8scan.hxx @@ -295,6 +295,8 @@ private: machen wir uns hiermit einen PLC: */ void GeneratePLCF( SvStream* pSt, INT32 nPN, INT32 ncpN ); + + void MakeFailedPLCF(); public: WW8PLCF( SvStream* pSt, WW8_FC nFilePos, INT32 nPLCF, int nStruct, WW8_CP nStartPos = -1 ); -- cgit From d8b779f2d3b99a845a391a25d43ccfa48c53b4f5 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 4 Jan 2010 12:57:09 +0000 Subject: exchgcmtdoc2: #i98634#: export writer change-comment as normal msword comment --- sw/source/filter/ww8/wrtw8sty.cxx | 63 ++++++++++++++++++++++------- sw/source/filter/ww8/wrtww8.cxx | 6 +-- sw/source/filter/ww8/wrtww8.hxx | 28 +++++++++---- sw/source/filter/ww8/ww8atr.cxx | 22 +++++++++- sw/source/filter/ww8/ww8attributeoutput.hxx | 3 +- sw/source/filter/ww8/ww8par.cxx | 5 ++- sw/source/filter/ww8/ww8scan.cxx | 11 ++--- 7 files changed, 103 insertions(+), 35 deletions(-) (limited to 'sw') diff --git a/sw/source/filter/ww8/wrtw8sty.cxx b/sw/source/filter/ww8/wrtw8sty.cxx index 70756840603c..8e6b0c77b878 100644 --- a/sw/source/filter/ww8/wrtw8sty.cxx +++ b/sw/source/filter/ww8/wrtw8sty.cxx @@ -72,6 +72,7 @@ #include #include #include +#include #include @@ -1856,13 +1857,48 @@ void WW8_WrPlcFtnEdn::Append( WW8_CP nCp, const SwFmtFtn& rFtn ) aCntnt.Insert( p, aCntnt.Count() ); } -void WW8_WrPlcPostIt::Append( WW8_CP nCp, const SwPostItField& rPostIt ) +WW8_Annotation::WW8_Annotation(const SwPostItField* pPostIt) +{ + mpRichText = pPostIt->GetTextObject(); + if (!mpRichText) + msSimpleText = pPostIt->GetTxt(); + msOwner = pPostIt->GetPar1(); + maDateTime = DateTime(pPostIt->GetDate(), pPostIt->GetTime()); +} + +WW8_Annotation::WW8_Annotation(const SwRedlineData* pRedline) : mpRichText(0) +{ + msSimpleText = pRedline->GetComment(); + msOwner = SW_MOD()->GetRedlineAuthor(pRedline->GetAuthor()); + maDateTime = pRedline->GetTimeStamp(); +} + +void WW8_WrPlcAnnotations::Append( WW8_CP nCp, const SwPostItField *pPostIt ) { aCps.Insert( nCp, aCps.Count() ); - void* p = (void*)&rPostIt; + WW8_Annotation* p = new WW8_Annotation(pPostIt); aCntnt.Insert( p, aCntnt.Count() ); } +void WW8_WrPlcAnnotations::Append( WW8_CP nCp, const SwRedlineData *pRedline ) +{ + maProcessedRedlines.insert(pRedline); + aCps.Insert( nCp, aCps.Count() ); + WW8_Annotation* p = new WW8_Annotation(pRedline); + aCntnt.Insert( p, aCntnt.Count() ); +} + +bool WW8_WrPlcAnnotations::IsNewRedlineComment( const SwRedlineData *pRedline ) +{ + return maProcessedRedlines.find(pRedline) == maProcessedRedlines.end(); +} + +WW8_WrPlcAnnotations::~WW8_WrPlcAnnotations() +{ + for( USHORT n=0; n < aCntnt.Count(); n++ ) + delete (WW8_Annotation*)aCntnt[n]; +} + bool WW8_WrPlcSubDoc::WriteGenericTxt( WW8Export& rWrt, BYTE nTTyp, WW8_CP& rCount ) { @@ -1882,13 +1918,13 @@ bool WW8_WrPlcSubDoc::WriteGenericTxt( WW8Export& rWrt, BYTE nTTyp, // Anfaenge fuer PlcfAtnTxt pTxtPos->Append( rWrt.Fc2Cp( rWrt.Strm().Tell() )); - const SwPostItField& rPFld = *(SwPostItField*)aCntnt[ i ]; rWrt.WritePostItBegin(); - if (const OutlinerParaObject* pOutliner = rPFld.GetTextObject()) - rWrt.WriteOutliner(*pOutliner, nTTyp); + const WW8_Annotation& rAtn = *(const WW8_Annotation*)aCntnt[i]; + if (rAtn.mpRichText) + rWrt.WriteOutliner(*rAtn.mpRichText, nTTyp); else { - String sTxt(rPFld.GetTxt()); + String sTxt(rAtn.msSimpleText); sTxt.SearchAndReplaceAll(0x0A, 0x0B); rWrt.WriteStringAsPara( sTxt ); } @@ -2015,8 +2051,8 @@ void WW8_WrPlcSubDoc::WriteGenericPlc( WW8Export& rWrt, BYTE nTTyp, // then write first the GrpXstAtnOwners for ( i = 0; i < nLen; ++i ) { - const SwPostItField& rPFld = *(SwPostItField*)aCntnt[ i ]; - aStrArr.push_back(rPFld.GetPar1()); + const WW8_Annotation& rAtn = *(const WW8_Annotation*)aCntnt[i]; + aStrArr.push_back(rAtn.msOwner); } //sort and remove duplicates @@ -2054,10 +2090,9 @@ void WW8_WrPlcSubDoc::WriteGenericPlc( WW8Export& rWrt, BYTE nTTyp, { for( i = 0; i < nLen; ++i ) { - const SwPostItField& rPFld = *(SwPostItField*)aCntnt[ i ]; + const WW8_Annotation& rAtn = *(const WW8_Annotation*)aCntnt[i]; - sal_uInt32 nDTTM = - sw::ms::DateTime2DTTM(DateTime(rPFld.GetDate(),rPFld.GetTime())); + sal_uInt32 nDTTM = sw::ms::DateTime2DTTM(rAtn.maDateTime); SwWW8Writer::WriteLong( *rWrt.pTableStrm, nDTTM ); SwWW8Writer::WriteShort( *rWrt.pTableStrm, 0 ); @@ -2137,12 +2172,12 @@ void WW8_WrPlcSubDoc::WriteGenericPlc( WW8Export& rWrt, BYTE nTTyp, { for ( i = 0; i < nLen; ++i ) { - const SwPostItField& rPFld = *(SwPostItField*)aCntnt[ i ]; + const WW8_Annotation& rAtn = *(const WW8_Annotation*)aCntnt[i]; //aStrArr is sorted myiter aIter = ::std::lower_bound(aStrArr.begin(), - aStrArr.end(), rPFld.GetPar1()); - ASSERT(aIter != aStrArr.end() && *aIter == rPFld.GetPar1(), + aStrArr.end(), rAtn.msOwner); + ASSERT(aIter != aStrArr.end() && *aIter == rAtn.msOwner, "Impossible"); sal_uInt16 nFndPos = static_cast< sal_uInt16 >(aIter - aStrArr.begin()); String sAuthor(*aIter); diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx index fb121eb322f7..fb5ce68ec654 100644 --- a/sw/source/filter/ww8/wrtww8.cxx +++ b/sw/source/filter/ww8/wrtww8.cxx @@ -3039,7 +3039,7 @@ void WW8Export::ExportDocument_Impl() pFtn = new WW8_WrPlcFtnEdn( TXT_FTN ); // Footnotes pEdn = new WW8_WrPlcFtnEdn( TXT_EDN ); // Endnotes - pAtn = new WW8_WrPlcPostIt; // PostIts + pAtn = new WW8_WrPlcAnnotations; // PostIts pTxtBxs = new WW8_WrPlcTxtBoxes( TXT_TXTBOX ); pHFTxtBxs = new WW8_WrPlcTxtBoxes( TXT_HFTXTBOX ); @@ -3448,7 +3448,7 @@ void WW8_WrPlcFtnEdn::WritePlc( WW8Export& rWrt ) const } -bool WW8_WrPlcPostIt::WriteTxt( WW8Export& rWrt ) +bool WW8_WrPlcAnnotations::WriteTxt( WW8Export& rWrt ) { bool bRet = WriteGenericTxt( rWrt, TXT_ATN, rWrt.pFib->ccpAtn ); rWrt.pFldAtn->Finish( rWrt.Fc2Cp( rWrt.Strm().Tell() ), @@ -3457,7 +3457,7 @@ bool WW8_WrPlcPostIt::WriteTxt( WW8Export& rWrt ) return bRet; } -void WW8_WrPlcPostIt::WritePlc( WW8Export& rWrt ) const +void WW8_WrPlcAnnotations::WritePlc( WW8Export& rWrt ) const { WriteGenericPlc( rWrt, TXT_ATN, rWrt.pFib->fcPlcfandTxt, rWrt.pFib->lcbPlcfandTxt, rWrt.pFib->fcPlcfandRef, diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx index 2e0b4ab7d778..83b3b7b265ed 100644 --- a/sw/source/filter/ww8/wrtww8.hxx +++ b/sw/source/filter/ww8/wrtww8.hxx @@ -109,7 +109,7 @@ class WW8_WrPlcFld; class WW8_WrMagicTable; class WW8_WrPlcFtnEdn; class WW8_WrPlcPn; -class WW8_WrPlcPostIt; +class WW8_WrPlcAnnotations; class MSWordSections; class WW8_WrPlcTxtBoxes; class WW8_WrPct; // Verwaltung @@ -488,7 +488,7 @@ public: WW8_WrPlcPn* pChpPlc; MSWordAttrIter* pChpIter; MSWordStyles* pStyles; - WW8_WrPlcPostIt* pAtn; + WW8_WrPlcAnnotations* pAtn; WW8_WrPlcTxtBoxes *pTxtBxs, *pHFTxtBxs; const sw::Frame *mpParentFrame; //If set we are exporting content inside @@ -1149,16 +1149,30 @@ public: void Append( WW8_CP nCp, const SwFmtFtn& rFtn ); }; -class WW8_WrPlcPostIt : public WW8_WrPlcSubDoc // Doppel-Plc fuer PostIts +struct WW8_Annotation +{ + const OutlinerParaObject* mpRichText; + String msSimpleText; + String msOwner; + DateTime maDateTime; + WW8_Annotation(const SwPostItField* pPostIt); + WW8_Annotation(const SwRedlineData* pRedline); +}; + +class WW8_WrPlcAnnotations : public WW8_WrPlcSubDoc // Doppel-Plc fuer PostIts { private: //No copying - WW8_WrPlcPostIt(const WW8_WrPlcPostIt&); - WW8_WrPlcPostIt& operator=(WW8_WrPlcPostIt&); + WW8_WrPlcAnnotations(const WW8_WrPlcAnnotations&); + WW8_WrPlcAnnotations& operator=(WW8_WrPlcAnnotations&); + std::set maProcessedRedlines; public: - WW8_WrPlcPostIt() {} + WW8_WrPlcAnnotations() {} + ~WW8_WrPlcAnnotations(); - void Append( WW8_CP nCp, const SwPostItField& rPostIt ); + void Append( WW8_CP nCp, const SwPostItField* pPostIt ); + void Append( WW8_CP nCp, const SwRedlineData* pRedLine ); + bool IsNewRedlineComment( const SwRedlineData* pRedLine ); bool WriteTxt( WW8Export& rWrt ); void WritePlc( WW8Export& rWrt ) const; }; diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index 54ebd5c5a9ba..b20df77e79a1 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -982,6 +982,24 @@ void WW8AttributeOutput::StartRunProperties() m_nFieldResults = pCurrentFields ? pCurrentFields->ResultCount() : 0; } + +void WW8AttributeOutput::StartRun( const SwRedlineData* pRedlineData ) +{ + if (pRedlineData) + { + const String &rComment = pRedlineData->GetComment(); + //Only possible to export to main text + if (rComment.Len() && (m_rWW8Export.nTxtTyp == TXT_MAINTEXT)) + { + if (m_rWW8Export.pAtn->IsNewRedlineComment(pRedlineData)) + { + m_rWW8Export.pAtn->Append( m_rWW8Export.Fc2Cp( m_rWW8Export.Strm().Tell() ), pRedlineData ); + m_rWW8Export.WritePostItBegin( m_rWW8Export.pO ); + } + } + } +} + void WW8AttributeOutput::EndRunProperties( const SwRedlineData* pRedlineData ) { Redline( pRedlineData ); @@ -2555,8 +2573,8 @@ void WW8AttributeOutput::SetField( const SwField& rFld, ww::eField eType, const void WW8AttributeOutput::PostitField( const SwField* pFld ) { - const SwPostItField& rPFld = *(SwPostItField*)pFld; - m_rWW8Export.pAtn->Append( m_rWW8Export.Fc2Cp( m_rWW8Export.Strm().Tell() ), rPFld ); + const SwPostItField *pPFld = (const SwPostItField*)pFld; + m_rWW8Export.pAtn->Append( m_rWW8Export.Fc2Cp( m_rWW8Export.Strm().Tell() ), pPFld ); m_rWW8Export.WritePostItBegin( m_rWW8Export.pO ); } diff --git a/sw/source/filter/ww8/ww8attributeoutput.hxx b/sw/source/filter/ww8/ww8attributeoutput.hxx index 4968d88887dc..8d8516433432 100644 --- a/sw/source/filter/ww8/ww8attributeoutput.hxx +++ b/sw/source/filter/ww8/ww8attributeoutput.hxx @@ -57,8 +57,7 @@ public: /// Start of the text run. /// - /// No-op for binary filters. - virtual void StartRun( const SwRedlineData* /*pRedlineData*/ ) {} + virtual void StartRun( const SwRedlineData* pRedlineData ); /// End of the text run. /// diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index b92f80c85290..cf6c4ebb008e 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -57,9 +57,8 @@ #include // SvxLRSpaceItem #include #include -// --> OD 2005-02-28 #i43427# #include -// <-- +#include #include #include #include @@ -1630,7 +1629,9 @@ long SwWW8ImplReader::Read_And(WW8PLCFManResult* pRes) sTxt, aDate ); aPostIt.SetTextObject(pOutliner); + pCtrlStck->NewAttr(*pPaM->GetPoint(), SvxCharHiddenItem(false, RES_CHRATR_HIDDEN)); rDoc.InsertPoolItem(*pPaM, SwFmtFld(aPostIt), 0); + pCtrlStck->SetAttr(*pPaM->GetPoint(), RES_CHRATR_HIDDEN); return 0; } diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx index f20c13889f27..726e48c314bc 100644 --- a/sw/source/filter/ww8/ww8scan.cxx +++ b/sw/source/filter/ww8/ww8scan.cxx @@ -4390,15 +4390,16 @@ WW8PLCFMan::WW8PLCFMan(WW8ScannerBase* pBase, ManTypes nType, long nStartCp, pBkm = &aD[1]; pEdn = &aD[2]; pFtn = &aD[3]; + pAnd = &aD[4]; - - pPcd = ( pBase->pPLCFx_PCD ) ? &aD[4] : 0; + pPcd = ( pBase->pPLCFx_PCD ) ? &aD[5] : 0; //pPcdA index == pPcd index + 1 - pPcdA = ( pBase->pPLCFx_PCDAttrs ) ? &aD[5] : 0; - pChp = &aD[6]; - pAnd = &aD[7]; + pPcdA = ( pBase->pPLCFx_PCDAttrs ) ? &aD[6] : 0; + + pChp = &aD[7]; pPap = &aD[8]; pSep = &aD[9]; + pSep->pPLCFx = pBase->pSepPLCF; pFtn->pPLCFx = pBase->pFtnPLCF; pEdn->pPLCFx = pBase->pEdnPLCF; -- cgit From 4bbfefa5fde9fb5f3941528a54fcdcfac17ca78d Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Tue, 5 Jan 2010 16:37:36 +0100 Subject: swunolocking1: #i107171#: fix crash caused by SwXParagraph::attachToText(): register at the text node, not at an uno cursor. --- sw/inc/unoobj.hxx | 2 +- sw/source/core/unocore/unoparagraph.cxx | 7 ++++--- sw/source/core/unocore/unotext.cxx | 24 ++++++++++++++---------- 3 files changed, 19 insertions(+), 14 deletions(-) (limited to 'sw') diff --git a/sw/inc/unoobj.hxx b/sw/inc/unoobj.hxx index b7a6c54d2bd2..08f5d2308b66 100644 --- a/sw/inc/unoobj.hxx +++ b/sw/inc/unoobj.hxx @@ -1283,7 +1283,7 @@ public: static SwXParagraph* GetImplementation(::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> xRef ); //falls es mal als Service erzeugt werden kann //void attachToRange(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xTextRange)throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); - void attachToText(SwXText* pParent, SwUnoCrsr* pCrsr); + void attachToText(SwXText & rParent, SwTxtNode & rTxtNode); }; /* -----------------23.03.99 12:57------------------- * diff --git a/sw/source/core/unocore/unoparagraph.cxx b/sw/source/core/unocore/unoparagraph.cxx index fe750469fade..4fbf9a7062d1 100644 --- a/sw/source/core/unocore/unoparagraph.cxx +++ b/sw/source/core/unocore/unoparagraph.cxx @@ -226,14 +226,15 @@ SwXParagraph::~SwXParagraph() /* -----------------------------11.07.00 14:48-------------------------------- ---------------------------------------------------------------------------*/ -void SwXParagraph::attachToText(SwXText* pParent, SwUnoCrsr* pCrsr) +void +SwXParagraph::attachToText(SwXText & rParent, SwTxtNode & rTxtNode) { DBG_ASSERT(m_bIsDescriptor, "Paragraph is not a descriptor"); if(m_bIsDescriptor) { m_bIsDescriptor = FALSE; - pCrsr->Add(this); - xParentText = pParent; + rTxtNode.Add(this); + xParentText = &rParent; if(m_sText.getLength()) { try { setString(m_sText); } diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index 7ae4b209f49f..7bcb064c8ced 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -662,7 +662,7 @@ void SwXText::insertTextContentBefore( SwXTextSection* pXSection = SwXTextSection::GetImplementation( xSuccessor ); SwXTextTable* pXTable = SwXTextTable::GetImplementation(xSuccessor ); SwFrmFmt* pTableFmt = pXTable ? pXTable->GetFrmFmt() : 0; - SwUnoCrsr* pUnoCrsr = 0; + SwTxtNode * pTxtNode = 0; if(pTableFmt && pTableFmt->GetDoc() == GetDoc()) { SwTable* pTable = SwTable::FindTable( pTableFmt ); @@ -671,7 +671,7 @@ void SwXText::insertTextContentBefore( SwNodeIndex aTblIdx( *pTblNode, -1 ); SwPosition aBefore(aTblIdx); bRet = GetDoc()->AppendTxtNode( aBefore ); - pUnoCrsr = GetDoc()->CreateUnoCrsr( aBefore, FALSE); + pTxtNode = aBefore.nNode.GetNode().GetTxtNode(); } else if(pXSection && pXSection->GetFmt() && @@ -683,13 +683,15 @@ void SwXText::insertTextContentBefore( SwNodeIndex aSectIdx( *pSectNode, -1 ); SwPosition aBefore(aSectIdx); bRet = GetDoc()->AppendTxtNode( aBefore ); - pUnoCrsr = GetDoc()->CreateUnoCrsr( aBefore, FALSE); + pTxtNode = aBefore.nNode.GetNode().GetTxtNode(); } - if(!bRet) + if (!bRet || !pTxtNode) + { throw lang::IllegalArgumentException(); + } else { - pPara->attachToText(this, pUnoCrsr); + pPara->attachToText(*this, *pTxtNode); } } @@ -708,11 +710,11 @@ void SwXText::insertTextContentAfter( if(!pPara || !pPara->IsDescriptor() || !xPredecessor.is()) throw lang::IllegalArgumentException(); - SwUnoCrsr* pUnoCrsr = 0; SwXTextSection* pXSection = SwXTextSection::GetImplementation( xPredecessor ); SwXTextTable* pXTable = SwXTextTable::GetImplementation(xPredecessor ); SwFrmFmt* pTableFmt = pXTable ? pXTable->GetFrmFmt() : 0; sal_Bool bRet = sal_False; + SwTxtNode * pTxtNode = 0; if(pTableFmt && pTableFmt->GetDoc() == GetDoc()) { SwTable* pTable = SwTable::FindTable( pTableFmt ); @@ -721,7 +723,7 @@ void SwXText::insertTextContentAfter( SwEndNode* pTableEnd = pTblNode->EndOfSectionNode(); SwPosition aTableEnd(*pTableEnd); bRet = GetDoc()->AppendTxtNode( aTableEnd ); - pUnoCrsr = GetDoc()->CreateUnoCrsr( aTableEnd, FALSE); + pTxtNode = aTableEnd.nNode.GetNode().GetTxtNode(); } else if(pXSection && pXSection->GetFmt() && @@ -732,13 +734,15 @@ void SwXText::insertTextContentAfter( SwEndNode* pEnd = pSectNode->EndOfSectionNode(); SwPosition aEnd(*pEnd); bRet = GetDoc()->AppendTxtNode( aEnd ); - pUnoCrsr = GetDoc()->CreateUnoCrsr( aEnd, FALSE); + pTxtNode = aEnd.nNode.GetNode().GetTxtNode(); } - if(!bRet) + if (!bRet || !pTxtNode) + { throw lang::IllegalArgumentException(); + } else { - pPara->attachToText(this, pUnoCrsr); + pPara->attachToText(*this, *pTxtNode); } } /* -----------------------------10.07.00 15:40-------------------------------- -- cgit From c941bb6a756a79a5c0ae1d903cc50399d8200812 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Tue, 5 Jan 2010 16:37:36 +0100 Subject: swunolocking1: #i106930#: thints.cxx: tweak isNestedAny() a bit with the fix for i106930, inserting a nesting hint without extent never overrides an existing hint; but overriding is actually desirable in the corner case where the existing hint is _also_ empty. [the unoapi test sw.SwXTextTableCursor relies on this] --- sw/source/core/txtnode/thints.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sw') diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx index 1222d6f2eeed..81a3b629f402 100644 --- a/sw/source/core/txtnode/thints.cxx +++ b/sw/source/core/txtnode/thints.cxx @@ -159,7 +159,8 @@ bool isNestedAny(const xub_StrLen nStart1, const xub_StrLen nEnd1, const xub_StrLen nStart2, const xub_StrLen nEnd2) { return ((nStart1 == nStart2) || (nEnd1 == nEnd2)) - ? (nStart1 != nEnd1) // same start/end: nested except if hint1 empty + // same start/end: nested except if hint1 empty and hint2 not empty + ? (nStart1 != nEnd1) || (nStart2 == nEnd2) : ((nStart1 < nStart2) ? (nEnd1 >= nEnd2) : (nEnd1 <= nEnd2)); } -- cgit From 733b831970204059b9d89eff203551d6d3bf4bbe Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Tue, 5 Jan 2010 16:37:41 +0100 Subject: swunolocking1: swtypes.hxx: rename frame anchor types enum RndStdIds: rename frame anchor types (FLY_*) to be more intuitive. [note the completely ridiculous number of files that care about anchor types] --- sw/inc/dcontact.hxx | 10 +-- sw/inc/fmtanchr.hxx | 4 +- sw/inc/swtypes.hxx | 10 +-- sw/source/core/access/accframe.cxx | 6 +- sw/source/core/access/accfrmobj.cxx | 6 +- sw/source/core/doc/doc.cxx | 4 +- sw/source/core/doc/docbm.cxx | 33 +++++--- sw/source/core/doc/docdraw.cxx | 10 +-- sw/source/core/doc/docedt.cxx | 38 ++++----- sw/source/core/doc/docfly.cxx | 52 ++++++------ sw/source/core/doc/docglbl.cxx | 22 +++-- sw/source/core/doc/doclay.cxx | 98 ++++++++++++---------- sw/source/core/doc/docnew.cxx | 2 +- sw/source/core/doc/docsort.cxx | 19 ++--- sw/source/core/doc/poolfmt.cxx | 18 ++-- sw/source/core/doc/tblcpy.cxx | 12 +-- sw/source/core/docnode/ndcopy.cxx | 47 +++++------ sw/source/core/docnode/ndtbl.cxx | 19 +++-- sw/source/core/docnode/node.cxx | 6 +- sw/source/core/docnode/swbaslnk.cxx | 30 +++---- sw/source/core/draw/dcontact.cxx | 26 ++---- sw/source/core/draw/dview.cxx | 14 ++-- sw/source/core/edit/autofmt.cxx | 2 +- sw/source/core/fields/expfld.cxx | 15 ++-- sw/source/core/frmedt/fecopy.cxx | 73 ++++++++-------- sw/source/core/frmedt/fefly1.cxx | 84 +++++++++++-------- sw/source/core/frmedt/feshview.cxx | 24 +++--- sw/source/core/frmedt/fews.cxx | 18 ++-- sw/source/core/frmedt/tblsel.cxx | 9 +- sw/source/core/inc/flyfrm.hxx | 8 +- sw/source/core/layout/anchoreddrawobject.cxx | 16 ++-- sw/source/core/layout/anchoredobject.cxx | 12 +-- sw/source/core/layout/atrfrm.cxx | 75 +++++++++-------- sw/source/core/layout/calcmove.cxx | 6 +- sw/source/core/layout/flowfrm.cxx | 2 +- sw/source/core/layout/fly.cxx | 19 +++-- sw/source/core/layout/flycnt.cxx | 2 +- sw/source/core/layout/flylay.cxx | 9 +- sw/source/core/layout/flypos.cxx | 8 +- sw/source/core/layout/frmtool.cxx | 27 +++--- sw/source/core/layout/laycache.cxx | 11 ++- sw/source/core/layout/objectformatter.cxx | 2 +- sw/source/core/layout/objectformattertxtfrm.cxx | 6 +- sw/source/core/layout/pagechg.cxx | 12 ++- sw/source/core/layout/sortedobjsimpl.cxx | 41 +++++---- sw/source/core/layout/tabfrm.cxx | 8 +- sw/source/core/layout/wsfrm.cxx | 10 +-- .../tocntntanchoredobjectposition.cxx | 6 +- sw/source/core/text/EnhancedPDFExportHelper.cxx | 12 +-- sw/source/core/text/itratr.cxx | 6 +- sw/source/core/text/porfly.cxx | 5 +- sw/source/core/text/txtfly.cxx | 50 +++++------ sw/source/core/text/txtfrm.cxx | 20 ++--- sw/source/core/txtnode/atrflyin.cxx | 10 ++- sw/source/core/txtnode/thints.cxx | 8 +- sw/source/core/undo/rolbck.cxx | 2 +- sw/source/core/undo/unattr.cxx | 16 ++-- sw/source/core/undo/undel.cxx | 4 +- sw/source/core/undo/undobj.cxx | 6 +- sw/source/core/undo/undobj1.cxx | 91 ++++++++++++-------- sw/source/core/undo/undraw.cxx | 37 ++++---- sw/source/core/undo/untbl.cxx | 10 +-- sw/source/core/undo/untblk.cxx | 16 ++-- sw/source/core/unocore/unodraw.cxx | 46 ++++++---- sw/source/core/unocore/unoframe.cxx | 23 ++--- sw/source/core/unocore/unoobj2.cxx | 3 +- sw/source/core/view/vdraw.cxx | 9 +- sw/source/filter/basflt/shellio.cxx | 19 +++-- sw/source/filter/html/css1atr.cxx | 10 +-- sw/source/filter/html/htmlcss1.cxx | 13 +-- sw/source/filter/html/htmldraw.cxx | 14 ++-- sw/source/filter/html/htmlfly.cxx | 20 ++--- sw/source/filter/html/htmlforw.cxx | 7 +- sw/source/filter/html/htmlgrin.cxx | 30 +++---- sw/source/filter/html/htmlplug.cxx | 8 +- sw/source/filter/html/swhtml.cxx | 36 ++++---- sw/source/filter/inc/fltshell.hxx | 4 +- sw/source/filter/rtf/rtfatr.cxx | 20 ++--- sw/source/filter/rtf/rtffly.cxx | 17 ++-- sw/source/filter/rtf/swparrtf.cxx | 28 ++----- sw/source/filter/rtf/wrtrtf.cxx | 7 +- sw/source/filter/ww1/fltshell.cxx | 13 ++- sw/source/filter/ww1/w1sprm.cxx | 10 +-- sw/source/filter/ww8/writerhelper.cxx | 2 +- sw/source/filter/ww8/wrtw8esh.cxx | 16 ++-- sw/source/filter/ww8/wrtw8nds.cxx | 13 +-- sw/source/filter/ww8/wrtww8.cxx | 2 +- sw/source/filter/ww8/wrtww8gr.cxx | 6 +- sw/source/filter/ww8/ww8atr.cxx | 8 +- sw/source/filter/ww8/ww8glsy.cxx | 13 ++- sw/source/filter/ww8/ww8graf.cxx | 20 ++--- sw/source/filter/ww8/ww8graf2.cxx | 8 +- sw/source/filter/ww8/ww8par.cxx | 2 +- sw/source/filter/ww8/ww8par2.cxx | 13 +-- sw/source/filter/ww8/ww8par4.cxx | 8 +- sw/source/filter/ww8/ww8par5.cxx | 8 +- sw/source/filter/ww8/ww8par6.cxx | 24 ++---- sw/source/filter/xml/xmltexti.cxx | 5 +- sw/source/ui/app/appenv.cxx | 20 +---- sw/source/ui/app/applab.cxx | 18 +--- sw/source/ui/dbui/mmlayoutpage.cxx | 6 +- sw/source/ui/dialog/regionsw.cxx | 23 +---- sw/source/ui/docvw/edtwin.cxx | 25 ++---- sw/source/ui/frmdlg/column.cxx | 2 +- sw/source/ui/frmdlg/frmmgr.cxx | 27 +++--- sw/source/ui/frmdlg/frmpage.cxx | 60 +++++++------ sw/source/ui/frmdlg/wrap.cxx | 54 +++++++----- sw/source/ui/ribbar/conrect.cxx | 11 +-- sw/source/ui/ribbar/drawbase.cxx | 3 +- sw/source/ui/shells/basesh.cxx | 58 +++++++------ sw/source/ui/shells/drwbassh.cxx | 12 ++- sw/source/ui/shells/textdrw.cxx | 6 -- sw/source/ui/shells/textidx.cxx | 6 +- sw/source/ui/shells/textsh.cxx | 12 +-- sw/source/ui/uiview/view2.cxx | 19 ----- sw/source/ui/uiview/viewtab.cxx | 4 +- sw/source/ui/utlui/attrdesc.cxx | 8 +- sw/source/ui/wrtsh/select.cxx | 6 -- 118 files changed, 1003 insertions(+), 1146 deletions(-) (limited to 'sw') diff --git a/sw/inc/dcontact.hxx b/sw/inc/dcontact.hxx index e1f20183deca..dc767403d1d5 100644 --- a/sw/inc/dcontact.hxx +++ b/sw/inc/dcontact.hxx @@ -191,11 +191,11 @@ public: } RndStdIds GetAnchorId() const { return GetAnchorFmt().GetAnchorId(); } - bool ObjAnchoredAtPage() const { return GetAnchorId() == FLY_PAGE; } - bool ObjAnchoredAtFly() const { return GetAnchorId() == FLY_AT_FLY; } - bool ObjAnchoredAtPara() const { return GetAnchorId() == FLY_AT_CNTNT; } - bool ObjAnchoredAtChar() const { return GetAnchorId() == FLY_AUTO_CNTNT; } - bool ObjAnchoredAsChar() const { return GetAnchorId() == FLY_IN_CNTNT; } + bool ObjAnchoredAtPage() const { return GetAnchorId() == FLY_AT_PAGE; } + bool ObjAnchoredAtFly() const { return GetAnchorId() == FLY_AT_FLY; } + bool ObjAnchoredAtPara() const { return GetAnchorId() == FLY_AT_PARA; } + bool ObjAnchoredAtChar() const { return GetAnchorId() == FLY_AT_CHAR; } + bool ObjAnchoredAsChar() const { return GetAnchorId() == FLY_AS_CHAR; } const SwPosition& GetCntntAnchor() const { diff --git a/sw/inc/fmtanchr.hxx b/sw/inc/fmtanchr.hxx index fd6975205347..df544884dd51 100644 --- a/sw/inc/fmtanchr.hxx +++ b/sw/inc/fmtanchr.hxx @@ -55,7 +55,7 @@ class SW_DLLPUBLIC SwFmtAnchor: public SfxPoolItem static sal_uInt32 mnOrderCounter; public: - SwFmtAnchor( RndStdIds eRnd = FLY_PAGE, USHORT nPageNum = 0 ); + SwFmtAnchor( RndStdIds eRnd = FLY_AT_PAGE, USHORT nPageNum = 0 ); SwFmtAnchor( const SwFmtAnchor &rCpy ); ~SwFmtAnchor(); @@ -86,7 +86,7 @@ public: }; inline const SwFmtAnchor &SwAttrSet::GetAnchor(BOOL bInP) const - { return (const SwFmtAnchor&)Get( RES_ANCHOR,bInP); } + { return static_cast(Get(RES_ANCHOR, bInP)); } inline const SwFmtAnchor &SwFmt::GetAnchor(BOOL bInP) const { return aSet.GetAnchor(bInP); } diff --git a/sw/inc/swtypes.hxx b/sw/inc/swtypes.hxx index 64cd8231f0ef..fbb90658098d 100644 --- a/sw/inc/swtypes.hxx +++ b/sw/inc/swtypes.hxx @@ -166,11 +166,11 @@ const short lOutlineMinTextDistance = 216; // 0.15 inch = 0.38 cm //Schnittstellen Bedeutung haben (SwDoc). enum RndStdIds { - FLY_AT_CNTNT, //Absatzgebundener Rahmen - FLY_IN_CNTNT, //Zeichengebundener Rahmen - FLY_PAGE, //Seitengebundener Rahmen - FLY_AT_FLY, //Rahmengebundener Rahmen ( LAYER_IMPL ) - FLY_AUTO_CNTNT, //Automatisch positionierter, absatzgebundener Rahmen + FLY_AT_PARA, // anchored at paragraph + FLY_AS_CHAR, // anchored as character + FLY_AT_PAGE, // anchored at page + FLY_AT_FLY, // anchored at frame + FLY_AT_CHAR, // anchored at character //Der Rest wird nur fuer SS benutzt. RND_STD_HEADER, RND_STD_FOOTER, diff --git a/sw/source/core/access/accframe.cxx b/sw/source/core/access/accframe.cxx index a62afc11e551..f6778c1564b8 100644 --- a/sw/source/core/access/accframe.cxx +++ b/sw/source/core/access/accframe.cxx @@ -438,7 +438,7 @@ const SwFrm *SwAccessibleFrame::GetParent( const SwFrmOrObj& rFrmOrObj, const SwFlyFrm *pFly = static_cast< const SwFlyFrm *>( pFrm ); if( pFly->IsFlyInCntFrm() ) { - // For FLY_IN_CNTNT the parent is the anchor + // For FLY_AS_CHAR the parent is the anchor aParent = pFly->GetAnchorFrm(); ASSERT( aParent.IsAccessible( bInPagePreview ), "parent is not accessible" ); @@ -471,9 +471,9 @@ const SwFrm *SwAccessibleFrame::GetParent( const SwFrmOrObj& rFrmOrObj, { const SwFrmFmt *pFrmFmt = pContact->GetFmt(); ASSERT( pFrmFmt, "frame format is missing" ); - if( pFrmFmt && FLY_IN_CNTNT == pFrmFmt->GetAnchor().GetAnchorId() ) + if (pFrmFmt && FLY_AS_CHAR == pFrmFmt->GetAnchor().GetAnchorId()) { - // For FLY_IN_CNTNT the parent is the anchor + // For FLY_AS_CHAR the parent is the anchor aParent = pContact->GetAnchorFrm(); ASSERT( aParent.IsAccessible( bInPagePreview ), "parent is not accessible" ); diff --git a/sw/source/core/access/accfrmobj.cxx b/sw/source/core/access/accfrmobj.cxx index f16d11692c9c..c7822e80ea72 100644 --- a/sw/source/core/access/accfrmobj.cxx +++ b/sw/source/core/access/accfrmobj.cxx @@ -59,8 +59,10 @@ sal_Bool SwFrmOrObj::IsBoundAsChar() const else { const SwFrmFmt *pFrmFmt = pObj ? ::FindFrmFmt( pObj ) : 0; - return pFrmFmt ? static_cast(FLY_IN_CNTNT == pFrmFmt->GetAnchor().GetAnchorId()) - : sal_False; + return (pFrmFmt) + ? static_cast(FLY_AS_CHAR == + pFrmFmt->GetAnchor().GetAnchorId()) + : sal_False; } } diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index 0c18b725d9f7..cacd46da9faf 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -95,9 +95,7 @@ #include #include #include -#ifndef _CMDID_H #include // fuer den dflt - Printer in SetJob -#endif #ifndef _STATSTR_HRC #include // StatLine-String #endif @@ -923,7 +921,7 @@ SwFlyFrmFmt* SwDoc::_InsNoTxtNode( const SwPosition& rPos, SwNoTxtNode* pNode, SwFlyFrmFmt *pFmt = 0; if( pNode ) { - pFmt = _MakeFlySection( rPos, *pNode, FLY_AT_CNTNT, + pFmt = _MakeFlySection( rPos, *pNode, FLY_AT_PARA, pFlyAttrSet, pFrmFmt ); if( pGrfAttrSet ) pNode->SetAttr( *pGrfAttrSet ); diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx index e1b4f3ee4322..924a677785ee 100644 --- a/sw/source/core/doc/docbm.cxx +++ b/sw/source/core/doc/docbm.cxx @@ -1259,7 +1259,6 @@ void _SaveCntntIdx(SwDoc* pDoc, SwCntntNode *pNode = pDoc->GetNodes()[nNode]->GetCntntNode(); if( pNode ) { - const SwPosition* pAPos; SwFrm* pFrm = pNode->GetFrm(); #if OSL_DEBUG_LEVEL > 1 @@ -1277,16 +1276,18 @@ void _SaveCntntIdx(SwDoc* pDoc, SwAnchoredObject* pObj = rDObj[ --n ]; const SwFrmFmt& rFmt = pObj->GetFrmFmt(); const SwFmtAnchor& rAnchor = rFmt.GetAnchor(); - if( ( ( nSaveFly && FLY_AT_CNTNT == rAnchor.GetAnchorId() ) || - FLY_AUTO_CNTNT == rAnchor.GetAnchorId() ) && - ( 0 != ( pAPos = rAnchor.GetCntntAnchor() ) ) ) + SwPosition const*const pAPos = rAnchor.GetCntntAnchor(); + if ( pAPos && + ( ( nSaveFly && + FLY_AT_PARA == rAnchor.GetAnchorId() ) || + ( FLY_AT_CHAR == rAnchor.GetAnchorId() ) ) ) { aSave.SetType( 0x2000 ); aSave.SetContent( pAPos->nContent.GetIndex() ); OSL_ENSURE( nNode == pAPos->nNode.GetIndex(), "_SaveCntntIdx: Wrong Node-Index" ); - if( FLY_AUTO_CNTNT == rAnchor.GetAnchorId() ) + if ( FLY_AT_CHAR == rAnchor.GetAnchorId() ) { if( nCntnt <= aSave.GetContent() ) { @@ -1321,14 +1322,14 @@ void _SaveCntntIdx(SwDoc* pDoc, continue; const SwFmtAnchor& rAnchor = pFrmFmt->GetAnchor(); - if( ( FLY_AT_CNTNT == rAnchor.GetAnchorId() || - FLY_AUTO_CNTNT == rAnchor.GetAnchorId() ) && - 0 != ( pAPos = rAnchor.GetCntntAnchor()) && - nNode == pAPos->nNode.GetIndex() ) + SwPosition const*const pAPos = rAnchor.GetCntntAnchor(); + if ( pAPos && ( nNode == pAPos->nNode.GetIndex() ) && + ( FLY_AT_PARA == rAnchor.GetAnchorId() || + FLY_AT_CHAR == rAnchor.GetAnchorId() ) ) { aSave.SetType( 0x2000 ); aSave.SetContent( pAPos->nContent.GetIndex() ); - if( FLY_AUTO_CNTNT == rAnchor.GetAnchorId() ) + if ( FLY_AT_CHAR == rAnchor.GetAnchorId() ) { if( nCntnt <= aSave.GetContent() ) { @@ -1444,11 +1445,15 @@ void _RestoreCntntIdx(SwDoc* pDoc, SwFmtAnchor aNew( rFlyAnchor ); SwPosition aNewPos( *rFlyAnchor.GetCntntAnchor() ); aNewPos.nNode = *pCNd; - if( FLY_AUTO_CNTNT == rFlyAnchor.GetAnchorId() ) + if ( FLY_AT_CHAR == rFlyAnchor.GetAnchorId() ) + { aNewPos.nContent.Assign( pCNd, aSave.GetContent() + nOffset ); + } else + { aNewPos.nContent.Assign( 0, 0 ); + } aNew.SetAnchor( &aNewPos ); pFrmFmt->SetFmtAttr( aNew ); } @@ -1608,11 +1613,15 @@ void _RestoreCntntIdx(SvULongs& rSaveArr, SwFmtAnchor aNew( rFlyAnchor ); SwPosition aNewPos( *rFlyAnchor.GetCntntAnchor() ); aNewPos.nNode = rNd; - if( FLY_AUTO_CNTNT == rFlyAnchor.GetAnchorId() ) + if ( FLY_AT_CHAR == rFlyAnchor.GetAnchorId() ) + { aNewPos.nContent.Assign( pCNd, Min( aSave.GetContent(), nLen ) ); + } else + { aNewPos.nContent.Assign( 0, 0 ); + } aNew.SetAnchor( &aNewPos ); pFrmFmt->SetFmtAttr( aNew ); } diff --git a/sw/source/core/doc/docdraw.cxx b/sw/source/core/doc/docdraw.cxx index 95e18a7e78af..4ab6f8541e02 100644 --- a/sw/source/core/doc/docdraw.cxx +++ b/sw/source/core/doc/docdraw.cxx @@ -32,9 +32,7 @@ #include "precompiled_sw.hxx" #include #include -#ifndef _OUTDEV_HXX //autogen #include -#endif #include #include #include @@ -46,22 +44,16 @@ #include #include -#ifndef _SVDOMEAS_HXX #include -#endif #include #include #include #include #include #include -#ifndef _SWHINTS_HXX #include -#endif #include -#ifndef _DOCSH_HXX #include -#endif #include //Damit der RootDtor gerufen wird. #include #include // fuer MakeDrawView @@ -481,7 +473,7 @@ BOOL SwDoc::DeleteSelection( SwDrawView& rDrawView ) SwDrawContact *pC = (SwDrawContact*)GetUserCall(pObj); SwDrawFrmFmt *pFrmFmt = (SwDrawFrmFmt*)pC->GetFmt(); if( pFrmFmt && - FLY_IN_CNTNT == pFrmFmt->GetAnchor().GetAnchorId() ) + FLY_AS_CHAR == pFrmFmt->GetAnchor().GetAnchorId() ) { rDrawView.MarkObj( pObj, rDrawView.Imp().GetPageView(), TRUE ); --i; diff --git a/sw/source/core/doc/docedt.cxx b/sw/source/core/doc/docedt.cxx index ddc6024c89ae..61c89cc579e2 100644 --- a/sw/source/core/doc/docedt.cxx +++ b/sw/source/core/doc/docedt.cxx @@ -220,17 +220,15 @@ void _RestFlyInRange( _SaveFlyArr & rArr, const SwNodeIndex& rSttIdx, void _SaveFlyInRange( const SwNodeRange& rRg, _SaveFlyArr& rArr ) { - SwFrmFmt* pFmt; - const SwFmtAnchor* pAnchor; - const SwPosition* pAPos; SwSpzFrmFmts& rFmts = *rRg.aStart.GetNode().GetDoc()->GetSpzFrmFmts(); for( sal_uInt16 n = 0; n < rFmts.Count(); ++n ) { - pFmt = (SwFrmFmt*)rFmts[n]; - pAnchor = &pFmt->GetAnchor(); - if( ( FLY_AT_CNTNT == pAnchor->GetAnchorId() || - FLY_AUTO_CNTNT == pAnchor->GetAnchorId() ) && - 0 != ( pAPos = pAnchor->GetCntntAnchor() ) && + SwFrmFmt *const pFmt = static_cast(rFmts[n]); + SwFmtAnchor const*const pAnchor = &pFmt->GetAnchor(); + SwPosition const*const pAPos = pAnchor->GetCntntAnchor(); + if (pAPos && + ((FLY_AT_PARA == pAnchor->GetAnchorId()) || + (FLY_AT_CHAR == pAnchor->GetAnchorId())) && rRg.aStart <= pAPos->nNode && pAPos->nNode < rRg.aEnd ) { _SaveFly aSave( pAPos->nNode.GetIndex() - rRg.aStart.GetIndex(), @@ -260,7 +258,6 @@ void _SaveFlyInRange( const SwPaM& rPam, const SwNodeIndex& rInsPos, pPos->nContent == rEndNdIdx.GetNode().GetCntntNode()->Len() )) ? 0 : 1; - const SwPosition* pAPos; const SwNodeIndex* pCntntIdx; for( sal_uInt16 n = 0; n < rFmts.Count(); ++n ) @@ -268,9 +265,10 @@ void _SaveFlyInRange( const SwPaM& rPam, const SwNodeIndex& rInsPos, sal_Bool bInsPos = sal_False; pFmt = (SwFrmFmt*)rFmts[n]; pAnchor = &pFmt->GetAnchor(); - if( ( FLY_AT_CNTNT == pAnchor->GetAnchorId() || - FLY_AUTO_CNTNT == pAnchor->GetAnchorId() ) && - 0 != ( pAPos = pAnchor->GetCntntAnchor() ) && + const SwPosition* pAPos = pAnchor->GetCntntAnchor(); + if (pAPos && + ((FLY_AT_PARA == pAnchor->GetAnchorId()) || + (FLY_AT_CHAR == pAnchor->GetAnchorId())) && // nicht verschieben, wenn die InsPos im CntntBereich vom Fly ist ( 0 == ( pCntntIdx = pFmt->GetCntnt().GetCntntIdx() ) || !( *pCntntIdx < rInsPos && @@ -317,14 +315,14 @@ void DelFlyInRange( const SwNodeIndex& rMkNdIdx, SwDoc* pDoc = rMkNdIdx.GetNode().GetDoc(); SwSpzFrmFmts& rTbl = *pDoc->GetSpzFrmFmts(); - const SwPosition* pAPos; for ( sal_uInt16 i = rTbl.Count(); i; ) { SwFrmFmt *pFmt = rTbl[--i]; const SwFmtAnchor &rAnch = pFmt->GetAnchor(); - if( ( rAnch.GetAnchorId() == FLY_AT_CNTNT || - rAnch.GetAnchorId() == FLY_AUTO_CNTNT ) && - 0 != ( pAPos = rAnch.GetCntntAnchor() ) && + SwPosition const*const pAPos = rAnch.GetCntntAnchor(); + if (pAPos && + ((rAnch.GetAnchorId() == FLY_AT_PARA) || + (rAnch.GetAnchorId() == FLY_AT_CHAR)) && ( bDelFwrd ? rMkNdIdx < pAPos->nNode && pAPos->nNode <= rPtNdIdx : rPtNdIdx <= pAPos->nNode && pAPos->nNode < rMkNdIdx )) @@ -2620,14 +2618,14 @@ bool SwDoc::DelFullPara( SwPaM& rPam ) // was ist mit Fly's ?? { // stehen noch FlyFrames rum, loesche auch diese - const SwPosition* pAPos; for( sal_uInt16 n = 0; n < GetSpzFrmFmts()->Count(); ++n ) { SwFrmFmt* pFly = (*GetSpzFrmFmts())[n]; const SwFmtAnchor* pAnchor = &pFly->GetAnchor(); - if( ( FLY_AT_CNTNT == pAnchor->GetAnchorId() || - FLY_AUTO_CNTNT == pAnchor->GetAnchorId() ) && - 0 != ( pAPos = pAnchor->GetCntntAnchor() ) && + SwPosition const*const pAPos = pAnchor->GetCntntAnchor(); + if (pAPos && + ((FLY_AT_PARA == pAnchor->GetAnchorId()) || + (FLY_AT_CHAR == pAnchor->GetAnchorId())) && aRg.aStart <= pAPos->nNode && pAPos->nNode <= aRg.aEnd ) { DelLayoutFmt( pFly ); diff --git a/sw/source/core/doc/docfly.cxx b/sw/source/core/doc/docfly.cxx index 507e63ba7a47..a34dabb435cd 100644 --- a/sw/source/core/doc/docfly.cxx +++ b/sw/source/core/doc/docfly.cxx @@ -181,7 +181,7 @@ Point lcl_FindAnchorLayPos( SwDoc& rDoc, const SwFmtAnchor& rAnch, if( rDoc.GetRootFrm() ) switch( rAnch.GetAnchorId() ) { - case FLY_IN_CNTNT: + case FLY_AS_CHAR: if( pFlyFmt && rAnch.GetCntntAnchor() ) { const SwFrm* pOld = ((SwFlyFrmFmt*)pFlyFmt)->GetFrm( &aRet, FALSE ); @@ -190,8 +190,8 @@ Point lcl_FindAnchorLayPos( SwDoc& rDoc, const SwFmtAnchor& rAnch, } break; - case FLY_AT_CNTNT: - case FLY_AUTO_CNTNT: // LAYER_IMPL + case FLY_AT_PARA: + case FLY_AT_CHAR: // LAYER_IMPL if( rAnch.GetCntntAnchor() ) { const SwPosition *pPos = rAnch.GetCntntAnchor(); @@ -213,7 +213,7 @@ Point lcl_FindAnchorLayPos( SwDoc& rDoc, const SwFmtAnchor& rAnch, } break; - case FLY_PAGE: + case FLY_AT_PAGE: { USHORT nPgNum = rAnch.GetPageNum(); const SwPageFrm *pPage = (SwPageFrm*)rDoc.GetRootFrm()->Lower(); @@ -249,9 +249,11 @@ sal_Int8 SwDoc::SetFlyFrmAnchor( SwFrmFmt& rFmt, SfxItemSet& rSet, BOOL bNewFrms // ist der neue ein gueltiger Anker? if( !aNewAnch.GetCntntAnchor() && (FLY_AT_FLY == nNew || - FLY_AT_CNTNT == nNew || FLY_IN_CNTNT == nNew || - FLY_AUTO_CNTNT == nNew )) + (FLY_AT_PARA == nNew) || (FLY_AS_CHAR == nNew) || + (FLY_AT_CHAR == nNew) )) + { return IGNOREANCHOR; + } if( nOld == nNew ) return DONTMAKEFRMS; @@ -264,7 +266,7 @@ sal_Int8 SwDoc::SetFlyFrmAnchor( SwFrmFmt& rFmt, SfxItemSet& rSet, BOOL bNewFrms //doppeltes hiden waere so eine art Show! rFmt.DelFrms(); - if( FLY_IN_CNTNT == nOld ) + if ( FLY_AS_CHAR == nOld ) { //Bei InCntnt's wird es spannend: Das TxtAttribut muss vernichtet //werden. Leider reisst dies neben den Frms auch noch das Format mit @@ -295,7 +297,7 @@ sal_Int8 SwDoc::SetFlyFrmAnchor( SwFrmFmt& rFmt, SfxItemSet& rSet, BOOL bNewFrms const SfxPoolItem* pItem; switch( nNew ) { - case FLY_IN_CNTNT: + case FLY_AS_CHAR: //Wenn keine Positionsattribute hereinkommen, dann muss dafuer //gesorgt werden, das keine unerlaubte automatische Ausrichtung //bleibt. @@ -326,10 +328,10 @@ sal_Int8 SwDoc::SetFlyFrmAnchor( SwFrmFmt& rFmt, SfxItemSet& rSet, BOOL bNewFrms } break; - case FLY_AT_CNTNT: - case FLY_AUTO_CNTNT: // LAYER_IMPL + case FLY_AT_PARA: + case FLY_AT_CHAR: // LAYER_IMPL case FLY_AT_FLY: // LAYER_IMPL - case FLY_PAGE: + case FLY_AT_PAGE: { //Wenn keine Positionsattribute hereinschneien korrigieren wir //die Position so, dass die Dokumentkoordinaten des Flys erhalten @@ -345,7 +347,7 @@ sal_Int8 SwDoc::SetFlyFrmAnchor( SwFrmFmt& rFmt, SfxItemSet& rSet, BOOL bNewFrms if( text::HoriOrientation::NONE == aOldH.GetHoriOrient() && ( !pItem || aOldH.GetPos() == ((SwFmtHoriOrient*)pItem)->GetPos() )) { - SwTwips nPos = FLY_IN_CNTNT == nOld ? 0 : aOldH.GetPos(); + SwTwips nPos = (FLY_AS_CHAR == nOld) ? 0 : aOldH.GetPos(); nPos += aOldAnchorPos.X() - aNewAnchorPos.X(); if( pItem ) @@ -367,7 +369,7 @@ sal_Int8 SwDoc::SetFlyFrmAnchor( SwFrmFmt& rFmt, SfxItemSet& rSet, BOOL bNewFrms if( text::VertOrientation::NONE == aOldV.GetVertOrient() && (!pItem || aOldV.GetPos() == ((SwFmtVertOrient*)pItem)->GetPos() ) ) { - SwTwips nPos = FLY_IN_CNTNT == nOld ? 0 : aOldV.GetPos(); + SwTwips nPos = (FLY_AS_CHAR == nOld) ? 0 : aOldV.GetPos(); nPos += aOldAnchorPos.Y() - aNewAnchorPos.Y(); if( pItem ) { @@ -698,7 +700,7 @@ sal_Bool SwDoc::ChgAnchor( const SdrMarkList& _rMrkList, // xub_StrLen nIndx = STRING_NOTFOUND; const SwPosition* pOldAsCharAnchorPos( 0L ); const RndStdIds eOldAnchorType = pContact->GetAnchorId(); - if ( !_bSameOnly && eOldAnchorType == FLY_IN_CNTNT ) + if ( !_bSameOnly && eOldAnchorType == FLY_AS_CHAR ) { pOldAsCharAnchorPos = new SwPosition( pContact->GetCntntAnchor() ); } @@ -713,8 +715,8 @@ sal_Bool SwDoc::ChgAnchor( const SdrMarkList& _rMrkList, switch ( _eAnchorType ) { - case FLY_AT_CNTNT: - case FLY_AUTO_CNTNT: + case FLY_AT_PARA: + case FLY_AT_CHAR: { const Point aNewPoint = pOldAnchorFrm && ( pOldAnchorFrm->IsVertical() || @@ -768,10 +770,10 @@ sal_Bool SwDoc::ChgAnchor( const SdrMarkList& _rMrkList, break; } - aNewAnch.SetType( FLY_PAGE ); + aNewAnch.SetType( FLY_AT_PAGE ); // no break } - case FLY_PAGE: + case FLY_AT_PAGE: { pNewAnchorFrm = GetRootFrm()->Lower(); while ( pNewAnchorFrm && !pNewAnchorFrm->Frm().IsInside( aPt ) ) @@ -782,7 +784,7 @@ sal_Bool SwDoc::ChgAnchor( const SdrMarkList& _rMrkList, aNewAnch.SetPageNum( ((SwPageFrm*)pNewAnchorFrm)->GetPhyPageNum()); } break; - case FLY_IN_CNTNT: + case FLY_AS_CHAR: if( _bSameOnly ) // Positions/Groessenaenderung { if( !pOldAnchorFrm ) @@ -805,7 +807,7 @@ sal_Bool SwDoc::ChgAnchor( const SdrMarkList& _rMrkList, bUnmark = ( 0 != i ); Point aPoint( aPt ); aPoint.X() -= 1; // nicht im DrawObj landen!! - aNewAnch.SetType( FLY_IN_CNTNT ); + aNewAnch.SetType( FLY_AS_CHAR ); SwPosition aPos( *((SwCntntFrm*)pNewAnchorFrm)->GetNode() ); if ( pNewAnchorFrm->Frm().IsInside( aPoint ) ) { @@ -839,7 +841,7 @@ sal_Bool SwDoc::ChgAnchor( const SdrMarkList& _rMrkList, ASSERT( !this, "unexpected AnchorId." ); } - if ( (FLY_IN_CNTNT != _eAnchorType) && + if ( (FLY_AS_CHAR != _eAnchorType) && pNewAnchorFrm && ( !_bSameOnly || pNewAnchorFrm != pOldAnchorFrm ) ) { @@ -949,8 +951,8 @@ int SwDoc::Chainable( const SwFrmFmt &rSource, const SwFrmFmt &rDest ) const SwFmtAnchor& rAnchor = (*GetSpzFrmFmts())[ n ]->GetAnchor(); ULONG nTstSttNd; // OD 11.12.2003 #i20622# - to-frame anchored objects are allowed. - if ( ( rAnchor.GetAnchorId() == FLY_AT_CNTNT || - rAnchor.GetAnchorId() == FLY_AUTO_CNTNT ) && + if ( ((rAnchor.GetAnchorId() == FLY_AT_PARA) || + (rAnchor.GetAnchorId() == FLY_AT_CHAR)) && 0 != rAnchor.GetCntntAnchor() && nFlySttNd <= ( nTstSttNd = rAnchor.GetCntntAnchor()->nNode.GetIndex() ) && @@ -971,9 +973,9 @@ int SwDoc::Chainable( const SwFrmFmt &rSource, const SwFrmFmt &rDest ) &rDstAnchor = rDest.GetAnchor(); ULONG nEndOfExtras = GetNodes().GetEndOfExtras().GetIndex(); BOOL bAllowed = FALSE; - if( FLY_PAGE == rSrcAnchor.GetAnchorId() ) + if ( FLY_AT_PAGE == rSrcAnchor.GetAnchorId() ) { - if( FLY_PAGE == rDstAnchor.GetAnchorId() || + if ( (FLY_AT_PAGE == rDstAnchor.GetAnchorId()) || ( rDstAnchor.GetCntntAnchor() && rDstAnchor.GetCntntAnchor()->nNode.GetIndex() > nEndOfExtras )) bAllowed = TRUE; diff --git a/sw/source/core/doc/docglbl.cxx b/sw/source/core/doc/docglbl.cxx index 113319494e03..9bef76da7508 100644 --- a/sw/source/core/doc/docglbl.cxx +++ b/sw/source/core/doc/docglbl.cxx @@ -49,12 +49,8 @@ #include #include #include -#ifndef _DOCSH_HXX #include -#endif -#ifndef _GLOBDOC_HXX #include -#endif #include #include // fuer die UndoIds #include @@ -371,14 +367,15 @@ BOOL SwDoc::SplitDoc( USHORT eDocType, const String& rPath, CorrAbs( aSIdx, aEIdx, *aTmp.GetPoint(), TRUE); // stehen noch FlyFrames rum, loesche auch diese - const SwPosition* pAPos; for( USHORT n = 0; n < GetSpzFrmFmts()->Count(); ++n ) { SwFrmFmt* pFly = (*GetSpzFrmFmts())[n]; const SwFmtAnchor* pAnchor = &pFly->GetAnchor(); - if( ( FLY_AT_CNTNT == pAnchor->GetAnchorId() || - FLY_AUTO_CNTNT == pAnchor->GetAnchorId() ) && - 0 != ( pAPos = pAnchor->GetCntntAnchor() ) && + SwPosition const*const pAPos = + pAnchor->GetCntntAnchor(); + if (pAPos && + ((FLY_AT_PARA == pAnchor->GetAnchorId()) || + (FLY_AT_CHAR == pAnchor->GetAnchorId())) && aSIdx <= pAPos->nNode && pAPos->nNode < aEIdx ) { @@ -717,14 +714,15 @@ BOOL SwDoc::SplitDoc( USHORT eDocType, const String& rPath, int nOutlineLevel ) CorrAbs( aSIdx, aEIdx, *aTmp.GetPoint(), TRUE); // stehen noch FlyFrames rum, loesche auch diese - const SwPosition* pAPos; for( USHORT n = 0; n < GetSpzFrmFmts()->Count(); ++n ) { SwFrmFmt* pFly = (*GetSpzFrmFmts())[n]; const SwFmtAnchor* pAnchor = &pFly->GetAnchor(); - if( ( FLY_AT_CNTNT == pAnchor->GetAnchorId() || - FLY_AUTO_CNTNT == pAnchor->GetAnchorId() ) && - 0 != ( pAPos = pAnchor->GetCntntAnchor() ) && + SwPosition const*const pAPos = + pAnchor->GetCntntAnchor(); + if (pAPos && + ((FLY_AT_PARA == pAnchor->GetAnchorId()) || + (FLY_AT_CHAR == pAnchor->GetAnchorId())) && aSIdx <= pAPos->nNode && pAPos->nNode < aEIdx ) { diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx index 1af12a64bf2f..e58059d95ac9 100644 --- a/sw/source/core/doc/doclay.cxx +++ b/sw/source/core/doc/doclay.cxx @@ -68,9 +68,7 @@ #include #include #include -#ifndef _FRMCNCT_HXX //autogen #include -#endif #include #include #include @@ -85,9 +83,7 @@ #include #include #include -#ifndef _DOCSH_HXX #include -#endif #include #include #include @@ -213,13 +209,12 @@ SwFrmFmt *SwDoc::MakeLayoutFmt( RndStdIds eRequest, const SfxItemSet* pSet ) break; #ifndef PRODUCT - case FLY_PAGE: - case FLY_AUTO_CNTNT: + case FLY_AT_PAGE: + case FLY_AT_CHAR: case FLY_AT_FLY: - case FLY_AT_CNTNT: - case FLY_IN_CNTNT: - ASSERT( !this, - "neue Schnittstelle benutzen: SwDoc::MakeFlySection!" ); + case FLY_AT_PARA: + case FLY_AS_CHAR: + ASSERT( false, "use new interface instead: SwDoc::MakeFlySection!" ); break; #endif @@ -358,7 +353,7 @@ void SwDoc::DelLayoutFmt( SwFrmFmt *pFmt ) // ggfs. bei Zeichengebundenen Flys das Zeichen loeschen const SwFmtAnchor& rAnchor = pFmt->GetAnchor(); - if( FLY_IN_CNTNT == rAnchor.GetAnchorId() && rAnchor.GetCntntAnchor()) + if ((FLY_AS_CHAR == rAnchor.GetAnchorId()) && rAnchor.GetCntntAnchor()) { const SwPosition* pPos = rAnchor.GetCntntAnchor(); SwTxtNode *pTxtNd = pPos->nNode.GetNode().GetTxtNode(); @@ -422,9 +417,9 @@ SwFrmFmt *SwDoc::CopyLayoutFmt( const SwFrmFmt& rSource, static_cast( rSource.FindContactObj() ); bMayNotCopy = - ( FLY_AT_CNTNT == rNewAnchor.GetAnchorId() || - FLY_AT_FLY == rNewAnchor.GetAnchorId() || - FLY_AUTO_CNTNT == rNewAnchor.GetAnchorId() ) && + ((FLY_AT_PARA == rNewAnchor.GetAnchorId()) || + (FLY_AT_FLY == rNewAnchor.GetAnchorId()) || + (FLY_AT_CHAR == rNewAnchor.GetAnchorId())) && rNewAnchor.GetCntntAnchor() && IsInHeaderFooter( rNewAnchor.GetCntntAnchor()->nNode ) && pDrawContact != NULL && @@ -551,7 +546,7 @@ SwFrmFmt *SwDoc::CopyLayoutFmt( const SwFrmFmt& rSource, } } - if( bSetTxtFlyAtt && FLY_IN_CNTNT == rNewAnchor.GetAnchorId() ) + if (bSetTxtFlyAtt && (FLY_AS_CHAR == rNewAnchor.GetAnchorId())) { const SwPosition* pPos = rNewAnchor.GetCntntAnchor(); SwFmtFlyCnt aFmt( pDest ); @@ -660,7 +655,7 @@ SwFlyFrmFmt* SwDoc::_MakeFlySection( const SwPosition& rAnchPos, RndStdIds eAnchorId = pAnchor ? pAnchor->GetAnchorId() : pFmt->GetAnchor().GetAnchorId(); if( !pAnchor || - (FLY_PAGE != pAnchor->GetAnchorId() && + ((FLY_AT_PAGE != pAnchor->GetAnchorId()) && //Nur Page und nicht: // FLY_AT_CNTNT == pAnchor->GetAnchorId() || // FLY_IN_CNTNT == pAnchor->GetAnchorId() || @@ -670,7 +665,7 @@ SwFlyFrmFmt* SwDoc::_MakeFlySection( const SwPosition& rAnchPos, { // dann setze ihn, wird im Undo gebraucht SwFmtAnchor aAnch( pFmt->GetAnchor() ); - if( pAnchor && FLY_AT_FLY == pAnchor->GetAnchorId() ) + if (pAnchor && (FLY_AT_FLY == pAnchor->GetAnchorId())) { SwPosition aPos( *rAnchPos.nNode.GetNode().FindFlyStartNode() ); aAnch.SetAnchor( &aPos ); @@ -683,7 +678,7 @@ SwFlyFrmFmt* SwDoc::_MakeFlySection( const SwPosition& rAnchPos, aAnch.SetType( eRequestId ); eAnchorId = aAnch.GetAnchorId(); - if ( FLY_PAGE != eAnchorId ) + if ( FLY_AT_PAGE != eAnchorId ) //Nur Page und nicht: // if( FLY_AT_CNTNT == eAnchorId || FLY_IN_CNTNT == eAnchorId || // FLY_AT_FLY == eAnchorId || FLY_AUTO_CNTNT == eAnchorId ) @@ -694,7 +689,7 @@ SwFlyFrmFmt* SwDoc::_MakeFlySection( const SwPosition& rAnchPos, else eAnchorId = pFmt->GetAnchor().GetAnchorId(); - if( FLY_IN_CNTNT == eAnchorId ) + if ( FLY_AS_CHAR == eAnchorId ) { xub_StrLen nStt = rAnchPos.nContent.GetIndex(); SwTxtNode * pTxtNode = rAnchPos.nNode.GetNode().GetTxtNode(); @@ -751,7 +746,7 @@ SwFlyFrmFmt* SwDoc::MakeFlySection( RndStdIds eAnchorType, { SwFlyFrmFmt* pFmt = 0; sal_Bool bCallMake = sal_True; - if( !pAnchorPos && FLY_PAGE != eAnchorType ) + if ( !pAnchorPos && (FLY_AT_PAGE != eAnchorType) ) { const SwFmtAnchor* pAnch; if( (pFlySet && SFX_ITEM_SET == pFlySet->GetItemState( @@ -759,9 +754,14 @@ SwFlyFrmFmt* SwDoc::MakeFlySection( RndStdIds eAnchorType, ( pFrmFmt && SFX_ITEM_SET == pFrmFmt->GetItemState( RES_ANCHOR, sal_True, (const SfxPoolItem**)&pAnch )) ) { - if( FLY_PAGE != pAnch->GetAnchorId() && - 0 == ( pAnchorPos = pAnch->GetCntntAnchor() ) ) - bCallMake = sal_False; + if ( (FLY_AT_PAGE != pAnch->GetAnchorId()) ) + { + pAnchorPos = pAnch->GetCntntAnchor(); + if (pAnchorPos) + { + bCallMake = sal_False; + } + } } } @@ -944,7 +944,7 @@ SwDrawFrmFmt* SwDoc::Insert( const SwPaM &rRg, // Anker noch nicht gesetzt ? // DrawObjecte duerfen niemals in Kopf-/Fusszeilen landen. - sal_Bool bIsAtCntnt = FLY_PAGE != eAnchorId; + const bool bIsAtCntnt = (FLY_AT_PAGE != eAnchorId); // FLY_AT_CNTNT == eAnchorId || FLY_IN_CNTNT == eAnchorId || // FLY_AT_FLY == eAnchorId || FLY_AUTO_CNTNT == eAnchorId; @@ -966,7 +966,7 @@ SwDrawFrmFmt* SwDoc::Insert( const SwPaM &rRg, ::CheckControlLayer( &rDrawObj ) && IsInHeaderFooter( *pChkIdx ) ) { - pFmt->SetFmtAttr( SwFmtAnchor( eAnchorId = FLY_PAGE ) ); + pFmt->SetFmtAttr( SwFmtAnchor( eAnchorId = FLY_AT_PAGE ) ); } else if( !pAnchor || (bIsAtCntnt && !pAnchor->GetCntntAnchor() )) { @@ -981,10 +981,10 @@ SwDrawFrmFmt* SwDoc::Insert( const SwPaM &rRg, else { aAnch.SetAnchor( rRg.GetPoint() ); - if( FLY_PAGE == eAnchorId ) + if ( FLY_AT_PAGE == eAnchorId ) { eAnchorId = rDrawObj.ISA( SdrUnoObj ) - ? FLY_IN_CNTNT : FLY_AT_CNTNT; + ? FLY_AS_CHAR : FLY_AT_PARA; aAnch.SetType( eAnchorId ); } } @@ -992,7 +992,7 @@ SwDrawFrmFmt* SwDoc::Insert( const SwPaM &rRg, } // bei als Zeichen gebundenen Draws das Attribut im Absatz setzen - if( FLY_IN_CNTNT == eAnchorId ) + if ( FLY_AS_CHAR == eAnchorId ) { xub_StrLen nStt = rRg.GetPoint()->nContent.GetIndex(); SwFmtFlyCnt aFmt( pFmt ); @@ -1063,7 +1063,7 @@ sal_Bool TstFlyRange( const SwPaM* pPam, const SwPosition* pFlyPos, const SwPosition* pPaMEnd = pTmp->End(); const sal_uInt32 nPamStartIndex = pPaMStart->nNode.GetIndex(); const sal_uInt32 nPamEndIndex = pPaMEnd->nNode.GetIndex(); - if(FLY_AT_CNTNT == nAnchorId) + if (FLY_AT_PARA == nAnchorId) bOk = (nPamStartIndex < nFlyIndex && nPamEndIndex > nFlyIndex) || (((nPamStartIndex == nFlyIndex) && (pPaMStart->nContent.GetIndex() == 0)) && (nPamEndIndex > nFlyIndex)); @@ -1091,7 +1091,6 @@ void SwDoc::GetAllFlyFmts( SwPosFlyFrms& rPosFlyFmts, const SwPaM* pCmpRange, sal_Bool bDrawAlso ) const { SwPosFlyFrm *pFPos = 0; - const SwPosition* pAPos; SwFrmFmt *pFly; // erstmal alle Absatzgebundenen einsammeln @@ -1103,10 +1102,11 @@ void SwDoc::GetAllFlyFmts( SwPosFlyFrms& rPosFlyFmts, if( bFlyFmt || bDrawFmt ) { const SwFmtAnchor& rAnchor = pFly->GetAnchor(); - if( ( FLY_AT_CNTNT == rAnchor.GetAnchorId() || - FLY_AT_FLY == rAnchor.GetAnchorId() || - FLY_AUTO_CNTNT == rAnchor.GetAnchorId() ) && - 0 != ( pAPos = rAnchor.GetCntntAnchor()) ) + SwPosition const*const pAPos = rAnchor.GetCntntAnchor(); + if (pAPos && + ((FLY_AT_PARA == rAnchor.GetAnchorId()) || + (FLY_AT_FLY == rAnchor.GetAnchorId()) || + (FLY_AT_CHAR == rAnchor.GetAnchorId()))) { if( pCmpRange && !TstFlyRange( pCmpRange, pAPos, rAnchor.GetAnchorId() )) @@ -1140,9 +1140,9 @@ void SwDoc::GetAllFlyFmts( SwPosFlyFrms& rPosFlyFmts, continue; const SwFmtAnchor& rAnchor = pFly->GetAnchor(); - if( FLY_AT_CNTNT != rAnchor.GetAnchorId() && - FLY_AT_FLY != rAnchor.GetAnchorId() && - FLY_AUTO_CNTNT != rAnchor.GetAnchorId() ) + if ((FLY_AT_PARA != rAnchor.GetAnchorId()) && + (FLY_AT_FLY != rAnchor.GetAnchorId()) && + (FLY_AT_CHAR != rAnchor.GetAnchorId())) { const SwCntntFrm * pCntntFrm = pPage->FindFirstBodyCntnt(); if ( !pCntntFrm ) @@ -1387,7 +1387,7 @@ SwFlyFrmFmt* SwDoc::InsertLabel( const SwLabelType eType, const String &rTxt, co //loesen wir vorher die Verbindung zwischen Attribut und Format. const SwFmtAnchor& rAnchor = pNewFmt->GetAnchor(); - if( FLY_IN_CNTNT == rAnchor.GetAnchorId() ) + if ( FLY_AS_CHAR == rAnchor.GetAnchorId() ) { const SwPosition *pPos = rAnchor.GetCntntAnchor(); SwTxtNode *pTxtNode = pPos->nNode.GetNode().GetTxtNode(); @@ -1433,7 +1433,7 @@ SwFlyFrmFmt* SwDoc::InsertLabel( const SwLabelType eType, const String &rTxt, co pNewSet->Put( SvxULSpaceItem(RES_UL_SPACE) ); //Der Alte ist absatzgebunden, und zwar am Absatz im neuen. - SwFmtAnchor aAnch( FLY_AT_CNTNT ); + SwFmtAnchor aAnch( FLY_AT_PARA ); SwNodeIndex aAnchIdx( *pNewFmt->GetCntnt().GetCntntIdx(), 1 ); pNew = aAnchIdx.GetNode().GetTxtNode(); SwPosition aPos( aAnchIdx ); @@ -1684,7 +1684,7 @@ SwFlyFrmFmt* SwDoc::InsertDrawLabel( const String &rTxt, pNewFmt->SetFmtAttr( *pNewSet ); const SwFmtAnchor& rAnchor = pNewFmt->GetAnchor(); - if( FLY_IN_CNTNT == rAnchor.GetAnchorId() ) + if ( FLY_AS_CHAR == rAnchor.GetAnchorId() ) { const SwPosition *pPos = rAnchor.GetCntntAnchor(); SwTxtNode *pTxtNode = pPos->nNode.GetNode().GetTxtNode(); @@ -1722,7 +1722,7 @@ SwFlyFrmFmt* SwDoc::InsertDrawLabel( const String &rTxt, pNewSet->Put( SwFmtHoriOrient( 0, text::HoriOrientation::CENTER, text::RelOrientation::FRAME ) ); //Der Alte ist absatzgebunden, und zwar am Absatz im neuen. - SwFmtAnchor aAnch( FLY_AT_CNTNT ); + SwFmtAnchor aAnch( FLY_AT_PARA ); SwNodeIndex aAnchIdx( *pNewFmt->GetCntnt().GetCntntIdx(), 1 ); pNew = aAnchIdx.GetNode().GetTxtNode(); SwPosition aPos( aAnchIdx ); @@ -2095,15 +2095,17 @@ void SwDoc::SetAllUniqueFlyNames() if( bLoadedFlag ) { const SwFmtAnchor& rAnchor = pFlyFmt->GetAnchor(); - if( ( FLY_PAGE == rAnchor.GetAnchorId() && - rAnchor.GetCntntAnchor() ) || + if (((FLY_AT_PAGE == rAnchor.GetAnchorId()) && + rAnchor.GetCntntAnchor()) || // oder werden DrawObjecte rel. zu irgendetwas ausgerichtet? ( RES_DRAWFRMFMT == pFlyFmt->Which() && ( SFX_ITEM_SET == pFlyFmt->GetItemState( RES_VERT_ORIENT )|| SFX_ITEM_SET == pFlyFmt->GetItemState( RES_HORI_ORIENT ))) ) + { bLoadedFlag = sal_False; + } } } @@ -2200,9 +2202,11 @@ sal_Bool SwDoc::IsInHeaderFooter( const SwNodeIndex& rIdx ) const if( pIdx && pFlyNd == &pIdx->GetNode() ) { const SwFmtAnchor& rAnchor = pFmt->GetAnchor(); - if( FLY_PAGE == rAnchor.GetAnchorId() || + if ((FLY_AT_PAGE == rAnchor.GetAnchorId()) || !rAnchor.GetCntntAnchor() ) + { return sal_False; + } pNd = &rAnchor.GetCntntAnchor()->nNode.GetNode(); pFlyNd = pNd->FindFlyStartNode(); @@ -2247,10 +2251,12 @@ short SwDoc::GetTextDirection( const SwPosition& rPos, { pItem = 0; const SwFmtAnchor* pAnchor = &pFlyFmt->GetAnchor(); - if( FLY_PAGE != pAnchor->GetAnchorId() && - pAnchor->GetCntntAnchor() ) + if ((FLY_AT_PAGE != pAnchor->GetAnchorId()) && + pAnchor->GetCntntAnchor()) + { pFlyFmt = pAnchor->GetCntntAnchor()->nNode. GetNode().GetFlyFmt(); + } else pFlyFmt = 0; } diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx index 2a36ce970615..71c42cf27176 100644 --- a/sw/source/core/doc/docnew.cxx +++ b/sw/source/core/doc/docnew.cxx @@ -1415,7 +1415,7 @@ void SwDoc::Paste( const SwDoc& rSource ) if( bInsWithFmt ) { SwFmtAnchor aAnchor( rCpyFmt.GetAnchor() ); - if( FLY_PAGE == aAnchor.GetAnchorId() ) + if (FLY_AT_PAGE == aAnchor.GetAnchorId()) { aAnchor.SetPageNum( aAnchor.GetPageNum() + /*nStartPageNumber - */1 ); } diff --git a/sw/source/core/doc/docsort.cxx b/sw/source/core/doc/docsort.cxx index 3f1a6babac56..de845b4ef433 100644 --- a/sw/source/core/doc/docsort.cxx +++ b/sw/source/core/doc/docsort.cxx @@ -48,9 +48,7 @@ #include #include #include -#ifndef _DOCSORT_HXX #include -#endif #include #include #include @@ -341,18 +339,13 @@ BOOL SwDoc::SortText(const SwPaM& rPaM, const SwSortOptions& rOpt) const SwPosition *pStart = rPaM.Start(), *pEnd = rPaM.End(); // Index auf den Start der Selektion - SwFrmFmt* pFmt; - const SwFmtAnchor* pAnchor; - const SwPosition* pAPos; - USHORT n; - - for( n = 0; n < GetSpzFrmFmts()->Count(); ++n ) + for ( USHORT n = 0; n < GetSpzFrmFmts()->Count(); ++n ) { - pFmt = (SwFrmFmt*)(*GetSpzFrmFmts())[n]; - pAnchor = &pFmt->GetAnchor(); + SwFrmFmt *const pFmt = static_cast((*GetSpzFrmFmts())[n]); + SwFmtAnchor const*const pAnchor = &pFmt->GetAnchor(); + SwPosition const*const pAPos = pAnchor->GetCntntAnchor(); - if( FLY_AT_CNTNT == pAnchor->GetAnchorId() && - 0 != (pAPos = pAnchor->GetCntntAnchor() ) && + if (pAPos && (FLY_AT_PARA == pAnchor->GetAnchorId()) && pStart->nNode <= pAPos->nNode && pAPos->nNode <= pEnd->nNode ) return FALSE; } @@ -444,7 +437,7 @@ BOOL SwDoc::SortText(const SwPaM& rPaM, const SwSortOptions& rOpt) DoUndo( FALSE ); - for( n = 0; n < aSortArr.Count(); ++n ) + for ( USHORT n = 0; n < aSortArr.Count(); ++n ) { SwSortTxtElement* pBox = (SwSortTxtElement*)aSortArr[n]; aStart = nBeg + n; diff --git a/sw/source/core/doc/poolfmt.cxx b/sw/source/core/doc/poolfmt.cxx index 5e2b2fead999..058dd50a833c 100644 --- a/sw/source/core/doc/poolfmt.cxx +++ b/sw/source/core/doc/poolfmt.cxx @@ -37,9 +37,7 @@ #include #include #include -#ifndef _SVX_TSTPITEM_HXX //autogen #include -#endif #include #include #include @@ -55,9 +53,7 @@ #include #include #include -#ifndef _SVX_EMPHITEM_HXX #include -#endif #include #include #include @@ -1303,13 +1299,13 @@ SwFmt* SwDoc::GetFmtFromPool( USHORT nId ) { if ( get(IDocumentSettingAccess::BROWSE_MODE) ) { - aSet.Put( SwFmtAnchor( FLY_IN_CNTNT )); + aSet.Put( SwFmtAnchor( FLY_AS_CHAR )); aSet.Put( SwFmtVertOrient( 0, text::VertOrientation::LINE_CENTER, text::RelOrientation::PRINT_AREA ) ); aSet.Put( SwFmtSurround( SURROUND_NONE ) ); } else { - aSet.Put( SwFmtAnchor( FLY_AT_CNTNT )); + aSet.Put( SwFmtAnchor( FLY_AT_PARA )); aSet.Put( SwFmtSurround( SURROUND_PARALLEL ) ); aSet.Put( SwFmtHoriOrient( 0, text::HoriOrientation::CENTER, text::RelOrientation::PRINT_AREA ) ); aSet.Put( SwFmtVertOrient( 0, text::VertOrientation::TOP, text::RelOrientation::PRINT_AREA ) ); @@ -1330,7 +1326,7 @@ SwFmt* SwDoc::GetFmtFromPool( USHORT nId ) case RES_POOLFRM_GRAPHIC: case RES_POOLFRM_OLE: { - aSet.Put( SwFmtAnchor( FLY_AT_CNTNT )); + aSet.Put( SwFmtAnchor( FLY_AT_PARA )); aSet.Put( SwFmtHoriOrient( 0, text::HoriOrientation::CENTER, text::RelOrientation::FRAME )); aSet.Put( SwFmtVertOrient( 0, text::VertOrientation::TOP, text::RelOrientation::FRAME )); aSet.Put( SwFmtSurround( SURROUND_NONE )); @@ -1338,14 +1334,14 @@ SwFmt* SwDoc::GetFmtFromPool( USHORT nId ) break; case RES_POOLFRM_FORMEL: { - aSet.Put( SwFmtAnchor( FLY_IN_CNTNT ) ); + aSet.Put( SwFmtAnchor( FLY_AS_CHAR ) ); aSet.Put( SwFmtVertOrient( 0, text::VertOrientation::CHAR_CENTER, text::RelOrientation::FRAME ) ); aSet.Put( SvxLRSpaceItem( 114, 114, 0, 0, RES_LR_SPACE ) ); } break; case RES_POOLFRM_MARGINAL: { - aSet.Put( SwFmtAnchor( FLY_AT_CNTNT )); + aSet.Put( SwFmtAnchor( FLY_AT_PARA )); aSet.Put( SwFmtHoriOrient( 0, text::HoriOrientation::LEFT, text::RelOrientation::FRAME )); aSet.Put( SwFmtVertOrient( 0, text::VertOrientation::TOP, text::RelOrientation::FRAME )); aSet.Put( SwFmtSurround( SURROUND_PARALLEL )); @@ -1358,7 +1354,7 @@ SwFmt* SwDoc::GetFmtFromPool( USHORT nId ) break; case RES_POOLFRM_WATERSIGN: { - aSet.Put( SwFmtAnchor( FLY_PAGE )); + aSet.Put( SwFmtAnchor( FLY_AT_PAGE )); aSet.Put( SwFmtHoriOrient( 0, text::HoriOrientation::CENTER, text::RelOrientation::FRAME )); aSet.Put( SwFmtVertOrient( 0, text::VertOrientation::CENTER, text::RelOrientation::FRAME )); aSet.Put( SvxOpaqueItem( FALSE )); @@ -1368,7 +1364,7 @@ SwFmt* SwDoc::GetFmtFromPool( USHORT nId ) case RES_POOLFRM_LABEL: { - aSet.Put( SwFmtAnchor( FLY_IN_CNTNT ) ); + aSet.Put( SwFmtAnchor( FLY_AS_CHAR ) ); aSet.Put( SwFmtVertOrient( 0, text::VertOrientation::TOP, text::RelOrientation::FRAME ) ); aSet.Put( SvxLRSpaceItem( 114, 114, 0, 0, RES_LR_SPACE ) ); diff --git a/sw/source/core/doc/tblcpy.cxx b/sw/source/core/doc/tblcpy.cxx index 5eea4c33247c..297328d0cca5 100644 --- a/sw/source/core/doc/tblcpy.cxx +++ b/sw/source/core/doc/tblcpy.cxx @@ -591,14 +591,14 @@ void lcl_CpyBox( const SwTable& rCpyTbl, const SwTableBox* pCpyBox, } // stehen noch FlyFrames rum, loesche auch diese - const SwPosition* pAPos; for( USHORT n = 0; n < pDoc->GetSpzFrmFmts()->Count(); ++n ) { - SwFrmFmt* pFly = (*pDoc->GetSpzFrmFmts())[n]; - const SwFmtAnchor* pAnchor = &pFly->GetAnchor(); - if( ( FLY_AT_CNTNT == pAnchor->GetAnchorId() || - FLY_AUTO_CNTNT == pAnchor->GetAnchorId() ) && - 0 != ( pAPos = pAnchor->GetCntntAnchor() ) && + SwFrmFmt *const pFly = (*pDoc->GetSpzFrmFmts())[n]; + SwFmtAnchor const*const pAnchor = &pFly->GetAnchor(); + SwPosition const*const pAPos = pAnchor->GetCntntAnchor(); + if (pAPos && + ((FLY_AT_PARA == pAnchor->GetAnchorId()) || + (FLY_AT_CHAR == pAnchor->GetAnchorId())) && aInsIdx <= pAPos->nNode && pAPos->nNode <= aEndNdIdx ) { pDoc->DelLayoutFmt( pFly ); diff --git a/sw/source/core/docnode/ndcopy.cxx b/sw/source/core/docnode/ndcopy.cxx index a2263bc3f442..f37b9c36392c 100644 --- a/sw/source/core/docnode/ndcopy.cxx +++ b/sw/source/core/docnode/ndcopy.cxx @@ -552,20 +552,18 @@ void SwTxtNode::CopyCollFmt( SwTxtNode& rDestNd ) BOOL lcl_ChkFlyFly( SwDoc* pDoc, ULONG nSttNd, ULONG nEndNd, ULONG nInsNd ) { - const SwFrmFmt* pFmt; - const SwFmtAnchor* pAnchor; - const SwPosition* pAPos; const SwSpzFrmFmts& rFrmFmtTbl = *pDoc->GetSpzFrmFmts(); for( USHORT n = 0; n < rFrmFmtTbl.Count(); ++n ) { - pFmt = rFrmFmtTbl[n]; - pAnchor = &pFmt->GetAnchor(); - if( 0 != ( pAPos = pAnchor->GetCntntAnchor()) && - ( FLY_IN_CNTNT == pAnchor->GetAnchorId() || - FLY_AUTO_CNTNT == pAnchor->GetAnchorId() || - FLY_AT_FLY == pAnchor->GetAnchorId() || - FLY_AT_CNTNT == pAnchor->GetAnchorId() ) && + SwFrmFmt const*const pFmt = rFrmFmtTbl[n]; + SwFmtAnchor const*const pAnchor = &pFmt->GetAnchor(); + SwPosition const*const pAPos = pAnchor->GetCntntAnchor(); + if (pAPos && + ((FLY_AS_CHAR == pAnchor->GetAnchorId()) || + (FLY_AT_CHAR == pAnchor->GetAnchorId()) || + (FLY_AT_FLY == pAnchor->GetAnchorId()) || + (FLY_AT_PARA == pAnchor->GetAnchorId())) && nSttNd <= pAPos->nNode.GetIndex() && pAPos->nNode.GetIndex() < nEndNd ) { @@ -1398,18 +1396,17 @@ void SwDoc::CopyFlyInFlyImpl( const SwNodeRange& rRg, SwDoc *const pDest = rStartIdx.GetNode().GetDoc(); _ZSortFlys aArr; USHORT nArrLen = GetSpzFrmFmts()->Count(); - USHORT n; - for( n = 0; n < nArrLen; ++n ) + for ( USHORT n = 0; n < nArrLen; ++n ) { - const SwFrmFmt* pFmt = (*GetSpzFrmFmts())[n]; - const SwFmtAnchor* pAnchor = &pFmt->GetAnchor(); - const SwPosition* pAPos; - bool bAtCntnt = pAnchor->GetAnchorId() == FLY_AT_CNTNT; - if ( ( bAtCntnt || - pAnchor->GetAnchorId() == FLY_AT_FLY || - pAnchor->GetAnchorId() == FLY_AUTO_CNTNT ) && - 0 != ( pAPos = pAnchor->GetCntntAnchor()) && + SwFrmFmt const*const pFmt = (*GetSpzFrmFmts())[n]; + SwFmtAnchor const*const pAnchor = &pFmt->GetAnchor(); + SwPosition const*const pAPos = pAnchor->GetCntntAnchor(); + bool bAtCntnt = (pAnchor->GetAnchorId() == FLY_AT_PARA); + if ( pAPos && + ( bAtCntnt || + (pAnchor->GetAnchorId() == FLY_AT_FLY) || + (pAnchor->GetAnchorId() == FLY_AT_CHAR)) && (( bCopyFlyAtFly && FLY_AT_FLY == pAnchor->GetAnchorId() ) ? rRg.aStart <= pAPos->nNode.GetIndex() + 1 : ( IsRedlineMove() @@ -1470,7 +1467,7 @@ void SwDoc::CopyFlyInFlyImpl( const SwNodeRange& rRg, //die Chains entsprechend aufgebaut werden koennen. SvPtrarr aNewArr( 10, 10 ); - for( n = 0; n < aArr.Count(); ++n ) + for ( USHORT n = 0; n < aArr.Count(); ++n ) { const _ZSortFly& rZSortFly = aArr[ n ]; @@ -1485,8 +1482,8 @@ void SwDoc::CopyFlyInFlyImpl( const SwNodeRange& rRg, // method . // Thus, the new anchor position in the destination document is found // by counting the text nodes. - if ( aAnchor.GetAnchorId() == FLY_AT_CNTNT || - aAnchor.GetAnchorId() == FLY_AUTO_CNTNT ) + if ((aAnchor.GetAnchorId() == FLY_AT_PARA) || + (aAnchor.GetAnchorId() == FLY_AT_CHAR) ) { // First, determine number of anchor text node in the copied range. // Note: The anchor text node *have* to be inside the copied range. @@ -1552,7 +1549,7 @@ void SwDoc::CopyFlyInFlyImpl( const SwNodeRange& rRg, } // <-- // die am Zeichen Flys wieder ans das vorgegebene Zeichen setzen - if ( FLY_AUTO_CNTNT == aAnchor.GetAnchorId() && + if ((FLY_AT_CHAR == aAnchor.GetAnchorId()) && pNewPos->nNode.GetNode().IsTxtNode() ) { pNewPos->nContent.Assign( (SwTxtNode*)&pNewPos->nNode.GetNode(), @@ -1592,7 +1589,7 @@ void SwDoc::CopyFlyInFlyImpl( const SwNodeRange& rRg, ASSERT( aArr.Count() == aNewArr.Count(), "Missing new Flys" ); if ( aArr.Count() == aNewArr.Count() ) { - for ( n = 0; n < aArr.Count(); ++n ) + for ( USHORT n = 0; n < aArr.Count(); ++n ) { const SwFrmFmt *pFmt = aArr[n].GetFmt(); const SwFmtChain &rChain = pFmt->GetChain(); diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx index 6407e505aa0c..3c4149298983 100644 --- a/sw/source/core/docnode/ndtbl.cxx +++ b/sw/source/core/docnode/ndtbl.cxx @@ -38,7 +38,6 @@ #endif #include - #include #include #include @@ -91,9 +90,7 @@ #include #endif #include "docsh.hxx" -#ifdef LINUX #include -#endif #include #include @@ -104,6 +101,9 @@ // --> OD 2005-12-05 #i27138# #include // <-- +#include + + #ifdef PRODUCT #define CHECK_TABLE(t) #else @@ -113,7 +113,6 @@ #define CHECK_TABLE(t) #endif #endif -#include using namespace ::com::sun::star; @@ -1684,17 +1683,19 @@ BOOL SwNodes::TableToText( const SwNodeRange& rRange, sal_Unicode cCh, // #i28006# Fly frames have to be restored even if the table was // #alone in the section const SwSpzFrmFmts& rFlyArr = *GetDoc()->GetSpzFrmFmts(); - const SwPosition* pAPos; for( USHORT n = 0; n < rFlyArr.Count(); ++n ) { - SwFrmFmt* pFmt = (SwFrmFmt*)rFlyArr[n]; + SwFrmFmt *const pFmt = (SwFrmFmt*)rFlyArr[n]; const SwFmtAnchor& rAnchor = pFmt->GetAnchor(); - if( ( FLY_AT_CNTNT == rAnchor.GetAnchorId() || - FLY_AUTO_CNTNT == rAnchor.GetAnchorId() ) && - 0 != ( pAPos = rAnchor.GetCntntAnchor() ) && + SwPosition const*const pAPos = rAnchor.GetCntntAnchor(); + if (pAPos && + ((FLY_AT_PARA == rAnchor.GetAnchorId()) || + (FLY_AT_CHAR == rAnchor.GetAnchorId())) && nStt <= pAPos->nNode.GetIndex() && pAPos->nNode.GetIndex() < nEnd ) + { pFmt->MakeFrms(); + } } return TRUE; diff --git a/sw/source/core/docnode/node.cxx b/sw/source/core/docnode/node.cxx index 61dd90bc509c..2dd69ef99db5 100644 --- a/sw/source/core/docnode/node.cxx +++ b/sw/source/core/docnode/node.cxx @@ -38,9 +38,7 @@ #include // <-- #include -#ifndef _COM_SUN_STAR_I18N_CHARACTERITERATORMODE_HDL_ #include -#endif #include #include #include @@ -609,7 +607,7 @@ const SwPageDesc* SwNode::FindPageDesc( BOOL bCalcLay, if( pFmt ) { const SwFmtAnchor* pAnchor = &pFmt->GetAnchor(); - if( FLY_PAGE != pAnchor->GetAnchorId() && + if ((FLY_AT_PAGE != pAnchor->GetAnchorId()) && pAnchor->GetCntntAnchor() ) { pNd = &pAnchor->GetCntntAnchor()->nNode.GetNode(); @@ -631,7 +629,7 @@ const SwPageDesc* SwNode::FindPageDesc( BOOL bCalcLay, break; } pAnchor = &pFrmFmt->GetAnchor(); - if( FLY_PAGE == pAnchor->GetAnchorId() || + if ((FLY_AT_PAGE == pAnchor->GetAnchorId()) || !pAnchor->GetCntntAnchor() ) { pFlyNd = 0; diff --git a/sw/source/core/docnode/swbaslnk.cxx b/sw/source/core/docnode/swbaslnk.cxx index bb799f7728e0..822a21e5b8c8 100644 --- a/sw/source/core/docnode/swbaslnk.cxx +++ b/sw/source/core/docnode/swbaslnk.cxx @@ -31,14 +31,11 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - #include #include #include -#ifndef _OSL_THREAD_HXX_ #include -#endif #include #include #include @@ -492,18 +489,23 @@ void SwBaseLink::Closed() const SwNode* SwBaseLink::GetAnchor() const { - SwFrmFmt* pFmt; - if( pCntntNode && 0 != ( pFmt = pCntntNode->GetFlyFmt()) ) + if (pCntntNode) { - const SwFmtAnchor& rAnchor = pFmt->GetAnchor(); - const SwPosition* pAPos; - if( 0 != ( pAPos = rAnchor.GetCntntAnchor()) && - ( FLY_IN_CNTNT == rAnchor.GetAnchorId() || - FLY_AUTO_CNTNT == rAnchor.GetAnchorId() || - FLY_AT_FLY == rAnchor.GetAnchorId() || - FLY_AT_CNTNT == rAnchor.GetAnchorId() )) - return &pAPos->nNode.GetNode(); - return 0; + SwFrmFmt *const pFmt = pCntntNode->GetFlyFmt(); + if (pFmt) + { + const SwFmtAnchor& rAnchor = pFmt->GetAnchor(); + SwPosition const*const pAPos = rAnchor.GetCntntAnchor(); + if (pAPos && + ((FLY_AS_CHAR == rAnchor.GetAnchorId()) || + (FLY_AT_CHAR == rAnchor.GetAnchorId()) || + (FLY_AT_FLY == rAnchor.GetAnchorId()) || + (FLY_AT_PARA == rAnchor.GetAnchorId()))) + { + return &pAPos->nNode.GetNode(); + } + return 0; + } } ASSERT( !this, "GetAnchor nicht ueberlagert" ); diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx index aa20281038da..13ae626bc8c7 100644 --- a/sw/source/core/draw/dcontact.cxx +++ b/sw/source/core/draw/dcontact.cxx @@ -61,9 +61,7 @@ #include #include #include -#ifndef IDOCUMENTDRAWMODELACCESS_HXX_INCLUDED #include -#endif #include #include #include @@ -80,17 +78,9 @@ #include // AW: For VCOfDrawVirtObj and stuff -#ifndef _SDR_CONTACT_VIEWCONTACTOFVIRTOBJ_HXX #include -#endif - -#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_TRANSFORMPRIMITIVE2D_HXX #include -#endif - -#ifndef _SDR_CONTACT_VIEWOBJECTCONTACTOFSDROBJ_HXX #include -#endif #include @@ -1958,7 +1948,7 @@ void SwDrawContact::ConnectToLayout( const SwFmtAnchor* pAnch ) switch ( pAnch->GetAnchorId() ) { - case FLY_PAGE: + case FLY_AT_PAGE: { USHORT nPgNum = pAnch->GetPageNum(); SwPageFrm *pPage = static_cast(pRoot->Lower()); @@ -1978,12 +1968,12 @@ void SwDrawContact::ConnectToLayout( const SwFmtAnchor* pAnch ) } break; - case FLY_AUTO_CNTNT: - case FLY_AT_CNTNT: + case FLY_AT_CHAR: + case FLY_AT_PARA: case FLY_AT_FLY: - case FLY_IN_CNTNT: + case FLY_AS_CHAR: { - if ( pAnch->GetAnchorId() == FLY_IN_CNTNT ) + if ( pAnch->GetAnchorId() == FLY_AS_CHAR ) { ClrContourCache( GetMaster() ); } @@ -2058,7 +2048,7 @@ void SwDrawContact::ConnectToLayout( const SwFmtAnchor* pAnch ) // OD 2004-01-20 #110582# - find correct follow for // as character anchored objects. - if ( pAnch->GetAnchorId() == FLY_IN_CNTNT && + if ((pAnch->GetAnchorId() == FLY_AS_CHAR) && pFrm->IsTxtFrm() ) { pFrm = lcl_GetFlyInCntntAnchor( @@ -2076,7 +2066,7 @@ void SwDrawContact::ConnectToLayout( const SwFmtAnchor* pAnch ) { // append 'virtual' drawing object SwDrawVirtObj* pDrawVirtObj = AddVirtObj(); - if ( pAnch->GetAnchorId() == FLY_IN_CNTNT ) + if ( pAnch->GetAnchorId() == FLY_AS_CHAR ) { ClrContourCache( pDrawVirtObj ); } @@ -2087,7 +2077,7 @@ void SwDrawContact::ConnectToLayout( const SwFmtAnchor* pAnch ) pDrawVirtObj->ActionChanged(); } - if ( pAnch->GetAnchorId() == FLY_IN_CNTNT ) + if ( pAnch->GetAnchorId() == FLY_AS_CHAR ) { pFrm->InvalidatePrt(); } diff --git a/sw/source/core/draw/dview.cxx b/sw/source/core/draw/dview.cxx index 9843f8f8c34e..8cf40983caf9 100644 --- a/sw/source/core/draw/dview.cxx +++ b/sw/source/core/draw/dview.cxx @@ -34,9 +34,7 @@ #include "hintids.hxx" #include #include -#ifndef _FM_FMMODEL_HXX #include -#endif #include "swtypes.hxx" #include "pagefrm.hxx" @@ -62,8 +60,6 @@ #include -using namespace com::sun::star; - // OD 18.06.2003 #108784# //#ifndef _SVDVMARK_HXX //autogen //#include @@ -74,6 +70,10 @@ using namespace com::sun::star; #include // <-- + +using namespace com::sun::star; + + class SwSdrHdl : public SdrHdl { public: @@ -258,7 +258,7 @@ void SwDrawView::AddCustomHdl() const SwFmtAnchor &rAnchor = pFrmFmt->GetAnchor(); // <-- - if(FLY_IN_CNTNT == rAnchor.GetAnchorId()) + if (FLY_AS_CHAR == rAnchor.GetAnchorId()) return; const SwFrm* pAnch; @@ -267,7 +267,7 @@ void SwDrawView::AddCustomHdl() Point aPos(aAnchorPoint); - if ( FLY_AUTO_CNTNT == rAnchor.GetAnchorId() ) + if ( FLY_AT_CHAR == rAnchor.GetAnchorId() ) { // --> OD 2004-06-24 #i28701# - use last character rectangle saved at object // in order to avoid a format of the anchor frame @@ -1019,7 +1019,7 @@ void SwDrawView::CheckPossibilities() " - missing frame format" ); bProtect = TRUE; } - else if ( FLY_IN_CNTNT == pFrmFmt->GetAnchor().GetAnchorId() && + else if ((FLY_AS_CHAR == pFrmFmt->GetAnchor().GetAnchorId()) && rMrkList.GetMarkCount() > 1 ) { bProtect = TRUE; diff --git a/sw/source/core/edit/autofmt.cxx b/sw/source/core/edit/autofmt.cxx index 7bacee8fbde4..533810062ee7 100644 --- a/sw/source/core/edit/autofmt.cxx +++ b/sw/source/core/edit/autofmt.cxx @@ -386,7 +386,7 @@ BOOL SwAutoFormat::HasObjects( const SwNode& rNd ) for( USHORT n = 0; n < rFmts.Count(); ++n ) { const SwFmtAnchor& rAnchor = rFmts[ n ]->GetAnchor(); - if( FLY_PAGE != rAnchor.GetAnchorId() && + if ((FLY_AT_PAGE != rAnchor.GetAnchorId()) && rAnchor.GetCntntAnchor() && &rAnchor.GetCntntAnchor()->nNode.GetNode() == &rNd ) { diff --git a/sw/source/core/fields/expfld.cxx b/sw/source/core/fields/expfld.cxx index ccb47233753d..38745a12ba7b 100644 --- a/sw/source/core/fields/expfld.cxx +++ b/sw/source/core/fields/expfld.cxx @@ -64,9 +64,7 @@ #include #include #include -#ifndef _UNOFLDMID_H #include -#endif #include using namespace ::com::sun::star; @@ -187,17 +185,20 @@ const SwTxtNode* GetBodyTxtNode( const SwDoc& rDoc, SwPosition& rPos, pLayout = (SwLayoutFrm*)((SwFlyFrm*)pLayout)->GetAnchorFrm(); continue; } - else if( FLY_AT_CNTNT == rAnchor.GetAnchorId() || - FLY_AUTO_CNTNT == rAnchor.GetAnchorId() || - FLY_IN_CNTNT == rAnchor.GetAnchorId() ) + else if ((FLY_AT_PARA == rAnchor.GetAnchorId()) || + (FLY_AT_CHAR == rAnchor.GetAnchorId()) || + (FLY_AS_CHAR == rAnchor.GetAnchorId())) { ASSERT( rAnchor.GetCntntAnchor(), "keine gueltige Position" ); rPos = *rAnchor.GetCntntAnchor(); pTxtNode = rPos.nNode.GetNode().GetTxtNode(); - if( FLY_AT_CNTNT == rAnchor.GetAnchorId() ) - ((SwTxtNode*)pTxtNode)->MakeStartIndex( &rPos.nContent ); + if ( FLY_AT_PARA == rAnchor.GetAnchorId() ) + { + const_cast(pTxtNode)->MakeStartIndex( + &rPos.nContent ); // oder doch besser das Ende vom (Anker-)TextNode nehmen ?? // ((SwTxtNode*)pTxtNode)->MakeEndIndex( &rPos.nContent ); + } // noch nicht abbrechen, kann ja auch noch im // Header/Footer/Footnote/Fly stehen !! diff --git a/sw/source/core/frmedt/fecopy.cxx b/sw/source/core/frmedt/fecopy.cxx index ccd2d86e4531..bb1a230699ae 100644 --- a/sw/source/core/frmedt/fecopy.cxx +++ b/sw/source/core/frmedt/fecopy.cxx @@ -151,14 +151,16 @@ BOOL SwFEShell::Copy( SwDoc* pClpDoc, const String* pNewClpTxt ) SwFrmFmt* pFlyFmt = pFly->GetFmt(); SwFmtAnchor aAnchor( pFlyFmt->GetAnchor() ); - if ( FLY_AT_CNTNT == aAnchor.GetAnchorId() || - FLY_AUTO_CNTNT == aAnchor.GetAnchorId() || - FLY_AT_FLY == aAnchor.GetAnchorId() || - FLY_IN_CNTNT == aAnchor.GetAnchorId() ) + if ((FLY_AT_PARA == aAnchor.GetAnchorId()) || + (FLY_AT_CHAR == aAnchor.GetAnchorId()) || + (FLY_AT_FLY == aAnchor.GetAnchorId()) || + (FLY_AS_CHAR == aAnchor.GetAnchorId())) { SwPosition aPos( aSttIdx ); - if( FLY_IN_CNTNT == aAnchor.GetAnchorId() ) + if ( FLY_AS_CHAR == aAnchor.GetAnchorId() ) + { aPos.nContent.Assign( pTxtNd, 0 ); + } aAnchor.SetAnchor( &aPos ); } pFlyFmt = pClpDoc->CopyLayoutFmt( *pFlyFmt, aAnchor, true, true ); @@ -175,7 +177,7 @@ BOOL SwFEShell::Copy( SwDoc* pClpDoc, const String* pNewClpTxt ) rSpzFrmFmts.Insert( pFlyFmt, 0 ); } - if( FLY_IN_CNTNT == aAnchor.GetAnchorId() ) + if ( FLY_AS_CHAR == aAnchor.GetAnchorId() ) { // JP 13.02.99 Bug 61863: wenn eine Rahmenselektion ins Clipboard // gestellt wird, so muss beim Pasten auch wieder @@ -206,24 +208,25 @@ BOOL SwFEShell::Copy( SwDoc* pClpDoc, const String* pNewClpTxt ) { SfxItemSet aSet( pClpDoc->GetAttrPool(), aFrmFmtSetRange ); - SwFmtAnchor aAnchor( FLY_AT_CNTNT ); + SwFmtAnchor aAnchor( FLY_AT_PARA ); aAnchor.SetAnchor( &aPos ); aSet.Put( aAnchor ); - SdrObject* pNew = pClpDoc->CloneSdrObj( *pObj, FALSE, TRUE ); + SdrObject *const pNew = + pClpDoc->CloneSdrObj( *pObj, FALSE, TRUE ); SwPaM aTemp(aPos); - pClpDoc->Insert(aTemp, *pNew, &aSet, NULL); + pClpDoc->Insert(aTemp, *pNew, &aSet, NULL); } else { SwDrawContact *pContact = (SwDrawContact*)GetUserCall( pObj ); SwFrmFmt *pFmt = pContact->GetFmt(); SwFmtAnchor aAnchor( pFmt->GetAnchor() ); - if ( FLY_AT_CNTNT == aAnchor.GetAnchorId() || - FLY_AUTO_CNTNT == aAnchor.GetAnchorId() || - FLY_AT_FLY == aAnchor.GetAnchorId() || - FLY_IN_CNTNT == aAnchor.GetAnchorId() ) + if ((FLY_AT_PARA == aAnchor.GetAnchorId()) || + (FLY_AT_CHAR == aAnchor.GetAnchorId()) || + (FLY_AT_FLY == aAnchor.GetAnchorId()) || + (FLY_AS_CHAR == aAnchor.GetAnchorId())) { aAnchor.SetAnchor( &aPos ); } @@ -269,7 +272,9 @@ BOOL lcl_SetAnchor( const SwPosition& rPos, const SwNode& rNd, SwFlyFrm* pFly, SwCntntFrm* pTmpFrm = rNd.GetCntntNode()->GetFrm( &rInsPt, 0, FALSE ); SwFlyFrm *pTmpFly = pTmpFrm->FindFlyFrm(); if( pTmpFly && bCheckFlyRecur && pFly->IsUpperOf( *pTmpFly ) ) + { bRet = FALSE; + } else if ( FLY_AT_FLY == rAnchor.GetAnchorId() ) { if( pTmpFly ) @@ -281,7 +286,7 @@ BOOL lcl_SetAnchor( const SwPosition& rPos, const SwNode& rNd, SwFlyFrm* pFly, } else { - rAnchor.SetType( FLY_PAGE ); + rAnchor.SetType( FLY_AT_PAGE ); rAnchor.SetPageNum( rDestShell.GetPageNumber( rInsPt ) ); const SwFrm *pPg = pTmpFrm->FindPageFrm(); rNewPos = pPg->Frm().Pos(); @@ -329,7 +334,7 @@ BOOL SwFEShell::CopyDrawSel( SwFEShell* pDestShell, const Point& rSttPt, // in die Gruppe einfuegen, wenns aus einer betretenen Gruppe // kommt oder das Object nicht zeichengebunden ist if( pSrcDrwView->IsGroupEntered() || - FLY_IN_CNTNT != rAnchor.GetAnchorId() ) + (FLY_AS_CHAR != rAnchor.GetAnchorId()) ) { SdrObject* pNew = pDestDoc->CloneSdrObj( *pObj, bIsMove && @@ -345,10 +350,10 @@ BOOL SwFEShell::CopyDrawSel( SwFEShell* pDestShell, const Point& rSttPt, SwFmtAnchor aAnchor( rAnchor ); Point aNewAnch; - if ( FLY_AT_CNTNT == aAnchor.GetAnchorId() || - FLY_AUTO_CNTNT == aAnchor.GetAnchorId() || - FLY_AT_FLY == aAnchor.GetAnchorId() || - FLY_IN_CNTNT == aAnchor.GetAnchorId() ) + if ((FLY_AT_PARA == aAnchor.GetAnchorId()) || + (FLY_AT_CHAR == aAnchor.GetAnchorId()) || + (FLY_AT_FLY == aAnchor.GetAnchorId()) || + (FLY_AS_CHAR == aAnchor.GetAnchorId())) { if ( this == pDestShell ) { @@ -378,7 +383,7 @@ BOOL SwFEShell::CopyDrawSel( SwFEShell* pDestShell, const Point& rSttPt, aNewAnch, FALSE ); } } - else if( FLY_PAGE == aAnchor.GetAnchorId() ) + else if ( FLY_AT_PAGE == aAnchor.GetAnchorId() ) { aAnchor.SetPageNum( pDestShell->GetPageNumber( rInsPt ) ); const SwRootFrm* pTmpRoot = pDestShell->GetLayout(); @@ -406,7 +411,7 @@ BOOL SwFEShell::CopyDrawSel( SwFEShell* pDestShell, const Point& rSttPt, if ( pFmt ) { SdrObject* pNew = pFmt->FindSdrObject(); - if( FLY_IN_CNTNT != aAnchor.GetAnchorId() ) + if ( FLY_AS_CHAR != aAnchor.GetAnchorId() ) { Point aPos( rInsPt ); aPos -= aNewAnch; @@ -496,10 +501,10 @@ BOOL SwFEShell::Copy( SwFEShell* pDestShell, const Point& rSttPt, bRet = TRUE; Point aNewAnch; - if ( FLY_AT_CNTNT == aAnchor.GetAnchorId() || - FLY_AUTO_CNTNT == aAnchor.GetAnchorId() || - FLY_AT_FLY == aAnchor.GetAnchorId() || - FLY_IN_CNTNT == aAnchor.GetAnchorId() ) + if ((FLY_AT_PARA == aAnchor.GetAnchorId()) || + (FLY_AT_CHAR == aAnchor.GetAnchorId()) || + (FLY_AT_FLY == aAnchor.GetAnchorId()) || + (FLY_AS_CHAR == aAnchor.GetAnchorId())) { if ( this == pDestShell ) { @@ -537,7 +542,7 @@ BOOL SwFEShell::Copy( SwFEShell* pDestShell, const Point& rSttPt, aNewAnch, GetDoc() == pDestShell->GetDoc()); } } - else if( FLY_PAGE == aAnchor.GetAnchorId() ) + else if ( FLY_AT_PAGE == aAnchor.GetAnchorId() ) { aAnchor.SetPageNum( pDestShell->GetPageNumber( rInsPt ) ); const SwRootFrm* pTmpRoot = pDestShell->GetLayout(); @@ -554,7 +559,7 @@ BOOL SwFEShell::Copy( SwFEShell* pDestShell, const Point& rSttPt, SwFrmFmt *pOldFmt = pFlyFmt; pFlyFmt = pDestShell->GetDoc()->CopyLayoutFmt( *pFlyFmt, aAnchor, true, true ); - if( FLY_IN_CNTNT != aAnchor.GetAnchorId() ) + if ( FLY_AS_CHAR != aAnchor.GetAnchorId() ) { Point aPos( rInsPt ); aPos -= aNewAnch; @@ -918,7 +923,7 @@ BOOL SwFEShell::Paste( SwDoc* pClpDoc, BOOL bIncludingPageFrames ) if( Imp()->GetDrawView()->IsGroupEntered() && RES_DRAWFRMFMT == rCpyFmt.Which() && - FLY_IN_CNTNT != rCpyFmt.GetAnchor().GetAnchorId() ) + (FLY_AS_CHAR != rCpyFmt.GetAnchor().GetAnchorId()) ) { const SdrObject* pSdrObj = rCpyFmt.FindSdrObject(); if( pSdrObj ) @@ -966,9 +971,9 @@ BOOL SwFEShell::Paste( SwDoc* pClpDoc, BOOL bIncludingPageFrames ) if( bInsWithFmt ) { SwFmtAnchor aAnchor( rCpyFmt.GetAnchor() ); - if( FLY_AT_CNTNT == aAnchor.GetAnchorId() || - FLY_AUTO_CNTNT == aAnchor.GetAnchorId() || - FLY_IN_CNTNT == aAnchor.GetAnchorId() ) + if ((FLY_AT_PARA == aAnchor.GetAnchorId()) || + (FLY_AT_CHAR == aAnchor.GetAnchorId()) || + (FLY_AS_CHAR == aAnchor.GetAnchorId())) { SwPosition* pPos = PCURCRSR->GetPoint(); // #108784# allow shapes (no controls) in header/footer @@ -979,7 +984,7 @@ BOOL SwFEShell::Paste( SwDoc* pClpDoc, BOOL bIncludingPageFrames ) aAnchor.SetAnchor( pPos ); } - else if( FLY_PAGE == aAnchor.GetAnchorId() ) + else if ( FLY_AT_PAGE == aAnchor.GetAnchorId() ) { aAnchor.SetPageNum( GetPhyPageNum() ); } @@ -1091,7 +1096,7 @@ BOOL SwFEShell::Paste( SwDoc* pClpDoc, BOOL bIncludingPageFrames ) if( bInsWithFmt ) { SwFmtAnchor aAnchor( rCpyFmt.GetAnchor() ); - if( FLY_PAGE == aAnchor.GetAnchorId() ) + if ( FLY_AT_PAGE == aAnchor.GetAnchorId() ) { aAnchor.SetPageNum( aAnchor.GetPageNum() + nStartPageNumber - 1 ); } @@ -1199,7 +1204,7 @@ BOOL SwFEShell::PastePages( SwFEShell& rToFill, USHORT nStartPage, USHORT nEndPa { const SwFrmFmt& rCpyFmt = *(*GetDoc()->GetSpzFrmFmts())[i]; SwFmtAnchor aAnchor( rCpyFmt.GetAnchor() ); - if( FLY_PAGE == aAnchor.GetAnchorId() && + if ((FLY_AT_PAGE == aAnchor.GetAnchorId()) && aAnchor.GetPageNum() >= nStartPage && aAnchor.GetPageNum() <= nEndPage) { aAnchor.SetPageNum( aAnchor.GetPageNum() - nStartPage + 1); diff --git a/sw/source/core/frmedt/fefly1.cxx b/sw/source/core/frmedt/fefly1.cxx index 1b18dc178dae..db708c63a0e1 100644 --- a/sw/source/core/frmedt/fefly1.cxx +++ b/sw/source/core/frmedt/fefly1.cxx @@ -113,7 +113,7 @@ sal_Bool lcl_SetNewFlyPos( const SwNode& rNode, SwFmtAnchor& rAnchor, const SwPageFrm *pPg = pCFrm ? pCFrm->FindPageFrm() : 0; rAnchor.SetPageNum( pPg ? pPg->GetPhyPageNum() : 1 ); - rAnchor.SetType( FLY_PAGE ); + rAnchor.SetType( FLY_AT_PAGE ); } return bRet; } @@ -130,9 +130,9 @@ BOOL lcl_FindAnchorPos( SwDoc& rDoc, const Point& rPt, const SwFrm& rFrm, Point aTmpPnt( rPt ); switch( nNew ) { - case FLY_IN_CNTNT: // sollte der nicht auch mit hinein? - case FLY_AT_CNTNT: - case FLY_AUTO_CNTNT: // LAYER_IMPL + case FLY_AS_CHAR: // sollte der nicht auch mit hinein? + case FLY_AT_PARA: + case FLY_AT_CHAR: // LAYER_IMPL { //Ausgehend von der linken oberen Ecke des Fly den //dichtesten CntntFrm suchen. @@ -146,7 +146,7 @@ BOOL lcl_FindAnchorPos( SwDoc& rDoc, const Point& rPt, const SwFrm& rFrm, } SwPosition aPos( *((SwCntntFrm*)pNewAnch)->GetNode() ); - if( FLY_AUTO_CNTNT == nNew || FLY_IN_CNTNT == nNew ) + if ((FLY_AT_CHAR == nNew) || (FLY_AS_CHAR == nNew)) { // es muss ein TextNode gefunden werden, denn nur in diesen // ist ein Inhaltsgebundene Frames zu verankern @@ -186,10 +186,10 @@ BOOL lcl_FindAnchorPos( SwDoc& rDoc, const Point& rPt, const SwFrm& rFrm, } } - aNewAnch.SetType( nNew = FLY_PAGE ); + aNewAnch.SetType( nNew = FLY_AT_PAGE ); // no break - case FLY_PAGE: + case FLY_AT_PAGE: pNewAnch = rFrm.FindPageFrm(); aNewAnch.SetPageNum( pNewAnch->GetPhyPageNum() ); break; @@ -219,8 +219,8 @@ sal_Bool lcl_ChkAndSetNewAnchor( const SwFlyFrm& rFly, SfxItemSet& rSet ) SwDoc* pDoc = (SwDoc*)rFmt.GetDoc(); #ifndef PRODUCT - ASSERT( !(nNew == FLY_PAGE && - (FLY_AT_CNTNT==nOld || FLY_AUTO_CNTNT==nOld || FLY_IN_CNTNT==nOld ) && + ASSERT( !(nNew == FLY_AT_PAGE && + (FLY_AT_PARA==nOld || FLY_AT_CHAR==nOld || FLY_AS_CHAR==nOld ) && pDoc->IsInHeaderFooter( rOldAnch.GetCntntAnchor()->nNode )), "Unerlaubter Ankerwechsel in Head/Foot." ); #endif @@ -441,7 +441,7 @@ Point SwFEShell::FindAnchorPos( const Point& rAbsPos, sal_Bool bMoveIt ) SwFrmFmt& rFmt = pAnchoredObj->GetFrmFmt(); RndStdIds nAnchorId = rFmt.GetAnchor().GetAnchorId(); - if ( FLY_IN_CNTNT == nAnchorId ) + if ( FLY_AS_CHAR == nAnchorId ) return aRet; sal_Bool bFlyFrame = pObj->ISA(SwVirtFlyDrawObj); @@ -462,8 +462,10 @@ Point SwFEShell::FindAnchorPos( const Point& rAbsPos, sal_Bool bMoveIt ) pOldAnch = pFly->GetAnchorFrm(); if( !pOldAnch ) return aRet; - if( FLY_PAGE != nAnchorId ) + if ( FLY_AT_PAGE != nAnchorId ) + { pFooterOrHeader = pCntnt->FindFooterOrHeader(); + } } // OD 26.06.2003 #108784# - set also for drawing // objects, but not for control objects. @@ -489,14 +491,18 @@ Point SwFEShell::FindAnchorPos( const Point& rAbsPos, sal_Bool bMoveIt ) const SwFrm *pNewAnch; if( pTxtFrm ) { - if( FLY_PAGE == nAnchorId ) + if ( FLY_AT_PAGE == nAnchorId ) + { pNewAnch = pTxtFrm->FindPageFrm(); + } else { pNewAnch = ::FindAnchor( pTxtFrm, rAbsPos ); if( FLY_AT_FLY == nAnchorId ) // LAYER_IMPL + { pNewAnch = pNewAnch->FindFlyFrm(); + } } } else @@ -522,19 +528,19 @@ Point SwFEShell::FindAnchorPos( const Point& rAbsPos, sal_Bool bMoveIt ) { aRet = pNewAnch->GetFrmAnchorPos( ::HasWrap( pObj ) ); - if( bMoveIt || nAnchorId == FLY_AUTO_CNTNT ) + if ( bMoveIt || (nAnchorId == FLY_AT_CHAR) ) { SwFmtAnchor aAnch( rFmt.GetAnchor() ); switch ( nAnchorId ) { - case FLY_AT_CNTNT: + case FLY_AT_PARA: { SwPosition *pPos = (SwPosition*)aAnch.GetCntntAnchor(); pPos->nNode = *pTxtFrm->GetNode(); pPos->nContent.Assign(0,0); break; } - case FLY_PAGE: + case FLY_AT_PAGE: { aAnch.SetPageNum( ((const SwPageFrm*)pNewAnch)-> GetPhyPageNum() ); @@ -547,7 +553,7 @@ Point SwFEShell::FindAnchorPos( const Point& rAbsPos, sal_Bool bMoveIt ) aAnch.SetAnchor( &aPos ); break; } - case FLY_AUTO_CNTNT: + case FLY_AT_CHAR: { SwPosition *pPos = (SwPosition*)aAnch.GetCntntAnchor(); Point aTmpPnt( rAbsPos ); @@ -666,21 +672,25 @@ const SwFrmFmt *SwFEShell::NewFlyFrm( const SfxItemSet& rSet, sal_Bool bAnchVali RndStdIds eRndId = rAnch.GetAnchorId(); switch( eRndId ) { - case FLY_PAGE: + case FLY_AT_PAGE: if( !rAnch.GetPageNum() ) //HotFix: Bug in UpdateByExample rAnch.SetPageNum( 1 ); break; case FLY_AT_FLY: - case FLY_AT_CNTNT: - case FLY_AUTO_CNTNT: - case FLY_IN_CNTNT: + case FLY_AT_PARA: + case FLY_AT_CHAR: + case FLY_AS_CHAR: if( !bAnchValid ) { if( FLY_AT_FLY != eRndId ) + { rAnch.SetAnchor( &rPos ); + } else if( lcl_SetNewFlyPos( rPos.nNode.GetNode(), rAnch, aPt ) ) - eRndId = FLY_PAGE; + { + eRndId = FLY_AT_PAGE; + } } break; @@ -698,7 +708,7 @@ const SwFrmFmt *SwFEShell::NewFlyFrm( const SfxItemSet& rSet, sal_Bool bAnchVali SwFmtVertOrient aOldV; SwFmtHoriOrient aOldH; - if( FLY_PAGE != eRndId ) + if ( FLY_AT_PAGE != eRndId ) { // erstmal als mit Seitenbindung, Absatz/Zeichenbindung erst wenn // alles verschoben ist. Dann ist die Position gueltig! @@ -706,7 +716,7 @@ const SwFrmFmt *SwFEShell::NewFlyFrm( const SfxItemSet& rSet, sal_Bool bAnchVali // umsetzen, damit diese beim Umanker NICHT // korrigiert wird pOldAnchor = new SwFmtAnchor( rAnch ); - ((SfxItemSet&)rSet).Put( SwFmtAnchor( FLY_PAGE, 1 ) ); + const_cast(rSet).Put( SwFmtAnchor( FLY_AT_PAGE, 1 ) ); const SfxPoolItem* pItem; if( SFX_ITEM_SET == rSet.GetItemState( RES_HORI_ORIENT, sal_False, &pItem ) @@ -741,8 +751,10 @@ const SwFrmFmt *SwFEShell::NewFlyFrm( const SfxItemSet& rSet, sal_Bool bAnchVali const SwFrm* pAnch = ::FindAnchor( GetLayout(), aPt, sal_False ); SwPosition aPos( *((SwCntntFrm*)pAnch)->GetNode() ); - if( FLY_IN_CNTNT == eRndId ) + if ( FLY_AS_CHAR == eRndId ) + { aPos.nContent.Assign( ((SwCntntFrm*)pAnch)->GetNode(), 0 ); + } pOldAnchor->SetAnchor( &aPos ); // das verschieben von TabelleSelektion ist noch nicht @@ -818,9 +830,9 @@ void SwFEShell::Insert( const String& rGrfName, const String& rFltName, SwFmtAnchor* pAnchor = (SwFmtAnchor*)pItem; switch( pAnchor->GetAnchorId()) { - case FLY_AT_CNTNT: - case FLY_AUTO_CNTNT: // LAYER_IMPL - case FLY_IN_CNTNT: + case FLY_AT_PARA: + case FLY_AT_CHAR: // LAYER_IMPL + case FLY_AS_CHAR: if( !pAnchor->GetCntntAnchor() ) { pAnchor->SetAnchor( pCursor->GetPoint() ); @@ -833,7 +845,7 @@ void SwFEShell::Insert( const String& rGrfName, const String& rFltName, *pAnchor, GetCrsrDocPos() ); } break; - case FLY_PAGE: + case FLY_AT_PAGE: if( !pAnchor->GetPageNum() ) { pAnchor->SetPageNum( pCursor->GetPageNum( @@ -912,10 +924,10 @@ void SwFEShell::Insert( SdrObject& rDrawObj, const SfxPoolItem* pItem; if( !pFlyAttrSet || !pFlyAttrSet->GetItemState( RES_ANCHOR, sal_False, &pItem ) || - FLY_PAGE != ((SwFmtAnchor*)pItem)->GetAnchorId() ) + (FLY_AT_PAGE != ((SwFmtAnchor*)pItem)->GetAnchorId())) { pSet = new SfxItemSet( GetDoc()->GetAttrPool(), aFrmFmtSetRange ); - pSet->Put( SwFmtAnchor( FLY_AT_CNTNT )); + pSet->Put( SwFmtAnchor( FLY_AT_PARA )); pFlyAttrSet = pSet; } @@ -978,8 +990,10 @@ void SwFEShell::GetPageObjs( SvPtrarr& rFillArr ) for( sal_uInt16 n = 0; n < pDoc->GetSpzFrmFmts()->Count(); ++n ) { pFmt = (const SwFrmFmt*)(*pDoc->GetSpzFrmFmts())[n]; - if( FLY_PAGE == pFmt->GetAnchor().GetAnchorId() ) + if (FLY_AT_PAGE == pFmt->GetAnchor().GetAnchorId()) + { rFillArr.Insert( (VoidPtr)pFmt, rFillArr.Count() ); + } } } @@ -1010,7 +1024,7 @@ void SwFEShell::SetPageObjsNewPage( SvPtrarr& rFillArr, int nOffset ) { // FlyFmt ist noch gueltig, also behandeln SwFmtAnchor aNewAnchor( pFmt->GetAnchor() ); - if( FLY_PAGE != aNewAnchor.GetAnchorId() || + if ((FLY_AT_PAGE != aNewAnchor.GetAnchorId()) || 0 >= ( nNewPage = aNewAnchor.GetPageNum() + nOffset ) ) // chaos::Anchor wurde veraendert oder ungueltige SeitenNummer, // also nicht veraendern !! @@ -1086,12 +1100,12 @@ sal_Bool SwFEShell::GetFlyFrmAttr( SfxItemSet &rSet ) const SwFmtAnchor* pAnchor = (SwFmtAnchor*)pItem; RndStdIds eType = pAnchor->GetAnchorId(); - if( FLY_PAGE != eType ) + if ( FLY_AT_PAGE != eType ) { // OD 12.11.2003 #i22341# - content anchor of anchor item is needed. // Thus, don't overwrite anchor item by default contructed anchor item. //rSet.Put( SwFmtAnchor( eType ) ); - if( FLY_IN_CNTNT == eType ) + if ( FLY_AS_CHAR == eType ) { rSet.ClearItem( RES_OPAQUE ); rSet.ClearItem( RES_SURROUND ); @@ -1828,7 +1842,7 @@ ObjCntType SwFEShell::GetObjCntType( const SdrObject& rObj ) const " - missing frame format" ); eType = OBJCNT_NONE; } - else if ( FLY_IN_CNTNT != pFrmFmt->GetAnchor().GetAnchorId() ) + else if ( FLY_AS_CHAR != pFrmFmt->GetAnchor().GetAnchorId() ) { eType = OBJCNT_GROUPOBJ; } diff --git a/sw/source/core/frmedt/feshview.cxx b/sw/source/core/frmedt/feshview.cxx index d465abc4403e..af2e8d1c7677 100644 --- a/sw/source/core/frmedt/feshview.cxx +++ b/sw/source/core/frmedt/feshview.cxx @@ -326,7 +326,7 @@ sal_Bool SwFEShell::MoveAnchor( USHORT nDir ) SwFrmFmt& rFmt = pAnchoredObj->GetFrmFmt(); SwFmtAnchor aAnch( rFmt.GetAnchor() ); RndStdIds nAnchorId = aAnch.GetAnchorId(); - if ( FLY_IN_CNTNT == nAnchorId ) + if ( FLY_AS_CHAR == nAnchorId ) return sal_False; if( pOld->IsVertical() ) { @@ -348,7 +348,7 @@ sal_Bool SwFEShell::MoveAnchor( USHORT nDir ) } } switch ( nAnchorId ) { - case FLY_PAGE: + case FLY_AT_PAGE: { ASSERT( pOld->IsPageFrm(), "Wrong anchor, page exspected." ); if( SW_MOVE_UP == nDir ) @@ -362,7 +362,7 @@ sal_Bool SwFEShell::MoveAnchor( USHORT nDir ) } break; } - case FLY_AUTO_CNTNT: + case FLY_AT_CHAR: { ASSERT( pOld->IsCntntFrm(), "Wrong anchor, page exspected." ); if( SW_MOVE_LEFT == nDir || SW_MOVE_RIGHT == nDir ) @@ -396,7 +396,7 @@ sal_Bool SwFEShell::MoveAnchor( USHORT nDir ) } } } // no break! - case FLY_AT_CNTNT: + case FLY_AT_PARA: { ASSERT( pOld->IsCntntFrm(), "Wrong anchor, page exspected." ); if( SW_MOVE_UP == nDir ) @@ -1652,7 +1652,7 @@ BOOL SwFEShell::ImpEndCreate() if( bCharBound ) { - aAnch.SetType( FLY_IN_CNTNT ); + aAnch.SetType( FLY_AS_CHAR ); aAnch.SetAnchor( &aPos ); } } @@ -1719,7 +1719,7 @@ BOOL SwFEShell::ImpEndCreate() bAtPage = true; else { - aAnch.SetType( FLY_AT_CNTNT ); + aAnch.SetType( FLY_AT_PARA ); aAnch.SetAnchor( &aPos ); } } @@ -1728,7 +1728,7 @@ BOOL SwFEShell::ImpEndCreate() { pPage = pAnch->FindPageFrm(); - aAnch.SetType( FLY_PAGE ); + aAnch.SetType( FLY_AT_PAGE ); aAnch.SetPageNum( pPage->GetPhyPageNum() ); pAnch = pPage; // die Page wird jetzt zum Anker } @@ -1871,7 +1871,7 @@ BOOL SwFEShell::ImpEndCreate() // <-- if( bCharBound ) { - ASSERT( aAnch.GetAnchorId() == FLY_IN_CNTNT, "wrong AnchorType" ); + ASSERT( aAnch.GetAnchorId() == FLY_AS_CHAR, "wrong AnchorType" ); SwTxtNode *pNd = aAnch.GetCntntAnchor()->nNode.GetNode().GetTxtNode(); SwFmtFlyCnt aFmt( pFmt ); pNd->InsertItem(aFmt, @@ -2256,7 +2256,7 @@ BOOL SwFEShell::IsGroupSelected() // --> FME 2004-12-08 #i38505# No ungroup allowed for 3d objects !pObj->Is3DObj() && // <-- - FLY_IN_CNTNT != ((SwDrawContact*)GetUserCall(pObj))-> + FLY_AS_CHAR != ((SwDrawContact*)GetUserCall(pObj))-> GetFmt()->GetAnchor().GetAnchorId() ) { return TRUE; @@ -2302,7 +2302,7 @@ bool SwFEShell::IsGroupAllowed() const " - missing frame format" ); bIsGroupAllowed = false; } - else if ( FLY_IN_CNTNT == pFrmFmt->GetAnchor().GetAnchorId() ) + else if ( FLY_AS_CHAR == pFrmFmt->GetAnchor().GetAnchorId() ) { bIsGroupAllowed = false; } @@ -2619,7 +2619,7 @@ BOOL SwFEShell::IsAlignPossible() const SdrObject *pO = Imp()->GetDrawView()->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj(); SwDrawContact *pC = (SwDrawContact*)GetUserCall(pO); //only as character bound drawings can be aligned - bRet = pC->GetFmt()->GetAnchor().GetAnchorId() == FLY_IN_CNTNT; + bRet = (pC->GetFmt()->GetAnchor().GetAnchorId() == FLY_AS_CHAR); } if ( bRet ) return Imp()->GetDrawView()->IsAlignPossible(); @@ -2664,7 +2664,7 @@ void SwFEShell::CheckUnboundObjects() { pAnch = ::FindAnchor( pPage, aPt, TRUE ); SwPosition aPos( *((SwCntntFrm*)pAnch)->GetNode() ); - aAnch.SetType( FLY_AT_CNTNT ); + aAnch.SetType( FLY_AT_PARA ); aAnch.SetAnchor( &aPos ); ((SwRect&)GetCharRect()).Pos() = aPt; } diff --git a/sw/source/core/frmedt/fews.cxx b/sw/source/core/frmedt/fews.cxx index d82b1de4cfdb..9319cddcfd82 100644 --- a/sw/source/core/frmedt/fews.cxx +++ b/sw/source/core/frmedt/fews.cxx @@ -31,11 +31,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - #include -//#ifndef _SVDVMARK_HXX //autogen -//#include -//#endif #include #include #include @@ -71,8 +67,10 @@ // OD 2004-03-29 #i26791# #include + using namespace com::sun::star; + TYPEINIT1(SwFEShell,SwEditShell) /*********************************************************************** @@ -780,12 +778,12 @@ void SwFEShell::CalcBoundRect( SwRect& _orRect, BOOL bVertic = FALSE; BOOL bRTL = FALSE; - if( FLY_PAGE == _nAnchorId || FLY_AT_FLY == _nAnchorId ) // LAYER_IMPL + if ((FLY_AT_PAGE == _nAnchorId) || (FLY_AT_FLY == _nAnchorId)) // LAYER_IMPL { const SwFrm* pTmp = pFrm; // OD 06.11.2003 #i22305# - if ( FLY_PAGE == _nAnchorId || - ( FLY_AT_FLY == _nAnchorId && !_bFollowTextFlow ) ) + if ((FLY_AT_PAGE == _nAnchorId) || + ((FLY_AT_FLY == _nAnchorId) && !_bFollowTextFlow)) { pFrm = pPage; } @@ -906,7 +904,7 @@ void SwFEShell::CalcBoundRect( SwRect& _orRect, aPos = (pFrm->Frm().*fnRect->fnGetPos)(); // OD 08.09.2003 #i17567#, #108749#, #110354# - allow negative positions // for fly frames anchor to paragraph/to character. - if ( _nAnchorId == FLY_AT_CNTNT || _nAnchorId == FLY_AUTO_CNTNT ) + if ((_nAnchorId == FLY_AT_PARA) || (_nAnchorId == FLY_AT_CHAR)) { // The rectangle, the fly frame can be positioned in, is determined // horizontally by the frame area of the horizontal environment @@ -985,7 +983,7 @@ void SwFEShell::CalcBoundRect( SwRect& _orRect, // fly frame). Thus, assure this. const SwTxtFrm* pTxtFrm( dynamic_cast(pFrm) ); if ( pTxtFrm && - _nAnchorId == FLY_AUTO_CNTNT && + (_nAnchorId == FLY_AT_CHAR) && ( _eVertRelOrient == text::RelOrientation::CHAR || _eVertRelOrient == text::RelOrientation::TEXT_LINE ) ) { @@ -1032,7 +1030,7 @@ void SwFEShell::CalcBoundRect( SwRect& _orRect, // position ( respectively ), if object is // anchored to character and horizontal aligned at character. if ( pTxtFrm && - _nAnchorId == FLY_AUTO_CNTNT && + (_nAnchorId == FLY_AT_CHAR) && _eHoriRelOrient == text::RelOrientation::CHAR ) { SwTwips nLeft = 0L; diff --git a/sw/source/core/frmedt/tblsel.cxx b/sw/source/core/frmedt/tblsel.cxx index f971be8d79e4..a61f27e864b4 100644 --- a/sw/source/core/frmedt/tblsel.cxx +++ b/sw/source/core/frmedt/tblsel.cxx @@ -30,6 +30,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" + #include #include #include @@ -984,11 +985,11 @@ BOOL IsEmptyBox( const SwTableBox& rBox, SwPaM& rPam ) for( USHORT n = 0; n < rFmts.Count(); ++n ) { - const SwPosition* pAPos; const SwFmtAnchor& rAnchor = rFmts[n]->GetAnchor(); - if( ( FLY_AT_CNTNT == rAnchor.GetAnchorId() || - FLY_AUTO_CNTNT == rAnchor.GetAnchorId() ) && - 0 != ( pAPos = rAnchor.GetCntntAnchor() ) && + const SwPosition* pAPos = rAnchor.GetCntntAnchor(); + if (pAPos && + ((FLY_AT_PARA == rAnchor.GetAnchorId()) || + (FLY_AT_CHAR == rAnchor.GetAnchorId())) && nSttIdx <= ( nIdx = pAPos->nNode.GetIndex() ) && nIdx < nEndIdx ) { diff --git a/sw/source/core/inc/flyfrm.hxx b/sw/source/core/inc/flyfrm.hxx index dc8975f3fd47..61004c3816a5 100644 --- a/sw/source/core/inc/flyfrm.hxx +++ b/sw/source/core/inc/flyfrm.hxx @@ -109,10 +109,10 @@ protected: //(CheckClip) nur das Format aufgerufen wird; //nicht aber die Breite anhand der Attribute //wieder bestimmt wird. - BOOL bInCnt :1; // FLY_IN_CNTNT, als Zeichen verankert - BOOL bAtCnt :1; // FLY_AT_CNTNT, am Absatz verankert - BOOL bLayout :1; // FLY_PAGE, FLY_AT_FLY, an Seite oder Rahmen - BOOL bAutoPosition :1; // FLY_AUTO_CNTNT, im Text verankerter Rahmen + BOOL bInCnt :1; // FLY_AS_CHAR, anchored as character + BOOL bAtCnt :1; // FLY_AT_PARA, anchored at paragraph + BOOL bLayout :1; // FLY_AT_PAGE, FLY_AT_FLY, at page or at frame + BOOL bAutoPosition :1; // FLY_AT_CHAR, anchored at character BOOL bNoShrink :1; // temporary forbud of shrinking to avoid loops BOOL bLockDeleteContent :1; // If the flag is set, the content of the // fly frame is not deleted if moved to diff --git a/sw/source/core/layout/anchoreddrawobject.cxx b/sw/source/core/layout/anchoreddrawobject.cxx index 0976dcbefdc0..5a6be9f2e255 100644 --- a/sw/source/core/layout/anchoreddrawobject.cxx +++ b/sw/source/core/layout/anchoreddrawobject.cxx @@ -37,12 +37,8 @@ #include #include #include -#ifndef _TOCNTNTANCHOROBJECTPOSITION_HXX #include -#endif -#ifndef _TOLAYOUTANCHOROBJECTPOSITION_HXX #include -#endif #include #include // --> OD 2004-08-12 #i32795# @@ -357,7 +353,7 @@ void SwAnchoredDrawObject::MakeObjPos() // determine relative position of drawing object and set it switch ( pDrawContact->GetAnchorId() ) { - case FLY_IN_CNTNT: + case FLY_AS_CHAR: { // indicate that position will be valid after positioning is performed mbValidPos = true; @@ -365,15 +361,15 @@ void SwAnchoredDrawObject::MakeObjPos() // during the format of its anchor frame - see } break; - case FLY_AT_CNTNT: - case FLY_AUTO_CNTNT: + case FLY_AT_PARA: + case FLY_AT_CHAR: { // --> OD 2004-08-12 #i32795# - move intrinsic positioning to // helper method <_MakeObjPosAnchoredAtPara()> _MakeObjPosAnchoredAtPara(); } break; - case FLY_PAGE: + case FLY_AT_PAGE: case FLY_AT_FLY: { // --> OD 2004-08-12 #i32795# - move intrinsic positioning to @@ -603,7 +599,7 @@ void SwAnchoredDrawObject::_InvalidatePage( SwPageFrm* _pPageFrm ) { // --> OD 2004-11-11 #i35007# - correct invalidation for as-character // anchored objects. - if ( GetFrmFmt().GetAnchor().GetAnchorId() == FLY_IN_CNTNT ) + if ( GetFrmFmt().GetAnchor().GetAnchorId() == FLY_AS_CHAR ) { _pPageFrm->InvalidateFlyInCnt(); } @@ -645,7 +641,7 @@ void SwAnchoredDrawObject::InvalidateObjPos() // --> OD 2005-03-09 #i44559# - assure, that text hint is already // existing in the text frame if ( GetAnchorFrm()->ISA(SwTxtFrm) && - GetFrmFmt().GetAnchor().GetAnchorId() == FLY_IN_CNTNT ) + (GetFrmFmt().GetAnchor().GetAnchorId() == FLY_AS_CHAR) ) { SwTxtFrm* pAnchorTxtFrm( static_cast(AnchorFrm()) ); if ( pAnchorTxtFrm->GetTxtNode()->GetpSwpHints() && diff --git a/sw/source/core/layout/anchoredobject.cxx b/sw/source/core/layout/anchoredobject.cxx index 62048fbca378..67a072832eb1 100644 --- a/sw/source/core/layout/anchoredobject.cxx +++ b/sw/source/core/layout/anchoredobject.cxx @@ -306,7 +306,7 @@ void SwAnchoredObject::CheckCharRectAndTopOfLine( GetAnchorFrm()->IsTxtFrm() ) { const SwFmtAnchor& rAnch = GetFrmFmt().GetAnchor(); - if ( rAnch.GetAnchorId() == FLY_AUTO_CNTNT && + if ( (rAnch.GetAnchorId() == FLY_AT_CHAR) && rAnch.GetCntntAnchor() ) { // --> OD 2004-07-14 #117380# - if requested, assure that anchor frame, @@ -540,8 +540,8 @@ bool SwAnchoredObject::ConsiderObjWrapInfluenceOnObjPos() const // <-- { const SwFmtAnchor& rAnchor = rObjFmt.GetAnchor(); - if ( ( rAnchor.GetAnchorId() == FLY_AUTO_CNTNT || - rAnchor.GetAnchorId() == FLY_AT_CNTNT ) && + if ( ((rAnchor.GetAnchorId() == FLY_AT_CHAR) || + (rAnchor.GetAnchorId() == FLY_AT_PARA)) && rObjFmt.GetSurround().GetSurround() != SURROUND_THROUGHT ) { // --> OD 2004-09-23 #i34520# - text also wraps around anchored @@ -792,7 +792,7 @@ void SwAnchoredObject::UpdateObjInSortedList() AnchorFrm()->GetDrawObjs()->Update( *this ); // update its position in the sorted object list of its page frame // note: as-character anchored object aren't registered at a page frame - if ( GetFrmFmt().GetAnchor().GetAnchorId() != FLY_IN_CNTNT ) + if ( GetFrmFmt().GetAnchor().GetAnchorId() != FLY_AS_CHAR ) { GetPageFrm()->GetSortedObjs()->Update( *this ); } @@ -859,8 +859,8 @@ SwTxtFrm* SwAnchoredObject::FindAnchorCharFrm() if ( mpAnchorFrm ) { const SwFmtAnchor& rAnch = GetFrmFmt().GetAnchor(); - if ( rAnch.GetAnchorId() == FLY_AUTO_CNTNT || - rAnch.GetAnchorId() == FLY_IN_CNTNT ) + if ((rAnch.GetAnchorId() == FLY_AT_CHAR) || + (rAnch.GetAnchorId() == FLY_AS_CHAR)) { pAnchorCharFrm = &(static_cast(AnchorFrm())-> GetFrmAtOfst( rAnch.GetCntntAnchor()->nContent.GetIndex() )); diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx index 7601f4ae370d..bdef8a74bcf7 100644 --- a/sw/source/core/layout/atrfrm.cxx +++ b/sw/source/core/layout/atrfrm.cxx @@ -51,9 +51,7 @@ #include #include #include -#ifndef __SBX_SBXVARIABLE_HXX //autogen #include -#endif #include #include #include @@ -79,9 +77,7 @@ #include #include #include -#ifndef _FMTLINE_HXX #include -#endif #include #include #include @@ -110,18 +106,12 @@ #include #include -#ifndef _CMDID_H #include -#endif -#ifndef _UNOMID_H #include -#endif #ifndef _COMCORE_HRC #include #endif -#ifndef _SVX_SVUNDO_HXX #include // #111827# -#endif // OD 2004-05-24 #i28701# #include // --> OD 2006-03-06 #125892# @@ -1484,9 +1474,11 @@ void SwFmtAnchor::SetAnchor( const SwPosition *pPos ) delete pCntntAnchor; pCntntAnchor = pPos ? new SwPosition( *pPos ) : 0; //AM Absatz gebundene Flys sollten nie in den Absatz hineinzeigen. - if ( pCntntAnchor && ( FLY_AT_CNTNT == nAnchorId || - FLY_AT_FLY == nAnchorId )) + if (pCntntAnchor && + ((FLY_AT_PARA == nAnchorId) || (FLY_AT_FLY == nAnchorId))) + { pCntntAnchor->nContent.Assign( 0, 0 ); + } } SwFmtAnchor& SwFmtAnchor::operator=(const SwFmtAnchor& rAnchor) @@ -1543,14 +1535,23 @@ BOOL SwFmtAnchor::QueryValue( uno::Any& rVal, BYTE nMemberId ) const case MID_ANCHOR_ANCHORTYPE: text::TextContentAnchorType eRet; - switch((sal_Int16)GetAnchorId()) + switch (GetAnchorId()) { - case FLY_AUTO_CNTNT : eRet = text::TextContentAnchorType_AT_CHARACTER;break; - case FLY_PAGE : eRet = text::TextContentAnchorType_AT_PAGE; break; - case FLY_AT_FLY : eRet = text::TextContentAnchorType_AT_FRAME; break; - case FLY_IN_CNTNT : eRet = text::TextContentAnchorType_AS_CHARACTER;break; - //case FLY_AT_CNTNT : - default: eRet = text::TextContentAnchorType_AT_PARAGRAPH; + case FLY_AT_CHAR: + eRet = text::TextContentAnchorType_AT_CHARACTER; + break; + case FLY_AT_PAGE: + eRet = text::TextContentAnchorType_AT_PAGE; + break; + case FLY_AT_FLY: + eRet = text::TextContentAnchorType_AT_FRAME; + break; + case FLY_AS_CHAR: + eRet = text::TextContentAnchorType_AS_CHARACTER; + break; + //case FLY_AT_PARA: + default: + eRet = text::TextContentAnchorType_AT_PARAGRAPH; } rVal <<= eRet; break; @@ -1591,10 +1592,10 @@ BOOL SwFmtAnchor::PutValue( const uno::Any& rVal, BYTE nMemberId ) switch( SWUnoHelper::GetEnumAsInt32( rVal ) ) { case text::TextContentAnchorType_AS_CHARACTER: - eAnchor = FLY_IN_CNTNT; + eAnchor = FLY_AS_CHAR; break; case text::TextContentAnchorType_AT_PAGE: - eAnchor = FLY_PAGE; + eAnchor = FLY_AT_PAGE; if( GetPageNum() > 0 && pCntntAnchor ) { // If the anchor type is page and a valid page number @@ -1608,11 +1609,11 @@ BOOL SwFmtAnchor::PutValue( const uno::Any& rVal, BYTE nMemberId ) eAnchor = FLY_AT_FLY; break; case text::TextContentAnchorType_AT_CHARACTER: - eAnchor = FLY_AUTO_CNTNT; + eAnchor = FLY_AT_CHAR; break; //case text::TextContentAnchorType_AT_PARAGRAPH: default: - eAnchor = FLY_AT_CNTNT; + eAnchor = FLY_AT_PARA; break; } SetType( eAnchor ); @@ -1624,7 +1625,7 @@ BOOL SwFmtAnchor::PutValue( const uno::Any& rVal, BYTE nMemberId ) if((rVal >>= nVal) && nVal > 0) { SetPageNum( nVal ); - if( FLY_PAGE == GetAnchorId() && pCntntAnchor ) + if ((FLY_AT_PAGE == GetAnchorId()) && pCntntAnchor) { // If the anchor type is page and a valid page number // is set, the content paoition has to be deleted to not @@ -2597,7 +2598,7 @@ sal_Bool SwFrmFmt::IsLowerOf( const SwFrmFmt& rFmt ) const // dann mal ueber die Node-Positionen versuchen const SwFmtAnchor* pAnchor = &rFmt.GetAnchor(); - if( FLY_PAGE != pAnchor->GetAnchorId() && pAnchor->GetCntntAnchor() ) + if ((FLY_AT_PAGE != pAnchor->GetAnchorId()) && pAnchor->GetCntntAnchor()) { const SwSpzFrmFmts& rFmts = *GetDoc()->GetSpzFrmFmts(); const SwNode* pFlyNd = pAnchor->GetCntntAnchor()->nNode.GetNode(). @@ -2616,9 +2617,11 @@ sal_Bool SwFrmFmt::IsLowerOf( const SwFrmFmt& rFmt ) const return sal_True; pAnchor = &pFmt->GetAnchor(); - if( FLY_PAGE == pAnchor->GetAnchorId() || + if ((FLY_AT_PAGE == pAnchor->GetAnchorId()) || !pAnchor->GetCntntAnchor() ) + { return sal_False; + } pFlyNd = pAnchor->GetCntntAnchor()->nNode.GetNode(). FindFlyStartNode(); @@ -2702,11 +2705,13 @@ void SwFlyFrmFmt::MakeFrms() SwFmtAnchor aAnchorAttr( GetAnchor() ); switch( aAnchorAttr.GetAnchorId() ) { - case FLY_IN_CNTNT: - case FLY_AT_CNTNT: - case FLY_AUTO_CNTNT: + case FLY_AS_CHAR: + case FLY_AT_PARA: + case FLY_AT_CHAR: if( aAnchorAttr.GetCntntAnchor() ) + { pModify = aAnchorAttr.GetCntntAnchor()->nNode.GetNode().GetCntntNode(); + } break; case FLY_AT_FLY: @@ -2739,7 +2744,7 @@ void SwFlyFrmFmt::MakeFrms() } break; - case FLY_PAGE: + case FLY_AT_PAGE: { sal_uInt16 nPgNum = aAnchorAttr.GetPageNum(); SwPageFrm *pPage = (SwPageFrm*)GetDoc()->GetRootFrm()->Lower(); @@ -2822,12 +2827,12 @@ void SwFlyFrmFmt::MakeFrms() pFly = new SwFlyLayFrm( this, pFrm ); break; - case FLY_AT_CNTNT: - case FLY_AUTO_CNTNT: + case FLY_AT_PARA: + case FLY_AT_CHAR: pFly = new SwFlyAtCntFrm( this, pFrm ); break; - case FLY_IN_CNTNT: + case FLY_AS_CHAR: pFly = new SwFlyInCntFrm( this, pFrm ); break; default: @@ -3026,8 +3031,8 @@ SwHandleAnchorNodeChg::SwHandleAnchorNodeChg( SwFlyFrmFmt& _rFlyFrmFmt, mbAnchorNodeChanged( false ) { const RndStdIds nNewAnchorType( _rNewAnchorFmt.GetAnchorId() ); - if ( ( nNewAnchorType == FLY_AT_CNTNT || - nNewAnchorType == FLY_AUTO_CNTNT ) && + if ( ((nNewAnchorType == FLY_AT_PARA) || + (nNewAnchorType == FLY_AT_CHAR)) && _rNewAnchorFmt.GetCntntAnchor() && _rNewAnchorFmt.GetCntntAnchor()->nNode.GetNode().GetCntntNode() ) { diff --git a/sw/source/core/layout/calcmove.cxx b/sw/source/core/layout/calcmove.cxx index b24ee7fd78b1..442a0fe38c57 100644 --- a/sw/source/core/layout/calcmove.cxx +++ b/sw/source/core/layout/calcmove.cxx @@ -46,9 +46,7 @@ #include #include -#ifndef _OUTDEV_HXX //autogen #include -#endif #include #include #include @@ -1014,10 +1012,12 @@ BOOL SwCntntFrm::MakePrtArea( const SwBorderAttrs &rAttrs ) rFmt.GetFrmSize().GetWidthPercent() ) continue; - if ( FLY_IN_CNTNT == rFmt.GetAnchor().GetAnchorId() ) + if ( FLY_AS_CHAR == rFmt.GetAnchor().GetAnchorId() ) + { nMinWidth = Max( nMinWidth, bFly ? rFmt.GetFrmSize().GetWidth() : pObj->GetObjRect().Width() ); + } // <-- } diff --git a/sw/source/core/layout/flowfrm.cxx b/sw/source/core/layout/flowfrm.cxx index 108dadf23ec8..0be59dbbeca1 100644 --- a/sw/source/core/layout/flowfrm.cxx +++ b/sw/source/core/layout/flowfrm.cxx @@ -366,7 +366,7 @@ BYTE SwFlowFrm::BwdMoveNecessary( const SwPageFrm *pPage, const SwRect &rRect ) //denn dann weiche ich ihm nicht aus. if ( ::IsFrmInSameKontext( pAnchor, &rThis ) ) { - if ( rFmt.GetAnchor().GetAnchorId() == FLY_AT_CNTNT ) + if ( rFmt.GetAnchor().GetAnchorId() == FLY_AT_PARA ) { // Den Index des anderen erhalten wir immer ueber das Ankerattr. ULONG nTmpIndex = rFmt.GetAnchor().GetCntntAnchor()->nNode.GetIndex(); diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx index 9ce3bc237db4..983c3a2b055e 100644 --- a/sw/source/core/layout/fly.cxx +++ b/sw/source/core/layout/fly.cxx @@ -33,9 +33,7 @@ #include "hintids.hxx" #include #include -#ifndef _GRAPH_HXX //autogen #include -#endif #include #include #include @@ -1182,7 +1180,7 @@ void SwFlyFrm::ChgRelPos( const Point &rNewPos ) // --> OD 2004-11-12 #i34948# - handle also at-page and at-fly anchored // Writer fly frames const RndStdIds eAnchorType = GetFrmFmt().GetAnchor().GetAnchorId(); - if ( eAnchorType == FLY_PAGE ) + if ( eAnchorType == FLY_AT_PAGE ) { aVert.SetVertOrient( text::VertOrientation::NONE ); aVert.SetRelationOrient( text::RelOrientation::PAGE_FRAME ); @@ -1235,7 +1233,7 @@ void SwFlyFrm::ChgRelPos( const Point &rNewPos ) SwFmtHoriOrient aHori( pFmt->GetHoriOrient() ); // --> OD 2004-11-12 #i34948# - handle also at-page and at-fly anchored // Writer fly frames - if ( eAnchorType == FLY_PAGE ) + if ( eAnchorType == FLY_AT_PAGE ) { aHori.SetHoriOrient( text::HoriOrientation::NONE ); aHori.SetRelationOrient( text::RelOrientation::PAGE_FRAME ); @@ -1645,11 +1643,17 @@ void CalcCntnt( SwLayoutFrm *pLay, { // Bei autopositionierten hilft manchmal nur // noch, auf Durchlauf zu schalten - if( rFmt.GetAnchor().GetAnchorId() == FLY_AUTO_CNTNT && - SURROUND_PARALLEL == aAttr.GetSurround() ) + if ((rFmt.GetAnchor().GetAnchorId() == + FLY_AT_CHAR) && + (SURROUND_PARALLEL == + aAttr.GetSurround())) + { aAttr.SetSurround( SURROUND_THROUGHT ); + } else + { aAttr.SetSurround( SURROUND_PARALLEL ); + } rFmt.LockModify(); rFmt.SetFmtAttr( aAttr ); rFmt.UnlockModify(); @@ -2313,7 +2317,8 @@ void SwFrm::InvalidateObjs( const bool _bInvaPosOnly, { SwAnchoredObject* pAnchoredObj = (*GetDrawObjs())[i]; if ( _bNoInvaOfAsCharAnchoredObjs && - pAnchoredObj->GetFrmFmt().GetAnchor().GetAnchorId() == FLY_IN_CNTNT ) + (pAnchoredObj->GetFrmFmt().GetAnchor().GetAnchorId() + == FLY_AS_CHAR) ) { continue; } diff --git a/sw/source/core/layout/flycnt.cxx b/sw/source/core/layout/flycnt.cxx index 41d0e97ec6d6..90017ee4884e 100644 --- a/sw/source/core/layout/flycnt.cxx +++ b/sw/source/core/layout/flycnt.cxx @@ -90,7 +90,7 @@ SwFlyAtCntFrm::SwFlyAtCntFrm( SwFlyFrmFmt *pFmt, SwFrm *pAnch ) : SwFlyFreeFrm( pFmt, pAnch ) { bAtCnt = TRUE; - bAutoPosition = FLY_AUTO_CNTNT == pFmt->GetAnchor().GetAnchorId(); + bAutoPosition = (FLY_AT_CHAR == pFmt->GetAnchor().GetAnchorId()); } // --> OD 2004-06-29 #i28701# diff --git a/sw/source/core/layout/flylay.cxx b/sw/source/core/layout/flylay.cxx index 252ea3298531..b68335451178 100644 --- a/sw/source/core/layout/flylay.cxx +++ b/sw/source/core/layout/flylay.cxx @@ -600,7 +600,7 @@ void SwFlyLayFrm::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew ) SwPageFrm *pOldPage = GetPageFrm(); AnchorFrm()->RemoveFly( this ); - if( FLY_PAGE == pAnch->GetAnchorId() ) + if ( FLY_AT_PAGE == pAnch->GetAnchorId() ) { USHORT nPgNum = pAnch->GetPageNum(); SwRootFrm *pRoot = FindRootFrm(); @@ -955,7 +955,7 @@ void SwPageFrm::AppendDrawObjToPage( SwAnchoredObject& _rNewObj ) _rNewObj.DrawObj()->SetOrdNum( nNewNum ); } - if ( FLY_IN_CNTNT == _rNewObj.GetFrmFmt().GetAnchor().GetAnchorId() ) + if ( FLY_AS_CHAR == _rNewObj.GetFrmFmt().GetAnchor().GetAnchorId() ) { return; } @@ -999,7 +999,8 @@ void SwPageFrm::RemoveDrawObjFromPage( SwAnchoredObject& _rToRemoveObj ) } if ( GetUpper() ) { - if ( FLY_IN_CNTNT != _rToRemoveObj.GetFrmFmt().GetAnchor().GetAnchorId() ) + if (FLY_AS_CHAR != + _rToRemoveObj.GetFrmFmt().GetAnchor().GetAnchorId()) { ((SwRootFrm*)GetUpper())->SetSuperfluous(); InvalidatePage(); @@ -1333,7 +1334,7 @@ BOOL CalcClipRect( const SdrObject *pSdrObj, SwRect &rRect, BOOL bMove ) const SwDrawContact *pC = (const SwDrawContact*)GetUserCall(pSdrObj); const SwFrmFmt *pFmt = (const SwFrmFmt*)pC->GetFmt(); const SwFmtAnchor &rAnch = pFmt->GetAnchor(); - if ( FLY_IN_CNTNT == rAnch.GetAnchorId() ) + if ( FLY_AS_CHAR == rAnch.GetAnchorId() ) { const SwFrm* pAnchorFrm = pC->GetAnchorFrm( pSdrObj ); if( !pAnchorFrm ) diff --git a/sw/source/core/layout/flypos.cxx b/sw/source/core/layout/flypos.cxx index 333de7f3ff97..cb566792ca83 100644 --- a/sw/source/core/layout/flypos.cxx +++ b/sw/source/core/layout/flypos.cxx @@ -57,8 +57,10 @@ SwPosFlyFrm::SwPosFlyFrm( const SwNodeIndex& rIdx, const SwFrmFmt* pFmt, { BOOL bFnd = FALSE; const SwFmtAnchor& rAnchor = pFmt->GetAnchor(); - if( FLY_PAGE == rAnchor.GetAnchorId() ) + if (FLY_AT_PAGE == rAnchor.GetAnchorId()) + { pNdIdx = new SwNodeIndex( rIdx ); + } else if( pFmt->GetDoc()->GetRootFrm() ) { SwClientIter aIter( (SwFmt&)*pFmt ); @@ -88,8 +90,10 @@ SwPosFlyFrm::SwPosFlyFrm( const SwNodeIndex& rIdx, const SwFrmFmt* pFmt, SwPosFlyFrm::~SwPosFlyFrm() { const SwFmtAnchor& rAnchor = pFrmFmt->GetAnchor(); - if( FLY_PAGE == rAnchor.GetAnchorId() ) + if (FLY_AT_PAGE == rAnchor.GetAnchorId()) + { delete pNdIdx; + } } BOOL SwPosFlyFrm::operator==( const SwPosFlyFrm& ) diff --git a/sw/source/core/layout/frmtool.cxx b/sw/source/core/layout/frmtool.cxx index f7fa2a0a8e80..f3ac0f966c67 100644 --- a/sw/source/core/layout/frmtool.cxx +++ b/sw/source/core/layout/frmtool.cxx @@ -1033,9 +1033,11 @@ SwCntntNotify::~SwCntntNotify() SwFrmFmt *pFmt = (*pTbl)[i]; const SwFmtAnchor &rAnch = pFmt->GetAnchor(); - if ( FLY_PAGE != rAnch.GetAnchorId() && - FLY_AT_CNTNT != rAnch.GetAnchorId() ) + if ((FLY_AT_PAGE != rAnch.GetAnchorId()) && + (FLY_AT_PARA != rAnch.GetAnchorId())) + { continue; //#60878# nicht etwa zeichengebundene. + } BOOL bCheckPos = FALSE; if ( rAnch.GetCntntAnchor() ) @@ -1047,7 +1049,7 @@ SwCntntNotify::~SwCntntNotify() if ( rAnch.GetCntntAnchor()->nNode == *pIdx ) { bCheckPos = TRUE; - if ( FLY_PAGE == rAnch.GetAnchorId() ) + if (FLY_AT_PAGE == rAnch.GetAnchorId()) { ASSERT( false, " - to page anchored object with content position. Please inform OD." ); SwFmtAnchor aAnch( rAnch ); @@ -1097,7 +1099,7 @@ SwCntntNotify::~SwCntntNotify() { SwAnchoredObject* pAnchoredObj = (*pObjs)[i]; if ( pAnchoredObj->GetFrmFmt().GetAnchor().GetAnchorId() - == FLY_AUTO_CNTNT ) + == FLY_AT_CHAR ) { pAnchoredObj->CheckCharRectAndTopOfLine( !pMasterFrm->IsEmpty() ); } @@ -1135,11 +1137,11 @@ void AppendObjs( const SwSpzFrmFmts *pTbl, ULONG nIndex, // OD 23.06.2003 #108784# - append also drawing objects anchored // as character. const bool bDrawObjInCntnt = bSdrObj && - rAnch.GetAnchorId() == FLY_IN_CNTNT; + (rAnch.GetAnchorId() == FLY_AS_CHAR); if( bFlyAtFly || - rAnch.GetAnchorId() == FLY_AT_CNTNT || - rAnch.GetAnchorId() == FLY_AUTO_CNTNT || + (rAnch.GetAnchorId() == FLY_AT_PARA) || + (rAnch.GetAnchorId() == FLY_AT_CHAR) || bDrawObjInCntnt ) { SdrObject* pSdrObj = 0; @@ -1227,7 +1229,7 @@ bool lcl_InHeaderOrFooter( SwFrmFmt& _rFmt ) const SwFmtAnchor& rAnch = _rFmt.GetAnchor(); - if ( rAnch.GetAnchorId() != FLY_PAGE ) + if (rAnch.GetAnchorId() != FLY_AT_PAGE) { bRetVal = _rFmt.GetDoc()->IsInHeaderFooter( rAnch.GetCntntAnchor()->nNode ); } @@ -1256,10 +1258,13 @@ void AppendAllObjs( const SwSpzFrmFmts *pTbl ) SwFrmFmt *pFmt = (SwFrmFmt*)aCpy[ USHORT(i) ]; const SwFmtAnchor &rAnch = pFmt->GetAnchor(); BOOL bRemove = FALSE; - if ( rAnch.GetAnchorId() == FLY_PAGE || rAnch.GetAnchorId() == FLY_IN_CNTNT ) + if ((rAnch.GetAnchorId() == FLY_AT_PAGE) || + (rAnch.GetAnchorId() == FLY_AS_CHAR)) + { //Seitengebunde sind bereits verankert, zeichengebundene //will ich hier nicht. bRemove = TRUE; + } else if ( FALSE == (bRemove = ::lcl_ObjConnected( pFmt )) || ::lcl_InHeaderOrFooter( *pFmt ) ) { @@ -2578,7 +2583,7 @@ void MA_FASTCALL lcl_RemoveObjsFromPage( SwFrm* _pFrm ) // --> OD 2004-11-29 #115759# - remove also drawing objects from page else if ( pObj->ISA(SwAnchoredDrawObject) ) { - if ( pObj->GetFrmFmt().GetAnchor().GetAnchorId() != FLY_IN_CNTNT ) + if (pObj->GetFrmFmt().GetAnchor().GetAnchorId() != FLY_AS_CHAR) { pObj->GetPageFrm()->RemoveDrawObjFromPage( *(static_cast(pObj)) ); @@ -2746,7 +2751,7 @@ void MA_FASTCALL lcl_AddObjsToPage( SwFrm* _pFrm, SwPageFrm* _pPage ) // --> OD 2004-11-29 #115759# - remove also drawing objects from page else if ( pObj->ISA(SwAnchoredDrawObject) ) { - if ( pObj->GetFrmFmt().GetAnchor().GetAnchorId() != FLY_IN_CNTNT ) + if (pObj->GetFrmFmt().GetAnchor().GetAnchorId() != FLY_AS_CHAR) { pObj->InvalidateObjPos(); _pPage->AppendDrawObjToPage( diff --git a/sw/source/core/layout/laycache.cxx b/sw/source/core/layout/laycache.cxx index 56995fcfcb26..999b8a1a6e77 100644 --- a/sw/source/core/layout/laycache.cxx +++ b/sw/source/core/layout/laycache.cxx @@ -63,17 +63,16 @@ #include // --> OD 2006-03-22 #b6375613# #include -#ifndef _DOCSH_HXX #include -#endif #include #include +#include + + using namespace ::com::sun::star; // <-- -#include - SV_IMPL_PTRARR( SwPageFlyCache, SwFlyCachePtr ) /*-----------------28.5.2001 10:06------------------ @@ -696,8 +695,8 @@ bool lcl_HasTextFrmAnchoredObjs( SwTxtFrm* p_pTxtFrm ) SwFrmFmt *pFmt = (SwFrmFmt*)(*pSpzFrmFmts)[i]; const SwFmtAnchor &rAnch = pFmt->GetAnchor(); if ( rAnch.GetCntntAnchor() && - ( rAnch.GetAnchorId() == FLY_AT_CNTNT || - rAnch.GetAnchorId() == FLY_AUTO_CNTNT ) && + ((rAnch.GetAnchorId() == FLY_AT_PARA) || + (rAnch.GetAnchorId() == FLY_AT_CHAR)) && rAnch.GetCntntAnchor()->nNode.GetIndex() == p_pTxtFrm->GetTxtNode()->GetIndex() ) { diff --git a/sw/source/core/layout/objectformatter.cxx b/sw/source/core/layout/objectformatter.cxx index b8d45b719014..0b98bc03f4cd 100644 --- a/sw/source/core/layout/objectformatter.cxx +++ b/sw/source/core/layout/objectformatter.cxx @@ -338,7 +338,7 @@ void SwObjectFormatter::_FormatObj( SwAnchoredObject& _rAnchoredObj ) // check, if only as-character anchored object have to be formatted, and // check the anchor type if ( FormatOnlyAsCharAnchored() && - !_rAnchoredObj.GetFrmFmt().GetAnchor().GetAnchorId() == FLY_IN_CNTNT ) + !(_rAnchoredObj.GetFrmFmt().GetAnchor().GetAnchorId() == FLY_AS_CHAR) ) { return; } diff --git a/sw/source/core/layout/objectformattertxtfrm.cxx b/sw/source/core/layout/objectformattertxtfrm.cxx index 697bea11dabf..2d7c2b02fb39 100644 --- a/sw/source/core/layout/objectformattertxtfrm.cxx +++ b/sw/source/core/layout/objectformattertxtfrm.cxx @@ -136,7 +136,7 @@ bool SwObjectFormatterTxtFrm::DoFormatObj( SwAnchoredObject& _rAnchoredObj, // check, if only as-character anchored object have to be formatted, and // check the anchor type if ( FormatOnlyAsCharAnchored() && - !_rAnchoredObj.GetFrmFmt().GetAnchor().GetAnchorId() == FLY_IN_CNTNT ) + !(_rAnchoredObj.GetFrmFmt().GetAnchor().GetAnchorId() == FLY_AS_CHAR) ) { return true; } @@ -656,8 +656,8 @@ bool SwObjectFormatterTxtFrm::CheckMovedFwdCondition( // which will be on the next page. if ( !bAnchorIsMovedForward && _bAnchoredAtMasterBeforeFormatAnchor && - ( _rAnchoredObj.GetFrmFmt().GetAnchor().GetAnchorId() == FLY_AUTO_CNTNT || - _rAnchoredObj.GetFrmFmt().GetAnchor().GetAnchorId() == FLY_AT_CNTNT ) ) + ((_rAnchoredObj.GetFrmFmt().GetAnchor().GetAnchorId() == FLY_AT_CHAR) || + (_rAnchoredObj.GetFrmFmt().GetAnchor().GetAnchorId() == FLY_AT_PARA))) { SwFrm* pAnchorFrm = _rAnchoredObj.GetAnchorFrmContainingAnchPos(); ASSERT( pAnchorFrm->IsTxtFrm(), diff --git a/sw/source/core/layout/pagechg.cxx b/sw/source/core/layout/pagechg.cxx index b73f8b4d1eeb..ef80288b9349 100644 --- a/sw/source/core/layout/pagechg.cxx +++ b/sw/source/core/layout/pagechg.cxx @@ -46,9 +46,7 @@ #include #include #include -#ifndef _DOCSH_HXX #include -#endif #include "viewimp.hxx" #include "pagefrm.hxx" @@ -408,7 +406,7 @@ void MA_FASTCALL lcl_MakeObjs( const SwSpzFrmFmts &rTbl, SwPageFrm *pPage ) { if( rAnch.GetCntntAnchor() ) { - if( FLY_PAGE == rAnch.GetAnchorId() ) + if (FLY_AT_PAGE == rAnch.GetAnchorId()) { SwFmtAnchor aAnch( rAnch ); aAnch.SetAnchor( 0 ); @@ -1659,7 +1657,7 @@ void SwRootFrm::AssertPageFlys( SwPageFrm *pPage ) SwFrmFmt& rFmt = (*pPage->GetSortedObjs())[i]->GetFrmFmt(); const SwFmtAnchor &rAnch = rFmt.GetAnchor(); const USHORT nPg = rAnch.GetPageNum(); - if ( rAnch.GetAnchorId() == FLY_PAGE && + if ((rAnch.GetAnchorId() == FLY_AT_PAGE) && nPg != pPage->GetPhyPageNum() ) { //Das er auf der falschen Seite steht muss noch nichts @@ -1834,11 +1832,11 @@ void SwRootFrm::ImplCalcBrowseWidth() long nWidth = 0; switch ( rFmt.GetAnchor().GetAnchorId() ) { - case FLY_IN_CNTNT: + case FLY_AS_CHAR: nWidth = bFly ? rFmt.GetFrmSize().GetWidth() : pAnchoredObj->GetObjRect().Width(); break; - case FLY_AT_CNTNT: + case FLY_AT_PARA: { // --> FME 2004-09-13 #i33170# // Reactivated old code because @@ -2007,7 +2005,7 @@ void lcl_MoveAllLowerObjs( SwFrm* pFrm, const Point& rOffset ) // all except from the as character anchored objects are moved // when processing the page frame: - const bool bAsChar = rAnchor.GetAnchorId() == FLY_IN_CNTNT; + const bool bAsChar = (rAnchor.GetAnchorId() == FLY_AS_CHAR); if ( !bPage && !bAsChar ) continue; diff --git a/sw/source/core/layout/sortedobjsimpl.cxx b/sw/source/core/layout/sortedobjsimpl.cxx index 96d3c73e8e3b..8afa7968b5f0 100644 --- a/sw/source/core/layout/sortedobjsimpl.cxx +++ b/sw/source/core/layout/sortedobjsimpl.cxx @@ -41,17 +41,14 @@ #include #include #include -#ifndef IDOCUMENTDRAWMODELACCESS_HXX_INCLUDED #include -#endif + using namespace ::com::sun::star; typedef std::vector< SwAnchoredObject* >::iterator tIter; typedef std::vector< SwAnchoredObject* >::const_iterator tConstIter; -using namespace ::com::sun::star; - SwSortedObjsImpl::SwSortedObjsImpl() { @@ -96,36 +93,36 @@ struct ObjAnchorOrder const SwFmtAnchor* pAnchorNew = &(rFmtNew.GetAnchor()); // check for to-page anchored objects - if ( pAnchorListed->GetAnchorId() == FLY_PAGE && - pAnchorNew->GetAnchorId() != FLY_PAGE ) + if ((pAnchorListed->GetAnchorId() == FLY_AT_PAGE) && + (pAnchorNew ->GetAnchorId() != FLY_AT_PAGE)) { return true; } - else if ( pAnchorListed->GetAnchorId() != FLY_PAGE && - pAnchorNew->GetAnchorId() == FLY_PAGE ) + else if ((pAnchorListed->GetAnchorId() != FLY_AT_PAGE) && + (pAnchorNew ->GetAnchorId() == FLY_AT_PAGE)) { return false; } - else if ( pAnchorListed->GetAnchorId() == FLY_PAGE && - pAnchorNew->GetAnchorId() == FLY_PAGE ) + else if ((pAnchorListed->GetAnchorId() == FLY_AT_PAGE) && + (pAnchorNew ->GetAnchorId() == FLY_AT_PAGE)) { return pAnchorListed->GetOrder() < pAnchorNew->GetOrder(); } // Both objects aren't anchored to page. // Thus, check for to-fly anchored objects - if ( pAnchorListed->GetAnchorId() == FLY_AT_FLY && - pAnchorNew->GetAnchorId() != FLY_AT_FLY ) + if ((pAnchorListed->GetAnchorId() == FLY_AT_FLY) && + (pAnchorNew ->GetAnchorId() != FLY_AT_FLY)) { return true; } - else if ( pAnchorListed->GetAnchorId() != FLY_AT_FLY && - pAnchorNew->GetAnchorId() == FLY_AT_FLY ) + else if ((pAnchorListed->GetAnchorId() != FLY_AT_FLY) && + (pAnchorNew ->GetAnchorId() == FLY_AT_FLY)) { return false; } - else if ( pAnchorListed->GetAnchorId() == FLY_AT_FLY && - pAnchorNew->GetAnchorId() == FLY_AT_FLY ) + else if ((pAnchorListed->GetAnchorId() == FLY_AT_FLY) && + (pAnchorNew ->GetAnchorId() == FLY_AT_FLY)) { return pAnchorListed->GetOrder() < pAnchorNew->GetOrder(); } @@ -144,21 +141,21 @@ struct ObjAnchorOrder // --> OD 2006-11-29 #???# - objects have to be ordered by anchor node position // Thus, compare content anchor node positions and anchor type, // if not anchored at-paragraph - if ( pAnchorListed->GetAnchorId() != FLY_AT_CNTNT && - pAnchorNew->GetAnchorId() != FLY_AT_CNTNT && + if ((pAnchorListed->GetAnchorId() != FLY_AT_PARA) && + (pAnchorNew ->GetAnchorId() != FLY_AT_PARA) && pCntntAnchorListed && pCntntAnchorNew ) { if ( pCntntAnchorListed->nContent != pCntntAnchorNew->nContent ) { return pCntntAnchorListed->nContent < pCntntAnchorNew->nContent; } - else if ( pAnchorListed->GetAnchorId() == FLY_AUTO_CNTNT && - pAnchorNew->GetAnchorId() == FLY_IN_CNTNT ) + else if ((pAnchorListed->GetAnchorId() == FLY_AT_CHAR) && + (pAnchorNew ->GetAnchorId() == FLY_AS_CHAR)) { return true; } - else if ( pAnchorListed->GetAnchorId() == FLY_IN_CNTNT && - pAnchorNew->GetAnchorId() == FLY_AUTO_CNTNT ) + else if ((pAnchorListed->GetAnchorId() == FLY_AS_CHAR) && + (pAnchorNew ->GetAnchorId() == FLY_AT_CHAR)) { return false; } diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx index f2a507bbd764..3605e3899706 100644 --- a/sw/source/core/layout/tabfrm.cxx +++ b/sw/source/core/layout/tabfrm.cxx @@ -57,9 +57,7 @@ // --> collapsing borders FME 2005-05-27 #i29550# #include // <-- -#ifndef _OUTDEV_HXX //autogen #include -#endif #include #include #include @@ -340,7 +338,7 @@ void lcl_InvalidateLowerObjs( SwLayoutFrm& _rLayoutFrm, pAnchoredObj->ClearCharRectAndTopOfLine(); pAnchoredObj->SetCurrRelPos( Point( 0, 0 ) ); if ( pAnchoredObj->GetFrmFmt().GetAnchor().GetAnchorId() - == FLY_IN_CNTNT ) + == FLY_AS_CHAR ) { pAnchoredObj->AnchorFrm() ->Prepare( PREP_FLY_ATTR_CHG, @@ -4194,7 +4192,7 @@ long MA_FASTCALL CalcHeightWidthFlys( const SwFrm *pFrm ) // the text flow have to be considered. const SwFrmFmt& rFrmFmt = pAnchoredObj->GetFrmFmt(); const bool bConsiderObj = - rFrmFmt.GetAnchor().GetAnchorId() != FLY_IN_CNTNT && + (rFrmFmt.GetAnchor().GetAnchorId() != FLY_AS_CHAR) && pAnchoredObj->GetObjRect().Top() != WEIT_WECH && rFrmFmt.GetFollowTextFlow().GetValue() && pAnchoredObj->GetPageFrm() == pTmp->FindPageFrm(); @@ -5222,7 +5220,7 @@ BOOL lcl_ArrangeLowers( SwLayoutFrm *pLay, long lYStart, BOOL bInva ) !( pTabFrm->IsFollow() && pTabFrm->FindMaster()->IsRebuildLastLine() ) && !pAnchoredObj->GetFrmFmt().GetAnchor().GetAnchorId() - == FLY_IN_CNTNT ) + == FLY_AS_CHAR ) { SwPageFrm* pPageFrm = pAnchoredObj->GetPageFrm(); SwPageFrm* pPageOfAnchor = pFrm->FindPageFrm(); diff --git a/sw/source/core/layout/wsfrm.cxx b/sw/source/core/layout/wsfrm.cxx index af97063da6e3..4bca9ba61c5c 100644 --- a/sw/source/core/layout/wsfrm.cxx +++ b/sw/source/core/layout/wsfrm.cxx @@ -35,9 +35,7 @@ #include #include #include -#ifndef _OUTDEV_HXX #include -#endif #include #include #include @@ -52,9 +50,7 @@ #include #include #include -#ifndef _DOCSH_HXX #include -#endif #include #include #include @@ -81,8 +77,10 @@ // OD 2004-05-24 #i28701# #include + using namespace ::com::sun::star; + /************************************************************************* |* |* SwFrm::SwFrm() @@ -3999,8 +3997,8 @@ void SwRootFrm::InvalidateAllObjPos() { SwAnchoredObject* pAnchoredObj = rObjs[i]; const SwFmtAnchor& rAnch = pAnchoredObj->GetFrmFmt().GetAnchor(); - if ( rAnch.GetAnchorId() != FLY_AT_CNTNT && - rAnch.GetAnchorId() != FLY_AUTO_CNTNT ) + if ((rAnch.GetAnchorId() != FLY_AT_PARA) && + (rAnch.GetAnchorId() != FLY_AT_CHAR)) { // only to paragraph and to character anchored objects are considered. continue; diff --git a/sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx b/sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx index 800235bf95e5..90a64c335e6f 100644 --- a/sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx +++ b/sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx @@ -47,13 +47,9 @@ #include #include #include -#ifndef _SVX_SVDOBJ_HXX #include -#endif #include -#ifndef _ENVIRONMENTOFANCHOREDOBJECT #include -#endif #include #include #include @@ -209,7 +205,7 @@ void SwToCntntAnchoredObjectPosition::CalcPosition() { // if object is at-character anchored, determine character-rectangle // and frame, position has to be oriented at. - mbAnchorToChar = FLY_AUTO_CNTNT == rFrmFmt.GetAnchor().GetAnchorId(); + mbAnchorToChar = (FLY_AT_CHAR == rFrmFmt.GetAnchor().GetAnchorId()); if ( mbAnchorToChar ) { const SwFmtAnchor& rAnch = rFrmFmt.GetAnchor(); diff --git a/sw/source/core/text/EnhancedPDFExportHelper.cxx b/sw/source/core/text/EnhancedPDFExportHelper.cxx index 1784ad946e41..09758fe6e6c2 100644 --- a/sw/source/core/text/EnhancedPDFExportHelper.cxx +++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx @@ -31,15 +31,11 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" #include -#ifndef _COM_SUN_STAR_I18N_SCRIPTTYPE_HDL_ #include -#endif #include #include -#ifndef _OUTDEV_HXX #include -#endif #include #include #include @@ -370,9 +366,9 @@ bool SwTaggedPDFHelper::CheckReopenTag() { const SwFmtAnchor& rAnchor = static_cast(&rFrm)->GetFmt()->GetAnchor(); - if ( FLY_AT_CNTNT == rAnchor.GetAnchorId() || - FLY_AUTO_CNTNT == rAnchor.GetAnchorId() || - FLY_PAGE == rAnchor.GetAnchorId() ) + if ((FLY_AT_PARA == rAnchor.GetAnchorId()) || + (FLY_AT_CHAR == rAnchor.GetAnchorId()) || + (FLY_AT_PAGE == rAnchor.GetAnchorId())) { pKeyFrm = static_cast(rFrm).GetAnchorFrm(); bContinue = true; @@ -1814,7 +1810,7 @@ void SwEnhancedPDFExportHelper::EnhancedPDFExport() // --> FME 2005-05-09 #i44368# Links in Header/Footer const SwFmtAnchor &rAnch = pFrmFmt->GetAnchor(); - if ( FLY_PAGE != rAnch.GetAnchorId() ) + if (FLY_AT_PAGE != rAnch.GetAnchorId()) { const SwPosition* pPosition = rAnch.GetCntntAnchor(); if ( pPosition && pDoc->IsInHeaderFooter( pPosition->nNode ) ) diff --git a/sw/source/core/text/itratr.cxx b/sw/source/core/text/itratr.cxx index bd51317f77fe..318f6770bf97 100644 --- a/sw/source/core/text/itratr.cxx +++ b/sw/source/core/text/itratr.cxx @@ -461,10 +461,8 @@ sal_Bool lcl_MinMaxNode( const SwFrmFmtPtr& rpNd, void* pArgs ) const SwFmtAnchor& rFmtA = ((SwFrmFmt*)rpNd)->GetAnchor(); bool bCalculate = false; - if ( - (FLY_AT_CNTNT == rFmtA.GetAnchorId()) || - (FLY_AUTO_CNTNT == rFmtA.GetAnchorId()) - ) + if ((FLY_AT_PARA == rFmtA.GetAnchorId()) || + (FLY_AT_CHAR == rFmtA.GetAnchorId())) { bCalculate = true; } diff --git a/sw/source/core/text/porfly.cxx b/sw/source/core/text/porfly.cxx index 55c905b7e679..105a1488cb06 100644 --- a/sw/source/core/text/porfly.cxx +++ b/sw/source/core/text/porfly.cxx @@ -39,9 +39,7 @@ #include "frmfmt.hxx" // SwFrmFmt #include "viewsh.hxx" -#ifndef _OUTDEV_HXX //autogen #include -#endif #include #include #include @@ -57,6 +55,7 @@ // OD 2004-05-24 #i28701# #include + /************************************************************************* * class SwFlyPortion * @@ -178,7 +177,7 @@ void SwTxtFrm::MoveFlyInCnt( SwTxtFrm *pNew, xub_StrLen nStart, xub_StrLen nEnd // entries SwAnchoredObject* pAnchoredObj = (*pObjs)[i]; const SwFmtAnchor& rAnch = pAnchoredObj->GetFrmFmt().GetAnchor(); - if ( rAnch.GetAnchorId() == FLY_IN_CNTNT ) + if (rAnch.GetAnchorId() == FLY_AS_CHAR) { const SwPosition* pPos = rAnch.GetCntntAnchor(); xub_StrLen nIdx = pPos->nContent.GetIndex(); diff --git a/sw/source/core/text/txtfly.cxx b/sw/source/core/text/txtfly.cxx index 706eca2ec52e..b7d87b540bc1 100644 --- a/sw/source/core/text/txtfly.cxx +++ b/sw/source/core/text/txtfly.cxx @@ -31,12 +31,8 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" -#ifndef _OUTDEV_HXX //autogen #include -#endif -#ifndef _VIRDEV_HXX //autogen #include -#endif #include "viewsh.hxx" #include "pagefrm.hxx" @@ -61,14 +57,9 @@ #include "flyfrms.hxx" #include "fmtcnct.hxx" // SwFmtChain #include // SwMultiPortion -#ifdef VERT_DISTANCE -#include -#endif #include -#ifndef _TXTRANGE_HXX //autogen #include -#endif #include #include // --> OD 2004-06-16 #i28701# @@ -83,30 +74,26 @@ #include #include #include -#ifndef IDOCUMENTDRAWMODELACCESS_HXX_INCLUDED #include -#endif #include #include #include -#ifndef _TXTRANGE_HXX //autogen #include -#endif #include #include #include #include - +#include "doc.hxx" #ifndef PRODUCT #include "viewopt.hxx" // SwViewOptions, nur zum Testen (Test2) #endif -#include "doc.hxx" #ifdef VERT_DISTANCE #include #endif + using namespace ::com::sun::star; /***************************************************************************** @@ -1006,8 +993,8 @@ sal_Bool SwTxtFly::DrawTextOpaque( SwDrawTextInfo &rInf ) // --> OD 2006-08-15 #i68520# GetMaster() == pFly->GetAnchorFrm() || // <-- - ( FLY_AT_CNTNT != rAnchor.GetAnchorId() && - FLY_AUTO_CNTNT != rAnchor.GetAnchorId() + ((FLY_AT_PARA != rAnchor.GetAnchorId()) && + (FLY_AT_CHAR != rAnchor.GetAnchorId()) ) ) && // --> OD 2006-08-15 #i68520# @@ -1176,7 +1163,7 @@ sal_Bool SwTxtFly::GetTop( const SwAnchoredObject* _pAnchoredObj, const SwFrmFmt& rFrmFmt = _pAnchoredObj->GetFrmFmt(); const SwFmtAnchor& rNewA = rFrmFmt.GetAnchor(); // <-- - if ( FLY_PAGE == rNewA.GetAnchorId() ) + if (FLY_AT_PAGE == rNewA.GetAnchorId()) { if ( bInFtn ) return sal_False; @@ -1225,23 +1212,25 @@ sal_Bool SwTxtFly::GetTop( const SwAnchoredObject* _pAnchoredObj, // If is anchored as character, its content // does not wrap around pNew - if( FLY_IN_CNTNT == rCurrA.GetAnchorId() ) + if (FLY_AS_CHAR == rCurrA.GetAnchorId()) return sal_False; // If pNew is anchored to page and does not wrap around pNew // If both pNew and are anchored to page, we can do // some more checks - if( FLY_PAGE == rNewA.GetAnchorId() ) + if (FLY_AT_PAGE == rNewA.GetAnchorId()) { - if( FLY_PAGE == rCurrA.GetAnchorId() ) + if (FLY_AT_PAGE == rCurrA.GetAnchorId()) + { bEvade = sal_True; + } else return sal_False; } - else if( FLY_PAGE == rCurrA.GetAnchorId() ) + else if (FLY_AT_PAGE == rCurrA.GetAnchorId()) return sal_False; // Seitengebundene weichen nur seitengeb. aus - else if( FLY_AT_FLY == rNewA.GetAnchorId() ) + else if (FLY_AT_FLY == rNewA.GetAnchorId()) bEvade = sal_True; // Nicht seitengeb. weichen Rahmengeb. aus else if( FLY_AT_FLY == rCurrA.GetAnchorId() ) return sal_False; // Rahmengebundene weichen abs.geb. nicht aus @@ -1285,8 +1274,9 @@ sal_Bool SwTxtFly::GetTop( const SwAnchoredObject* _pAnchoredObj, // --> OD 2004-10-06 #i26945# const SwFmtAnchor& rNewA = _pAnchoredObj->GetFrmFmt().GetAnchor(); // <-- - ASSERT( FLY_IN_CNTNT != rNewA.GetAnchorId(), "Don't call GetTop with a FlyInCntFrm" ); - if( FLY_PAGE == rNewA.GetAnchorId() ) + ASSERT( FLY_AS_CHAR != rNewA.GetAnchorId(), + "Don't call GetTop with a FlyInCntFrm" ); + if (FLY_AT_PAGE == rNewA.GetAnchorId()) return sal_True; // Seitengebundenen wird immer ausgewichen. // Wenn absatzgebundene Flys in einem FlyCnt gefangen sind, so @@ -2015,8 +2005,8 @@ sal_Bool SwTxtFly::ForEach( const SwRect &rRect, SwRect* pRect, sal_Bool bAvoid // --> OD 2006-08-15 #i68520# GetMaster() == pAnchoredObj->GetAnchorFrm() || // <-- - ( FLY_AT_CNTNT != rAnchor.GetAnchorId() && - FLY_AUTO_CNTNT != rAnchor.GetAnchorId() ) ) ) + ((FLY_AT_PARA != rAnchor.GetAnchorId()) && + (FLY_AT_CHAR != rAnchor.GetAnchorId())) ) ) || aRect.Top() == WEIT_WECH ) continue; } @@ -2442,9 +2432,11 @@ SwSurround SwTxtFly::_GetSurroundForTextWrap( const SwAnchoredObject* pAnchoredO if( rFlyFmt.IsAnchorOnly() && pAnchoredObj->GetAnchorFrm() != GetMaster() ) { const SwFmtAnchor& rAnchor = pFmt->GetAnchor(); - if ( FLY_AT_CNTNT == rAnchor.GetAnchorId() || - FLY_AUTO_CNTNT == rAnchor.GetAnchorId() ) + if ((FLY_AT_PARA == rAnchor.GetAnchorId()) || + (FLY_AT_CHAR == rAnchor.GetAnchorId())) + { return SURROUND_NONE; + } } // Beim Durchlauf und Nowrap wird smart ignoriert. diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx index 14944264d39e..479d082b5477 100644 --- a/sw/source/core/text/txtfrm.cxx +++ b/sw/source/core/text/txtfrm.cxx @@ -65,9 +65,7 @@ #include #include #include -#ifndef _FMTLINE_HXX #include -#endif #include // SwTxtFrm #include // SwSectFrm #include // DBG_LOOP @@ -76,9 +74,7 @@ #include #include // GetLineSpace benutzt pLastFont #include -#ifndef _LINEINFO_HXX #include -#endif #include // OD 2004-01-15 #110582# #include @@ -101,6 +97,7 @@ extern const sal_Char *GetPrepName( const enum PrepareHint ePrep ); #endif + TYPEINIT1( SwTxtFrm, SwCntntFrm ); // Switches width and height of the text frame @@ -487,7 +484,7 @@ bool lcl_HideObj( const SwTxtFrm& _rFrm, { bool bRet( true ); - if ( _eAnchorType == FLY_AUTO_CNTNT ) + if (_eAnchorType == FLY_AT_CHAR) { const IDocumentSettingAccess* pIDSA = _rFrm.GetTxtNode()->getIDocumentSettingAccess(); if ( !pIDSA->get(IDocumentSettingAccess::USE_FORMER_TEXT_WRAPPING) && @@ -560,8 +557,9 @@ void SwTxtFrm::HideAndShowObjects() // under certain conditions const RndStdIds eAnchorType( pContact->GetAnchorId() ); const xub_StrLen nObjAnchorPos = pContact->GetCntntAnchorIndex().GetIndex(); - if ( eAnchorType != FLY_AUTO_CNTNT || - lcl_HideObj( *this, eAnchorType, nObjAnchorPos, (*GetDrawObjs())[i] ) ) + if ((eAnchorType != FLY_AT_CHAR) || + lcl_HideObj( *this, eAnchorType, nObjAnchorPos, + (*GetDrawObjs())[i] )) { pContact->MoveObjToInvisibleLayer( pObj ); } @@ -588,12 +586,12 @@ void SwTxtFrm::HideAndShowObjects() const RndStdIds eAnchorType( pContact->GetAnchorId() ); // <-- - if ( eAnchorType == FLY_AT_CNTNT ) + if (eAnchorType == FLY_AT_PARA) { pContact->MoveObjToVisibleLayer( pObj ); } - else if ( eAnchorType == FLY_AUTO_CNTNT || - eAnchorType == FLY_IN_CNTNT ) + else if ((eAnchorType == FLY_AT_CHAR) || + (eAnchorType == FLY_AS_CHAR)) { xub_StrLen nHiddenStart; xub_StrLen nHiddenEnd; @@ -1704,7 +1702,7 @@ void SwTxtFrm::Prepare( const PrepareHint ePrep, const void* pVoid, // --> OD 2004-07-16 #i28701# - consider all // to-character anchored objects if ( pAnchoredObj->GetFrmFmt().GetAnchor().GetAnchorId() - == FLY_AUTO_CNTNT ) + == FLY_AT_CHAR ) { bFormat = sal_True; break; diff --git a/sw/source/core/txtnode/atrflyin.cxx b/sw/source/core/txtnode/atrflyin.cxx index fa0a734f79c1..eefca09e08d0 100644 --- a/sw/source/core/txtnode/atrflyin.cxx +++ b/sw/source/core/txtnode/atrflyin.cxx @@ -124,8 +124,8 @@ void SwTxtFlyCnt::CopyFlyFmt( SwDoc* pDoc ) BOOL bUndo = pDoc->DoesUndo(); pDoc->DoUndo( FALSE ); SwFmtAnchor aAnchor( pFmt->GetAnchor() ); - if( FLY_PAGE != aAnchor.GetAnchorId() && - pDoc != pFmt->GetDoc() ) // Unterschiedliche Docs? + if ((FLY_AT_PAGE != aAnchor.GetAnchorId()) && + (pDoc != pFmt->GetDoc())) // different documents? { // JP 03.06.96: dann sorge dafuer, das der koperierte Anker auf // gueltigen Content zeigt! Die Umsetzung auf die @@ -137,8 +137,10 @@ void SwTxtFlyCnt::CopyFlyFmt( SwDoc* pDoc ) SwPosition* pPos = (SwPosition*)aAnchor.GetCntntAnchor(); pPos->nNode = aIdx; - if( FLY_IN_CNTNT == aAnchor.GetAnchorId() ) + if (FLY_AS_CHAR == aAnchor.GetAnchorId()) + { pPos->nContent.Assign( pCNd, 0 ); + } else { pPos->nContent.Assign( 0, 0 ); @@ -181,7 +183,7 @@ void SwTxtFlyCnt::SetAnchor( const SwTxtNode *pNode ) else aPos.nNode = aAnchor.GetCntntAnchor()->nNode; - aAnchor.SetType( FLY_IN_CNTNT ); // defaulten !! + aAnchor.SetType( FLY_AS_CHAR ); // default! aAnchor.SetAnchor( &aPos ); // beim Ankerwechsel werden immer alle FlyFrms vom Attribut geloescht diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx index 81a3b629f402..ba471381cad4 100644 --- a/sw/source/core/txtnode/thints.cxx +++ b/sw/source/core/txtnode/thints.cxx @@ -1270,11 +1270,15 @@ bool SwTxtNode::InsertHint( SwTxtAttr * const pAttr, const SetAttrMode nMode ) InsertText( c, aIdx, nInsertFlags ); nInsMode |= nsSetAttrMode::SETATTR_NOTXTATRCHR; - if( pAnchor && FLY_IN_CNTNT == pAnchor->GetAnchorId() && + if (pAnchor && + (FLY_AS_CHAR == pAnchor->GetAnchorId()) && pAnchor->GetCntntAnchor() && pAnchor->GetCntntAnchor()->nNode == *this && pAnchor->GetCntntAnchor()->nContent == aIdx ) - ((SwIndex&)pAnchor->GetCntntAnchor()->nContent)--; + { + const_cast( + pAnchor->GetCntntAnchor()->nContent)--; + } } pFly->SetAnchor( this ); diff --git a/sw/source/core/undo/rolbck.cxx b/sw/source/core/undo/rolbck.cxx index 908fc480fe66..d7df1593af7a 100644 --- a/sw/source/core/undo/rolbck.cxx +++ b/sw/source/core/undo/rolbck.cxx @@ -922,7 +922,7 @@ SwHistoryChangeFlyAnchor::SwHistoryChangeFlyAnchor( SwFrmFmt& rFmt ) : SwHistoryHint( HSTRY_CHGFLYANCHOR ) , m_rFmt( rFmt ) , m_nOldNodeIndex( rFmt.GetAnchor().GetCntntAnchor()->nNode.GetIndex() ) - , m_nOldContentIndex( ( FLY_AUTO_CNTNT == rFmt.GetAnchor().GetAnchorId() ) + , m_nOldContentIndex( (FLY_AT_CHAR == rFmt.GetAnchor().GetAnchorId()) ? rFmt.GetAnchor().GetCntntAnchor()->nContent.GetIndex() : STRING_MAXLEN ) { diff --git a/sw/source/core/undo/unattr.cxx b/sw/source/core/undo/unattr.cxx index e5312b3cefdd..acc167ed9900 100644 --- a/sw/source/core/undo/unattr.cxx +++ b/sw/source/core/undo/unattr.cxx @@ -462,10 +462,10 @@ void SwUndoFmtAttr::SaveFlyAnchor( bool bSvDrwPt ) xub_StrLen nCntnt = 0; switch( rAnchor.GetAnchorId() ) { - case FLY_IN_CNTNT: - case FLY_AUTO_CNTNT: + case FLY_AS_CHAR: + case FLY_AT_CHAR: nCntnt = rAnchor.GetCntntAnchor()->nContent.GetIndex(); - case FLY_AT_CNTNT: + case FLY_AT_PARA: case FLY_AT_FLY: m_nNodeIndex = rAnchor.GetCntntAnchor()->nNode.GetIndex(); break; @@ -489,7 +489,7 @@ bool SwUndoFmtAttr::RestoreFlyAnchor( SwUndoIter& rIter ) static_cast( m_pOldSet->Get( RES_ANCHOR, FALSE ) ); SwFmtAnchor aNewAnchor( rAnchor.GetAnchorId() ); - if( FLY_PAGE != rAnchor.GetAnchorId() ) + if (FLY_AT_PAGE != rAnchor.GetAnchorId()) { SwNode* pNd = pDoc->GetNodes()[ m_nNodeIndex ]; @@ -505,8 +505,8 @@ bool SwUndoFmtAttr::RestoreFlyAnchor( SwUndoIter& rIter ) } SwPosition aPos( *pNd ); - if( FLY_IN_CNTNT == rAnchor.GetAnchorId() || - FLY_AUTO_CNTNT == rAnchor.GetAnchorId() ) + if ((FLY_AS_CHAR == rAnchor.GetAnchorId()) || + (FLY_AT_CHAR == rAnchor.GetAnchorId())) { aPos.nContent.Assign( (SwTxtNode*)pNd, rAnchor.GetPageNum() ); if ( aPos.nContent.GetIndex() > @@ -549,7 +549,7 @@ bool SwUndoFmtAttr::RestoreFlyAnchor( SwUndoIter& rIter ) const SwFmtAnchor &rOldAnch = pFrmFmt->GetAnchor(); // --> OD 2006-03-13 #i54336# // Consider case, that as-character anchored object has moved its anchor position. - if ( FLY_IN_CNTNT == rOldAnch.GetAnchorId() ) + if (FLY_AS_CHAR == rOldAnch.GetAnchorId()) // <-- { //Bei InCntnt's wird es spannend: Das TxtAttribut muss vernichtet @@ -613,7 +613,7 @@ bool SwUndoFmtAttr::RestoreFlyAnchor( SwUndoIter& rIter ) SwFmtFrmSize( ATT_VAR_SIZE, aDrawOldPt.X(), aDrawOldPt.Y() ) ); } - if( FLY_IN_CNTNT == aNewAnchor.GetAnchorId() ) + if (FLY_AS_CHAR == aNewAnchor.GetAnchorId()) { const SwPosition* pPos = aNewAnchor.GetCntntAnchor(); SwTxtNode* pTxtNd = pPos->nNode.GetNode().GetTxtNode(); diff --git a/sw/source/core/undo/undel.cxx b/sw/source/core/undo/undel.cxx index d9a2e6e8486c..dfa0ee9d469e 100644 --- a/sw/source/core/undo/undel.cxx +++ b/sw/source/core/undo/undel.cxx @@ -81,7 +81,7 @@ void lcl_MakeAutoFrms( const SwSpzFrmFmts& rSpzArr, ULONG nMovedIndex ) { pFmt = (SwFlyFrmFmt*)rSpzArr[n]; pAnchor = &pFmt->GetAnchor(); - if( pAnchor->GetAnchorId() == FLY_AUTO_CNTNT ) + if (pAnchor->GetAnchorId() == FLY_AT_CHAR) { const SwPosition* pAPos = pAnchor->GetCntntAnchor(); if( pAPos && nMovedIndex == pAPos->nNode.GetIndex() ) @@ -632,7 +632,7 @@ void lcl_ReAnchorAtCntntFlyFrames( const SwSpzFrmFmts& rSpzArr, SwPosition &rPos { pFmt = (SwFlyFrmFmt*)rSpzArr[n]; pAnchor = &pFmt->GetAnchor(); - if( pAnchor->GetAnchorId() == FLY_AT_CNTNT ) + if (pAnchor->GetAnchorId() == FLY_AT_PARA) { pAPos = pAnchor->GetCntntAnchor(); if( pAPos && nOldIdx == pAPos->nNode.GetIndex() ) diff --git a/sw/source/core/undo/undobj.cxx b/sw/source/core/undo/undobj.cxx index 3b090e875ea8..ce479d51ac98 100644 --- a/sw/source/core/undo/undobj.cxx +++ b/sw/source/core/undo/undobj.cxx @@ -593,7 +593,7 @@ void SwUndoSaveCntnt::DelCntntIndex( const SwPosition& rMark, pAnchor = &pFmt->GetAnchor(); switch( pAnchor->GetAnchorId() ) { - case FLY_IN_CNTNT: + case FLY_AS_CHAR: if( 0 != (pAPos = pAnchor->GetCntntAnchor() ) && (( nsDelCntntType::DELCNT_CHKNOCNTNT & nDelCntntType ) ? ( pStt->nNode <= pAPos->nNode && @@ -611,7 +611,7 @@ void SwUndoSaveCntnt::DelCntntIndex( const SwPosition& rMark, n = n >= rSpzArr.Count() ? rSpzArr.Count() : n+1; } break; - case FLY_AT_CNTNT: + case FLY_AT_PARA: { pAPos = pAnchor->GetCntntAnchor(); if( pAPos ) @@ -660,7 +660,7 @@ void SwUndoSaveCntnt::DelCntntIndex( const SwPosition& rMark, } } break; - case FLY_AUTO_CNTNT: + case FLY_AT_CHAR: if( 0 != (pAPos = pAnchor->GetCntntAnchor() ) && ( pStt->nNode <= pAPos->nNode && pAPos->nNode <= pEnd->nNode ) ) { diff --git a/sw/source/core/undo/undobj1.cxx b/sw/source/core/undo/undobj1.cxx index dd261282e5c7..69b235d7f5eb 100644 --- a/sw/source/core/undo/undobj1.cxx +++ b/sw/source/core/undo/undobj1.cxx @@ -93,15 +93,19 @@ void SwUndoFlyBase::InsFly( SwUndoIter& rUndoIter, BOOL bShowSelFrm ) SwFmtAnchor aAnchor( (RndStdIds)nRndId ); - if( FLY_PAGE == nRndId ) + if (FLY_AT_PAGE == nRndId) + { aAnchor.SetPageNum( (USHORT)nNdPgPos ); + } else { SwPosition aNewPos( *rUndoIter.pAktPam->GetPoint() ); aNewPos.nNode = nNdPgPos; - if( FLY_IN_CNTNT == nRndId || FLY_AUTO_CNTNT == nRndId ) + if ((FLY_AS_CHAR == nRndId) || (FLY_AT_CHAR == nRndId)) + { aNewPos.nContent.Assign( aNewPos.nNode.GetNode().GetCntntNode(), nCntPos ); + } aAnchor.SetAnchor( &aNewPos ); } @@ -119,7 +123,7 @@ void SwUndoFlyBase::InsFly( SwUndoIter& rUndoIter, BOOL bShowSelFrm ) // vorhanden ist! Sonst wuerde das Layout den Fly vorher // formatieren, aber keine Inhalt finden; so geschene bei // Grafiken aus dem Internet - if( FLY_IN_CNTNT == nRndId ) + if (FLY_AS_CHAR == nRndId) { // es muss mindestens das Attribut im TextNode stehen SwCntntNode* pCNd = aAnchor.GetCntntAnchor()->nNode.GetNode().GetCntntNode(); @@ -138,22 +142,22 @@ void SwUndoFlyBase::InsFly( SwUndoIter& rUndoIter, BOOL bShowSelFrm ) switch( nRndId ) { - case FLY_IN_CNTNT: - case FLY_AUTO_CNTNT: + case FLY_AS_CHAR: + case FLY_AT_CHAR: { const SwFmtAnchor& rAnchor = pFrmFmt->GetAnchor(); nNdPgPos = rAnchor.GetCntntAnchor()->nNode.GetIndex(); nCntPos = rAnchor.GetCntntAnchor()->nContent.GetIndex(); } break; - case FLY_AT_CNTNT: + case FLY_AT_PARA: case FLY_AT_FLY: { const SwFmtAnchor& rAnchor = pFrmFmt->GetAnchor(); nNdPgPos = rAnchor.GetCntntAnchor()->nNode.GetIndex(); } break; - case FLY_PAGE: + case FLY_AT_PAGE: break; } bDelFmt = FALSE; @@ -193,7 +197,8 @@ void SwUndoFlyBase::DelFly( SwDoc* pDoc ) const SwFmtAnchor& rAnchor = pFrmFmt->GetAnchor(); const SwPosition* pPos = rAnchor.GetCntntAnchor(); // die Positionen im Nodes-Array haben sich verschoben - if( FLY_IN_CNTNT == ( nRndId = static_cast(rAnchor.GetAnchorId()) ) ) + nRndId = static_cast(rAnchor.GetAnchorId()); + if (FLY_AS_CHAR == nRndId) { nNdPgPos = pPos->nNode.GetIndex(); nCntPos = pPos->nContent.GetIndex(); @@ -210,15 +215,19 @@ void SwUndoFlyBase::DelFly( SwDoc* pDoc ) pTxtNd->EraseText( aIdx, 1 ); } } - else if( FLY_AUTO_CNTNT == nRndId ) + else if (FLY_AT_CHAR == nRndId) { nNdPgPos = pPos->nNode.GetIndex(); nCntPos = pPos->nContent.GetIndex(); } - else if( FLY_AT_CNTNT == nRndId || FLY_AT_FLY == nRndId ) + else if ((FLY_AT_PARA == nRndId) || (FLY_AT_FLY == nRndId)) + { nNdPgPos = pPos->nNode.GetIndex(); + } else + { nNdPgPos = rAnchor.GetPageNum(); + } pFrmFmt->ResetFmtAttr( RES_ANCHOR ); // Anchor loeschen @@ -240,15 +249,15 @@ SwUndoInsLayFmt::SwUndoInsLayFmt( SwFrmFmt* pFormat, ULONG nNodeIdx, xub_StrLen bDelFmt = FALSE; switch( nRndId ) { - case FLY_PAGE: + case FLY_AT_PAGE: nNdPgPos = rAnchor.GetPageNum(); break; - case FLY_AT_CNTNT: + case FLY_AT_PARA: case FLY_AT_FLY: nNdPgPos = rAnchor.GetCntntAnchor()->nNode.GetIndex(); break; - case FLY_IN_CNTNT: - case FLY_AUTO_CNTNT: + case FLY_AS_CHAR: + case FLY_AT_CHAR: { const SwPosition* pPos = rAnchor.GetCntntAnchor(); nCntPos = pPos->nContent.GetIndex(); @@ -305,13 +314,15 @@ void SwUndoInsLayFmt::Repeat( SwUndoIter& rUndoIter ) SwDoc* pDoc = &rUndoIter.GetDoc(); // erfrage und setze den Anker neu SwFmtAnchor aAnchor( pFrmFmt->GetAnchor() ); - if( FLY_AT_CNTNT == aAnchor.GetAnchorId() || - FLY_AUTO_CNTNT == aAnchor.GetAnchorId() || - FLY_IN_CNTNT == aAnchor.GetAnchorId() ) + if ((FLY_AT_PARA == aAnchor.GetAnchorId()) || + (FLY_AT_CHAR == aAnchor.GetAnchorId()) || + (FLY_AS_CHAR == aAnchor.GetAnchorId())) { SwPosition aPos( *rUndoIter.pAktPam->GetPoint() ); - if( FLY_AT_CNTNT == aAnchor.GetAnchorId() ) + if (FLY_AT_PARA == aAnchor.GetAnchorId()) + { aPos.nContent.Assign( 0, 0 ); + } aAnchor.SetAnchor( &aPos ); } else if( FLY_AT_FLY == aAnchor.GetAnchorId() ) @@ -328,7 +339,7 @@ void SwUndoInsLayFmt::Repeat( SwUndoIter& rUndoIter ) return ; } } - else if( FLY_PAGE == aAnchor.GetAnchorId() ) + else if (FLY_AT_PAGE == aAnchor.GetAnchorId()) { aAnchor.SetPageNum( pDoc->GetRootFrm()->GetCurrPage( rUndoIter.pAktPam )); @@ -482,7 +493,7 @@ void SwUndoSetFlyFmt::GetAnchor( SwFmtAnchor& rAnchor, ULONG nNode, xub_StrLen nCntnt ) { RndStdIds nAnchorTyp = rAnchor.GetAnchorId(); - if( FLY_PAGE != nAnchorTyp ) + if (FLY_AT_PAGE != nAnchorTyp) { SwNode* pNd = pFrmFmt->GetDoc()->GetNodes()[ nNode ]; @@ -490,26 +501,34 @@ void SwUndoSetFlyFmt::GetAnchor( SwFmtAnchor& rAnchor, ? ( !pNd->IsStartNode() || SwFlyStartNode != ((SwStartNode*)pNd)->GetStartNodeType() ) : !pNd->IsTxtNode() ) - pNd = 0; // ungueltige Position + { + pNd = 0; // invalid position + } else { SwPosition aPos( *pNd ); - if( FLY_IN_CNTNT == nAnchorTyp || - FLY_AUTO_CNTNT == nAnchorTyp ) + if ((FLY_AS_CHAR == nAnchorTyp) || + (FLY_AT_CHAR == nAnchorTyp)) { - if( nCntnt > ((SwTxtNode*)pNd)->GetTxt().Len() ) - pNd = 0; // ungueltige Position + if ( nCntnt > static_cast(pNd)->GetTxt().Len() ) + { + pNd = 0; // invalid position + } else - aPos.nContent.Assign( (SwTxtNode*)pNd, nCntnt ); + { + aPos.nContent.Assign(static_cast(pNd), nCntnt); + } } - if( pNd ) + if ( pNd ) + { rAnchor.SetAnchor( &aPos ); + } } if( !pNd ) { // ungueltige Position - setze auf 1. Seite - rAnchor.SetType( FLY_PAGE ); + rAnchor.SetType( FLY_AT_PAGE ); rAnchor.SetPageNum( 1 ); } } @@ -548,7 +567,7 @@ void SwUndoSetFlyFmt::Undo( SwUndoIter& rIter ) if( bAnchorChgd ) { const SwFmtAnchor& rOldAnch = pFrmFmt->GetAnchor(); - if( FLY_IN_CNTNT == rOldAnch.GetAnchorId() ) + if (FLY_AS_CHAR == rOldAnch.GetAnchorId()) { // Bei InCntnt's wird es spannend: Das TxtAttribut muss // vernichtet werden. Leider reisst dies neben den Frms @@ -577,7 +596,7 @@ void SwUndoSetFlyFmt::Undo( SwUndoIter& rIter ) GetAnchor( aNewAnchor, nOldNode, nOldCntnt ); pFrmFmt->SetFmtAttr( aNewAnchor ); - if( FLY_IN_CNTNT == aNewAnchor.GetAnchorId() ) + if (FLY_AS_CHAR == aNewAnchor.GetAnchorId()) { SwPosition* pPos = (SwPosition*)aNewAnchor.GetCntntAnchor(); SwFmtFlyCnt aFmt( pFrmFmt ); @@ -629,10 +648,10 @@ void SwUndoSetFlyFmt::PutAttr( USHORT nWhich, const SfxPoolItem* pItem ) const SwFmtAnchor* pAnchor = (SwFmtAnchor*)pItem; switch( nOldAnchorTyp = static_cast(pAnchor->GetAnchorId()) ) { - case FLY_IN_CNTNT: - case FLY_AUTO_CNTNT: + case FLY_AS_CHAR: + case FLY_AT_CHAR: nOldCntnt = pAnchor->GetCntntAnchor()->nContent.GetIndex(); - case FLY_AT_CNTNT: + case FLY_AT_PARA: case FLY_AT_FLY: nOldNode = pAnchor->GetCntntAnchor()->nNode.GetIndex(); break; @@ -644,10 +663,10 @@ void SwUndoSetFlyFmt::PutAttr( USHORT nWhich, const SfxPoolItem* pItem ) pAnchor = (SwFmtAnchor*)&pFrmFmt->GetAnchor(); switch( nNewAnchorTyp = static_cast(pAnchor->GetAnchorId()) ) { - case FLY_IN_CNTNT: - case FLY_AUTO_CNTNT: + case FLY_AS_CHAR: + case FLY_AT_CHAR: nNewCntnt = pAnchor->GetCntntAnchor()->nContent.GetIndex(); - case FLY_AT_CNTNT: + case FLY_AT_PARA: case FLY_AT_FLY: nNewNode = pAnchor->GetCntntAnchor()->nNode.GetIndex(); break; diff --git a/sw/source/core/undo/undraw.cxx b/sw/source/core/undo/undraw.cxx index 54ed7ea8421d..2c09ff4f3da6 100644 --- a/sw/source/core/undo/undraw.cxx +++ b/sw/source/core/undo/undraw.cxx @@ -32,15 +32,9 @@ #include "precompiled_sw.hxx" #include - -#ifndef _RTL_MEMORY_H #include -#endif #include -#ifndef _RTL_STRING_H -#include -#endif #include #include #include @@ -61,6 +55,7 @@ #include #include + struct SwUndoGroupObjImpl { SwDrawFrmFmt* pFmt; @@ -142,15 +137,15 @@ void lcl_SendRemoveToUno( SwFmt& rFmt ) void lcl_SaveAnchor( SwFrmFmt* pFmt, ULONG& rNodePos ) { const SwFmtAnchor& rAnchor = pFmt->GetAnchor(); - if( FLY_AT_CNTNT == rAnchor.GetAnchorId() || - FLY_AUTO_CNTNT == rAnchor.GetAnchorId() || - FLY_AT_FLY == rAnchor.GetAnchorId() || - FLY_IN_CNTNT == rAnchor.GetAnchorId() ) + if ((FLY_AT_PARA == rAnchor.GetAnchorId()) || + (FLY_AT_CHAR == rAnchor.GetAnchorId()) || + (FLY_AT_FLY == rAnchor.GetAnchorId()) || + (FLY_AS_CHAR == rAnchor.GetAnchorId())) { rNodePos = rAnchor.GetCntntAnchor()->nNode.GetIndex(); xub_StrLen nCntntPos = 0; - if( FLY_IN_CNTNT == rAnchor.GetAnchorId() ) + if (FLY_AS_CHAR == rAnchor.GetAnchorId()) { nCntntPos = rAnchor.GetCntntAnchor()->nContent.GetIndex(); @@ -168,8 +163,10 @@ void lcl_SaveAnchor( SwFrmFmt* pFmt, ULONG& rNodePos ) pTxtNd->EraseText( aIdx, 1 ); } } - else if( FLY_AUTO_CNTNT == rAnchor.GetAnchorId() ) + else if (FLY_AT_CHAR == rAnchor.GetAnchorId()) + { nCntntPos = rAnchor.GetCntntAnchor()->nContent.GetIndex(); + } pFmt->SetFmtAttr( SwFmtAnchor( rAnchor.GetAnchorId(), nCntntPos ) ); } @@ -178,10 +175,10 @@ void lcl_SaveAnchor( SwFrmFmt* pFmt, ULONG& rNodePos ) void lcl_RestoreAnchor( SwFrmFmt* pFmt, ULONG& rNodePos ) { const SwFmtAnchor& rAnchor = pFmt->GetAnchor(); - if( FLY_AT_CNTNT == rAnchor.GetAnchorId() || - FLY_AUTO_CNTNT == rAnchor.GetAnchorId() || - FLY_AT_FLY == rAnchor.GetAnchorId() || - FLY_IN_CNTNT == rAnchor.GetAnchorId() ) + if ((FLY_AT_PARA == rAnchor.GetAnchorId()) || + (FLY_AT_CHAR == rAnchor.GetAnchorId()) || + (FLY_AT_FLY == rAnchor.GetAnchorId()) || + (FLY_AS_CHAR == rAnchor.GetAnchorId())) { xub_StrLen nCntntPos = rAnchor.GetPageNum(); SwNodes& rNds = pFmt->GetDoc()->GetNodes(); @@ -190,13 +187,15 @@ void lcl_RestoreAnchor( SwFrmFmt* pFmt, ULONG& rNodePos ) SwPosition aPos( aIdx ); SwFmtAnchor aTmp( rAnchor.GetAnchorId() ); - if( FLY_IN_CNTNT == rAnchor.GetAnchorId() || - FLY_AUTO_CNTNT == rAnchor.GetAnchorId() ) + if ((FLY_AS_CHAR == rAnchor.GetAnchorId()) || + (FLY_AT_CHAR == rAnchor.GetAnchorId())) + { aPos.nContent.Assign( aIdx.GetNode().GetCntntNode(), nCntntPos ); + } aTmp.SetAnchor( &aPos ); pFmt->SetFmtAttr( aTmp ); - if( FLY_IN_CNTNT == rAnchor.GetAnchorId() ) + if (FLY_AS_CHAR == rAnchor.GetAnchorId()) { SwTxtNode *pTxtNd = aIdx.GetNode().GetTxtNode(); ASSERT( pTxtNd, "no Text Node" ); diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx index 3d5dbd429e49..438bdf733666 100644 --- a/sw/source/core/undo/untbl.cxx +++ b/sw/source/core/undo/untbl.cxx @@ -449,12 +449,12 @@ SwUndoTblToTxt::SwUndoTblToTxt( const SwTable& rTbl, sal_Unicode cCh ) const SwSpzFrmFmts& rFrmFmtTbl = *pTblNd->GetDoc()->GetSpzFrmFmts(); for( USHORT n = 0; n < rFrmFmtTbl.Count(); ++n ) { - const SwPosition* pAPos; SwFrmFmt* pFmt = rFrmFmtTbl[ n ]; - const SwFmtAnchor* pAnchor = &pFmt->GetAnchor(); - if( 0 != ( pAPos = pAnchor->GetCntntAnchor()) && - ( FLY_AUTO_CNTNT == pAnchor->GetAnchorId() || - FLY_AT_CNTNT == pAnchor->GetAnchorId() ) && + SwFmtAnchor const*const pAnchor = &pFmt->GetAnchor(); + SwPosition const*const pAPos = pAnchor->GetCntntAnchor(); + if (pAPos && + ((FLY_AT_CHAR == pAnchor->GetAnchorId()) || + (FLY_AT_PARA == pAnchor->GetAnchorId())) && nTblStt <= pAPos->nNode.GetIndex() && pAPos->nNode.GetIndex() < nTblEnd ) { diff --git a/sw/source/core/undo/untblk.cxx b/sw/source/core/undo/untblk.cxx index 1c076a05dcce..6a6618935155 100644 --- a/sw/source/core/undo/untblk.cxx +++ b/sw/source/core/undo/untblk.cxx @@ -69,10 +69,10 @@ SwUndoInserts::SwUndoInserts( SwUndoId nUndoId, const SwPaM& rPam ) for( USHORT n = 0; n < nArrLen; ++n ) { SwFrmFmt* pFmt = (*pDoc->GetSpzFrmFmts())[n]; - const SwFmtAnchor* pAnchor = &pFmt->GetAnchor(); - const SwPosition* pAPos; - if ( pAnchor->GetAnchorId() == FLY_AT_CNTNT && - 0 != ( pAPos = pAnchor->GetCntntAnchor()) && + SwFmtAnchor const*const pAnchor = &pFmt->GetAnchor(); + const SwPosition* pAPos = pAnchor->GetCntntAnchor(); + if (pAPos && + (pAnchor->GetAnchorId() == FLY_AT_PARA) && nSttNode == pAPos->nNode.GetIndex() ) { if( !pFrmFmts ) @@ -124,10 +124,10 @@ void SwUndoInserts::SetInsertRange( const SwPaM& rPam, BOOL bScanFlys, for( USHORT n = 0; n < nArrLen; ++n ) { SwFrmFmt* pFmt = (*pDoc->GetSpzFrmFmts())[n]; - const SwFmtAnchor* pAnchor = &pFmt->GetAnchor(); - const SwPosition* pAPos; - if( pAnchor->GetAnchorId() == FLY_AT_CNTNT && - 0 != ( pAPos = pAnchor->GetCntntAnchor()) && + SwFmtAnchor const*const pAnchor = &pFmt->GetAnchor(); + SwPosition const*const pAPos = pAnchor->GetCntntAnchor(); + if (pAPos && + (pAnchor->GetAnchorId() == FLY_AT_PARA) && nSttNode == pAPos->nNode.GetIndex() ) { if( !pFrmFmts || diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx index f8256a7ada0b..5a050eb690ed 100644 --- a/sw/source/core/unocore/unodraw.cxx +++ b/sw/source/core/unocore/unodraw.cxx @@ -163,7 +163,9 @@ public: SwFmtAnchor* GetAnchor(sal_Bool bCreate = sal_False) { if(bCreate && !pAnchor) - pAnchor = new SwFmtAnchor(FLY_IN_CNTNT); + { + pAnchor = new SwFmtAnchor(FLY_AS_CHAR); + } return pAnchor; } SwFmtHoriOrient* GetHOrient(sal_Bool bCreate = sal_False) @@ -700,7 +702,7 @@ void SwXDrawPage::add(const uno::Reference< drawing::XShape > & xShape) SfxItemSet aSet( pDoc->GetAttrPool(), RES_FRMATR_BEGIN, RES_FRMATR_END-1 ); - SwFmtAnchor aAnchor( FLY_IN_CNTNT ); + SwFmtAnchor aAnchor( FLY_AS_CHAR ); sal_Bool bOpaque = sal_False; if( pDesc ) { @@ -781,14 +783,18 @@ void SwXDrawPage::add(const uno::Reference< drawing::XShape > & xShape) { if(FLY_AT_FLY == aAnchor.GetAnchorId() && !pInternalPam->GetNode()->FindFlyStartNode()) - aAnchor.SetType(FLY_IN_CNTNT); - else if(FLY_PAGE == aAnchor.GetAnchorId()) + { + aAnchor.SetType(FLY_AS_CHAR); + } + else if (FLY_AT_PAGE == aAnchor.GetAnchorId()) + { aAnchor.SetAnchor(pInternalPam->Start()); + } } else throw uno::RuntimeException(); } - else if( aAnchor.GetAnchorId() != FLY_PAGE && pDoc->GetRootFrm() ) + else if ((aAnchor.GetAnchorId() != FLY_AT_PAGE) && pDoc->GetRootFrm()) { SwCrsrMoveState aState( MV_SETONLYTEXT ); Point aTmp(MM100_TO_TWIP(aMM100Pos.X), MM100_TO_TWIP(aMM100Pos.Y)); @@ -800,7 +806,7 @@ void SwXDrawPage::add(const uno::Reference< drawing::XShape > & xShape) } else { - aAnchor.SetType(FLY_PAGE); + aAnchor.SetType(FLY_AT_PAGE); // --> OD 2004-08-18 #i32349# - adjustment of vertical positioning // attributes no longer needed, because its already got a default. @@ -853,8 +859,11 @@ uno::Reference< drawing::XShapeGroup > SwXDrawPage::group(const uno::Reference< for ( sal_uInt16 i = 0; !bFlyInCnt && i < rMarkList.GetMarkCount(); ++i ) { const SdrObject *pObj = rMarkList.GetMark( i )->GetMarkedSdrObj(); - if ( FLY_IN_CNTNT == ::FindFrmFmt( (SdrObject*)pObj )->GetAnchor().GetAnchorId() ) + if (FLY_AS_CHAR == ::FindFrmFmt(const_cast( + pObj))->GetAnchor().GetAnchorId()) + { bFlyInCnt = sal_True; + } } if( bFlyInCnt ) throw uno::RuntimeException(); @@ -864,7 +873,9 @@ uno::Reference< drawing::XShapeGroup > SwXDrawPage::group(const uno::Reference< pDoc->StartUndo( UNDO_START, NULL ); SwDrawContact* pContact = pDoc->GroupSelection( *pPage->GetDrawView() ); - pDoc->ChgAnchor( pPage->GetDrawView()->GetMarkedObjectList(), FLY_AT_CNTNT/*int eAnchorId*/, + pDoc->ChgAnchor( + pPage->GetDrawView()->GetMarkedObjectList(), + FLY_AT_PARA/*int eAnchorId*/, sal_True, sal_False ); pPage->GetDrawView()->UnmarkAll(); @@ -899,7 +910,8 @@ void SwXDrawPage::ungroup(const uno::Reference< drawing::XShapeGroup > & xShapeG pDoc->StartUndo( UNDO_START, NULL ); pDoc->UnGroupSelection( *pPage->GetDrawView() ); - pDoc->ChgAnchor( pPage->GetDrawView()->GetMarkedObjectList(), FLY_AT_CNTNT/*int eAnchorId*/, + pDoc->ChgAnchor( pPage->GetDrawView()->GetMarkedObjectList(), + FLY_AT_PARA/*int eAnchorId*/, sal_True, sal_False ); pDoc->EndUndo( UNDO_END, NULL ); } @@ -1274,7 +1286,7 @@ void SwXShape::setPropertyValue(const rtl::OUString& rPropertyName, const uno::A else if ( FN_TEXT_RANGE == pEntry->nWID ) { SwFmtAnchor aAnchor( static_cast(aSet.Get( RES_ANCHOR )) ); - if ( aAnchor.GetAnchorId() == FLY_PAGE ) + if (aAnchor.GetAnchorId() == FLY_AT_PAGE) { // set property not valid for to-page anchored shapes throw lang::IllegalArgumentException(); @@ -1287,7 +1299,7 @@ void SwXShape::setPropertyValue(const rtl::OUString& rPropertyName, const uno::A aValue >>= xRg; if ( SwXTextRange::XTextRangeToSwPaM(*pInternalPam, xRg) ) { - if(aAnchor.GetAnchorId() == FLY_IN_CNTNT) + if (aAnchor.GetAnchorId() == FLY_AS_CHAR) { //delete old SwFmtFlyCnt //With AnchorAsCharacter the current TxtAttribute has to be deleted. @@ -1375,7 +1387,7 @@ void SwXShape::setPropertyValue(const rtl::OUString& rPropertyName, const uno::A SwFrmFmt *pFlyFmt = FindFrmFmt( pObj ); pFlyFmt->DelFrms(); if( text::TextContentAnchorType_AS_CHARACTER != eNewAnchor && - FLY_IN_CNTNT == eOldAnchorId ) + (FLY_AS_CHAR == eOldAnchorId)) { //With AnchorAsCharacter the current TxtAttribute has to be deleted. //Tbis removes the frame format too. @@ -1398,7 +1410,7 @@ void SwXShape::setPropertyValue(const rtl::OUString& rPropertyName, const uno::A pTxtNode->DeleteAttributes(RES_TXTATR_FLYCNT, nIdx); } else if( text::TextContentAnchorType_AT_PAGE != eNewAnchor && - FLY_PAGE == eOldAnchorId ) + (FLY_AT_PAGE == eOldAnchorId)) { SwFmtAnchor aNewAnchor( dynamic_cast< const SwFmtAnchor& >( aSet.Get( RES_ANCHOR ) ) ); //if the fly has been anchored at page then it needs to be connected @@ -1421,7 +1433,7 @@ void SwXShape::setPropertyValue(const rtl::OUString& rPropertyName, const uno::A pFmt->SetFmtAttr(aSet); bSetAttr = false; if( text::TextContentAnchorType_AS_CHARACTER == eNewAnchor && - FLY_IN_CNTNT != eOldAnchorId ) + (FLY_AS_CHAR != eOldAnchorId)) { //the RES_TXTATR_FLYCNT needs to be added now SwTxtNode *pNd = aPam.GetNode()->GetTxtNode(); @@ -1606,7 +1618,7 @@ uno::Any SwXShape::getPropertyValue(const rtl::OUString& rPropertyName) else if ( FN_TEXT_RANGE == pEntry->nWID ) { const SwFmtAnchor aAnchor = pFmt->GetAnchor(); - if ( aAnchor.GetAnchorId() == FLY_PAGE ) + if (aAnchor.GetAnchorId() == FLY_AT_PAGE) { // return nothing, because property isn't // valid for to-page anchored shapes @@ -2180,7 +2192,7 @@ uno::Reference< text::XTextRange > SwXShape::getAnchor(void) throw( uno::Runtim const SwFmtAnchor& rAnchor = pFmt->GetAnchor(); // return an anchor for non-page bound frames // and for page bound frames that have a page no == NULL and a content position - if( rAnchor.GetAnchorId() != FLY_PAGE || + if ((rAnchor.GetAnchorId() != FLY_AT_PAGE) || (rAnchor.GetCntntAnchor() && !rAnchor.GetPageNum())) { const SwPosition &rPos = *(pFmt->GetAnchor().GetCntntAnchor()); @@ -2224,7 +2236,7 @@ void SwXShape::dispose(void) throw( uno::RuntimeException ) pObj->IsInserted() ) // <-- { - if( pFmt->GetAnchor().GetAnchorId() == FLY_IN_CNTNT ) + if (pFmt->GetAnchor().GetAnchorId() == FLY_AS_CHAR) { const SwPosition &rPos = *(pFmt->GetAnchor().GetCntntAnchor()); SwTxtNode *pTxtNode = rPos.nNode.GetNode().GetTxtNode(); diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx index 09066c447546..1f9d39bca94c 100644 --- a/sw/source/core/unocore/unoframe.cxx +++ b/sw/source/core/unocore/unoframe.cxx @@ -45,9 +45,7 @@ #include #include #include -#ifndef _DOCSH_HXX //autogen #include -#endif #include #include #include @@ -1402,7 +1400,8 @@ void SwXFrame::setPropertyValue(const :: OUString& rPropertyName, const :: uno:: aSet.Put(aAnchor); } } - else if(aAnchor.GetAnchorId() != FLY_PAGE && !aAnchor.GetCntntAnchor()) + else if ((aAnchor.GetAnchorId() != FLY_AT_PAGE) && + !aAnchor.GetCntntAnchor()) { SwNode& rNode = pDoc->GetNodes().GetEndOfContent(); SwPaM aPam(rNode); @@ -2023,7 +2022,7 @@ void SwXFrame::dispose(void) throw( uno::RuntimeException ) ( pObj->GetUserCall() && !static_cast(pObj->GetUserCall())->IsInDTOR() ) ) ) { - if( pFmt->GetAnchor().GetAnchorId() == FLY_IN_CNTNT ) + if (pFmt->GetAnchor().GetAnchorId() == FLY_AS_CHAR) { const SwPosition &rPos = *(pFmt->GetAnchor().GetCntntAnchor()); SwTxtNode *pTxtNode = rPos.nNode.GetNode().GetTxtNode(); @@ -2049,7 +2048,7 @@ uno::Reference< text::XTextRange > SwXFrame::getAnchor(void) throw( uno::Runtim const SwFmtAnchor& rAnchor = pFmt->GetAnchor(); // return an anchor for non-page bound frames // and for page bound frames that have a page no == NULL and a content position - if( rAnchor.GetAnchorId() != FLY_PAGE || + if ((rAnchor.GetAnchorId() != FLY_AT_PAGE) || (rAnchor.GetCntntAnchor() && !rAnchor.GetPageNum())) { const SwPosition &rPos = *(rAnchor.GetCntntAnchor()); @@ -2128,7 +2127,7 @@ void SwXFrame::attachToRange(const uno::Reference< text::XTextRange > & xTextRan } const SfxPoolItem* pItem; - RndStdIds eAnchorId = FLY_AT_CNTNT; + RndStdIds eAnchorId = FLY_AT_PARA; if(SFX_ITEM_SET == aFrmSet.GetItemState(RES_ANCHOR, sal_False, &pItem) ) { eAnchorId = ((const SwFmtAnchor*)pItem)->GetAnchorId(); @@ -2136,10 +2135,10 @@ void SwXFrame::attachToRange(const uno::Reference< text::XTextRange > & xTextRan !aPam.GetNode()->FindFlyStartNode()) { //rahmengebunden geht nur dort, wo ein Rahmen ist! - SwFmtAnchor aAnchor(FLY_AT_CNTNT); + SwFmtAnchor aAnchor(FLY_AT_PARA); aFrmSet.Put(aAnchor); } - else if( FLY_PAGE == eAnchorId && + else if ((FLY_AT_PAGE == eAnchorId) && 0 == ((const SwFmtAnchor*)pItem)->GetPageNum() ) { SwFmtAnchor aAnchor( *((const SwFmtAnchor*)pItem) ); @@ -2162,10 +2161,10 @@ void SwXFrame::attachToRange(const uno::Reference< text::XTextRange > & xTextRan SwFmtAnchor* pAnchorItem = 0; // the frame is inserted bound to page // to prevent conflicts if the to-be-anchored position is part of the to-be-copied text - if(eAnchorId != FLY_PAGE) + if (eAnchorId != FLY_AT_PAGE) { pAnchorItem = static_cast(aFrmSet.Get(RES_ANCHOR).Clone()); - aFrmSet.Put( SwFmtAnchor( FLY_PAGE, 1 )); + aFrmSet.Put( SwFmtAnchor( FLY_AT_PAGE, 1 )); } pFmt = pDoc->MakeFlyAndMove( *m_pCopySource, aFrmSet, @@ -2183,8 +2182,10 @@ void SwXFrame::attachToRange(const uno::Reference< text::XTextRange > & xTextRan DELETEZ( m_pCopySource ); } else - pFmt = pDoc->MakeFlySection( FLY_AT_CNTNT, aPam.GetPoint(), + { + pFmt = pDoc->MakeFlySection( FLY_AT_PARA, aPam.GetPoint(), &aFrmSet, pParentFrmFmt ); + } if(pFmt) { pFmt->Add(this); diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index 0d606ab2f50d..26a237b5625a 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -163,7 +163,8 @@ void CollectFrameAtNode( SwClient& rClnt, const SwNodeIndex& rIdx, // gebunden sind SwDoc* pDoc = rIdx.GetNode().GetDoc(); - USHORT nChkType = static_cast< USHORT >(_bAtCharAnchoredObjs ? FLY_AUTO_CNTNT : FLY_AT_CNTNT); + USHORT nChkType = static_cast< USHORT >((_bAtCharAnchoredObjs) + ? FLY_AT_CHAR : FLY_AT_PARA); const SwCntntFrm* pCFrm; const SwCntntNode* pCNd; if( pDoc->GetRootFrm() && diff --git a/sw/source/core/view/vdraw.cxx b/sw/source/core/view/vdraw.cxx index 7429eb5c444d..2e25913611a8 100644 --- a/sw/source/core/view/vdraw.cxx +++ b/sw/source/core/view/vdraw.cxx @@ -46,10 +46,8 @@ #include #ifndef PRODUCT -#ifndef _SVX_FMGLOB_HXX #include #endif -#endif #include "fesh.hxx" #include "pagefrm.hxx" @@ -62,9 +60,8 @@ #include "flyfrm.hxx" #include -#ifndef IDOCUMENTDRAWMODELACCESS_HXX_INCLUDED #include -#endif + /************************************************************************* |* @@ -337,8 +334,10 @@ void SwViewImp::NotifySizeChg( const Size &rNewSz ) const SwFrm *pAnchor = ((SwDrawContact*)pCont)->GetAnchorFrm(); if ( !pAnchor || pAnchor->IsInFly() || !pAnchor->IsValid() || !pAnchor->GetUpper() || !pAnchor->FindPageFrm() || - FLY_IN_CNTNT == pCont->GetFmt()->GetAnchor().GetAnchorId() ) + (FLY_AS_CHAR == pCont->GetFmt()->GetAnchor().GetAnchorId()) ) + { continue; + } // OD 19.06.2003 #108784# - no move for drawing objects in header/footer if ( pAnchor->FindFooterOrHeader() ) diff --git a/sw/source/filter/basflt/shellio.cxx b/sw/source/filter/basflt/shellio.cxx index e21433271845..4d849174ddba 100644 --- a/sw/source/filter/basflt/shellio.cxx +++ b/sw/source/filter/basflt/shellio.cxx @@ -34,9 +34,7 @@ #include #include #include -#ifndef SVTOOLS_FSTATHELPER_HXX #include -#endif #include #include #include @@ -60,9 +58,7 @@ #include #include #include -#ifndef _DOCSH_HXX #include -#endif #include #include @@ -72,6 +68,7 @@ #include // <-- + using namespace ::com::sun::star; ////////////////////////////////////////////////////////////////////////// @@ -241,9 +238,9 @@ ULONG SwReader::Read( const Reader& rOptions ) { SwPosition const*const pFrameAnchor( rAnchor.GetCntntAnchor()); - if ( (FLY_PAGE == rAnchor.GetAnchorId()) + if ( (FLY_AT_PAGE == rAnchor.GetAnchorId()) || ( pFrameAnchor - && ( ( (FLY_AT_CNTNT == rAnchor.GetAnchorId()) + && ( ( (FLY_AT_PARA == rAnchor.GetAnchorId()) && ( (pUndoPam->GetPoint()->nNode == pFrameAnchor->nNode) || (pUndoPam->GetMark()->nNode == @@ -251,7 +248,7 @@ ULONG SwReader::Read( const Reader& rOptions ) ) ) // #i97570# also check frames anchored AT char - || ( (FLY_AUTO_CNTNT == rAnchor.GetAnchorId()) + || ( (FLY_AT_CHAR == rAnchor.GetAnchorId()) && !IsDestroyFrameAnchoredAtChar( *pFrameAnchor, *pUndoPam->GetPoint(), @@ -262,7 +259,7 @@ ULONG SwReader::Read( const Reader& rOptions ) ) { if( bChkHeaderFooter && - FLY_AT_CNTNT == rAnchor.GetAnchorId() && + (FLY_AT_PARA == rAnchor.GetAnchorId()) && RES_DRAWFRMFMT == pFrmFmt->Which() ) { // DrawObjecte in Kopf-/Fusszeilen ist nicht @@ -286,15 +283,19 @@ ULONG SwReader::Read( const Reader& rOptions ) pFrmFmt->DelFrms(); } - if( FLY_PAGE == rAnchor.GetAnchorId() ) + if (FLY_AT_PAGE == rAnchor.GetAnchorId()) { if( !rAnchor.GetCntntAnchor() ) + { pFrmFmt->MakeFrms(); + } else if( pCrsr ) + { // seitengebundene Flys eingefuegt, dann schalte // die Optimierungs-Flags vom SwDoc ab. Sonst // werden die Flys nicht an der Position erzeugt. pDoc->SetLoaded( FALSE ); + } } else pFrmFmt->MakeFrms(); diff --git a/sw/source/filter/html/css1atr.cxx b/sw/source/filter/html/css1atr.cxx index 01108a0d2567..33c354fbfebe 100644 --- a/sw/source/filter/html/css1atr.cxx +++ b/sw/source/filter/html/css1atr.cxx @@ -35,9 +35,7 @@ #include "hintids.hxx" #include -#ifndef _WRKWIN_HXX //autogen #include -#endif #include #include #include @@ -2130,8 +2128,8 @@ void SwHTMLWriter::OutCSS1_FrmFmtOptions( const SwFrmFmt& rFrmFmt, const SwFmtAnchor& rAnchor = rFrmFmt.GetAnchor(); switch( rAnchor.GetAnchorId() ) { - case FLY_AT_CNTNT: - case FLY_AUTO_CNTNT: + case FLY_AT_PARA: + case FLY_AT_CHAR: if( text::RelOrientation::FRAME == rHoriOri.GetRelationOrient() || text::RelOrientation::PRINT_AREA == rHoriOri.GetRelationOrient() ) { @@ -2146,7 +2144,7 @@ void SwHTMLWriter::OutCSS1_FrmFmtOptions( const SwFrmFmt& rFrmFmt, break; } - case FLY_PAGE: + case FLY_AT_PAGE: case FLY_AT_FLY: { // position @@ -2375,7 +2373,7 @@ void SwHTMLWriter::OutCSS1_FrmFmtBackground( const SwFrmFmt& rFrmFmt ) const SwFmtAnchor& rAnchor = rFrmFmt.GetAnchor(); RndStdIds eAnchorId = rAnchor.GetAnchorId(); const SwPosition *pAnchorPos = rAnchor.GetCntntAnchor(); - if( FLY_PAGE != eAnchorId && pAnchorPos ) + if (FLY_AT_PAGE != eAnchorId && pAnchorPos) { const SwNode& rNode = pAnchorPos->nNode.GetNode(); if( rNode.IsCntntNode() ) diff --git a/sw/source/filter/html/htmlcss1.cxx b/sw/source/filter/html/htmlcss1.cxx index 7fb4fd8502af..89af81314b99 100644 --- a/sw/source/filter/html/htmlcss1.cxx +++ b/sw/source/filter/html/htmlcss1.cxx @@ -39,17 +39,12 @@ #include #include #include -#ifndef _APP_HXX //autogen #include -#endif #include #include #include #include -#ifndef _SVX_BOXITEM_HXX //autogen - #include -#endif #include #include #include @@ -2094,7 +2089,7 @@ void SwHTMLParser::SetAnchorAndAdjustment( const SfxItemSet & /*rItemSet*/, } else { - aAnchor.SetType( FLY_PAGE ); + aAnchor.SetType( FLY_AT_PAGE ); aAnchor.SetPageNum( 1 ); } nHoriPos = rPropInfo.nLeft; @@ -2102,7 +2097,7 @@ void SwHTMLParser::SetAnchorAndAdjustment( const SfxItemSet & /*rItemSet*/, } else { - aAnchor.SetType( FLY_AT_CNTNT ); + aAnchor.SetType( FLY_AT_PARA ); aAnchor.SetAnchor( pPam->GetPoint() ); eVertOri = text::VertOrientation::TOP; eVertRel = text::RelOrientation::CHAR; @@ -2128,14 +2123,14 @@ void SwHTMLParser::SetAnchorAndAdjustment( const SfxItemSet & /*rItemSet*/, xub_StrLen nCntnt = pPam->GetPoint()->nContent.GetIndex(); if( nCntnt ) { - aAnchor.SetType( FLY_AUTO_CNTNT ); + aAnchor.SetType( FLY_AT_CHAR ); pPam->Move( fnMoveBackward ); eVertOri = text::VertOrientation::CHAR_BOTTOM; eVertRel = text::RelOrientation::CHAR; } else { - aAnchor.SetType( FLY_AT_CNTNT ); + aAnchor.SetType( FLY_AT_PARA ); eVertOri = text::VertOrientation::TOP; eVertRel = text::RelOrientation::PRINT_AREA; } diff --git a/sw/source/filter/html/htmldraw.cxx b/sw/source/filter/html/htmldraw.cxx index 328eb21be526..e3b3af0029a7 100644 --- a/sw/source/filter/html/htmldraw.cxx +++ b/sw/source/filter/html/htmldraw.cxx @@ -34,9 +34,7 @@ #include "hintids.hxx" #include -#ifndef _WRKWIN_HXX //autogen #include -#endif #include #include #include @@ -182,7 +180,7 @@ void SwHTMLParser::InsertDrawObject( SdrObject* pNewDrawObj, aFrmSet.Put( aULItem ); } - SwFmtAnchor aAnchor( FLY_IN_CNTNT ); + SwFmtAnchor aAnchor( FLY_AS_CHAR ); if( SVX_CSS1_POS_ABSOLUTE == rCSS1PropInfo.ePosition && SVX_CSS1_LTYPE_TWIP == rCSS1PropInfo.eLeftType && SVX_CSS1_LTYPE_TWIP == rCSS1PropInfo.eTopType ) @@ -198,7 +196,7 @@ void SwHTMLParser::InsertDrawObject( SdrObject* pNewDrawObj, } else { - aAnchor.SetType( FLY_PAGE ); + aAnchor.SetType( FLY_AT_PAGE ); } // OD 2004-04-13 #i26791# - direct positioning for pNewDrawObj->SetRelativePos( Point(rCSS1PropInfo.nLeft + nLeftSpace, @@ -208,7 +206,7 @@ void SwHTMLParser::InsertDrawObject( SdrObject* pNewDrawObj, else if( SVX_ADJUST_LEFT == rCSS1PropInfo.eFloat || text::HoriOrientation::LEFT == eHoriOri ) { - aAnchor.SetType( FLY_AT_CNTNT ); + aAnchor.SetType( FLY_AT_PARA ); aFrmSet.Put( SwFmtSurround(bHidden ? SURROUND_THROUGHT : SURROUND_RIGHT) ); // OD 2004-04-13 #i26791# - direct positioning for @@ -219,10 +217,14 @@ void SwHTMLParser::InsertDrawObject( SdrObject* pNewDrawObj, aFrmSet.Put( SwFmtVertOrient( 0, eVertOri ) ); } - if( FLY_PAGE == aAnchor.GetAnchorId() ) + if (FLY_AT_PAGE == aAnchor.GetAnchorId()) + { aAnchor.SetPageNum( 1 ); + } else if( FLY_AT_FLY != aAnchor.GetAnchorId() ) + { aAnchor.SetAnchor( pPam->GetPoint() ); + } aFrmSet.Put( aAnchor ); pDoc->Insert( *pPam, *pNewDrawObj, &aFrmSet, NULL ); diff --git a/sw/source/filter/html/htmlfly.cxx b/sw/source/filter/html/htmlfly.cxx index 92f9e1adb3d5..acbcb8eb0c25 100644 --- a/sw/source/filter/html/htmlfly.cxx +++ b/sw/source/filter/html/htmlfly.cxx @@ -39,12 +39,8 @@ #include "hintids.hxx" #include #include -#ifndef _APP_HXX #include -#endif -#ifndef _WRKWIN_HXX //autogen #include -#endif #include #include #include @@ -338,12 +334,12 @@ void SwHTMLWriter::CollectFlyFrms() sal_Int16 eHoriRel = rFrmFmt.GetHoriOrient().GetRelationOrient(); switch( rAnchor.GetAnchorId() ) { - case FLY_PAGE: + case FLY_AT_PAGE: case FLY_AT_FLY: nMode = aHTMLOutFrmPageFlyTable[eType][nExportMode]; break; - case FLY_AT_CNTNT: + case FLY_AT_PARA: // Absatz-gebundene Rahmen werden nur dann vor den // Absatz geschrieben, wenn der Absatz einen Abstand // hat. @@ -362,7 +358,7 @@ void SwHTMLWriter::CollectFlyFrms() nMode = aHTMLOutFrmParaPrtAreaTable[eType][nExportMode]; break; - case FLY_AUTO_CNTNT: + case FLY_AT_CHAR: if( text::RelOrientation::FRAME == eHoriRel || text::RelOrientation::PRINT_AREA == eHoriRel ) nMode = aHTMLOutFrmParaPrtAreaTable[eType][nExportMode]; else @@ -594,7 +590,7 @@ void SwHTMLWriter::OutFrmFmtOptions( const SwFrmFmt &rFrmFmt, const sal_Char *pStr = 0; RndStdIds eAnchorId = rFrmFmt.GetAnchor().GetAnchorId(); if( (nFrmOpts & HTML_FRMOPT_ALIGN) && - (FLY_AT_CNTNT == eAnchorId || FLY_AUTO_CNTNT == eAnchorId) ) + ((FLY_AT_PARA == eAnchorId) || (FLY_AT_CHAR == eAnchorId)) ) { // MIB 12.3.98: Ist es nicht schlauer, absatzgebundene // Rahmen notfalls links auszurichten als sie @@ -611,7 +607,7 @@ void SwHTMLWriter::OutFrmFmtOptions( const SwFrmFmt &rFrmFmt, } if( (nFrmOpts & HTML_FRMOPT_ALIGN) && !pStr && ( (nFrmOpts & HTML_FRMOPT_S_ALIGN) == 0 || - FLY_IN_CNTNT == eAnchorId ) && + (FLY_AS_CHAR == eAnchorId) ) && SFX_ITEM_SET == rItemSet.GetItemState( RES_VERT_ORIENT, TRUE, &pItem )) { switch( ((SwFmtVertOrient*)pItem)->GetVertOrient() ) @@ -764,8 +760,8 @@ void SwHTMLWriter::OutFrmFmtOptions( const SwFrmFmt &rFrmFmt, // Umlauf fuer absatzgeb. Grafiken als
in den String // schreiben if( (nFrmOpts & HTML_FRMOPT_BRCLEAR) && - (FLY_AT_CNTNT== rFrmFmt.GetAnchor().GetAnchorId() || - FLY_AUTO_CNTNT== rFrmFmt.GetAnchor().GetAnchorId()) && + ((FLY_AT_PARA == rFrmFmt.GetAnchor().GetAnchorId()) || + (FLY_AT_CHAR == rFrmFmt.GetAnchor().GetAnchorId())) && SFX_ITEM_SET == rItemSet.GetItemState( RES_SURROUND, TRUE, &pItem )) { const SwFmtSurround* pSurround = (const SwFmtSurround*)pItem; @@ -1893,7 +1889,7 @@ SwHTMLPosFlyFrm::SwHTMLPosFlyFrm( const SwPosFlyFrm& rPosFly, nOutputMode( nOutMode ) { const SwFmtAnchor& rAnchor = rPosFly.GetFmt().GetAnchor(); - if( FLY_AUTO_CNTNT==rAnchor.GetAnchorId() && + if ((FLY_AT_CHAR == rAnchor.GetAnchorId()) && HTML_POS_INSIDE == GetOutPos() ) { // Auto-gebundene Rahmen werden ein Zeichen weiter hinten diff --git a/sw/source/filter/html/htmlforw.cxx b/sw/source/filter/html/htmlforw.cxx index 147e736a4353..575cbc4c719e 100644 --- a/sw/source/filter/html/htmlforw.cxx +++ b/sw/source/filter/html/htmlforw.cxx @@ -45,18 +45,14 @@ #include #include #include -#ifndef _WRKWIN_HXX //autogen #include -#endif #include #include #include #include #include #include "svtools/urihelper.hxx" -#ifndef _TOOLKIT_UNOHLP_HXX #include -#endif #include #include #include @@ -81,6 +77,7 @@ #include "htmlfly.hxx" #include "htmlform.hxx" + using namespace ::com::sun::star; using ::rtl::OUString; /* */ @@ -1427,7 +1424,7 @@ void SwHTMLWriter::GetControls() const SwFmtAnchor& rAnchor = pFrmFmt->GetAnchor(); const SwPosition *pPos = rAnchor.GetCntntAnchor(); - if( FLY_IN_CNTNT != rAnchor.GetAnchorId() || !pPos ) + if ((FLY_AS_CHAR != rAnchor.GetAnchorId()) || !pPos) continue; const SdrObject *pSdrObj = diff --git a/sw/source/filter/html/htmlgrin.cxx b/sw/source/filter/html/htmlgrin.cxx index d18a2b762aa0..eaf43495fe1e 100644 --- a/sw/source/filter/html/htmlgrin.cxx +++ b/sw/source/filter/html/htmlgrin.cxx @@ -33,9 +33,7 @@ #include "hintids.hxx" #include -#ifndef _WRKWIN_HXX //autogen #include -#endif #include #include #include @@ -208,7 +206,7 @@ void SwHTMLParser::SetAnchorAndAdjustment( sal_Int16 eVertOri, BOOL bDontAppend ) { BOOL bMoveBackward = FALSE; - SwFmtAnchor aAnchor( FLY_IN_CNTNT ); + SwFmtAnchor aAnchor( FLY_AS_CHAR ); sal_Int16 eVertRel = text::RelOrientation::FRAME; if( text::HoriOrientation::NONE != eHoriOri ) @@ -267,14 +265,14 @@ void SwHTMLParser::SetAnchorAndAdjustment( sal_Int16 eVertOri, xub_StrLen nCntnt = pPam->GetPoint()->nContent.GetIndex(); if( nCntnt ) { - aAnchor.SetType( FLY_AUTO_CNTNT ); + aAnchor.SetType( FLY_AT_CHAR ); bMoveBackward = TRUE; eVertOri = text::VertOrientation::CHAR_BOTTOM; eVertRel = text::RelOrientation::CHAR; } else { - aAnchor.SetType( FLY_AT_CNTNT ); + aAnchor.SetType( FLY_AT_PARA ); eVertOri = text::VertOrientation::TOP; eVertRel = text::RelOrientation::PRINT_AREA; } @@ -301,7 +299,7 @@ void SwHTMLParser::RegisterFlyFrm( SwFrmFmt *pFlyFmt ) // automatisch verankerte Rahmen muessen noch um eine Position // nach vorne verschoben werden. if( RES_DRAWFRMFMT != pFlyFmt->Which() && - FLY_AT_CNTNT == pFlyFmt->GetAnchor().GetAnchorId() && + (FLY_AT_PARA == pFlyFmt->GetAnchor().GetAnchorId()) && SURROUND_THROUGHT == pFlyFmt->GetSurround().GetSurround() ) { aMoveFlyFrms.Insert( pFlyFmt, aMoveFlyFrms.Count() ); @@ -778,7 +776,7 @@ IMAGE_SETEVENT: aMacroItem.SetMacro( aEvents[ n ], *pMacro ); } - if( FLY_IN_CNTNT == pFlyFmt->GetAnchor().GetAnchorId() && + if ((FLY_AS_CHAR == pFlyFmt->GetAnchor().GetAnchorId()) && aAttrTab.pINetFmt->GetSttPara() == pPam->GetPoint()->nNode && aAttrTab.pINetFmt->GetSttCnt() == @@ -1342,20 +1340,16 @@ void SwHTMLParser::StripTrailingPara() { ULONG nNodeIdx = pPam->GetPoint()->nNode.GetIndex(); - USHORT i; - - const SwFrmFmt* pFmt; - const SwFmtAnchor* pAnchor; - const SwPosition* pAPos; const SwSpzFrmFmts& rFrmFmtTbl = *pDoc->GetSpzFrmFmts(); - for( i=0; iGetAnchor(); - if( 0 != ( pAPos = pAnchor->GetCntntAnchor()) && - (FLY_AT_CNTNT == pAnchor->GetAnchorId() || - FLY_AUTO_CNTNT == pAnchor->GetAnchorId()) && + SwFrmFmt const*const pFmt = rFrmFmtTbl[i]; + SwFmtAnchor const*const pAnchor = &pFmt->GetAnchor(); + SwPosition const*const pAPos = pAnchor->GetCntntAnchor(); + if (pAPos && + ((FLY_AT_PARA == pAnchor->GetAnchorId()) || + (FLY_AT_CHAR == pAnchor->GetAnchorId())) && pAPos->nNode == nNodeIdx ) return; // den Knoten duerfen wir nicht loeschen diff --git a/sw/source/filter/html/htmlplug.cxx b/sw/source/filter/html/htmlplug.cxx index 21e409c48530..a003678013da 100644 --- a/sw/source/filter/html/htmlplug.cxx +++ b/sw/source/filter/html/htmlplug.cxx @@ -33,8 +33,6 @@ #include #include - - #include "hintids.hxx" #include #define _SVSTDARR_ULONGS @@ -42,9 +40,7 @@ #include #include #include -#ifndef _WRKWIN_HXX //autogen #include -#endif #include #include #include @@ -465,7 +461,7 @@ void SwHTMLParser::InsertEmbed() } else { - SwFmtAnchor aAnchor( FLY_AT_CNTNT ); + SwFmtAnchor aAnchor( FLY_AT_PARA ); aAnchor.SetAnchor( pPam->GetPoint() ); aFrmSet.Put( aAnchor ); aFrmSet.Put( SwFmtHoriOrient( 0, text::HoriOrientation::LEFT, text::RelOrientation::FRAME) ); @@ -1167,7 +1163,7 @@ Writer& OutHTML_FrmFmtOLENode( Writer& rWrt, const SwFrmFmt& rFrmFmt, sOut = '\"'; } - if( FLY_AT_CNTNT == rFrmFmt.GetAnchor().GetAnchorId() && + if ((FLY_AT_PARA == rFrmFmt.GetAnchor().GetAnchorId()) && SURROUND_THROUGHT == rFrmFmt.GetSurround().GetSurround() ) { // Das Plugin ist HIDDEN diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx index 551ebf937be2..9f13486da684 100644 --- a/sw/source/filter/html/swhtml.cxx +++ b/sw/source/filter/html/swhtml.cxx @@ -2837,7 +2837,7 @@ void SwHTMLParser::_SetAttr( BOOL bChkEnd, BOOL bBeforeTable, SwFrmFmt *pFrmFmt = aMoveFlyFrms[ --n ]; const SwFmtAnchor& rAnchor = pFrmFmt->GetAnchor(); - ASSERT( FLY_AT_CNTNT==rAnchor.GetAnchorId(), + ASSERT( FLY_AT_PARA == rAnchor.GetAnchorId(), "Nur Auto-Rahmen brauchen eine Spezialbehandlung" ); const SwPosition *pFlyPos = rAnchor.GetCntntAnchor(); ULONG nFlyParaIdx = pFlyPos->nNode.GetIndex(); @@ -2862,7 +2862,7 @@ void SwHTMLParser::_SetAttr( BOOL bChkEnd, BOOL bBeforeTable, pAttrPam->GetPoint()->nContent.Assign( pAttrPam->GetCntntNode(), aMoveFlyCnts[n] ); SwFmtAnchor aAnchor( rAnchor ); - aAnchor.SetType( FLY_AUTO_CNTNT ); + aAnchor.SetType( FLY_AT_CHAR ); aAnchor.SetAnchor( pAttrPam->GetPoint() ); pFrmFmt->SetFmtAttr( aAnchor ); @@ -4411,27 +4411,23 @@ BOOL SwHTMLParser::HasCurrentParaFlys( BOOL bNoSurroundOnly, // sonst: Der Absatz enthaelt irgendeinen Rahmen SwNodeIndex& rNodeIdx = pPam->GetPoint()->nNode; - SwFrmFmt* pFmt; - const SwFmtAnchor* pAnchor; - const SwPosition* pAPos; const SwSpzFrmFmts& rFrmFmtTbl = *pDoc->GetSpzFrmFmts(); - USHORT i; BOOL bFound = FALSE; - for( i=0; iGetAnchor(); + SwFrmFmt *const pFmt = rFrmFmtTbl[i]; + SwFmtAnchor const*const pAnchor = &pFmt->GetAnchor(); // Ein Rahmen wurde gefunden, wenn // - er absatzgebunden ist, und // - im aktuellen Absatz verankert ist, und // - jeder absatzgebunene Rahmen zaehlt, oder // - (nur Rahmen oder umlauf zaehlen und ) der Rahmen keinen // Umlauf besitzt - - if( 0 != ( pAPos = pAnchor->GetCntntAnchor()) && - (FLY_AT_CNTNT == pAnchor->GetAnchorId() || - FLY_AUTO_CNTNT == pAnchor->GetAnchorId()) && + SwPosition const*const pAPos = pAnchor->GetCntntAnchor(); + if (pAPos && + ((FLY_AT_PARA == pAnchor->GetAnchorId()) || + (FLY_AT_CHAR == pAnchor->GetAnchorId())) && pAPos->nNode == rNodeIdx ) { if( !(bNoSurroundOnly || bSurroundOnly) ) @@ -5073,18 +5069,16 @@ void SwHTMLParser::InsertLineBreak() SwTxtNode* pTxtNd = rNodeIdx.GetNode().GetTxtNode(); if( pTxtNd ) { - SwFrmFmt* pFmt; - const SwFmtAnchor* pAnchor; - const SwPosition* pAPos; const SwSpzFrmFmts& rFrmFmtTbl = *pDoc->GetSpzFrmFmts(); for( USHORT i=0; iGetAnchor(); - if( 0 != ( pAPos = pAnchor->GetCntntAnchor()) && - (FLY_AT_CNTNT == pAnchor->GetAnchorId() || - FLY_AUTO_CNTNT == pAnchor->GetAnchorId()) && + SwFrmFmt *const pFmt = rFrmFmtTbl[i]; + SwFmtAnchor const*const pAnchor = &pFmt->GetAnchor(); + SwPosition const*const pAPos = pAnchor->GetCntntAnchor(); + if (pAPos && + ((FLY_AT_PARA == pAnchor->GetAnchorId()) || + (FLY_AT_CHAR == pAnchor->GetAnchorId())) && pAPos->nNode == rNodeIdx && pFmt->GetSurround().GetSurround() != SURROUND_NONE ) { diff --git a/sw/source/filter/inc/fltshell.hxx b/sw/source/filter/inc/fltshell.hxx index ec836f2b8549..036933bd4a67 100644 --- a/sw/source/filter/inc/fltshell.hxx +++ b/sw/source/filter/inc/fltshell.hxx @@ -36,9 +36,7 @@ #include #include #include -#ifndef _KEYCOD_HXX //autogen #include -#endif #include #include #include @@ -556,7 +554,7 @@ public: pOut->EndTable(); } // methoden zur verwaltung von Flys BOOL IsInFly() { return pOut->IsInFly(); } - BOOL BeginFly( RndStdIds eAnchor = FLY_AT_CNTNT, BOOL bAbsolutePos = FALSE ); + BOOL BeginFly( RndStdIds eAnchor = FLY_AT_PARA, BOOL bAbsolutePos = FALSE ); void SetFlyAnchor( RndStdIds eAnchor ) { pOut->SetFlyAnchor( eAnchor ); } void SetFlyXPos( short nXPos, sal_Int16 eHRel = com::sun::star::text::RelOrientation::FRAME, diff --git a/sw/source/filter/rtf/rtfatr.cxx b/sw/source/filter/rtf/rtfatr.cxx index fc60c857aedb..1f2e60f7c87d 100644 --- a/sw/source/filter/rtf/rtfatr.cxx +++ b/sw/source/filter/rtf/rtfatr.cxx @@ -38,9 +38,7 @@ */ #include -#ifndef _COM_SUN_STAR_I18N_SCRIPTTYPE_HDL_ #include -#endif #include #include #include @@ -50,9 +48,7 @@ #include #include #include -#ifndef _SVX_TSTPITEM_HXX //autogen #include -#endif #include #include #include @@ -72,16 +68,12 @@ #include #include #include -#ifndef _SVX_CNTRITEM_HXX //autogen #include -#endif #include #include #include #include -#ifndef _SVX_EMPHITEM_HXX #include -#endif #include #include #include @@ -127,9 +119,7 @@ #include #include // fuer SwPageDesc ... #include // fuer SwPageDesc ... -#ifndef _DOCSH_HXX #include -#endif #include #include #include @@ -3592,7 +3582,7 @@ static Writer& OutRTF_SwFmtVertOrient ( Writer& rWrt, const SfxPoolItem& rHt ) const char* pOrient; RndStdIds eAnchor = rRTFWrt.pFlyFmt->GetAnchor().GetAnchorId(); sal_Int16 eOrient = rFlyVert.GetRelationOrient(); - if( FLY_PAGE == eAnchor ) + if (FLY_AT_PAGE == eAnchor) { if( text::RelOrientation::PAGE_FRAME == eOrient || text::RelOrientation::FRAME == eOrient ) pOrient = OOO_STRING_SVTOOLS_RTF_PVPG; @@ -3648,7 +3638,7 @@ static Writer& OutRTF_SwFmtHoriOrient( Writer& rWrt, const SfxPoolItem& rHt ) const char* pS; RndStdIds eAnchor = rRTFWrt.pFlyFmt->GetAnchor().GetAnchorId(); sal_Int16 eOrient = rFlyHori.GetRelationOrient(); - if( FLY_PAGE == eAnchor ) + if (FLY_AT_PAGE == eAnchor) { if( text::RelOrientation::PAGE_FRAME == eOrient || text::RelOrientation::FRAME == eOrient ) pS = OOO_STRING_SVTOOLS_RTF_PHPG; @@ -3702,12 +3692,12 @@ static Writer& OutRTF_SwFmtAnchor( Writer& rWrt, const SfxPoolItem& rHt ) rRTFWrt.bOutFmtAttr = TRUE; switch( nId ) { - case FLY_PAGE: + case FLY_AT_PAGE: rWrt.Strm() << OOO_STRING_SVTOOLS_RTF_FLYPAGE; rWrt.OutULong( rAnchor.GetPageNum() ); break; - case FLY_AT_CNTNT: - case FLY_IN_CNTNT: + case FLY_AT_PARA: + case FLY_AS_CHAR: rWrt.Strm() << OOO_STRING_SVTOOLS_RTF_FLYCNTNT; break; } diff --git a/sw/source/filter/rtf/rtffly.cxx b/sw/source/filter/rtf/rtffly.cxx index e4043f2e8529..0bfdaa0b206b 100644 --- a/sw/source/filter/rtf/rtffly.cxx +++ b/sw/source/filter/rtf/rtffly.cxx @@ -64,15 +64,9 @@ #include #include #include -#ifndef __SGI_STL_DEQUE #include -#endif -#ifndef __SGI_STL_MAP #include -#endif -#ifndef __SGI_STL_UTILITY #include -#endif // --> OD 2004-06-30 #i27767# #include // <-- @@ -82,6 +76,7 @@ #include "dcontact.hxx" // <-- + using namespace ::com::sun::star; #define ANCHOR(p) ((SwFmtAnchor*)p) @@ -459,7 +454,7 @@ void SwRTFParser::SetFlysInDoc() SwFlyFrmFmt* pFmt = pDoc->MakeFlyFrmFmt( aEmptyStr, pParent ); pFmt->SetFmtAttr( pFlySave->aFlySet ); const SwFmtAnchor& rAnchor = pFmt->GetAnchor(); - if( FLY_IN_CNTNT != rAnchor.GetAnchorId() ) + if (FLY_AS_CHAR != rAnchor.GetAnchorId()) { // korrigiere noch den Absatz, ist immer der vorhergehende ! // JP 20.09.95: wenn es diesen gibt! (DocAnfang!) @@ -568,7 +563,7 @@ void SwRTFParser::ReadFly( int nToken, SfxItemSet* pSet ) // RTF-Defaults setzen: // --> OD 2004-06-24 #i27767# - SwFmtAnchor aAnchor( FLY_AT_CNTNT ); + SwFmtAnchor aAnchor( FLY_AT_PARA ); SwFmtHoriOrient aHori( 0, text::HoriOrientation::LEFT, text::RelOrientation::FRAME ); SwFmtVertOrient aVert( 0, text::VertOrientation::TOP, text::RelOrientation::FRAME ); @@ -844,7 +839,7 @@ void SwRTFParser::ReadFly( int nToken, SfxItemSet* pSet ) switch( GetNextToken() ) { case RTF_FLY_PAGE: - aAnchor.SetType( FLY_PAGE ); + aAnchor.SetType( FLY_AT_PAGE ); aAnchor.SetPageNum( USHORT(nTokenValue)); aAnchor.SetAnchor( 0 ); break; @@ -854,7 +849,7 @@ void SwRTFParser::ReadFly( int nToken, SfxItemSet* pSet ) SwNodeIndex aIdx( pPam->GetPoint()->nNode ); pDoc->GetNodes().GoPrevious( &aIdx ); SwPosition aPos( aIdx ); - aAnchor.SetType( FLY_AT_CNTNT ); + aAnchor.SetType( FLY_AT_PARA ); aAnchor.SetAnchor( &aPos ); } break; @@ -1288,7 +1283,7 @@ void SwRTFParser::InsPicture( const String& rGrfNm, const Graphic* pGrf, RES_VERT_ORIENT,*/ RES_ANCHOR ); const SwPosition* pPos = pPam->GetPoint(); - SwFmtAnchor aAnchor( FLY_IN_CNTNT ); + SwFmtAnchor aAnchor( FLY_AS_CHAR ); aAnchor.SetAnchor( pPos ); aFlySet.Put( aAnchor ); aFlySet.Put( SwFmtVertOrient( 0, text::VertOrientation::TOP )); diff --git a/sw/source/filter/rtf/swparrtf.cxx b/sw/source/filter/rtf/swparrtf.cxx index 9b5b90a01641..c23cdb521491 100644 --- a/sw/source/filter/rtf/swparrtf.cxx +++ b/sw/source/filter/rtf/swparrtf.cxx @@ -35,18 +35,14 @@ #include -#ifndef __RSC //autogen #include -#endif #include #include #include #include #include #include -#ifndef _SVX_TSTPITEM_HXX //autogen #include -#endif #include #include #include @@ -82,18 +78,14 @@ #include #include #include -#ifndef _SECTIOM_HXX #include -#endif #include #include #include #include #include #include -#ifndef _CMDID_H #include -#endif #ifndef _STATSTR_HRC #include // ResId fuer Statusleiste #endif @@ -471,8 +463,8 @@ if( pSttNdIdx->GetIndex()+1 == pPam->GetBound( FALSE ).nNode.GetIndex() ) for ( USHORT nI = pFrmFmts->Count(); nI; --nI ) { const SwFmtAnchor & rAnchor = (*pFrmFmts)[ nI - 1 ]->GetAnchor(); - if ( FLY_AT_CNTNT == rAnchor.GetAnchorId() || - FLY_AUTO_CNTNT == rAnchor.GetAnchorId() ) + if ((FLY_AT_PARA == rAnchor.GetAnchorId()) || + (FLY_AT_CHAR == rAnchor.GetAnchorId())) { const SwPosition * pObjPos = rAnchor.GetCntntAnchor(); if ( pObjPos && nNodeIdx == pObjPos->nNode.GetIndex() ) @@ -1270,14 +1262,7 @@ void SwRTFParser::ReadDrawingObject() sw::util::SetLayer aSetLayer(*pDoc); aSetLayer.SendObjectToHeaven(*pStroke); */ - /* - FLY_AT_CNTNT, //Absatzgebundener Rahmen - FLY_IN_CNTNT, //Zeichengebundener Rahmen - FLY_PAGE, //Seitengebundener Rahmen - FLY_AT_FLY, //Rahmengebundener Rahmen ( LAYER_IMPL ) - FLY_AUTO_CNTNT, //Automatisch positionierter, absatzgebundener Rahmen - */ - SwFmtAnchor aAnchor( FLY_AT_CNTNT ); + SwFmtAnchor aAnchor( FLY_AT_PARA ); aAnchor.SetAnchor( pPam->GetPoint() ); aFlySet.Put( aAnchor ); @@ -1343,7 +1328,7 @@ void SwRTFParser::InsertShpObject(SdrObject* pStroke, int _nZOrder) SwFmtFollowTextFlow aFollowTextFlow( FALSE ); aFlySet.Put( aFollowTextFlow ); - SwFmtAnchor aAnchor( FLY_AT_CNTNT ); + SwFmtAnchor aAnchor( FLY_AT_PARA ); aAnchor.SetAnchor( pPam->GetPoint() ); aFlySet.Put( aAnchor ); @@ -3710,8 +3695,9 @@ void SwRTFParser::ReadHeaderFooter( int nToken, SwPageDesc* pPageDesc ) xub_StrLen nPos = pPam->GetPoint()->nContent.GetIndex(); SfxItemSet aSet( pDoc->GetAttrPool(), RES_FRMATR_BEGIN, RES_FRMATR_END-1 ); - aSet.Put( SwFmtAnchor( FLY_IN_CNTNT )); - pHdFtFmt = pDoc->MakeFlySection( FLY_IN_CNTNT, pPam->GetPoint(), &aSet ); + aSet.Put( SwFmtAnchor( FLY_AS_CHAR )); + pHdFtFmt = pDoc->MakeFlySection( FLY_AS_CHAR, + pPam->GetPoint(), &aSet ); pTxtAttr = pPam->GetNode()->GetTxtNode()->GetTxtAttrForCharAt( nPos, RES_TXTATR_FLYCNT ); diff --git a/sw/source/filter/rtf/wrtrtf.cxx b/sw/source/filter/rtf/wrtrtf.cxx index d0129f29380f..bcfafdd0c28f 100644 --- a/sw/source/filter/rtf/wrtrtf.cxx +++ b/sw/source/filter/rtf/wrtrtf.cxx @@ -46,9 +46,7 @@ #include #include #include -#ifndef _SVX_TSTPITEM_HXX //autogen #include -#endif #include #include #include @@ -85,6 +83,7 @@ #include #include + #if defined(UNX) const sal_Char SwRTFWriter::sNewLine = '\012'; #else @@ -1129,7 +1128,7 @@ bool ExportAsInline(const SwFlyFrmFmt& rFlyFrmFmt) { //if not an inline element (hack in our limitations here as to only //graphics like this!!!! - return rFlyFrmFmt.GetAnchor().GetAnchorId() == FLY_IN_CNTNT; + return rFlyFrmFmt.GetAnchor().GetAnchorId() == FLY_AS_CHAR; } void SwRTFWriter::OutRTFFlyFrms(const SwFlyFrmFmt& rFlyFrmFmt) @@ -1779,7 +1778,7 @@ short SwRTFWriter::TrueFrameDirection(const SwFrmFmt &rFlyFmt) const { pItem = 0; const SwFmtAnchor* pAnchor = &pFlyFmt2->GetAnchor(); - if( FLY_PAGE != pAnchor->GetAnchorId() && + if ((FLY_AT_PAGE != pAnchor->GetAnchorId()) && pAnchor->GetCntntAnchor() ) { pFlyFmt2 = pAnchor->GetCntntAnchor()->nNode. diff --git a/sw/source/filter/ww1/fltshell.cxx b/sw/source/filter/ww1/fltshell.cxx index 822091cec765..fa784f9fb86e 100644 --- a/sw/source/filter/ww1/fltshell.cxx +++ b/sw/source/filter/ww1/fltshell.cxx @@ -35,9 +35,7 @@ #include #include -#ifndef _GRAPH_HXX //autogen #include -#endif #include #include #include @@ -72,13 +70,12 @@ #include // class SwSection #include // class SwSelBoxes #include -#ifndef _DOCSH_HXX #include // class SwDocSh -#endif #include #include #include + #define MAX_FIELDLEN 64000 using namespace com::sun::star; @@ -437,7 +434,7 @@ void SwFltControlStack::SetAttrInDoc(const SwPosition& rTmpPos, SwFltStackEntry* // Damit die Frames bei Einfuegen in existierendes Doc // erzeugt werden (erst nach Setzen des Ankers!): if(pDoc->GetRootFrm() - && FLY_AT_CNTNT == pFmt->GetAnchor().GetAnchorId()) + && (FLY_AT_PARA == pFmt->GetAnchor().GetAnchorId())) { pFmt->MakeFrms(); } @@ -1285,7 +1282,7 @@ SwFltOutBase::~SwFltOutBase() } SwFltOutBase::SwFltOutBase(SwDoc& rDocu) - : rDoc(rDocu), eFlyAnchor(FLY_AT_CNTNT), bFlyAbsPos(false) + : rDoc(rDocu), eFlyAnchor(FLY_AT_PARA), bFlyAbsPos(false) { } @@ -1702,8 +1699,8 @@ BOOL SwFltOutBase::BeginFly( RndStdIds eAnchor /*= FLY_AT_CNTNT*/, ASSERT( FALSE, "SetFlyAnchor() ohne Fly" ); return; } - if( eAnchor == FLY_IN_CNTNT ){ - ASSERT( FALSE, "SetFlyAnchor( FLY_IN_CNTNT ) nicht implementiert" ); + if ( eAnchor == FLY_AS_CHAR ){ + ASSERT( FALSE, "SetFlyAnchor( FLY_AS_CHAR ) nicht implementiert" ); return; } SwFmtAnchor& rAnchor = (SwFmtAnchor&)GetFlyFrmAttr( RES_ANCHOR ); diff --git a/sw/source/filter/ww1/w1sprm.cxx b/sw/source/filter/ww1/w1sprm.cxx index 6aac7b226289..3ed4718cd7a8 100644 --- a/sw/source/filter/ww1/w1sprm.cxx +++ b/sw/source/filter/ww1/w1sprm.cxx @@ -31,9 +31,6 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - - - #include #include @@ -46,10 +43,7 @@ #include #include #include -#ifndef _SVX_TSTPITEM_HXX //autogen #include -#endif - #include #include @@ -595,13 +589,13 @@ void Ww1SingleSprmPpc::Start( sal_Int16 eVRel; // Seite oder Seitenrand switch ( ( nPpc & 0x30 ) >> 4 ){ // Y - Bindung bestimmt Sw-Bindung - case 0: eAnchor = FLY_AT_CNTNT; // Vert Margin + case 0: eAnchor = FLY_AT_PARA; // Vert Margin eVRel = text::RelOrientation::PRINT_AREA; // if( nYPos < 0 ) // nYPos = 0; // koennen wir nicht break; /* case 1:*/ // Vert. Seite - default:eAnchor = FLY_PAGE; // Vert Page oder unknown + default:eAnchor = FLY_AT_PAGE; // Vert Page oder unknown eVRel = text::RelOrientation::FRAME; break; // 2=Vert. Paragraph, 3=Use Default } diff --git a/sw/source/filter/ww8/writerhelper.cxx b/sw/source/filter/ww8/writerhelper.cxx index 2ad32c7be689..8bd1eaa39601 100644 --- a/sw/source/filter/ww8/writerhelper.cxx +++ b/sw/source/filter/ww8/writerhelper.cxx @@ -190,7 +190,7 @@ namespace sw meWriterType(eTxtBox), mpStartFrameContent(0), // --> OD 2007-04-19 #i43447# - move to initialization list - mbIsInline( (rFmt.GetAnchor().GetAnchorId() == FLY_IN_CNTNT) ) + mbIsInline( (rFmt.GetAnchor().GetAnchorId() == FLY_AS_CHAR) ) // <-- { switch (rFmt.Which()) diff --git a/sw/source/filter/ww8/wrtw8esh.cxx b/sw/source/filter/ww8/wrtw8esh.cxx index 5bb1ffc557b7..a53ee1b87e9f 100644 --- a/sw/source/filter/ww8/wrtw8esh.cxx +++ b/sw/source/filter/ww8/wrtw8esh.cxx @@ -587,7 +587,7 @@ void PlcDrawObj::WritePlc( WW8Export& rWrt ) const //fHdr/bx/by/wr/wrk/fRcaSimple/fBelowText/fAnchorLock USHORT nFlags=0; //If nFlags isn't 0x14 its overridden by the escher properties - if( FLY_PAGE == rFmt.GetAnchor().GetAnchorId()) + if (FLY_AT_PAGE == rFmt.GetAnchor().GetAnchorId()) nFlags = 0x0000; else nFlags = 0x0014; // x-rel to text, y-rel to text @@ -2117,7 +2117,7 @@ bool WinwordAnchoring::ConvertPosition( SwFmtHoriOrient& _iorHoriOri, { const RndStdIds eAnchor = _rFrmFmt.GetAnchor().GetAnchorId(); - if ( FLY_IN_CNTNT == eAnchor || FLY_AT_FLY == eAnchor ) + if ( (FLY_AS_CHAR == eAnchor) || (FLY_AT_FLY == eAnchor) ) { // no conversion for as-character or at frame anchored objects return false; @@ -2166,7 +2166,7 @@ bool WinwordAnchoring::ConvertPosition( SwFmtHoriOrient& _iorHoriOri, // the fact, that the object is anchored at a paragraph, which has a "column // break before" attribute bool bConvDueToAnchoredAtColBreakPara( false ); - if ( ( eAnchor == FLY_AT_CNTNT || eAnchor == FLY_AUTO_CNTNT ) && + if ( ( (eAnchor == FLY_AT_PARA) || (eAnchor == FLY_AT_CHAR) ) && _rFrmFmt.GetAnchor().GetCntntAnchor() && _rFrmFmt.GetAnchor().GetCntntAnchor()->nNode.GetNode().IsTxtNode() ) { @@ -2403,7 +2403,7 @@ bool WinwordAnchoring::ConvertPosition( SwFmtHoriOrient& _iorHoriOri, void WinwordAnchoring::SetAnchoring(const SwFrmFmt& rFmt) { const RndStdIds eAnchor = rFmt.GetAnchor().GetAnchorId(); - mbInline = (eAnchor == FLY_IN_CNTNT); + mbInline = (eAnchor == FLY_AS_CHAR); SwFmtHoriOrient rHoriOri = rFmt.GetHoriOrient(); SwFmtVertOrient rVertOri = rFmt.GetVertOrient(); @@ -2487,13 +2487,13 @@ void WinwordAnchoring::SetAnchoring(const SwFrmFmt& rFmt) case text::RelOrientation::FRAME: case text::RelOrientation::FRAME_LEFT: //:-( case text::RelOrientation::FRAME_RIGHT: //:-( - if (eAnchor == FLY_PAGE) + if (eAnchor == FLY_AT_PAGE) mnXRelTo = 1; else mnXRelTo = 2; break; case text::RelOrientation::PRINT_AREA: - if (eAnchor == FLY_PAGE) + if (eAnchor == FLY_AT_PAGE) mnXRelTo = 0; else mnXRelTo = 2; @@ -2515,13 +2515,13 @@ void WinwordAnchoring::SetAnchoring(const SwFrmFmt& rFmt) mnYRelTo = 1; break; case text::RelOrientation::PRINT_AREA: - if (eAnchor == FLY_PAGE) + if (eAnchor == FLY_AT_PAGE) mnYRelTo = 0; else mnYRelTo = 2; break; case text::RelOrientation::FRAME: - if (eAnchor == FLY_PAGE) + if (eAnchor == FLY_AT_PAGE) mnYRelTo = 1; else mnYRelTo = 2; diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx index 2cbbb7943f37..b9bf46cf750f 100644 --- a/sw/source/filter/ww8/wrtw8nds.cxx +++ b/sw/source/filter/ww8/wrtw8nds.cxx @@ -376,7 +376,7 @@ xub_StrLen SwAttrIter::SearchNext( xub_StrLen nStartPos ) if (nPos >= nStartPos && nPos <= nMinPos) nMinPos = nPos; - if (maFlyIter->GetFrmFmt().GetAnchor().GetAnchorId() == FLY_AUTO_CNTNT) + if (maFlyIter->GetFrmFmt().GetAnchor().GetAnchorId() == FLY_AT_CHAR) { ++nPos; if (nPos >= nStartPos && nPos <= nMinPos) @@ -1301,7 +1301,7 @@ short MSWordExportBase::TrueFrameDirection( const SwFrmFmt &rFlyFmt ) const { pItem = 0; const SwFmtAnchor* pAnchor = &pFlyFmt->GetAnchor(); - if ( FLY_PAGE != pAnchor->GetAnchorId() && + if ((FLY_AT_PAGE != pAnchor->GetAnchorId()) && pAnchor->GetCntntAnchor() ) { pFlyFmt = pAnchor->GetCntntAnchor()->nNode.GetNode().GetFlyFmt(); @@ -1359,7 +1359,7 @@ SvxBrushItem WW8Export::TrueFrameBgBrush(const SwFrmFmt &rFlyFmt) const { pRet = 0; const SwFmtAnchor* pAnchor = &pFlyFmt->GetAnchor(); - if (FLY_PAGE != pAnchor->GetAnchorId() && + if ((FLY_AT_PAGE != pAnchor->GetAnchorId()) && pAnchor->GetCntntAnchor()) { pFlyFmt = @@ -2497,12 +2497,13 @@ void WW8AttributeOutput::OutputFlyFrame_Impl( const sw::Frame& rFmt, const Point aOffset -= aPageRect.Pos(); m_rWW8Export.pFlyOffset = &aOffset; - m_rWW8Export.eNewAnchorType = FLY_PAGE; + m_rWW8Export.eNewAnchorType = FLY_AT_PAGE; } m_rWW8Export.mpParentFrame = &rFmt; if ( - m_rWW8Export.bIsInTable && (FLY_PAGE != rAnch.GetAnchorId()) && + m_rWW8Export.bIsInTable && + (FLY_AT_PAGE != rAnch.GetAnchorId()) && !m_rWW8Export.pDoc->GetNodes()[ nStt ]->IsNoTxtNode() ) { @@ -2534,7 +2535,7 @@ void AttributeOutputBase::OutputFlyFrame( const sw::Frame& rFmt ) Point* pLayPos; bool bValidNdPos = false, bValidPgPos = false; - if ( FLY_PAGE == rFmt.GetFrmFmt().GetAnchor().GetAnchorId() ) + if (FLY_AT_PAGE == rFmt.GetFrmFmt().GetAnchor().GetAnchorId()) { // get the Layout Node-Position. if ( !bValidPgPos ) diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx index dcef287a1537..a32962640117 100644 --- a/sw/source/filter/ww8/wrtww8.cxx +++ b/sw/source/filter/ww8/wrtww8.cxx @@ -2899,7 +2899,7 @@ void MSWordExportBase::ExportDocument( bool bWriteAll ) mpParentFrame = 0; pFlyOffset = 0; - eNewAnchorType = FLY_PAGE; + eNewAnchorType = FLY_AT_PAGE; nTxtTyp = TXT_MAINTEXT; // --> OD 2007-04-19 #i43447# - removed // nFlyWidth = nFlyHeight = 0; diff --git a/sw/source/filter/ww8/wrtww8gr.cxx b/sw/source/filter/ww8/wrtww8gr.cxx index aaafe0ee49fc..649bb7ed3b8e 100644 --- a/sw/source/filter/ww8/wrtww8gr.cxx +++ b/sw/source/filter/ww8/wrtww8gr.cxx @@ -404,7 +404,7 @@ void WW8Export::OutGrf(const sw::Frame &rFrame) const SwFrmFmt &rFlyFmt = rFrame.GetFrmFmt(); const RndStdIds eAn = rFlyFmt.GetAttrSet().GetAnchor(false).GetAnchorId(); - if( eAn == FLY_IN_CNTNT ) + if (eAn == FLY_AS_CHAR) { sal_Int16 eVert = rFlyFmt.GetVertOrient().GetVertOrient(); if ((eVert == text::VertOrientation::CHAR_CENTER) || (eVert == text::VertOrientation::LINE_CENTER)) @@ -465,8 +465,8 @@ void WW8Export::OutGrf(const sw::Frame &rFrame) // Otherwise, an additional paragraph is exported for a graphic, which is // forced to be treated as inline, because it's anchored inside another frame. if ( !rFrame.IsInline() && - ( ( eAn == FLY_AT_CNTNT && ( bWrtWW8 || !bIsInTable ) ) || - eAn == FLY_PAGE ) ) + ( ((eAn == FLY_AT_PARA) && ( bWrtWW8 || !bIsInTable )) || + (eAn == FLY_AT_PAGE)) ) // <-- { WriteChar( (char)0x0d ); // umgebenden Rahmen mit CR abschliessen diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index 3b91de937668..3712c13d372d 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -4069,15 +4069,15 @@ void WW8AttributeOutput::FormatAnchor( const SwFmtAnchor& rAnchor ) BYTE nP = 0; switch ( rAnchor.GetAnchorId() ) { - case FLY_PAGE: + case FLY_AT_PAGE: // Vert: Page | Horz: Page nP |= (1 << 4) | (2 << 6); break; // Im Fall eine Flys als Zeichen: Absatz-gebunden setzen!!! case FLY_AT_FLY: - case FLY_AUTO_CNTNT: - case FLY_AT_CNTNT: - case FLY_IN_CNTNT: + case FLY_AT_CHAR: + case FLY_AT_PARA: + case FLY_AS_CHAR: // Vert: Page | Horz: Page nP |= (2 << 4) | (0 << 6); break; diff --git a/sw/source/filter/ww8/ww8glsy.cxx b/sw/source/filter/ww8/ww8glsy.cxx index b0dabff56b2f..cdb13be50aaa 100644 --- a/sw/source/filter/ww8/ww8glsy.cxx +++ b/sw/source/filter/ww8/ww8glsy.cxx @@ -36,14 +36,10 @@ #include #include #include -#ifndef _NDTXT #include -#endif #include #include -#ifndef _DOCSH_HXX #include -#endif #include #include #include @@ -51,6 +47,7 @@ #include "ww8glsy.hxx" #include "ww8par.hxx" + WW8Glossary::WW8Glossary(SvStorageStreamRef &refStrm, BYTE nVersion, SvStorage *pStg) : pGlossary(0), rStrm(refStrm), xStg(pStg), nStrings(0) @@ -82,10 +79,10 @@ bool WW8Glossary::HasBareGraphicEnd(SwDoc *pDoc,SwNodeIndex &rIdx) RES_DRAWFRMFMT != pFrmFmt->Which() ) continue; const SwFmtAnchor& rAnchor = pFrmFmt->GetAnchor(); - const SwPosition* pAPos; - if( ( FLY_AT_CNTNT == rAnchor.GetAnchorId() || - FLY_AUTO_CNTNT == rAnchor.GetAnchorId() ) && - 0 != ( pAPos = rAnchor.GetCntntAnchor()) && + SwPosition const*const pAPos = rAnchor.GetCntntAnchor(); + if (pAPos && + ((FLY_AT_PARA == rAnchor.GetAnchorId()) || + (FLY_AT_CHAR == rAnchor.GetAnchorId())) && rIdx == pAPos->nNode.GetIndex() ) { bRet=true; diff --git a/sw/source/filter/ww8/ww8graf.cxx b/sw/source/filter/ww8/ww8graf.cxx index 4948ac5eddae..cc17df625630 100644 --- a/sw/source/filter/ww8/ww8graf.cxx +++ b/sw/source/filter/ww8/ww8graf.cxx @@ -58,9 +58,7 @@ #include #include #include -#ifndef _SVX_CNTRITEM_HXX #include -#endif #include #include #include @@ -191,13 +189,13 @@ bool SwWW8ImplReader::ReadGrafStart(void* pData, short nDataSiz, } pStrm->Read(pData, nDataSiz); - RndStdIds eAnchor = (SVBT8ToByte(pDo->by) < 2) ? FLY_PAGE : FLY_AT_CNTNT; + RndStdIds eAnchor = (SVBT8ToByte(pDo->by) < 2) ? FLY_AT_PAGE : FLY_AT_PARA; rSet.Put(SwFmtAnchor(eAnchor)); nDrawXOfs2 = nDrawXOfs; nDrawYOfs2 = nDrawYOfs; - if( eAnchor == FLY_AT_CNTNT ) + if (eAnchor == FLY_AT_PARA) { if( SVBT8ToByte( pDo->bx ) == 1 ) // Pos: echt links nDrawXOfs2 = static_cast< short >(nDrawXOfs2 - maSectionManager.GetPageLeft()); @@ -2247,7 +2245,7 @@ RndStdIds SwWW8ImplReader::ProcessEscherAlign(SvxMSDffImportRec* pRecord, { ASSERT(pRecord || pFSPA, "give me something! to work with for anchoring"); if (!pRecord && !pFSPA) - return FLY_PAGE; + return FLY_AT_PAGE; SvxMSDffImportRec aRecordFromFSPA; if (!pRecord) @@ -2298,7 +2296,7 @@ RndStdIds SwWW8ImplReader::ProcessEscherAlign(SvxMSDffImportRec* pRecord, UINT32 nYRelTo = nCntRelTo > pRecord->nYRelTo ? pRecord->nYRelTo : 1; // --> OD 2005-03-03 #i43718# - RndStdIds eAnchor = IsInlineEscherHack() ? FLY_IN_CNTNT : FLY_AUTO_CNTNT; + RndStdIds eAnchor = IsInlineEscherHack() ? FLY_AS_CHAR : FLY_AT_CHAR; // <-- SwFmtAnchor aAnchor( eAnchor ); @@ -2462,7 +2460,7 @@ RndStdIds SwWW8ImplReader::ProcessEscherAlign(SvxMSDffImportRec* pRecord, if ( (pFSPA->nYaTop < 0) && (eVertOri == text::VertOrientation::NONE) && - ((eAnchor == FLY_AT_CNTNT) || (eAnchor == FLY_AUTO_CNTNT)) + ((eAnchor == FLY_AT_PARA) || (eAnchor == FLY_AT_CHAR)) ) { maTracer.Log(sw::log::eNegativeVertPlacement); @@ -2845,7 +2843,7 @@ SwFrmFmt* SwWW8ImplReader::Read_GrafLayer( long nGrafAnchorCp ) SwFrmFmt *SwWW8ImplReader::AddAutoAnchor(SwFrmFmt *pFmt) { - if (pFmt && (pFmt->GetAnchor().GetAnchorId() != FLY_IN_CNTNT)) + if (pFmt && (pFmt->GetAnchor().GetAnchorId() != FLY_AS_CHAR)) { sal_uInt16 nTextAreaWidth = static_cast< sal_uInt16 >( maSectionManager.GetPageWidth() - maSectionManager.GetPageRight() - maSectionManager.GetPageLeft()); @@ -2860,8 +2858,10 @@ SwFrmFmt *SwWW8ImplReader::AddAutoAnchor(SwFrmFmt *pFmt) * * Leave to later and set the correct location then. */ - if ((pFmt) && (pFmt->GetAnchor().GetAnchorId() != FLY_IN_CNTNT)) + if ((pFmt) && (pFmt->GetAnchor().GetAnchorId() != FLY_AS_CHAR)) + { pAnchorStck->AddAnchor(*pPaM->GetPoint(), pFmt); + } return pFmt; } @@ -3234,7 +3234,7 @@ void SwWW8ImplReader::GrafikDtor() void SwWW8FltAnchorStack::AddAnchor(const SwPosition& rPos, SwFrmFmt *pFmt) { - ASSERT(pFmt->GetAnchor().GetAnchorId() != FLY_IN_CNTNT, + ASSERT(pFmt->GetAnchor().GetAnchorId() != FLY_AS_CHAR, "Don't use fltanchors with inline frames, slap!"); NewAttr(rPos, SwFltAnchor(pFmt)); } diff --git a/sw/source/filter/ww8/ww8graf2.cxx b/sw/source/filter/ww8/ww8graf2.cxx index dc653c5738e6..9c0ea275f10d 100644 --- a/sw/source/filter/ww8/ww8graf2.cxx +++ b/sw/source/filter/ww8/ww8graf2.cxx @@ -33,9 +33,7 @@ /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil -*- */ -#ifndef __SGI_STL_ITERATOR #include -#endif #include #include #include @@ -415,7 +413,7 @@ SwFlyFrmFmt* SwWW8ImplReader::MakeGrafNotInCntnt(const WW8PicDesc& rPD, // Damit die Frames bei Einfuegen in existierendes Doc erzeugt werden: if (rDoc.GetRootFrm() && - (FLY_AT_CNTNT == pFlyFmt->GetAnchor().GetAnchorId())) + (FLY_AT_PARA == pFlyFmt->GetAnchor().GetAnchorId())) { pFlyFmt->MakeFrms(); } @@ -548,9 +546,11 @@ SwFrmFmt* SwWW8ImplReader::ImportGraf(SdrTextObj* pTextObj, // it is anchored in content; because this anchor add // a character into the textnode. // IussueZilla task 2806 - if( FLY_IN_CNTNT == + if (FLY_AS_CHAR == pFlyFmtOfJustInsertedGraphic->GetAnchor().GetAnchorId() ) + { aFlySet.ClearItem( RES_ANCHOR ); + } pFlyFmtOfJustInsertedGraphic->SetFmtAttr( aFlySet ); diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index 599c6b3ea1b6..2602c03f7138 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -1648,7 +1648,7 @@ void SwWW8ImplReader::Read_HdFtTextAsHackedFrame(long nStart, long nLen, pPaM->GetPoint()->nNode = pSttIdx->GetIndex() + 1; pPaM->GetPoint()->nContent.Assign(pPaM->GetCntntNode(), 0); - SwFlyFrmFmt *pFrame = rDoc.MakeFlySection(FLY_AT_CNTNT, pPaM->GetPoint()); + SwFlyFrmFmt *pFrame = rDoc.MakeFlySection(FLY_AT_PARA, pPaM->GetPoint()); pFrame->SetFmtAttr(SwFmtFrmSize(ATT_MIN_SIZE, nPageWidth, MINLAY)); pFrame->SetFmtAttr(SwFmtSurround(SURROUND_THROUGHT)); diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx index 5cb19358f385..87b5cc4a806a 100644 --- a/sw/source/filter/ww8/ww8par2.cxx +++ b/sw/source/filter/ww8/ww8par2.cxx @@ -3473,7 +3473,7 @@ bool SwWW8ImplReader::StartTable(WW8_CP nStartCp) // --> OD 2005-03-21 #i45301# - anchor nested table inside Writer fly frame // only at-character, if absolute position object attributes are available. // Thus, default anchor type is as-character anchored. - RndStdIds eAnchor( FLY_IN_CNTNT ); + RndStdIds eAnchor( FLY_AS_CHAR ); // <-- if ( nInTable ) { @@ -3505,7 +3505,7 @@ bool SwWW8ImplReader::StartTable(WW8_CP nStartCp) // <-- // --> OD 2005-03-21 #i45301# - anchor nested table Writer fly // frame at-character - eAnchor = FLY_AUTO_CNTNT; + eAnchor = FLY_AT_CHAR; // <-- } } @@ -3523,7 +3523,8 @@ bool SwWW8ImplReader::StartTable(WW8_CP nStartCp) "how could we be in a local apo and have no apo"); } - if ( eAnchor == FLY_AUTO_CNTNT && !maTableStack.empty() && !InEqualApo(nNewInTable) ) + if ((eAnchor == FLY_AT_CHAR) + && !maTableStack.empty() && !InEqualApo(nNewInTable) ) { pTableDesc->pParentPos = new SwPosition(*pPaM->GetPoint()); SfxItemSet aItemSet(rDoc.GetAttrPool(), @@ -3551,7 +3552,7 @@ bool SwWW8ImplReader::StartTable(WW8_CP nStartCp) if ( pTableWFlyPara && pTableSFlyPara ) { WW8FlySet aFlySet( *this, pTableWFlyPara, pTableSFlyPara, false ); - SwFmtAnchor aAnchor( FLY_AUTO_CNTNT ); + SwFmtAnchor aAnchor( FLY_AT_CHAR ); aAnchor.SetAnchor( pTableDesc->pParentPos ); aFlySet.Put( aAnchor ); pTableDesc->pFlyFmt->SetFmtAttr( aFlySet ); @@ -3606,8 +3607,8 @@ bool lcl_PamContainsFly(SwPaM & rPam) switch (pAnchor->GetAnchorId()) { - case FLY_AT_CNTNT: - case FLY_AUTO_CNTNT: + case FLY_AT_PARA: + case FLY_AT_CHAR: { const SwPosition* pAPos = pAnchor->GetCntntAnchor(); diff --git a/sw/source/filter/ww8/ww8par4.cxx b/sw/source/filter/ww8/ww8par4.cxx index ccabdcf8cac1..eef92f7148cf 100644 --- a/sw/source/filter/ww8/ww8par4.cxx +++ b/sw/source/filter/ww8/ww8par4.cxx @@ -35,12 +35,8 @@ #include "writerhelper.hxx" #include -#ifndef __SGI_STL_ALGORITHM #include -#endif -#ifndef __SGI_STL_FUNCTIONAL #include -#endif #include #include #include @@ -59,9 +55,7 @@ #include #include #include -#ifndef _DOCSH_HXX #include // fuer Ole-Node -#endif #include // Progress #include #include @@ -296,7 +290,7 @@ SwFrmFmt* SwWW8ImplReader::ImportOle(const Graphic* pGrf, if (!mbNewDoc) Reader::ResetFrmFmtAttrs( *pTempSet ); - SwFmtAnchor aAnchor( FLY_IN_CNTNT ); + SwFmtAnchor aAnchor( FLY_AS_CHAR ); aAnchor.SetAnchor( pPaM->GetPoint() ); pTempSet->Put( aAnchor ); diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx index f5f82d879aac..d51b4c5d2f4b 100644 --- a/sw/source/filter/ww8/ww8par5.cxx +++ b/sw/source/filter/ww8/ww8par5.cxx @@ -45,17 +45,11 @@ #include #include -#ifndef _UCBHELPER_CONTENT_HXX_ #include -#endif -#ifndef _UCBHELPER_CONTENTBROKER_HXX_ #include -#endif #include -#ifndef _COM_SUN_STAR_I18N_SCRIPTTYPE_HDL_ #include -#endif #include #include #include @@ -2216,7 +2210,7 @@ eF_ResT SwWW8ImplReader::Read_F_IncludePicture( WW8FieldDesc*, String& rStr ) */ SfxItemSet aFlySet( rDoc.GetAttrPool(), RES_FRMATR_BEGIN, RES_FRMATR_END-1 ); - aFlySet.Put( SwFmtAnchor( FLY_IN_CNTNT ) ); + aFlySet.Put( SwFmtAnchor( FLY_AS_CHAR ) ); aFlySet.Put( SwFmtVertOrient( 0, text::VertOrientation::TOP, text::RelOrientation::FRAME )); pFlyFmtOfJustInsertedGraphic = rDoc.Insert( *pPaM, aGrfName, diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx index 978834f3345e..21bfa4efdc64 100644 --- a/sw/source/filter/ww8/ww8par6.cxx +++ b/sw/source/filter/ww8/ww8par6.cxx @@ -44,9 +44,7 @@ #include #include #include -#ifndef _SVX_CNTRITEM_HXX //autogen #include -#endif #include #include #include @@ -65,19 +63,13 @@ #include #include #include -#ifndef _SVX_TSTPITEM_HXX //autogen #include -#endif #include #include -#ifndef _SVX_EMPHITEM_HXX //autogen #include -#endif #include #include -#ifndef _SVX_SCRIPSPACEITEM_HXX #include -#endif #include #include #include @@ -1995,7 +1987,7 @@ WW8SwFlyPara::WW8SwFlyPara( SwPaM& rPaM, nYBind = (( rWW.nSp29 & 0x30 ) >> 4); // --> OD 2005-08-24 #i53725# - absolute positioned objects have to be // anchored at-paragraph to assure its correct anchor position. - eAnchor = FLY_AT_CNTNT; + eAnchor = FLY_AT_PARA; // <-- switch (nYBind) { @@ -2287,7 +2279,7 @@ void WW8FlySet::Init(const SwWW8ImplReader& rReader, const SwPaM* pPaM) Reader::ResetFrmFmtAttrs(*this); // Abstand/Umrandung raus Put(SvxLRSpaceItem(RES_LR_SPACE)); //inline writer ole2 objects start with 0.2cm l/r - SwFmtAnchor aAnchor(FLY_IN_CNTNT); + SwFmtAnchor aAnchor(FLY_AS_CHAR); aAnchor.SetAnchor(pPaM->GetPoint()); Put(aAnchor); @@ -2519,8 +2511,10 @@ bool SwWW8ImplReader::StartApo(const ApoTestResults &rApo, pWWZOrder->InsertTextLayerObject(pOurNewObject); } - if (FLY_IN_CNTNT != pSFlyPara->eAnchor) + if (FLY_AS_CHAR != pSFlyPara->eAnchor) + { pAnchorStck->AddAnchor(*pPaM->GetPoint(),pSFlyPara->pFlyFmt); + } // merke Pos im Haupttext pSFlyPara->pMainTextPos = new SwPosition( *pPaM->GetPoint() ); @@ -3206,7 +3200,7 @@ SwFrmFmt *SwWW8ImplReader::ContainsSingleInlineGraphic(const SwPaM &rRegion) subscripting to force the graphic into a centered position on the line, so we must check when applying sub/super to see if it the subscript range contains only a single graphic, and if that graphic is anchored as - FLY_IN_CNTNT and then we can change its anchoring to centered in the line. + FLY_AS_CHAR and then we can change its anchoring to centered in the line. */ SwFrmFmt *pRet=0; SwNodeIndex aBegin(rRegion.Start()->nNode); @@ -3223,8 +3217,8 @@ SwFrmFmt *SwWW8ImplReader::ContainsSingleInlineGraphic(const SwPaM &rRegion) { const SwFmtFlyCnt& rFly = pTFlyAttr->GetFlyCnt(); SwFrmFmt *pFlyFmt = rFly.GetFrmFmt(); - if( pFlyFmt && - FLY_IN_CNTNT == pFlyFmt->GetAnchor().GetAnchorId() ) + if (pFlyFmt && + (FLY_AS_CHAR == pFlyFmt->GetAnchor().GetAnchorId())) { pRet = pFlyFmt; } @@ -3240,7 +3234,7 @@ bool SwWW8ImplReader::ConvertSubToGraphicPlacement() subscripting to force the graphic into a centered position on the line, so we must check when applying sub/super to see if it the subscript range contains only a single graphic, and if that graphic is anchored as - FLY_IN_CNTNT and then we can change its anchoring to centered in the line. + FLY_AS_CHAR and then we can change its anchoring to centered in the line. */ bool bIsGraphicPlacementHack = false; USHORT nPos; diff --git a/sw/source/filter/xml/xmltexti.cxx b/sw/source/filter/xml/xmltexti.cxx index 6953e065c82a..8c414cdeab0e 100644 --- a/sw/source/filter/xml/xmltexti.cxx +++ b/sw/source/filter/xml/xmltexti.cxx @@ -47,9 +47,7 @@ #include #include #include -#ifndef _XMLOFF_TXTPRMAP_HXX #include -#endif #include #include "unocrsr.hxx" #include "unoobj.hxx" @@ -76,6 +74,7 @@ #include #include + using ::rtl::OUString; using ::rtl::OUStringBuffer; using namespace ::com::sun::star; @@ -126,7 +125,7 @@ static void lcl_putHeightAndWidth ( SfxItemSet &rItemSet, rItemSet.Put( SwFmtFrmSize( ATT_FIX_SIZE, nWidth, nHeight ) ); } - SwFmtAnchor aAnchor( FLY_AUTO_CNTNT ); + SwFmtAnchor aAnchor( FLY_AT_CHAR ); rItemSet.Put( aAnchor ); if( pTwipWidth ) diff --git a/sw/source/ui/app/appenv.cxx b/sw/source/ui/app/appenv.cxx index 7f3acf375b35..57a5bed15f5c 100644 --- a/sw/source/ui/app/appenv.cxx +++ b/sw/source/ui/app/appenv.cxx @@ -43,18 +43,12 @@ #include #include -#ifndef _APP_HXX //autogen #include -#endif -#ifndef _WRKWIN_HXX //autogen #include -#endif #include #include #include -#ifndef _MSGBOX_HXX //autogen #include -#endif #include #include #include @@ -67,21 +61,13 @@ #include #include #include -#ifndef _VIEW_HXX #include -#endif -#ifndef _DOCSH_HXX #include -#endif #include #include #include -#ifndef IDOCUMENTDEVICEACCESS_HXX_INCLUDED #include -#endif -#ifndef _DBMGR_HXX #include -#endif #include #include #include @@ -91,9 +77,7 @@ #include #include -#ifndef _CMDID_H #include -#endif #ifndef _GLOBALS_HRC #include #endif @@ -478,7 +462,7 @@ static USHORT nTitleNo = 0; if (rItem.bSend) { pSh->SttEndDoc(TRUE); - aMgr.InsertFlyFrm(FLY_PAGE, + aMgr.InsertFlyFrm(FLY_AT_PAGE, Point(rItem.lSendFromLeft + lLeft, rItem.lSendFromTop + lUpper), Size (rItem.lAddrFromLeft - rItem.lSendFromLeft, 0)); @@ -494,7 +478,7 @@ static USHORT nTitleNo = 0; // Empfaenger pSh->SttEndDoc(TRUE); - aMgr.InsertFlyFrm(FLY_PAGE, + aMgr.InsertFlyFrm(FLY_AT_PAGE, Point(rItem.lAddrFromLeft + lLeft, rItem.lAddrFromTop + lUpper), Size (nPageW - rItem.lAddrFromLeft - 566, 0)); pSh->EnterSelFrmMode(); diff --git a/sw/source/ui/app/applab.cxx b/sw/source/ui/app/applab.cxx index d09e522599d7..b6df61c2b968 100644 --- a/sw/source/ui/app/applab.cxx +++ b/sw/source/ui/app/applab.cxx @@ -39,15 +39,9 @@ #include -#ifndef _APP_HXX //autogen #include -#endif -#ifndef _WRKWIN_HXX //autogen #include -#endif -#ifndef _MSGBOX_HXX //autogen #include -#endif #include #include #include @@ -71,21 +65,13 @@ #include #include #include -#ifndef _VIEW_HXX #include -#endif -#ifndef _DOCSH_HXX #include -#endif #include #include #include -#ifndef _CMDID_H #include -#endif -#ifndef _DBMGR_HXX #include -#endif #include #include #include @@ -126,7 +112,7 @@ const SwFrmFmt *lcl_InsertBCText( SwWrtShell& rSh, const SwLabItem& rItem, sal_uInt16 nPhyPageNum, nVirtPageNum; rSh.GetPageNum( nPhyPageNum, nVirtPageNum ); - aSet.Put(SwFmtAnchor(bPage ? FLY_IN_CNTNT : FLY_PAGE, nPhyPageNum)); + aSet.Put(SwFmtAnchor(bPage ? FLY_AS_CHAR : FLY_AT_PAGE, nPhyPageNum)); if (!bPage) { aSet.Put(SwFmtHoriOrient(rItem.lLeft + nCol * rItem.lHDist, @@ -166,7 +152,7 @@ const SwFrmFmt *lcl_InsertLabText( SwWrtShell& rSh, const SwLabItem& rItem, sal_uInt16 nPhyPageNum, nVirtPageNum; rSh.GetPageNum( nPhyPageNum, nVirtPageNum ); - aSet.Put(SwFmtAnchor(bPage ? FLY_IN_CNTNT : FLY_PAGE, nPhyPageNum)); + aSet.Put(SwFmtAnchor(bPage ? FLY_AS_CHAR : FLY_AT_PAGE, nPhyPageNum)); if (!bPage) { aSet.Put(SwFmtHoriOrient(rItem.lLeft + nCol * rItem.lHDist, diff --git a/sw/source/ui/dbui/mmlayoutpage.cxx b/sw/source/ui/dbui/mmlayoutpage.cxx index ddb37e3c8eeb..450311349694 100644 --- a/sw/source/ui/dbui/mmlayoutpage.cxx +++ b/sw/source/ui/dbui/mmlayoutpage.cxx @@ -42,9 +42,7 @@ #include #include #include -#ifndef _VIEW_HXX #include -#endif #include #include #include @@ -56,9 +54,7 @@ #include #include #include -#ifndef _DOCSH_HXX #include -#endif #include #include #include @@ -325,7 +321,7 @@ SwFrmFmt* SwMailMergeLayoutPage::InsertAddressFrame( RES_FRM_SIZE, RES_FRM_SIZE, RES_SURROUND, RES_SURROUND, 0 ); - aSet.Put(SwFmtAnchor(FLY_PAGE, 1)); + aSet.Put(SwFmtAnchor(FLY_AT_PAGE, 1)); if(bAlignLeft) aSet.Put(SwFmtHoriOrient( 0, text::HoriOrientation::NONE, text::RelOrientation::PAGE_PRINT_AREA )); else diff --git a/sw/source/ui/dialog/regionsw.cxx b/sw/source/ui/dialog/regionsw.cxx index 47936697a20d..aaf95674cb10 100644 --- a/sw/source/ui/dialog/regionsw.cxx +++ b/sw/source/ui/dialog/regionsw.cxx @@ -36,37 +36,24 @@ #include #include #include -#ifndef _MSGBOX_HXX //autogen #include -#endif #include #include #include -#ifndef _PASSWD_HXX //autogen #include -#endif #include #include #include #include -#ifndef _SVX_SIZEITEM_HXX //autogen - #include -#endif #include #include #include #include -#ifndef _BASESH_HXX #include -#endif -#ifndef _WDOCSH_HXX #include -#endif -#ifndef _VIEW_HXX #include -#endif #include #include #include // fuer Undo-Ids @@ -75,12 +62,8 @@ #include #include -#ifndef _HELPID_H #include -#endif -#ifndef _CMDID_H #include -#endif #ifndef _REGIONSW_HRC #include #endif @@ -118,7 +101,7 @@ void SwBaseShell::InsertRegionDialog(SfxRequest& rReq) if (!pSet || pSet->Count()==0) { SwRect aRect; - rSh.CalcBoundRect(aRect, FLY_IN_CNTNT); + rSh.CalcBoundRect(aRect, FLY_AS_CHAR); long nWidth = aRect.Width(); aSet.Put(SwFmtFrmSize(ATT_VAR_SIZE, nWidth)); @@ -154,7 +137,7 @@ void SwBaseShell::InsertRegionDialog(SfxRequest& rReq) { SwFmtCol aCol; SwRect aRect; - rSh.CalcBoundRect(aRect, FLY_IN_CNTNT); + rSh.CalcBoundRect(aRect, FLY_AS_CHAR); long nWidth = aRect.Width(); USHORT nCol = ((SfxUInt16Item *)pItem)->GetValue(); @@ -232,7 +215,7 @@ IMPL_STATIC_LINK( SwWrtShell, InsertRegionDialog, SwSection*, pSect ) SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE, 0); SwRect aRect; - pThis->CalcBoundRect(aRect, FLY_IN_CNTNT); + pThis->CalcBoundRect(aRect, FLY_AS_CHAR); long nWidth = aRect.Width(); aSet.Put(SwFmtFrmSize(ATT_VAR_SIZE, nWidth)); // Hoehe=Breite fuer konsistentere Vorschau (analog zu Bereich bearbeiten) diff --git a/sw/source/ui/docvw/edtwin.cxx b/sw/source/ui/docvw/edtwin.cxx index 7d8e38443ca0..cdaa09f0a549 100644 --- a/sw/source/ui/docvw/edtwin.cxx +++ b/sw/source/ui/docvw/edtwin.cxx @@ -50,16 +50,12 @@ #include #include #include -#ifndef __SBX_SBXVARIABLE_HXX //autogen #include -#endif #include #include #include #include -#ifndef _SFX_CLIENTSH_HXX #include -#endif #include #include #include @@ -69,9 +65,6 @@ #include #include #include -//#ifndef _SVDVMARK_HXX //autogen -//#include -//#endif #include #include #include @@ -128,12 +121,8 @@ #include #include -#ifndef _HELPID_H #include -#endif -#ifndef _CMDID_H #include -#endif #ifndef _DOCVW_HRC #include #endif @@ -1019,7 +1008,7 @@ void SwEditWin::ChangeFly( BYTE nDir, BOOL bWeb ) default: ASSERT( TRUE, "ChangeFly: Unknown direction." ); } BOOL bSet = FALSE; - if( FLY_IN_CNTNT == eAnchorId && ( nDir % 2 ) ) + if ((FLY_AS_CHAR == eAnchorId) && ( nDir % 2 )) { long aDiff = aTmp.Top() - aRefPoint.Y(); if( aDiff > 0 ) @@ -1064,7 +1053,8 @@ void SwEditWin::ChangeFly( BYTE nDir, BOOL bWeb ) aSet.Put( aVert ); bSet = TRUE; } - if( bWeb && FLY_AT_CNTNT == eAnchorId && ( nDir==MOVE_LEFT_SMALL || nDir==MOVE_RIGHT_BIG ) ) + if (bWeb && (FLY_AT_PARA == eAnchorId) + && ( nDir==MOVE_LEFT_SMALL || nDir==MOVE_RIGHT_BIG )) { SwFmtHoriOrient aHori( (SwFmtHoriOrient&)aSet.Get(RES_HORI_ORIENT) ); sal_Int16 eNew; @@ -1091,11 +1081,13 @@ void SwEditWin::ChangeFly( BYTE nDir, BOOL bWeb ) rSh.StartAllAction(); if( bSet ) rSh.SetFlyFrmAttr( aSet ); - BOOL bSetPos = FLY_IN_CNTNT != eAnchorId; + BOOL bSetPos = (FLY_AS_CHAR != eAnchorId); if(bSetPos && bWeb) { - if(FLY_PAGE != eAnchorId) + if (FLY_AT_PAGE != eAnchorId) + { bSetPos = FALSE; + } else { bSetPos = (::GetHtmlMode(rView.GetDocShell()) & HTMLMODE_SOME_ABS_POS) ? @@ -1185,7 +1177,8 @@ void SwEditWin::ChangeDrawing( BYTE nDir ) BOOL bDummy; const bool bVertAnchor = rSh.IsFrmVertical( TRUE, bDummy ); const bool bHoriMove = !bVertAnchor == !( nDir % 2 ); - const bool bMoveAllowed = !bHoriMove || rSh.GetAnchorId() != FLY_IN_CNTNT; + const bool bMoveAllowed = + !bHoriMove || (rSh.GetAnchorId() != FLY_AS_CHAR); if ( bMoveAllowed ) { // <-- diff --git a/sw/source/ui/frmdlg/column.cxx b/sw/source/ui/frmdlg/column.cxx index a9df9762ad92..af0298fe807e 100644 --- a/sw/source/ui/frmdlg/column.cxx +++ b/sw/source/ui/frmdlg/column.cxx @@ -125,7 +125,7 @@ SwColumnDlg::SwColumnDlg(Window* pParent, SwWrtShell& rSh) : FreeResource(); SwRect aRect; - rWrtShell.CalcBoundRect(aRect, FLY_IN_CNTNT); + rWrtShell.CalcBoundRect(aRect, FLY_AS_CHAR); nSelectionWidth = aRect.Width(); diff --git a/sw/source/ui/frmdlg/frmmgr.cxx b/sw/source/ui/frmdlg/frmmgr.cxx index bd1e98b37b9e..1d872a47e919 100644 --- a/sw/source/ui/frmdlg/frmmgr.cxx +++ b/sw/source/ui/frmdlg/frmmgr.cxx @@ -31,12 +31,9 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - - #include "cmdid.h" #include "hintids.hxx" - #include #include #include @@ -212,11 +209,11 @@ void SwFlyFrmAttrMgr::InsertFlyFrm(RndStdIds eAnchorType, const Size &rSize, BOOL bAbs ) { - ASSERT( eAnchorType == FLY_PAGE || - eAnchorType == FLY_AT_CNTNT || - eAnchorType == FLY_AUTO_CNTNT || - eAnchorType == FLY_AT_FLY || - eAnchorType == FLY_IN_CNTNT, "Rahmentyp nicht erlaubt" ); + ASSERT( eAnchorType == FLY_AT_PAGE || + eAnchorType == FLY_AT_PARA || + eAnchorType == FLY_AT_CHAR || + eAnchorType == FLY_AT_FLY || + eAnchorType == FLY_AS_CHAR, "invalid frame type" ); if ( bAbs ) SetAbsPos( rPos ); @@ -238,8 +235,8 @@ void SwFlyFrmAttrMgr::SetAnchor( RndStdIds eId ) pOwnSh->GetPageNum( nPhyPageNum, nVirtPageNum ); aSet.Put( SwFmtAnchor( eId, nPhyPageNum ) ); - if( FLY_PAGE == eId || FLY_AT_CNTNT == eId || FLY_AUTO_CNTNT == eId - || FLY_AT_FLY == eId ) + if ((FLY_AT_PAGE == eId) || (FLY_AT_PARA == eId) || (FLY_AT_CHAR == eId) + || (FLY_AT_FLY == eId)) { SwFmtVertOrient aVertOrient( GetVertOrient() ); SwFmtHoriOrient aHoriOrient( GetHoriOrient() ); @@ -319,7 +316,7 @@ void SwFlyFrmAttrMgr::ValidateMetrics( SvxSwFrameValidation& rVal, rVal.nWidth = rVal.nHeight; rVal.nHeight = nTmp; } - if ( eAnchorType == FLY_PAGE || eAnchorType == FLY_AT_FLY ) + if ((eAnchorType == FLY_AT_PAGE) || (eAnchorType == FLY_AT_FLY)) { // MinimalPosition rVal.nMinHPos = aBoundRect.Left(); @@ -369,8 +366,8 @@ void SwFlyFrmAttrMgr::ValidateMetrics( SvxSwFrameValidation& rVal, } // OD 12.11.2003 #i22341# - handle to character anchored objects vertical // aligned at character or top of line in a special case - else if ( eAnchorType == FLY_AT_CNTNT || - ( eAnchorType == FLY_AUTO_CNTNT && + else if ((eAnchorType == FLY_AT_PARA) || + ((eAnchorType == FLY_AT_CHAR) && !(rVal.nVRelOrient == text::RelOrientation::CHAR) && !(rVal.nVRelOrient == text::RelOrientation::TEXT_LINE) ) ) { @@ -437,7 +434,7 @@ void SwFlyFrmAttrMgr::ValidateMetrics( SvxSwFrameValidation& rVal, // vertical aligned at character or top of line. // Note: (1) positive vertical values are positions above the top of line // (2) negative vertical values are positions below the top of line - else if ( eAnchorType == FLY_AUTO_CNTNT && + else if ( (eAnchorType == FLY_AT_CHAR) && ( rVal.nVRelOrient == text::RelOrientation::CHAR || rVal.nVRelOrient == text::RelOrientation::TEXT_LINE ) ) { @@ -484,7 +481,7 @@ void SwFlyFrmAttrMgr::ValidateMetrics( SvxSwFrameValidation& rVal, rVal.nMaxHeight = aBoundRect.Height(); } } - else if ( eAnchorType == FLY_IN_CNTNT ) + else if ( eAnchorType == FLY_AS_CHAR ) { rVal.nMinHPos = 0; rVal.nMaxHPos = 0; diff --git a/sw/source/ui/frmdlg/frmpage.cxx b/sw/source/ui/frmdlg/frmpage.cxx index dc9fe2d1bf2e..c95f97e5ae59 100644 --- a/sw/source/ui/frmdlg/frmpage.cxx +++ b/sw/source/ui/frmdlg/frmpage.cxx @@ -37,12 +37,8 @@ #include #include -#ifndef _CMDID_H #include -#endif -#ifndef _HELPID_H #include -#endif #include #include #include @@ -68,9 +64,7 @@ #include #include #include -#ifndef _DOCSH_HXX #include -#endif #include #include #include @@ -881,10 +875,10 @@ void SwFrmPage::Reset( const SfxItemSet &rSet ) // Allgemeiner Initialisierungteil switch(rAnchor.GetAnchorId()) { - case FLY_PAGE: aAnchorAtPageRB.Check(); break; - case FLY_AT_CNTNT: aAnchorAtParaRB.Check(); break; - case FLY_AUTO_CNTNT: aAnchorAtCharRB.Check(); break; - case FLY_IN_CNTNT: aAnchorAsCharRB.Check(); break; + case FLY_AT_PAGE: aAnchorAtPageRB.Check(); break; + case FLY_AT_PARA: aAnchorAtParaRB.Check(); break; + case FLY_AT_CHAR: aAnchorAtCharRB.Check(); break; + case FLY_AS_CHAR: aAnchorAsCharRB.Check(); break; case FLY_AT_FLY: aAnchorAtFrameRB.Check();break; default:; //prevent warning } @@ -911,7 +905,7 @@ void SwFrmPage::Reset( const SfxItemSet &rSet ) } if( 0 == (nHtmlMode & HTMLMODE_SOME_ABS_POS)) { - if(GetAnchor() == FLY_PAGE) + if (GetAnchor() == FLY_AT_PAGE) { aAnchorAtParaRB.Check(); } @@ -1048,8 +1042,10 @@ BOOL SwFrmPage::FillItemSet(SfxItemSet &rSet) // Vertikale Position // fuer zeichengebundene Rahmen Offset umrechenen SwTwips nY = static_cast< SwTwips >(aAtVertPosED.Denormalize(aAtVertPosED.GetValue(FUNIT_TWIP))); - if (eAnchorId == FLY_IN_CNTNT) + if (eAnchorId == FLY_AS_CHAR) + { nY *= -1; + } aVertOrient.SetPos( nY ); } pOldItem = GetOldItem(rSet, FN_VERT_ORIENT); @@ -1188,7 +1184,7 @@ void SwFrmPage::InitPos(RndStdIds eId, } BOOL bEnable = TRUE; - if ( eId == FLY_PAGE ) + if ( eId == FLY_AT_PAGE ) { pVMap = bHtmlMode ? aVPageHtmlMap : aVPageMap; pHMap = bHtmlMode ? aHPageHtmlMap : aHPageMap; @@ -1200,7 +1196,7 @@ void SwFrmPage::InitPos(RndStdIds eId, pVMap = bHtmlMode ? aVFlyHtmlMap : aVFrameMap; pHMap = bHtmlMode ? aHFlyHtmlMap : aHFrameMap; } - else if ( eId == FLY_AT_CNTNT ) + else if ( eId == FLY_AT_PARA ) { if(bHtmlMode) { @@ -1213,7 +1209,7 @@ void SwFrmPage::InitPos(RndStdIds eId, pHMap = aHParaMap; } } - else if ( eId == FLY_AUTO_CNTNT ) + else if ( eId == FLY_AT_CHAR ) { if(bHtmlMode) { @@ -1226,7 +1222,7 @@ void SwFrmPage::InitPos(RndStdIds eId, pHMap = aHCharMap; } } - else if ( eId == FLY_IN_CNTNT ) + else if ( eId == FLY_AS_CHAR ) { pVMap = bHtmlMode ? aVAsCharHtmlMap : aVAsCharMap; pHMap = 0; @@ -1257,7 +1253,7 @@ void SwFrmPage::InitPos(RndStdIds eId, FillRelLB(pVMap, nMapPos, nV, nVRel, aVertRelationLB, aVertRelationFT); // Edits init - bEnable = nH == text::HoriOrientation::NONE && eId != FLY_IN_CNTNT;//#61359# warum nicht in Formaten&& !bFormat; + bEnable = nH == text::HoriOrientation::NONE && eId != FLY_AS_CHAR; if (!bEnable) { aAtHorzPosED.SetValue( 0, FUNIT_TWIP ); @@ -1281,7 +1277,7 @@ void SwFrmPage::InitPos(RndStdIds eId, } else { - if ( eId == FLY_IN_CNTNT ) + if ( eId == FLY_AS_CHAR ) { if ( nY == LONG_MAX ) nY = 0; @@ -1608,15 +1604,23 @@ USHORT SwFrmPage::GetMapPos( const FrmMap *pMap, ListBox &rAlignLB ) RndStdIds SwFrmPage::GetAnchor() { - RndStdIds nRet = FLY_PAGE; + RndStdIds nRet = FLY_AT_PAGE; if(aAnchorAtParaRB.IsChecked()) - nRet = FLY_AT_CNTNT; + { + nRet = FLY_AT_PARA; + } else if(aAnchorAtCharRB.IsChecked()) - nRet = FLY_AUTO_CNTNT; + { + nRet = FLY_AT_CHAR; + } else if(aAnchorAsCharRB.IsChecked()) - nRet = FLY_IN_CNTNT; + { + nRet = FLY_AS_CHAR; + } else if(aAnchorAtFrameRB.IsChecked()) + { nRet = FLY_AT_FLY; + } return nRet; } @@ -1818,8 +1822,10 @@ IMPL_LINK( SwFrmPage, RangeModifyHdl, Edit *, EMPTYARG ) if ( aVal.nHPos != nAtHorzPosVal ) aAtHorzPosED.SetValue(aAtHorzPosED.Normalize(aVal.nHPos), FUNIT_TWIP); - SwTwips nUpperOffset = aVal.nAnchorType == FLY_IN_CNTNT ? nUpperBorder : 0; - SwTwips nLowerOffset = aVal.nAnchorType == FLY_IN_CNTNT ? nLowerBorder : 0; + const SwTwips nUpperOffset = (aVal.nAnchorType == FLY_AS_CHAR) + ? nUpperBorder : 0; + const SwTwips nLowerOffset = (aVal.nAnchorType == FLY_AS_CHAR) + ? nLowerBorder : 0; aAtVertPosED.SetMin(aAtVertPosED.Normalize(aVal.nMinVPos + nLowerOffset + nUpperOffset), FUNIT_TWIP); aAtVertPosED.SetMax(aAtVertPosED.Normalize(aVal.nMaxVPos), FUNIT_TWIP); @@ -1905,7 +1911,7 @@ IMPL_LINK( SwFrmPage, PosHdl, ListBox *, pLB ) // Sonderbehandlung fuer HTML-Mode mit horz-vert-Abhaengigkeiten if(bHtmlMode && nHtmlMode&HTMLMODE_SOME_ABS_POS && - FLY_AUTO_CNTNT == (RndStdIds)GetAnchor()) + (FLY_AT_CHAR == GetAnchor())) { BOOL bSet = FALSE; if(bHori) @@ -1977,7 +1983,7 @@ IMPL_LINK( SwFrmPage, RelHdl, ListBox *, pLB ) else bAtVertPosModified = TRUE; - if(bHtmlMode && FLY_AUTO_CNTNT == (RndStdIds)GetAnchor()) // wieder Sonderbehandlung + if (bHtmlMode && (FLY_AT_CHAR == GetAnchor())) { if(bHori) { @@ -2219,7 +2225,7 @@ void SwFrmPage::Init(const SfxItemSet& rSet, BOOL bReset) nOldV = rVert.GetVertOrient(), nOldVRel = rVert.GetRelationOrient(); - if (eAnchorId == FLY_PAGE) + if (eAnchorId == FLY_AT_PAGE) { if (nOldHRel == text::RelOrientation::FRAME) nOldHRel = text::RelOrientation::PAGE_FRAME; diff --git a/sw/source/ui/frmdlg/wrap.cxx b/sw/source/ui/frmdlg/wrap.cxx index b3828797fc07..4479b7da8b1e 100644 --- a/sw/source/ui/frmdlg/wrap.cxx +++ b/sw/source/ui/frmdlg/wrap.cxx @@ -36,7 +36,6 @@ #endif - #include "hintids.hxx" #include #include @@ -141,7 +140,7 @@ SwWrapTabPage::SwWrapTabPage(Window *pParent, const SfxItemSet &rSet) : aWrapIL (SW_RES(IL_WRAP)), aWrapILH (SW_RES(ILH_WRAP)), - nAnchorId(FLY_AT_CNTNT), + nAnchorId(FLY_AT_PARA), nHtmlMode(0), pWrtSh(0), @@ -254,10 +253,15 @@ void SwWrapTabPage::Reset(const SfxItemSet &rSet) const SwFmtAnchor &rAnch = (const SwFmtAnchor&)rSet.Get(RES_ANCHOR); nAnchorId = rAnch.GetAnchorId(); - if ( (nAnchorId == FLY_AT_CNTNT || nAnchorId == FLY_AUTO_CNTNT) && nSur != SURROUND_NONE ) + if (((nAnchorId == FLY_AT_PARA) || (nAnchorId == FLY_AT_CHAR)) + && (nSur != SURROUND_NONE)) + { aWrapAnchorOnlyCB.Check( rSurround.IsAnchorOnly() ); + } else + { aWrapAnchorOnlyCB.Enable( FALSE ); + } BOOL bContour = rSurround.IsContour(); aWrapOutlineCB.Check( bContour ); @@ -452,7 +456,7 @@ void SwWrapTabPage::ActivatePage(const SfxItemSet& rSet) // Anchor const SwFmtAnchor &rAnch = (const SwFmtAnchor&)rSet.Get(RES_ANCHOR); nAnchorId = rAnch.GetAnchorId(); - BOOL bEnable = nAnchorId != FLY_IN_CNTNT; + BOOL bEnable = (nAnchorId != FLY_AS_CHAR); if (!bDrawMode) { @@ -521,7 +525,7 @@ void SwWrapTabPage::ActivatePage(const SfxItemSet& rSet) } else { - if (aVal.nAnchorType == FLY_IN_CNTNT) + if (aVal.nAnchorType == FLY_AS_CHAR) { nLeft = nRight; @@ -566,7 +570,8 @@ void SwWrapTabPage::ActivatePage(const SfxItemSet& rSet) sal_Int16 eHOrient = rHori.GetHoriOrient(); sal_Int16 eHRelOrient = rHori.GetRelationOrient(); aWrapOutlineCB.Hide(); - BOOL bAllHtmlModes = (nAnchorId == FLY_AT_CNTNT || nAnchorId == FLY_AUTO_CNTNT) && + const bool bAllHtmlModes = + ((nAnchorId == FLY_AT_PARA) || (nAnchorId == FLY_AT_CHAR)) && (eHOrient == text::HoriOrientation::RIGHT || eHOrient == text::HoriOrientation::LEFT); aWrapAnchorOnlyCB.Enable( bAllHtmlModes && nSur != SURROUND_NONE ); aWrapOutsideCB.Hide(); @@ -574,17 +579,26 @@ void SwWrapTabPage::ActivatePage(const SfxItemSet& rSet) aWrapTransparentCB.Enable( FALSE ); - aNoWrapRB.Enable( FLY_AT_CNTNT == nAnchorId ); + aNoWrapRB.Enable( FLY_AT_PARA == nAnchorId ); aWrapParallelRB.Enable( FALSE ); - aWrapLeftRB .Enable( FLY_AT_CNTNT == nAnchorId || - (FLY_AUTO_CNTNT == nAnchorId && eHOrient == text::HoriOrientation::RIGHT && eHRelOrient == text::RelOrientation::PRINT_AREA)); - aWrapRightRB .Enable( FLY_AT_CNTNT == nAnchorId || - ( FLY_AUTO_CNTNT == nAnchorId && eHOrient == text::HoriOrientation::LEFT && eHRelOrient == text::RelOrientation::PRINT_AREA)); - - aWrapThroughRB.Enable( (FLY_PAGE == nAnchorId || - (FLY_AUTO_CNTNT == nAnchorId && eHRelOrient != text::RelOrientation::PRINT_AREA) || FLY_AT_CNTNT == nAnchorId ) - && bSomeAbsPos && - eHOrient != text::HoriOrientation::RIGHT); + aWrapLeftRB .Enable + ( (FLY_AT_PARA == nAnchorId) + || ( (FLY_AT_CHAR == nAnchorId) + && (eHOrient == text::HoriOrientation::RIGHT) + && (eHRelOrient == text::RelOrientation::PRINT_AREA))); + aWrapRightRB .Enable + ( (FLY_AT_PARA == nAnchorId) + || ( (FLY_AT_CHAR == nAnchorId) + && (eHOrient == text::HoriOrientation::LEFT) + && (eHRelOrient == text::RelOrientation::PRINT_AREA))); + + aWrapThroughRB.Enable + ( ( (FLY_AT_PAGE == nAnchorId) + || ( (FLY_AT_CHAR == nAnchorId) + && (eHRelOrient != text::RelOrientation::PRINT_AREA)) + || (FLY_AT_PARA == nAnchorId)) + && bSomeAbsPos + && (eHOrient != text::HoriOrientation::RIGHT)); if(aNoWrapRB.IsChecked() && !aNoWrapRB.IsEnabled()) { if(aWrapThroughRB.IsEnabled()) @@ -624,7 +638,8 @@ void SwWrapTabPage::ActivatePage(const SfxItemSet& rSet) aIdealWrapRB.Enable( bEnable ); aWrapThroughRB.Enable( bEnable ); aWrapParallelRB.Enable( bEnable ); - aWrapAnchorOnlyCB.Enable( (nAnchorId == FLY_AT_CNTNT || nAnchorId == FLY_AUTO_CNTNT) + aWrapAnchorOnlyCB.Enable( + ((nAnchorId == FLY_AT_PARA) || (nAnchorId == FLY_AT_CHAR)) && nSur != SURROUND_NONE ); } ContourHdl(0); @@ -693,10 +708,11 @@ IMPL_LINK( SwWrapTabPage, WrapTypeHdl, ImageRadioButton *, pBtn ) { BOOL bWrapThrough = (pBtn == &aWrapThroughRB); aWrapTransparentCB.Enable( bWrapThrough && !bHtmlMode ); - bWrapThrough |= ( nAnchorId == FLY_IN_CNTNT ); + bWrapThrough |= ( nAnchorId == FLY_AS_CHAR ); aWrapOutlineCB.Enable( !bWrapThrough && pBtn != &aNoWrapRB); aWrapOutsideCB.Enable( !bWrapThrough && aWrapOutlineCB.IsChecked() ); - aWrapAnchorOnlyCB.Enable( (nAnchorId == FLY_AT_CNTNT || nAnchorId == FLY_AUTO_CNTNT) && + aWrapAnchorOnlyCB.Enable( + ((nAnchorId == FLY_AT_PARA) || (nAnchorId == FLY_AT_CHAR)) && (pBtn != &aNoWrapRB) ); ContourHdl(0); diff --git a/sw/source/ui/ribbar/conrect.cxx b/sw/source/ui/ribbar/conrect.cxx index e5540dab1c11..51cdc5a72a1f 100644 --- a/sw/source/ui/ribbar/conrect.cxx +++ b/sw/source/ui/ribbar/conrect.cxx @@ -43,21 +43,14 @@ #include #include #include -#ifndef _CMDID_H #include -#endif -#ifndef _VIEW_HXX #include -#endif #include #include #include -#ifndef _DRAWBASE_HXX #include -#endif -#ifndef _CONRECT_HXX #include -#endif + /************************************************************************* |* @@ -119,7 +112,7 @@ BOOL ConstRectangle::MouseButtonUp(const MouseEvent& rMEvt) case OBJ_TEXT: if( bMarquee ) { - m_pSh->ChgAnchor(FLY_IN_CNTNT); + m_pSh->ChgAnchor(FLY_AS_CHAR); if( pObj ) { diff --git a/sw/source/ui/ribbar/drawbase.cxx b/sw/source/ui/ribbar/drawbase.cxx index f6a48d36cd68..aa33c637f44c 100644 --- a/sw/source/ui/ribbar/drawbase.cxx +++ b/sw/source/ui/ribbar/drawbase.cxx @@ -344,7 +344,8 @@ BOOL SwDrawBase::MouseButtonUp(const MouseEvent& rMEvt) if ( xRecorder.is() ) { SfxRequest aReq(m_pSh->GetView().GetViewFrame(),FN_INSERT_FRAME); - aReq.AppendItem(SfxUInt16Item( FN_INSERT_FRAME, (USHORT)FLY_AT_CNTNT )); + aReq.AppendItem(SfxUInt16Item( FN_INSERT_FRAME, + static_cast(FLY_AT_PARA) )); aReq.AppendItem(SfxPointItem( FN_PARAM_1, m_pSh->GetAnchorObjDiff())); aReq.AppendItem(SvxSizeItem( FN_PARAM_2, m_pSh->GetObjSize())); aReq.Done(); diff --git a/sw/source/ui/shells/basesh.cxx b/sw/source/ui/shells/basesh.cxx index 6bb599e44867..93b74d40040f 100644 --- a/sw/source/ui/shells/basesh.cxx +++ b/sw/source/ui/shells/basesh.cxx @@ -100,9 +100,7 @@ #include #include #include -#ifndef _CMDID_H #include -#endif #ifndef _GLOBALS_HRC #include #endif @@ -1063,14 +1061,14 @@ void SwBaseShell::Execute(SfxRequest &rReq) case FN_TOOL_ANKER_FRAME: { RndStdIds eSet = nSlot == FN_TOOL_ANKER_PAGE - ? FLY_PAGE + ? FLY_AT_PAGE : nSlot == FN_TOOL_ANKER_PARAGRAPH - ? FLY_AT_CNTNT + ? FLY_AT_PARA : nSlot == FN_TOOL_ANKER_FRAME ? FLY_AT_FLY : nSlot == FN_TOOL_ANKER_CHAR - ? FLY_IN_CNTNT - : FLY_AUTO_CNTNT; + ? FLY_AS_CHAR + : FLY_AT_CHAR; rSh.StartUndo(); if( rSh.IsObjSelected() ) rSh.ChgAnchor( eSet ); @@ -1101,7 +1099,7 @@ void SwBaseShell::Execute(SfxRequest &rReq) switch( eSet ) { case FLY_AT_FLY: - case FLY_PAGE: + case FLY_AT_PAGE: //Durchlauf, links oder von links, oben, von oben if(eSurround != SURROUND_THROUGHT) @@ -1114,7 +1112,7 @@ void SwBaseShell::Execute(SfxRequest &rReq) aSet.Put(SwFmtHoriOrient(0, text::HoriOrientation::LEFT)); break; - case FLY_AT_CNTNT: + case FLY_AT_PARA: //links, von links, rechts, oben, kein Uml, li+re Umlauf, if(eSurround != SURROUND_LEFT || eSurround != SURROUND_RIGHT) aSet.Put(SwFmtSurround(SURROUND_LEFT)); @@ -1126,7 +1124,7 @@ void SwBaseShell::Execute(SfxRequest &rReq) aSet.Put(SwFmtHoriOrient(0, text::HoriOrientation::LEFT)); break; - case FLY_AUTO_CNTNT: + case FLY_AT_CHAR: //links, von links, rechts, oben, Durchlauf if(eSurround != SURROUND_THROUGHT) aSet.Put(SwFmtSurround(SURROUND_THROUGHT)); @@ -1624,12 +1622,17 @@ void SwBaseShell::GetState( SfxItemSet &rSet ) else rSh.GetFlyFrmAttr(aSet); RndStdIds eSet = ((SwFmtAnchor&)aSet.Get(RES_ANCHOR)).GetAnchorId(); - BOOL bSet; - bSet = (nWhich == FN_TOOL_ANKER_PAGE && eSet == FLY_PAGE) || - (nWhich == FN_TOOL_ANKER_PARAGRAPH && eSet == FLY_AT_CNTNT) || - (nWhich == FN_TOOL_ANKER_FRAME && eSet == FLY_AT_FLY) || - (nWhich == FN_TOOL_ANKER_AT_CHAR && eSet == FLY_AUTO_CNTNT) || - (nWhich == FN_TOOL_ANKER_CHAR && eSet == FLY_IN_CNTNT); + const BOOL bSet = + ((nWhich == FN_TOOL_ANKER_PAGE) && + (eSet == FLY_AT_PAGE)) + || ((nWhich == FN_TOOL_ANKER_PARAGRAPH) && + (eSet == FLY_AT_PARA)) + || ((nWhich == FN_TOOL_ANKER_FRAME) && + (eSet == FLY_AT_FLY)) + || ((nWhich == FN_TOOL_ANKER_AT_CHAR) && + (eSet == FLY_AT_CHAR)) + || ((nWhich == FN_TOOL_ANKER_CHAR) && + (eSet == FLY_AS_CHAR)); if(nWhich != FN_TOOL_ANKER) { USHORT nHtmlMode = ::GetHtmlMode(GetView().GetDocShell()); @@ -1646,16 +1649,16 @@ void SwBaseShell::GetState( SfxItemSet &rSet ) switch (eSet) { - case FLY_PAGE: + case FLY_AT_PAGE: nSlotId = FN_TOOL_ANKER_PAGE; break; - case FLY_AT_CNTNT: + case FLY_AT_PARA: nSlotId = FN_TOOL_ANKER_PARAGRAPH; break; - case FLY_IN_CNTNT: + case FLY_AS_CHAR: nSlotId = FN_TOOL_ANKER_CHAR; break; - case FLY_AUTO_CNTNT: + case FLY_AT_CHAR: nSlotId = FN_TOOL_ANKER_AT_CHAR; break; case FLY_AT_FLY: @@ -1705,15 +1708,18 @@ void SwBaseShell::GetState( SfxItemSet &rSet ) SwSurround nSurround = rWrap.GetSurround(); BOOL bSet = FALSE; - BOOL bDisable = nAnchorType == - 1 || nAnchorType == FLY_IN_CNTNT; - BOOL bHtmlMode = 0 != ::GetHtmlMode(GetView().GetDocShell()); + bool bDisable = + (nAnchorType == - 1) || (nAnchorType == FLY_AS_CHAR); + const bool bHtmlMode = + 0 != ::GetHtmlMode(GetView().GetDocShell()); switch( nWhich ) { case FN_FRAME_NOWRAP: bDisable |= - ( nAnchorType != FLY_AT_CNTNT && - nAnchorType != FLY_AUTO_CNTNT && nAnchorType != FLY_PAGE); + ( (nAnchorType != FLY_AT_PARA) + && (nAnchorType != FLY_AT_CHAR) + && (nAnchorType != FLY_AT_PAGE)); bSet = nSurround == SURROUND_NONE; break; case FN_FRAME_WRAP: @@ -1726,7 +1732,9 @@ void SwBaseShell::GetState( SfxItemSet &rSet ) break; case FN_FRAME_WRAPTHRU: bDisable |= (bHtmlMode || - (nAnchorType != FLY_AT_CNTNT&& nAnchorType != FLY_AUTO_CNTNT && nAnchorType != FLY_PAGE)); + ( (nAnchorType != FLY_AT_PARA) + && (nAnchorType != FLY_AT_CHAR) + && (nAnchorType != FLY_AT_PAGE))); if(bObj) bSet = nSurround == SURROUND_THROUGHT && rSh.GetLayerId(); else @@ -1766,7 +1774,7 @@ void SwBaseShell::GetState( SfxItemSet &rSet ) break; case FN_WRAP_ANCHOR_ONLY: bDisable |= (bHtmlMode || - (nAnchorType != FLY_AT_CNTNT)); + (nAnchorType != FLY_AT_PARA)); bSet = rWrap.IsAnchorOnly(); break; case FN_FRAME_WRAP_LEFT: diff --git a/sw/source/ui/shells/drwbassh.cxx b/sw/source/ui/shells/drwbassh.cxx index 339c332c9135..2de9201bffdd 100644 --- a/sw/source/ui/shells/drwbassh.cxx +++ b/sw/source/ui/shells/drwbassh.cxx @@ -49,9 +49,7 @@ #include #include #include -#ifndef _CMDID_H #include -#endif #include #include #include @@ -479,7 +477,7 @@ void SwDrawBaseShell::Execute(SfxRequest &rReq) { // Objekte nicht aneinander ausrichten USHORT nAnchor = pSh->GetAnchorId(); - if (nAnchor == FLY_IN_CNTNT) + if (nAnchor == FLY_AS_CHAR) { sal_Int16 nVertOrient = -1; @@ -509,7 +507,7 @@ void SwDrawBaseShell::Execute(SfxRequest &rReq) } break; } - if (nAnchor == FLY_AT_CNTNT) + if (nAnchor == FLY_AT_PARA) break; // Absatzverankerte Rahmen nicht ausrichten } @@ -855,7 +853,7 @@ IMPL_LINK(SwDrawBaseShell, ValidatePosition, SvxSwFrameValidation*, pValidation pValidation->nWidth = pValidation->nHeight; pValidation->nHeight = nTmp; } - if ( eAnchorType == FLY_PAGE || eAnchorType == FLY_AT_FLY ) + if ((eAnchorType == FLY_AT_PAGE) || (eAnchorType == FLY_AT_FLY)) { // MinimalPosition pValidation->nMinHPos = aBoundRect.Left(); @@ -903,7 +901,7 @@ IMPL_LINK(SwDrawBaseShell, ValidatePosition, SvxSwFrameValidation*, pValidation pValidation->nMaxVPos = aBoundRect.Bottom() - pValidation->nHeight; pValidation->nMaxWidth = aBoundRect.Right() - nH; } - else if ( eAnchorType == FLY_AT_CNTNT || eAnchorType == FLY_AUTO_CNTNT ) + else if ((eAnchorType == FLY_AT_PARA) || (eAnchorType == FLY_AT_CHAR)) { if (pValidation->nHPos + pValidation->nWidth > aBoundRect.Right()) { @@ -964,7 +962,7 @@ IMPL_LINK(SwDrawBaseShell, ValidatePosition, SvxSwFrameValidation*, pValidation pValidation->nMaxHeight = pValidation->nMaxVPos + pValidation->nHeight - nV; pValidation->nMaxWidth = pValidation->nMaxHPos + pValidation->nWidth - nH; } - else if ( eAnchorType == FLY_IN_CNTNT ) + else if (eAnchorType == FLY_AS_CHAR) { pValidation->nMinHPos = 0; pValidation->nMaxHPos = 0; diff --git a/sw/source/ui/shells/textdrw.cxx b/sw/source/ui/shells/textdrw.cxx index 1d10c885bc17..77a88a5a33ea 100644 --- a/sw/source/ui/shells/textdrw.cxx +++ b/sw/source/ui/shells/textdrw.cxx @@ -39,23 +39,17 @@ #include #include -#ifndef _VIEW_HXX #include -#endif #include #include #include -#ifndef _BASESH_HXX #include -#endif #ifndef _POOLFMT_HRC #include #endif -#ifndef _DOCSH_HXX #include -#endif #include #include #include diff --git a/sw/source/ui/shells/textidx.cxx b/sw/source/ui/shells/textidx.cxx index 3eb67f725acd..8ad65538640f 100644 --- a/sw/source/ui/shells/textidx.cxx +++ b/sw/source/ui/shells/textidx.cxx @@ -32,9 +32,7 @@ #include "precompiled_sw.hxx" #include -#ifndef _MSGBOX_HXX //autogen #include -#endif #include #include #include @@ -55,6 +53,8 @@ #include "swabstdlg.hxx" #include #include + + // STATIC DATA ----------------------------------------------------------- void SwTextShell::ExecIdx(SfxRequest &rReq) @@ -136,7 +136,7 @@ void SwTextShell::ExecIdx(SfxRequest &rReq) 0 ); SwWrtShell& rSh = GetShell(); SwRect aRect; - rSh.CalcBoundRect(aRect, FLY_IN_CNTNT); + rSh.CalcBoundRect(aRect, FLY_AS_CHAR); long nWidth = aRect.Width(); aSet.Put(SwFmtFrmSize(ATT_VAR_SIZE, nWidth)); diff --git a/sw/source/ui/shells/textsh.cxx b/sw/source/ui/shells/textsh.cxx index 7e38c1297d0b..6dffd49dd8c3 100644 --- a/sw/source/ui/shells/textsh.cxx +++ b/sw/source/ui/shells/textsh.cxx @@ -39,9 +39,7 @@ #include #include -#ifndef __RSC //autogen #include -#endif #include #include #include @@ -82,9 +80,7 @@ #include #include #include -#ifndef _CMDID_H #include -#endif #ifndef _GLOBALS_HRC #include #endif @@ -112,9 +108,7 @@ #ifndef _POPUP_HRC #include #endif -#ifndef _SWERROR_H #include -#endif #include #include @@ -566,7 +560,7 @@ void SwTextShell::ExecInsert(SfxRequest &rReq) aCol.Init( nCols, aCol.GetGutterWidth(), aCol.GetWishWidth() ); aMgr.SetCol( aCol ); } - aMgr.InsertFlyFrm(FLY_AT_CNTNT, aStartPos, aSize); + aMgr.InsertFlyFrm(FLY_AT_PARA, aStartPos, aSize); GetShell().EndAllAction(); GetShell().UnlockPaint(); } @@ -600,7 +594,7 @@ void SwTextShell::ExecInsert(SfxRequest &rReq) Size aSize(aMgr.GetSize()); aSize.Width() = GetShell().GetAnyCurRect(RECT_PAGE_PRT).Width(); Point aPos = aMgr.GetPos(); - RndStdIds eAnchor = FLY_AT_CNTNT; + RndStdIds eAnchor = FLY_AT_PARA; if(pArgs->GetItemState(nSlot, FALSE, &pItem) == SFX_ITEM_SET) eAnchor = (RndStdIds)((SfxUInt16Item *)pItem)->GetValue(); if(pArgs->GetItemState(FN_PARAM_1, FALSE, &pItem) == SFX_ITEM_SET) @@ -764,7 +758,7 @@ void SwTextShell::ExecInsert(SfxRequest &rReq) SwFlyFrmAttrMgr aFrmMgr( TRUE, &rSh, FRMMGR_TYPE_GRF ); // am FrmMgr muessen die richtigen Parameter eingestellt werden - aFrmMgr.SetAnchor(FLY_IN_CNTNT); + aFrmMgr.SetAnchor(FLY_AS_CHAR); rSh.SplitNode( FALSE, FALSE ); rSh.SplitNode( FALSE, FALSE ); diff --git a/sw/source/ui/uiview/view2.cxx b/sw/source/ui/uiview/view2.cxx index 77c06f44c494..dea0dc3d096b 100644 --- a/sw/source/ui/uiview/view2.cxx +++ b/sw/source/ui/uiview/view2.cxx @@ -34,12 +34,6 @@ #include #include -// #ifndef _COM_SUN_STAR_LANG_LOCALE_HPP_ -// #include -// #endif -// #ifndef _COM_SUN_STAR_UI_DIALOGS_XFILEPICKER_HPP_ -// #include -// #endif #include #include #include @@ -49,9 +43,6 @@ #include #include -// #ifndef _FILTER_HXX -// #include -// #endif #include #include #include @@ -69,12 +60,8 @@ #include #include #include -#ifndef _APP_HXX //autogen #include -#endif -#ifndef _WRKWIN_HXX //autogen #include -#endif #include #include #include @@ -94,9 +81,7 @@ #include #include #include -#ifndef __RSC //autogen #include -#endif #include #include #include @@ -148,10 +133,6 @@ #include #include -// #ifndef _FRMMGR_HXX -// #include -// #endif - #include //#outline level,added by zhaojianwei #include diff --git a/sw/source/ui/uiview/viewtab.cxx b/sw/source/ui/uiview/viewtab.cxx index 6223d1d0234a..592be8bc1d73 100644 --- a/sw/source/ui/uiview/viewtab.cxx +++ b/sw/source/ui/uiview/viewtab.cxx @@ -347,7 +347,7 @@ void SwView::ExecTabWin( SfxRequest& rReq ) if(aSize.GetWidthPercent()) { SwRect aRect; - rSh.CalcBoundRect(aRect, FLY_IN_CNTNT); + rSh.CalcBoundRect(aRect, FLY_AS_CHAR); long nPrtWidth = aRect.Width(); aSize.SetWidthPercent(BYTE((nPageWidth - aLongLR.GetLeft() - aLongLR.GetRight()) * 100 /nPrtWidth)); } @@ -472,7 +472,7 @@ void SwView::ExecTabWin( SfxRequest& rReq ) if(aSize.GetHeightPercent()) { SwRect aRect; - rSh.CalcBoundRect(aRect, FLY_IN_CNTNT); + rSh.CalcBoundRect(aRect, FLY_AS_CHAR); long nPrtHeight = aRect.Height(); aSize.SetHeightPercent(BYTE(nHeight * 100 /nPrtHeight)); } diff --git a/sw/source/ui/utlui/attrdesc.cxx b/sw/source/ui/utlui/attrdesc.cxx index 14c27c19b137..fcf675c26fcc 100644 --- a/sw/source/ui/utlui/attrdesc.cxx +++ b/sw/source/ui/utlui/attrdesc.cxx @@ -53,9 +53,7 @@ #include #include #include -#ifndef _FMTLINE_HXX #include -#endif #include #include #include @@ -687,13 +685,13 @@ SfxItemPresentation SwFmtAnchor::GetPresentation USHORT nId = 0; switch ( GetAnchorId() ) { - case FLY_AT_CNTNT: //Absatzgebundener Rahmen + case FLY_AT_PARA: nId = STR_FLY_AT_CNTNT; break; - case FLY_IN_CNTNT: //Zeichengebundener Rahmen + case FLY_AS_CHAR: nId = STR_FLY_IN_CNTNT; break; - case FLY_PAGE: //Seitengebundener Rahmen + case FLY_AT_PAGE: nId = STR_FLY_PAGE; break; default:;//prevent warning diff --git a/sw/source/ui/wrtsh/select.cxx b/sw/source/ui/wrtsh/select.cxx index 44a854a7ad4d..9499c44b63a4 100644 --- a/sw/source/ui/wrtsh/select.cxx +++ b/sw/source/ui/wrtsh/select.cxx @@ -39,15 +39,9 @@ #include #include #include -#ifndef _CMDID_H #include -#endif -#ifndef _VIEW_HXX #include -#endif -#ifndef _BASESH_HXX #include -#endif #include #include #include -- cgit From eb1338534074029d8135c9a475cd301a8d11e3e3 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Tue, 5 Jan 2010 16:37:42 +0100 Subject: swunolocking1: calbck.hxx: SwClientIter constructor takes a const& parameter --- sw/inc/calbck.hxx | 5 ++--- sw/source/core/attr/calbck.cxx | 2 +- sw/source/core/inc/frmtool.hxx | 2 +- sw/source/core/layout/frmtool.cxx | 4 ++-- 4 files changed, 6 insertions(+), 7 deletions(-) (limited to 'sw') diff --git a/sw/inc/calbck.hxx b/sw/inc/calbck.hxx index 7a8ff7f8f471..cde55aec812e 100644 --- a/sw/inc/calbck.hxx +++ b/sw/inc/calbck.hxx @@ -202,7 +202,7 @@ class SwClientIter friend SwClient* SwModify::_Remove(SwClient *); // fuer Ptr-Korrektur friend void SwModify::Add(SwClient *); // nur fuer ASSERT ! - SwModify& rRoot; + SwModify const& rRoot; SwClient *pAkt, *pDelNext; // fuers Updaten der aller Iteratoren beim Einfuegen/Loeschen von // Clients, wenn der Iterator gerade draufsteht. @@ -213,11 +213,10 @@ class SwClientIter TypeId aSrchId; // fuer First/Next - suche diesen Type public: - SW_DLLPUBLIC SwClientIter( SwModify& ); + SW_DLLPUBLIC SwClientIter( SwModify const& ); SW_DLLPUBLIC ~SwClientIter(); const SwModify& GetModify() const { return rRoot; } - SwModify& GetModify() { return rRoot; } #ifndef CFRONT SwClient* operator++(int); // zum Naechsten diff --git a/sw/source/core/attr/calbck.cxx b/sw/source/core/attr/calbck.cxx index e4410c26e8bb..a844356d1e2e 100644 --- a/sw/source/core/attr/calbck.cxx +++ b/sw/source/core/attr/calbck.cxx @@ -463,7 +463,7 @@ BOOL SwDepend::GetInfo( SfxPoolItem& rInfo ) const /********************************************************************/ -SwClientIter::SwClientIter( SwModify& rModify ) +SwClientIter::SwClientIter( SwModify const& rModify ) : rRoot( rModify ) { // hinten einketten! diff --git a/sw/source/core/inc/frmtool.hxx b/sw/source/core/inc/frmtool.hxx index ed172b310a01..8cb536f32cba 100644 --- a/sw/source/core/inc/frmtool.hxx +++ b/sw/source/core/inc/frmtool.hxx @@ -141,7 +141,7 @@ const SwFrm * MA_FASTCALL FindPage( const SwRect &rRect, const SwFrm *pPage ); // JP 07.05.98: wird von SwCntntNode::GetFrm und von SwFlyFrm::GetFrm // gerufen -SwFrm* GetFrmOfModify( SwModify&, USHORT nFrmType, const Point* = 0, +SwFrm* GetFrmOfModify( SwModify const&, USHORT const nFrmType, const Point* = 0, const SwPosition *pPos = 0, const BOOL bCalcFrm = FALSE ); diff --git a/sw/source/core/layout/frmtool.cxx b/sw/source/core/layout/frmtool.cxx index f3ac0f966c67..e04b9746a2f8 100644 --- a/sw/source/core/layout/frmtool.cxx +++ b/sw/source/core/layout/frmtool.cxx @@ -3519,8 +3519,8 @@ const SwFrm* MA_FASTCALL FindPage( const SwRect &rRect, const SwFrm *pPage ) return pPage; } -SwFrm* GetFrmOfModify( SwModify& rMod, USHORT nFrmType, const Point* pPoint, - const SwPosition *pPos, const BOOL bCalcFrm ) +SwFrm* GetFrmOfModify( SwModify const& rMod, USHORT const nFrmType, + const Point* pPoint, const SwPosition *pPos, const BOOL bCalcFrm ) { SwFrm *pMinFrm = 0, *pTmpFrm; SwRect aCalcRect; -- cgit From c00fbf426f2add382d18d99ed14a3c48b7d36afb Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Tue, 5 Jan 2010 16:37:42 +0100 Subject: swunolocking1: swtable.hxx: SwTable::FindTable() takes a const parameter --- sw/inc/swtable.hxx | 2 +- sw/source/core/table/swtable.cxx | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'sw') diff --git a/sw/inc/swtable.hxx b/sw/inc/swtable.hxx index 1a62bb3d4dfd..800fd4bb4a18 100644 --- a/sw/inc/swtable.hxx +++ b/sw/inc/swtable.hxx @@ -299,7 +299,7 @@ public: virtual BOOL GetInfo( SfxPoolItem& ) const; // suche im Format nach der angemeldeten Tabelle - static SwTable* FindTable( SwFrmFmt* pFmt ); + static SwTable * FindTable( SwFrmFmt const*const pFmt ); // Struktur ein wenig aufraeumen void GCLines(); diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx index 070e8eb625f9..8e5dc1131e1b 100644 --- a/sw/source/core/table/swtable.cxx +++ b/sw/source/core/table/swtable.cxx @@ -2060,9 +2060,11 @@ BOOL SwTable::GetInfo( SfxPoolItem& rInfo ) const return TRUE; } -SwTable* SwTable::FindTable( SwFrmFmt* pFmt ) +SwTable * SwTable::FindTable( SwFrmFmt const*const pFmt ) { - return pFmt ? (SwTable*)SwClientIter( *pFmt ).First( TYPE(SwTable) ) : 0; + return (pFmt) + ? static_cast(SwClientIter(*pFmt).First( TYPE(SwTable) )) + : 0; } SwTableNode* SwTable::GetTableNode() const -- cgit From 92bbc112a283deee8796f09a1eaa49515979a548 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Tue, 5 Jan 2010 16:37:42 +0100 Subject: swunolocking1: #i105557#: remove unnecessary includes of unoobj.hxx --- sw/inc/chpfld.hxx | 4 +++- sw/inc/unochart.hxx | 10 ++++++++-- sw/inc/unofield.hxx | 8 ++++++-- sw/inc/unoidx.hxx | 15 +++++++++++++-- sw/source/core/doc/docfld.cxx | 7 +------ sw/source/core/fields/expfld.cxx | 2 +- 6 files changed, 32 insertions(+), 14 deletions(-) (limited to 'sw') diff --git a/sw/inc/chpfld.hxx b/sw/inc/chpfld.hxx index 08ebcf93bd5c..0edd6681da58 100644 --- a/sw/inc/chpfld.hxx +++ b/sw/inc/chpfld.hxx @@ -32,9 +32,11 @@ #include "fldbas.hxx" + class SwFrm; +class SwCntntNode; class SwTxtNode; -#include + enum SwChapterFormat { diff --git a/sw/inc/unochart.hxx b/sw/inc/unochart.hxx index 955030cbada8..bc29daa21a4d 100644 --- a/sw/inc/unochart.hxx +++ b/sw/inc/unochart.hxx @@ -32,6 +32,8 @@ #include #include + +#include #include #include #include @@ -48,8 +50,8 @@ #include #include #include - #include + #include //OMultiTypeInterfaceContainerHelper #include // helper for implementations #include // helper for implementations @@ -57,17 +59,21 @@ #include // helper for implementations #include +#include +#include +#include #include -#include +class SfxItemPropertySet; class SwDoc; class SwTable; class SwTableBox; class SwUnoCrsr; struct SwRangeDescriptor; class SwSelBoxes; +class SwFrmFmt; ////////////////////////////////////////////////////////////////////// diff --git a/sw/inc/unofield.hxx b/sw/inc/unofield.hxx index bef657b5b797..092a4bdc56a1 100644 --- a/sw/inc/unofield.hxx +++ b/sw/inc/unofield.hxx @@ -30,14 +30,18 @@ #ifndef _UNOFIELD_HXX #define _UNOFIELD_HXX -#include +#include #include #include +#include + +#include + #include -#include #include #include + class SwFieldType; class SwDoc; class SwFmtFld; diff --git a/sw/inc/unoidx.hxx b/sw/inc/unoidx.hxx index 5ea20f65c89d..ef503926ad1f 100644 --- a/sw/inc/unoidx.hxx +++ b/sw/inc/unoidx.hxx @@ -30,15 +30,26 @@ #ifndef _UNOIDX_HXX #define _UNOIDX_HXX +#include +#include +#include +#include +#include #include #include -#include -#include + +#include + +#include #include #include + + +class SfxItemPropertySet; class SwTOXBaseSection; class SwTOXMark; class SwTOXType; + /* -----------------07.12.98 10:08------------------- * * --------------------------------------------------*/ diff --git a/sw/source/core/doc/docfld.cxx b/sw/source/core/doc/docfld.cxx index fba401974a5b..06999d846c81 100644 --- a/sw/source/core/doc/docfld.cxx +++ b/sw/source/core/doc/docfld.cxx @@ -41,12 +41,8 @@ #define _SVSTDARR_ULONGS #include #endif -#ifndef _APP_HXX //autogen #include -#endif -#ifndef _APP_HXX //autogen #include -#endif #include #include #include @@ -69,14 +65,13 @@ #include #include #include -#ifndef _DBMGR_HXX #include -#endif #include #include #include #include #include +#include #ifndef _POOLFMT_HRC #include // fuer InitFldTypes #endif diff --git a/sw/source/core/fields/expfld.cxx b/sw/source/core/fields/expfld.cxx index 38745a12ba7b..05a8dee4253e 100644 --- a/sw/source/core/fields/expfld.cxx +++ b/sw/source/core/fields/expfld.cxx @@ -31,7 +31,6 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - #include #include #include @@ -41,6 +40,7 @@ #include #include #include +#include #include #include #include -- cgit From 37dee57c4d5640e59c296c926a74a25342afdc2e Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Tue, 5 Jan 2010 16:37:43 +0100 Subject: swunolocking1: #i105557#: unoobj.hxx: split out unorefmark.hxx: move SwXReferenceMark from unoobj.hxx to new unorefmark.hxx. --- sw/inc/unoobj.hxx | 73 ------------ sw/inc/unorefmark.hxx | 199 +++++++++++++++++++++++++++++++ sw/source/core/unocore/unoclbck.cxx | 1 + sw/source/core/unocore/unocoll.cxx | 4 +- sw/source/core/unocore/unocrsrhelper.cxx | 2 +- sw/source/core/unocore/unoportenum.cxx | 1 + sw/source/core/unocore/unorefmk.cxx | 2 +- sw/source/core/unocore/unotext.cxx | 1 + 8 files changed, 206 insertions(+), 77 deletions(-) create mode 100644 sw/inc/unorefmark.hxx (limited to 'sw') diff --git a/sw/inc/unoobj.hxx b/sw/inc/unoobj.hxx index 08f5d2308b66..62cf34e1a580 100644 --- a/sw/inc/unoobj.hxx +++ b/sw/inc/unoobj.hxx @@ -99,7 +99,6 @@ class SwFmtFtn; -class SwFmtRefMark; class GetCurTxtFmtColl; @@ -1416,78 +1415,6 @@ public: //SwClient virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew); }; -/* -----------------27.08.98 15:11------------------- - * - * --------------------------------------------------*/ -typedef ::cppu::WeakImplHelper5 -< - ::com::sun::star::text::XTextContent, - ::com::sun::star::beans::XPropertySet, - ::com::sun::star::lang::XServiceInfo, - ::com::sun::star::container::XNamed, - ::com::sun::star::lang::XUnoTunnel -> -SwRefMarkBaseClass; - -class SwXReferenceMark : public SwRefMarkBaseClass, - public SwClient -{ - SwEventListenerContainer aLstnrCntnr; - SwDoc* pDoc; - const SwFmtRefMark* pMark; - String sMarkName; - BOOL m_bIsDescriptor; - - BOOL IsValid() const {return 0 != GetRegisteredIn();} - void InsertRefMark( SwPaM& rPam, SwXTextCursor * pCursor ); -public: - SwXReferenceMark(SwDoc* pDoc, const SwFmtRefMark* pMark); - ~SwXReferenceMark(); - - TYPEINFO(); - - static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId(); - - //XUnoTunnel - virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); - - //XTextContent - virtual void SAL_CALL attach(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xTextRange) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getAnchor( ) throw(::com::sun::star::uno::RuntimeException); - - //XComponent - virtual void SAL_CALL dispose(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw( ::com::sun::star::uno::RuntimeException ); - - //XNamed - virtual rtl::OUString SAL_CALL getName(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL setName(const rtl::OUString& Name_) throw( ::com::sun::star::uno::RuntimeException ); - //XServiceInfo - virtual rtl::OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual BOOL SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException ); - - //XPropertySet - virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - - //SwClient - virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew); - - void attachToRange(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xTextRange)throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); - - const SwFmtRefMark* GetMark()const {return pMark;} - const String& GetMarkName() const {return sMarkName;} - SwDoc* GetDoc() const{return pDoc;} - void Invalidate(); -}; #endif - diff --git a/sw/inc/unorefmark.hxx b/sw/inc/unorefmark.hxx new file mode 100644 index 000000000000..8a37b5655e9e --- /dev/null +++ b/sw/inc/unorefmark.hxx @@ -0,0 +1,199 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: unoobj.hxx,v $ + * + * $Revision: 1.49 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SW_UNOREFMARK_HXX +#define SW_UNOREFMARK_HXX + +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include + + +class SwDoc; +class SwPaM; +class SwFmtRefMark; +class SwXTextCursor; + + +/* -----------------27.08.98 15:11------------------- + * + * --------------------------------------------------*/ +typedef ::cppu::WeakImplHelper5 +< ::com::sun::star::lang::XUnoTunnel +, ::com::sun::star::lang::XServiceInfo +, ::com::sun::star::beans::XPropertySet +, ::com::sun::star::container::XNamed +, ::com::sun::star::text::XTextContent +> SwXReferenceMark_Base; + +class SwXReferenceMark + : public SwXReferenceMark_Base + , public SwClient +{ + +private: + + SwEventListenerContainer aLstnrCntnr; + SwDoc* pDoc; + const SwFmtRefMark* pMark; + String sMarkName; + BOOL m_bIsDescriptor; + + BOOL IsValid() const {return 0 != GetRegisteredIn();} + void InsertRefMark( SwPaM& rPam, SwXTextCursor * pCursor ); + + virtual ~SwXReferenceMark(); + +public: + + SwXReferenceMark(SwDoc * pDoc, const SwFmtRefMark * pMark); + + void attachToRange( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange >& xTextRange) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + + const SwFmtRefMark* GetMark() const {return pMark;} + const String& GetMarkName() const {return sMarkName;} + SwDoc* GetDoc() const {return pDoc;} + void Invalidate(); + + TYPEINFO(); + + // SwClient + virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + + static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId(); + + // XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( + const ::com::sun::star::uno::Sequence< sal_Int8 >& rIdentifier) + throw (::com::sun::star::uno::RuntimeException); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( + const ::rtl::OUString& rServiceName) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL + getSupportedServiceNames() + throw (::com::sun::star::uno::RuntimeException); + + // XComponent + virtual void SAL_CALL dispose() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addEventListener( + const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XEventListener > & xListener) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeEventListener( + const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XEventListener > & xListener) + throw (::com::sun::star::uno::RuntimeException); + + // XPropertySet + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySetInfo > SAL_CALL + getPropertySetInfo() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertyValue( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Any& rValue) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::beans::PropertyVetoException, + ::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( + const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addPropertyChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertyChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removePropertyChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertyChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addVetoableChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XVetoableChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeVetoableChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XVetoableChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + + // XNamed + virtual ::rtl::OUString SAL_CALL getName() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setName(const ::rtl::OUString& rName) + throw (::com::sun::star::uno::RuntimeException); + + // XTextContent + virtual void SAL_CALL attach( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xTextRange) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > SAL_CALL getAnchor() + throw (::com::sun::star::uno::RuntimeException); + +}; + +#endif // SW_UNOREFMARK_HXX + diff --git a/sw/source/core/unocore/unoclbck.cxx b/sw/source/core/unocore/unoclbck.cxx index ef14a270630d..01890a1f40a4 100644 --- a/sw/source/core/unocore/unoclbck.cxx +++ b/sw/source/core/unocore/unoclbck.cxx @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx index 0a95eee00bcd..d7315e42383d 100644 --- a/sw/source/core/unocore/unocoll.cxx +++ b/sw/source/core/unocore/unocoll.cxx @@ -31,7 +31,6 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - #include #include #include @@ -76,7 +75,8 @@ #include #include -#include "unometa.hxx" +#include +#include #include "docsh.hxx" diff --git a/sw/source/core/unocore/unocrsrhelper.cxx b/sw/source/core/unocore/unocrsrhelper.cxx index 194200bfad0c..de893c8fe76a 100644 --- a/sw/source/core/unocore/unocrsrhelper.cxx +++ b/sw/source/core/unocore/unocrsrhelper.cxx @@ -32,10 +32,10 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unoportenum.cxx b/sw/source/core/unocore/unoportenum.cxx index a8426cf8b438..be51783b955f 100644 --- a/sw/source/core/unocore/unoportenum.cxx +++ b/sw/source/core/unocore/unoportenum.cxx @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unorefmk.cxx b/sw/source/core/unocore/unorefmk.cxx index 6fc3873db49c..25f87488d4d5 100644 --- a/sw/source/core/unocore/unorefmk.cxx +++ b/sw/source/core/unocore/unorefmk.cxx @@ -31,10 +31,10 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index 7bcb064c8ced..c16498a51979 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include -- cgit From a36e10b3749788ccfb5c79827f53af04301866e1 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Tue, 5 Jan 2010 16:37:43 +0100 Subject: swunolocking1: #i105557#: unoobj.hxx: split out unobookmark.hxx: move SwXBookmark, SwXFieldmark from unoobj.hxx to new unobookmark.hxx. --- sw/inc/unobookmark.hxx | 248 +++++++++++++++++++++++++++++++++ sw/inc/unoobj.hxx | 113 +-------------- sw/source/core/crsr/bookmrk.cxx | 2 +- sw/source/core/unocore/unobkm.cxx | 18 ++- sw/source/core/unocore/unocoll.cxx | 1 + sw/source/core/unocore/unoportenum.cxx | 1 + sw/source/core/unocore/unotext.cxx | 1 + sw/source/ui/uno/unotxvw.cxx | 1 + 8 files changed, 270 insertions(+), 115 deletions(-) create mode 100644 sw/inc/unobookmark.hxx (limited to 'sw') diff --git a/sw/inc/unobookmark.hxx b/sw/inc/unobookmark.hxx new file mode 100644 index 000000000000..2b16d7828001 --- /dev/null +++ b/sw/inc/unobookmark.hxx @@ -0,0 +1,248 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: unoobj.hxx,v $ + * + * $Revision: 1.49 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SW_UNOBOOKMARK_HXX +#define SW_UNOBOOKMARK_HXX + +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include +#include +#include + + +class SwDoc; + + +typedef ::cppu::ImplInheritanceHelper5 +< ::sfx2::MetadatableMixin +, ::com::sun::star::lang::XUnoTunnel +, ::com::sun::star::lang::XServiceInfo +, ::com::sun::star::beans::XPropertySet +, ::com::sun::star::container::XNamed +, ::com::sun::star::text::XTextContent +> SwXBookmark_Base; + +class SwXBookmark + : public SwXBookmark_Base + , private SwClient +{ + +private: + + SwEventListenerContainer m_aLstnrCntnr; + SwDoc* m_pDoc; + String m_aName; + ::sw::mark::IMark* m_pRegisteredBookmark; + + void registerInMark(::sw::mark::IMark* const pBkmk); + +protected: + + virtual ~SwXBookmark(); + +public: + + SwXBookmark(::sw::mark::IMark* pMark = 0, SwDoc* pDoc = 0); + + const ::sw::mark::IMark* GetBookmark() const + { return m_pRegisteredBookmark; } + ::sw::mark::IMark* GetBookmark() + { return m_pRegisteredBookmark; } + SwDoc* GetDoc() + { return m_pDoc; } + + void attachToRangeEx( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xTextRange, + IDocumentMarkAccess::MarkType eType) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException ); + virtual void attachToRange( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xTextRange) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + + TYPEINFO(); + + // SwClient + virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew ); + + // MetadatableMixin + virtual ::sfx2::Metadatable* GetCoreObject(); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel > GetModel(); + + static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId(); + + // XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( + const ::com::sun::star::uno::Sequence< sal_Int8 >& rIdentifier) + throw (::com::sun::star::uno::RuntimeException); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( + const ::rtl::OUString& rServiceName) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL + getSupportedServiceNames() + throw (::com::sun::star::uno::RuntimeException); + + // XComponent + virtual void SAL_CALL dispose() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addEventListener( + const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XEventListener > & xListener) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeEventListener( + const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XEventListener > & xListener) + throw (::com::sun::star::uno::RuntimeException); + + // XPropertySet + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySetInfo > SAL_CALL + getPropertySetInfo() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertyValue( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Any& rValue) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::beans::PropertyVetoException, + ::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( + const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addPropertyChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertyChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removePropertyChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertyChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addVetoableChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XVetoableChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeVetoableChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XVetoableChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + + // XNamed + virtual ::rtl::OUString SAL_CALL getName() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setName(const ::rtl::OUString& rName) + throw (::com::sun::star::uno::RuntimeException); + + // XTextContent + virtual void SAL_CALL attach( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xTextRange) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > SAL_CALL getAnchor() + throw (::com::sun::star::uno::RuntimeException); + +}; + +typedef cppu::ImplInheritanceHelper1< SwXBookmark, + ::com::sun::star::text::XFormField > SwXFieldmark_Base; + +class SwXFieldmark + : public SwXFieldmark_Base +{ + +private: + + bool isReplacementObject; + +public: + + SwXFieldmark(bool isReplacementObject, + ::sw::mark::IMark* pBkm = 0, SwDoc* pDoc = 0); + + virtual void attachToRange( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xTextRange) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + + virtual ::rtl::OUString SAL_CALL getDescription() + throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int16 SAL_CALL getType() + throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int16 SAL_CALL getRes() + throw (::com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL setDescription(const ::rtl::OUString& rDescription) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setType(::sal_Int16 fieldType) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setRes(::sal_Int16 res) + throw (::com::sun::star::uno::RuntimeException); + +}; + +#endif // SW_UNOBOOKMARK_HXX + diff --git a/sw/inc/unoobj.hxx b/sw/inc/unoobj.hxx index 62cf34e1a580..74197ec9b2ba 100644 --- a/sw/inc/unoobj.hxx +++ b/sw/inc/unoobj.hxx @@ -86,12 +86,11 @@ #include "TextCursorHelper.hxx" #include #include -#include #include #include -#include +#include #include #include @@ -569,116 +568,6 @@ public: }; */ -typedef ::cppu::ImplInheritanceHelper5 -< - ::sfx2::MetadatableMixin, - ::com::sun::star::text::XTextContent, - ::com::sun::star::beans::XPropertySet, - ::com::sun::star::lang::XServiceInfo, - ::com::sun::star::container::XNamed, - ::com::sun::star::lang::XUnoTunnel -> -SwBookmarkBaseClass; - -class SwXBookmark - : public SwBookmarkBaseClass - , private SwClient -{ - private: - SwEventListenerContainer m_aLstnrCntnr; - SwDoc* m_pDoc; - String m_aName; - ::sw::mark::IMark* m_pRegisteredBookmark; - - void registerInMark(::sw::mark::IMark* const pBkmk) - { - if(pBkmk) - pBkmk->Add(this); - else if(m_pRegisteredBookmark) - { - m_aName = m_pRegisteredBookmark->GetName(); - m_pRegisteredBookmark->Remove(this); - } - m_pRegisteredBookmark = pBkmk; - } - - protected: - virtual ~SwXBookmark(); - public: - SwXBookmark(::sw::mark::IMark* pMark = 0, SwDoc* pDoc = 0); - - TYPEINFO(); - - static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId(); - - //XUnoTunnel - virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); - - //XTextContent - virtual void SAL_CALL attach(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xTextRange) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getAnchor( ) throw(::com::sun::star::uno::RuntimeException); - - //XComponent - virtual void SAL_CALL dispose(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw( ::com::sun::star::uno::RuntimeException ); - - //XNamed - virtual rtl::OUString SAL_CALL getName(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL setName(const rtl::OUString& rName) throw( ::com::sun::star::uno::RuntimeException ); - - //XServiceInfo - virtual rtl::OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual BOOL SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException ); - - //XPropertySet - virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - - void attachToRangeEx(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xTextRange, IDocumentMarkAccess::MarkType eType) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); - virtual void attachToRange(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xTextRange) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); - - //SwClient - virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew ); - - // MetadatableMixin - virtual ::sfx2::Metadatable* GetCoreObject(); - virtual ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > GetModel(); - - const ::sw::mark::IMark* GetBookmark() const - { return m_pRegisteredBookmark; } - ::sw::mark::IMark* GetBookmark() - { return m_pRegisteredBookmark; } - SwDoc* GetDoc() - { return m_pDoc; } -}; - -typedef cppu::ImplInheritanceHelper1< SwXBookmark, ::com::sun::star::text::XFormField > SwXFieldmark_BASE; - -class SwXFieldmark : public SwXFieldmark_BASE -{ - private: - bool isReplacementObject; - public: - SwXFieldmark(bool isReplacementObject, ::sw::mark::IMark* pBkm = 0, SwDoc* pDoc = 0); - - virtual void attachToRange(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xTextRange) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); - virtual ::rtl::OUString SAL_CALL getDescription(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::sal_Int16 SAL_CALL getType( ) throw (::com::sun::star::uno::RuntimeException); - virtual ::sal_Int16 SAL_CALL getRes( ) throw (::com::sun::star::uno::RuntimeException); - - virtual void SAL_CALL setType( ::sal_Int16 fieldType ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setRes( ::sal_Int16 res ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setDescription( const ::rtl::OUString& description ) throw (::com::sun::star::uno::RuntimeException); -}; - /*-----------------23.02.98 10:45------------------- --------------------------------------------------*/ diff --git a/sw/source/core/crsr/bookmrk.cxx b/sw/source/core/crsr/bookmrk.cxx index 3cdfa7ec03e4..1028c7b2b432 100644 --- a/sw/source/core/crsr/bookmrk.cxx +++ b/sw/source/core/crsr/bookmrk.cxx @@ -42,7 +42,7 @@ #include #include #include -#include +#include #include diff --git a/sw/source/core/unocore/unobkm.cxx b/sw/source/core/unocore/unobkm.cxx index 0a9528823689..da9568603b01 100644 --- a/sw/source/core/unocore/unobkm.cxx +++ b/sw/source/core/unocore/unobkm.cxx @@ -31,7 +31,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - +#include #include #include #include @@ -74,6 +74,20 @@ namespace ******************************************************************/ TYPEINIT1(SwXBookmark, SwClient) +void SwXBookmark::registerInMark(::sw::mark::IMark* const pBkmk) +{ + if (pBkmk) + { + pBkmk->Add(this); + } + else if (m_pRegisteredBookmark) + { + m_aName = m_pRegisteredBookmark->GetName(); + m_pRegisteredBookmark->Remove(this); + } + m_pRegisteredBookmark = pBkmk; +} + const uno::Sequence< sal_Int8 > & SwXBookmark::getUnoTunnelId() { static uno::Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId(); @@ -353,7 +367,7 @@ void SwXBookmark::removeVetoableChangeListener(const OUString& /*PropertyName*/, { } SwXFieldmark::SwXFieldmark(bool _isReplacementObject, ::sw::mark::IMark* pBkm, SwDoc* pDc) - : SwXFieldmark_BASE(pBkm, pDc) + : SwXFieldmark_Base(pBkm, pDc) , isReplacementObject(_isReplacementObject) { } diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx index d7315e42383d..cc9c3d34050a 100644 --- a/sw/source/core/unocore/unocoll.cxx +++ b/sw/source/core/unocore/unocoll.cxx @@ -75,6 +75,7 @@ #include #include +#include #include #include #include "docsh.hxx" diff --git a/sw/source/core/unocore/unoportenum.cxx b/sw/source/core/unocore/unoportenum.cxx index be51783b955f..ad3e52cff75b 100644 --- a/sw/source/core/unocore/unoportenum.cxx +++ b/sw/source/core/unocore/unoportenum.cxx @@ -48,6 +48,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index c16498a51979..bbb371d66974 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/ui/uno/unotxvw.cxx b/sw/source/ui/uno/unotxvw.cxx index 6197bb489d61..6ed41d64c7a6 100644 --- a/sw/source/ui/uno/unotxvw.cxx +++ b/sw/source/ui/uno/unotxvw.cxx @@ -77,6 +77,7 @@ #include #include #include +#include #include #include -- cgit From af7ef16cd1dd50610a5d89798a3ef68aa43de922 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Tue, 5 Jan 2010 16:37:44 +0100 Subject: swunolocking1: #i105557#: unoobj.hxx: split out unoparagraph.hxx: move SwXParagraph{,Enumeration} from unoobj.hxx to new unoparagraph.hxx. move enum CursorType to unobaseclass.hxx. --- sw/inc/unobaseclass.hxx | 21 ++ sw/inc/unoobj.hxx | 201 --------------- sw/inc/unoparagraph.hxx | 439 ++++++++++++++++++++++++++++++++ sw/source/core/txtnode/ndtxt.cxx | 1 + sw/source/core/unocore/unobkm.cxx | 2 + sw/source/core/unocore/unocoll.cxx | 1 + sw/source/core/unocore/unodraw.cxx | 1 + sw/source/core/unocore/unoframe.cxx | 1 + sw/source/core/unocore/unoftn.cxx | 1 + sw/source/core/unocore/unoidx.cxx | 6 +- sw/source/core/unocore/unoobj2.cxx | 1 + sw/source/core/unocore/unoparagraph.cxx | 1 + sw/source/core/unocore/unoredline.cxx | 2 + sw/source/core/unocore/unorefmk.cxx | 1 + sw/source/core/unocore/unosect.cxx | 9 +- sw/source/core/unocore/unotbl.cxx | 7 +- sw/source/core/unocore/unotext.cxx | 3 + sw/source/ui/uno/unotxvw.cxx | 1 + 18 files changed, 484 insertions(+), 215 deletions(-) create mode 100644 sw/inc/unoparagraph.hxx (limited to 'sw') diff --git a/sw/inc/unobaseclass.hxx b/sw/inc/unobaseclass.hxx index 17b6e6f5d080..adb7b880356a 100644 --- a/sw/inc/unobaseclass.hxx +++ b/sw/inc/unobaseclass.hxx @@ -43,5 +43,26 @@ cppu::WeakImplHelper2 > SwSimpleEnumerationBaseClass; + +/* -----------------29.04.98 07:35------------------- + * + * --------------------------------------------------*/ +enum CursorType +{ + CURSOR_INVALID, + CURSOR_BODY, + CURSOR_FRAME, + CURSOR_TBLTEXT, + CURSOR_FOOTNOTE, + CURSOR_HEADER, + CURSOR_FOOTER, + CURSOR_REDLINE, + CURSOR_ALL, // for Search&Replace + CURSOR_SELECTION, // create a paragraph enumeration from + // a text range or cursor + CURSOR_SELECTION_IN_TABLE, + CURSOR_META, // meta/meta-field +}; + #endif diff --git a/sw/inc/unoobj.hxx b/sw/inc/unoobj.hxx index 74197ec9b2ba..54e652fc6816 100644 --- a/sw/inc/unoobj.hxx +++ b/sw/inc/unoobj.hxx @@ -61,7 +61,6 @@ #include #include #include -#include #include #include #include @@ -91,7 +90,6 @@ #include #include -#include #include #include @@ -115,25 +113,6 @@ typedef ::std::deque< FrameDependSortListEntry > typedef ::std::deque< ::boost::shared_ptr > FrameDependList_t; -/* -----------------29.04.98 07:35------------------- - * - * --------------------------------------------------*/ -enum CursorType -{ - CURSOR_INVALID, - CURSOR_BODY, - CURSOR_FRAME, - CURSOR_TBLTEXT, - CURSOR_FOOTNOTE, - CURSOR_HEADER, - CURSOR_FOOTER, - CURSOR_REDLINE, - CURSOR_ALL, // fuer Search&Replace - CURSOR_SELECTION, // create a paragraph enumeration from a text range or cursor - CURSOR_SELECTION_IN_TABLE, - CURSOR_META, // meta/meta-field -}; - /* -----------------26.06.98 16:18------------------- * @@ -993,186 +972,6 @@ public: void Invalidate(); }; -/*-----------------07.04.98 08:10------------------- - ---------------------------------------------------*/ -class SwXParagraphEnumeration : public SwSimpleEnumerationBaseClass, - public SwClient -{ - ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > xParentText; - ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > xNextPara; - - const SwTable * pOwnTable; - const SwStartNode * pOwnStartNode; // start node of the cell the enumeration - // belongs to. - // Used to restrict the movement of the - // UNO cursor to the cell and its - // embedded tables. - sal_Int32 nFirstParaStart; - sal_Int32 nLastParaEnd; - ULONG nEndIndex; - CursorType eCursorType; - BOOL bFirstParagraph; - - SwUnoCrsr* GetCrsr(){return (SwUnoCrsr*)GetRegisteredIn();} - -protected: - virtual ~SwXParagraphEnumeration(); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > SAL_CALL NextElement_Impl(void) throw( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException ); - -public: - SwXParagraphEnumeration(SwXText* pParent, SwPosition& rPos, CursorType eType); - SwXParagraphEnumeration(SwXText* pParent, SwUnoCrsr* pCrsr, CursorType eType); - - - - //XEnumeration - virtual BOOL SAL_CALL hasMoreElements(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Any SAL_CALL nextElement(void) throw( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException ); - - //XServiceInfo - virtual rtl::OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual BOOL SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException ); - - //SwClient - virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew); - - //non-Uno functions - - void SetOwnTable( const SwTable* pTable ) { pOwnTable = pTable; } - const SwTable* GetOwnTable() const { return pOwnTable; } - void SetOwnStartNode( const SwStartNode* pNode ) { pOwnStartNode = pNode; } - const SwStartNode* GetOwnStartNode() const { return pOwnStartNode; } -}; -/*-----------------07.04.98 08:15------------------- - ---------------------------------------------------*/ -class SwXParagraph : public cppu::ImplInheritanceHelper10 -< - ::sfx2::MetadatableMixin, - ::com::sun::star::beans::XTolerantMultiPropertySet, - ::com::sun::star::beans::XMultiPropertySet, - ::com::sun::star::text::XTextRange, - ::com::sun::star::beans::XPropertySet, - ::com::sun::star::lang::XServiceInfo, - ::com::sun::star::lang::XUnoTunnel, - ::com::sun::star::beans::XPropertyState, - ::com::sun::star::container::XEnumerationAccess, - ::com::sun::star::text::XTextContent, - ::com::sun::star::container::XContentEnumerationAccess ->, - public SwClient -{ - ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > xParentText; - SwEventListenerContainer aLstnrCntnr; - const SfxItemPropertySet* m_pPropSet; - rtl::OUString m_sText; - sal_Int32 nSelectionStartPos; - sal_Int32 nSelectionEndPos; - BOOL m_bIsDescriptor; - - -protected: - void SAL_CALL SetPropertyValues_Impl( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aValues ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL GetPropertyValues_Impl( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - - ::com::sun::star::uno::Sequence< ::com::sun::star::beans::GetDirectPropertyTolerantResult > SAL_CALL GetPropertyValuesTolerant_Impl( - const ::com::sun::star::uno::Sequence< rtl::OUString >& rPropertyNames, - sal_Bool bDirectValuesOnly ) throw (::com::sun::star::uno::RuntimeException); - - virtual ~SwXParagraph(); -public: - SwXParagraph(); - SwXParagraph(::com::sun::star::uno::Reference< ::com::sun::star::text::XText > const & i_xParent, SwTxtNode * i_pTxtNode, sal_Int32 nSelStart = -1, sal_Int32 nSelEnd = - 1); - - TYPEINFO(); - - static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId(); - - //XUnoTunnel - virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); - - //XTolerantMultiPropertySet - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::SetPropertyTolerantFailed > SAL_CALL setPropertyValuesTolerant( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aValues ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::GetPropertyTolerantResult > SAL_CALL getPropertyValuesTolerant( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames ) throw (::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::GetDirectPropertyTolerantResult > SAL_CALL getDirectPropertyValuesTolerant( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames ) throw (::com::sun::star::uno::RuntimeException); - - //XMultiPropertySet -// virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aValues ) throw(::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL getPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addPropertiesChangeListener( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removePropertiesChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL firePropertiesChangeEvent( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener ) throw(::com::sun::star::uno::RuntimeException); - - //XPropertySet - virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - - //XPropertyState - virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyState > SAL_CALL getPropertyStates( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setPropertyToDefault( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault( const ::rtl::OUString& aPropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - - //XTextContent - virtual void SAL_CALL attach(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xTextRange) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getAnchor( ) throw(::com::sun::star::uno::RuntimeException); - - //XComponent - virtual void SAL_CALL dispose(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw( ::com::sun::star::uno::RuntimeException ); - - //XEnumerationAccess - war XTextPortionEnumerationAccess - virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createEnumeration(void) throw( ::com::sun::star::uno::RuntimeException ); - - //XElementAccess - virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw(::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL hasElements( ) throw(::com::sun::star::uno::RuntimeException); - - //XTextRange - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > SAL_CALL getText(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getStart(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getEnd(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual rtl::OUString SAL_CALL getString(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL setString(const rtl::OUString& aString) throw( ::com::sun::star::uno::RuntimeException ); - - //XServiceInfo - virtual rtl::OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual BOOL SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException ); - - //XContentEnumerationAccess - virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createContentEnumeration(const rtl::OUString& aServiceName) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getAvailableServiceNames(void) throw( ::com::sun::star::uno::RuntimeException ); - - //MetadatableMixin - virtual ::sfx2::Metadatable* GetCoreObject(); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > - GetModel(); - - //SwClient - virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew); - - BOOL IsDescriptor() const {return m_bIsDescriptor;} - - const SwTxtNode * GetTxtNode() const; - SwTxtNode * GetTxtNode(); - - static BOOL getDefaultTextContentValue(::com::sun::star::uno::Any& rAny, - const rtl::OUString& rPropertyName, USHORT nWID = 0); - static SwXParagraph* GetImplementation(::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> xRef ); - //falls es mal als Service erzeugt werden kann - //void attachToRange(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xTextRange)throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); - void attachToText(SwXText & rParent, SwTxtNode & rTxtNode); -}; /* -----------------23.03.99 12:57------------------- * * --------------------------------------------------*/ diff --git a/sw/inc/unoparagraph.hxx b/sw/inc/unoparagraph.hxx new file mode 100644 index 000000000000..6ef62e00c1a9 --- /dev/null +++ b/sw/inc/unoparagraph.hxx @@ -0,0 +1,439 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: unoobj.hxx,v $ + * + * $Revision: 1.49 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SW_UNOPARAGRAPH_HXX +#define SW_UNOPARAGRAPH_HXX + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include + + +class SfxItemPropertySet; +struct SwPosition; +class SwUnoCrsr; +class SwStartNode; +class SwTxtNode; +class SwTable; +class SwXText; + + +/*-----------------07.04.98 08:15------------------- + +--------------------------------------------------*/ +typedef ::cppu::ImplInheritanceHelper10 +< ::sfx2::MetadatableMixin +, ::com::sun::star::lang::XUnoTunnel +, ::com::sun::star::lang::XServiceInfo +, ::com::sun::star::beans::XPropertySet +, ::com::sun::star::beans::XPropertyState +, ::com::sun::star::beans::XMultiPropertySet +, ::com::sun::star::beans::XTolerantMultiPropertySet +, ::com::sun::star::container::XEnumerationAccess +, ::com::sun::star::container::XContentEnumerationAccess +, ::com::sun::star::text::XTextContent +, ::com::sun::star::text::XTextRange +> SwXParagraph_Base; + +class SwXParagraph + : public SwXParagraph_Base + , public SwClient +{ + +private: + + ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > xParentText; + SwEventListenerContainer aLstnrCntnr; + const SfxItemPropertySet* m_pPropSet; + ::rtl::OUString m_sText; + sal_Int32 nSelectionStartPos; + sal_Int32 nSelectionEndPos; + BOOL m_bIsDescriptor; + +protected: + + void SAL_CALL SetPropertyValues_Impl( + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& + rPropertyNames, + const ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Any >& rValues) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::beans::PropertyVetoException, + ::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL + GetPropertyValues_Impl( + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& + rPropertyNames) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + + ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::GetDirectPropertyTolerantResult > SAL_CALL + GetPropertyValuesTolerant_Impl( + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& + rPropertyNames, + sal_Bool bDirectValuesOnly) + throw (::com::sun::star::uno::RuntimeException); + + virtual ~SwXParagraph(); + +public: + + SwXParagraph(); + SwXParagraph(::com::sun::star::uno::Reference< + ::com::sun::star::text::XText > const & i_xParent, + SwTxtNode * i_pTxtNode, + sal_Int32 nSelStart = -1, sal_Int32 nSelEnd = - 1); + + BOOL IsDescriptor() const {return m_bIsDescriptor;} + + const SwTxtNode * GetTxtNode() const; + SwTxtNode * GetTxtNode(); + + static BOOL getDefaultTextContentValue(::com::sun::star::uno::Any& rAny, + const ::rtl::OUString& rPropertyName, USHORT nWID = 0); + static SwXParagraph* GetImplementation( + ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XInterface> xRef); + void attachToText(SwXText & rParent, SwTxtNode & rTxtNode); + + TYPEINFO(); + + // SwClient + virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + + // MetadatableMixin + virtual ::sfx2::Metadatable* GetCoreObject(); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > + GetModel(); + + static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId(); + + // XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( + const ::com::sun::star::uno::Sequence< sal_Int8 >& rIdentifier) + throw (::com::sun::star::uno::RuntimeException); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( + const ::rtl::OUString& rServiceName) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL + getSupportedServiceNames() + throw (::com::sun::star::uno::RuntimeException); + + // XComponent + virtual void SAL_CALL dispose() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addEventListener( + const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XEventListener > & xListener) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeEventListener( + const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XEventListener > & xListener) + throw (::com::sun::star::uno::RuntimeException); + + // XPropertySet + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySetInfo > SAL_CALL + getPropertySetInfo() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertyValue( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Any& rValue) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::beans::PropertyVetoException, + ::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( + const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addPropertyChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertyChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removePropertyChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertyChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addVetoableChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XVetoableChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeVetoableChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XVetoableChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + + // XPropertyState + virtual ::com::sun::star::beans::PropertyState SAL_CALL + getPropertyState(const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyState > SAL_CALL + getPropertyStates( + const ::com::sun::star::uno::Sequence< + ::rtl::OUString >& rPropertyNames) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertyToDefault( + const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault( + const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + + // XMultiPropertySet + virtual void SAL_CALL setPropertyValues( + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& + rPropertyNames, + const ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Any >& rValues) + throw (::com::sun::star::beans::PropertyVetoException, + ::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > + SAL_CALL getPropertyValues( + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& + rPropertyNames) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addPropertiesChangeListener( + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& + rPropertyNames, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertiesChangeListener >& xListener) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removePropertiesChangeListener( + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertiesChangeListener >& xListener) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL firePropertiesChangeEvent( + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& + rPropertyNames, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertiesChangeListener >& xListener) + throw (::com::sun::star::uno::RuntimeException); + + // XTolerantMultiPropertySet + virtual ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::SetPropertyTolerantFailed > SAL_CALL + setPropertyValuesTolerant( + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& + rPropertyNames, + const ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Any >& rValues) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::GetPropertyTolerantResult > SAL_CALL + getPropertyValuesTolerant( + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& + rPropertyNames) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::GetDirectPropertyTolerantResult > SAL_CALL + getDirectPropertyValuesTolerant( + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& + rPropertyNames) + throw (::com::sun::star::uno::RuntimeException); + + // XElementAccess + virtual ::com::sun::star::uno::Type SAL_CALL getElementType() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL hasElements() + throw (::com::sun::star::uno::RuntimeException); + + // XEnumerationAccess + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::container::XEnumeration > SAL_CALL + createEnumeration() + throw (::com::sun::star::uno::RuntimeException); + + // XContentEnumerationAccess + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::container::XEnumeration > SAL_CALL + createContentEnumeration(const ::rtl::OUString& rServiceName) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL + getAvailableServiceNames() + throw (::com::sun::star::uno::RuntimeException); + + // XTextContent + virtual void SAL_CALL attach( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xTextRange) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > SAL_CALL getAnchor() + throw (::com::sun::star::uno::RuntimeException); + + // XTextRange + virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > + SAL_CALL getText() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > SAL_CALL getStart() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > SAL_CALL getEnd() + throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getString() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setString(const ::rtl::OUString& rString) + throw (::com::sun::star::uno::RuntimeException); + +}; + + +/*-----------------07.04.98 08:10------------------- + +--------------------------------------------------*/ +class SwXParagraphEnumeration + : public SwSimpleEnumerationBaseClass + , public SwClient +{ + +private: + + ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > + xParentText; + ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > + xNextPara; + + const SwTable * pOwnTable; + /// Start node of the cell the enumeration belongs to. + /// Used to restrict the movement of the UNO cursor to the cell and its + /// embedded tables. + const SwStartNode * pOwnStartNode; + sal_Int32 nFirstParaStart; + sal_Int32 nLastParaEnd; + ULONG nEndIndex; + CursorType eCursorType; + BOOL bFirstParagraph; + + SwUnoCrsr* GetCrsr() {return (SwUnoCrsr*)GetRegisteredIn();} + +protected: + + virtual ~SwXParagraphEnumeration(); + + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextContent > SAL_CALL + NextElement_Impl() + throw (::com::sun::star::container::NoSuchElementException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + +public: + + SwXParagraphEnumeration( + SwXText* pParent, SwPosition& rPos, CursorType eType); + SwXParagraphEnumeration( + SwXText* pParent, SwUnoCrsr* pCrsr, CursorType eType); + + // non-Uno functions + + void SetOwnTable(const SwTable* pTable) + { pOwnTable = pTable; } + const SwTable* GetOwnTable() const + { return pOwnTable; } + void SetOwnStartNode(const SwStartNode* pNode) + { pOwnStartNode = pNode; } + const SwStartNode* GetOwnStartNode() const + { return pOwnStartNode; } + + // SwClient + virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( + const ::rtl::OUString& rServiceName) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL + getSupportedServiceNames() + throw (::com::sun::star::uno::RuntimeException); + + // XEnumeration + virtual sal_Bool SAL_CALL hasMoreElements() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL nextElement() + throw (::com::sun::star::container::NoSuchElementException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + +}; + +#endif // SW_UNOPARAGRAPH_HXX + diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index eb1f5c3e94fc..46b105723a1d 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -4972,6 +4972,7 @@ bool SwTxtNode::IsInContent() const return !GetDoc()->IsInHeaderFooter( SwNodeIndex(*this) ); } +#include #include ::com::sun::star::uno::Reference< ::com::sun::star::rdf::XMetadatable > diff --git a/sw/source/core/unocore/unobkm.cxx b/sw/source/core/unocore/unobkm.cxx index da9568603b01..0ec0442457f5 100644 --- a/sw/source/core/unocore/unobkm.cxx +++ b/sw/source/core/unocore/unobkm.cxx @@ -31,10 +31,12 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" + #include #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx index cc9c3d34050a..598e95cbf385 100644 --- a/sw/source/core/unocore/unocoll.cxx +++ b/sw/source/core/unocore/unocoll.cxx @@ -75,6 +75,7 @@ #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx index 5a050eb690ed..ec978f02a0ec 100644 --- a/sw/source/core/unocore/unodraw.cxx +++ b/sw/source/core/unocore/unodraw.cxx @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx index 1f9d39bca94c..87bc0ff6b173 100644 --- a/sw/source/core/unocore/unoframe.cxx +++ b/sw/source/core/unocore/unoframe.cxx @@ -61,6 +61,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unoftn.cxx b/sw/source/core/unocore/unoftn.cxx index 98ee87c2ae33..cf1b6dc516c4 100644 --- a/sw/source/core/unocore/unoftn.cxx +++ b/sw/source/core/unocore/unoftn.cxx @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unoidx.cxx b/sw/source/core/unocore/unoidx.cxx index 5633ca1f0661..3e1fde6746b3 100644 --- a/sw/source/core/unocore/unoidx.cxx +++ b/sw/source/core/unocore/unoidx.cxx @@ -43,9 +43,7 @@ #include #include #include -#ifndef _CMDID_H #include -#endif #include #include #include @@ -58,18 +56,18 @@ #include #include #include +#include #include #include #include #include #include #include -#ifndef _DOCSH_HXX //autogen #include -#endif #include #include + using namespace ::com::sun::star; using ::rtl::OUString; diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index 26a237b5625a..b8435fe17166 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -78,6 +78,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unoparagraph.cxx b/sw/source/core/unocore/unoparagraph.cxx index 4fbf9a7062d1..bb7c30667ab1 100644 --- a/sw/source/core/unocore/unoparagraph.cxx +++ b/sw/source/core/unocore/unoparagraph.cxx @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unoredline.cxx b/sw/source/core/unocore/unoredline.cxx index b04a7fea1fae..80297bb64321 100644 --- a/sw/source/core/unocore/unoredline.cxx +++ b/sw/source/core/unocore/unoredline.cxx @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -50,6 +51,7 @@ #include #include + using namespace ::com::sun::star; using ::rtl::OUString; using ::rtl::OUStringBuffer; diff --git a/sw/source/core/unocore/unorefmk.cxx b/sw/source/core/unocore/unorefmk.cxx index 25f87488d4d5..45c79b5edcf5 100644 --- a/sw/source/core/unocore/unorefmk.cxx +++ b/sw/source/core/unocore/unorefmk.cxx @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unosect.cxx b/sw/source/core/unocore/unosect.cxx index 1308c6ad7d3e..e3c0c56908a9 100644 --- a/sw/source/core/unocore/unosect.cxx +++ b/sw/source/core/unocore/unosect.cxx @@ -38,24 +38,21 @@ #include #include #include -#ifndef _SVX_XMLCNITEM_HXX #include -#endif #include #include #include #include #include #include +#include #include #include #include #include #include #include -#ifndef _DOCSH_HXX #include -#endif #include #include #include @@ -65,13 +62,12 @@ #include #include #include -#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPPP_ #include -#endif #include /* #109700# */ #include + using namespace ::com::sun::star; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::uno; @@ -80,6 +76,7 @@ using namespace ::com::sun::star::container; using namespace ::com::sun::star::beans; using ::rtl::OUString; + TYPEINIT1(SwXTextSectionClient, SwClient); /*-- 20.12.2005 09:56:33--------------------------------------------------- diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index 20dde56ead7d..b0514f74d4ab 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -33,16 +33,12 @@ #include "precompiled_sw.hxx" - - // STL includes #include #include // for DBL_MIN #include -#ifndef _CMDID_H #include -#endif #include #include #include @@ -87,6 +83,7 @@ #include #include #include +#include #include // SvNumberFormatter #include #include @@ -103,9 +100,11 @@ #include #include + using namespace ::com::sun::star; using ::rtl::OUString; + //----------------------------------------------------------------------------- // from unoobj.cxx extern void lcl_SetTxtFmtColl(const uno::Any& rAny, SwPaM& rPaM) throw (lang::IllegalArgumentException); diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index bbb371d66974..fed9109b094e 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -53,6 +53,7 @@ #include #include #include +#include #include #include #include @@ -70,9 +71,11 @@ #include + using namespace ::com::sun::star; using ::rtl::OUString; + const sal_Char cInvalidObject[] = "this object is invalid"; /****************************************************************** * SwXText diff --git a/sw/source/ui/uno/unotxvw.cxx b/sw/source/ui/uno/unotxvw.cxx index 6ed41d64c7a6..6239bc9503ea 100644 --- a/sw/source/ui/uno/unotxvw.cxx +++ b/sw/source/ui/uno/unotxvw.cxx @@ -78,6 +78,7 @@ #include #include #include +#include #include #include -- cgit From a04b8cd2adec9a16a9989670160634d588a15a87 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Tue, 5 Jan 2010 16:37:44 +0100 Subject: swunolocking1: #i105557#: unoobj.hxx: split out unosection.hxx: move SwXTextSection from unoobj.hxx to new unosection.hxx. --- sw/inc/unoframe.hxx | 1 + sw/inc/unoobj.hxx | 126 ------------ sw/inc/unosection.hxx | 337 +++++++++++++++++++++++++++++++ sw/inc/unotbl.hxx | 1 + sw/source/core/unocore/unocoll.cxx | 1 + sw/source/core/unocore/unocrsrhelper.cxx | 2 + sw/source/core/unocore/unoidx.cxx | 1 + sw/source/core/unocore/unosect.cxx | 2 +- sw/source/core/unocore/unotbl.cxx | 1 + sw/source/core/unocore/unotext.cxx | 1 + sw/source/filter/xml/xmltble.cxx | 5 +- 11 files changed, 348 insertions(+), 130 deletions(-) create mode 100644 sw/inc/unosection.hxx (limited to 'sw') diff --git a/sw/inc/unoframe.hxx b/sw/inc/unoframe.hxx index a02999c8ca3d..4f62430f1cc2 100644 --- a/sw/inc/unoframe.hxx +++ b/sw/inc/unoframe.hxx @@ -32,6 +32,7 @@ #include #include +#include #include #include #include diff --git a/sw/inc/unoobj.hxx b/sw/inc/unoobj.hxx index 54e652fc6816..c4e6a3035ccd 100644 --- a/sw/inc/unoobj.hxx +++ b/sw/inc/unoobj.hxx @@ -49,7 +49,6 @@ #include #include #include -#include #include #include #include @@ -58,9 +57,7 @@ #include #include #include -#include #include -#include #include #include #include @@ -77,7 +74,6 @@ #include // helper for implementations #include // helper for implementations #include // helper for implementations -#include // helper for implementations #include #include #include @@ -754,128 +750,6 @@ public: const SwUnoCrsr* GetCursor() const { return (const SwUnoCrsr*)GetRegisteredIn(); } }; -/*-----------------09.03.98 13:57------------------- - ---------------------------------------------------*/ - -class SwXTextSection; -class SwXTextSectionClient : public SwClient -{ - friend class SwXTextSection; - SwXTextSection* m_pSection; - ::com::sun::star::uno::WeakReference< ::com::sun::star::text::XTextSection > m_xReference; - //SwClient - virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew); - SwXTextSectionClient( - SwSectionFmt& rFmt, - SwXTextSection& rTextSection, - ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextSection > xSection ); - virtual ~SwXTextSectionClient(); - DECL_STATIC_LINK( SwXTextSectionClient, RemoveSectionClient_Impl, - SwXTextSectionClient* ); - -public: - TYPEINFO(); - ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextSection > GetXTextSection(); - - static ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextSection > - CreateXTextSection(SwSectionFmt* pFmt = 0, BOOL bIndexHeader = FALSE ); - static SwXTextSectionClient* Create( - SwXTextSection& rSection, - ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextSection > xSection, - SwSectionFmt& rFmt ); -}; - -struct SwTextSectionProperties_Impl; -class SwXTextSection : public cppu::WeakImplHelper7 -< - ::com::sun::star::text::XTextSection, - ::com::sun::star::beans::XPropertyState, - ::com::sun::star::beans::XPropertySet, - ::com::sun::star::beans::XMultiPropertySet, - ::com::sun::star::lang::XServiceInfo, - ::com::sun::star::container::XNamed, - ::com::sun::star::lang::XUnoTunnel ->/*, - public SwClient*/ -{ - friend class SwXTextSectionClient; - SwEventListenerContainer aLstnrCntnr; - const SfxItemPropertySet* m_pPropSet; - - BOOL m_bIsDescriptor; - BOOL m_bIndexHeader; - String m_sName; - SwTextSectionProperties_Impl* pProps; - SwXTextSectionClient* m_pClient; -protected: - void SAL_CALL SetPropertyValues_Impl( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aValues ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL GetPropertyValues_Impl( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - - SwXTextSection(sal_Bool bWithFormat, sal_Bool bIndexHeader = FALSE); - virtual ~SwXTextSection(); - void ResetClient() {m_pClient = 0;} - void SetClient( SwXTextSectionClient* pClient ){m_pClient = pClient;} - -public: - static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId(); - - //XUnoTunnel - virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); - - //XTextSection - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextSection > SAL_CALL getParentSection(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextSection > > SAL_CALL getChildSections(void) throw( ::com::sun::star::uno::RuntimeException ); - - //XTextContent - virtual void SAL_CALL attach(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xTextRange) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getAnchor( ) throw(::com::sun::star::uno::RuntimeException); - - //XComponent - virtual void SAL_CALL dispose(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw( ::com::sun::star::uno::RuntimeException ); - - //XMultiPropertySet -// virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aValues ) throw(::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL getPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addPropertiesChangeListener( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removePropertiesChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL firePropertiesChangeEvent( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener ) throw(::com::sun::star::uno::RuntimeException); - - //XPropertySet - virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - - //XPropertyState - virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyState > SAL_CALL getPropertyStates( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setPropertyToDefault( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault( const ::rtl::OUString& aPropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - - //XNamed - virtual rtl::OUString SAL_CALL getName(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL setName(const rtl::OUString& Name_) throw( ::com::sun::star::uno::RuntimeException ); - - //XServiceInfo - virtual rtl::OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual BOOL SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException ); - - //SwClient -// virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew); - - void attachToRange(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xTextRange)throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); - - SwSectionFmt* GetFmt()const; - static SwXTextSection* GetImplementation(::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> xRef ); -}; /*-----------------12.02.98 08:01------------------- --------------------------------------------------*/ diff --git a/sw/inc/unosection.hxx b/sw/inc/unosection.hxx new file mode 100644 index 000000000000..31d15d7010d4 --- /dev/null +++ b/sw/inc/unosection.hxx @@ -0,0 +1,337 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: unoobj.hxx,v $ + * + * $Revision: 1.49 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SW_UNOSECTION_HXX +#define SW_UNOSECTION_HXX + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include +#include + + +class SfxItemPropertySet; +class SwSectionFmt; + + +/*-----------------09.03.98 13:57------------------- + +--------------------------------------------------*/ + +class SwXTextSection; + +class SwXTextSectionClient + : public SwClient +{ + +private: + + friend class SwXTextSection; + + SwXTextSection * m_pSection; + ::com::sun::star::uno::WeakReference< + ::com::sun::star::text::XTextSection > m_xReference; + + // SwClient + virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + + SwXTextSectionClient( + SwSectionFmt& rFmt, + SwXTextSection& rTextSection, + ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextSection > xSection); + + virtual ~SwXTextSectionClient(); + + DECL_STATIC_LINK( SwXTextSectionClient, RemoveSectionClient_Impl, + SwXTextSectionClient* ); + +public: + + TYPEINFO(); + + ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextSection > + GetXTextSection(); + + static ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextSection > + CreateXTextSection(SwSectionFmt* pFmt = 0, BOOL bIndexHeader = FALSE); + static SwXTextSectionClient* Create( + SwXTextSection& rSection, + ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextSection > xSection, + SwSectionFmt& rFmt); +}; + + +struct SwTextSectionProperties_Impl; + +typedef ::cppu::WeakImplHelper7 +< ::com::sun::star::lang::XUnoTunnel +, ::com::sun::star::lang::XServiceInfo +, ::com::sun::star::beans::XPropertySet +, ::com::sun::star::beans::XPropertyState +, ::com::sun::star::beans::XMultiPropertySet +, ::com::sun::star::container::XNamed +, ::com::sun::star::text::XTextSection +> SwXTextSection_Base; + +class SwXTextSection + : public SwXTextSection_Base +{ + +private: + + friend class SwXTextSectionClient; + + SwEventListenerContainer aLstnrCntnr; + const SfxItemPropertySet* m_pPropSet; + + BOOL m_bIsDescriptor; + BOOL m_bIndexHeader; + String m_sName; + SwTextSectionProperties_Impl* pProps; + SwXTextSectionClient* m_pClient; + +protected: + + void SAL_CALL SetPropertyValues_Impl( + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& + rPropertyNames, + const ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Any >& aValues) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::beans::PropertyVetoException, + ::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL + GetPropertyValues_Impl( + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& + rPropertyNames) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + + SwXTextSection(sal_Bool bWithFormat, sal_Bool bIndexHeader = FALSE); + + virtual ~SwXTextSection(); + + void ResetClient() { m_pClient = 0; } + void SetClient(SwXTextSectionClient* pClient) { m_pClient = pClient; } + +public: + + void attachToRange( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xTextRange) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + + SwSectionFmt* GetFmt() const; + + static SwXTextSection* GetImplementation( + ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XInterface> xRef); + + static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId(); + + // XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( + const ::com::sun::star::uno::Sequence< sal_Int8 >& rIdentifier) + throw (::com::sun::star::uno::RuntimeException); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( + const ::rtl::OUString& rServiceName) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL + getSupportedServiceNames() + throw (::com::sun::star::uno::RuntimeException); + + // XComponent + virtual void SAL_CALL dispose() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addEventListener( + const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XEventListener > & xListener) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeEventListener( + const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XEventListener > & xListener) + throw (::com::sun::star::uno::RuntimeException); + + // XPropertySet + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySetInfo > SAL_CALL + getPropertySetInfo() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertyValue( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Any& rValue) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::beans::PropertyVetoException, + ::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( + const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addPropertyChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertyChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removePropertyChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertyChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addVetoableChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XVetoableChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeVetoableChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XVetoableChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + + // XPropertyState + virtual ::com::sun::star::beans::PropertyState SAL_CALL + getPropertyState(const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyState > SAL_CALL + getPropertyStates( + const ::com::sun::star::uno::Sequence< + ::rtl::OUString >& rPropertyNames) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertyToDefault( + const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault( + const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + + // XMultiPropertySet + virtual void SAL_CALL setPropertyValues( + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& + rPropertyNames, + const ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Any >& rValues) + throw (::com::sun::star::beans::PropertyVetoException, + ::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > + SAL_CALL getPropertyValues( + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& + rPropertyNames) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addPropertiesChangeListener( + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& + rPropertyNames, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertiesChangeListener >& xListener) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removePropertiesChangeListener( + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertiesChangeListener >& xListener) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL firePropertiesChangeEvent( + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& + rPropertyNames, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertiesChangeListener >& xListener) + throw (::com::sun::star::uno::RuntimeException); + + // XNamed + virtual ::rtl::OUString SAL_CALL getName() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setName(const ::rtl::OUString& rName) + throw (::com::sun::star::uno::RuntimeException); + + // XTextContent + virtual void SAL_CALL attach( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xTextRange) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > SAL_CALL getAnchor() + throw (::com::sun::star::uno::RuntimeException); + + // XTextSection + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextSection > SAL_CALL + getParentSection() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextSection > > SAL_CALL + getChildSections() + throw (::com::sun::star::uno::RuntimeException); + +}; + +#endif // SW_UNOSECTION_HXX + diff --git a/sw/inc/unotbl.hxx b/sw/inc/unotbl.hxx index a8ca07bb0f34..7e28a5a2d116 100644 --- a/sw/inc/unotbl.hxx +++ b/sw/inc/unotbl.hxx @@ -31,6 +31,7 @@ #define _UNOTBL_HXX #include +#include #include #include #include diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx index 598e95cbf385..9cec70fa8a2f 100644 --- a/sw/source/core/unocore/unocoll.cxx +++ b/sw/source/core/unocore/unocoll.cxx @@ -75,6 +75,7 @@ #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unocrsrhelper.cxx b/sw/source/core/unocore/unocrsrhelper.cxx index de893c8fe76a..a5fcf29f8b64 100644 --- a/sw/source/core/unocore/unocrsrhelper.cxx +++ b/sw/source/core/unocore/unocrsrhelper.cxx @@ -32,6 +32,8 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" +#include + #include #include #include diff --git a/sw/source/core/unocore/unoidx.cxx b/sw/source/core/unocore/unoidx.cxx index 3e1fde6746b3..a90bdc28bdab 100644 --- a/sw/source/core/unocore/unoidx.cxx +++ b/sw/source/core/unocore/unoidx.cxx @@ -31,6 +31,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" +#include #include #include diff --git a/sw/source/core/unocore/unosect.cxx b/sw/source/core/unocore/unosect.cxx index e3c0c56908a9..c7d53042ee62 100644 --- a/sw/source/core/unocore/unosect.cxx +++ b/sw/source/core/unocore/unosect.cxx @@ -31,7 +31,6 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - #include #include @@ -45,6 +44,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index b0514f74d4ab..ab9006d5fae4 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -69,6 +69,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index fed9109b094e..f7ae2ebcde95 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/filter/xml/xmltble.cxx b/sw/source/filter/xml/xmltble.cxx index 360f8349142e..b80a8f15eda8 100644 --- a/sw/source/filter/xml/xmltble.cxx +++ b/sw/source/filter/xml/xmltble.cxx @@ -31,10 +31,11 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" +#include +#include #include #include -#include #include #include #include @@ -44,9 +45,7 @@ #include #include #include -#ifndef _SVX_FRAMEDIRITEM_HXX #include -#endif #include #include "swtable.hxx" -- cgit From 3d404991d52a130cf2144bcf3aec2ea52859d31f Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Tue, 5 Jan 2010 16:37:45 +0100 Subject: swunolocking1: #i105557#: unoobj.hxx: split out unotextcursor.hxx: move SwXTextCursor from unoobj.hxx to new unotextcursor.hxx. move enum SwGetPropertyStatesCaller to unotextcursor.hxx. --- sw/inc/unoobj.hxx | 222 +----------- sw/inc/unotbl.hxx | 5 + sw/inc/unotextcursor.hxx | 461 ++++++++++++++++++++++++ sw/source/core/access/accpara.cxx | 3 +- sw/source/core/edit/editsh.cxx | 2 +- sw/source/core/unocore/unobkm.cxx | 1 + sw/source/core/unocore/unocrsrhelper.cxx | 1 + sw/source/core/unocore/unodraw.cxx | 1 + sw/source/core/unocore/unofield.cxx | 1 + sw/source/core/unocore/unoframe.cxx | 1 + sw/source/core/unocore/unoftn.cxx | 1 + sw/source/core/unocore/unoidx.cxx | 1 + sw/source/core/unocore/unoobj.cxx | 2 + sw/source/core/unocore/unoobj2.cxx | 2 + sw/source/core/unocore/unoparagraph.cxx | 1 + sw/source/core/unocore/unoport.cxx | 1 + sw/source/core/unocore/unoportenum.cxx | 1 + sw/source/core/unocore/unoredline.cxx | 1 + sw/source/core/unocore/unorefmk.cxx | 1 + sw/source/core/unocore/unosect.cxx | 1 + sw/source/core/unocore/unotbl.cxx | 2 + sw/source/core/unocore/unotext.cxx | 1 + sw/source/filter/xml/XMLRedlineImportHelper.cxx | 1 + sw/source/filter/xml/xmlimp.cxx | 5 +- sw/source/filter/xml/xmltexti.cxx | 1 + sw/source/ui/uno/unoatxt.cxx | 5 +- sw/source/ui/uno/unotxdoc.cxx | 1 + sw/source/ui/uno/unotxvw.cxx | 1 + sw/source/ui/utlui/unotools.cxx | 3 +- 29 files changed, 499 insertions(+), 231 deletions(-) create mode 100644 sw/inc/unotextcursor.hxx (limited to 'sw') diff --git a/sw/inc/unoobj.hxx b/sw/inc/unoobj.hxx index c4e6a3035ccd..98bee1bf0e93 100644 --- a/sw/inc/unoobj.hxx +++ b/sw/inc/unoobj.hxx @@ -42,24 +42,16 @@ #include #include #include -#include -#include -#include -#include -#include -#include #include #include #include #include #include -#include #include #include #include #include #include -#include #include #include #include @@ -77,13 +69,9 @@ #include #include #include -#include // helper for implementations -#include "TextCursorHelper.hxx" -#include #include #include -#include #include @@ -169,8 +157,8 @@ void ClientModify(SwClient* pClient, SfxPoolItem *pOld, SfxPoolItem *pNew); /* -----------------03.12.98 12:22------------------- * * --------------------------------------------------*/ +class OTextCursorHelper; class SwXTextRange; -class SwXTextCursor; class SwXText : public ::com::sun::star::lang::XTypeProvider, public ::com::sun::star::text::XTextRangeCompare, public ::com::sun::star::text::XRelativeTextContentInsert, @@ -285,214 +273,6 @@ public: CursorType GetTextType() {return eCrsrType;} }; -/* -----------------03.12.98 12:16------------------- - * - * --------------------------------------------------*/ -enum SwGetPropertyStatesCaller -{ - SW_PROPERTY_STATE_CALLER_DEFAULT, - SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION, - SW_PROPERTY_STATE_CALLER_SINGLE_VALUE_ONLY, - SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION_TOLERANT -}; -#define CRSR_ATTR_MODE_TABLE 1 //attributes should be applied to a table selection -#define CRSR_ATTR_MODE_DONTREPLACE 2 //attributes should be added, not replaced - -typedef cppu::WeakImplHelper12< - ::com::sun::star::text::XSentenceCursor, - ::com::sun::star::text::XWordCursor, - ::com::sun::star::text::XParagraphCursor, - ::com::sun::star::text::XRedline, - ::com::sun::star::beans::XPropertySet, - ::com::sun::star::beans::XPropertyState, - ::com::sun::star::document::XDocumentInsertable, - ::com::sun::star::lang::XServiceInfo, - ::com::sun::star::util::XSortable, - ::com::sun::star::container::XContentEnumerationAccess, - ::com::sun::star::container::XEnumerationAccess, - ::com::sun::star::beans::XMultiPropertyStates - > SwXTextCursor_Base; -class SwXTextCursor : public SwXTextCursor_Base, - public SwClient, - public OTextCursorHelper -{ - SwEventListenerContainer aLstnrCntnr; - const SfxItemPropertySet* m_pPropSet; - ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > xParentText; - SwSortOptions* pLastSortOptions; - - CursorType eType; - - // --> FME 2006-03-07 #126177# We need to track if the RemoveCursor_Impl - // user event has been posted. In this case we have to remove the user - // event in ~SwXTextCursor(). - ULONG mnUserEventId; - bool mbRemoveUserEvent; - // <-- - - DECL_STATIC_LINK( SwXTextCursor, RemoveCursor_Impl, - ::com::sun::star::uno::Reference< - ::com::sun::star::uno::XInterface>* ); - -protected: - virtual ~SwXTextCursor(); -public: - void DeleteAndInsert(const String& rText, const bool bForceExpandHints); - SwXTextCursor(::com::sun::star::uno::Reference< ::com::sun::star::text::XText > xParent, const SwPosition& rPos, - CursorType eSet, SwDoc* pDoc, const SwPosition* pMark = 0); - SwXTextCursor(::com::sun::star::uno::Reference< ::com::sun::star::text::XText > xParent, SwUnoCrsr* pSourceCrsr, CursorType eSet = CURSOR_ALL); - - static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId(); - - DECLARE_XINTERFACE() - - //XUnoTunnel - virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); - - //XTextCursor - neu - virtual void SAL_CALL collapseToStart( ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL collapseToEnd( ) throw(::com::sun::star::uno::RuntimeException); - virtual BOOL SAL_CALL isCollapsed( ) throw(::com::sun::star::uno::RuntimeException); - virtual BOOL SAL_CALL goLeft( sal_Int16 nCount, BOOL bExpand ) throw(::com::sun::star::uno::RuntimeException); - virtual BOOL SAL_CALL goRight( sal_Int16 nCount, BOOL bExpand ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL gotoStart( BOOL bExpand ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL gotoEnd( BOOL bExpand ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL gotoRange( const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange >& xRange, BOOL bExpand ) throw(::com::sun::star::uno::RuntimeException); - - //XWordCursor - neu - virtual BOOL SAL_CALL isStartOfWord( ) throw(::com::sun::star::uno::RuntimeException); - virtual BOOL SAL_CALL isEndOfWord( ) throw(::com::sun::star::uno::RuntimeException); - virtual BOOL SAL_CALL gotoNextWord( BOOL bExpand ) throw(::com::sun::star::uno::RuntimeException); - virtual BOOL SAL_CALL gotoPreviousWord( BOOL bExpand ) throw(::com::sun::star::uno::RuntimeException); - virtual BOOL SAL_CALL gotoEndOfWord( BOOL bExpand ) throw(::com::sun::star::uno::RuntimeException); - virtual BOOL SAL_CALL gotoStartOfWord( BOOL bExpand ) throw(::com::sun::star::uno::RuntimeException); - - //XSentenceCursor - neu - virtual BOOL SAL_CALL isStartOfSentence( ) throw(::com::sun::star::uno::RuntimeException); - virtual BOOL SAL_CALL isEndOfSentence( ) throw(::com::sun::star::uno::RuntimeException); - virtual BOOL SAL_CALL gotoNextSentence( BOOL Expand ) throw(::com::sun::star::uno::RuntimeException); - virtual BOOL SAL_CALL gotoPreviousSentence( BOOL Expand ) throw(::com::sun::star::uno::RuntimeException); - virtual BOOL SAL_CALL gotoStartOfSentence( BOOL Expand ) throw(::com::sun::star::uno::RuntimeException); - virtual BOOL SAL_CALL gotoEndOfSentence( BOOL Expand ) throw(::com::sun::star::uno::RuntimeException); - - //ParagraphCursor - neu - virtual BOOL SAL_CALL isStartOfParagraph(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual BOOL SAL_CALL isEndOfParagraph(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual BOOL SAL_CALL gotoStartOfParagraph(BOOL Expand) throw( ::com::sun::star::uno::RuntimeException ); - virtual BOOL SAL_CALL gotoEndOfParagraph(BOOL Expand) throw( ::com::sun::star::uno::RuntimeException ); - virtual BOOL SAL_CALL gotoNextParagraph(BOOL Expand) throw( ::com::sun::star::uno::RuntimeException ); - virtual BOOL SAL_CALL gotoPreviousParagraph(BOOL Expand) throw( ::com::sun::star::uno::RuntimeException ); - - //XRedline - virtual void SAL_CALL makeRedline( const ::rtl::OUString& RedlineType, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& RedlineProperties ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); - - //XTextRange - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > SAL_CALL getText(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getStart(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getEnd(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual rtl::OUString SAL_CALL getString(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL setString(const rtl::OUString& aString) throw( ::com::sun::star::uno::RuntimeException ); - - //XPropertySet - virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - - //XPropertyState - virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyState > SAL_CALL getPropertyStates( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setPropertyToDefault( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault( const ::rtl::OUString& aPropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - - static void SetPropertyValue( - SwPaM& rPaM, - const SfxItemPropertySet& rPropSet, - const rtl::OUString& rPropertyName, - const ::com::sun::star::uno::Any& aValue, - USHORT nAttrMode = 0) - throw(::com::sun::star::beans::UnknownPropertyException, - ::com::sun::star::beans::PropertyVetoException, - ::com::sun::star::lang::IllegalArgumentException, - ::com::sun::star::lang::WrappedTargetException, - ::com::sun::star::uno::RuntimeException); - static ::com::sun::star::uno::Any GetPropertyValue( SwPaM& rPaM, const SfxItemPropertySet& rPropSet, const ::rtl::OUString& rPropertyName) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - static ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyState > GetPropertyStates( SwPaM& rPaM, const SfxItemPropertySet& rPropSet, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& PropertyNames, SwGetPropertyStatesCaller eCaller = SW_PROPERTY_STATE_CALLER_DEFAULT) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); - static ::com::sun::star::beans::PropertyState GetPropertyState( SwPaM& rPaM, const SfxItemPropertySet& rPropSet, const ::rtl::OUString& rPropertyName) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); - static void SetPropertyToDefault( SwPaM& rPaM, const SfxItemPropertySet& rPropSet, const rtl::OUString& rPropertyName) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); - static ::com::sun::star::uno::Any GetPropertyDefault( SwPaM& rPaM, const SfxItemPropertySet& rPropSet, const ::rtl::OUString& rPropertyName) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - - //XDocumentInsertable - neu - virtual void SAL_CALL insertDocumentFromURL(const rtl::OUString& rURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aOptions) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException ); - - //XSortable - neu - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL createSortDescriptor(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL sort(const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& xDescriptor) throw( ::com::sun::star::uno::RuntimeException ); - - //XContentEnumerationAccess - virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createContentEnumeration(const rtl::OUString& aServiceName) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getAvailableServiceNames(void) throw( ::com::sun::star::uno::RuntimeException ); - - //XEnumerationAccess - virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createEnumeration(void) throw( ::com::sun::star::uno::RuntimeException ); - - //XElementAccess - virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw(::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL hasElements( ) throw(::com::sun::star::uno::RuntimeException); - - //XServiceInfo - virtual rtl::OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual BOOL SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException ); - - //XMultiPropertyStates - //virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyState > SAL_CALL getPropertyStates( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setAllPropertiesToDefault( ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setPropertiesToDefault( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL getPropertyDefaults( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - - - //SwClient - virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew); - - virtual const SwPaM* GetPaM() const; - virtual SwPaM* GetPaM(); - virtual const SwDoc* GetDoc() const; - virtual SwDoc* GetDoc(); - SwUnoCrsr* GetCrsr(){return (SwUnoCrsr*)GetRegisteredIn();} - const SwUnoCrsr* GetCrsr()const{return (SwUnoCrsr*)GetRegisteredIn();} - - static void SetCrsrAttr(SwPaM& rPam, const SfxItemSet& rSet, USHORT nAttrMode ); - // --> OD 2006-07-12 #i63870# - // split third parameter into new parameters - // and to get better control about resulting -// static void GetCrsrAttr(SwPaM& rPam, SfxItemSet& rSet, BOOL bCurrentAttrOnly = FALSE); - static void GetCrsrAttr( SwPaM& rPam, - SfxItemSet& rSet, - BOOL bOnlyTxtAttr = FALSE, - BOOL bGetFromChrFmt = TRUE ); - // <-- - static void getTextFromPam(SwPaM& aCrsr, rtl::OUString& rBuffer); - static SwFmtColl* GetCurTxtFmtColl(SwPaM& rPam, BOOL bConditional); - - static void SelectPam(SwPaM& rCrsr, sal_Bool bExpand); - static void SetString(SwCursor& rCrsr, const rtl::OUString& rString); - - static ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > - createSortDescriptor(sal_Bool bFromTable); - static sal_Bool convertSortProperties( - const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rDescriptor, - SwSortOptions& rSortOpt); - - // --> FME 2006-03-07 #126177# - void DoNotRemoveUserEvent() { mbRemoveUserEvent = false; } - // <-- - - bool IsAtEndOfMeta() const; -}; /*-----------------20.03.98 07:47------------------- --------------------------------------------------*/ diff --git a/sw/inc/unotbl.hxx b/sw/inc/unotbl.hxx index 7e28a5a2d116..fa82f1b63aa3 100644 --- a/sw/inc/unotbl.hxx +++ b/sw/inc/unotbl.hxx @@ -32,6 +32,7 @@ #include #include +#include #include #include #include @@ -44,6 +45,10 @@ #include // helper for implementations #include // helper for implementations +#include +#include + + class SwTableBoxFmt; class SwTableLine; class SwTableCursor; diff --git a/sw/inc/unotextcursor.hxx b/sw/inc/unotextcursor.hxx new file mode 100644 index 000000000000..ce91bd295267 --- /dev/null +++ b/sw/inc/unotextcursor.hxx @@ -0,0 +1,461 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: unoobj.hxx,v $ + * + * $Revision: 1.49 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SW_UNOTEXTCURSOR_HXX +#define SW_UNOTEXTCURSOR_HXX + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +#include +#include +#include +#include + + +class SfxItemSet; +class SfxItemPropertySet; +class SwDoc; +struct SwPosition; +class SwCursor; +class SwUnoCrsr; +class SwFmtColl; +struct SwSortOptions; + + +/* -----------------03.12.98 12:16------------------- + * + * --------------------------------------------------*/ +enum SwGetPropertyStatesCaller +{ + SW_PROPERTY_STATE_CALLER_DEFAULT, + SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION, + SW_PROPERTY_STATE_CALLER_SINGLE_VALUE_ONLY, + SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION_TOLERANT +}; + +/// attributes should be applied to a table selection +#define CRSR_ATTR_MODE_TABLE 1 +/// attributes should be added, not replaced +#define CRSR_ATTR_MODE_DONTREPLACE 2 + +typedef ::cppu::WeakImplHelper12 +< ::com::sun::star::lang::XServiceInfo +, ::com::sun::star::beans::XPropertySet +, ::com::sun::star::beans::XPropertyState +, ::com::sun::star::beans::XMultiPropertyStates +, ::com::sun::star::container::XEnumerationAccess +, ::com::sun::star::container::XContentEnumerationAccess +, ::com::sun::star::util::XSortable +, ::com::sun::star::document::XDocumentInsertable +, ::com::sun::star::text::XSentenceCursor +, ::com::sun::star::text::XWordCursor +, ::com::sun::star::text::XParagraphCursor +, ::com::sun::star::text::XRedline +> SwXTextCursor_Base; + +class SwXTextCursor + : public SwXTextCursor_Base + , public SwClient + , public OTextCursorHelper +{ + +private: + + SwEventListenerContainer aLstnrCntnr; + const SfxItemPropertySet* m_pPropSet; + ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > xParentText; + SwSortOptions* pLastSortOptions; + + CursorType eType; + + // --> FME 2006-03-07 #126177# We need to track if the RemoveCursor_Impl + // user event has been posted. In this case we have to remove the user + // event in ~SwXTextCursor(). + ULONG mnUserEventId; + bool mbRemoveUserEvent; + // <-- + + DECL_STATIC_LINK(SwXTextCursor, RemoveCursor_Impl, + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>*); + +protected: + + virtual ~SwXTextCursor(); + +public: + + SwXTextCursor( + ::com::sun::star::uno::Reference< + ::com::sun::star::text::XText > xParent, + const SwPosition& rPos, + CursorType eSet, SwDoc* pDoc, const SwPosition* pMark = 0); + SwXTextCursor( + ::com::sun::star::uno::Reference< + ::com::sun::star::text::XText > xParent, + SwUnoCrsr* pSourceCrsr, CursorType eSet = CURSOR_ALL); + + SwUnoCrsr* GetCrsr() {return (SwUnoCrsr*)GetRegisteredIn();} + const SwUnoCrsr* GetCrsr() const {return (SwUnoCrsr*)GetRegisteredIn();} + + // --> FME 2006-03-07 #126177# + void DoNotRemoveUserEvent() { mbRemoveUserEvent = false; } + // <-- + + bool IsAtEndOfMeta() const; + + void DeleteAndInsert(const String& rText, + const bool bForceExpandHints); + + static void SetCrsrAttr(SwPaM& rPam, const SfxItemSet& rSet, + USHORT nAttrMode); + static void GetCrsrAttr( SwPaM& rPam, SfxItemSet& rSet, + BOOL bOnlyTxtAttr = FALSE, BOOL bGetFromChrFmt = TRUE ); + static void getTextFromPam(SwPaM& aCrsr, ::rtl::OUString& rBuffer); + static SwFmtColl* GetCurTxtFmtColl(SwPaM& rPam, BOOL bConditional); + + static void SelectPam(SwPaM& rCrsr, sal_Bool bExpand); + static void SetString(SwCursor& rCrsr, const ::rtl::OUString& rString); + + static ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue > + createSortDescriptor(sal_Bool bFromTable); + static sal_Bool convertSortProperties( + const ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue >& rDescriptor, + SwSortOptions& rSortOpt); + + static void SetPropertyValue( + SwPaM& rPaM, + const SfxItemPropertySet& rPropSet, + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Any& aValue, + USHORT nAttrMode = 0) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::beans::PropertyVetoException, + ::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + static ::com::sun::star::uno::Any GetPropertyValue( + SwPaM& rPaM, + const SfxItemPropertySet& rPropSet, + const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + static ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyState > GetPropertyStates( + SwPaM& rPaM, + const SfxItemPropertySet& rPropSet, + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& + rPropertyNames, + SwGetPropertyStatesCaller eCaller=SW_PROPERTY_STATE_CALLER_DEFAULT) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::uno::RuntimeException); + static ::com::sun::star::beans::PropertyState GetPropertyState( + SwPaM& rPaM, + const SfxItemPropertySet& rPropSet, + const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::uno::RuntimeException); + static void SetPropertyToDefault( + SwPaM& rPaM, + const SfxItemPropertySet& rPropSet, + const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::uno::RuntimeException); + static ::com::sun::star::uno::Any GetPropertyDefault( + SwPaM& rPaM, + const SfxItemPropertySet& rPropSet, + const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + + virtual const SwPaM* GetPaM() const; + virtual SwPaM* GetPaM(); + virtual const SwDoc* GetDoc() const; + virtual SwDoc* GetDoc(); + + // SwClient + virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + + DECLARE_XINTERFACE() + + static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId(); + + // XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( + const ::com::sun::star::uno::Sequence< sal_Int8 >& rIdentifier) + throw (::com::sun::star::uno::RuntimeException); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( + const ::rtl::OUString& rServiceName) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL + getSupportedServiceNames() + throw (::com::sun::star::uno::RuntimeException); + + // XPropertySet + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySetInfo > SAL_CALL + getPropertySetInfo() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertyValue( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Any& rValue) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::beans::PropertyVetoException, + ::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( + const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addPropertyChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertyChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removePropertyChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertyChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addVetoableChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XVetoableChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeVetoableChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XVetoableChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + + // XPropertyState + virtual ::com::sun::star::beans::PropertyState SAL_CALL + getPropertyState(const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyState > SAL_CALL + getPropertyStates( + const ::com::sun::star::uno::Sequence< + ::rtl::OUString >& rPropertyNames) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertyToDefault( + const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault( + const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + + // XMultiPropertyStates + virtual void SAL_CALL setAllPropertiesToDefault() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertiesToDefault( + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& + rPropertyNames) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > + SAL_CALL getPropertyDefaults( + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& + rPropertyNames) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + + // XElementAccess + virtual ::com::sun::star::uno::Type SAL_CALL getElementType() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL hasElements() + throw (::com::sun::star::uno::RuntimeException); + + // XEnumerationAccess + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::container::XEnumeration > SAL_CALL + createEnumeration() + throw (::com::sun::star::uno::RuntimeException); + + // XContentEnumerationAccess + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::container::XEnumeration > SAL_CALL + createContentEnumeration(const ::rtl::OUString& rServiceName) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL + getAvailableServiceNames() + throw (::com::sun::star::uno::RuntimeException); + + // XSortable + virtual ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue > SAL_CALL + createSortDescriptor() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL sort( + const ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue >& xDescriptor) + throw (::com::sun::star::uno::RuntimeException); + + // XDocumentInsertable + virtual void SAL_CALL insertDocumentFromURL( + const ::rtl::OUString& rURL, + const ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue >& rOptions) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::io::IOException, + ::com::sun::star::uno::RuntimeException); + + // XTextRange + virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > + SAL_CALL getText() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > SAL_CALL getStart() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > SAL_CALL getEnd() + throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getString() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setString(const ::rtl::OUString& rString) + throw (::com::sun::star::uno::RuntimeException); + + // XTextCursor + virtual void SAL_CALL collapseToStart() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL collapseToEnd() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isCollapsed() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL goLeft(sal_Int16 nCount, sal_Bool bExpand) + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL goRight(sal_Int16 nCount, sal_Bool bExpand) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL gotoStart(sal_Bool bExpand) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL gotoEnd(sal_Bool bExpand) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL gotoRange( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange >& xRange, + sal_Bool bExpand) + throw (::com::sun::star::uno::RuntimeException); + + // XWordCursor + virtual sal_Bool SAL_CALL isStartOfWord() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isEndOfWord() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL gotoNextWord(sal_Bool bExpand) + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL gotoPreviousWord(sal_Bool bExpand) + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL gotoEndOfWord(sal_Bool bExpand) + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL gotoStartOfWord(sal_Bool bExpand) + throw (::com::sun::star::uno::RuntimeException); + + // XSentenceCursor + virtual sal_Bool SAL_CALL isStartOfSentence() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isEndOfSentence() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL gotoNextSentence(sal_Bool Expand) + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL gotoPreviousSentence(sal_Bool Expand) + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL gotoStartOfSentence(sal_Bool Expand) + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL gotoEndOfSentence(sal_Bool Expand) + throw (::com::sun::star::uno::RuntimeException); + + // XParagraphCursor + virtual sal_Bool SAL_CALL isStartOfParagraph() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isEndOfParagraph() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL gotoStartOfParagraph(sal_Bool Expand) + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL gotoEndOfParagraph(sal_Bool Expand) + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL gotoNextParagraph(sal_Bool Expand) + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL gotoPreviousParagraph(sal_Bool Expand) + throw (::com::sun::star::uno::RuntimeException); + + // XRedline + virtual void SAL_CALL makeRedline( + const ::rtl::OUString& rRedlineType, + const ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue >& RedlineProperties) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + +}; + +#endif // SW_UNOTEXTCURSOR_HXX + diff --git a/sw/source/core/access/accpara.cxx b/sw/source/core/access/accpara.cxx index ced1e6261c7b..cf24aaa87065 100644 --- a/sw/source/core/access/accpara.cxx +++ b/sw/source/core/access/accpara.cxx @@ -30,10 +30,12 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" + #include #include #include #include +#include #include #include #include "fesh.hxx" @@ -63,7 +65,6 @@ #include // for GetWordBoundary // for get/setCharacterAttribute(...) #include "unocrsr.hxx" -#include "unoobj.hxx" #include "unoport.hxx" #include "doc.hxx" #include "crsskip.hxx" diff --git a/sw/source/core/edit/editsh.cxx b/sw/source/core/edit/editsh.cxx index 4d7cbc07e4ad..796905fd49f5 100644 --- a/sw/source/core/edit/editsh.cxx +++ b/sw/source/core/edit/editsh.cxx @@ -63,7 +63,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sw/source/core/unocore/unobkm.cxx b/sw/source/core/unocore/unobkm.cxx index 0ec0442457f5..8f7a44de70d8 100644 --- a/sw/source/core/unocore/unobkm.cxx +++ b/sw/source/core/unocore/unobkm.cxx @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unocrsrhelper.cxx b/sw/source/core/unocore/unocrsrhelper.cxx index a5fcf29f8b64..5b83f3007904 100644 --- a/sw/source/core/unocore/unocrsrhelper.cxx +++ b/sw/source/core/unocore/unocrsrhelper.cxx @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx index ec978f02a0ec..7eacc7eeaa68 100644 --- a/sw/source/core/unocore/unodraw.cxx +++ b/sw/source/core/unocore/unodraw.cxx @@ -49,6 +49,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx index f8de0eb39691..c846c4a90f82 100644 --- a/sw/source/core/unocore/unofield.cxx +++ b/sw/source/core/unocore/unofield.cxx @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx index 87bc0ff6b173..68598e3a3f98 100644 --- a/sw/source/core/unocore/unoframe.cxx +++ b/sw/source/core/unocore/unoframe.cxx @@ -61,6 +61,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unoftn.cxx b/sw/source/core/unocore/unoftn.cxx index cf1b6dc516c4..bb9e2f2ed5ff 100644 --- a/sw/source/core/unocore/unoftn.cxx +++ b/sw/source/core/unocore/unoftn.cxx @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unoidx.cxx b/sw/source/core/unocore/unoidx.cxx index a90bdc28bdab..6bcb59dca0b1 100644 --- a/sw/source/core/unocore/unoidx.cxx +++ b/sw/source/core/unocore/unoidx.cxx @@ -58,6 +58,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx index 3f07ccf66b62..00c0f5bd0e6c 100644 --- a/sw/source/core/unocore/unoobj.cxx +++ b/sw/source/core/unocore/unoobj.cxx @@ -83,6 +83,7 @@ #include #include #include +#include #include #include #include @@ -118,6 +119,7 @@ #include #include #include +#include #include #include diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index b8435fe17166..85bc6f8270f1 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -78,6 +78,7 @@ #include #include #include +#include #include #include #include @@ -123,6 +124,7 @@ #include // OD 2004-05-24 #i28701# #include +#include #include #include diff --git a/sw/source/core/unocore/unoparagraph.cxx b/sw/source/core/unocore/unoparagraph.cxx index bb7c30667ab1..db3accd76165 100644 --- a/sw/source/core/unocore/unoparagraph.cxx +++ b/sw/source/core/unocore/unoparagraph.cxx @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unoport.cxx b/sw/source/core/unocore/unoport.cxx index 7071eb59731d..5dae67498cfe 100644 --- a/sw/source/core/unocore/unoport.cxx +++ b/sw/source/core/unocore/unoport.cxx @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unoportenum.cxx b/sw/source/core/unocore/unoportenum.cxx index ad3e52cff75b..f9379cbd476f 100644 --- a/sw/source/core/unocore/unoportenum.cxx +++ b/sw/source/core/unocore/unoportenum.cxx @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unoredline.cxx b/sw/source/core/unocore/unoredline.cxx index 80297bb64321..eb8b43bc0ecc 100644 --- a/sw/source/core/unocore/unoredline.cxx +++ b/sw/source/core/unocore/unoredline.cxx @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unorefmk.cxx b/sw/source/core/unocore/unorefmk.cxx index 45c79b5edcf5..1b8f58d514e2 100644 --- a/sw/source/core/unocore/unorefmk.cxx +++ b/sw/source/core/unocore/unorefmk.cxx @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unosect.cxx b/sw/source/core/unocore/unosect.cxx index c7d53042ee62..b5f1c3765f00 100644 --- a/sw/source/core/unocore/unosect.cxx +++ b/sw/source/core/unocore/unosect.cxx @@ -46,6 +46,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index ab9006d5fae4..6e5bf7a554d8 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -84,6 +84,7 @@ #include #include #include +#include #include #include // SvNumberFormatter #include @@ -99,6 +100,7 @@ #include #include #include +#include #include diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index f7ae2ebcde95..06cd397269c9 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/filter/xml/XMLRedlineImportHelper.cxx b/sw/source/filter/xml/XMLRedlineImportHelper.cxx index 7e3187a4a948..62fd05dac6f3 100644 --- a/sw/source/filter/xml/XMLRedlineImportHelper.cxx +++ b/sw/source/filter/xml/XMLRedlineImportHelper.cxx @@ -33,6 +33,7 @@ #include "XMLRedlineImportHelper.hxx" +#include #include "unoobj.hxx" #include #include "doc.hxx" diff --git a/sw/source/filter/xml/xmlimp.cxx b/sw/source/filter/xml/xmlimp.cxx index 44744f0d18a2..aae9e1f60fd7 100644 --- a/sw/source/filter/xml/xmlimp.cxx +++ b/sw/source/filter/xml/xmlimp.cxx @@ -38,18 +38,15 @@ #include #include #include -#ifndef _XMLOFF_TXTIMP_HXX #include -#endif #include -#ifndef _XMLOFF_XMLTEXTSHAPEIMPORTHELPER_HXX_ #include -#endif #include #include #include #include #include +#include #include #include "unocrsr.hxx" #include diff --git a/sw/source/filter/xml/xmltexti.cxx b/sw/source/filter/xml/xmltexti.cxx index 8c414cdeab0e..acf49038078a 100644 --- a/sw/source/filter/xml/xmltexti.cxx +++ b/sw/source/filter/xml/xmltexti.cxx @@ -51,6 +51,7 @@ #include #include "unocrsr.hxx" #include "unoobj.hxx" +#include "TextCursorHelper.hxx" #include "unoframe.hxx" #include "doc.hxx" #include "unocoll.hxx" diff --git a/sw/source/ui/uno/unoatxt.cxx b/sw/source/ui/uno/unoatxt.cxx index 2b302245f53b..88f7ce8dbaa8 100644 --- a/sw/source/ui/uno/unoatxt.cxx +++ b/sw/source/ui/uno/unoatxt.cxx @@ -34,10 +34,7 @@ #define _SVSTDARR_STRINGS - -#ifndef _COM_SUN_STAR_BEANS_PropertyAttribute_HPP_ #include -#endif #include #include #include @@ -53,6 +50,7 @@ #include #include #include +#include #include #include #include @@ -68,6 +66,7 @@ #include + SV_IMPL_REF ( SwDocShell ) using namespace ::com::sun::star; using ::rtl::OUString; diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index fe3d8639bf84..6be92a156397 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -50,6 +50,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/ui/uno/unotxvw.cxx b/sw/source/ui/uno/unotxvw.cxx index 6239bc9503ea..5c71f6707873 100644 --- a/sw/source/ui/uno/unotxvw.cxx +++ b/sw/source/ui/uno/unotxvw.cxx @@ -79,6 +79,7 @@ #include #include #include +#include #include #include diff --git a/sw/source/ui/utlui/unotools.cxx b/sw/source/ui/utlui/unotools.cxx index f2efc1d85a00..c638594431d1 100644 --- a/sw/source/ui/utlui/unotools.cxx +++ b/sw/source/ui/utlui/unotools.cxx @@ -59,12 +59,13 @@ #include #include #include -#include +#include #include #include #include + using namespace ::com::sun::star; using ::rtl::OUString; -- cgit From e23c9ccd3e9e8d415d0bbab189e2de5ba48b42e9 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Tue, 5 Jan 2010 16:37:46 +0100 Subject: swunolocking1: #i105557#: unoobj.hxx: split out unotextrange.hxx: move SwXTextRange, SwXTextRanges from unoobj.hxx to new unotextrange.hxx. move SwUnoInternalPaM to unotextrange.hxx. --- sw/inc/unoframe.hxx | 8 +- sw/inc/unoobj.hxx | 184 ----------- sw/inc/unotbl.hxx | 9 +- sw/inc/unotextrange.hxx | 376 +++++++++++++++++++++++ sw/source/core/access/accpara.cxx | 2 +- sw/source/core/crsr/crsrsh.cxx | 2 +- sw/source/core/txtnode/fmtatr2.cxx | 2 +- sw/source/core/txtnode/ndtxt.cxx | 2 +- sw/source/core/unocore/unobkm.cxx | 2 +- sw/source/core/unocore/unodraw.cxx | 1 + sw/source/core/unocore/unofield.cxx | 1 + sw/source/core/unocore/unoflatpara.cxx | 1 + sw/source/core/unocore/unoframe.cxx | 1 + sw/source/core/unocore/unoftn.cxx | 3 +- sw/source/core/unocore/unoidx.cxx | 1 + sw/source/core/unocore/unoobj.cxx | 1 + sw/source/core/unocore/unoobj2.cxx | 1 + sw/source/core/unocore/unoparagraph.cxx | 1 + sw/source/core/unocore/unoport.cxx | 1 + sw/source/core/unocore/unoredline.cxx | 1 + sw/source/core/unocore/unorefmk.cxx | 1 + sw/source/core/unocore/unosect.cxx | 1 + sw/source/core/unocore/unotbl.cxx | 1 + sw/source/core/unocore/unotext.cxx | 1 + sw/source/filter/html/htmlform.cxx | 9 +- sw/source/filter/ww8/ww8par3.cxx | 2 +- sw/source/filter/xml/XMLRedlineImportHelper.cxx | 1 + sw/source/filter/xml/swxml.cxx | 2 +- sw/source/filter/xml/xmlimp.cxx | 1 + sw/source/filter/xml/xmltbli.cxx | 2 +- sw/source/ui/dialog/SwSpellDialogChildWindow.cxx | 6 +- sw/source/ui/uno/unoatxt.cxx | 1 + sw/source/ui/uno/unotxdoc.cxx | 1 + sw/source/ui/uno/unotxvw.cxx | 1 + 34 files changed, 423 insertions(+), 207 deletions(-) create mode 100644 sw/inc/unotextrange.hxx (limited to 'sw') diff --git a/sw/inc/unoframe.hxx b/sw/inc/unoframe.hxx index 4f62430f1cc2..470303ab92ed 100644 --- a/sw/inc/unoframe.hxx +++ b/sw/inc/unoframe.hxx @@ -31,7 +31,7 @@ #define _UNOFRAME_HXX #include -#include +#include #include #include #include @@ -43,8 +43,14 @@ #include */ +#include + +#include + + class SwDoc; class SfxItemPropertSet; + /*-----------------12.02.98 11:21------------------- --------------------------------------------------*/ diff --git a/sw/inc/unoobj.hxx b/sw/inc/unoobj.hxx index 98bee1bf0e93..fa6600b14107 100644 --- a/sw/inc/unoobj.hxx +++ b/sw/inc/unoobj.hxx @@ -35,46 +35,35 @@ #include #include #include -#include #include #include #include #include -#include #include #include #include -#include #include #include #include -#include -#include #include -#include #include #include #include #include #include -#include #include #include // helper for factories #include // helper for implementations -#include // helper for implementations #include // helper for implementations #include // helper for implementations #include // helper for implementations -#include #include #include #include #include -#include - #include #include @@ -110,19 +99,6 @@ void CollectFrameAtNode( SwClient& rClnt, const SwNodeIndex& rIdx, FrameDependSortList_t & rFrames, const bool _bAtCharAnchoredObjs ); -/* -----------------29.04.98 07:35------------------- - * - * --------------------------------------------------*/ -class SwUnoInternalPaM : public SwPaM -{ - SwUnoInternalPaM( const SwUnoInternalPaM& ); -public: - SwUnoInternalPaM(SwDoc& rDoc); - ~SwUnoInternalPaM(); - - SwUnoInternalPaM& operator=(const SwPaM& rPaM); -}; - /*-----------------04.03.98 11:54------------------- Start/EndAction oder Start/EndAllAction --------------------------------------------------*/ @@ -149,8 +125,6 @@ class UnoActionRemoveContext /****************************************************************************** * ******************************************************************************/ -typedef com::sun::star::uno::Reference< com::sun::star::text::XTextRange > * XTextRangeRefPtr; -SV_DECL_PTRARR(XTextRangeArr, XTextRangeRefPtr, 4, 4) void ClientModify(SwClient* pClient, SfxPoolItem *pOld, SfxPoolItem *pNew); @@ -371,164 +345,6 @@ public: ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > CreateTextCursor(BOOL bIgnoreTables = sal_False); }; -class SW_DLLPUBLIC SwXTextRange : public cppu::WeakImplHelper8 -< - ::com::sun::star::text::XTextRange, - ::com::sun::star::lang::XUnoTunnel, - ::com::sun::star::lang::XServiceInfo, - ::com::sun::star::container::XContentEnumerationAccess, - ::com::sun::star::beans::XPropertySet, - ::com::sun::star::beans::XPropertyState, - ::com::sun::star::container::XEnumerationAccess, - ::com::sun::star::text::XRedline ->, private SwClient -{ - friend class SwXText; - enum RangePosition - { - RANGE_IN_TEXT, // 'normaler' ::com::sun::star::text::TextRange - RANGE_IN_FRAME,// TextPosition wurde mit einem Rahmen angelegt, der kein Uno-Objekt besitzt - RANGE_IN_CELL, // TextPosition wurde mit einer Zelle angelegt, die kein Uno-Objekt besitzt - RANGE_IS_TABLE, // Anker einer Tabelle - RANGE_INVALID // von NewInstance erzeugt - } eRangePosition; - - SwDoc* pDoc; - SwTableBox* pBox; - const SwStartNode* pBoxStartNode; - SwDepend aObjectDepend; //Format der Tabelle oder des Rahmens anmelden - const SfxItemPropertySet* m_pPropSet; - //SwDepend aFrameDepend; - ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > xParentText; - ::sw::mark::IMark* pMark; - - void _CreateNewBookmark(SwPaM& rPam); - //TODO: new exception type for protected content - void DeleteAndInsert(const String& rText, const bool bForceExpandHints) - throw( ::com::sun::star::uno::RuntimeException ); -protected: - virtual ~SwXTextRange(); - -public: - SwXTextRange(SwPaM& rPam, const ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > & rxParent, enum RangePosition eRange = RANGE_IN_TEXT); - // only for RANGE_IS_TABLE - SwXTextRange(SwFrmFmt& rTblFmt); - - TYPEINFO(); - - static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId(); - - //XUnoTunnel - virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); - - //XTextRange - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > SAL_CALL getText(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getStart(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getEnd(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual rtl::OUString SAL_CALL getString(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL setString(const rtl::OUString& aString) throw( ::com::sun::star::uno::RuntimeException ); - - //XContentEnumerationAccess - virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createContentEnumeration(const rtl::OUString& aServiceName) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getAvailableServiceNames(void) throw( ::com::sun::star::uno::RuntimeException ); - - //XEnumerationAccess - virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createEnumeration(void) throw( ::com::sun::star::uno::RuntimeException ); - - //XElementAccess - virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw(::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL hasElements( ) throw(::com::sun::star::uno::RuntimeException); - - //XServiceInfo - virtual rtl::OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual BOOL SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException ); - - //XPropertySet - virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - - //XPropertyState - virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyState > SAL_CALL getPropertyStates( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setPropertyToDefault( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault( const ::rtl::OUString& aPropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - - //XRedline - virtual void SAL_CALL makeRedline( const ::rtl::OUString& RedlineType, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& RedlineProperties ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); - - //SwClient - virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); - BOOL GetPositions(SwPaM& rToFill) const; - const SwDoc* GetDoc() const - { return pDoc; } - SwDoc* GetDoc() - { return pDoc; } - const ::sw::mark::IMark * GetBookmark() const - { return pMark; } - - static BOOL XTextRangeToSwPaM(SwUnoInternalPaM& rToFill, - const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xTextRange); - static ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > CreateTextRangeFromPosition( - SwDoc* pDoc, - const SwPosition& rPos, const SwPosition* pMark); - static ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > CreateParentXText(SwDoc* pDoc, - const SwPosition& rPos); -}; - -/* -----------------15.05.98 08:29------------------- - * - * --------------------------------------------------*/ -typedef cppu::WeakImplHelper3 -< - ::com::sun::star::container::XIndexAccess, - ::com::sun::star::lang::XUnoTunnel, - ::com::sun::star::lang::XServiceInfo -> -SwXTextRangesBaseClass; -class SwXTextRanges : public SwXTextRangesBaseClass, - public SwClient -{ - XTextRangeArr* pRangeArr; - ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > xParentText; - XTextRangeArr* GetRangesArray(); - SwUnoCrsr* GetCrsr() const { return (SwUnoCrsr*)GetRegisteredIn(); } -protected: - virtual ~SwXTextRanges(); -public: - SwXTextRanges(); - SwXTextRanges(SwPaM* pCrsr); - - - static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId(); - - //XUnoTunnel - virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) - throw(::com::sun::star::uno::RuntimeException); - - - //XIndexAccess - virtual sal_Int32 SAL_CALL getCount(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException ); - - //XElementAccess - virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw(::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL hasElements( ) throw(::com::sun::star::uno::RuntimeException); - - //XServiceInfo - virtual rtl::OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual BOOL SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException ); - - //SwClient - virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew); - const SwUnoCrsr* GetCursor() const { return (const SwUnoCrsr*)GetRegisteredIn(); } -}; /*-----------------12.02.98 08:01------------------- diff --git a/sw/inc/unotbl.hxx b/sw/inc/unotbl.hxx index fa82f1b63aa3..c14dac1bc2d0 100644 --- a/sw/inc/unotbl.hxx +++ b/sw/inc/unotbl.hxx @@ -41,11 +41,14 @@ #include #include #include -#include // helper for implementations -#include // helper for implementations -#include // helper for implementations + +#include +#include +#include +#include #include + #include diff --git a/sw/inc/unotextrange.hxx b/sw/inc/unotextrange.hxx new file mode 100644 index 000000000000..a7d13daf4848 --- /dev/null +++ b/sw/inc/unotextrange.hxx @@ -0,0 +1,376 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: unoobj.hxx,v $ + * + * $Revision: 1.49 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SW_UNOTEXTRANGE_HXX +#define SW_UNOTEXTRANGE_HXX + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include +#include + + +class String; +class SfxItemPropertySet; +class SwDoc; +class SwStartNode; +struct SwPosition; +class SwPaM; +class SwUnoCrsr; +class SwFrmFmt; +class SwTableBox; + +namespace sw { + namespace mark { + class IMark; + } +} + +/* -----------------29.04.98 07:35------------------- + * + * --------------------------------------------------*/ +class SwUnoInternalPaM + : public SwPaM +{ + +private: + SwUnoInternalPaM(const SwUnoInternalPaM&); + SwUnoInternalPaM& operator=(const SwPaM& rPaM); + +public: + SwUnoInternalPaM(SwDoc& rDoc); + virtual ~SwUnoInternalPaM(); + +}; + + +typedef ::cppu::WeakImplHelper8 +< ::com::sun::star::lang::XUnoTunnel +, ::com::sun::star::lang::XServiceInfo +, ::com::sun::star::beans::XPropertySet +, ::com::sun::star::beans::XPropertyState +, ::com::sun::star::container::XEnumerationAccess +, ::com::sun::star::container::XContentEnumerationAccess +, ::com::sun::star::text::XTextRange +, ::com::sun::star::text::XRedline +> SwXTextRange_Base; + +class SW_DLLPUBLIC SwXTextRange + : public SwXTextRange_Base + , private SwClient +{ + +private: + + friend class SwXText; + + enum RangePosition + { + RANGE_IN_TEXT, // "ordinary" ::com::sun::star::text::TextRange + RANGE_IN_FRAME, // position created with a frame that has no uno object + RANGE_IN_CELL, // position created with a cell that has no uno object + RANGE_IS_TABLE, // anchor of a table + RANGE_INVALID // created by NewInstance + } eRangePosition; + + SwDoc* pDoc; + SwTableBox* pBox; + const SwStartNode* pBoxStartNode; + SwDepend aObjectDepend; // register at format of table or frame + const SfxItemPropertySet* m_pPropSet; + //SwDepend aFrameDepend; + ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > + xParentText; + ::sw::mark::IMark* pMark; + + void _CreateNewBookmark(SwPaM& rPam); + //TODO: new exception type for protected content + void DeleteAndInsert(const String& rText, const bool bForceExpandHints) + throw (::com::sun::star::uno::RuntimeException); + +protected: + + virtual ~SwXTextRange(); + +public: + + SwXTextRange(SwPaM& rPam, + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XText > & xParent, + enum RangePosition eRange = RANGE_IN_TEXT); + // only for RANGE_IS_TABLE + SwXTextRange(SwFrmFmt& rTblFmt); + + BOOL GetPositions(SwPaM& rToFill) const; + const SwDoc* GetDoc() const + { return pDoc; } + SwDoc* GetDoc() + { return pDoc; } + const ::sw::mark::IMark * GetBookmark() const + { return pMark; } + + static BOOL XTextRangeToSwPaM(SwUnoInternalPaM& rToFill, + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xTextRange); + static ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > CreateTextRangeFromPosition( + SwDoc* pDoc, + const SwPosition& rPos, const SwPosition* pMark); + static ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > + CreateParentXText(SwDoc* pDoc, const SwPosition& rPos); + + TYPEINFO(); + + // SwClient + virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + + static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId(); + + // XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( + const ::com::sun::star::uno::Sequence< sal_Int8 >& rIdentifier) + throw (::com::sun::star::uno::RuntimeException); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( + const ::rtl::OUString& rServiceName) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL + getSupportedServiceNames() + throw (::com::sun::star::uno::RuntimeException); + + // XPropertySet + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySetInfo > SAL_CALL + getPropertySetInfo() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertyValue( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Any& rValue) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::beans::PropertyVetoException, + ::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( + const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addPropertyChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertyChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removePropertyChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertyChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addVetoableChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XVetoableChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeVetoableChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XVetoableChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + + // XPropertyState + virtual ::com::sun::star::beans::PropertyState SAL_CALL + getPropertyState(const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyState > SAL_CALL + getPropertyStates( + const ::com::sun::star::uno::Sequence< + ::rtl::OUString >& rPropertyNames) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertyToDefault( + const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault( + const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + + // XElementAccess + virtual ::com::sun::star::uno::Type SAL_CALL getElementType() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL hasElements() + throw (::com::sun::star::uno::RuntimeException); + + // XEnumerationAccess + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::container::XEnumeration > SAL_CALL + createEnumeration() + throw (::com::sun::star::uno::RuntimeException); + + // XContentEnumerationAccess + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::container::XEnumeration > SAL_CALL + createContentEnumeration(const ::rtl::OUString& rServiceName) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL + getAvailableServiceNames() + throw (::com::sun::star::uno::RuntimeException); + + // XTextRange + virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > + SAL_CALL getText() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > SAL_CALL getStart() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > SAL_CALL getEnd() + throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getString() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setString(const ::rtl::OUString& rString) + throw (::com::sun::star::uno::RuntimeException); + + // XRedline + virtual void SAL_CALL makeRedline( + const ::rtl::OUString& rRedlineType, + const ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue >& RedlineProperties) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + +}; + +/* -----------------15.05.98 08:29------------------- + * + * --------------------------------------------------*/ +typedef ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > * + XTextRangeRefPtr; +SV_DECL_PTRARR(XTextRangeArr, XTextRangeRefPtr, 4, 4) + +typedef ::cppu::WeakImplHelper3 +< ::com::sun::star::lang::XUnoTunnel +, ::com::sun::star::lang::XServiceInfo +, ::com::sun::star::container::XIndexAccess +> SwXTextRanges_Base; + +class SwXTextRanges + : public SwXTextRanges_Base + , public SwClient +{ + +private: + + XTextRangeArr* pRangeArr; + ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > + xParentText; + XTextRangeArr* GetRangesArray(); + SwUnoCrsr* GetCrsr() const { return (SwUnoCrsr*)GetRegisteredIn(); } + +protected: + + virtual ~SwXTextRanges(); + +public: + + SwXTextRanges(); + SwXTextRanges(SwPaM* pCrsr); + + const SwUnoCrsr* GetCursor() const { + return (const SwUnoCrsr*)(GetRegisteredIn()); + } + + // SwClient + virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + + static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId(); + + // XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( + const ::com::sun::star::uno::Sequence< sal_Int8 >& rIdentifier) + throw (::com::sun::star::uno::RuntimeException); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( + const ::rtl::OUString& rServiceName) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL + getSupportedServiceNames() + throw (::com::sun::star::uno::RuntimeException); + + // XElementAccess + virtual ::com::sun::star::uno::Type SAL_CALL getElementType() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL hasElements() + throw (::com::sun::star::uno::RuntimeException); + + // XIndexAccess + virtual sal_Int32 SAL_CALL getCount() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) + throw (::com::sun::star::lang::IndexOutOfBoundsException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + +}; + +#endif // SW_UNOTEXTRANGE_HXX + diff --git a/sw/source/core/access/accpara.cxx b/sw/source/core/access/accpara.cxx index cf24aaa87065..29464206c24b 100644 --- a/sw/source/core/access/accpara.cxx +++ b/sw/source/core/access/accpara.cxx @@ -34,7 +34,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx index 8a82e66c4c7b..f4b7e0a0b10d 100644 --- a/sw/source/core/crsr/crsrsh.cxx +++ b/sw/source/core/crsr/crsrsh.cxx @@ -66,7 +66,7 @@ #include // ...Percent() #include #include // SMARTTAGS -#include // SMARTTAGS +#include // SMARTTAGS #include #include #include diff --git a/sw/source/core/txtnode/fmtatr2.cxx b/sw/source/core/txtnode/fmtatr2.cxx index 8093a84dbbd9..405358adac59 100644 --- a/sw/source/core/txtnode/fmtatr2.cxx +++ b/sw/source/core/txtnode/fmtatr2.cxx @@ -57,7 +57,7 @@ #include // for meta #include // for meta #include -#include // SwXTextRange +#include #include #include // GetNumberFormat diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index 46b105723a1d..8e83c3cb9ded 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -4973,7 +4973,7 @@ bool SwTxtNode::IsInContent() const } #include -#include +#include ::com::sun::star::uno::Reference< ::com::sun::star::rdf::XMetadatable > SwTxtNode::MakeUnoObject() diff --git a/sw/source/core/unocore/unobkm.cxx b/sw/source/core/unocore/unobkm.cxx index 8f7a44de70d8..171bead57a09 100644 --- a/sw/source/core/unocore/unobkm.cxx +++ b/sw/source/core/unocore/unobkm.cxx @@ -31,12 +31,12 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - #include #include #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx index 7eacc7eeaa68..b3c5eebc11a8 100644 --- a/sw/source/core/unocore/unodraw.cxx +++ b/sw/source/core/unocore/unodraw.cxx @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx index c846c4a90f82..eca06ed0d741 100644 --- a/sw/source/core/unocore/unofield.cxx +++ b/sw/source/core/unocore/unofield.cxx @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unoflatpara.cxx b/sw/source/core/unocore/unoflatpara.cxx index ae773f389f30..66796031c4ba 100644 --- a/sw/source/core/unocore/unoflatpara.cxx +++ b/sw/source/core/unocore/unoflatpara.cxx @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx index 68598e3a3f98..14ac1007d3ae 100644 --- a/sw/source/core/unocore/unoframe.cxx +++ b/sw/source/core/unocore/unoframe.cxx @@ -61,6 +61,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unoftn.cxx b/sw/source/core/unocore/unoftn.cxx index bb9e2f2ed5ff..23ec936a4244 100644 --- a/sw/source/core/unocore/unoftn.cxx +++ b/sw/source/core/unocore/unoftn.cxx @@ -31,11 +31,11 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - #include #include #include #include +#include #include #include #include @@ -48,6 +48,7 @@ #include #include + using namespace ::com::sun::star; using ::rtl::OUString; diff --git a/sw/source/core/unocore/unoidx.cxx b/sw/source/core/unocore/unoidx.cxx index 6bcb59dca0b1..e8bba7ac7357 100644 --- a/sw/source/core/unocore/unoidx.cxx +++ b/sw/source/core/unocore/unoidx.cxx @@ -58,6 +58,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx index 00c0f5bd0e6c..13a102164cad 100644 --- a/sw/source/core/unocore/unoobj.cxx +++ b/sw/source/core/unocore/unoobj.cxx @@ -83,6 +83,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index 85bc6f8270f1..299d9904d4f4 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -78,6 +78,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unoparagraph.cxx b/sw/source/core/unocore/unoparagraph.cxx index db3accd76165..99e67d06a00a 100644 --- a/sw/source/core/unocore/unoparagraph.cxx +++ b/sw/source/core/unocore/unoparagraph.cxx @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unoport.cxx b/sw/source/core/unocore/unoport.cxx index 5dae67498cfe..f7b2e40fa440 100644 --- a/sw/source/core/unocore/unoport.cxx +++ b/sw/source/core/unocore/unoport.cxx @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unoredline.cxx b/sw/source/core/unocore/unoredline.cxx index eb8b43bc0ecc..1aca819a6d2e 100644 --- a/sw/source/core/unocore/unoredline.cxx +++ b/sw/source/core/unocore/unoredline.cxx @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unorefmk.cxx b/sw/source/core/unocore/unorefmk.cxx index 1b8f58d514e2..ce501056affc 100644 --- a/sw/source/core/unocore/unorefmk.cxx +++ b/sw/source/core/unocore/unorefmk.cxx @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unosect.cxx b/sw/source/core/unocore/unosect.cxx index b5f1c3765f00..5a87da1e48ab 100644 --- a/sw/source/core/unocore/unosect.cxx +++ b/sw/source/core/unocore/unosect.cxx @@ -44,6 +44,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index 6e5bf7a554d8..e24e17dd47cb 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -84,6 +84,7 @@ #include #include #include +#include #include #include #include // SvNumberFormatter diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index 06cd397269c9..be23a873ad28 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/filter/html/htmlform.cxx b/sw/source/filter/html/htmlform.cxx index dd93a4e60b92..0b8ad7322a80 100644 --- a/sw/source/filter/html/htmlform.cxx +++ b/sw/source/filter/html/htmlform.cxx @@ -34,22 +34,16 @@ #include #include -#ifndef _WRKWIN_HXX //autogen #include -#endif #include -#ifndef _TOOLKIT_UNOHLP_HXX #include -#endif #include #include #include #include #include -#ifndef _SFXAPP_HXX #include -#endif #include #include #include @@ -84,13 +78,14 @@ #include #include #include -#include +#include #include "dcontact.hxx" #include "swcss1.hxx" #include "swhtml.hxx" #include "htmlform.hxx" + using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::lang; diff --git a/sw/source/filter/ww8/ww8par3.cxx b/sw/source/filter/ww8/ww8par3.cxx index aa2737da1fa4..8ea782ad0426 100644 --- a/sw/source/filter/ww8/ww8par3.cxx +++ b/sw/source/filter/ww8/ww8par3.cxx @@ -77,7 +77,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sw/source/filter/xml/XMLRedlineImportHelper.cxx b/sw/source/filter/xml/XMLRedlineImportHelper.cxx index 62fd05dac6f3..0102462b4864 100644 --- a/sw/source/filter/xml/XMLRedlineImportHelper.cxx +++ b/sw/source/filter/xml/XMLRedlineImportHelper.cxx @@ -35,6 +35,7 @@ #include "XMLRedlineImportHelper.hxx" #include #include "unoobj.hxx" +#include #include #include "doc.hxx" #include diff --git a/sw/source/filter/xml/swxml.cxx b/sw/source/filter/xml/swxml.cxx index a99e719e3fe0..d53261ea3fe5 100644 --- a/sw/source/filter/xml/swxml.cxx +++ b/sw/source/filter/xml/swxml.cxx @@ -72,7 +72,7 @@ #include #include #include -#include +#include #include #include diff --git a/sw/source/filter/xml/xmlimp.cxx b/sw/source/filter/xml/xmlimp.cxx index aae9e1f60fd7..476f8871e7a5 100644 --- a/sw/source/filter/xml/xmlimp.cxx +++ b/sw/source/filter/xml/xmlimp.cxx @@ -48,6 +48,7 @@ #include #include #include +#include #include "unocrsr.hxx" #include #include diff --git a/sw/source/filter/xml/xmltbli.cxx b/sw/source/filter/xml/xmltbli.cxx index b71812df6774..e2b154178b29 100644 --- a/sw/source/filter/xml/xmltbli.cxx +++ b/sw/source/filter/xml/xmltbli.cxx @@ -32,7 +32,6 @@ #include "precompiled_sw.hxx" - #include "hintids.hxx" #include @@ -58,6 +57,7 @@ #include "swtblfmt.hxx" #include "pam.hxx" #include "unotbl.hxx" +#include "unotextrange.hxx" #include "unocrsr.hxx" #include "cellatr.hxx" #include "swddetbl.hxx" diff --git a/sw/source/ui/dialog/SwSpellDialogChildWindow.cxx b/sw/source/ui/dialog/SwSpellDialogChildWindow.cxx index 8dca8ef1abf0..85838652d370 100644 --- a/sw/source/ui/dialog/SwSpellDialogChildWindow.cxx +++ b/sw/source/ui/dialog/SwSpellDialogChildWindow.cxx @@ -30,6 +30,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" + #include #include #include @@ -50,21 +51,20 @@ #include #include #include -#ifndef _DOCSH_HXX #include -#endif #include #include #include #include #include #include -#include +#include #ifndef _DIALOG_HXX #include #endif #include + using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::text; diff --git a/sw/source/ui/uno/unoatxt.cxx b/sw/source/ui/uno/unoatxt.cxx index 88f7ce8dbaa8..5543277cc585 100644 --- a/sw/source/ui/uno/unoatxt.cxx +++ b/sw/source/ui/uno/unoatxt.cxx @@ -50,6 +50,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index 6be92a156397..8d29db3dd30d 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -50,6 +50,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/ui/uno/unotxvw.cxx b/sw/source/ui/uno/unotxvw.cxx index 5c71f6707873..9da88953d481 100644 --- a/sw/source/ui/uno/unotxvw.cxx +++ b/sw/source/ui/uno/unotxvw.cxx @@ -80,6 +80,7 @@ #include #include #include +#include #include #include -- cgit From a6b34b60ba3e7451cfa8d5a492d53484ec131421 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Tue, 5 Jan 2010 16:37:47 +0100 Subject: swunolocking1: #i105557#: unoobj.hxx: split out unotext.hxx etc.: move SwXText from unoobj.hxx to new unotext.hxx. move SwXBodyText, SwXHeadFootText from unoobj.hxx to new unotextbodyhf.hxx. move SwXFootnote from unoobj.hxx to new unofootnote.hxx. --- sw/inc/unofootnote.hxx | 246 ++++++++++++++++++++ sw/inc/unoframe.hxx | 18 +- sw/inc/unoobj.hxx | 326 --------------------------- sw/inc/unoredline.hxx | 4 +- sw/inc/unotbl.hxx | 13 +- sw/inc/unotext.hxx | 375 +++++++++++++++++++++++++++++++ sw/inc/unotextbodyhf.hxx | 218 ++++++++++++++++++ sw/source/core/doc/doclay.cxx | 3 +- sw/source/core/layout/atrfrm.cxx | 1 + sw/source/core/unocore/unoclbck.cxx | 2 +- sw/source/core/unocore/unocoll.cxx | 2 + sw/source/core/unocore/unocrsrhelper.cxx | 1 + sw/source/core/unocore/unodraw.cxx | 2 + sw/source/core/unocore/unoftn.cxx | 14 +- sw/source/core/unocore/unoobj2.cxx | 2 + sw/source/core/unocore/unoparagraph.cxx | 1 + sw/source/core/unocore/unoredlines.cxx | 1 + sw/source/core/unocore/unorefmk.cxx | 1 + sw/source/core/unocore/unostyle.cxx | 9 +- sw/source/core/unocore/unotext.cxx | 29 +-- sw/source/filter/xml/xmlexp.cxx | 4 +- sw/source/filter/xml/xmlfonte.cxx | 5 +- sw/source/filter/xml/xmlimp.cxx | 1 + sw/source/filter/xml/xmltexte.cxx | 5 +- sw/source/ui/uno/unoatxt.cxx | 1 + sw/source/ui/uno/unotxdoc.cxx | 1 + sw/source/ui/uno/unotxvw.cxx | 1 + 27 files changed, 914 insertions(+), 372 deletions(-) create mode 100644 sw/inc/unofootnote.hxx create mode 100644 sw/inc/unotext.hxx create mode 100644 sw/inc/unotextbodyhf.hxx (limited to 'sw') diff --git a/sw/inc/unofootnote.hxx b/sw/inc/unofootnote.hxx new file mode 100644 index 000000000000..d1c869404d32 --- /dev/null +++ b/sw/inc/unofootnote.hxx @@ -0,0 +1,246 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: unoobj.hxx,v $ + * + * $Revision: 1.49 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SW_UNOFOOTNOTE_HXX +#define SW_UNOFOOTNOTE_HXX + +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include + + +class SwDoc; +class SwFmtFtn; + + +/*-----------------12.02.98 08:01------------------- + +--------------------------------------------------*/ +typedef ::cppu::WeakImplHelper5 +< ::com::sun::star::lang::XUnoTunnel +, ::com::sun::star::lang::XServiceInfo +, ::com::sun::star::beans::XPropertySet +, ::com::sun::star::container::XEnumerationAccess +, ::com::sun::star::text::XFootnote +> SwXFootnote_Base; + +class SwXFootnote + : public SwXFootnote_Base + , public SwXText + , public SwClient +{ + +private: + + friend class SwXFootnotes; + + SwEventListenerContainer aLstnrCntnr; + const SwFmtFtn* pFmtFtn; + BOOL m_bIsDescriptor; + String m_sLabel; + BOOL m_bIsEndnote; + +protected: + + virtual const SwStartNode *GetStartNode() const; + + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextCursor > + createCursor() + throw (::com::sun::star::uno::RuntimeException); + + virtual ~SwXFootnote(); + +public: + + SwXFootnote(BOOL bEndnote); + SwXFootnote(SwDoc* pDoc, const SwFmtFtn& rFmt); + + void attachToRange( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xTextRange) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + + const SwFmtFtn* FindFmt() const { return GetDoc() ? pFmtFtn : 0; } + void Invalidate(); + + TYPEINFO(); + + // SwClient + virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + + // XInterface + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( + const ::com::sun::star::uno::Type& rType) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL acquire() throw() { OWeakObject::acquire(); } + virtual void SAL_CALL release() throw() { OWeakObject::release(); } + + // XTypeProvider + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > + SAL_CALL getTypes() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL + getImplementationId() + throw (::com::sun::star::uno::RuntimeException); + + static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId(); + + // XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( + const ::com::sun::star::uno::Sequence< sal_Int8 >& rIdentifier) + throw (::com::sun::star::uno::RuntimeException); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( + const ::rtl::OUString& rServiceName) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL + getSupportedServiceNames() + throw (::com::sun::star::uno::RuntimeException); + + // XComponent + virtual void SAL_CALL dispose() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addEventListener( + const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XEventListener > & xListener) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeEventListener( + const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XEventListener > & xListener) + throw (::com::sun::star::uno::RuntimeException); + + // XPropertySet + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySetInfo > SAL_CALL + getPropertySetInfo() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertyValue( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Any& rValue) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::beans::PropertyVetoException, + ::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( + const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addPropertyChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertyChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removePropertyChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertyChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addVetoableChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XVetoableChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeVetoableChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XVetoableChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + + // XElementAccess + virtual ::com::sun::star::uno::Type SAL_CALL getElementType() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL hasElements() + throw (::com::sun::star::uno::RuntimeException); + + // XEnumerationAccess + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::container::XEnumeration > SAL_CALL + createEnumeration() + throw (::com::sun::star::uno::RuntimeException); + + // XTextContent + virtual void SAL_CALL attach( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xTextRange) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > SAL_CALL getAnchor() + throw (::com::sun::star::uno::RuntimeException); + + // XFootnote + virtual ::rtl::OUString SAL_CALL getLabel() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setLabel(const ::rtl::OUString& rLabel) + throw (::com::sun::star::uno::RuntimeException); + + // XSimpleText + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextCursor > SAL_CALL + createTextCursor() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextCursor > SAL_CALL + createTextCursorByRange( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xTextPosition) + throw (::com::sun::star::uno::RuntimeException); + +}; + +#endif // SW_UNOFOOTNOTE_HXX + diff --git a/sw/inc/unoframe.hxx b/sw/inc/unoframe.hxx index 470303ab92ed..d681e520d028 100644 --- a/sw/inc/unoframe.hxx +++ b/sw/inc/unoframe.hxx @@ -30,26 +30,34 @@ #ifndef _UNOFRAME_HXX #define _UNOFRAME_HXX -#include #include #include +#include #include #include #include #include #include #include - /* -#include - */ +#include #include +#include #include +#include +#include +#include +#include + -class SwDoc; class SfxItemPropertSet; +class SdrObject; +class SwDoc; +class SwFmt; +class SwFlyFrmFmt; + /*-----------------12.02.98 11:21------------------- diff --git a/sw/inc/unoobj.hxx b/sw/inc/unoobj.hxx index fa6600b14107..d43a4a7105e1 100644 --- a/sw/inc/unoobj.hxx +++ b/sw/inc/unoobj.hxx @@ -36,28 +36,14 @@ #include #include #include -#include #include #include #include -#include #include -#include #include -#include -#include -#include -#include -#include -#include -#include #include #include // helper for factories -#include // helper for implementations -#include // helper for implementations -#include // helper for implementations -#include // helper for implementations #include #include #include @@ -68,7 +54,6 @@ #include -class SwFmtFtn; class GetCurTxtFmtColl; @@ -128,124 +113,6 @@ class UnoActionRemoveContext void ClientModify(SwClient* pClient, SfxPoolItem *pOld, SfxPoolItem *pNew); -/* -----------------03.12.98 12:22------------------- - * - * --------------------------------------------------*/ -class OTextCursorHelper; -class SwXTextRange; -class SwXText : public ::com::sun::star::lang::XTypeProvider, - public ::com::sun::star::text::XTextRangeCompare, - public ::com::sun::star::text::XRelativeTextContentInsert, - public ::com::sun::star::text::XRelativeTextContentRemove, - public ::com::sun::star::beans::XPropertySet, - public ::com::sun::star::lang::XUnoTunnel, - public ::com::sun::star::text::XTextAppendAndConvert -{ - SwDoc* pDoc; - BOOL bObjectValid; - CursorType eCrsrType; - const SfxItemPropertySet* m_pPropSet; - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL finishOrAppendParagraph( - bool bFinish, - const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > & CharacterAndParagraphProperties ) - throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); - - virtual void PrepareForAttach( ::com::sun::star::uno::Reference< - ::com::sun::star::text::XTextRange > & xRange, - const SwXTextRange* const pRange, const SwPaM * const pPam); - -public: /*not protected because C++ is retarded*/ - virtual const SwStartNode *GetStartNode() const; - -public: - SwXText(SwDoc* pDc, CursorType eType); - virtual ~SwXText(); - - const SwDoc* GetDoc()const {return pDoc;} - SwDoc* GetDoc() {return pDoc;} - - // wenn ein SwXText attached wird, wird das Doc gesetzt - void SetDoc(SwDoc* pDc) - {DBG_ASSERT(!pDoc || !pDc, "Doc schon gesetzt?"); - pDoc = pDc; - bObjectValid = 0 != pDc; - } - virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw(::com::sun::star::uno::RuntimeException); - - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); - - //XText - virtual void SAL_CALL insertString(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xRange, const rtl::OUString& aString, BOOL bAbsorb) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL insertControlCharacter(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xRange, sal_Int16 nControlCharacter, BOOL bAbsorb) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL insertTextContent(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xRange, const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > & xContent, BOOL bAbsorb) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL removeTextContent(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > & xContent) throw( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException); - - //XTextRange - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > SAL_CALL getText(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getStart(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getEnd(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual rtl::OUString SAL_CALL getString(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL setString(const rtl::OUString& aString) throw( ::com::sun::star::uno::RuntimeException ); - - //XTextRangeCompare - sal_Int16 SAL_CALL compareRegionStarts( const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange >& xR1, const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange >& xR2 ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); - sal_Int16 SAL_CALL compareRegionEnds( const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange >& xR1, const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange >& xR2 ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); - - //XRelativeTextContentInsert - virtual void SAL_CALL insertTextContentBefore(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent>& xNewContent, const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent>& xSuccessor) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL insertTextContentAfter(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent>& xNewContent, const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent>& xPredecessor) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); - - //XRelativeTextContentRemove - virtual void SAL_CALL removeTextContentBefore(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent>& xSuccessor) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removeTextContentAfter(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent>& xPredecessor) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); - - - //XPropertySet - virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - - //XUnoTunnel - static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId(); - virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); - - //XParagraphAppend - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL appendParagraph( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > & CharacterAndParagraphProperties ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL finishParagraph( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > & CharacterAndParagraphProperties ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); - - //XTextPortionAppend - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL appendTextPortion( const ::rtl::OUString& Text, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > & CharacterAndParagraphProperties ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); - - //XTextContentAppend - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL appendTextContent( const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent >& TextContent, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& CharacterAndParagraphProperties ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); - - //XTextConvert - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > SAL_CALL convertToTextFrame( const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange >& Start, const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange >& End, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& FrameProperties ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextTable > SAL_CALL convertToTable( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > > > >& TableRanges, - const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > > >& CellProperties, - const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > >& RowProperties, - const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& TableProperties - ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); - - - // - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > createCursor()throw(::com::sun::star::uno::RuntimeException); - INT16 ComparePositions(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange>& xPos1, const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange>& xPos2) throw (com::sun::star::lang::IllegalArgumentException, com::sun::star::uno::RuntimeException); - BOOL CheckForOwnMember(const SwXTextRange* pRange1, const OTextCursorHelper* pCursor1)throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); - virtual bool CheckForOwnMemberMeta(const SwXTextRange* const pRange, - const SwPaM* const pPam, bool bAbsorb) - throw (::com::sun::star::lang::IllegalArgumentException, - ::com::sun::star::uno::RuntimeException); - // - void Invalidate() {bObjectValid = sal_False;} - BOOL IsValid()const {return bObjectValid;} - - CursorType GetTextType() {return eCrsrType;} -}; /*-----------------20.03.98 07:47------------------- @@ -301,147 +168,6 @@ public: --------------------------------------------------*/ -typedef cppu::WeakAggImplHelper2 -< - ::com::sun::star::container::XEnumerationAccess, - ::com::sun::star::lang::XServiceInfo -> SwXBodyTextBaseClass; -class SwXBodyText : public SwXBodyTextBaseClass, - public SwXText -{ -protected: - virtual ~SwXBodyText(); -public: - SwXBodyText(SwDoc* pDoc); - - - virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL acquire( ) throw(){OWeakObject::acquire();} - virtual void SAL_CALL release( ) throw(){OWeakObject::release();} - - //XAggregation - virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type& aType ) throw(::com::sun::star::uno::RuntimeException); - - //XTypeProvider - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw(::com::sun::star::uno::RuntimeException); - - //XText - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > SAL_CALL createTextCursor(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > SAL_CALL createTextCursorByRange(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & aTextPosition) throw( ::com::sun::star::uno::RuntimeException ); - - //XEnumerationAccess - frueher XParagraphEnumerationAccess - virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createEnumeration(void) throw( ::com::sun::star::uno::RuntimeException ); - - //XElementAccess - virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw(::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL hasElements( ) throw(::com::sun::star::uno::RuntimeException); - - //XServiceInfo - virtual rtl::OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual BOOL SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException ); - - ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > CreateTextCursor(BOOL bIgnoreTables = sal_False); -}; - - -/*-----------------12.02.98 08:01------------------- - ---------------------------------------------------*/ -typedef -cppu::WeakImplHelper5 -< - ::com::sun::star::text::XFootnote, - ::com::sun::star::lang::XServiceInfo, - ::com::sun::star::container::XEnumerationAccess, - ::com::sun::star::beans::XPropertySet, - ::com::sun::star::lang::XUnoTunnel -> -SwXFootnoteBaseClass; -class SwXFootnote : public SwXFootnoteBaseClass, - public SwXText, - public SwClient -{ - friend class SwXFootnotes; - - SwEventListenerContainer aLstnrCntnr; - const SwFmtFtn* pFmtFtn; - BOOL m_bIsDescriptor; - String m_sLabel; - BOOL m_bIsEndnote; - -protected: - virtual const SwStartNode *GetStartNode() const; - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > createCursor()throw(::com::sun::star::uno::RuntimeException); - virtual ~SwXFootnote(); -public: - SwXFootnote(BOOL bEndnote); - SwXFootnote(SwDoc* pDoc, const SwFmtFtn& rFmt); - - - TYPEINFO(); - - static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId(); - - //XUnoTunnel - virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); - - virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL acquire( ) throw(){SwXFootnoteBaseClass::acquire();} - virtual void SAL_CALL release( ) throw(){SwXFootnoteBaseClass::release();} - - //XTypeProvider - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw(::com::sun::star::uno::RuntimeException); - - //XFootnote - virtual rtl::OUString SAL_CALL getLabel(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL setLabel(const rtl::OUString& aLabel) throw( ::com::sun::star::uno::RuntimeException ); - - //XTextContent - virtual void SAL_CALL attach(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xTextRange) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getAnchor( ) throw(::com::sun::star::uno::RuntimeException); - - //XComponent - virtual void SAL_CALL dispose(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw( ::com::sun::star::uno::RuntimeException ); - - //XText - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > SAL_CALL createTextCursor(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > SAL_CALL createTextCursorByRange(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & aTextPosition) throw( ::com::sun::star::uno::RuntimeException ); - - //XEnumerationAccess - frueher XParagraphEnumerationAccess - virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createEnumeration(void) throw( ::com::sun::star::uno::RuntimeException ); - - //XElementAccess - virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw(::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL hasElements( ) throw(::com::sun::star::uno::RuntimeException); - - //XServiceInfo - virtual rtl::OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual BOOL SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException ); - - //XPropertySet - virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - - //SwClient - virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew); - - void attachToRange(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xTextRange)throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); - - const SwFmtFtn* FindFmt() const {return GetDoc() ? pFmtFtn : 0;} - void Invalidate(); -}; - /* -----------------23.03.99 12:57------------------- * * --------------------------------------------------*/ @@ -521,58 +247,6 @@ public: void SetSortOptions(const SwSortOptions& rSortOpt); }; */ -/* -----------------25.08.98 11:02------------------- - * - * --------------------------------------------------*/ -typedef -cppu::WeakImplHelper2 -< - ::com::sun::star::lang::XServiceInfo, - ::com::sun::star::container::XEnumerationAccess -> -SwXHeadFootTextBaseClass; -class SwXHeadFootText : public SwXHeadFootTextBaseClass, - public SwXText, - public SwClient -{ - SwFrmFmt* GetFmt() const { return (SwFrmFmt*)GetRegisteredIn(); } - BOOL bIsHeader; -protected: - virtual const SwStartNode *GetStartNode() const; - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > createCursor()throw(::com::sun::star::uno::RuntimeException); -public: - SwXHeadFootText(SwFrmFmt& rHeadFootFmt, BOOL bHeader); - ~SwXHeadFootText(); - - TYPEINFO(); - - virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL acquire( ) throw(){SwXHeadFootTextBaseClass::acquire();} - virtual void SAL_CALL release( ) throw(){SwXHeadFootTextBaseClass::release();} - - //XTypeProvider - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw(::com::sun::star::uno::RuntimeException); - - //XText - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > SAL_CALL createTextCursor(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > SAL_CALL createTextCursorByRange(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & aTextPosition) throw( ::com::sun::star::uno::RuntimeException ); - - //XServiceInfo - virtual rtl::OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual BOOL SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException ); - - //XEnumerationAccess - frueher XParagraphEnumerationAccess - virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createEnumeration(void) throw( ::com::sun::star::uno::RuntimeException ); - - //XElementAccess - virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw(::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL hasElements( ) throw(::com::sun::star::uno::RuntimeException); - - //SwClient - virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew); -}; #endif diff --git a/sw/inc/unoredline.hxx b/sw/inc/unoredline.hxx index 5730c6e55ff0..b46189734301 100644 --- a/sw/inc/unoredline.hxx +++ b/sw/inc/unoredline.hxx @@ -31,9 +31,11 @@ #define _UNOREDLINE_HXX #include -#include +#include + class SwRedline; + /* -----------------------------19.12.00 11:35-------------------------------- ---------------------------------------------------------------------------*/ diff --git a/sw/inc/unotbl.hxx b/sw/inc/unotbl.hxx index c14dac1bc2d0..d2e14309a5d4 100644 --- a/sw/inc/unotbl.hxx +++ b/sw/inc/unotbl.hxx @@ -30,8 +30,8 @@ #ifndef _UNOTBL_HXX #define _UNOTBL_HXX -#include #include +#include #include #include #include @@ -43,22 +43,27 @@ #include #include +#include #include #include #include #include +#include #include +#include +#include -class SwTableBoxFmt; +class SwUnoCrsr; +class SwTable; +class SwTableBox; class SwTableLine; class SwTableCursor; class SwTableBoxFmt; -class SwTableLine; -class SwTableCursor; class SwChartDataProvider; +class SwFrmFmt; /* -----------------------------22.09.00 11:10-------------------------------- diff --git a/sw/inc/unotext.hxx b/sw/inc/unotext.hxx new file mode 100644 index 000000000000..499e0620dae4 --- /dev/null +++ b/sw/inc/unotext.hxx @@ -0,0 +1,375 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: unoobj.hxx,v $ + * + * $Revision: 1.49 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SW_UNOTEXT_HXX +#define SW_UNOTEXT_HXX + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + + +namespace com { namespace sun { namespace star { + namespace text { + class XTextContent; + } +} } } + +class SfxItemPropertySet; +class SwDoc; +class SwStartNode; +class SwPaM; +class OTextCursorHelper; +class SwXTextRange; + + +/* -----------------03.12.98 12:22------------------- + * + * --------------------------------------------------*/ + +class SwXText + : public ::com::sun::star::lang::XTypeProvider + , public ::com::sun::star::lang::XUnoTunnel + , public ::com::sun::star::beans::XPropertySet + , public ::com::sun::star::text::XTextAppendAndConvert + , public ::com::sun::star::text::XTextRangeCompare + , public ::com::sun::star::text::XRelativeTextContentInsert + , public ::com::sun::star::text::XRelativeTextContentRemove +{ + +private: + + SwDoc* pDoc; + BOOL bObjectValid; + CursorType eCrsrType; + const SfxItemPropertySet* m_pPropSet; + + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > SAL_CALL + finishOrAppendParagraph( + bool bFinish, + const ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue >& + rCharacterAndParagraphProperties) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + + virtual void PrepareForAttach( + ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xRange, + SwXTextRange const * const pRange, SwPaM const * const pPam); + +protected: + + virtual ~SwXText(); + +public: /*not protected because C++ is retarded*/ + virtual const SwStartNode *GetStartNode() const; + +public: + + SwXText(SwDoc* pDc, CursorType eType); + + const SwDoc* GetDoc() const { return pDoc; } + SwDoc* GetDoc() { return pDoc; } + + // SwDoc is set when SwXText is attached + void SetDoc(SwDoc* pDc) { + DBG_ASSERT(!pDoc || !pDc, "Doc schon gesetzt?"); + pDoc = pDc; + bObjectValid = 0 != pDc; + } + + void Invalidate() { bObjectValid = sal_False; } + BOOL IsValid() const { return bObjectValid; } + + CursorType GetTextType() { return eCrsrType; } + + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextCursor > createCursor() + throw (::com::sun::star::uno::RuntimeException); + INT16 ComparePositions( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange>& xPos1, + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange>& xPos2) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + BOOL CheckForOwnMember(const SwXTextRange* pRange1, + const OTextCursorHelper* pCursor1) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + virtual bool CheckForOwnMemberMeta( + const SwXTextRange* const pRange, + const SwPaM* const pPam, bool bAbsorb) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + + // XInterface + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( + const ::com::sun::star::uno::Type& rType) + throw (::com::sun::star::uno::RuntimeException); + + // XTypeProvider + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > + SAL_CALL getTypes() + throw (::com::sun::star::uno::RuntimeException); + + static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId(); + + // XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( + const ::com::sun::star::uno::Sequence< sal_Int8 >& rIdentifier) + throw (::com::sun::star::uno::RuntimeException); + + // XPropertySet + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySetInfo > SAL_CALL + getPropertySetInfo() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertyValue( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Any& rValue) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::beans::PropertyVetoException, + ::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( + const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addPropertyChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertyChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removePropertyChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertyChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addVetoableChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XVetoableChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeVetoableChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XVetoableChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + + // XTextRange + virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > + SAL_CALL getText() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > SAL_CALL getStart() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > SAL_CALL getEnd() + throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getString() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setString(const ::rtl::OUString& rString) + throw (::com::sun::star::uno::RuntimeException); + + // XSimpleText + virtual void SAL_CALL insertString( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xRange, + const ::rtl::OUString& aString, sal_Bool bAbsorb) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL insertControlCharacter( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xRange, + sal_Int16 nControlCharacter, sal_Bool bAbsorb) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + + // XText + virtual void SAL_CALL insertTextContent( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xRange, + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextContent > & xContent, + sal_Bool bAbsorb) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeTextContent( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextContent > & xContent) + throw (::com::sun::star::container::NoSuchElementException, + ::com::sun::star::uno::RuntimeException); + + // XParagraphAppend + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > SAL_CALL + appendParagraph( + const ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue >& + rCharacterAndParagraphProperties) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > SAL_CALL + finishParagraph( + const ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue >& + rCharacterAndParagraphProperties) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + + // XTextPortionAppend + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > SAL_CALL + appendTextPortion( + const ::rtl::OUString& rText, + const ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue >& + rCharacterAndParagraphProperties) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + + // XTextContentAppend + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > SAL_CALL + appendTextContent( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextContent >& xTextContent, + const ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue >& + rCharacterAndParagraphProperties) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + + // XTextConvert + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextContent > SAL_CALL + convertToTextFrame( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange >& xStart, + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange >& xEnd, + const ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue >& xFrameProperties) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextTable > SAL_CALL + convertToTable( + ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > > > > const& + rTableRanges, + ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue > > > const& + rCellProperties, + ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue > > const& + rRowProperties, + ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue > const& + rTableProperties) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + + // XTextRangeCompare + sal_Int16 SAL_CALL compareRegionStarts( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange >& xR1, + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange >& xR2) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + sal_Int16 SAL_CALL compareRegionEnds( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange >& xR1, + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange >& xR2) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + + // XRelativeTextContentInsert + virtual void SAL_CALL insertTextContentBefore( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextContent>& xNewContent, + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextContent>& xSuccessor) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL insertTextContentAfter( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextContent>& xNewContent, + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextContent>& xPredecessor) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + + // XRelativeTextContentRemove + virtual void SAL_CALL removeTextContentBefore( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextContent>& xSuccessor) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeTextContentAfter( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextContent>& xPredecessor) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + +}; + +#endif // SW_UNOTEXT_HXX + diff --git a/sw/inc/unotextbodyhf.hxx b/sw/inc/unotextbodyhf.hxx new file mode 100644 index 000000000000..8e7a64c18669 --- /dev/null +++ b/sw/inc/unotextbodyhf.hxx @@ -0,0 +1,218 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: unoobj.hxx,v $ + * + * $Revision: 1.49 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SW_UNOTEXTBODYHF_HXX +#define SW_UNOTEXTBODYHF_HXX + +#include +#include +#include + +#include + +#include +#include +#include + + +class SwDoc; +class SwFrmFmt; + + +typedef ::cppu::WeakAggImplHelper2 +< ::com::sun::star::lang::XServiceInfo +, ::com::sun::star::container::XEnumerationAccess +> SwXBodyText_Base; + +class SwXBodyText + : public SwXBodyText_Base + , public SwXText +{ + +protected: + + virtual ~SwXBodyText(); + +public: + + SwXBodyText(SwDoc* pDoc); + + ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > + CreateTextCursor(sal_Bool bIgnoreTables = sal_False); + + // XInterface + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( + const ::com::sun::star::uno::Type& rType) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL acquire() throw() { OWeakObject::acquire(); } + virtual void SAL_CALL release() throw() { OWeakObject::release(); } + + // XAggregation + virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( + const ::com::sun::star::uno::Type& rType) + throw (::com::sun::star::uno::RuntimeException); + + // XTypeProvider + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > + SAL_CALL getTypes() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL + getImplementationId() + throw (::com::sun::star::uno::RuntimeException); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( + const ::rtl::OUString& rServiceName) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL + getSupportedServiceNames() + throw (::com::sun::star::uno::RuntimeException); + + // XElementAccess + virtual ::com::sun::star::uno::Type SAL_CALL getElementType() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL hasElements() + throw (::com::sun::star::uno::RuntimeException); + + // XEnumerationAccess + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::container::XEnumeration > SAL_CALL + createEnumeration() + throw (::com::sun::star::uno::RuntimeException); + + // XSimpleText + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextCursor > SAL_CALL + createTextCursor() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextCursor > SAL_CALL + createTextCursorByRange( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xTextPosition) + throw (::com::sun::star::uno::RuntimeException); + +}; + + +/* -----------------25.08.98 11:02------------------- + * + * --------------------------------------------------*/ +typedef ::cppu::WeakImplHelper2 +< ::com::sun::star::lang::XServiceInfo +, ::com::sun::star::container::XEnumerationAccess +> SwXHeadFootText_Base; + +class SwXHeadFootText + : public SwXHeadFootText_Base + , public SwXText + , public SwClient +{ + +private: + + SwFrmFmt* GetFmt() const { return (SwFrmFmt*)GetRegisteredIn(); } + BOOL bIsHeader; + +protected: + + virtual const SwStartNode *GetStartNode() const; + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextCursor > + createCursor() + throw (::com::sun::star::uno::RuntimeException); + + virtual ~SwXHeadFootText(); + +public: + + SwXHeadFootText(SwFrmFmt& rHeadFootFmt, BOOL bHeader); + + TYPEINFO(); + + // SwClient + virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + + // XInterface + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( + const ::com::sun::star::uno::Type& rType) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL acquire() throw() { OWeakObject::acquire(); } + virtual void SAL_CALL release() throw() { OWeakObject::release(); } + + // XTypeProvider + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > + SAL_CALL getTypes() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL + getImplementationId() + throw (::com::sun::star::uno::RuntimeException); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( + const ::rtl::OUString& rServiceName) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL + getSupportedServiceNames() + throw (::com::sun::star::uno::RuntimeException); + + // XElementAccess + virtual ::com::sun::star::uno::Type SAL_CALL getElementType() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL hasElements() + throw (::com::sun::star::uno::RuntimeException); + + // XEnumerationAccess + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::container::XEnumeration > SAL_CALL + createEnumeration() + throw (::com::sun::star::uno::RuntimeException); + + // XSimpleText + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextCursor > SAL_CALL + createTextCursor() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextCursor > SAL_CALL + createTextCursorByRange( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xTextPosition) + throw (::com::sun::star::uno::RuntimeException); + +}; + +#endif // SW_UNOTEXTBODYHF_HXX + diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx index e58059d95ac9..a366f7f898b7 100644 --- a/sw/source/core/doc/doclay.cxx +++ b/sw/source/core/doc/doclay.cxx @@ -1880,7 +1880,8 @@ IMPL_LINK( SwDoc, DoIdleJobs, Timer *, pTimer ) BOOL bIsOnlineSpell = pSh->GetViewOptions()->IsOnlineSpell(); sal_Bool bIsAutoGrammar = sal_False; - SvtLinguConfig().GetProperty( C2U( UPN_IS_GRAMMAR_AUTO ) ) >>= bIsAutoGrammar; + SvtLinguConfig().GetProperty( ::rtl::OUString::createFromAscii( + UPN_IS_GRAMMAR_AUTO ) ) >>= bIsAutoGrammar; if (bIsOnlineSpell && bIsAutoGrammar) StartGrammarChecking( *this ); diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx index bdef8a74bcf7..f5963931f545 100644 --- a/sw/source/core/layout/atrfrm.cxx +++ b/sw/source/core/layout/atrfrm.cxx @@ -99,6 +99,7 @@ #include #include #include +#include #include /// OD 22.08.2002 #99657# /// include definition of class SvxBrushItem and GraphicObject diff --git a/sw/source/core/unocore/unoclbck.cxx b/sw/source/core/unocore/unoclbck.cxx index 01890a1f40a4..9807a8f5b3fb 100644 --- a/sw/source/core/unocore/unoclbck.cxx +++ b/sw/source/core/unocore/unoclbck.cxx @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx index 9cec70fa8a2f..437fec101e53 100644 --- a/sw/source/core/unocore/unocoll.cxx +++ b/sw/source/core/unocore/unocoll.cxx @@ -66,7 +66,9 @@ #include #include #include +#include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unocrsrhelper.cxx b/sw/source/core/unocore/unocrsrhelper.cxx index 5b83f3007904..e152ff2b9d23 100644 --- a/sw/source/core/unocore/unocrsrhelper.cxx +++ b/sw/source/core/unocore/unocrsrhelper.cxx @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx index b3c5eebc11a8..2bfaadaa4f1e 100644 --- a/sw/source/core/unocore/unodraw.cxx +++ b/sw/source/core/unocore/unodraw.cxx @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -44,6 +45,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unoftn.cxx b/sw/source/core/unocore/unoftn.cxx index 23ec936a4244..a4d83d8f51d5 100644 --- a/sw/source/core/unocore/unoftn.cxx +++ b/sw/source/core/unocore/unoftn.cxx @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -147,7 +148,7 @@ SwXFootnote::~SwXFootnote() ---------------------------------------------------------------------------*/ uno::Sequence< uno::Type > SAL_CALL SwXFootnote::getTypes( ) throw(uno::RuntimeException) { - uno::Sequence< uno::Type > aFtnTypes = SwXFootnoteBaseClass::getTypes(); + uno::Sequence< uno::Type > aFtnTypes = SwXFootnote_Base::getTypes(); uno::Sequence< uno::Type > aTextTypes = SwXText::getTypes(); long nIndex = aFtnTypes.getLength(); @@ -179,12 +180,13 @@ uno::Sequence< sal_Int8 > SAL_CALL SwXFootnote::getImplementationId( ) throw(un /* -----------------------------21.03.00 15:46-------------------------------- ---------------------------------------------------------------------------*/ -uno::Any SAL_CALL SwXFootnote::queryInterface( const uno::Type& aType ) throw(uno::RuntimeException) +uno::Any SAL_CALL SwXFootnote::queryInterface(const uno::Type& rType) +throw (uno::RuntimeException) { - uno::Any aRet = SwXFootnoteBaseClass::queryInterface(aType); - if(aRet.getValueType() == ::getCppuVoidType() ) - aRet = SwXText::queryInterface(aType); - return aRet; + const uno::Any ret = SwXFootnote_Base::queryInterface(rType); + return (ret.getValueType() == ::getCppuVoidType()) + ? SwXText::queryInterface(rType) + : ret; } /*-- 10.12.98 15:31:47--------------------------------------------------- diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index 299d9904d4f4..aa6a35526866 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -78,6 +78,8 @@ #include #include #include +#include +#include #include #include #include diff --git a/sw/source/core/unocore/unoparagraph.cxx b/sw/source/core/unocore/unoparagraph.cxx index 99e67d06a00a..8a47c71ebd75 100644 --- a/sw/source/core/unocore/unoparagraph.cxx +++ b/sw/source/core/unocore/unoparagraph.cxx @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unoredlines.cxx b/sw/source/core/unocore/unoredlines.cxx index efaaa32c9e3d..a88b3ff4672c 100644 --- a/sw/source/core/unocore/unoredlines.cxx +++ b/sw/source/core/unocore/unoredlines.cxx @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include "poolfmt.hxx" diff --git a/sw/source/core/unocore/unorefmk.cxx b/sw/source/core/unocore/unorefmk.cxx index ce501056affc..61c3056a7bef 100644 --- a/sw/source/core/unocore/unorefmk.cxx +++ b/sw/source/core/unocore/unorefmk.cxx @@ -440,6 +440,7 @@ void SwXReferenceMark::removeVetoableChangeListener( #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index 722235e3c391..cbf75f593146 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -31,7 +31,6 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - #include #include #include @@ -62,6 +61,7 @@ #include #include #include +#include #include #include #include @@ -74,16 +74,9 @@ #include #include #include -/* -#include -*/ #include -#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPPP_ #include -#endif -#ifndef _COM_SUN_STAR_BEANS_NAMEDVALUE_HPPP_ #include -#endif #include #include #include diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index be23a873ad28..63e27c7abc8d 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -40,6 +40,8 @@ #include #include #include +#include +#include #include #include #include @@ -2272,7 +2274,7 @@ uno::Any SwXBodyText::queryAggregation( -----------------------------------------------------------------------*/ uno::Sequence< uno::Type > SwXBodyText::getTypes( ) throw(uno::RuntimeException) { - uno::Sequence< uno::Type > aTypes = SwXBodyTextBaseClass::getTypes(); + uno::Sequence< uno::Type > aTypes = SwXBodyText_Base::getTypes(); uno::Sequence< uno::Type > aTextTypes = SwXText::getTypes(); long nIndex = aTypes.getLength(); aTypes.realloc(aTypes.getLength() + aTextTypes.getLength()); @@ -2301,13 +2303,13 @@ uno::Sequence< sal_Int8 > SwXBodyText::getImplementationId( ) throw(uno::Runtim -----------------------------------------------------------------------*/ uno::Any SAL_CALL - SwXBodyText::queryInterface( const uno::Type& rType ) - throw(uno::RuntimeException) +SwXBodyText::queryInterface(const uno::Type& rType) +throw (uno::RuntimeException) { - uno::Any aRet = SwXText::queryInterface( rType ); - if(aRet.getValueType() == ::getCppuVoidType()) - aRet = SwXBodyTextBaseClass::queryInterface( rType ); - return aRet; + const uno::Any ret = SwXText::queryInterface(rType); + return (ret.getValueType() == ::getCppuVoidType()) + ? SwXBodyText_Base::queryInterface(rType) + : ret; } /* -----------------------------05.01.00 11:07-------------------------------- @@ -2504,7 +2506,7 @@ uno::Reference< text::XTextCursor > SwXHeadFootText::createCursor() throw(uno: ---------------------------------------------------------------------------*/ uno::Sequence< uno::Type > SwXHeadFootText::getTypes( ) throw(uno::RuntimeException) { - uno::Sequence< uno::Type > aHFTypes = SwXHeadFootTextBaseClass::getTypes(); + uno::Sequence< uno::Type > aHFTypes = SwXHeadFootText_Base::getTypes(); uno::Sequence< uno::Type > aTextTypes = SwXText::getTypes(); long nIndex = aHFTypes.getLength(); @@ -2538,12 +2540,13 @@ uno::Sequence< sal_Int8 > SwXHeadFootText::getImplementationId( ) throw(uno::Ru /* -----------------------------21.03.00 15:46-------------------------------- ---------------------------------------------------------------------------*/ -uno::Any SwXHeadFootText::queryInterface( const uno::Type& aType ) throw(uno::RuntimeException) +uno::Any SwXHeadFootText::queryInterface(const uno::Type& rType) +throw (uno::RuntimeException) { - uno::Any aRet = SwXHeadFootTextBaseClass::queryInterface(aType); - if(aRet.getValueType() == ::getCppuVoidType() ) - aRet = SwXText::queryInterface(aType); - return aRet; + const uno::Any ret = SwXHeadFootText_Base::queryInterface(rType); + return (ret.getValueType() == ::getCppuVoidType()) + ? SwXText::queryInterface(rType) + : ret; } /*-- 11.12.98 10:14:50--------------------------------------------------- diff --git a/sw/source/filter/xml/xmlexp.cxx b/sw/source/filter/xml/xmlexp.cxx index cd3c5d1734d4..74196dfbd9ce 100644 --- a/sw/source/filter/xml/xmlexp.cxx +++ b/sw/source/filter/xml/xmlexp.cxx @@ -31,7 +31,6 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - #include #include #include @@ -41,7 +40,6 @@ #include #include #include -#include #include #include #include @@ -59,6 +57,7 @@ #include #include #include +#include #include #include #include @@ -76,6 +75,7 @@ #include // <-- + using ::rtl::OUString; using namespace ::com::sun::star; using namespace ::com::sun::star::frame; diff --git a/sw/source/filter/xml/xmlfonte.cxx b/sw/source/filter/xml/xmlfonte.cxx index 1edeb1fc846a..d3d8772e43da 100644 --- a/sw/source/filter/xml/xmlfonte.cxx +++ b/sw/source/filter/xml/xmlfonte.cxx @@ -31,15 +31,16 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - #include "hintids.hxx" #include #include #include -#include +//#include +#include #include #include + using namespace ::com::sun::star::uno; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::text; diff --git a/sw/source/filter/xml/xmlimp.cxx b/sw/source/filter/xml/xmlimp.cxx index 476f8871e7a5..cf96a699dd7f 100644 --- a/sw/source/filter/xml/xmlimp.cxx +++ b/sw/source/filter/xml/xmlimp.cxx @@ -48,6 +48,7 @@ #include #include #include +#include #include #include "unocrsr.hxx" #include diff --git a/sw/source/filter/xml/xmltexte.cxx b/sw/source/filter/xml/xmltexte.cxx index 018ca0c0b5bb..6ef61df5a0bc 100644 --- a/sw/source/filter/xml/xmltexte.cxx +++ b/sw/source/filter/xml/xmltexte.cxx @@ -31,7 +31,6 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - #include #include #include @@ -44,13 +43,12 @@ #include #include #include -#ifndef _XMLOFF_TXTPRMAP_HXX #include -#endif #include #include #include +#include #include #include #include @@ -65,6 +63,7 @@ #include #include + using ::rtl::OUString; using ::rtl::OUStringBuffer; using namespace ::com::sun::star; diff --git a/sw/source/ui/uno/unoatxt.cxx b/sw/source/ui/uno/unoatxt.cxx index 5543277cc585..7ed98a979a6a 100644 --- a/sw/source/ui/uno/unoatxt.cxx +++ b/sw/source/ui/uno/unoatxt.cxx @@ -50,6 +50,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index 8d29db3dd30d..3afeb1ee0c39 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -50,6 +50,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/ui/uno/unotxvw.cxx b/sw/source/ui/uno/unotxvw.cxx index 9da88953d481..9de9e882b869 100644 --- a/sw/source/ui/uno/unotxvw.cxx +++ b/sw/source/ui/uno/unotxvw.cxx @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include -- cgit From 80c54710e69437a743c9a0213c4e76eed6286945 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Tue, 5 Jan 2010 16:37:47 +0100 Subject: swunolocking1: #i105557#: unoobj.hxx: split out unoparaframeenum.hxx: move SwXParaFrameEnumeration from unoobj.hxx to new unoparaframeenum.hxx. move FrameDependSortList_t, CollectFrameAtNode to unoparaframeenum.hxx. --- sw/inc/unoobj.hxx | 68 ---------------- sw/inc/unoparaframeenum.hxx | 138 ++++++++++++++++++++++++++++++++ sw/source/core/unocore/unoobj2.cxx | 2 +- sw/source/core/unocore/unoparagraph.cxx | 2 +- sw/source/core/unocore/unoport.cxx | 1 + sw/source/core/unocore/unoportenum.cxx | 1 + 6 files changed, 142 insertions(+), 70 deletions(-) create mode 100644 sw/inc/unoparaframeenum.hxx (limited to 'sw') diff --git a/sw/inc/unoobj.hxx b/sw/inc/unoobj.hxx index d43a4a7105e1..ae9eaa205a3b 100644 --- a/sw/inc/unoobj.hxx +++ b/sw/inc/unoobj.hxx @@ -50,27 +50,10 @@ #include -#include -#include - class GetCurTxtFmtColl; -struct FrameDependSortListEntry { - xub_StrLen nIndex; - sal_uInt32 nOrder; - ::boost::shared_ptr pFrameDepend; - FrameDependSortListEntry (xub_StrLen const i_nIndex, - sal_uInt32 const i_nOrder, SwDepend * const i_pDepend) - : nIndex(i_nIndex), nOrder(i_nOrder), pFrameDepend(i_pDepend) { } -}; -typedef ::std::deque< FrameDependSortListEntry > - FrameDependSortList_t; - -typedef ::std::deque< ::boost::shared_ptr > - FrameDependList_t; - /* -----------------26.06.98 16:18------------------- * @@ -79,10 +62,6 @@ typedef ::std::deque< ::boost::shared_ptr > SwPageDesc* GetPageDescByName_Impl(SwDoc& rDoc, const String& rName); ::com::sun::star::uno::Sequence< sal_Int8 > CreateUnoTunnelId(); -// OD 2004-05-07 #i28701# - adjust 4th parameter -void CollectFrameAtNode( SwClient& rClnt, const SwNodeIndex& rIdx, - FrameDependSortList_t & rFrames, - const bool _bAtCharAnchoredObjs ); /*-----------------04.03.98 11:54------------------- Start/EndAction oder Start/EndAllAction @@ -168,53 +147,6 @@ public: --------------------------------------------------*/ -/* -----------------23.03.99 12:57------------------- - * - * --------------------------------------------------*/ -#define PARAFRAME_PORTION_PARAGRAPH 0 -#define PARAFRAME_PORTION_CHAR 1 -#define PARAFRAME_PORTION_TEXTRANGE 2 - -class SwXParaFrameEnumeration : public cppu::WeakImplHelper2 -< - ::com::sun::star::container::XEnumeration, - ::com::sun::star::lang::XServiceInfo ->, - public SwClient -{ - ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > - m_xNextObject; // created by hasMoreElements - FrameDependList_t m_Frames; - - SwUnoCrsr* GetCursor() const - {return static_cast(const_cast(GetRegisteredIn()));} - -public: - SwXParaFrameEnumeration(const SwPaM& rPaM, - sal_uInt8 nParaFrameMode, SwFrmFmt* pFmt = 0); - ~SwXParaFrameEnumeration(); - - // XEnumeration - virtual sal_Bool SAL_CALL hasMoreElements() - throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Any SAL_CALL nextElement() - throw( ::com::sun::star::container::NoSuchElementException, - ::com::sun::star::lang::WrappedTargetException, - ::com::sun::star::uno::RuntimeException ); - - // XServiceInfo - virtual rtl::OUString SAL_CALL getImplementationName() - throw( ::com::sun::star::uno::RuntimeException ); - virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName) - throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL - getSupportedServiceNames() - throw( ::com::sun::star::uno::RuntimeException ); - - //SwClient - virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew); -}; - /* -----------------29.09.98 09:01------------------- * diff --git a/sw/inc/unoparaframeenum.hxx b/sw/inc/unoparaframeenum.hxx new file mode 100644 index 000000000000..d05fccfed46d --- /dev/null +++ b/sw/inc/unoparaframeenum.hxx @@ -0,0 +1,138 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: unoobj.hxx,v $ + * + * $Revision: 1.49 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SW_UNOPARAFRAMEENUM_HXX +#define SW_UNOPARAFRAMEENUM_HXX + +#include + +#include + +#include +#include +#include + +#include + +#include +#include + + +class SwNodeIndex; +class SwPaM; +class SwUnoCrsr; +class SwFrmFmt; + + +struct FrameDependSortListEntry +{ + xub_StrLen nIndex; + sal_uInt32 nOrder; + ::boost::shared_ptr pFrameDepend; + + FrameDependSortListEntry (xub_StrLen const i_nIndex, + sal_uInt32 const i_nOrder, SwDepend * const i_pDepend) + : nIndex(i_nIndex), nOrder(i_nOrder), pFrameDepend(i_pDepend) { } +}; + +typedef ::std::deque< FrameDependSortListEntry > + FrameDependSortList_t; + +typedef ::std::deque< ::boost::shared_ptr > + FrameDependList_t; + + +// OD 2004-05-07 #i28701# - adjust 4th parameter +void CollectFrameAtNode( SwClient& rClnt, const SwNodeIndex& rIdx, + FrameDependSortList_t & rFrames, + const bool _bAtCharAnchoredObjs ); + + +/* -----------------23.03.99 12:57------------------- + * + * --------------------------------------------------*/ + +#define PARAFRAME_PORTION_PARAGRAPH 0 +#define PARAFRAME_PORTION_CHAR 1 +#define PARAFRAME_PORTION_TEXTRANGE 2 + + +typedef ::cppu::WeakImplHelper2 +< ::com::sun::star::lang::XServiceInfo +, ::com::sun::star::container::XEnumeration +> SwXParaFrameEnumeration_Base; + +class SwXParaFrameEnumeration + : public SwXParaFrameEnumeration_Base + , public SwClient +{ + +private: + + ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > + m_xNextObject; // created by hasMoreElements + FrameDependList_t m_Frames; + + SwUnoCrsr* GetCursor() const + {return static_cast(const_cast(GetRegisteredIn()));} + + virtual ~SwXParaFrameEnumeration(); + +public: + + SwXParaFrameEnumeration(const SwPaM& rPaM, + sal_uInt8 nParaFrameMode, SwFrmFmt* pFmt = 0); + + // SwClient + virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( + const ::rtl::OUString& rServiceName) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL + getSupportedServiceNames() + throw (::com::sun::star::uno::RuntimeException); + + // XEnumeration + virtual sal_Bool SAL_CALL hasMoreElements() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL nextElement() + throw (::com::sun::star::container::NoSuchElementException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + +}; + +#endif // SW_UNOPARAFRAMEENUM_HXX + diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index aa6a35526866..506cc5d81cdf 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -31,7 +31,6 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - #include #include #include @@ -78,6 +77,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unoparagraph.cxx b/sw/source/core/unocore/unoparagraph.cxx index 8a47c71ebd75..dd809240151e 100644 --- a/sw/source/core/unocore/unoparagraph.cxx +++ b/sw/source/core/unocore/unoparagraph.cxx @@ -31,10 +31,10 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unoport.cxx b/sw/source/core/unocore/unoport.cxx index f7b2e40fa440..eba2f9e923d3 100644 --- a/sw/source/core/unocore/unoport.cxx +++ b/sw/source/core/unocore/unoport.cxx @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unoportenum.cxx b/sw/source/core/unocore/unoportenum.cxx index f9379cbd476f..214336dce955 100644 --- a/sw/source/core/unocore/unoportenum.cxx +++ b/sw/source/core/unocore/unoportenum.cxx @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include -- cgit From 7e156d00e9e09e3329856c685a9c6c0138db1253 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Tue, 5 Jan 2010 16:37:49 +0100 Subject: swunolocking1: #i105557#: unoobj.hxx: move misc stuff: move GetPageDescByName_Impl from unoobj.hxx to pagedesc.hxx. move UnoActionContext, UnoActionRemoveContext, ClientModify, CreateUnoTunnelId from unoobj.hxx to unobaseclass.hxx. move UnoActionContext, UnoActionRemoveContext from unoobj.cxx to unoobj2.cxx. --- sw/inc/pagedesc.hxx | 3 ++ sw/inc/unobaseclass.hxx | 52 +++++++++++++++++++--- sw/inc/unoobj.hxx | 26 ----------- sw/inc/unoparagraph.hxx | 2 +- sw/inc/unoredlines.hxx | 5 ++- sw/inc/unotbl.hxx | 1 + sw/source/core/unocore/TextCursorHelper.cxx | 4 +- sw/source/core/unocore/unobkm.cxx | 1 - sw/source/core/unocore/unochart.cxx | 3 +- sw/source/core/unocore/unocoll.cxx | 3 +- sw/source/core/unocore/unocrsrhelper.cxx | 1 - sw/source/core/unocore/unodraw.cxx | 4 +- sw/source/core/unocore/unofield.cxx | 1 - sw/source/core/unocore/unoflatpara.cxx | 2 +- sw/source/core/unocore/unoframe.cxx | 3 +- sw/source/core/unocore/unoftn.cxx | 3 +- sw/source/core/unocore/unoidx.cxx | 2 +- sw/source/core/unocore/unoobj.cxx | 45 ------------------- sw/source/core/unocore/unoobj2.cxx | 57 ++++++++++++++++++++++++- sw/source/core/unocore/unoparagraph.cxx | 1 - sw/source/core/unocore/unoport.cxx | 3 +- sw/source/core/unocore/unoportenum.cxx | 3 +- sw/source/core/unocore/unoredline.cxx | 9 ++-- sw/source/core/unocore/unoredlines.cxx | 8 ++-- sw/source/core/unocore/unorefmk.cxx | 3 +- sw/source/core/unocore/unosect.cxx | 4 +- sw/source/core/unocore/unosett.cxx | 5 --- sw/source/core/unocore/unosrch.cxx | 7 +-- sw/source/core/unocore/unostyle.cxx | 1 - sw/source/core/unocore/unotbl.cxx | 1 - sw/source/core/unocore/unotext.cxx | 8 ++-- sw/source/filter/html/htmlforw.cxx | 2 +- sw/source/filter/ww8/ww8atr.cxx | 4 +- sw/source/filter/xml/XMLRedlineImportHelper.cxx | 1 - sw/source/filter/xml/xmlexp.cxx | 1 - sw/source/filter/xml/xmlfmt.cxx | 10 +---- sw/source/filter/xml/xmlfonte.cxx | 1 - sw/source/filter/xml/xmlimp.cxx | 2 +- sw/source/filter/xml/xmlmeta.cxx | 1 - sw/source/filter/xml/xmltble.cxx | 1 - sw/source/filter/xml/xmltexti.cxx | 2 +- sw/source/ui/app/docsh2.cxx | 35 ++------------- sw/source/ui/envelp/labelexp.cxx | 2 +- sw/source/ui/misc/glossary.cxx | 22 +--------- sw/source/ui/shells/drwtxtsh.cxx | 6 +-- sw/source/ui/shells/tabsh.cxx | 6 +-- sw/source/ui/table/chartins.cxx | 7 --- sw/source/ui/uno/SwXDocumentSettings.cxx | 6 +-- sw/source/ui/uno/unoatxt.cxx | 2 +- sw/source/ui/uno/unodispatch.cxx | 7 +-- sw/source/ui/uno/unomod.cxx | 2 +- sw/source/ui/uno/unotxdoc.cxx | 2 +- sw/source/ui/uno/unotxvw.cxx | 1 - sw/source/ui/utlui/swrenamexnameddlg.cxx | 1 - 54 files changed, 170 insertions(+), 225 deletions(-) (limited to 'sw') diff --git a/sw/inc/pagedesc.hxx b/sw/inc/pagedesc.hxx index 40d8874f912d..8815945c8bc4 100644 --- a/sw/inc/pagedesc.hxx +++ b/sw/inc/pagedesc.hxx @@ -344,4 +344,7 @@ public: operator SwPageDesc() const; // #i7983# }; + +SwPageDesc* GetPageDescByName_Impl(SwDoc& rDoc, const String& rName); + #endif //_PAGEDESC_HXX diff --git a/sw/inc/unobaseclass.hxx b/sw/inc/unobaseclass.hxx index adb7b880356a..75443b2c7584 100644 --- a/sw/inc/unobaseclass.hxx +++ b/sw/inc/unobaseclass.hxx @@ -30,18 +30,22 @@ #ifndef _UNOBASECLASS_HXX #define _UNOBASECLASS_HXX -#include #include #include + #include -typedef -cppu::WeakImplHelper2 -< - ::com::sun::star::container::XEnumeration, - ::com::sun::star::lang::XServiceInfo + +class SfxPoolItem; +class SwClient; +class SwDoc; + + +typedef ::cppu::WeakImplHelper2 +< ::com::sun::star::lang::XServiceInfo +, ::com::sun::star::container::XEnumeration > -SwSimpleEnumerationBaseClass; +SwSimpleEnumeration_Base; /* -----------------29.04.98 07:35------------------- @@ -64,5 +68,39 @@ enum CursorType CURSOR_META, // meta/meta-field }; +/*-----------------04.03.98 11:54------------------- + Start/EndAction or Start/EndAllAction + -------------------------------------------------- */ +class UnoActionContext +{ + private: + SwDoc * m_pDoc; + + public: + UnoActionContext(SwDoc *const pDoc); + ~UnoActionContext(); + + void InvalidateDocument() { m_pDoc = 0; } +}; + +/* -----------------07.07.98 12:03------------------- + interrupt Actions for a little while + -------------------------------------------------- */ +class UnoActionRemoveContext +{ + private: + SwDoc *const m_pDoc; + + public: + UnoActionRemoveContext(SwDoc *const pDoc); + ~UnoActionRemoveContext(); +}; + + +::com::sun::star::uno::Sequence< sal_Int8 > CreateUnoTunnelId(); + +/// helper function for implementing SwClient::Modify +void ClientModify(SwClient* pClient, SfxPoolItem *pOld, SfxPoolItem *pNew); + #endif diff --git a/sw/inc/unoobj.hxx b/sw/inc/unoobj.hxx index ae9eaa205a3b..6ab11b13e9ec 100644 --- a/sw/inc/unoobj.hxx +++ b/sw/inc/unoobj.hxx @@ -59,38 +59,12 @@ class GetCurTxtFmtColl; * * --------------------------------------------------*/ -SwPageDesc* GetPageDescByName_Impl(SwDoc& rDoc, const String& rName); -::com::sun::star::uno::Sequence< sal_Int8 > CreateUnoTunnelId(); -/*-----------------04.03.98 11:54------------------- - Start/EndAction oder Start/EndAllAction ---------------------------------------------------*/ -class UnoActionContext -{ - SwDoc* pDoc; - public: - UnoActionContext(SwDoc* pDoc); - ~UnoActionContext(); - - void InvalidateDocument() {pDoc = 0;} -}; -/* -----------------07.07.98 12:03------------------- - * Actions kurzfristig unterbrechen - * --------------------------------------------------*/ -class UnoActionRemoveContext -{ - SwDoc* pDoc; - public: - UnoActionRemoveContext(SwDoc* pDoc); - ~UnoActionRemoveContext(); -}; - /****************************************************************************** * ******************************************************************************/ -void ClientModify(SwClient* pClient, SfxPoolItem *pOld, SfxPoolItem *pNew); /*-----------------20.03.98 07:47------------------- diff --git a/sw/inc/unoparagraph.hxx b/sw/inc/unoparagraph.hxx index 6ef62e00c1a9..984786b0d1fb 100644 --- a/sw/inc/unoparagraph.hxx +++ b/sw/inc/unoparagraph.hxx @@ -359,7 +359,7 @@ public: --------------------------------------------------*/ class SwXParagraphEnumeration - : public SwSimpleEnumerationBaseClass + : public SwSimpleEnumeration_Base , public SwClient { diff --git a/sw/inc/unoredlines.hxx b/sw/inc/unoredlines.hxx index 52f2ab16a368..ba08afc1f8bf 100644 --- a/sw/inc/unoredlines.hxx +++ b/sw/inc/unoredlines.hxx @@ -78,8 +78,9 @@ public: /* -----------------------------12.01.01 14:58-------------------------------- ---------------------------------------------------------------------------*/ -class SwXRedlineEnumeration : public SwSimpleEnumerationBaseClass, - public SwClient +class SwXRedlineEnumeration + : public SwSimpleEnumeration_Base + , public SwClient { SwDoc* pDoc; USHORT nCurrentIndex; diff --git a/sw/inc/unotbl.hxx b/sw/inc/unotbl.hxx index d2e14309a5d4..a539c7384a39 100644 --- a/sw/inc/unotbl.hxx +++ b/sw/inc/unotbl.hxx @@ -51,6 +51,7 @@ #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/TextCursorHelper.cxx b/sw/source/core/unocore/TextCursorHelper.cxx index ec64dd0d7593..8eb1019183ad 100644 --- a/sw/source/core/unocore/TextCursorHelper.cxx +++ b/sw/source/core/unocore/TextCursorHelper.cxx @@ -30,8 +30,10 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" + #include "TextCursorHelper.hxx" -#include "unoobj.hxx" +#include "unobaseclass.hxx" + using namespace ::com::sun::star; /* -----------------------------03.03.03 11:07-------------------------------- diff --git a/sw/source/core/unocore/unobkm.cxx b/sw/source/core/unocore/unobkm.cxx index 171bead57a09..282ae6b389a8 100644 --- a/sw/source/core/unocore/unobkm.cxx +++ b/sw/source/core/unocore/unobkm.cxx @@ -35,7 +35,6 @@ #include #include #include -#include #include #include #include diff --git a/sw/source/core/unocore/unochart.cxx b/sw/source/core/unocore/unochart.cxx index 8103b924ae98..f3a2fe55499d 100644 --- a/sw/source/core/unocore/unochart.cxx +++ b/sw/source/core/unocore/unochart.cxx @@ -34,7 +34,6 @@ #include #include - #include #include #include @@ -51,7 +50,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx index 437fec101e53..557e73c17ac4 100644 --- a/sw/source/core/unocore/unocoll.cxx +++ b/sw/source/core/unocore/unocoll.cxx @@ -874,7 +874,8 @@ namespace } template - class SwXFrameEnumeration : public SwSimpleEnumerationBaseClass + class SwXFrameEnumeration + : public SwSimpleEnumeration_Base { private: typedef ::std::slist< Any > frmcontainer_t; diff --git a/sw/source/core/unocore/unocrsrhelper.cxx b/sw/source/core/unocore/unocrsrhelper.cxx index e152ff2b9d23..1138f5ee273e 100644 --- a/sw/source/core/unocore/unocrsrhelper.cxx +++ b/sw/source/core/unocore/unocrsrhelper.cxx @@ -36,7 +36,6 @@ #include #include -#include #include #include #include diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx index 2bfaadaa4f1e..b967f59f4899 100644 --- a/sw/source/core/unocore/unodraw.cxx +++ b/sw/source/core/unocore/unodraw.cxx @@ -37,7 +37,6 @@ #include #include #include -#include #include #include #include @@ -443,7 +442,8 @@ uno::Reference< drawing::XShape > SwFmDrawPage::_CreateShape( SdrObject *pObj ) ****************************************************************************/ namespace { - class SwXShapesEnumeration : public SwSimpleEnumerationBaseClass + class SwXShapesEnumeration + : public SwSimpleEnumeration_Base { private: typedef ::std::slist< ::com::sun::star::uno::Any > shapescontainer_t; diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx index eca06ed0d741..59954b6a954e 100644 --- a/sw/source/core/unocore/unofield.cxx +++ b/sw/source/core/unocore/unofield.cxx @@ -41,7 +41,6 @@ #include #include #include -#include #include #include #include diff --git a/sw/source/core/unocore/unoflatpara.cxx b/sw/source/core/unocore/unoflatpara.cxx index 66796031c4ba..42f2934c5b01 100644 --- a/sw/source/core/unocore/unoflatpara.cxx +++ b/sw/source/core/unocore/unoflatpara.cxx @@ -46,7 +46,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx index 14ac1007d3ae..9d3fab300c03 100644 --- a/sw/source/core/unocore/unoframe.cxx +++ b/sw/source/core/unocore/unoframe.cxx @@ -30,6 +30,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" + #include #include #include @@ -60,7 +61,6 @@ #include #include #include -#include #include #include #include @@ -100,6 +100,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unoftn.cxx b/sw/source/core/unocore/unoftn.cxx index a4d83d8f51d5..5ef6c3d3c5bc 100644 --- a/sw/source/core/unocore/unoftn.cxx +++ b/sw/source/core/unocore/unoftn.cxx @@ -34,7 +34,8 @@ #include #include #include -#include + +#include #include #include #include diff --git a/sw/source/core/unocore/unoidx.cxx b/sw/source/core/unocore/unoidx.cxx index e8bba7ac7357..92309d6368cf 100644 --- a/sw/source/core/unocore/unoidx.cxx +++ b/sw/source/core/unocore/unoidx.cxx @@ -55,8 +55,8 @@ #include #endif #include +#include #include -#include #include #include #include diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx index 13a102164cad..eb89201cf978 100644 --- a/sw/source/core/unocore/unoobj.cxx +++ b/sw/source/core/unocore/unoobj.cxx @@ -82,7 +82,6 @@ #include #include #include -#include #include #include #include @@ -187,50 +186,6 @@ SwUnoInternalPaM& SwUnoInternalPaM::operator=(const SwPaM& rPaM) } return *this; } -/**************************************************************************** - ActionContext -****************************************************************************/ -UnoActionContext::UnoActionContext(SwDoc* pDc) : - pDoc(pDc) -{ - SwRootFrm* pRootFrm = pDoc->GetRootFrm(); - if(pRootFrm) - pRootFrm->StartAllAction(); -} -/*-----------------04.03.98 11:56------------------- - ---------------------------------------------------*/ -UnoActionContext::~UnoActionContext() -{ - //das Doc kann hier schon entfernt worden sein - if(pDoc) - { - SwRootFrm* pRootFrm = pDoc->GetRootFrm(); - if(pRootFrm) - pRootFrm->EndAllAction(); - } -} - -/**************************************************************************** - ActionRemoveContext -****************************************************************************/ -UnoActionRemoveContext::UnoActionRemoveContext(SwDoc* pDc) : - pDoc(pDc) -{ - SwRootFrm* pRootFrm = pDoc->GetRootFrm(); - if(pRootFrm) - pRootFrm->UnoRemoveAllActions(); -} -/* -----------------07.07.98 12:05------------------- - * - * --------------------------------------------------*/ -UnoActionRemoveContext::~UnoActionRemoveContext() -{ - SwRootFrm* pRootFrm = pDoc->GetRootFrm(); - if(pRootFrm) - pRootFrm->UnoRestoreAllActions(); - -} /*-----------------09.03.98 08:29------------------- diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index 506cc5d81cdf..6d2a0d49f9d5 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -76,7 +76,6 @@ #include #include #include -#include #include #include #include @@ -100,6 +99,7 @@ #include #include #include +#include #include #include #include @@ -227,6 +227,60 @@ void CollectFrameAtNode( SwClient& rClnt, const SwNodeIndex& rIdx, } } +/**************************************************************************** + ActionContext +****************************************************************************/ +UnoActionContext::UnoActionContext(SwDoc *const pDoc) + : m_pDoc(pDoc) +{ + SwRootFrm *const pRootFrm = m_pDoc->GetRootFrm(); + if (pRootFrm) + { + pRootFrm->StartAllAction(); + } +} + +/*-----------------04.03.98 11:56------------------- + +--------------------------------------------------*/ +UnoActionContext::~UnoActionContext() +{ + // Doc may already have been removed here + if (m_pDoc) + { + SwRootFrm *const pRootFrm = m_pDoc->GetRootFrm(); + if (pRootFrm) + { + pRootFrm->EndAllAction(); + } + } +} + +/**************************************************************************** + ActionRemoveContext +****************************************************************************/ +UnoActionRemoveContext::UnoActionRemoveContext(SwDoc *const pDoc) + : m_pDoc(pDoc) +{ + SwRootFrm *const pRootFrm = m_pDoc->GetRootFrm(); + if (pRootFrm) + { + pRootFrm->UnoRemoveAllActions(); + } +} + +/* -----------------07.07.98 12:05------------------- + * + * --------------------------------------------------*/ +UnoActionRemoveContext::~UnoActionRemoveContext() +{ + SwRootFrm *const pRootFrm = m_pDoc->GetRootFrm(); + if (pRootFrm) + { + pRootFrm->UnoRestoreAllActions(); + } +} + /*-- 09.12.98 14:18:58--------------------------------------------------- @@ -752,6 +806,7 @@ SwDoc* SwXTextCursor::GetDoc() return GetCrsr() ? GetCrsr()->GetDoc() : 0; } + /*-- 09.12.98 14:19:03--------------------------------------------------- -----------------------------------------------------------------------*/ diff --git a/sw/source/core/unocore/unoparagraph.cxx b/sw/source/core/unocore/unoparagraph.cxx index dd809240151e..22611e0b8e5b 100644 --- a/sw/source/core/unocore/unoparagraph.cxx +++ b/sw/source/core/unocore/unoparagraph.cxx @@ -33,7 +33,6 @@ #include #include -#include #include #include #include diff --git a/sw/source/core/unocore/unoport.cxx b/sw/source/core/unocore/unoport.cxx index eba2f9e923d3..909c7bc7a450 100644 --- a/sw/source/core/unocore/unoport.cxx +++ b/sw/source/core/unocore/unoport.cxx @@ -36,9 +36,9 @@ #include #include #include + #include #include -#include #include #include #include @@ -51,6 +51,7 @@ #include #include #include +#include #include #include diff --git a/sw/source/core/unocore/unoportenum.cxx b/sw/source/core/unocore/unoportenum.cxx index 214336dce955..8ce587ef8bc6 100644 --- a/sw/source/core/unocore/unoportenum.cxx +++ b/sw/source/core/unocore/unoportenum.cxx @@ -46,7 +46,7 @@ #include #include #include -#include +#include #include #include #include @@ -56,6 +56,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unoredline.cxx b/sw/source/core/unocore/unoredline.cxx index 1aca819a6d2e..031f339773a2 100644 --- a/sw/source/core/unocore/unoredline.cxx +++ b/sw/source/core/unocore/unoredline.cxx @@ -31,15 +31,19 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" +#include +#include +#include #include #include + #include #include "poolfmt.hxx" #include #include #include -#include +#include #include #include #include @@ -49,9 +53,6 @@ #include #include #include -#include -#include -#include using namespace ::com::sun::star; diff --git a/sw/source/core/unocore/unoredlines.cxx b/sw/source/core/unocore/unoredlines.cxx index a88b3ff4672c..4ce2e8f5a414 100644 --- a/sw/source/core/unocore/unoredlines.cxx +++ b/sw/source/core/unocore/unoredlines.cxx @@ -31,19 +31,21 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" +#include +#include #include #include + #include #include -#include -#include +#include #include #include "poolfmt.hxx" #include #include #include -#include + using namespace ::com::sun::star; using ::rtl::OUString; diff --git a/sw/source/core/unocore/unorefmk.cxx b/sw/source/core/unocore/unorefmk.cxx index 61c3056a7bef..13b52a6b226b 100644 --- a/sw/source/core/unocore/unorefmk.cxx +++ b/sw/source/core/unocore/unorefmk.cxx @@ -33,7 +33,8 @@ #include #include -#include + +#include #include #include #include diff --git a/sw/source/core/unocore/unosect.cxx b/sw/source/core/unocore/unosect.cxx index 5a87da1e48ab..9f599533eec9 100644 --- a/sw/source/core/unocore/unosect.cxx +++ b/sw/source/core/unocore/unosect.cxx @@ -31,6 +31,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" +#include #include #include @@ -43,7 +44,6 @@ #include #include #include -#include #include #include #include @@ -64,7 +64,7 @@ #include #include #include -#include +#include #include /* #109700# */ #include diff --git a/sw/source/core/unocore/unosett.cxx b/sw/source/core/unocore/unosett.cxx index 0df45c83458a..31d104cc96a5 100644 --- a/sw/source/core/unocore/unosett.cxx +++ b/sw/source/core/unocore/unosett.cxx @@ -61,20 +61,15 @@ #include #include #include -#ifndef _COM_SUN_STAR_BEANS_PropertyAttribute_HPP_ #include -#endif #include -#include #include #include #include #include #include #include -#ifndef _TOOLKIT_UNOHLP_HXX #include -#endif #include #include #include diff --git a/sw/source/core/unocore/unosrch.cxx b/sw/source/core/unocore/unosrch.cxx index 12cc91b1a3f5..1a0a523bb17f 100644 --- a/sw/source/core/unocore/unosrch.cxx +++ b/sw/source/core/unocore/unosrch.cxx @@ -30,13 +30,14 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" -#include "unosrch.hxx" - +#include "unosrch.hxx" #include #include #include -#include +#include +#include + #include #include #include "svx/unolingu.hxx" diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index cbf75f593146..1866613e8ab0 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -60,7 +60,6 @@ #include #include #include -#include #include #include #include diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index e24e17dd47cb..a6ad01ea7a4f 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -83,7 +83,6 @@ #include #include #include -#include #include #include #include diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index 63e27c7abc8d..e571cd722f6c 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -34,12 +34,13 @@ #include #include +#include -#include #include #include #include -#include + +#include #include #include #include @@ -68,9 +69,10 @@ #include #include #include +#include #include #include -#include + #include #include diff --git a/sw/source/filter/html/htmlforw.cxx b/sw/source/filter/html/htmlforw.cxx index 575cbc4c719e..b234e16eecfe 100644 --- a/sw/source/filter/html/htmlforw.cxx +++ b/sw/source/filter/html/htmlforw.cxx @@ -63,7 +63,7 @@ #include #include #include -#include + #include #include #include diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index 3712c13d372d..c081d8c88a67 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -128,9 +128,7 @@ #include -#if OSL_DEBUG_LEVEL > 1 -# include -#endif +#include #include "writerhelper.hxx" #include "writerwordglue.hxx" #include "wrtww8.hxx" diff --git a/sw/source/filter/xml/XMLRedlineImportHelper.cxx b/sw/source/filter/xml/XMLRedlineImportHelper.cxx index 0102462b4864..4b89f042977f 100644 --- a/sw/source/filter/xml/XMLRedlineImportHelper.cxx +++ b/sw/source/filter/xml/XMLRedlineImportHelper.cxx @@ -34,7 +34,6 @@ #include "XMLRedlineImportHelper.hxx" #include -#include "unoobj.hxx" #include #include #include "doc.hxx" diff --git a/sw/source/filter/xml/xmlexp.cxx b/sw/source/filter/xml/xmlexp.cxx index 74196dfbd9ce..98009fccef38 100644 --- a/sw/source/filter/xml/xmlexp.cxx +++ b/sw/source/filter/xml/xmlexp.cxx @@ -56,7 +56,6 @@ #include #include #include -#include #include #include #include diff --git a/sw/source/filter/xml/xmlfmt.cxx b/sw/source/filter/xml/xmlfmt.cxx index 357546259777..cba68f69091e 100644 --- a/sw/source/filter/xml/xmlfmt.cxx +++ b/sw/source/filter/xml/xmlfmt.cxx @@ -43,7 +43,6 @@ #include #include #include -#include #include #include #include @@ -57,19 +56,11 @@ #include #include "xmlitem.hxx" #include -#ifndef _XMLOFF_TXTSTYLI_HXX #include -#endif -#ifndef _XMLOFF_TXTIMP_HXX #include -#endif -#ifndef _XMLOFF_FAMILIES_HXX #include -#endif #include -#ifndef _XMLOFF_XMLTEXTSHAPESTYLECONTEXT_HXX #include -#endif #include #include "xmlimp.hxx" #include "xmltbli.hxx" @@ -79,6 +70,7 @@ #include #include + using namespace ::com::sun::star; using ::rtl::OUString; using ::rtl::OUStringBuffer; diff --git a/sw/source/filter/xml/xmlfonte.cxx b/sw/source/filter/xml/xmlfonte.cxx index d3d8772e43da..3fc753058f3c 100644 --- a/sw/source/filter/xml/xmlfonte.cxx +++ b/sw/source/filter/xml/xmlfonte.cxx @@ -35,7 +35,6 @@ #include #include #include -//#include #include #include #include diff --git a/sw/source/filter/xml/xmlimp.cxx b/sw/source/filter/xml/xmlimp.cxx index cf96a699dd7f..003318dbe989 100644 --- a/sw/source/filter/xml/xmlimp.cxx +++ b/sw/source/filter/xml/xmlimp.cxx @@ -30,6 +30,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" + #include #include #include @@ -47,7 +48,6 @@ #include #include #include -#include #include #include #include "unocrsr.hxx" diff --git a/sw/source/filter/xml/xmlmeta.cxx b/sw/source/filter/xml/xmlmeta.cxx index e9acd9a7ab77..733bf0749faf 100644 --- a/sw/source/filter/xml/xmlmeta.cxx +++ b/sw/source/filter/xml/xmlmeta.cxx @@ -45,7 +45,6 @@ #include "docstat.hxx" #include "docsh.hxx" #include -#include #include "xmlimp.hxx" #include "xmlexp.hxx" diff --git a/sw/source/filter/xml/xmltble.cxx b/sw/source/filter/xml/xmltble.cxx index b80a8f15eda8..05b9d1740f4f 100644 --- a/sw/source/filter/xml/xmltble.cxx +++ b/sw/source/filter/xml/xmltble.cxx @@ -61,7 +61,6 @@ #include #include #include // for cTokenSeperator -#include "unoobj.hxx" #include "unotbl.hxx" #include "xmltexte.hxx" #include "xmlexp.hxx" diff --git a/sw/source/filter/xml/xmltexti.cxx b/sw/source/filter/xml/xmltexti.cxx index acf49038078a..fdd551566789 100644 --- a/sw/source/filter/xml/xmltexti.cxx +++ b/sw/source/filter/xml/xmltexti.cxx @@ -50,13 +50,13 @@ #include #include #include "unocrsr.hxx" -#include "unoobj.hxx" #include "TextCursorHelper.hxx" #include "unoframe.hxx" #include "doc.hxx" #include "unocoll.hxx" #include #include +#include #include "xmlimp.hxx" #include "xmltbli.hxx" #include "xmltexti.hxx" diff --git a/sw/source/ui/app/docsh2.cxx b/sw/source/ui/app/docsh2.cxx index 3fd1e879b063..4dad964fafca 100644 --- a/sw/source/ui/app/docsh2.cxx +++ b/sw/source/ui/app/docsh2.cxx @@ -30,30 +30,19 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" -#ifndef _COM_SUN_STAR_LANG_XMultiServiceFactory_HPP_ -#include -#endif -#ifndef _UNOTOOLS_PROCESSFACTORY_HXX -#include -#endif +#include #include +#include #include #include #include -#ifndef _WRKWIN_HXX //autogen #include -#endif -#ifndef _MSGBOX_HXX //autogen #include -#endif #include #include -/* -#include -*/ #include #include #include @@ -90,51 +79,33 @@ #include #include #include -#ifndef _VIEW_HXX #include // fuer die aktuelle Sicht -#endif -#ifndef _DOCSH_HXX #include // Dokumenterzeugung -#endif #include #include #include -#ifndef _GLOBDOC_HXX #include -#endif #include -#ifndef _REDLNDLG_HXX #include -#endif #include #include #include #include -#ifndef _PVIEW_HXX #include -#endif -#ifndef _SRCVIEW_HXX #include -#endif #include #include -#ifndef _WDOCSH_HXX #include -#endif #include #include #include -#include +#include #include #include -#ifndef _CMDID_H #include -#endif #include -#ifndef _HELPID_H #include -#endif #ifndef _APP_HRC #include #endif diff --git a/sw/source/ui/envelp/labelexp.cxx b/sw/source/ui/envelp/labelexp.cxx index 5c32abede88a..450ebabb1a76 100644 --- a/sw/source/ui/envelp/labelexp.cxx +++ b/sw/source/ui/envelp/labelexp.cxx @@ -43,7 +43,7 @@ #include #include #include -#include +#include #include diff --git a/sw/source/ui/misc/glossary.cxx b/sw/source/ui/misc/glossary.cxx index ef368f680378..d40772b3a0f1 100644 --- a/sw/source/ui/misc/glossary.cxx +++ b/sw/source/ui/misc/glossary.cxx @@ -30,25 +30,18 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" + #ifdef SW_DLLIMPLEMENTATION #undef SW_DLLIMPLEMENTATION #endif - - #define _SVSTDARR_STRINGSDTOR #define _SVSTDARR_STRINGS #include -#ifndef _MENU_HXX //autogen #include -#endif -#ifndef _MSGBOX_HXX //autogen #include -#endif -#ifndef _HELP_HXX //autogen #include -#endif #ifndef _SVSTDARR_HXX #include #endif @@ -64,7 +57,6 @@ #include #include #include -#include #include #include #include @@ -75,12 +67,8 @@ #include #include #include -#ifndef _VIEW_HXX #include -#endif -#ifndef _BASESH_HXX #include -#endif #include #include #include @@ -88,20 +76,12 @@ #include #include #include -#ifndef _DOCSH_HXX #include -#endif #include -#ifndef _CMDID_H #include -#endif -#ifndef _HELPID_H #include -#endif -#ifndef _SWERROR_H #include -#endif #ifndef _GLOBALS_HRC #include #endif diff --git a/sw/source/ui/shells/drwtxtsh.cxx b/sw/source/ui/shells/drwtxtsh.cxx index 9f1d49ebe067..00bf99ce04a3 100644 --- a/sw/source/ui/shells/drwtxtsh.cxx +++ b/sw/source/ui/shells/drwtxtsh.cxx @@ -30,6 +30,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" + #include #include #include @@ -53,7 +54,6 @@ #include #include #include -#include #include #include #include @@ -67,12 +67,8 @@ #include #include -#ifndef _CMDID_H #include -#endif -#ifndef _HELPID_H #include -#endif #ifndef _GLOBALS_HRC #include #endif diff --git a/sw/source/ui/shells/tabsh.cxx b/sw/source/ui/shells/tabsh.cxx index 7ba4d0b8e954..fd7e4ba4d3b8 100644 --- a/sw/source/ui/shells/tabsh.cxx +++ b/sw/source/ui/shells/tabsh.cxx @@ -108,16 +108,12 @@ #ifndef _TABLE_HRC #include #endif -#ifndef _CMDID_H #include -#endif #ifndef _GLOBALS_HRC #include #endif -#ifndef _HELPID_H #include -#endif -#include +#include #define SwTableShell #include diff --git a/sw/source/ui/table/chartins.cxx b/sw/source/ui/table/chartins.cxx index 6c9916e27e0e..0cf308dd4fe4 100644 --- a/sw/source/ui/table/chartins.cxx +++ b/sw/source/ui/table/chartins.cxx @@ -33,9 +33,7 @@ #include -#ifndef _MSGBOX_HXX //autogen #include -#endif #include #include #include @@ -45,24 +43,19 @@ #include #include #include -#ifndef _VIEW_HXX #include -#endif #include #include #include #include #include -#include #include #include #include #include -#ifndef _CMDID_H #include -#endif #ifndef _CHARTINS_HRC #include #endif diff --git a/sw/source/ui/uno/SwXDocumentSettings.cxx b/sw/source/ui/uno/SwXDocumentSettings.cxx index 055dfab0c7f0..98c5903ce0eb 100644 --- a/sw/source/ui/uno/SwXDocumentSettings.cxx +++ b/sw/source/ui/uno/SwXDocumentSettings.cxx @@ -30,16 +30,13 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" + #include #include #include #include -#ifndef _COMPHELPER_MASTERPROPERTSETINFO_HXX_ #include -#endif -#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPPP_ #include -#endif #include #include #include @@ -50,7 +47,6 @@ #include #include #include -#include #include #include #include diff --git a/sw/source/ui/uno/unoatxt.cxx b/sw/source/ui/uno/unoatxt.cxx index 7ed98a979a6a..87d27b15a76b 100644 --- a/sw/source/ui/uno/unoatxt.cxx +++ b/sw/source/ui/uno/unoatxt.cxx @@ -49,7 +49,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sw/source/ui/uno/unodispatch.cxx b/sw/source/ui/uno/unodispatch.cxx index 81849559cfc2..d1d06ec87960 100644 --- a/sw/source/ui/uno/unodispatch.cxx +++ b/sw/source/ui/uno/unodispatch.cxx @@ -31,17 +31,18 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - #include #include #include +#include + #include -#include +#include #include #include #include "wrtsh.hxx" #include "dbmgr.hxx" -#include + using namespace ::com::sun::star; using namespace rtl; diff --git a/sw/source/ui/uno/unomod.cxx b/sw/source/ui/uno/unomod.cxx index ed6d61898804..69cfa1bd6457 100644 --- a/sw/source/ui/uno/unomod.cxx +++ b/sw/source/ui/uno/unomod.cxx @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index 3afeb1ee0c39..ca29279c132b 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -49,7 +49,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sw/source/ui/uno/unotxvw.cxx b/sw/source/ui/uno/unotxvw.cxx index 9de9e882b869..9da88953d481 100644 --- a/sw/source/ui/uno/unotxvw.cxx +++ b/sw/source/ui/uno/unotxvw.cxx @@ -47,7 +47,6 @@ #include #include #include -#include #include #include #include diff --git a/sw/source/ui/utlui/swrenamexnameddlg.cxx b/sw/source/ui/utlui/swrenamexnameddlg.cxx index 85d8aa2cf7a6..1420831b4a84 100644 --- a/sw/source/ui/utlui/swrenamexnameddlg.cxx +++ b/sw/source/ui/utlui/swrenamexnameddlg.cxx @@ -63,7 +63,6 @@ #include #include #include -#include #include #include "swrenamexnameddlg.hxx" -- cgit From 4f555e6d5467a2a198113789c5527969e287da9c Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Tue, 5 Jan 2010 16:37:49 +0100 Subject: swunolocking1: #i105557#: remove unoobj.hxx --- sw/inc/unoobj.hxx | 158 ------------------------------------------------------ 1 file changed, 158 deletions(-) delete mode 100644 sw/inc/unoobj.hxx (limited to 'sw') diff --git a/sw/inc/unoobj.hxx b/sw/inc/unoobj.hxx deleted file mode 100644 index 6ab11b13e9ec..000000000000 --- a/sw/inc/unoobj.hxx +++ /dev/null @@ -1,158 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: unoobj.hxx,v $ - * - * $Revision: 1.49 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef _UNOOBJ_HXX -#define _UNOOBJ_HXX - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include // helper for factories - -#include -#include -#include - -#include - - -class GetCurTxtFmtColl; - - - -/* -----------------26.06.98 16:18------------------- - * - * --------------------------------------------------*/ - - - -/****************************************************************************** - * - ******************************************************************************/ - - - -/*-----------------20.03.98 07:47------------------- - ---------------------------------------------------*/ -/* das wird zunaechst nicht gebraucht - bisher fuer den XPropertySetCloner -class SwXPropertySet : public ::com::sun::star::beans::XPropertySet, - public UsrObject -{ - ::com::sun::star::uno::Sequence<::com::sun::star::uno::Any>* pAny; - ::com::sun::star::uno::Sequence< Property >* pInfo; - -public: - // Eigentumsuebergang der Pointer! - SwXPropertySet( ::com::sun::star::uno::Sequence<::com::sun::star::uno::Any>* pAny, - ::com::sun::star::uno::Sequence* pInfo ); - virtual ~SwXPropertySet(); - - SMART_UNO_DECLARATION( SwXPropertySet, UsrObject ); - - //XPropertySet - virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - -}; -*/ -/*-----------------20.03.98 08:26------------------- - ---------------------------------------------------*/ -/* das wird zunaechst nicht gebraucht - bisher fuer den XPropertySetCloner - -class SwXPropertySetInfo: public ::com::sun::star::beans::XPropertySetInfo, UsrObject -{ - ::com::sun::star::uno::Sequence< Property >* pSeq; - -public: - SwXPropertySetInfo( const ::com::sun::star::uno::Sequence& rInfo ); - virtual ~SwXPropertySetInfo(); - - SMART_UNO_DECLARATION( SwXPropertySetInfo, UsrObject ); - - virtual ::com::sun::star::uno::Sequence< Property > getProperties(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual Property getPropertyByName(const rtl::OUString& Name) throw( ::com::sun::star::uno::RuntimeException ); - virtual BOOL hasPropertyByName(const rtl::OUString& Name) throw( ::com::sun::star::uno::RuntimeException ); -}; -*/ - -/*-----------------23.02.98 10:45------------------- - ---------------------------------------------------*/ - - -/* -----------------29.09.98 09:01------------------- - * - * --------------------------------------------------*/ -/* os: 04.12.98 11:40 hier gibt es noch keine sinnvolle Definition -#define MAX_SORT_FIELDS 3 // das ist eher willkuerlich (wie im Dialog) -class SwXTextSortDescriptor : public XTextSortDescriptor, - public UsrObject -{ - SwSortOptions aSortOptions; - BOOL bUseHeader; -public: - SwXTextSortDescriptor(BOOL bUsedInTable); - virtual ~SwXTextSortDescriptor(); - - //XTextSortDescriptor - virtual sal_Unicode getTextColumnSeparator(void) const; - virtual void setTextColumnSeparator(sal_Unicode TextColumnSeparator_); - - //XSortDescriptor - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::util::SortField > getSortFields(void) const; - virtual void setSortFields(const ::com::sun::star::uno::Sequence< ::com::sun::star::util::SortField >& SortFields_); - virtual sal_uInt16 getMaxFieldCount(void) const; - virtual ColumnsOrRows getOrientation(void) const; - virtual void setOrientation(ColumnsOrRows Orientation_); - virtual BOOL getUseHeader(void) const; - virtual void setUseHeader(BOOL UseHeader_); - - const SwSortOptions& GetSortOptions() const {return aSortOptions;} - void SetSortOptions(const SwSortOptions& rSortOpt); -}; -*/ - -#endif - -- cgit From 5e8eac444983d7fcf8e4c102171179dbb6fffed9 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 8 Jan 2010 17:13:47 +0100 Subject: swunolocking1: #i105557#: unobaseclass.hxx: add UnoImplPtr: new smart pointer template UnoImplPtr: calls dtor with SolarMutex locked. --- sw/inc/unobaseclass.hxx | 43 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) (limited to 'sw') diff --git a/sw/inc/unobaseclass.hxx b/sw/inc/unobaseclass.hxx index 75443b2c7584..5f55115f479e 100644 --- a/sw/inc/unobaseclass.hxx +++ b/sw/inc/unobaseclass.hxx @@ -27,8 +27,8 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -#ifndef _UNOBASECLASS_HXX -#define _UNOBASECLASS_HXX +#ifndef SW_UNOBASECLASS_HXX +#define SW_UNOBASECLASS_HXX #include #include @@ -102,5 +102,42 @@ class UnoActionRemoveContext /// helper function for implementing SwClient::Modify void ClientModify(SwClient* pClient, SfxPoolItem *pOld, SfxPoolItem *pNew); -#endif + +#include +#include +#include +#include + +namespace sw { + + template class UnoImplPtr + : private ::boost::noncopyable + { + private: + T * m_p; + + public: + UnoImplPtr(T *const i_p) + : m_p(i_p) + { + OSL_ENSURE(i_p, "UnoImplPtr: null"); + } + + ~UnoImplPtr() + { + ::vos::OGuard g(Application::GetSolarMutex()); + delete m_p; // #i105557#: call dtor with locked solar mutex + m_p = 0; + } + + T & operator * () const { return *m_p; } + + T * operator ->() const { return m_p; } + + T * get () const { return m_p; } + }; + +} // namespace sw + +#endif // SW_UNOBASECLASS_HXX -- cgit From a22723dc6276d018fcd2fffa04c143e9c6c04c7a Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 8 Jan 2010 17:13:48 +0100 Subject: swunolocking1: #i105557#: unobaseclass.hxx: add UnoTunnel helpers: new template UnoTunnelImpl to implement XUnoTunnel::getSomething(). new template UnoTunnelGetImplementation to use XUnoTunnel::getSomething(). --- sw/inc/unobaseclass.hxx | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'sw') diff --git a/sw/inc/unobaseclass.hxx b/sw/inc/unobaseclass.hxx index 5f55115f479e..e9ae3f909a63 100644 --- a/sw/inc/unobaseclass.hxx +++ b/sw/inc/unobaseclass.hxx @@ -30,6 +30,7 @@ #ifndef SW_UNOBASECLASS_HXX #define SW_UNOBASECLASS_HXX +#include #include #include @@ -137,6 +138,32 @@ namespace sw { T * get () const { return m_p; } }; + template< class C > C * + UnoTunnelGetImplementation( + ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XUnoTunnel > const & xUnoTunnel) + { + if (!xUnoTunnel.is()) { return 0; } + C *const pC( reinterpret_cast< C* >( + ::sal::static_int_cast< sal_IntPtr >( + xUnoTunnel->getSomething(C::getUnoTunnelId())))); + return pC; + } + + template< class C > sal_Int64 + UnoTunnelImpl(const ::com::sun::star::uno::Sequence< sal_Int8 > & rId, + C *const pThis) + { + if ((rId.getLength() == 16) && + (0 == rtl_compareMemory(C::getUnoTunnelId().getConstArray(), + rId.getConstArray(), 16))) + { + return ::sal::static_int_cast< sal_Int64 >( + reinterpret_cast< sal_IntPtr >(pThis) ); + } + return 0; + } + } // namespace sw #endif // SW_UNOBASECLASS_HXX -- cgit From 6e3f9b6a9a1f70811e393d10a21addfaeedc174e Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 8 Jan 2010 17:13:48 +0100 Subject: swunolocking1: #i105557#: unobaseclass.hxx: add XServiceInfo helpers: new functions GetSupportedServiceNamesImpl and SupportsServiceImpl. --- sw/inc/unobaseclass.hxx | 7 +++++++ sw/source/core/unocore/unoobj2.cxx | 31 +++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) (limited to 'sw') diff --git a/sw/inc/unobaseclass.hxx b/sw/inc/unobaseclass.hxx index e9ae3f909a63..91ef17d4e9d4 100644 --- a/sw/inc/unobaseclass.hxx +++ b/sw/inc/unobaseclass.hxx @@ -164,6 +164,13 @@ namespace sw { return 0; } + ::com::sun::star::uno::Sequence< ::rtl::OUString > + GetSupportedServiceNamesImpl( + size_t const nServices, char const*const pServices[]); + sal_Bool SupportsServiceImpl( + size_t const nServices, char const*const pServices[], + ::rtl::OUString const & rServiceName); + } // namespace sw #endif // SW_UNOBASECLASS_HXX diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index 6d2a0d49f9d5..a7f6119e5962 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -146,6 +146,37 @@ using namespace ::com::sun::star::drawing; using ::rtl::OUString; +namespace sw { + +sal_Bool SupportsServiceImpl( + size_t const nServices, char const*const pServices[], + ::rtl::OUString const & rServiceName) +{ + for (size_t i = 0; i < nServices; ++i) + { + if (rServiceName.equalsAscii(pServices[i])) + { + return sal_True; + } + } + return sal_False; +} + +uno::Sequence< ::rtl::OUString > +GetSupportedServiceNamesImpl( + size_t const nServices, char const*const pServices[]) +{ + uno::Sequence< ::rtl::OUString > ret(nServices); + for (size_t i = 0; i < nServices; ++i) + { + ret[i] = C2U(pServices[i]); + } + return ret; +} + +} // namespace sw + + struct FrameDependSortListLess { bool operator() (FrameDependSortListEntry const& r1, -- cgit From e9ca667fa65f946acec102e3932372010b8622bd Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 8 Jan 2010 17:13:49 +0100 Subject: swunolocking1: refactor Meta registration at its text node. Meta will now be registered via SwTxtMeta::ChgTxtNode(), with additional workarounds necessary in SwFmtMeta::DoCopy(). --- sw/inc/fmtmeta.hxx | 8 +++-- sw/inc/txtatr.hxx | 2 +- .../complex/writer/TextPortionEnumerationTest.java | 2 +- sw/source/core/docnode/nodes.cxx | 11 +++++-- sw/source/core/txtnode/fmtatr2.cxx | 35 ++++++++++++++++++---- sw/source/core/txtnode/thints.cxx | 7 ++++- sw/source/core/txtnode/txtatr2.cxx | 10 +++++++ 7 files changed, 60 insertions(+), 15 deletions(-) (limited to 'sw') diff --git a/sw/inc/fmtmeta.hxx b/sw/inc/fmtmeta.hxx index 952181d0498c..6d3f63ece477 100755 --- a/sw/inc/fmtmeta.hxx +++ b/sw/inc/fmtmeta.hxx @@ -122,8 +122,8 @@ public: virtual SfxPoolItem * Clone( SfxItemPool *pPool = 0 ) const; // TYPEINFO(); - // notify clients registered at m_pMeta that this meta is being removed - void NotifyRemoval(); + /// notify clients registered at m_pMeta that this meta is being (re-)moved + void NotifyChangeTxtNode(SwTxtNode *const pTxtNode); static SwFmtMeta * CreatePoolDefault( const USHORT i_nWhich ); ::sw::Meta * GetMeta() { return m_pMeta.get(); } /// this method must be called when the hint is actually copied @@ -140,7 +140,7 @@ class Meta , public SwModify { protected: - friend class ::SwFmtMeta; // SetFmtMeta + friend class ::SwFmtMeta; // SetFmtMeta, NotifyChangeTxtNode friend class ::SwXMeta; // GetTxtNode, GetTxtAttr SwFmtMeta * m_pFmt; @@ -151,6 +151,8 @@ protected: SwFmtMeta * GetFmtMeta() const { return m_pFmt; } void SetFmtMeta( SwFmtMeta * const i_pFmt ) { m_pFmt = i_pFmt; }; + void NotifyChangeTxtNode(); + public: explicit Meta(SwFmtMeta * const i_pFmt = 0); virtual ~Meta(); diff --git a/sw/inc/txtatr.hxx b/sw/inc/txtatr.hxx index d9e9463a30a7..8c0ad5854665 100644 --- a/sw/inc/txtatr.hxx +++ b/sw/inc/txtatr.hxx @@ -80,7 +80,7 @@ public: const xub_StrLen i_nStart, const xub_StrLen i_nEnd ); virtual ~SwTxtMeta(); - void ChgTxtNode( SwTxtNode * const pNode ) { m_pTxtNode = pNode; } + void ChgTxtNode(SwTxtNode * const pNode); SwTxtNode * GetTxtNode() const { return m_pTxtNode; } }; diff --git a/sw/qa/complex/writer/TextPortionEnumerationTest.java b/sw/qa/complex/writer/TextPortionEnumerationTest.java index a07b3cccadef..8110c82a6e58 100755 --- a/sw/qa/complex/writer/TextPortionEnumerationTest.java +++ b/sw/qa/complex/writer/TextPortionEnumerationTest.java @@ -3097,7 +3097,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase XPropertySet xPropSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xPortion); String type = (String) xPropSet.getPropertyValue("TextPortionType"); - assure("first: not text", type.equals("Text")); + assure("first: not text: " + type, type.equals("Text")); String txt = xPortion.getString(); assure("first: text differs: " + txt, "45".equals(txt)); } diff --git a/sw/source/core/docnode/nodes.cxx b/sw/source/core/docnode/nodes.cxx index ce24e4ba06b5..29d9c61e1ad8 100644 --- a/sw/source/core/docnode/nodes.cxx +++ b/sw/source/core/docnode/nodes.cxx @@ -47,7 +47,7 @@ #include #include #include -#include +#include #include #include @@ -350,8 +350,13 @@ void SwNodes::ChgNode( SwNodeIndex& rDelPos, ULONG nSz, case RES_TXTATR_META: case RES_TXTATR_METAFIELD: - static_cast(pAttr->GetAttr()) - .NotifyRemoval(); + { + SwTxtMeta *const pTxtMeta( + static_cast(pAttr)); + // force removal of UNO object + pTxtMeta->ChgTxtNode(0); + pTxtMeta->ChgTxtNode(pTxtNd); + } break; default: diff --git a/sw/source/core/txtnode/fmtatr2.cxx b/sw/source/core/txtnode/fmtatr2.cxx index 405358adac59..f7fe06d6b006 100644 --- a/sw/source/core/txtnode/fmtatr2.cxx +++ b/sw/source/core/txtnode/fmtatr2.cxx @@ -650,19 +650,28 @@ void SwFmtMeta::SetTxtAttr(SwTxtMeta * const i_pTxtAttr) } } -void SwFmtMeta::NotifyRemoval() +void SwFmtMeta::NotifyChangeTxtNode(SwTxtNode *const pTxtNode) { // N.B.: do not reset m_pTxtAttr here: see call in nodes.cxx, // where the hint is not deleted! ASSERT(m_pMeta, "NotifyRemoval: no meta ?"); if (m_pMeta) { - SwPtrMsgPoolItem aMsgHint( RES_REMOVE_UNO_OBJECT, - &static_cast(*m_pMeta) ); // cast to proper base class! - m_pMeta->Modify(&aMsgHint, &aMsgHint); + if (!pTxtNode) + { + SwPtrMsgPoolItem aMsgHint( RES_REMOVE_UNO_OBJECT, + &static_cast(*m_pMeta) ); // cast to base class! + m_pMeta->Modify(&aMsgHint, &aMsgHint); + } + else + { // do not call Modify, that would call SwXMeta::Modify! + m_pMeta->NotifyChangeTxtNode(); + } } } +// UGLY: this really awful method fixes up an inconsistent state, +// and if it is not called when copying, total chaos will undoubtedly ensue void SwFmtMeta::DoCopy(SwFmtMeta & rOriginalMeta) { ASSERT(m_pMeta, "DoCopy called for SwFmtMeta with no sw::Meta?"); @@ -673,6 +682,8 @@ void SwFmtMeta::DoCopy(SwFmtMeta & rOriginalMeta) // inserted via MakeTxtAttr! so fix it up to point at the original item // (maybe would be better to tell MakeTxtAttr that it creates a copy?) pOriginal->SetFmtMeta(&rOriginalMeta); + // force pOriginal to register in original text node! + pOriginal->NotifyChangeTxtNode(); if (RES_TXTATR_META == Which()) { m_pMeta.reset( new ::sw::Meta(this) ); @@ -685,7 +696,10 @@ void SwFmtMeta::DoCopy(SwFmtMeta & rOriginalMeta) m_pMeta = pTargetDoc->GetMetaFieldManager().makeMetaField( this, pMetaField->m_nNumberFormat, pMetaField->IsFixedLanguage() ); } + // this cannot be done in Clone: a Clone is not necessarily a copy! m_pMeta->RegisterAsCopyOf(*pOriginal); + // force copy Meta to register in target text node! + m_pMeta->NotifyChangeTxtNode(); } } @@ -718,14 +732,23 @@ SwTxtNode * Meta::GetTxtNode() const return (pTxtAttr) ? pTxtAttr->GetTxtNode() : 0; } -// SwClient -void Meta::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew ) +void Meta::NotifyChangeTxtNode() { SwTxtNode * const pTxtNode( GetTxtNode() ); if (pTxtNode && (GetRegisteredIn() != pTxtNode)) { pTxtNode->Add(this); } + else if (!pTxtNode && GetRegisteredIn()) + { + const_cast(GetRegisteredIn())->Remove(this); + } +} + +// SwClient +void Meta::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew ) +{ + NotifyChangeTxtNode(); SwModify::Modify(pOld, pNew); } diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx index ba471381cad4..3300294f9e4b 100644 --- a/sw/source/core/txtnode/thints.cxx +++ b/sw/source/core/txtnode/thints.cxx @@ -114,6 +114,11 @@ struct TxtAttrDeleter TxtAttrDeleter( SwDoc & rDoc ) : m_rPool( rDoc.GetAttrPool() ) { } void operator() (SwTxtAttr * const pAttr) { + if (RES_TXTATR_META == pAttr->Which() || + RES_TXTATR_METAFIELD == pAttr->Which()) + { + static_cast(pAttr)->ChgTxtNode(0); // prevents ASSERT + } SwTxtAttr::Destroy( pAttr, m_rPool ); } }; @@ -1178,7 +1183,7 @@ void SwTxtNode::DestroyAttr( SwTxtAttr* pAttr ) case RES_TXTATR_META: case RES_TXTATR_METAFIELD: - static_cast(pAttr->GetAttr()).NotifyRemoval(); + static_cast(pAttr)->ChgTxtNode(0); break; default: diff --git a/sw/source/core/txtnode/txtatr2.cxx b/sw/source/core/txtnode/txtatr2.cxx index afed4e1af732..e3f1d1386a95 100644 --- a/sw/source/core/txtnode/txtatr2.cxx +++ b/sw/source/core/txtnode/txtatr2.cxx @@ -329,3 +329,13 @@ SwTxtMeta::~SwTxtMeta() } } +void SwTxtMeta::ChgTxtNode(SwTxtNode * const pNode) +{ + m_pTxtNode = pNode; // before Notify! + SwFmtMeta & rFmtMeta( static_cast(GetAttr()) ); + if (rFmtMeta.GetTxtAttr() == this) + { + rFmtMeta.NotifyChangeTxtNode(pNode); + } +} + -- cgit From dd567990b4372498dfbe5063082c792f241ee41d Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 8 Jan 2010 17:13:49 +0100 Subject: swunolocking1: #i105557#: fix locking for SwXMeta: move SwClient base to pImpl struct, and use UnoImplPtr to lock destructor. replace broken SwClient iteration with a WeakReference in sw::Meta. make constructor protected, and add factory function CreateXMeta. use new XUnoTunnel and XServiceInfo helpers. --- sw/inc/fmtmeta.hxx | 14 +- sw/source/core/inc/unometa.hxx | 193 +++++++++++++------------ sw/source/core/txtnode/fmtatr2.cxx | 31 +--- sw/source/core/unocore/unoportenum.cxx | 57 +++++--- sw/source/core/unocore/unorefmk.cxx | 251 ++++++++++++++++++++------------- 5 files changed, 311 insertions(+), 235 deletions(-) (limited to 'sw') diff --git a/sw/inc/fmtmeta.hxx b/sw/inc/fmtmeta.hxx index 6d3f63ece477..792a7d8374db 100755 --- a/sw/inc/fmtmeta.hxx +++ b/sw/inc/fmtmeta.hxx @@ -31,6 +31,8 @@ #ifndef SW_FMTMETA_HXX #define SW_FMTMETA_HXX +#include + #include #include @@ -141,7 +143,10 @@ class Meta { protected: friend class ::SwFmtMeta; // SetFmtMeta, NotifyChangeTxtNode - friend class ::SwXMeta; // GetTxtNode, GetTxtAttr + friend class ::SwXMeta; // GetTxtNode, GetTxtAttr, Get/SetXMeta + + ::com::sun::star::uno::WeakReference< + ::com::sun::star::rdf::XMetadatable> m_wXMeta; SwFmtMeta * m_pFmt; @@ -153,6 +158,13 @@ protected: void NotifyChangeTxtNode(); + ::com::sun::star::uno::WeakReference< + ::com::sun::star::rdf::XMetadatable> const& GetXMeta() const + { return m_wXMeta; } + void SetXMeta(::com::sun::star::uno::Reference< + ::com::sun::star::rdf::XMetadatable> const& xMeta) + { m_wXMeta = xMeta; } + public: explicit Meta(SwFmtMeta * const i_pFmt = 0); virtual ~Meta(); diff --git a/sw/source/core/inc/unometa.hxx b/sw/source/core/inc/unometa.hxx index 1dc1985f7dfe..5568aa88b52e 100755 --- a/sw/source/core/inc/unometa.hxx +++ b/sw/source/core/inc/unometa.hxx @@ -31,19 +31,21 @@ #ifndef SW_UNOMETA_HXX #define SW_UNOMETA_HXX -#include "calbck.hxx" - -#include -#include -#include +#include #include #include +#include #include #include #include -#include +#include +#include + +#include + +#include typedef ::std::deque< @@ -52,42 +54,78 @@ typedef ::std::deque< class SwXTextRange; class SwPaM; -class SwTxtMeta; +class SwTxtNode; + namespace sw { class Meta; class MetaField; } -typedef -::cppu::ImplInheritanceHelper5 -< ::sfx2::MetadatableMixin -, ::com::sun::star::lang::XUnoTunnel -, ::com::sun::star::lang::XServiceInfo -, ::com::sun::star::text::XTextContent -, ::com::sun::star::text::XText -, ::com::sun::star::container::XEnumerationAccess -> SwXMetaBaseClass; +typedef ::cppu::ImplInheritanceHelper5 +< ::sfx2::MetadatableMixin +, ::com::sun::star::lang::XUnoTunnel +, ::com::sun::star::lang::XServiceInfo +, ::com::sun::star::container::XEnumerationAccess +, ::com::sun::star::text::XTextContent +, ::com::sun::star::text::XText +> SwXMeta_Base; class SwXMeta - : public SwXMetaBaseClass - , public SwClient + : public SwXMeta_Base , private ::boost::noncopyable { -private: - struct Impl; - ::std::auto_ptr m_pImpl; + +public: + + class Impl; protected: + + ::sw::UnoImplPtr m_pImpl; + + virtual void SAL_CALL AttachImpl( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xTextRange, + const USHORT nWhich) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + virtual ~SwXMeta(); -public: - SwXMeta(SwDoc *const pDoc, + /// @param pDoc and pMeta != 0, but not & because of ImplInheritanceHelper + SwXMeta(SwDoc *const pDoc, ::sw::Meta *const pMeta, ::com::sun::star::uno::Reference< ::com::sun::star::text::XText> const& xParentText, - TextRangeList_t * const pPortions, SwTxtMeta * const pHint); + TextRangeList_t const*const pPortions); + +public: + SwXMeta(SwDoc *const pDoc); - TYPEINFO(); + static ::com::sun::star::uno::Reference< + ::com::sun::star::rdf::XMetadatable > + CreateXMeta( + ::sw::Meta & rMeta, + ::com::sun::star::uno::Reference< ::com::sun::star::text::XText> + const& xParentText = 0, + ::std::auto_ptr pPortions = + ::std::auto_ptr(0)); + + /// init params with position of the attribute content (w/out CH_TXTATR) + bool SetContentRange( + SwTxtNode *& rpNode, xub_StrLen & rStart, xub_StrLen & rEnd) const; + ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > + GetParentText() const; + + bool CheckForOwnMemberMeta(const SwXTextRange* const pRange, + const SwPaM* const pPam, bool bAbsorb) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + + // MetadatableMixin + virtual ::sfx2::Metadatable * GetCoreObject(); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > + GetModel(); static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId(); @@ -118,6 +156,18 @@ public: ::com::sun::star::lang::XEventListener > & xListener) throw (::com::sun::star::uno::RuntimeException); + // XElementAccess + virtual ::com::sun::star::uno::Type SAL_CALL getElementType() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL hasElements() + throw (::com::sun::star::uno::RuntimeException); + + // XEnumerationAccess + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::container::XEnumeration > SAL_CALL + createEnumeration() + throw (::com::sun::star::uno::RuntimeException); + // XTextContent virtual void SAL_CALL attach( const ::com::sun::star::uno::Reference< @@ -180,72 +230,37 @@ public: throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException); - // XElementAccess - virtual ::com::sun::star::uno::Type SAL_CALL getElementType() - throw (::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL hasElements() - throw (::com::sun::star::uno::RuntimeException); - - // XEnumerationAccess - virtual ::com::sun::star::uno::Reference< - ::com::sun::star::container::XEnumeration > SAL_CALL - createEnumeration() - throw (::com::sun::star::uno::RuntimeException); - - // MetadatableMixin - virtual ::sfx2::Metadatable * GetCoreObject(); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > - GetModel(); - - // SwClient - virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew ); - - /// init params with position of the attribute content (w/out CH_TXTATR) - bool SetContentRange( - SwTxtNode *& rpNode, xub_StrLen & rStart, xub_StrLen & rEnd) const; - ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > - GetParentText() const; - - bool CheckForOwnMemberMeta(const SwXTextRange* const pRange, - const SwPaM* const pPam, bool bAbsorb) - throw (::com::sun::star::lang::IllegalArgumentException, - ::com::sun::star::uno::RuntimeException); - -protected: - virtual void SAL_CALL AttachImpl( - const ::com::sun::star::uno::Reference< - ::com::sun::star::text::XTextRange > & xTextRange, - const USHORT nWhich) - throw ( ::com::sun::star::lang::IllegalArgumentException, - ::com::sun::star::uno::RuntimeException ); - -private: - inline const ::sw::Meta * GetMeta() const; - }; -typedef -::cppu::ImplInheritanceHelper2 -< SwXMeta -, ::com::sun::star::beans::XPropertySet -, ::com::sun::star::text::XTextField -> SwXMetaFieldBaseClass; +typedef ::cppu::ImplInheritanceHelper2 +< SwXMeta +, ::com::sun::star::beans::XPropertySet +, ::com::sun::star::text::XTextField +> SwXMetaField_Base; class SwXMetaField - : public SwXMetaFieldBaseClass + : public SwXMetaField_Base { + private: + virtual ~SwXMetaField(); -private: - inline const ::sw::MetaField * GetMetaField() const; + friend ::com::sun::star::uno::Reference< + ::com::sun::star::rdf::XMetadatable > + SwXMeta::CreateXMeta(::sw::Meta &, + ::com::sun::star::uno::Reference< ::com::sun::star::text::XText> + const&, + ::std::auto_ptr pPortions); -public: - SwXMetaField(SwDoc *const pDoc, + SwXMetaField(SwDoc *const pDoc, ::sw::Meta *const pMeta, ::com::sun::star::uno::Reference< ::com::sun::star::text::XText> const& xParentText, - TextRangeList_t * const pPortions, SwTxtMeta * const pHint); + TextRangeList_t const*const pPortions); + +public: + SwXMetaField(SwDoc *const pDoc); // XServiceInfo @@ -270,16 +285,6 @@ public: ::com::sun::star::lang::XEventListener > & xListener) throw (::com::sun::star::uno::RuntimeException); - // XTextContent - virtual void SAL_CALL attach( - const ::com::sun::star::uno::Reference< - ::com::sun::star::text::XTextRange > & xTextRange) - throw ( ::com::sun::star::lang::IllegalArgumentException, - ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Reference< - ::com::sun::star::text::XTextRange > SAL_CALL getAnchor() - throw (::com::sun::star::uno::RuntimeException); - // XPropertySet virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL @@ -327,6 +332,16 @@ public: ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + // XTextContent + virtual void SAL_CALL attach( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xTextRange) + throw ( ::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException ); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > SAL_CALL getAnchor() + throw (::com::sun::star::uno::RuntimeException); + // XTextField virtual rtl::OUString SAL_CALL getPresentation(sal_Bool bShowCommand) throw (::com::sun::star::uno::RuntimeException); diff --git a/sw/source/core/txtnode/fmtatr2.cxx b/sw/source/core/txtnode/fmtatr2.cxx index f7fe06d6b006..e76b7f8e4cb1 100644 --- a/sw/source/core/txtnode/fmtatr2.cxx +++ b/sw/source/core/txtnode/fmtatr2.cxx @@ -57,7 +57,6 @@ #include // for meta #include // for meta #include -#include #include #include // GetNumberFormat @@ -750,6 +749,10 @@ void Meta::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew ) { NotifyChangeTxtNode(); SwModify::Modify(pOld, pNew); + if (pOld && (RES_REMOVE_UNO_OBJECT == pOld->Which())) + { // invalidate cached uno object + SetXMeta(uno::Reference(0)); + } } // sw::Metadatable @@ -788,31 +791,7 @@ bool Meta::IsInContent() const ::com::sun::star::uno::Reference< ::com::sun::star::rdf::XMetadatable > Meta::MakeUnoObject() { - // re-use existing SwXMeta - SwClientIter iter( *this ); - SwClient * pClient( iter.First( TYPE( SwXMeta ) ) ); - while (pClient) { - SwXMeta *const pMeta( dynamic_cast(pClient) ); - if (pMeta && pMeta->GetCoreObject() == this) { - return pMeta; - } - pClient = iter.Next(); - } - - // create new SwXMeta - SwTxtMeta * const pTxtAttr( GetTxtAttr() ); - OSL_ENSURE(pTxtAttr, "MakeUnoObject: no text attr?"); - if (!pTxtAttr) return 0; - SwTxtNode * const pTxtNode( pTxtAttr->GetTxtNode() ); - OSL_ENSURE(pTxtNode, "MakeUnoObject: no text node?"); - if (!pTxtNode) return 0; - const SwPosition aPos(*pTxtNode, *pTxtAttr->GetStart()); - const uno::Reference xParentText( - SwXTextRange::CreateParentXText(pTxtNode->GetDoc(), aPos) ); - if (!xParentText.is()) return 0; - return (RES_TXTATR_META == m_pFmt->Which()) - ? new SwXMeta (pTxtNode->GetDoc(), xParentText, 0, pTxtAttr) - : new SwXMetaField(pTxtNode->GetDoc(), xParentText, 0, pTxtAttr); + return SwXMeta::CreateXMeta(*this); } /************************************************************************* diff --git a/sw/source/core/unocore/unoportenum.cxx b/sw/source/core/unocore/unoportenum.cxx index 8ce587ef8bc6..e7426091f745 100644 --- a/sw/source/core/unocore/unoportenum.cxx +++ b/sw/source/core/unocore/unoportenum.cxx @@ -54,6 +54,7 @@ #include #include #include +#include #include #include #include @@ -492,6 +493,33 @@ lcl_CreateTOXMarkPortion( return pPortion; } +//----------------------------------------------------------------------------- +static uno::Reference +lcl_CreateMetaPortion( + uno::Reference const& xParent, + const SwUnoCrsr * const pUnoCrsr, + SwTxtAttr & rAttr, ::std::auto_ptr & pPortions) +{ + const uno::Reference xMeta( SwXMeta::CreateXMeta( + *static_cast(rAttr.GetAttr()).GetMeta(), + xParent, pPortions)); + SwXTextPortion * pPortion(0); + if (RES_TXTATR_META == rAttr.Which()) + { + const uno::Reference xContent(xMeta, + uno::UNO_QUERY); + pPortion = new SwXTextPortion(pUnoCrsr, xParent, PORTION_META); + pPortion->SetMeta(xContent); + } + else + { + const uno::Reference xField(xMeta, uno::UNO_QUERY); + pPortion = new SwXTextPortion(pUnoCrsr, xParent, PORTION_FIELD); + pPortion->SetTextField(xField); + } + return pPortion; +} + //----------------------------------------------------------------------------- static void lcl_ExportBookmark( @@ -692,30 +720,13 @@ lcl_ExportHints( } else { - TextRangeList_t *const pCurrentPortions(Top.first); + ::std::auto_ptr + pCurrentPortions(Top.first); rPortionStack.pop(); - SwXTextPortion * pPortion; - if (RES_TXTATR_META == nWhich) - { - SwXMeta * const pMeta = - new SwXMeta(pDoc, xParent, - pCurrentPortions, - static_cast(pAttr)); - pPortion = new SwXTextPortion( - pUnoCrsr, xParent, PORTION_META); - pPortion->SetMeta(pMeta); - } - else - { - SwXMetaField * const pMeta = - new SwXMetaField(pDoc, xParent, - pCurrentPortions, - static_cast(pAttr)); - pPortion = new SwXTextPortion( - pUnoCrsr, xParent, PORTION_FIELD); - pPortion->SetTextField(pMeta); - } - rPortionStack.top().first->push_back(pPortion); + const uno::Reference xPortion( + lcl_CreateMetaPortion(xParent, pUnoCrsr, + *pAttr, pCurrentPortions)); + rPortionStack.top().first->push_back(xPortion); } } break; diff --git a/sw/source/core/unocore/unorefmk.cxx b/sw/source/core/unocore/unorefmk.cxx index 13b52a6b226b..8e1d18f1dae8 100644 --- a/sw/source/core/unocore/unorefmk.cxx +++ b/sw/source/core/unocore/unorefmk.cxx @@ -493,6 +493,8 @@ public: const uno::Reference< text::XTextRange > & xTextPosition) throw (uno::RuntimeException); + SwXMeta & GetXMeta() { return m_rMeta; } + }; SwXMetaText::SwXMetaText(SwDoc & rDoc, SwXMeta & rMeta) @@ -598,8 +600,12 @@ SwXMetaText::createTextCursorByRange( // this list is created by SwXTextPortionEnumeration // the Meta listens at the SwTxtNode and throws away the cache when it changes -struct SwXMeta::Impl +class SwXMeta::Impl + : public SwClient { + +public: + SwEventListenerContainer m_ListenerContainer; ::std::auto_ptr m_pTextPortions; // 3 possible states: not attached, attached, disposed @@ -608,37 +614,132 @@ struct SwXMeta::Impl uno::Reference m_xParentText; SwXMetaText m_Text; - Impl(SwXMeta & rThis, SwDoc & rDoc, + Impl( SwXMeta & rThis, SwDoc & rDoc, + ::sw::Meta * const pMeta, uno::Reference const& xParentText, - TextRangeList_t const * const pPortions, - SwTxtMeta const * const pHint) - : m_ListenerContainer( - static_cast< ::cppu::OWeakObject* >(&rThis)) + TextRangeList_t const * const pPortions) + : SwClient(pMeta) + , m_ListenerContainer(static_cast< ::cppu::OWeakObject* >(&rThis)) , m_pTextPortions( pPortions ) , m_bIsDisposed( false ) - , m_bIsDescriptor( 0 == pHint ) + , m_bIsDescriptor(0 == pMeta) , m_xParentText(xParentText) , m_Text(rDoc, rThis) { } -}; -TYPEINIT1(SwXMeta, SwClient); + inline const ::sw::Meta * GetMeta() const; + // only for SwXMetaField! + inline const ::sw::MetaField * GetMetaField() const; + + // SwClient + virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); -inline const ::sw::Meta * SwXMeta::GetMeta() const +}; + +inline const ::sw::Meta * SwXMeta::Impl::GetMeta() const { return static_cast< const ::sw::Meta * >(GetRegisteredIn()); } +// SwModify +void SwXMeta::Impl::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew ) +{ + m_pTextPortions.reset(); // throw away cache (SwTxtNode changed) + + ClientModify(this, pOld, pNew); + + if (!GetRegisteredIn()) // removed => dispose + { + m_ListenerContainer.Disposing(); + m_bIsDisposed = true; + m_Text.Invalidate(); + } +} + uno::Reference SwXMeta::GetParentText() const { return m_pImpl->m_xParentText; } +SwXMeta::SwXMeta(SwDoc *const pDoc, ::sw::Meta *const pMeta, + uno::Reference const& xParentText, + TextRangeList_t const*const pPortions) + : m_pImpl( new SwXMeta::Impl(*this, *pDoc, pMeta, xParentText, pPortions) ) +{ +} + +SwXMeta::SwXMeta(SwDoc *const pDoc) + : m_pImpl( new SwXMeta::Impl(*this, *pDoc, 0, 0, 0) ) +{ +} + +SwXMeta::~SwXMeta() +{ +} + +uno::Reference +SwXMeta::CreateXMeta(::sw::Meta & rMeta, + uno::Reference const& i_xParent, + ::std::auto_ptr pPortions) +{ + // re-use existing SwXMeta + // #i105557#: do not iterate over the registered clients: race condition + uno::Reference xMeta(rMeta.GetXMeta()); + if (xMeta.is()) + { + if (pPortions.get()) // set cache in the XMeta to the given portions + { + const uno::Reference xUT(xMeta, uno::UNO_QUERY); + SwXMeta *const pXMeta( + ::sw::UnoTunnelGetImplementation(xUT)); + OSL_ENSURE(pXMeta, "no pXMeta?"); + // NB: the meta must always be created with the complete content + // if SwXTextPortionEnumeration is created for a selection, + // it must be checked that the Meta is contained in the selection! + pXMeta->m_pImpl->m_pTextPortions = pPortions; + // ??? is this necessary? + if (pXMeta->m_pImpl->m_xParentText.get() != i_xParent.get()) + { + OSL_ENSURE(false, "SwXMeta with different parent?"); + pXMeta->m_pImpl->m_xParentText.set(i_xParent); + } + } + return xMeta; + } + + // create new SwXMeta + SwTxtNode * const pTxtNode( rMeta.GetTxtNode() ); + OSL_ENSURE(pTxtNode, "CreateXMeta: no text node?"); + if (!pTxtNode) { return 0; } + uno::Reference xParentText(i_xParent); + if (!xParentText.is()) + { + SwTxtMeta * const pTxtAttr( rMeta.GetTxtAttr() ); + OSL_ENSURE(pTxtAttr, "CreateXMeta: no text attr?"); + if (!pTxtAttr) { return 0; } + const SwPosition aPos(*pTxtNode, *pTxtAttr->GetStart()); + xParentText.set( + SwXTextRange::CreateParentXText(pTxtNode->GetDoc(), aPos) ); + } + if (!xParentText.is()) { return 0; } + SwXMeta *const pXMeta( (RES_TXTATR_META == rMeta.GetFmtMeta()->Which()) + ? new SwXMeta (pTxtNode->GetDoc(), &rMeta, xParentText, + pPortions.release()) // temporarily un-auto_ptr :-( + : new SwXMetaField(pTxtNode->GetDoc(), &rMeta, xParentText, + pPortions.release())); + // this is why the constructor is private: need to acquire pXMeta here + xMeta.set(pXMeta); + // in order to initialize the weak pointer cache in the core object + rMeta.SetXMeta(xMeta); + return xMeta; +} + + bool SwXMeta::SetContentRange( SwTxtNode *& rpNode, xub_StrLen & rStart, xub_StrLen & rEnd ) const { - ::sw::Meta const * const pMeta( GetMeta() ); + ::sw::Meta const * const pMeta( m_pImpl->GetMeta() ); if (pMeta) { SwTxtMeta const * const pTxtAttr( pMeta->GetTxtAttr() ); @@ -657,23 +758,6 @@ bool SwXMeta::SetContentRange( return false; } -SwXMeta::SwXMeta(SwDoc *const pDoc, - uno::Reference const& xParentText, - TextRangeList_t * const pPortions, SwTxtMeta * const pHint) - : m_pImpl( new SwXMeta::Impl(*this, *pDoc, xParentText, pPortions, pHint) ) -{ - if (pHint) - { - ::sw::Meta * const pMeta( - static_cast(pHint->GetAttr()).GetMeta() ); - ASSERT(pMeta, "SwXMeta: no meta?") - if (pMeta) - { - pMeta->Add(this); - } - } -} - bool SwXMeta::CheckForOwnMemberMeta(const SwXTextRange* const pRange, const SwPaM* const pPam, bool bAbsorb) throw (lang::IllegalArgumentException, uno::RuntimeException) @@ -744,16 +828,6 @@ bool SwXMeta::CheckForOwnMemberMeta(const SwXTextRange* const pRange, return bForceExpandHints; } - -SwXMeta::SwXMeta(SwDoc *const pDoc) - : m_pImpl( new SwXMeta::Impl(*this, *pDoc, 0, 0, 0) ) -{ -} - -SwXMeta::~SwXMeta() -{ -} - const uno::Sequence< sal_Int8 > & SwXMeta::getUnoTunnelId() { static uno::Sequence< sal_Int8 > aSeq( ::CreateUnoTunnelId() ); @@ -765,14 +839,7 @@ sal_Int64 SAL_CALL SwXMeta::getSomething( const uno::Sequence< sal_Int8 > & i_rId ) throw (uno::RuntimeException) { - if ( i_rId.getLength() == 16 && - 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), - i_rId.getConstArray(), 16 ) ) - { - return sal::static_int_cast< sal_Int64 >( - reinterpret_cast< sal_IntPtr >(this) ); - } - return 0; + return ::sw::UnoTunnelImpl(i_rId, this); } // XServiceInfo @@ -782,21 +849,26 @@ SwXMeta::getImplementationName() throw (uno::RuntimeException) return C2U("SwXMeta"); } +static char const*const g_ServicesMeta[] = +{ + "com.sun.star.text.TextContent", + "com.sun.star.text.InContentMetadata", +}; +static const size_t g_nServicesMeta( + sizeof(g_ServicesMeta)/sizeof(g_ServicesMeta[0])); + sal_Bool SAL_CALL SwXMeta::supportsService(const ::rtl::OUString& rServiceName) throw (uno::RuntimeException) { - return rServiceName.equalsAscii("com.sun.star.text.TextContent") - || rServiceName.equalsAscii("com.sun.star.text.InContentMetadata"); + return ::sw::SupportsServiceImpl( + g_nServicesMeta, g_ServicesMeta, rServiceName); } uno::Sequence< ::rtl::OUString > SAL_CALL SwXMeta::getSupportedServiceNames() throw (uno::RuntimeException) { - uno::Sequence< ::rtl::OUString > aRet(2); - aRet[0] = C2U("com.sun.star.text.TextContent"); - aRet[1] = C2U("com.sun.star.text.InContentMetadata"); - return aRet; + return ::sw::GetSupportedServiceNamesImpl(g_nServicesMeta, g_ServicesMeta); } @@ -886,14 +958,10 @@ throw (lang::IllegalArgumentException, uno::RuntimeException) C2S("SwXMeta::attach(): argument is no XUnoTunnel"), static_cast< ::cppu::OWeakObject* >(this), 0); } - SwXTextRange * const pRange( - reinterpret_cast< SwXTextRange * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( - SwXTextRange::getUnoTunnelId() ))) ); - OTextCursorHelper * const pCursor( pRange ? 0 : - reinterpret_cast< OTextCursorHelper * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( - OTextCursorHelper::getUnoTunnelId() ))) ); + SwXTextRange *const pRange( + ::sw::UnoTunnelGetImplementation(xRangeTunnel)); + OTextCursorHelper *const pCursor( (pRange) ? 0 : + ::sw::UnoTunnelGetImplementation(xRangeTunnel)); if (!pRange && !pCursor) { throw lang::IllegalArgumentException( @@ -945,7 +1013,8 @@ throw (lang::IllegalArgumentException, uno::RuntimeException) static_cast< ::cppu::OWeakObject* >(this)); } - pMeta->Add(this); + pMeta->Add(m_pImpl.get()); + pMeta->SetXMeta(uno::Reference(this)); m_pImpl->m_xParentText = SwXTextRange::CreateParentXText(pDoc, *aPam.GetPoint()); @@ -1102,7 +1171,7 @@ SwXMeta::hasElements() throw (uno::RuntimeException) { vos::OGuard g(Application::GetSolarMutex()); - return GetRegisteredIn() ? sal_True : sal_False; + return m_pImpl->GetRegisteredIn() ? sal_True : sal_False; } // XEnumerationAccess @@ -1118,7 +1187,7 @@ SwXMeta::createEnumeration() throw (uno::RuntimeException) if (m_pImpl->m_bIsDescriptor) { throw uno::RuntimeException( - C2S("getAnchor(): not inserted"), + C2S("createEnumeration(): not inserted"), static_cast< ::cppu::OWeakObject* >(this)); } @@ -1147,12 +1216,12 @@ SwXMeta::createEnumeration() throw (uno::RuntimeException) // MetadatableMixin ::sfx2::Metadatable* SwXMeta::GetCoreObject() { - return const_cast< ::sw::Meta * >(GetMeta()); + return const_cast< ::sw::Meta * >(m_pImpl->GetMeta()); } uno::Reference SwXMeta::GetModel() { - ::sw::Meta const * const pMeta( GetMeta() ); + ::sw::Meta const * const pMeta( m_pImpl->GetMeta() ); if (pMeta) { SwTxtNode const * const pTxtNode( pMeta->GetTxtNode() ); @@ -1165,42 +1234,27 @@ uno::Reference SwXMeta::GetModel() return 0; } -// SwModify -void SwXMeta::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew ) -{ - m_pImpl->m_pTextPortions.reset(); // throw away cache (SwTxtNode changed) - - ClientModify(this, pOld, pNew); - - if (!GetRegisteredIn()) // removed => dispose - { - m_pImpl->m_ListenerContainer.Disposing(); - m_pImpl->m_bIsDisposed = true; - m_pImpl->m_Text.Invalidate(); - } -} - /****************************************************************** * SwXMetaField ******************************************************************/ -inline const ::sw::MetaField * SwXMetaField::GetMetaField() const +inline const ::sw::MetaField * SwXMeta::Impl::GetMetaField() const { return static_cast< const ::sw::MetaField * >(GetRegisteredIn()); } -SwXMetaField::SwXMetaField(SwDoc *const pDoc, +SwXMetaField::SwXMetaField(SwDoc *const pDoc, ::sw::Meta *const pMeta, uno::Reference const& xParentText, - TextRangeList_t * const pPortions, SwTxtMeta * const pHint) - : SwXMetaFieldBaseClass(pDoc, xParentText, pPortions, pHint) + TextRangeList_t const*const pPortions) + : SwXMetaField_Base(pDoc, pMeta, xParentText, pPortions) { - ASSERT(!pHint || RES_TXTATR_METAFIELD == pHint->Which(), + ASSERT(pMeta && dynamic_cast< ::sw::MetaField* >(pMeta), "SwXMetaField created for wrong hint!"); } SwXMetaField::SwXMetaField(SwDoc *const pDoc) - : SwXMetaFieldBaseClass(pDoc) + : SwXMetaField_Base(pDoc) { } @@ -1215,23 +1269,28 @@ SwXMetaField::getImplementationName() throw (uno::RuntimeException) return C2U("SwXMetaField"); } +static char const*const g_ServicesMetaField[] = +{ + "com.sun.star.text.TextContent", + "com.sun.star.text.TextField", + "com.sun.star.text.textfield.MetadataField", +}; +static const size_t g_nServicesMetaField( + sizeof(g_ServicesMetaField)/sizeof(g_ServicesMetaField[0])); + sal_Bool SAL_CALL SwXMetaField::supportsService(const ::rtl::OUString& rServiceName) throw (uno::RuntimeException) { - return rServiceName.equalsAscii("com.sun.star.text.TextContent") - || rServiceName.equalsAscii("com.sun.star.text.TextField") - || rServiceName.equalsAscii("com.sun.star.text.textfield.MetadataField"); + return ::sw::SupportsServiceImpl( + g_nServicesMetaField, g_ServicesMetaField, rServiceName); } uno::Sequence< ::rtl::OUString > SAL_CALL SwXMetaField::getSupportedServiceNames() throw (uno::RuntimeException) { - uno::Sequence< ::rtl::OUString > aRet(3); - aRet[0] = C2U("com.sun.star.text.TextContent"); - aRet[1] = C2U("com.sun.star.text.TextField"); - aRet[2] = C2U("com.sun.star.text.textfield.MetadataField"); - return aRet; + return ::sw::GetSupportedServiceNamesImpl( + g_nServicesMetaField, g_ServicesMetaField); } // XComponent @@ -1293,7 +1352,7 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException, vos::OGuard g(Application::GetSolarMutex()); ::sw::MetaField * const pMeta( - const_cast< ::sw::MetaField * >(GetMetaField()) ); + const_cast< ::sw::MetaField * >(m_pImpl->GetMetaField()) ); if (!pMeta) throw lang::DisposedException(); @@ -1326,7 +1385,7 @@ throw (beans::UnknownPropertyException, lang::WrappedTargetException, { vos::OGuard g(Application::GetSolarMutex()); - ::sw::MetaField const * const pMeta( GetMetaField() ); + ::sw::MetaField const * const pMeta( m_pImpl->GetMetaField() ); if (!pMeta) throw lang::DisposedException(); -- cgit From faf50e31a983c1be11d74c1b574cd6c5f63d3a4e Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 8 Jan 2010 17:13:49 +0100 Subject: swunolocking1: #i105557#: fix locking for SwXReferenceMark: add Impl struct, and use UnoImplPtr to lock destructor. move all implementation details out of header, into Impl struct. disable broken SwClient iteration. add factory function CreateXReferenceMark. use new XUnoTunnel and XServiceInfo helpers. clean up the implementation a little. --- sw/inc/unorefmark.hxx | 41 +-- sw/source/core/unocore/unoclbck.cxx | 16 +- sw/source/core/unocore/unocoll.cxx | 14 +- sw/source/core/unocore/unorefmk.cxx | 516 ++++++++++++++++++++++-------------- 4 files changed, 336 insertions(+), 251 deletions(-) (limited to 'sw') diff --git a/sw/inc/unorefmark.hxx b/sw/inc/unorefmark.hxx index 8a37b5655e9e..61b6d09df06b 100644 --- a/sw/inc/unorefmark.hxx +++ b/sw/inc/unorefmark.hxx @@ -40,16 +40,12 @@ #include -#include - -#include -#include +#include class SwDoc; -class SwPaM; +class SwModify; class SwFmtRefMark; -class SwXTextCursor; /* -----------------27.08.98 15:11------------------- @@ -65,41 +61,24 @@ typedef ::cppu::WeakImplHelper5 class SwXReferenceMark : public SwXReferenceMark_Base - , public SwClient { private: - SwEventListenerContainer aLstnrCntnr; - SwDoc* pDoc; - const SwFmtRefMark* pMark; - String sMarkName; - BOOL m_bIsDescriptor; - - BOOL IsValid() const {return 0 != GetRegisteredIn();} - void InsertRefMark( SwPaM& rPam, SwXTextCursor * pCursor ); + class Impl; + ::sw::UnoImplPtr m_pImpl; virtual ~SwXReferenceMark(); public: - SwXReferenceMark(SwDoc * pDoc, const SwFmtRefMark * pMark); - - void attachToRange( - const ::com::sun::star::uno::Reference< - ::com::sun::star::text::XTextRange >& xTextRange) - throw (::com::sun::star::lang::IllegalArgumentException, - ::com::sun::star::uno::RuntimeException); - - const SwFmtRefMark* GetMark() const {return pMark;} - const String& GetMarkName() const {return sMarkName;} - SwDoc* GetDoc() const {return pDoc;} - void Invalidate(); - - TYPEINFO(); + SwXReferenceMark(SwDoc *const pDoc, const SwFmtRefMark *const pMark); - // SwClient - virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + static SwXReferenceMark * + CreateXReferenceMark(SwDoc & rDoc, SwFmtRefMark const& rMarkFmt); + /// may return 0 + static SwXReferenceMark * + GetReferenceMark(SwModify const& rUnoCB, SwFmtRefMark const& rMarkFmt); static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId(); diff --git a/sw/source/core/unocore/unoclbck.cxx b/sw/source/core/unocore/unoclbck.cxx index 9807a8f5b3fb..1d2185b381fb 100644 --- a/sw/source/core/unocore/unoclbck.cxx +++ b/sw/source/core/unocore/unoclbck.cxx @@ -64,21 +64,9 @@ SwUnoCallBack::~SwUnoCallBack() ---------------------------------------------------------------------------*/ SwXReferenceMark* SwUnoCallBack::GetRefMark(const SwFmtRefMark& rMark) { - SwClientIter aIter( *this ); - SwXReferenceMark* pxRefMark = (SwXReferenceMark*)aIter.First( TYPE( SwXReferenceMark )); - while(pxRefMark) - { - SwDoc* pDoc = pxRefMark->GetDoc(); - if(pDoc) - { - const SwFmtRefMark* pFmt = pDoc->GetRefMark(pxRefMark->GetMarkName()); - if(pFmt == &rMark) - return pxRefMark; - } - pxRefMark = (SwXReferenceMark*)aIter.Next( ); - } - return 0; + return SwXReferenceMark::GetReferenceMark(*this, rMark); } + /* -----------------------------05.09.00 12:38-------------------------------- ---------------------------------------------------------------------------*/ diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx index 557e73c17ac4..72606237ec70 100644 --- a/sw/source/core/unocore/unocoll.cxx +++ b/sw/source/core/unocore/unocoll.cxx @@ -1946,18 +1946,10 @@ sal_Bool SwXReferenceMarks::hasElements(void) throw( uno::RuntimeException ) SwXReferenceMark* SwXReferenceMarks::GetObject( SwDoc* pDoc, const SwFmtRefMark* pMark ) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwClientIter aIter( *pDoc->GetUnoCallBack() ); - SwXReferenceMark* pxMark = (SwXReferenceMark*)aIter.First( TYPE( SwXReferenceMark )); - while(pxMark) - { - if(pxMark->GetMark() == pMark) - break; - pxMark = (SwXReferenceMark*)aIter.Next(); - } - if( !pxMark ) - pxMark = new SwXReferenceMark(pDoc, pMark); - return pxMark; + + return SwXReferenceMark::CreateXReferenceMark(*pDoc, *pMark); } + /****************************************************************** * ******************************************************************/ diff --git a/sw/source/core/unocore/unorefmk.cxx b/sw/source/core/unocore/unorefmk.cxx index 8e1d18f1dae8..39e93acd19dc 100644 --- a/sw/source/core/unocore/unorefmk.cxx +++ b/sw/source/core/unocore/unorefmk.cxx @@ -47,6 +47,7 @@ #include #include + using namespace ::com::sun::star; using ::rtl::OUString; @@ -54,81 +55,191 @@ using ::rtl::OUString; * SwXReferenceMark ******************************************************************/ -/* -----------------------------13.03.00 12:15-------------------------------- +class SwXReferenceMark::Impl + : public SwClient +{ + +public: + SwEventListenerContainer m_ListenerContainer; + bool m_bIsDescriptor; + SwDoc * m_pDoc; + const SwFmtRefMark * m_pMarkFmt; + ::rtl::OUString m_sMarkName; + + Impl( SwXReferenceMark & rThis, + SwDoc *const pDoc, SwFmtRefMark const*const pRefMark) + : SwClient((pDoc) ? pDoc->GetUnoCallBack() : 0) + , m_ListenerContainer(static_cast< ::cppu::OWeakObject* >(&rThis)) + , m_bIsDescriptor(0 == pRefMark) + , m_pDoc(pDoc) + , m_pMarkFmt(pRefMark) + { + if (pRefMark) + { + m_sMarkName = pRefMark->GetRefName(); + } + } + + bool IsValid() const { return 0 != GetRegisteredIn(); } + void InsertRefMark( SwPaM & rPam, SwXTextCursor const*const pCursor ); + void Invalidate(); + + // SwClient + virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + +}; + +/* -----------------------------07.01.00 12:51-------------------------------- ---------------------------------------------------------------------------*/ -const uno::Sequence< sal_Int8 > & SwXReferenceMark::getUnoTunnelId() +void SwXReferenceMark::Impl::Invalidate() { - static uno::Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId(); - return aSeq; + if (IsValid()) + { + const_cast(GetRegisteredIn())->Remove(this); + } + m_ListenerContainer.Disposing(); + m_pDoc = 0; + m_pMarkFmt = 0; } -/* -----------------------------10.03.00 18:04-------------------------------- - ---------------------------------------------------------------------------*/ -sal_Int64 SAL_CALL SwXReferenceMark::getSomething( const uno::Sequence< sal_Int8 >& rId ) - throw(uno::RuntimeException) +/*-- 11.12.98 10:28:37--------------------------------------------------- + + -----------------------------------------------------------------------*/ +void SwXReferenceMark::Impl::Modify(SfxPoolItem *pOld, SfxPoolItem *pNew) +{ + ClientModify(this, pOld, pNew); + + if (!GetRegisteredIn()) // removed => dispose + { + Invalidate(); + } + else if (pOld) + { + switch (pOld->Which()) + { + case RES_REFMARK_DELETED: + if (static_cast(m_pMarkFmt) == + static_cast(pOld)->pObject) + { + Invalidate(); + } + break; + } + } +} + + +/*-- 11.12.98 10:28:32--------------------------------------------------- + + -----------------------------------------------------------------------*/ +SwXReferenceMark::SwXReferenceMark( + SwDoc *const pDoc, SwFmtRefMark const*const pRefMark) + : m_pImpl( new SwXReferenceMark::Impl(*this, pDoc, pRefMark) ) +{ +} + +/*-- 11.12.98 10:28:33--------------------------------------------------- + + -----------------------------------------------------------------------*/ +SwXReferenceMark::~SwXReferenceMark() +{ +} + +SwXReferenceMark * +SwXReferenceMark::GetReferenceMark( + SwModify const& /*rUnoCB*/, SwFmtRefMark const& /*rMarkFmt*/) { - if( rId.getLength() == 16 - && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), - rId.getConstArray(), 16 ) ) + // #i105557#: do not iterate over the registered clients: race condition + // to do this properly requires the SwXReferenceMark to register at the + // SwFmtRefMark directly, not at the unocallback +#if 0 + SwClientIter aIter( rUnoCB ); + SwXReferenceMark::Impl * pXMark = + static_cast( + aIter.First( TYPE( SwXReferenceMark::Impl ) )); + while (pXMark) { - return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(this) ); + if (pXMark->m_pMarkFmt == &rMarkFmt) + { + return &pXMark->m_rThis; + } + pXMark = static_cast(aIter.Next()); } +#endif return 0; } -/* -----------------------------06.04.00 16:41-------------------------------- + +SwXReferenceMark * +SwXReferenceMark::CreateXReferenceMark( + SwDoc & rDoc, SwFmtRefMark const& rMarkFmt) +{ + SwXReferenceMark *const pXMark( + GetReferenceMark(*rDoc.GetUnoCallBack(), rMarkFmt) ); + return (pXMark) + ? pXMark + : new SwXReferenceMark(&rDoc, &rMarkFmt); +} + +/* -----------------------------13.03.00 12:15-------------------------------- ---------------------------------------------------------------------------*/ -OUString SwXReferenceMark::getImplementationName(void) throw( uno::RuntimeException ) +const uno::Sequence< sal_Int8 > & SwXReferenceMark::getUnoTunnelId() { - return C2U("SwXReferenceMark"); + static uno::Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId(); + return aSeq; } -/* -----------------------------06.04.00 16:41-------------------------------- +/* -----------------------------10.03.00 18:04-------------------------------- ---------------------------------------------------------------------------*/ -BOOL SwXReferenceMark::supportsService(const OUString& rServiceName) throw( uno::RuntimeException ) +sal_Int64 SAL_CALL +SwXReferenceMark::getSomething(const uno::Sequence< sal_Int8 >& rId) +throw (uno::RuntimeException) { - return !rServiceName.compareToAscii("com.sun.star.text.ReferenceMark")|| - !rServiceName.compareToAscii("com.sun.star.text.TextContent"); + return ::sw::UnoTunnelImpl(rId, this); } /* -----------------------------06.04.00 16:41-------------------------------- ---------------------------------------------------------------------------*/ -uno::Sequence< OUString > SwXReferenceMark::getSupportedServiceNames(void) throw( uno::RuntimeException ) +OUString SAL_CALL SwXReferenceMark::getImplementationName() +throw (uno::RuntimeException) { - uno::Sequence< OUString > aRet(2); - OUString* pArray = aRet.getArray(); - pArray[0] = C2U("com.sun.star.text.ReferenceMark"); - pArray[1] = C2U("com.sun.star.text.TextContent"); - return aRet; + return C2U("SwXReferenceMark"); } -/*-- 11.12.98 10:28:32--------------------------------------------------- +/* -----------------------------06.04.00 16:41-------------------------------- - -----------------------------------------------------------------------*/ -TYPEINIT1(SwXReferenceMark, SwClient); + ---------------------------------------------------------------------------*/ +static char const*const g_ServicesReferenceMark[] = +{ + "com.sun.star.text.TextContent", + "com.sun.star.text.ReferenceMark", +}; +static const size_t g_nServicesReferenceMark( + sizeof(g_ServicesReferenceMark)/sizeof(g_ServicesReferenceMark[0])); -SwXReferenceMark::SwXReferenceMark(SwDoc* pDc, const SwFmtRefMark* pRefMark) : - aLstnrCntnr( (text::XTextContent*)this), - pDoc(pDc), - pMark(pRefMark), - m_bIsDescriptor(0 == pRefMark) +sal_Bool SAL_CALL +SwXReferenceMark::supportsService(const OUString& rServiceName) +throw (uno::RuntimeException) { - if(pRefMark) - sMarkName = pRefMark->GetRefName(); - if(pDoc) - pDoc->GetUnoCallBack()->Add(this); + return ::sw::SupportsServiceImpl( + g_nServicesReferenceMark, g_ServicesReferenceMark, rServiceName); } -/*-- 11.12.98 10:28:33--------------------------------------------------- +/* -----------------------------06.04.00 16:41-------------------------------- - -----------------------------------------------------------------------*/ -SwXReferenceMark::~SwXReferenceMark() + ---------------------------------------------------------------------------*/ +uno::Sequence< OUString > SAL_CALL +SwXReferenceMark::getSupportedServiceNames() +throw (uno::RuntimeException) { - + return ::sw::GetSupportedServiceNamesImpl( + g_nServicesReferenceMark, g_ServicesReferenceMark); } + /* -----------------03.11.99 14:14------------------- --------------------------------------------------*/ -void SwXReferenceMark::InsertRefMark(SwPaM& rPam, SwXTextCursor * pCursor) +void SwXReferenceMark::Impl::InsertRefMark(SwPaM& rPam, + SwXTextCursor const*const pCursor) { //! in some cases when this function is called the pDoc pointer member may have become //! invalid/deleted thus we obtain the document pointer from rPaM where it should always @@ -136,12 +247,8 @@ void SwXReferenceMark::InsertRefMark(SwPaM& rPam, SwXTextCursor * pCursor) SwDoc *pDoc2 = rPam.GetDoc(); UnoActionContext aCont(pDoc2); - SwTxtAttr* pTxtAttr = 0; - SwFmtRefMark aRefMark(sMarkName); -// SfxItemSet aSet(pDoc2->GetAttrPool(), RES_TXTATR_REFMARK, RES_TXTATR_REFMARK, 0L); -// aSet.Put(aRefMark); + SwFmtRefMark aRefMark(m_sMarkName); sal_Bool bMark = *rPam.GetPoint() != *rPam.GetMark(); -// SwXTextCursor::SetCrsrAttr(rPam, aSet, 0); const bool bForceExpandHints( (!bMark && pCursor) ? pCursor->IsAtEndOfMeta() : false ); @@ -153,290 +260,309 @@ void SwXReferenceMark::InsertRefMark(SwPaM& rPam, SwXTextCursor * pCursor) pDoc2->InsertPoolItem( rPam, aRefMark, nInsertFlags ); if( bMark && *rPam.GetPoint() > *rPam.GetMark()) - rPam.Exchange(); - - if( bMark ) - pTxtAttr = rPam.GetNode()->GetTxtNode()->GetTxtAttr( - rPam.GetPoint()->nContent, RES_TXTATR_REFMARK ); - else { - pTxtAttr = rPam.GetNode()->GetTxtNode()->GetTxtAttrForCharAt( - rPam.GetPoint()->nContent.GetIndex()-1, RES_TXTATR_REFMARK ); + rPam.Exchange(); } + SwTxtAttr *const pTxtAttr = (bMark) + ? rPam.GetNode()->GetTxtNode()->GetTxtAttr( + rPam.GetPoint()->nContent, RES_TXTATR_REFMARK) + : rPam.GetNode()->GetTxtNode()->GetTxtAttrForCharAt( + rPam.GetPoint()->nContent.GetIndex() - 1, RES_TXTATR_REFMARK); + if(pTxtAttr) - pMark = &pTxtAttr->GetRefMark(); + { + m_pMarkFmt = &pTxtAttr->GetRefMark(); + } pDoc2->GetUnoCallBack()->Add(this); } -/* -----------------18.02.99 13:33------------------- - * - * --------------------------------------------------*/ -void SwXReferenceMark::attachToRange(const uno::Reference< text::XTextRange > & xTextRange) - throw( lang::IllegalArgumentException, uno::RuntimeException ) +/*-- 11.12.98 10:28:34--------------------------------------------------- + + -----------------------------------------------------------------------*/ +void SAL_CALL +SwXReferenceMark::attach(const uno::Reference< text::XTextRange > & xTextRange) +throw (lang::IllegalArgumentException, uno::RuntimeException) { - if(!m_bIsDescriptor) + vos::OGuard aGuard(Application::GetSolarMutex()); + + if (!m_pImpl->m_bIsDescriptor) + { throw uno::RuntimeException(); + } uno::Reference xRangeTunnel( xTextRange, uno::UNO_QUERY); SwXTextRange* pRange = 0; OTextCursorHelper* pCursor = 0; if(xRangeTunnel.is()) { - pRange = reinterpret_cast< SwXTextRange * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXTextRange::getUnoTunnelId()) )); - pCursor = reinterpret_cast< OTextCursorHelper * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( OTextCursorHelper::getUnoTunnelId()) )); + pRange = ::sw::UnoTunnelGetImplementation(xRangeTunnel); + pCursor = + ::sw::UnoTunnelGetImplementation(xRangeTunnel); } - SwDoc* pDocument = pRange ? (SwDoc*)pRange->GetDoc() : pCursor ? (SwDoc*)pCursor->GetDoc() : 0; - if(pDocument) + SwDoc *const pDocument = + (pRange) ? pRange->GetDoc() : ((pCursor) ? pCursor->GetDoc() : 0); + if (!pDocument) { - SwUnoInternalPaM aPam(*pDocument); - //das muss jetzt sal_True liefern - SwXTextRange::XTextRangeToSwPaM(aPam, xTextRange); - InsertRefMark(aPam, dynamic_cast(pCursor)); - m_bIsDescriptor = sal_False; - pDoc = pDocument; - pDoc->GetUnoCallBack()->Add(this); - } - else throw lang::IllegalArgumentException(); -} -/*-- 11.12.98 10:28:34--------------------------------------------------- + } - -----------------------------------------------------------------------*/ -void SwXReferenceMark::attach(const uno::Reference< text::XTextRange > & xTextRange) - throw( lang::IllegalArgumentException, uno::RuntimeException ) -{ - vos::OGuard aGuard(Application::GetSolarMutex()); - attachToRange( xTextRange ); + SwUnoInternalPaM aPam(*pDocument); + //das muss jetzt sal_True liefern + SwXTextRange::XTextRangeToSwPaM(aPam, xTextRange); + m_pImpl->InsertRefMark(aPam, dynamic_cast(pCursor)); + m_pImpl->m_bIsDescriptor = sal_False; + m_pImpl->m_pDoc = pDocument; + m_pImpl->m_pDoc->GetUnoCallBack()->Add(m_pImpl.get()); } + /*-- 11.12.98 10:28:34--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextRange > SwXReferenceMark::getAnchor(void) throw( uno::RuntimeException ) +uno::Reference< text::XTextRange > SAL_CALL +SwXReferenceMark::getAnchor() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< text::XTextRange > xRet; - if(IsValid()) + + if (m_pImpl->IsValid()) { - const SwFmtRefMark* pNewMark = pDoc->GetRefMark(sMarkName); - if(pNewMark && pNewMark == pMark) + SwFmtRefMark const*const pNewMark = + m_pImpl->m_pDoc->GetRefMark(m_pImpl->m_sMarkName); + if (pNewMark && (pNewMark == m_pImpl->m_pMarkFmt)) { - const SwTxtRefMark* pTxtMark = pMark->GetTxtRefMark(); - if(pTxtMark && - &pTxtMark->GetTxtNode().GetNodes() == &pDoc->GetNodes()) + SwTxtRefMark const*const pTxtMark = + m_pImpl->m_pMarkFmt->GetTxtRefMark(); + if (pTxtMark && + (&pTxtMark->GetTxtNode().GetNodes() == + &m_pImpl->m_pDoc->GetNodes())) { - SwTxtNode& rTxtNode = (SwTxtNode&)pTxtMark->GetTxtNode(); - SwPaM* pPam = pTxtMark->GetEnd() ? - new SwPaM( rTxtNode, *pTxtMark->GetEnd(), - rTxtNode, *pTxtMark->GetStart()) : - new SwPaM( rTxtNode, *pTxtMark->GetStart()); - - - xRet = SwXTextRange::CreateTextRangeFromPosition(pDoc, - *pPam->Start(), pPam->End()); - delete pPam; + SwTxtNode const& rTxtNode = pTxtMark->GetTxtNode(); + const ::std::auto_ptr pPam( (pTxtMark->GetEnd()) + ? new SwPaM( rTxtNode, *pTxtMark->GetEnd(), + rTxtNode, *pTxtMark->GetStart()) + : new SwPaM( rTxtNode, *pTxtMark->GetStart()) ); + + return SwXTextRange::CreateTextRangeFromPosition( + m_pImpl->m_pDoc, *pPam->Start(), pPam->End()); } } } - return xRet; + return 0; } /*-- 11.12.98 10:28:35--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXReferenceMark::dispose(void) throw( uno::RuntimeException ) +void SAL_CALL SwXReferenceMark::dispose() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(IsValid()) + if (m_pImpl->IsValid()) { - const SwFmtRefMark* pNewMark = pDoc->GetRefMark(sMarkName); - if(pNewMark && pNewMark == pMark) + SwFmtRefMark const*const pNewMark = + m_pImpl->m_pDoc->GetRefMark(m_pImpl->m_sMarkName); + if (pNewMark && (pNewMark == m_pImpl->m_pMarkFmt)) { - const SwTxtRefMark* pTxtMark = pMark->GetTxtRefMark(); - if(pTxtMark && - &pTxtMark->GetTxtNode().GetNodes() == &pDoc->GetNodes()) + SwTxtRefMark const*const pTxtMark = + m_pImpl->m_pMarkFmt->GetTxtRefMark(); + if (pTxtMark && + (&pTxtMark->GetTxtNode().GetNodes() == + &m_pImpl->m_pDoc->GetNodes())) { - SwTxtNode& rTxtNode = (SwTxtNode&)pTxtMark->GetTxtNode(); + SwTxtNode const& rTxtNode = pTxtMark->GetTxtNode(); xub_StrLen nStt = *pTxtMark->GetStart(), nEnd = pTxtMark->GetEnd() ? *pTxtMark->GetEnd() : nStt + 1; SwPaM aPam( rTxtNode, nStt, rTxtNode, nEnd ); - pDoc->DeleteAndJoin( aPam ); + m_pImpl->m_pDoc->DeleteAndJoin( aPam ); } } } - else - throw uno::RuntimeException(); + else if (m_pImpl->m_bIsDescriptor) + { + m_pImpl->Invalidate(); + } } /*-- 11.12.98 10:28:35--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXReferenceMark::addEventListener(const uno::Reference< lang::XEventListener > & aListener) throw( uno::RuntimeException ) +void SAL_CALL SwXReferenceMark::addEventListener( + const uno::Reference< lang::XEventListener > & xListener) +throw (uno::RuntimeException) { - if(!GetRegisteredIn()) + vos::OGuard g(Application::GetSolarMutex()); + + if (!m_pImpl->IsValid()) + { throw uno::RuntimeException(); - aLstnrCntnr.AddListener(aListener); + } + m_pImpl->m_ListenerContainer.AddListener(xListener); } /*-- 11.12.98 10:28:35--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXReferenceMark::removeEventListener(const uno::Reference< lang::XEventListener > & aListener) throw( uno::RuntimeException ) +void SAL_CALL SwXReferenceMark::removeEventListener( + const uno::Reference< lang::XEventListener > & xListener) +throw (uno::RuntimeException) { - if(!GetRegisteredIn() || !aLstnrCntnr.RemoveListener(aListener)) + vos::OGuard g(Application::GetSolarMutex()); + + if (!m_pImpl->IsValid() || + !m_pImpl->m_ListenerContainer.RemoveListener(xListener)) + { throw uno::RuntimeException(); + } } /*-- 11.12.98 10:28:36--------------------------------------------------- -----------------------------------------------------------------------*/ -OUString SwXReferenceMark::getName(void) throw( uno::RuntimeException ) +OUString SAL_CALL SwXReferenceMark::getName() +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(!IsValid() || !pDoc->GetRefMark(sMarkName)) + if (!m_pImpl->IsValid() || + !m_pImpl->m_pDoc->GetRefMark(m_pImpl->m_sMarkName)) { throw uno::RuntimeException(); } - return sMarkName; + return m_pImpl->m_sMarkName; } /*-- 11.12.98 10:28:36--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXReferenceMark::setName(const OUString& Name_) throw( uno::RuntimeException ) +void SAL_CALL SwXReferenceMark::setName(const OUString& rName) +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(m_bIsDescriptor) - sMarkName = String(Name_); + if (m_pImpl->m_bIsDescriptor) + { + m_pImpl->m_sMarkName = rName; + } else { - String sNewName(Name_); - if(!IsValid() || !pDoc->GetRefMark(sMarkName) || pDoc->GetRefMark(sNewName)) + if (!m_pImpl->IsValid() + || !m_pImpl->m_pDoc->GetRefMark(m_pImpl->m_sMarkName) + || m_pImpl->m_pDoc->GetRefMark(rName)) { throw uno::RuntimeException(); } - const SwFmtRefMark* pCurMark = pDoc->GetRefMark(sMarkName); - if(sNewName != sMarkName && pCurMark && pCurMark == pMark) + SwFmtRefMark const*const pCurMark = + m_pImpl->m_pDoc->GetRefMark(m_pImpl->m_sMarkName); + if ((rName != m_pImpl->m_sMarkName) + && pCurMark && (pCurMark == m_pImpl->m_pMarkFmt)) { - UnoActionContext aCont(pDoc); - const SwTxtRefMark* pTxtMark = pMark->GetTxtRefMark(); - if(pTxtMark && - &pTxtMark->GetTxtNode().GetNodes() == &pDoc->GetNodes()) + const UnoActionContext aCont(m_pImpl->m_pDoc); + SwTxtRefMark const*const pTxtMark = + m_pImpl->m_pMarkFmt->GetTxtRefMark(); + if (pTxtMark && + (&pTxtMark->GetTxtNode().GetNodes() == + &m_pImpl->m_pDoc->GetNodes())) { - SwTxtNode& rTxtNode = (SwTxtNode&)pTxtMark->GetTxtNode(); + SwTxtNode const& rTxtNode = pTxtMark->GetTxtNode(); xub_StrLen nStt = *pTxtMark->GetStart(), nEnd = pTxtMark->GetEnd() ? *pTxtMark->GetEnd() : nStt + 1; SwPaM aPam( rTxtNode, nStt, rTxtNode, nEnd ); - pDoc->DeleteAndJoin( aPam ); //! deletes the pDoc member in the SwXReferenceMark - //! The aPam will keep the correct and functional doc though + // deletes the m_pImpl->m_pDoc member in the SwXReferenceMark! + m_pImpl->m_pDoc->DeleteAndJoin( aPam ); + // The aPam will keep the correct and functional doc though - sMarkName = sNewName; + m_pImpl->m_sMarkName = rName; //create a new one - InsertRefMark( aPam, 0 ); - pDoc = aPam.GetDoc(); + m_pImpl->InsertRefMark( aPam, 0 ); + m_pImpl->m_pDoc = aPam.GetDoc(); } } } } -/* -----------------------------07.01.00 12:51-------------------------------- - - ---------------------------------------------------------------------------*/ -void SwXReferenceMark::Invalidate() -{ - if(GetRegisteredIn()) - { - ((SwModify*)GetRegisteredIn())->Remove(this); - aLstnrCntnr.Disposing(); - pDoc = 0; - pMark = 0; - } -} -/*-- 11.12.98 10:28:37--------------------------------------------------- - - -----------------------------------------------------------------------*/ -void SwXReferenceMark::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew) -{ - switch( pOld ? pOld->Which() : 0 ) - { - case RES_REMOVE_UNO_OBJECT: - case RES_OBJECTDYING: - if( (void*)GetRegisteredIn() == ((SwPtrMsgPoolItem *)pOld)->pObject ) - Invalidate(); - break; - case RES_FMT_CHG: - // wurden wir an das neue umgehaengt und wird das alte geloscht? - if( ((SwFmtChg*)pNew)->pChangedFmt == GetRegisteredIn() && - ((SwFmtChg*)pOld)->pChangedFmt->IsFmtInDTOR() ) - Invalidate(); - break; - case RES_REFMARK_DELETED: - if( (void*)pMark == ((SwPtrMsgPoolItem *)pOld)->pObject ) - Invalidate(); - break; - } -} /*-- 12.09.00 12:58:20--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< beans::XPropertySetInfo > SwXReferenceMark::getPropertySetInfo( ) throw(uno::RuntimeException) +uno::Reference< beans::XPropertySetInfo > SAL_CALL +SwXReferenceMark::getPropertySetInfo() throw (uno::RuntimeException) { + vos::OGuard g(Application::GetSolarMutex()); + static uno::Reference< beans::XPropertySetInfo > xRef = - aSwMapProvider.GetPropertySet(PROPERTY_MAP_PARAGRAPH_EXTENSIONS)->getPropertySetInfo(); + aSwMapProvider.GetPropertySet(PROPERTY_MAP_PARAGRAPH_EXTENSIONS) + ->getPropertySetInfo(); return xRef; } /*-- 12.09.00 12:58:20--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXReferenceMark::setPropertyValue( +void SAL_CALL SwXReferenceMark::setPropertyValue( const OUString& /*rPropertyName*/, const uno::Any& /*rValue*/ ) - throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +throw (beans::UnknownPropertyException, beans::PropertyVetoException, + lang::IllegalArgumentException, lang::WrappedTargetException, + uno::RuntimeException) { throw lang::IllegalArgumentException(); } /*-- 12.09.00 12:58:20--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Any SwXReferenceMark::getPropertyValue( const OUString& rPropertyName ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +uno::Any SAL_CALL +SwXReferenceMark::getPropertyValue(const OUString& rPropertyName) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { + // does not seem to need SolarMutex uno::Any aRet; if(!SwXParagraph::getDefaultTextContentValue(aRet, rPropertyName)) + { throw beans::UnknownPropertyException(); + } return aRet; } /*-- 12.09.00 12:58:20--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXReferenceMark::addPropertyChangeListener( - const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/ ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +void SAL_CALL SwXReferenceMark::addPropertyChangeListener( + const OUString& /*rPropertyName*/, + const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { + OSL_ENSURE(false, + "SwXReferenceMark::addPropertyChangeListener(): not implemented"); } /*-- 12.09.00 12:58:20--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXReferenceMark::removePropertyChangeListener( - const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/ ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +void SAL_CALL SwXReferenceMark::removePropertyChangeListener( + const OUString& /*rPropertyName*/, + const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { + OSL_ENSURE(false, + "SwXReferenceMark::removePropertyChangeListener(): not implemented"); } /*-- 12.09.00 12:58:20--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXReferenceMark::addVetoableChangeListener( const OUString& /*rPropertyName*/, - const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/ ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +void SAL_CALL SwXReferenceMark::addVetoableChangeListener( + const OUString& /*rPropertyName*/, + const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { + OSL_ENSURE(false, + "SwXReferenceMark::addVetoableChangeListener(): not implemented"); } /*-- 12.09.00 12:58:21--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXReferenceMark::removeVetoableChangeListener( - const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/ ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +void SAL_CALL SwXReferenceMark::removeVetoableChangeListener( + const OUString& /*rPropertyName*/, + const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { + OSL_ENSURE(false, + "SwXReferenceMark::removeVetoableChangeListener(): not implemented"); } #include -- cgit From 440e521dad8c97e939460af857c6a851b220c52e Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 8 Jan 2010 17:13:50 +0100 Subject: swunolocking1: #i105557#: fix locking for SwXBookmark: add Impl struct, and use UnoImplPtr to lock destructor. move all implementation details out of header, into Impl struct. replace broken SwClient iteration with a WeakReference in sw::mark::MarkBase. make constructor protected, and add factory function CreateXBookmark. use new XUnoTunnel and XServiceInfo helpers. clean up the implementation a little. remove SwXBookmarks::GetObject(). --- sw/inc/unobookmark.hxx | 48 ++-- sw/inc/unocoll.hxx | 1 - sw/source/core/crsr/bookmrk.cxx | 30 +-- sw/source/core/inc/bookmrk.hxx | 24 +- sw/source/core/unocore/unobkm.cxx | 480 ++++++++++++++++++++++----------- sw/source/core/unocore/unocoll.cxx | 31 +-- sw/source/core/unocore/unoportenum.cxx | 15 +- sw/source/ui/uno/unotxvw.cxx | 17 +- 8 files changed, 399 insertions(+), 247 deletions(-) (limited to 'sw') diff --git a/sw/inc/unobookmark.hxx b/sw/inc/unobookmark.hxx index 2b16d7828001..46d0054551b7 100644 --- a/sw/inc/unobookmark.hxx +++ b/sw/inc/unobookmark.hxx @@ -41,12 +41,10 @@ #include -#include #include +#include #include -#include -#include class SwDoc; @@ -63,33 +61,15 @@ typedef ::cppu::ImplInheritanceHelper5 class SwXBookmark : public SwXBookmark_Base - , private SwClient { private: - SwEventListenerContainer m_aLstnrCntnr; - SwDoc* m_pDoc; - String m_aName; - ::sw::mark::IMark* m_pRegisteredBookmark; - - void registerInMark(::sw::mark::IMark* const pBkmk); + class Impl; + ::sw::UnoImplPtr m_pImpl; protected: - virtual ~SwXBookmark(); - -public: - - SwXBookmark(::sw::mark::IMark* pMark = 0, SwDoc* pDoc = 0); - - const ::sw::mark::IMark* GetBookmark() const - { return m_pRegisteredBookmark; } - ::sw::mark::IMark* GetBookmark() - { return m_pRegisteredBookmark; } - SwDoc* GetDoc() - { return m_pDoc; } - void attachToRangeEx( const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xTextRange, @@ -102,10 +82,26 @@ public: throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); - TYPEINFO(); + const ::sw::mark::IMark* GetBookmark() const; - // SwClient - virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew ); + virtual ~SwXBookmark(); + + /// @param pDoc and pMark != 0, but not & because of ImplInheritanceHelper + SwXBookmark(::sw::mark::IMark *const pMark, SwDoc *const pDoc); + +public: + + /// descriptor + SwXBookmark(); + + static ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextContent> + CreateXBookmark(SwDoc & rDoc, ::sw::mark::IMark & rBookmark); + + /// @return IMark for this, but only if it lives in pDoc + static ::sw::mark::IMark const* GetBookmarkInDoc(SwDoc const*const pDoc, + const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XUnoTunnel> & xUT); // MetadatableMixin virtual ::sfx2::Metadatable* GetCoreObject(); diff --git a/sw/inc/unocoll.hxx b/sw/inc/unocoll.hxx index b630668f8965..f4d54a55adca 100644 --- a/sw/inc/unocoll.hxx +++ b/sw/inc/unocoll.hxx @@ -481,7 +481,6 @@ class SwXBookmarks : public SwCollectionBaseClass, virtual BOOL SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException ); virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException ); - static SwXBookmark* GetObject( ::sw::mark::IMark& rBkm, SwDoc* pDoc); }; class SwXNumberingRulesCollection : public cppu::WeakImplHelper1 diff --git a/sw/source/core/crsr/bookmrk.cxx b/sw/source/core/crsr/bookmrk.cxx index 1028c7b2b432..a9321324be3a 100644 --- a/sw/source/core/crsr/bookmrk.cxx +++ b/sw/source/core/crsr/bookmrk.cxx @@ -49,6 +49,7 @@ SV_IMPL_REF( SwServerObject ) using namespace ::sw::mark; +using namespace ::com::sun::star; namespace { @@ -147,6 +148,16 @@ namespace sw { namespace mark return aResult.append(nCount++).append(sUniquePostfix).makeStringAndClear(); } + // SwClient + void MarkBase::Modify(SfxPoolItem *pOld, SfxPoolItem *pNew) + { + SwModify::Modify(pOld, pNew); + if (pOld && (RES_REMOVE_UNO_OBJECT == pOld->Which())) + { // invalidate cached uno object + SetXBookmark(uno::Reference(0)); + } + } + NavigatorReminder::NavigatorReminder(const SwPaM& rPaM) : MarkBase(rPaM, our_sNamePrefix) @@ -240,24 +251,13 @@ namespace sw { namespace mark return !pDoc->IsInHeaderFooter( SwNodeIndex(GetMarkPos().nNode) ); } - ::com::sun::star::uno::Reference< ::com::sun::star::rdf::XMetadatable > - Bookmark::MakeUnoObject() + uno::Reference< rdf::XMetadatable > Bookmark::MakeUnoObject() { - // re-use existing SwXBookmark - SwClientIter iter( *this ); - SwClient * pClient( iter.First( TYPE( SwXBookmark ) ) ); - while (pClient) { - SwXBookmark *const pBookmark( dynamic_cast(pClient) ); - if (pBookmark && pBookmark->GetCoreObject() == this) { - return pBookmark; - } - pClient = iter.Next(); - } - - // create new SwXBookmark SwDoc *const pDoc( GetMarkPos().GetDoc() ); OSL_ENSURE(pDoc, "Bookmark::MakeUnoObject: no doc?"); - return new SwXBookmark(this, pDoc); + const uno::Reference< rdf::XMetadatable> xMeta( + SwXBookmark::CreateXBookmark(*pDoc, *this), uno::UNO_QUERY); + return xMeta; } diff --git a/sw/source/core/inc/bookmrk.hxx b/sw/source/core/inc/bookmrk.hxx index 18f8860ecab9..313df12fddb7 100644 --- a/sw/source/core/inc/bookmrk.hxx +++ b/sw/source/core/inc/bookmrk.hxx @@ -31,12 +31,20 @@ #ifndef _BOOKMRK_HXX #define _BOOKMRK_HXX -#include +#include + #include #include #include +#include + + +namespace com { namespace sun { namespace star { + namespace text { class XTextContent; } +} } } + struct SwPosition; // fwd Decl. wg. UI class SwDoc; @@ -90,6 +98,17 @@ namespace sw { namespace mark {} virtual ~MarkBase(); + + // SwClient + virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew ); + + const ::com::sun::star::uno::WeakReference< + ::com::sun::star::text::XTextContent> & GetXBookmark() const + { return m_wXBookmark; } + void SetXBookmark(::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextContent> const& xBkmk) + { m_wXBookmark = xBkmk; } + protected: MarkBase(const SwPaM& rPaM, const ::rtl::OUString& rName); @@ -97,6 +116,9 @@ namespace sw { namespace mark ::boost::scoped_ptr m_pPos2; ::rtl::OUString m_aName; static ::rtl::OUString GenerateNewName(const ::rtl::OUString& rPrefix); + + ::com::sun::star::uno::WeakReference< + ::com::sun::star::text::XTextContent> m_wXBookmark; }; class NavigatorReminder diff --git a/sw/source/core/unocore/unobkm.cxx b/sw/source/core/unocore/unobkm.cxx index 282ae6b389a8..86b8b3ee8403 100644 --- a/sw/source/core/unocore/unobkm.cxx +++ b/sw/source/core/unocore/unobkm.cxx @@ -34,11 +34,13 @@ #include #include #include + #include #include #include #include #include +#include #include #include #include @@ -52,13 +54,8 @@ using namespace ::com::sun::star; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::text; -using namespace ::com::sun::star::container; -using namespace ::com::sun::star::beans; using ::rtl::OUString; -using ::rtl::OUStringBuffer; + namespace { @@ -66,7 +63,7 @@ namespace { static const OUString sStart = OUString(String(SW_RES(STR_START_QUOTE))); static const OUString sEnd = OUString(String(SW_RES(STR_END_QUOTE))); - OUStringBuffer sBuf(64); + ::rtl::OUStringBuffer sBuf(64); return sBuf.append(sStart).append(rName).append(sEnd).makeStringAndClear(); } } @@ -74,184 +71,307 @@ namespace /****************************************************************** * SwXBookmark ******************************************************************/ -TYPEINIT1(SwXBookmark, SwClient) -void SwXBookmark::registerInMark(::sw::mark::IMark* const pBkmk) +class SwXBookmark::Impl + : public SwClient +{ + +public: + SwEventListenerContainer m_ListenerContainer; + SwDoc * m_pDoc; + ::sw::mark::IMark * m_pRegisteredBookmark; + ::rtl::OUString m_sMarkName; + + + Impl( SwXBookmark & rThis, + SwDoc *const pDoc, ::sw::mark::IMark *const /*pBookmark*/) + : SwClient() + , m_ListenerContainer(static_cast< ::cppu::OWeakObject* >(&rThis)) + , m_pDoc(pDoc) + , m_pRegisteredBookmark(0) + { + // DO NOT regiserInMark here! (because SetXBookmark would delete rThis) + } + + void registerInMark(SwXBookmark & rThis, ::sw::mark::IMark *const pBkmk); + + // SwClient + virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + +}; + +void SwXBookmark::Impl::Modify(SfxPoolItem *pOld, SfxPoolItem *pNew) +{ + ClientModify(this, pOld, pNew); + if (!GetRegisteredIn()) + { + m_pRegisteredBookmark = NULL; + m_pDoc = NULL; + m_ListenerContainer.Disposing(); + } +} + +void SwXBookmark::Impl::registerInMark(SwXBookmark & rThis, + ::sw::mark::IMark *const pBkmk) { if (pBkmk) { pBkmk->Add(this); + ::sw::mark::MarkBase *const pMarkBase( + dynamic_cast< ::sw::mark::MarkBase * >(pBkmk)); + OSL_ENSURE(pMarkBase, "registerInMark: no MarkBase?"); + if (pMarkBase) + { + const uno::Reference xBookmark(& rThis); + pMarkBase->SetXBookmark(xBookmark); + } } else if (m_pRegisteredBookmark) { - m_aName = m_pRegisteredBookmark->GetName(); + m_sMarkName = m_pRegisteredBookmark->GetName(); m_pRegisteredBookmark->Remove(this); } m_pRegisteredBookmark = pBkmk; } -const uno::Sequence< sal_Int8 > & SwXBookmark::getUnoTunnelId() + +const ::sw::mark::IMark* SwXBookmark::GetBookmark() const { - static uno::Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId(); - return aSeq; + return m_pImpl->m_pRegisteredBookmark; } -sal_Int64 SAL_CALL SwXBookmark::getSomething( const uno::Sequence< sal_Int8 >& rId ) - throw(uno::RuntimeException) +SwXBookmark::SwXBookmark(::sw::mark::IMark *const pBkmk, SwDoc *const pDoc) + : m_pImpl( new SwXBookmark::Impl(*this, pDoc, pBkmk) ) { - if( rId.getLength() == 16 - && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), rId.getConstArray(), 16 ) ) +} + +SwXBookmark::SwXBookmark() + : m_pImpl( new SwXBookmark::Impl(*this, 0, 0) ) +{ +} + +SwXBookmark::~SwXBookmark() +{ +} + +uno::Reference +SwXBookmark::CreateXBookmark(SwDoc & rDoc, ::sw::mark::IMark & rBookmark) +{ + // #i105557#: do not iterate over the registered clients: race condition + ::sw::mark::MarkBase *const pMarkBase( + dynamic_cast< ::sw::mark::MarkBase * >(&rBookmark)); + OSL_ENSURE(pMarkBase, "CreateXBookmark: no MarkBase?"); + if (!pMarkBase) { return 0; } + uno::Reference xBookmark(pMarkBase->GetXBookmark()); + if (!xBookmark.is()) { - return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(this) ); + // FIXME: These belong in XTextFieldsSupplier + //if (dynamic_cast< ::sw::mark::TextFieldmark* >(&rBkmk)) + // pXBkmk = new SwXFieldmark(false, &rBkmk, pDoc); + //else if (dynamic_cast< ::sw::mark::CheckboxFieldmark* >(&rBkmk)) + // pXBkmk = new SwXFieldmark(true, &rBkmk, pDoc); + //else + OSL_ENSURE( + dynamic_cast< ::sw::mark::IBookmark* >(&rBookmark), + "" + "SwXBookmark requested for non-bookmark mark."); + SwXBookmark *const pXBookmark = new SwXBookmark(&rBookmark, &rDoc); + xBookmark.set(pXBookmark); + pXBookmark->m_pImpl->registerInMark(*pXBookmark, pMarkBase); + } + return xBookmark; +} + +::sw::mark::IMark const* SwXBookmark::GetBookmarkInDoc(SwDoc const*const pDoc, + const uno::Reference< lang::XUnoTunnel> & xUT) +{ + SwXBookmark *const pXBkm( + ::sw::UnoTunnelGetImplementation(xUT)); + if (pXBkm && (pDoc == pXBkm->m_pImpl->m_pDoc)) + { + return pXBkm->m_pImpl->m_pRegisteredBookmark; } return 0; } -SwXBookmark::SwXBookmark(::sw::mark::IMark* pBkmk, SwDoc* pDoc) - : m_aLstnrCntnr((text::XTextContent*)this) - , m_pDoc(pDoc) - , m_pRegisteredBookmark(NULL) +const uno::Sequence< sal_Int8 > & SwXBookmark::getUnoTunnelId() { - registerInMark(pBkmk); + static uno::Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId(); + return aSeq; } -SwXBookmark::~SwXBookmark() -{ } +sal_Int64 SAL_CALL +SwXBookmark::getSomething(const uno::Sequence< sal_Int8 >& rId) +throw (uno::RuntimeException) +{ + return ::sw::UnoTunnelImpl(rId, this); +} void SwXBookmark::attachToRangeEx( const uno::Reference< text::XTextRange > & xTextRange, IDocumentMarkAccess::MarkType eType) - throw(lang::IllegalArgumentException, uno::RuntimeException) +throw (lang::IllegalArgumentException, uno::RuntimeException) { - if(m_pRegisteredBookmark) + if (m_pImpl->m_pRegisteredBookmark) + { throw uno::RuntimeException(); + } - uno::Reference xRangeTunnel( xTextRange, uno::UNO_QUERY); + const uno::Reference xRangeTunnel( + xTextRange, uno::UNO_QUERY); SwXTextRange* pRange = 0; OTextCursorHelper* pCursor = 0; if(xRangeTunnel.is()) { + pRange = ::sw::UnoTunnelGetImplementation(xRangeTunnel); + pCursor = + ::sw::UnoTunnelGetImplementation(xRangeTunnel); + } - pRange = reinterpret_cast< SwXTextRange * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXTextRange::getUnoTunnelId() ))); - pCursor = reinterpret_cast< OTextCursorHelper * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( OTextCursorHelper::getUnoTunnelId() ))); + SwDoc *const pDoc = + (pRange) ? pRange->GetDoc() : ((pCursor) ? pCursor->GetDoc() : 0); + if (!pDoc) + { + throw lang::IllegalArgumentException(); } - SwDoc* pDc = pRange ? (SwDoc*)pRange->GetDoc() : pCursor ? - (SwDoc*)pCursor->GetDoc() : 0; - if(pDc) + m_pImpl->m_pDoc = pDoc; + SwUnoInternalPaM aPam(*m_pImpl->m_pDoc); + SwXTextRange::XTextRangeToSwPaM(aPam, xTextRange); + UnoActionContext aCont(m_pImpl->m_pDoc); + if (!m_pImpl->m_sMarkName.getLength()) { - m_pDoc = pDc; - SwUnoInternalPaM aPam(*m_pDoc); - SwXTextRange::XTextRangeToSwPaM(aPam, xTextRange); - UnoActionContext aCont(m_pDoc); - if(!m_aName.Len()) - m_aName = OUString::createFromAscii("Bookmark"); - if(eType == IDocumentMarkAccess::BOOKMARK && ::sw::mark::CrossRefNumItemBookmark::IsLegalName(m_aName)) - eType = IDocumentMarkAccess::CROSSREF_NUMITEM_BOOKMARK; - else if(eType == IDocumentMarkAccess::BOOKMARK && ::sw::mark::CrossRefHeadingBookmark::IsLegalName(m_aName)) - eType = IDocumentMarkAccess::CROSSREF_HEADING_BOOKMARK; - registerInMark(m_pDoc->getIDocumentMarkAccess()->makeMark(aPam, m_aName, eType)); - // --> OD 2007-10-23 #i81002# - // Check, if bookmark has been created. - // E.g., the creation of a cross-reference bookmark is suppress, - // if the PaM isn't a valid one for cross-reference bookmarks. - if(!m_pRegisteredBookmark) - { - OSL_ENSURE(false, - "" - " - could not create Mark."); - throw lang::IllegalArgumentException(); - } - // <-- + m_pImpl->m_sMarkName = OUString::createFromAscii("Bookmark"); } - else + if ((eType == IDocumentMarkAccess::BOOKMARK) && + ::sw::mark::CrossRefNumItemBookmark::IsLegalName(m_pImpl->m_sMarkName)) + { + eType = IDocumentMarkAccess::CROSSREF_NUMITEM_BOOKMARK; + } + else if ((eType == IDocumentMarkAccess::BOOKMARK) && + ::sw::mark::CrossRefHeadingBookmark::IsLegalName(m_pImpl->m_sMarkName)) + { + eType = IDocumentMarkAccess::CROSSREF_HEADING_BOOKMARK; + } + m_pImpl->registerInMark(*this, + m_pImpl->m_pDoc->getIDocumentMarkAccess()->makeMark( + aPam, m_pImpl->m_sMarkName, eType)); + // --> OD 2007-10-23 #i81002# + // Check, if bookmark has been created. + // E.g., the creation of a cross-reference bookmark is suppress, + // if the PaM isn't a valid one for cross-reference bookmarks. + if (!m_pImpl->m_pRegisteredBookmark) + { + OSL_ENSURE(false, + "" + " - could not create Mark."); throw lang::IllegalArgumentException(); + } + // <-- } -void SwXBookmark::attachToRange(const uno::Reference< text::XTextRange > & xTextRange) - throw( lang::IllegalArgumentException, uno::RuntimeException ) +void SwXBookmark::attachToRange( + const uno::Reference< text::XTextRange > & xTextRange) +throw (lang::IllegalArgumentException, uno::RuntimeException) { attachToRangeEx(xTextRange, IDocumentMarkAccess::BOOKMARK); } -void SwXBookmark::attach(const uno::Reference< text::XTextRange > & xTextRange) - throw( lang::IllegalArgumentException, uno::RuntimeException ) +void SAL_CALL +SwXBookmark::attach(const uno::Reference< text::XTextRange > & xTextRange) +throw (lang::IllegalArgumentException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); attachToRange( xTextRange ); } -uno::Reference< text::XTextRange > SwXBookmark::getAnchor(void) - throw( uno::RuntimeException ) +uno::Reference< text::XTextRange > SAL_CALL +SwXBookmark::getAnchor() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< text::XTextRange > aRet; - if(m_pRegisteredBookmark) - aRet = SwXTextRange::CreateTextRangeFromPosition( - m_pDoc, - m_pRegisteredBookmark->GetMarkPos(), - m_pRegisteredBookmark->IsExpanded() ? &m_pRegisteredBookmark->GetOtherMarkPos() : NULL); - else + + if (!m_pImpl->m_pRegisteredBookmark) + { throw uno::RuntimeException(); - return aRet; + } + return SwXTextRange::CreateTextRangeFromPosition( + m_pImpl->m_pDoc, + m_pImpl->m_pRegisteredBookmark->GetMarkPos(), + (m_pImpl->m_pRegisteredBookmark->IsExpanded()) + ? &m_pImpl->m_pRegisteredBookmark->GetOtherMarkPos() : NULL); } -void SwXBookmark::dispose(void) - throw( uno::RuntimeException ) +void SAL_CALL SwXBookmark::dispose() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(m_pRegisteredBookmark) - GetDoc()->getIDocumentMarkAccess()->deleteMark(m_pRegisteredBookmark); - else - throw uno::RuntimeException(); + if (m_pImpl->m_pRegisteredBookmark) + { + m_pImpl->m_pDoc->getIDocumentMarkAccess()->deleteMark( + m_pImpl->m_pRegisteredBookmark); + } } -void SwXBookmark::addEventListener(const uno::Reference< lang::XEventListener > & aListener) - throw( uno::RuntimeException ) +void SAL_CALL SwXBookmark::addEventListener( + const uno::Reference< lang::XEventListener > & xListener) +throw (uno::RuntimeException) { - if(!m_pRegisteredBookmark) + vos::OGuard g(Application::GetSolarMutex()); + + if (!m_pImpl->m_pRegisteredBookmark) + { throw uno::RuntimeException(); - m_aLstnrCntnr.AddListener(aListener); + } + m_pImpl->m_ListenerContainer.AddListener(xListener); } -void SwXBookmark::removeEventListener(const uno::Reference< lang::XEventListener > & aListener) - throw( uno::RuntimeException ) +void SAL_CALL SwXBookmark::removeEventListener( + const uno::Reference< lang::XEventListener > & xListener) +throw (uno::RuntimeException) { - if(!m_pRegisteredBookmark || !m_aLstnrCntnr.RemoveListener(aListener)) + vos::OGuard g(Application::GetSolarMutex()); + + if (!m_pImpl->m_pRegisteredBookmark || + !m_pImpl->m_ListenerContainer.RemoveListener(xListener)) + { throw uno::RuntimeException(); + } } -OUString SwXBookmark::getName(void) - throw(uno::RuntimeException) +OUString SAL_CALL SwXBookmark::getName() +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - OUString sRet; - if(m_pRegisteredBookmark) - sRet = m_pRegisteredBookmark->GetName(); - else - sRet = m_aName; - return sRet; + + return (m_pImpl->m_pRegisteredBookmark) + ? m_pImpl->m_pRegisteredBookmark->GetName() + : m_pImpl->m_sMarkName; } -void SwXBookmark::setName(const OUString& rName) - throw(uno::RuntimeException) +void SAL_CALL SwXBookmark::setName(const OUString& rName) +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(!m_pRegisteredBookmark) - m_aName = rName; - if(!m_pRegisteredBookmark || getName() == rName) + + if (!m_pImpl->m_pRegisteredBookmark) + { + m_pImpl->m_sMarkName = rName; + } + if (!m_pImpl->m_pRegisteredBookmark || (getName() == rName)) + { return; - IDocumentMarkAccess* const pMarkAccess = m_pDoc->getIDocumentMarkAccess(); + } + IDocumentMarkAccess *const pMarkAccess = + m_pImpl->m_pDoc->getIDocumentMarkAccess(); if(pMarkAccess->findMark(rName) != pMarkAccess->getMarksEnd()) + { throw uno::RuntimeException(); + } - SwPaM aPam(m_pRegisteredBookmark->GetMarkPos()); - if(m_pRegisteredBookmark->IsExpanded()) + SwPaM aPam(m_pImpl->m_pRegisteredBookmark->GetMarkPos()); + if (m_pImpl->m_pRegisteredBookmark->IsExpanded()) { aPam.SetMark(); - *aPam.GetMark() = m_pRegisteredBookmark->GetOtherMarkPos(); + *aPam.GetMark() = m_pImpl->m_pRegisteredBookmark->GetOtherMarkPos(); } SwRewriter aRewriter; @@ -259,114 +379,145 @@ void SwXBookmark::setName(const OUString& rName) aRewriter.AddRule(UNDO_ARG2, SW_RES(STR_YIELDS)); aRewriter.AddRule(UNDO_ARG3, lcl_QuoteName(rName)); - m_pDoc->StartUndo(UNDO_BOOKMARK_RENAME, &aRewriter); - pMarkAccess->renameMark(m_pRegisteredBookmark, rName); - m_pDoc->EndUndo(UNDO_BOOKMARK_RENAME, NULL); + m_pImpl->m_pDoc->StartUndo(UNDO_BOOKMARK_RENAME, &aRewriter); + pMarkAccess->renameMark(m_pImpl->m_pRegisteredBookmark, rName); + m_pImpl->m_pDoc->EndUndo(UNDO_BOOKMARK_RENAME, NULL); } -OUString SwXBookmark::getImplementationName(void) throw( uno::RuntimeException ) +OUString SAL_CALL +SwXBookmark::getImplementationName() throw (uno::RuntimeException) { return OUString::createFromAscii("SwXBookmark"); } -sal_Bool SwXBookmark::supportsService(const OUString& rServiceName) - throw( uno::RuntimeException ) +static char const*const g_ServicesBookmark[] = { - return !rServiceName.compareToAscii("com.sun.star.text.Bookmark") || - !rServiceName.compareToAscii("com.sun.star.document.LinkTarget") || - !rServiceName.compareToAscii("com.sun.star.text.TextContent"); -} - -uno::Sequence< OUString > SwXBookmark::getSupportedServiceNames(void) - throw( uno::RuntimeException ) + "com.sun.star.text.TextContent", + "com.sun.star.text.Bookmark", + "com.sun.star.document.LinkTarget", +}; +static const size_t g_nServicesBookmark( + sizeof(g_ServicesBookmark)/sizeof(g_ServicesBookmark[0])); + +sal_Bool SAL_CALL SwXBookmark::supportsService(const OUString& rServiceName) +throw (uno::RuntimeException) { - uno::Sequence< OUString > aRet(3); - aRet[0] = OUString::createFromAscii("com.sun.star.text.Bookmark"); - aRet[1] = OUString::createFromAscii("com.sun.star.document.LinkTarget"); - aRet[2] = OUString::createFromAscii("com.sun.star.text.TextContent"); - return aRet; + return ::sw::SupportsServiceImpl( + g_nServicesBookmark, g_ServicesBookmark, rServiceName); } -void SwXBookmark::Modify(SfxPoolItem *pOld, SfxPoolItem *pNew) +uno::Sequence< OUString > SAL_CALL +SwXBookmark::getSupportedServiceNames() throw (uno::RuntimeException) { - ClientModify(this, pOld, pNew); - if(!GetRegisteredIn()) - { - m_pRegisteredBookmark = NULL; - m_pDoc = NULL; - m_aLstnrCntnr.Disposing(); - } + return ::sw::GetSupportedServiceNamesImpl( + g_nServicesBookmark, g_ServicesBookmark); } // MetadatableMixin ::sfx2::Metadatable* SwXBookmark::GetCoreObject() { - return dynamic_cast< ::sfx2::Metadatable* >( GetBookmark() ); + return dynamic_cast< ::sfx2::Metadatable* >(m_pImpl->m_pRegisteredBookmark); } uno::Reference SwXBookmark::GetModel() { - if (GetDoc()) + if (m_pImpl->m_pDoc) { - SwDocShell const * const pShell( GetDoc()->GetDocShell() ); + SwDocShell const * const pShell( m_pImpl->m_pDoc->GetDocShell() ); return (pShell) ? pShell->GetModel() : 0; } return 0; } -uno::Reference< beans::XPropertySetInfo > SwXBookmark::getPropertySetInfo(void) - throw( uno::RuntimeException ) +uno::Reference< beans::XPropertySetInfo > SAL_CALL +SwXBookmark::getPropertySetInfo() throw (uno::RuntimeException) { - static uno::Reference< beans::XPropertySetInfo > aRef; - if(!aRef.is()) - { - aRef = aSwMapProvider.GetPropertySet(PROPERTY_MAP_BOOKMARK)->getPropertySetInfo(); - } - return aRef; + vos::OGuard g(Application::GetSolarMutex()); + + static uno::Reference< beans::XPropertySetInfo > xRef( + aSwMapProvider.GetPropertySet(PROPERTY_MAP_BOOKMARK) + ->getPropertySetInfo() ); + return xRef; } -void SwXBookmark::setPropertyValue(const OUString& PropertyName, const uno::Any& /*aValue*/) - throw( beans::UnknownPropertyException, - beans::PropertyVetoException, - lang::IllegalArgumentException, - lang::WrappedTargetException, - uno::RuntimeException ) +void SAL_CALL +SwXBookmark::setPropertyValue(const OUString& PropertyName, + const uno::Any& /*rValue*/) +throw (beans::UnknownPropertyException, beans::PropertyVetoException, + lang::IllegalArgumentException, lang::WrappedTargetException, + uno::RuntimeException) { // nothing to set here - throw IllegalArgumentException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + PropertyName, static_cast < cppu::OWeakObject * > ( this ), 0 ); + throw lang::IllegalArgumentException( ::rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("Property is read-only: ")) + + PropertyName, static_cast< cppu::OWeakObject * >(this), 0 ); } -uno::Any SwXBookmark::getPropertyValue(const OUString& rPropertyName) - throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +uno::Any SAL_CALL SwXBookmark::getPropertyValue(const OUString& rPropertyName) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { + vos::OGuard g(Application::GetSolarMutex()); + uno::Any aRet; if(!SwXParagraph::getDefaultTextContentValue(aRet, rPropertyName)) { if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_LINK_DISPLAY_NAME))) + { aRet <<= getName(); + } } return aRet; } -void SwXBookmark::addPropertyChangeListener(const OUString& /*PropertyName*/, - const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/) - throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) -{ } +void SAL_CALL +SwXBookmark::addPropertyChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) +{ + OSL_ENSURE(false, + "SwXBookmark::addPropertyChangeListener(): not implemented"); +} -void SwXBookmark::removePropertyChangeListener(const OUString& /*PropertyName*/, - const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/) - throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) -{ } +void SAL_CALL +SwXBookmark::removePropertyChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) +{ + OSL_ENSURE(false, + "SwXBookmark::removePropertyChangeListener(): not implemented"); +} -void SwXBookmark::addVetoableChangeListener(const OUString& /*PropertyName*/, - const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/) - throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) -{ } +void SAL_CALL +SwXBookmark::addVetoableChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) +{ + OSL_ENSURE(false, + "SwXBookmark::addVetoableChangeListener(): not implemented"); +} -void SwXBookmark::removeVetoableChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/) - throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) -{ } +void SAL_CALL +SwXBookmark::removeVetoableChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) +{ + OSL_ENSURE(false, + "SwXBookmark::removeVetoableChangeListener(): not implemented"); +} + +/****************************************************************** + * SwXFieldmark + ******************************************************************/ SwXFieldmark::SwXFieldmark(bool _isReplacementObject, ::sw::mark::IMark* pBkm, SwDoc* pDc) : SwXFieldmark_Base(pBkm, pDc) @@ -436,3 +587,4 @@ void SAL_CALL SwXFieldmark::setDescription( const ::rtl::OUString& description ) else throw uno::RuntimeException(); } + diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx index 72606237ec70..87f96ba72346 100644 --- a/sw/source/core/unocore/unocoll.cxx +++ b/sw/source/core/unocore/unocoll.cxx @@ -1529,8 +1529,9 @@ uno::Any SwXBookmarks::getByIndex(sal_Int32 nIndex) uno::Any aRet; ::sw::mark::IMark* pBkmk = pMarkAccess->getBookmarksBegin()[nIndex].get(); - uno::Reference< XTextContent > xRef = GetObject(*pBkmk, GetDoc()); - aRet.setValue(&xRef, ::getCppuType((uno::Reference*)0)); + const uno::Reference< text::XTextContent > xRef = + SwXBookmark::CreateXBookmark(*GetDoc(), *pBkmk); + aRet <<= xRef; return aRet; } @@ -1547,8 +1548,9 @@ uno::Any SwXBookmarks::getByName(const rtl::OUString& rName) throw NoSuchElementException(); uno::Any aRet; - uno::Reference< XTextContent > xRef = SwXBookmarks::GetObject(*(ppBkmk->get()), GetDoc()); - aRet.setValue(&xRef, ::getCppuType((uno::Reference*)0)); + const uno::Reference< text::XTextContent > xRef = + SwXBookmark::CreateXBookmark(*GetDoc(), *(ppBkmk->get())); + aRet <<= xRef; return aRet; } @@ -1594,27 +1596,6 @@ sal_Bool SwXBookmarks::hasElements(void) return GetDoc()->getIDocumentMarkAccess()->getBookmarksCount() != 0; } -SwXBookmark* SwXBookmarks::GetObject( ::sw::mark::IMark& rBkmk, SwDoc* pDoc) -{ - SwModify* const pModify = static_cast(&rBkmk); - SwXBookmark* pXBkmk = (SwXBookmark*)SwClientIter(*pModify).First(TYPE(SwXBookmark)); - if(!pXBkmk) - { - // FIXME: These belong in XTextFieldsSupplier - //if (dynamic_cast< ::sw::mark::TextFieldmark* >(&rBkmk)) - // pXBkmk = new SwXFieldmark(false, &rBkmk, pDoc); - //else if (dynamic_cast< ::sw::mark::CheckboxFieldmark* >(&rBkmk)) - // pXBkmk = new SwXFieldmark(true, &rBkmk, pDoc); - //else - OSL_ENSURE( - dynamic_cast< ::sw::mark::IBookmark* >(&rBkmk), - "" - "SwXBookmark requested for non-bookmark mark."); - pXBkmk = new SwXBookmark(&rBkmk, pDoc); - } - return pXBkmk; -} - /****************************************************************** * ******************************************************************/ diff --git a/sw/source/core/unocore/unoportenum.cxx b/sw/source/core/unocore/unoportenum.cxx index e7426091f745..605554253bf8 100644 --- a/sw/source/core/unocore/unoportenum.cxx +++ b/sw/source/core/unocore/unoportenum.cxx @@ -100,8 +100,9 @@ namespace BYTE nBkmType; const SwPosition aPosition; - SwXBookmarkPortion_Impl( SwXBookmark* pXMark, BYTE nType, const SwPosition &rPosition ) - : xBookmark ( pXMark ) + SwXBookmarkPortion_Impl(uno::Reference const& xMark, + const BYTE nType, SwPosition const& rPosition) + : xBookmark ( xMark ) , nBkmType ( nType ) , aPosition ( rPosition ) { @@ -165,7 +166,9 @@ namespace { const BYTE nType = hasOther ? BKM_TYPE_START : BKM_TYPE_START_END; rBkmArr.insert(SwXBookmarkPortion_ImplSharedPtr( - new SwXBookmarkPortion_Impl ( SwXBookmarks::GetObject(*pBkmk, &rDoc ), nType, rStartPos))); + new SwXBookmarkPortion_Impl( + SwXBookmark::CreateXBookmark(rDoc, *pBkmk), + nType, rStartPos))); } const SwPosition& rEndPos = pBkmk->GetMarkEnd(); @@ -183,8 +186,12 @@ namespace pEndPos = pCrossRefEndPos.get(); } if(pEndPos) + { rBkmArr.insert(SwXBookmarkPortion_ImplSharedPtr( - new SwXBookmarkPortion_Impl ( SwXBookmarks::GetObject(*pBkmk, &rDoc ), BKM_TYPE_END, *pEndPos))); + new SwXBookmarkPortion_Impl( + SwXBookmark::CreateXBookmark(rDoc, *pBkmk), + BKM_TYPE_END, *pEndPos))); + } } } } diff --git a/sw/source/ui/uno/unotxvw.cxx b/sw/source/ui/uno/unotxvw.cxx index 9da88953d481..35a4c5a2f92c 100644 --- a/sw/source/ui/uno/unotxvw.cxx +++ b/sw/source/ui/uno/unotxvw.cxx @@ -433,19 +433,14 @@ sal_Bool SwXTextView::select(const uno::Any& aInterface) throw( lang::IllegalArg if(xBkm.is() && xIfcTunnel.is()) { - SwXBookmark* pBkm = reinterpret_cast( - xIfcTunnel->getSomething(SwXBookmark::getUnoTunnelId())); - if(pBkm && pBkm->GetDoc() == pDoc) + ::sw::mark::IMark const*const pMark( + SwXBookmark::GetBookmarkInDoc(pDoc, xIfcTunnel) ); + if (pMark) { - IDocumentMarkAccess* const pMarkAccess = rSh.getIDocumentMarkAccess(); - IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->findMark(pBkm->getName()); - if( ppMark != pMarkAccess->getMarksEnd() ) - { - rSh.EnterStdMode(); - rSh.GotoMark( ppMark->get() ); - } - return sal_True; + rSh.EnterStdMode(); + rSh.GotoMark(pMark); } + return sal_True; } // IndexMark, Index, TextField, Draw, Section, Footnote, Paragraph // -- cgit From ee9d6d30959b5467fb5f2407ce5aa24fe1043fc5 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 8 Jan 2010 17:13:50 +0100 Subject: swunolocking1: #i105557#: fix locking for SwXParagraph: add Impl struct, and use UnoImplPtr to lock destructor. move all implementation details out of header, into Impl struct. make SwXParagraph instances reusable with a WeakReference in SwTxtNode. make constructor private, and add factory function CreateXParagraph. use new XUnoTunnel and XServiceInfo helpers. clean up the implementation a little. --- sw/inc/ndtxt.hxx | 20 +- sw/inc/unoparagraph.hxx | 75 +- sw/source/core/txtnode/ndtxt.cxx | 31 +- sw/source/core/unocore/unodraw.cxx | 4 +- sw/source/core/unocore/unoobj2.cxx | 16 +- sw/source/core/unocore/unoparagraph.cxx | 1163 +++++++++++++++++++------------ sw/source/core/unocore/unotext.cxx | 15 +- 7 files changed, 775 insertions(+), 549 deletions(-) (limited to 'sw') diff --git a/sw/inc/ndtxt.hxx b/sw/inc/ndtxt.hxx index d4d59afa3d9c..04f1fad3e660 100644 --- a/sw/inc/ndtxt.hxx +++ b/sw/inc/ndtxt.hxx @@ -30,6 +30,8 @@ #ifndef _NDTXT_HXX #define _NDTXT_HXX +#include + #include "swdllapi.h" #include #include @@ -76,9 +78,12 @@ class SwScriptInfo; struct SwDocStat; struct SwParaIdleData_Impl; -namespace com { namespace sun { namespace star { namespace uno { - template < class > class Sequence; -}}}} +namespace com { namespace sun { namespace star { + namespace uno { + template < class > class Sequence; + } + namespace text { class XTextContent; } +} } } typedef std::set< xub_StrLen > SwSoftPageBreakList; @@ -132,6 +137,8 @@ class SW_DLLPUBLIC SwTxtNode: public SwCntntNode, public ::sfx2::Metadatable SwList* mpList; // <-- + ::com::sun::star::uno::WeakReference< + ::com::sun::star::text::XTextContent> m_wXParagraph; SW_DLLPRIVATE SwTxtNode( const SwNodeIndex &rWhere, SwTxtFmtColl *pTxtColl, const SfxItemSet* pAutoAttr = 0 ); @@ -813,6 +820,13 @@ public: USHORT GetScalingOfSelectedText( xub_StrLen nStt, xub_StrLen nEnd ) const; + SW_DLLPRIVATE ::com::sun::star::uno::WeakReference< + ::com::sun::star::text::XTextContent> const& GetXParagraph() const + { return m_wXParagraph; } + SW_DLLPRIVATE void SetXParagraph(::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextContent> const& xParagraph) + { m_wXParagraph = xParagraph; } + // sfx2::Metadatable virtual ::sfx2::IXmlIdRegistry& GetRegistry(); virtual bool IsInClipboard() const; diff --git a/sw/inc/unoparagraph.hxx b/sw/inc/unoparagraph.hxx index 984786b0d1fb..d5c5e2ed2832 100644 --- a/sw/inc/unoparagraph.hxx +++ b/sw/inc/unoparagraph.hxx @@ -48,12 +48,11 @@ #include #include -#include #include -class SfxItemPropertySet; struct SwPosition; +class SwPaM; class SwUnoCrsr; class SwStartNode; class SwTxtNode; @@ -80,73 +79,41 @@ typedef ::cppu::ImplInheritanceHelper10 class SwXParagraph : public SwXParagraph_Base - , public SwClient { private: - ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > xParentText; - SwEventListenerContainer aLstnrCntnr; - const SfxItemPropertySet* m_pPropSet; - ::rtl::OUString m_sText; - sal_Int32 nSelectionStartPos; - sal_Int32 nSelectionEndPos; - BOOL m_bIsDescriptor; - -protected: - - void SAL_CALL SetPropertyValues_Impl( - const ::com::sun::star::uno::Sequence< ::rtl::OUString >& - rPropertyNames, - const ::com::sun::star::uno::Sequence< - ::com::sun::star::uno::Any >& rValues) - throw (::com::sun::star::beans::UnknownPropertyException, - ::com::sun::star::beans::PropertyVetoException, - ::com::sun::star::lang::IllegalArgumentException, - ::com::sun::star::lang::WrappedTargetException, - ::com::sun::star::uno::RuntimeException); - ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL - GetPropertyValues_Impl( - const ::com::sun::star::uno::Sequence< ::rtl::OUString >& - rPropertyNames) - throw (::com::sun::star::beans::UnknownPropertyException, - ::com::sun::star::lang::WrappedTargetException, - ::com::sun::star::uno::RuntimeException); - - ::com::sun::star::uno::Sequence< - ::com::sun::star::beans::GetDirectPropertyTolerantResult > SAL_CALL - GetPropertyValuesTolerant_Impl( - const ::com::sun::star::uno::Sequence< ::rtl::OUString >& - rPropertyNames, - sal_Bool bDirectValuesOnly) - throw (::com::sun::star::uno::RuntimeException); + class Impl; + ::sw::UnoImplPtr m_pImpl; virtual ~SwXParagraph(); + SwXParagraph(::com::sun::star::uno::Reference< + ::com::sun::star::text::XText > const & xParent, + SwTxtNode & rTxtNode, + const sal_Int32 nSelStart = -1, const sal_Int32 nSelEnd = - 1); + public: + /// descriptor SwXParagraph(); - SwXParagraph(::com::sun::star::uno::Reference< - ::com::sun::star::text::XText > const & i_xParent, - SwTxtNode * i_pTxtNode, - sal_Int32 nSelStart = -1, sal_Int32 nSelEnd = - 1); - BOOL IsDescriptor() const {return m_bIsDescriptor;} + static ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextContent> + CreateXParagraph(SwDoc & rDoc, SwTxtNode& rTxtNode, + ::com::sun::star::uno::Reference< ::com::sun::star::text::XText> + const& xParentText = 0, + const sal_Int32 nSelStart = -1, const sal_Int32 nSelEnd = - 1); const SwTxtNode * GetTxtNode() const; - SwTxtNode * GetTxtNode(); - - static BOOL getDefaultTextContentValue(::com::sun::star::uno::Any& rAny, - const ::rtl::OUString& rPropertyName, USHORT nWID = 0); - static SwXParagraph* GetImplementation( - ::com::sun::star::uno::Reference< - ::com::sun::star::uno::XInterface> xRef); + bool IsDescriptor() const; + /// make rPaM select the paragraph + bool SelectPaM(SwPaM & rPaM); + /// for SwXText void attachToText(SwXText & rParent, SwTxtNode & rTxtNode); - TYPEINFO(); - - // SwClient - virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + static bool getDefaultTextContentValue(::com::sun::star::uno::Any& rAny, + const ::rtl::OUString& rPropertyName, USHORT nWID = 0); // MetadatableMixin virtual ::sfx2::Metadatable* GetCoreObject(); diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index 8e83c3cb9ded..acae6495e046 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -3623,6 +3623,12 @@ void SwTxtNode::Modify( SfxPoolItem* pOldValue, SfxPoolItem* pNewValue ) } m_bNotifiable = bWasNotifiable; + + if (pOldValue && (RES_REMOVE_UNO_OBJECT == pOldValue->Which())) + { // invalidate cached uno object + SetXParagraph(::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextContent>(0)); + } } SwFmtColl* SwTxtNode::ChgFmtColl( SwFmtColl *pNewColl ) @@ -4973,27 +4979,14 @@ bool SwTxtNode::IsInContent() const } #include -#include -::com::sun::star::uno::Reference< ::com::sun::star::rdf::XMetadatable > +using namespace ::com::sun::star; + +uno::Reference< rdf::XMetadatable > SwTxtNode::MakeUnoObject() { - // re-use existing SwXParagraph - SwClientIter iter( *this ); - SwClient * pClient( iter.First( TYPE( SwXParagraph ) ) ); - while (pClient) { - SwXParagraph *pPara( dynamic_cast(pClient) ); - if (pPara && pPara->GetCoreObject() == this ) { - return pPara; - } - pClient = iter.Next(); - } - - // create new SwXParagraph - SwPosition Pos( *this ); - ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > xParent( - SwXTextRange::CreateParentXText( GetDoc(), Pos ) ); - SwXParagraph * pXPara( new SwXParagraph( xParent, this ) ); - return pXPara; + const uno::Reference xMeta( + SwXParagraph::CreateXParagraph(*GetDoc(), *this), uno::UNO_QUERY); + return xMeta; } diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx index b967f59f4899..9a2eb1dfae45 100644 --- a/sw/source/core/unocore/unodraw.cxx +++ b/sw/source/core/unocore/unodraw.cxx @@ -2158,7 +2158,9 @@ void SwXShape::attach(const uno::Reference< text::XTextRange > & xTextRange) pDoc = pPortion->GetCursor()->GetDoc(); } else if ( !pDoc && pParagraph && pParagraph->GetTxtNode( ) ) - pDoc = pParagraph->GetTxtNode( )->GetDoc( ); + { + pDoc = const_cast(pParagraph->GetTxtNode()->GetDoc()); + } } diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index a7f6119e5962..b5c2ea2a6993 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -1169,9 +1169,9 @@ uno::Reference< XTextContent > SAL_CALL SwXParagraphEnumeration::NextElement_Imp } else { - aRef = new SwXParagraph(static_cast(pText), - pStart->nNode.GetNode().GetTxtNode(), - nFirstContent, nLastContent); + aRef = SwXParagraph::CreateXParagraph(*pUnoCrsr->GetDoc(), + *pStart->nNode.GetNode().GetTxtNode(), + static_cast(pText), nFirstContent, nLastContent); } } } @@ -1528,15 +1528,7 @@ sal_Bool SwXTextRange::XTextRangeToSwPaM( SwUnoInternalPaM& rToFill, { if (pPara) { - const SwTxtNode * pTxtNode( pPara->GetTxtNode() ); - - if (pTxtNode) { - bRet = sal_True; - *rToFill.GetPoint() = SwPosition( *pTxtNode ); - // set selection to the whole paragraph - rToFill.SetMark(); - rToFill.GetMark()->nContent = pTxtNode->GetTxt().Len(); - } + bRet = pPara->SelectPaM(rToFill); } else { diff --git a/sw/source/core/unocore/unoparagraph.cxx b/sw/source/core/unocore/unoparagraph.cxx index 22611e0b8e5b..404a93005a19 100644 --- a/sw/source/core/unocore/unoparagraph.cxx +++ b/sw/source/core/unocore/unoparagraph.cxx @@ -31,13 +31,13 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" +#include #include #include #include #include #include #include -#include #include #include #include @@ -60,6 +60,7 @@ #include #include + using namespace ::com::sun::star; using ::rtl::OUString; @@ -69,38 +70,38 @@ using ::rtl::OUString; ---------------------------------------------------------------------------*/ class SwParaSelection { - SwCursor* m_pCursor; + SwCursor & m_rCursor; public: - SwParaSelection(SwCursor* pPam); + SwParaSelection(SwCursor & rCursor); ~SwParaSelection(); }; -SwParaSelection::SwParaSelection(SwCursor* pCursor) - : m_pCursor(pCursor) +SwParaSelection::SwParaSelection(SwCursor & rCursor) + : m_rCursor(rCursor) { - if (m_pCursor->HasMark()) + if (m_rCursor.HasMark()) { - m_pCursor->DeleteMark(); + m_rCursor.DeleteMark(); } // is it at the start? - if (m_pCursor->GetPoint()->nContent != 0) + if (m_rCursor.GetPoint()->nContent != 0) { - m_pCursor->MovePara(fnParaCurr, fnParaStart); + m_rCursor.MovePara(fnParaCurr, fnParaStart); } // or at the end already? - if (m_pCursor->GetPoint()->nContent != m_pCursor->GetCntntNode()->Len()) + if (m_rCursor.GetPoint()->nContent != m_rCursor.GetCntntNode()->Len()) { - m_pCursor->SetMark(); - m_pCursor->MovePara(fnParaCurr, fnParaEnd); + m_rCursor.SetMark(); + m_rCursor.MovePara(fnParaCurr, fnParaEnd); } } SwParaSelection::~SwParaSelection() { - if (m_pCursor->GetPoint()->nContent != 0) + if (m_rCursor.GetPoint()->nContent != 0) { - m_pCursor->DeleteMark(); - m_pCursor->MovePara(fnParaCurr, fnParaStart); + m_rCursor.DeleteMark(); + m_rCursor.MovePara(fnParaCurr, fnParaStart); } } @@ -114,25 +115,184 @@ beans::PropertyState lcl_SwXParagraph_getPropertyState( const SwAttrSet** ppSet, const SfxItemPropertySimpleEntry& rEntry, sal_Bool &rAttrSetFetched ) - throw( beans::UnknownPropertyException); + throw (beans::UnknownPropertyException); /****************************************************************** * SwXParagraph ******************************************************************/ -TYPEINIT1(SwXParagraph, SwClient); +class SwXParagraph::Impl + : public SwClient +{ -/* -----------------------------11.07.00 12:10-------------------------------- +public: + SwXParagraph & m_rThis; + SwEventListenerContainer m_ListenerContainer; + SfxItemPropertySet const& m_rPropSet; + bool m_bIsDescriptor; + sal_Int32 m_nSelectionStartPos; + sal_Int32 m_nSelectionEndPos; + ::rtl::OUString m_sText; + uno::Reference m_xParentText; + + Impl( SwXParagraph & rThis, + SwTxtNode *const pTxtNode = 0, + uno::Reference< text::XText > const & xParent = 0, + const sal_Int32 nSelStart = -1, const sal_Int32 nSelEnd = -1) + : SwClient(pTxtNode) + , m_rThis(rThis) + , m_ListenerContainer(static_cast< ::cppu::OWeakObject* >(&rThis)) + , m_rPropSet(*aSwMapProvider.GetPropertySet(PROPERTY_MAP_PARAGRAPH)) + , m_bIsDescriptor(0 == pTxtNode) + , m_nSelectionStartPos(nSelStart) + , m_nSelectionEndPos(nSelEnd) + , m_xParentText(xParent) + { + } - ---------------------------------------------------------------------------*/ -SwXParagraph* SwXParagraph::GetImplementation(uno::Reference< XInterface> xRef ) + const SwTxtNode * GetTxtNode() const { + return static_cast(GetRegisteredIn()); + } + SwTxtNode * GetTxtNode() { + return static_cast(pRegisteredIn); + } + + SwTxtNode & GetTxtNodeOrThrow() { + SwTxtNode *const pTxtNode( GetTxtNode() ); + if (!pTxtNode) { + throw uno::RuntimeException(OUString(RTL_CONSTASCII_USTRINGPARAM( + "SwXParagraph: disposed or invalid")), 0); + } + return *pTxtNode; + } + + bool IsDescriptor() const { return m_bIsDescriptor; } + + void SetPropertyValues_Impl( + const uno::Sequence< ::rtl::OUString >& rPropertyNames, + const uno::Sequence< uno::Any >& rValues) + throw (beans::UnknownPropertyException, beans::PropertyVetoException, + lang::IllegalArgumentException, lang::WrappedTargetException, + uno::RuntimeException); + + uno::Sequence< uno::Any > + GetPropertyValues_Impl( + const uno::Sequence< ::rtl::OUString >& rPropertyNames) + throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException); + + uno::Sequence< beans::GetDirectPropertyTolerantResult > + GetPropertyValuesTolerant_Impl( + const uno::Sequence< ::rtl::OUString >& rPropertyNames, + bool bDirectValuesOnly) + throw (uno::RuntimeException); + + // SwClient + virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + +}; + +/*-- 11.12.98 08:12:58--------------------------------------------------- + + -----------------------------------------------------------------------*/ +void SwXParagraph::Impl::Modify(SfxPoolItem *pOld, SfxPoolItem *pNew) +{ + ClientModify(this, pOld, pNew); + if (!GetRegisteredIn()) + { + m_ListenerContainer.Disposing(); + } +} + +/*-- 11.12.98 08:12:47--------------------------------------------------- + + -----------------------------------------------------------------------*/ +SwXParagraph::SwXParagraph() + : m_pImpl( new SwXParagraph::Impl(*this) ) +{ +} + +/*-- 11.12.98 08:12:47--------------------------------------------------- + + -----------------------------------------------------------------------*/ +SwXParagraph::SwXParagraph( + uno::Reference< text::XText > const & xParent, + SwTxtNode & rTxtNode, + const sal_Int32 nSelStart, const sal_Int32 nSelEnd) + : m_pImpl( + new SwXParagraph::Impl(*this, &rTxtNode, xParent, nSelStart, nSelEnd)) { - uno::Reference xParaTunnel( xRef, uno::UNO_QUERY); - if(xParaTunnel.is()) - return reinterpret_cast< SwXParagraph * >( - sal::static_int_cast< sal_IntPtr >( xParaTunnel->getSomething(SwXParagraph::getUnoTunnelId()) )); - return 0; } + +/*-- 11.12.98 08:12:48--------------------------------------------------- + + -----------------------------------------------------------------------*/ +SwXParagraph::~SwXParagraph() +{ +} + +const SwTxtNode * SwXParagraph::GetTxtNode() const +{ + return m_pImpl->GetTxtNode(); +} + +bool SwXParagraph::IsDescriptor() const +{ + return m_pImpl->IsDescriptor(); +} + +uno::Reference +SwXParagraph::CreateXParagraph(SwDoc & rDoc, SwTxtNode& rTxtNode, + uno::Reference< text::XText> const& i_xParent, + const sal_Int32 nSelStart, const sal_Int32 nSelEnd) +{ + // re-use existing SwXParagraph + // #i105557#: do not iterate over the registered clients: race condition + uno::Reference xParagraph; + if ((-1 == nSelStart) && (-1 == nSelEnd)) // only use cache if no selection! + { + xParagraph.set(rTxtNode.GetXParagraph()); + } + if (xParagraph.is()) + { + return xParagraph; + } + + // create new SwXParagraph + uno::Reference xParentText(i_xParent); + if (!xParentText.is()) + { + SwPosition Pos( rTxtNode ); + xParentText.set(SwXTextRange::CreateParentXText( &rDoc, Pos )); + } + SwXParagraph *const pXPara( + new SwXParagraph(xParentText, rTxtNode, nSelStart, nSelEnd) ); + // this is why the constructor is private: need to acquire pXPara here + xParagraph.set(pXPara); + // in order to initialize the weak pointer cache in the core object + if ((-1 == nSelStart) && (-1 == nSelEnd)) + { + rTxtNode.SetXParagraph(xParagraph); + } + return xParagraph; +} + +bool SwXParagraph::SelectPaM(SwPaM & rPaM) +{ + SwTxtNode const*const pTxtNode( GetTxtNode() ); + + if (!pTxtNode) + { + return false; + } + + *rPaM.GetPoint() = SwPosition( *pTxtNode ); + // set selection to the whole paragraph + rPaM.SetMark(); + rPaM.GetMark()->nContent = pTxtNode->GetTxt().Len(); + return true; +} + /* -----------------------------13.03.00 12:15-------------------------------- ---------------------------------------------------------------------------*/ @@ -144,191 +304,176 @@ const uno::Sequence< sal_Int8 > & SwXParagraph::getUnoTunnelId() /* -----------------------------10.03.00 18:04-------------------------------- ---------------------------------------------------------------------------*/ -sal_Int64 SAL_CALL SwXParagraph::getSomething( const uno::Sequence< sal_Int8 >& rId ) - throw(uno::RuntimeException) +sal_Int64 SAL_CALL +SwXParagraph::getSomething(const uno::Sequence< sal_Int8 >& rId) +throw (uno::RuntimeException) { - if( rId.getLength() == 16 - && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), - rId.getConstArray(), 16 ) ) - { - return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(this) ); - } - return 0; + return ::sw::UnoTunnelImpl(rId, this); } -/* -----------------------------06.04.00 16:37-------------------------------- - ---------------------------------------------------------------------------*/ -OUString SwXParagraph::getImplementationName(void) throw( uno::RuntimeException ) -{ - return C2U("SwXParagraph"); -} /* -----------------------------06.04.00 16:37-------------------------------- ---------------------------------------------------------------------------*/ -BOOL SwXParagraph::supportsService(const OUString& rServiceName) throw( uno::RuntimeException ) +OUString SAL_CALL +SwXParagraph::getImplementationName() throw (uno::RuntimeException) { - String sServiceName(rServiceName); - return sServiceName.EqualsAscii("com.sun.star.text.TextContent") || - sServiceName.EqualsAscii("com.sun.star.text.Paragraph") || - sServiceName.EqualsAscii("com.sun.star.style.CharacterProperties")|| - sServiceName.EqualsAscii("com.sun.star.style.CharacterPropertiesAsian")|| - sServiceName.EqualsAscii("com.sun.star.style.CharacterPropertiesComplex")|| - sServiceName.EqualsAscii("com.sun.star.style.ParagraphProperties") || - sServiceName.EqualsAscii("com.sun.star.style.ParagraphPropertiesAsian") || - sServiceName.EqualsAscii("com.sun.star.style.ParagraphPropertiesComplex"); + return C2U("SwXParagraph"); } /* -----------------------------06.04.00 16:37-------------------------------- ---------------------------------------------------------------------------*/ -uno::Sequence< OUString > SwXParagraph::getSupportedServiceNames(void) throw( uno::RuntimeException ) +static char const*const g_ServicesParagraph[] = { - uno::Sequence< OUString > aRet(8); - OUString* pArray = aRet.getArray(); - pArray[0] = C2U("com.sun.star.text.Paragraph"); - pArray[1] = C2U("com.sun.star.style.CharacterProperties"); - pArray[2] = C2U("com.sun.star.style.CharacterPropertiesAsian"); - pArray[3] = C2U("com.sun.star.style.CharacterPropertiesComplex"); - pArray[4] = C2U("com.sun.star.style.ParagraphProperties"); - pArray[5] = C2U("com.sun.star.style.ParagraphPropertiesAsian"); - pArray[6] = C2U("com.sun.star.style.ParagraphPropertiesComplex"); - pArray[7] = C2U("com.sun.star.text.TextContent"); - return aRet; -} -/*-- 11.12.98 08:12:47--------------------------------------------------- + "com.sun.star.text.TextContent", + "com.sun.star.text.Paragraph", + "com.sun.star.style.CharacterProperties", + "com.sun.star.style.CharacterPropertiesAsian", + "com.sun.star.style.CharacterPropertiesComplex", + "com.sun.star.style.ParagraphProperties", + "com.sun.star.style.ParagraphPropertiesAsian", + "com.sun.star.style.ParagraphPropertiesComplex", +}; +static const size_t g_nServicesParagraph( + sizeof(g_ServicesParagraph)/sizeof(g_ServicesParagraph[0])); - -----------------------------------------------------------------------*/ -SwXParagraph::SwXParagraph() : - xParentText(0), - aLstnrCntnr( (text::XTextRange*)this), - m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_PARAGRAPH)), - nSelectionStartPos(-1), - nSelectionEndPos(-1), - m_bIsDescriptor(TRUE) +sal_Bool SAL_CALL +SwXParagraph::supportsService(const OUString& rServiceName) +throw (uno::RuntimeException) { + return ::sw::SupportsServiceImpl( + g_nServicesParagraph, g_ServicesParagraph, rServiceName); } +/* -----------------------------06.04.00 16:37-------------------------------- -/*-- 11.12.98 08:12:47--------------------------------------------------- - - -----------------------------------------------------------------------*/ -SwXParagraph::SwXParagraph(uno::Reference< text::XText > const & i_xParent, SwTxtNode * i_pTxtNode, sal_Int32 nSelStart, sal_Int32 nSelEnd) : - SwClient(i_pTxtNode), - xParentText(i_xParent), - aLstnrCntnr( (text::XTextRange*)this), - m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_PARAGRAPH)), - nSelectionStartPos(nSelStart), - nSelectionEndPos(nSelEnd), - m_bIsDescriptor(FALSE) + ---------------------------------------------------------------------------*/ +uno::Sequence< OUString > SAL_CALL +SwXParagraph::getSupportedServiceNames() throw (uno::RuntimeException) { + return ::sw::GetSupportedServiceNamesImpl( + g_nServicesParagraph, g_ServicesParagraph); } -/*-- 11.12.98 08:12:48--------------------------------------------------- - -----------------------------------------------------------------------*/ -SwXParagraph::~SwXParagraph() -{ -} /* -----------------------------11.07.00 14:48-------------------------------- ---------------------------------------------------------------------------*/ void SwXParagraph::attachToText(SwXText & rParent, SwTxtNode & rTxtNode) { - DBG_ASSERT(m_bIsDescriptor, "Paragraph is not a descriptor"); - if(m_bIsDescriptor) + DBG_ASSERT(m_pImpl->m_bIsDescriptor, "Paragraph is not a descriptor"); + if (m_pImpl->m_bIsDescriptor) { - m_bIsDescriptor = FALSE; - rTxtNode.Add(this); - xParentText = &rParent; - if(m_sText.getLength()) + m_pImpl->m_bIsDescriptor = false; + rTxtNode.Add(m_pImpl.get()); + rTxtNode.SetXParagraph(uno::Reference(this)); + m_pImpl->m_xParentText = &rParent; + if (m_pImpl->m_sText.getLength()) { - try { setString(m_sText); } + try { setString(m_pImpl->m_sText); } catch(...){} - m_sText = OUString(); + m_pImpl->m_sText = OUString(); } } } + /*-- 11.12.98 08:12:49--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< beans::XPropertySetInfo > SwXParagraph::getPropertySetInfo(void) - throw( uno::RuntimeException ) +uno::Reference< beans::XPropertySetInfo > SAL_CALL +SwXParagraph::getPropertySetInfo() +throw (uno::RuntimeException) { - static uno::Reference< beans::XPropertySetInfo > xRef = m_pPropSet->getPropertySetInfo(); + vos::OGuard g(Application::GetSolarMutex()); + + static uno::Reference< beans::XPropertySetInfo > xRef = + m_pImpl->m_rPropSet.getPropertySetInfo(); return xRef; } /*-- 11.12.98 08:12:49--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXParagraph::setPropertyValue(const OUString& rPropertyName, const uno::Any& aValue) - throw( beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, - lang::WrappedTargetException, uno::RuntimeException ) +void SAL_CALL +SwXParagraph::setPropertyValue(const OUString& rPropertyName, + const uno::Any& rValue) +throw (beans::UnknownPropertyException, beans::PropertyVetoException, + lang::IllegalArgumentException, lang::WrappedTargetException, + uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); uno::Sequence aPropertyNames(1); aPropertyNames.getArray()[0] = rPropertyName; uno::Sequence aValues(1); - aValues.getArray()[0] = aValue; - SetPropertyValues_Impl( aPropertyNames, aValues ); + aValues.getArray()[0] = rValue; + m_pImpl->SetPropertyValues_Impl( aPropertyNames, aValues ); } + /*-- 11.12.98 08:12:49--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Any SwXParagraph::getPropertyValue(const OUString& rPropertyName) - throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +uno::Any +SwXParagraph::getPropertyValue(const OUString& rPropertyName) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); uno::Sequence aPropertyNames(1); aPropertyNames.getArray()[0] = rPropertyName; - uno::Sequence< uno::Any > aRet = GetPropertyValues_Impl(aPropertyNames ); + const uno::Sequence< uno::Any > aRet = + m_pImpl->GetPropertyValues_Impl(aPropertyNames); return aRet.getConstArray()[0]; } /* -----------------------------02.04.01 11:43-------------------------------- ---------------------------------------------------------------------------*/ -void SAL_CALL SwXParagraph::SetPropertyValues_Impl( +void SwXParagraph::Impl::SetPropertyValues_Impl( const uno::Sequence< OUString >& rPropertyNames, const uno::Sequence< uno::Any >& rValues ) - throw( beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, - lang::WrappedTargetException, uno::RuntimeException) +throw (beans::UnknownPropertyException, beans::PropertyVetoException, + lang::IllegalArgumentException, lang::WrappedTargetException, + uno::RuntimeException) { - if (GetTxtNode()) + SwTxtNode & rTxtNode(GetTxtNodeOrThrow()); + + SwPosition aPos( rTxtNode ); + SwCursor aCursor( aPos, 0, false ); + const OUString* pPropertyNames = rPropertyNames.getConstArray(); + const uno::Any* pValues = rValues.getConstArray(); + SfxItemPropertyMap const*const pMap = m_rPropSet.getPropertyMap(); + SwParaSelection aParaSel( aCursor ); + for (sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); nProp++) { - SwPosition aPos( *GetTxtNode() ); - SwCursor aCursor( aPos, 0, false ); - const OUString* pPropertyNames = rPropertyNames.getConstArray(); - const uno::Any* pValues = rValues.getConstArray(); - const SfxItemPropertyMap* pMap = m_pPropSet->getPropertyMap(); - SwParaSelection aParaSel( & aCursor ); - for(sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); nProp++) + SfxItemPropertySimpleEntry const*const pEntry = + pMap->getByName( pPropertyNames[nProp] ); + if (!pEntry) { - const SfxItemPropertySimpleEntry* pEntry = pMap->getByName( pPropertyNames[nProp] ); - if(!pEntry) - throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pPropertyNames[nProp], static_cast < cppu::OWeakObject * > ( this ) ); - else - { - if ( pEntry->nFlags & beans::PropertyAttribute::READONLY) - throw beans::PropertyVetoException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + pPropertyNames[nProp], static_cast < cppu::OWeakObject * > ( this ) ); - - SwXTextCursor::SetPropertyValue(aCursor, *m_pPropSet, - pPropertyNames[nProp], pValues[nProp]); - } + throw beans::UnknownPropertyException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) + + pPropertyNames[nProp], + static_cast< cppu::OWeakObject * >(&m_rThis)); + } + if (pEntry->nFlags & beans::PropertyAttribute::READONLY) + { + throw beans::PropertyVetoException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Property is read-only: ")) + + pPropertyNames[nProp], + static_cast< cppu::OWeakObject * >(&m_rThis)); } + SwXTextCursor::SetPropertyValue(aCursor, m_rPropSet, + pPropertyNames[nProp], pValues[nProp]); } - else - throw uno::RuntimeException(); } -void SwXParagraph::setPropertyValues( +void SAL_CALL SwXParagraph::setPropertyValues( const uno::Sequence< OUString >& rPropertyNames, const uno::Sequence< uno::Any >& rValues ) - throw(beans::PropertyVetoException, lang::IllegalArgumentException, - lang::WrappedTargetException, uno::RuntimeException) +throw (beans::PropertyVetoException, lang::IllegalArgumentException, + lang::WrappedTargetException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); // workaround for bad designed API try { - SetPropertyValues_Impl( rPropertyNames, rValues ); + m_pImpl->SetPropertyValues_Impl( rPropertyNames, rValues ); } catch (beans::UnknownPropertyException &rException) { @@ -339,53 +484,57 @@ void SwXParagraph::setPropertyValues( throw aWExc; } } + /* -----------------------------02.04.01 11:43-------------------------------- ---------------------------------------------------------------------------*/ -uno::Sequence< uno::Any > SAL_CALL SwXParagraph::GetPropertyValues_Impl( +uno::Sequence< uno::Any > SwXParagraph::Impl::GetPropertyValues_Impl( const uno::Sequence< OUString > & rPropertyNames ) - throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { + SwTxtNode & rTxtNode(GetTxtNodeOrThrow()); + uno::Sequence< uno::Any > aValues(rPropertyNames.getLength()); - const SwTxtNode * pTxtNode( GetTxtNode() ); - if (pTxtNode) + SwPosition aPos( rTxtNode ); + SwPaM aPam( aPos ); + uno::Any* pValues = aValues.getArray(); + const OUString* pPropertyNames = rPropertyNames.getConstArray(); + SfxItemPropertyMap const*const pMap = m_rPropSet.getPropertyMap(); + const SwAttrSet& rAttrSet( rTxtNode.GetSwAttrSet() ); + for (sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); nProp++) { - SwPosition aPos( *pTxtNode ); - SwPaM aPam( aPos ); - uno::Any* pValues = aValues.getArray(); - const OUString* pPropertyNames = rPropertyNames.getConstArray(); - const SfxItemPropertyMap* pMap = m_pPropSet->getPropertyMap(); - const SwAttrSet& rAttrSet( pTxtNode->GetSwAttrSet() ); - for(sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); nProp++) + SfxItemPropertySimpleEntry const*const pEntry = + pMap->getByName( pPropertyNames[nProp] ); + if (!pEntry) + { + throw beans::UnknownPropertyException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) + + pPropertyNames[nProp], + static_cast< cppu::OWeakObject * >(&m_rThis)); + } + if (!SwXParagraph::getDefaultTextContentValue( + pValues[nProp], pPropertyNames[nProp], pEntry->nWID)) { - const SfxItemPropertySimpleEntry* pEntry = pMap->getByName( pPropertyNames[nProp] ); - if(pEntry) + beans::PropertyState eTemp; + const bool bDone = SwUnoCursorHelper::getCrsrPropertyValue( + *pEntry, aPam, &(pValues[nProp]), eTemp, &rTxtNode ); + if (!bDone) { - if(!SwXParagraph::getDefaultTextContentValue( - pValues[nProp], pPropertyNames[nProp], pEntry->nWID)) - { - BOOL bDone = FALSE; - beans::PropertyState eTemp; - bDone = SwUnoCursorHelper::getCrsrPropertyValue( - *pEntry, aPam, &(pValues[nProp]), eTemp, pTxtNode ); - if(!bDone) - m_pPropSet->getPropertyValue(*pEntry, rAttrSet, pValues[nProp]); - } + m_rPropSet.getPropertyValue( + *pEntry, rAttrSet, pValues[nProp]); } - else - throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pPropertyNames[nProp], static_cast < cppu::OWeakObject * > ( this ) ); } } - else - throw uno::RuntimeException(); return aValues; } + /* -----------------------------04.11.03 11:43-------------------------------- ---------------------------------------------------------------------------*/ -uno::Sequence< uno::Any > SwXParagraph::getPropertyValues( - const uno::Sequence< OUString >& rPropertyNames ) - throw(uno::RuntimeException) +uno::Sequence< uno::Any > SAL_CALL +SwXParagraph::getPropertyValues(const uno::Sequence< OUString >& rPropertyNames) +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); uno::Sequence< uno::Any > aValues; @@ -393,67 +542,82 @@ uno::Sequence< uno::Any > SwXParagraph::getPropertyValues( // workaround for bad designed API try { - aValues = GetPropertyValues_Impl( rPropertyNames ); + aValues = m_pImpl->GetPropertyValues_Impl( rPropertyNames ); } catch (beans::UnknownPropertyException &) { - throw uno::RuntimeException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property exception caught" ) ), static_cast < cppu::OWeakObject * > ( this ) ); + throw uno::RuntimeException(OUString(RTL_CONSTASCII_USTRINGPARAM( + "Unknown property exception caught")), + static_cast(this)); } catch (lang::WrappedTargetException &) { - throw uno::RuntimeException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "WrappedTargetException caught" ) ), static_cast < cppu::OWeakObject * > ( this ) ); + throw uno::RuntimeException(OUString(RTL_CONSTASCII_USTRINGPARAM( + "WrappedTargetException caught")), + static_cast(this)); } return aValues; } + /* -----------------------------02.04.01 11:43-------------------------------- ---------------------------------------------------------------------------*/ -void SwXParagraph::addPropertiesChangeListener( +void SAL_CALL SwXParagraph::addPropertiesChangeListener( const uno::Sequence< OUString >& /*aPropertyNames*/, const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ ) - throw(uno::RuntimeException) -{} +throw (uno::RuntimeException) +{ + OSL_ENSURE(false, + "SwXParagraph::addPropertiesChangeListener(): not implemented"); +} /* -----------------------------02.04.01 11:43-------------------------------- ---------------------------------------------------------------------------*/ -void SwXParagraph::removePropertiesChangeListener( +void SAL_CALL SwXParagraph::removePropertiesChangeListener( const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ ) - throw(uno::RuntimeException) -{} +throw (uno::RuntimeException) +{ + OSL_ENSURE(false, + "SwXParagraph::removePropertiesChangeListener(): not implemented"); +} /* -----------------------------02.04.01 11:43-------------------------------- ---------------------------------------------------------------------------*/ -void SwXParagraph::firePropertiesChangeEvent( +void SAL_CALL SwXParagraph::firePropertiesChangeEvent( const uno::Sequence< OUString >& /*aPropertyNames*/, const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ ) throw(uno::RuntimeException) -{} +{ + OSL_ENSURE(false, + "SwXParagraph::firePropertiesChangeEvent(): not implemented"); +} /* -----------------------------25.09.03 11:09-------------------------------- ---------------------------------------------------------------------------*/ /* disabled for #i46921# */ -uno::Sequence< beans::SetPropertyTolerantFailed > SAL_CALL SwXParagraph::setPropertyValuesTolerant( +uno::Sequence< beans::SetPropertyTolerantFailed > SAL_CALL +SwXParagraph::setPropertyValuesTolerant( const uno::Sequence< OUString >& rPropertyNames, const uno::Sequence< uno::Any >& rValues ) - throw (lang::IllegalArgumentException, uno::RuntimeException) +throw (lang::IllegalArgumentException, uno::RuntimeException) { vos::OGuard aGuard( Application::GetSolarMutex() ); if (rPropertyNames.getLength() != rValues.getLength()) + { throw lang::IllegalArgumentException(); + } - const SwTxtNode * const pTxtNode( GetTxtNode() ); - if (!pTxtNode) - throw uno::RuntimeException(); + SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow()); //SwNode& rTxtNode = pUnoCrsr->GetPoint()->nNode.GetNode(); //const SwAttrSet& rAttrSet = ((SwTxtNode&)rTxtNode).GetSwAttrSet(); //USHORT nAttrCount = rAttrSet.Count(); - sal_Int32 nProps = rPropertyNames.getLength(); + const sal_Int32 nProps = rPropertyNames.getLength(); const OUString *pProp = rPropertyNames.getConstArray(); //sal_Int32 nVals = rValues.getLength(); @@ -464,31 +628,39 @@ uno::Sequence< beans::SetPropertyTolerantFailed > SAL_CALL SwXParagraph::setProp beans::SetPropertyTolerantFailed *pFailed = aFailed.getArray(); // get entry to start with - const SfxItemPropertyMap* pPropMap = m_pPropSet->getPropertyMap(); + SfxItemPropertyMap const*const pPropMap = + m_pImpl->m_rPropSet.getPropertyMap(); OUString sTmp; - SwPosition aPos( *pTxtNode ); + SwPosition aPos( rTxtNode ); SwCursor aCursor( aPos, 0, false ); - SwParaSelection aParaSel( & aCursor ); + SwParaSelection aParaSel( aCursor ); for (sal_Int32 i = 0; i < nProps; ++i) { try { pFailed[ nFailed ].Name = pProp[i]; - const SfxItemPropertySimpleEntry* pEntry = pPropMap->getByName( pProp[i] ); + SfxItemPropertySimpleEntry const*const pEntry = + pPropMap->getByName( pProp[i] ); if (!pEntry) - pFailed[ nFailed++ ].Result = beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY; + { + pFailed[ nFailed++ ].Result = + beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY; + } else { // set property value // (compare to SwXParagraph::setPropertyValues) if (pEntry->nFlags & beans::PropertyAttribute::READONLY) - pFailed[ nFailed++ ].Result = beans::TolerantPropertySetResultType::PROPERTY_VETO; + { + pFailed[ nFailed++ ].Result = + beans::TolerantPropertySetResultType::PROPERTY_VETO; + } else { SwXTextCursor::SetPropertyValue( - aCursor, *m_pPropSet, pProp[i], pValue[i] ); + aCursor, m_pImpl->m_rPropSet, pProp[i], pValue[i]); } } } @@ -496,19 +668,23 @@ uno::Sequence< beans::SetPropertyTolerantFailed > SAL_CALL SwXParagraph::setProp { // should not occur because property was searched for before DBG_ERROR( "unexpected exception catched" ); - pFailed[ nFailed++ ].Result = beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY; + pFailed[ nFailed++ ].Result = + beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY; } catch (lang::IllegalArgumentException &) { - pFailed[ nFailed++ ].Result = beans::TolerantPropertySetResultType::ILLEGAL_ARGUMENT; + pFailed[ nFailed++ ].Result = + beans::TolerantPropertySetResultType::ILLEGAL_ARGUMENT; } catch (beans::PropertyVetoException &) { - pFailed[ nFailed++ ].Result = beans::TolerantPropertySetResultType::PROPERTY_VETO; + pFailed[ nFailed++ ].Result = + beans::TolerantPropertySetResultType::PROPERTY_VETO; } catch (lang::WrappedTargetException &) { - pFailed[ nFailed++ ].Result = beans::TolerantPropertySetResultType::WRAPPED_TARGET; + pFailed[ nFailed++ ].Result = + beans::TolerantPropertySetResultType::WRAPPED_TARGET; } } @@ -517,52 +693,56 @@ uno::Sequence< beans::SetPropertyTolerantFailed > SAL_CALL SwXParagraph::setProp } -uno::Sequence< beans::GetPropertyTolerantResult > SAL_CALL SwXParagraph::getPropertyValuesTolerant( +uno::Sequence< beans::GetPropertyTolerantResult > SAL_CALL +SwXParagraph::getPropertyValuesTolerant( const uno::Sequence< OUString >& rPropertyNames ) - throw (uno::RuntimeException) +throw (uno::RuntimeException) { vos::OGuard aGuard( Application::GetSolarMutex() ); uno::Sequence< beans::GetDirectPropertyTolerantResult > aTmpRes( - GetPropertyValuesTolerant_Impl( rPropertyNames, sal_False ) ); - const beans::GetDirectPropertyTolerantResult *pTmpRes = aTmpRes.getConstArray(); + m_pImpl->GetPropertyValuesTolerant_Impl( rPropertyNames, false ) ); + const beans::GetDirectPropertyTolerantResult *pTmpRes = + aTmpRes.getConstArray(); // copy temporary result to final result type - sal_Int32 nLen = aTmpRes.getLength(); + const sal_Int32 nLen = aTmpRes.getLength(); uno::Sequence< beans::GetPropertyTolerantResult > aRes( nLen ); beans::GetPropertyTolerantResult *pRes = aRes.getArray(); for (sal_Int32 i = 0; i < nLen; i++) + { *pRes++ = *pTmpRes++; + } return aRes; } -uno::Sequence< beans::GetDirectPropertyTolerantResult > SAL_CALL SwXParagraph::getDirectPropertyValuesTolerant( +uno::Sequence< beans::GetDirectPropertyTolerantResult > SAL_CALL +SwXParagraph::getDirectPropertyValuesTolerant( const uno::Sequence< OUString >& rPropertyNames ) - throw (uno::RuntimeException) +throw (uno::RuntimeException) { vos::OGuard aGuard( Application::GetSolarMutex() ); - return GetPropertyValuesTolerant_Impl( rPropertyNames, sal_True ); + + return m_pImpl->GetPropertyValuesTolerant_Impl( rPropertyNames, true ); } -uno::Sequence< beans::GetDirectPropertyTolerantResult > SAL_CALL SwXParagraph::GetPropertyValuesTolerant_Impl( +uno::Sequence< beans::GetDirectPropertyTolerantResult > +SwXParagraph::Impl::GetPropertyValuesTolerant_Impl( const uno::Sequence< OUString >& rPropertyNames, - sal_Bool bDirectValuesOnly ) - throw (uno::RuntimeException) + bool bDirectValuesOnly ) +throw (uno::RuntimeException) { vos::OGuard aGuard( Application::GetSolarMutex() ); - const SwTxtNode * const pTxtNode( GetTxtNode() ); - DBG_ASSERT( pTxtNode != NULL, "need text node" ); - if (!pTxtNode) - throw uno::RuntimeException(); + SwTxtNode & rTxtNode(GetTxtNodeOrThrow()); // #i46786# Use SwAttrSet pointer for determining the state. // Use the value SwAttrSet (from the paragraph OR the style) // for determining the actual value(s). - const SwAttrSet* pAttrSet = pTxtNode->GetpSwAttrSet(); - const SwAttrSet& rValueAttrSet = pTxtNode->GetSwAttrSet(); + const SwAttrSet* pAttrSet = rTxtNode.GetpSwAttrSet(); + const SwAttrSet& rValueAttrSet = rTxtNode.GetSwAttrSet(); sal_Int32 nProps = rPropertyNames.getLength(); const OUString *pProp = rPropertyNames.getConstArray(); @@ -572,7 +752,7 @@ uno::Sequence< beans::GetDirectPropertyTolerantResult > SAL_CALL SwXParagraph::G sal_Int32 nIdx = 0; // get entry to start with - const SfxItemPropertyMap *pPropMap = m_pPropSet->getPropertyMap(); + SfxItemPropertyMap const*const pPropMap = m_rPropSet.getPropertyMap(); for (sal_Int32 i = 0; i < nProps; ++i) { @@ -583,23 +763,28 @@ uno::Sequence< beans::GetDirectPropertyTolerantResult > SAL_CALL SwXParagraph::G { rResult.Name = pProp[i]; - const SfxItemPropertySimpleEntry* pEntry = pPropMap->getByName( pProp[i] ); + SfxItemPropertySimpleEntry const*const pEntry = + pPropMap->getByName( pProp[i] ); if (!pEntry) // property available? - rResult.Result = beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY; + { + rResult.Result = + beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY; + } else { // get property state // (compare to SwXParagraph::getPropertyState) sal_Bool bAttrSetFetched = sal_True; beans::PropertyState eState = lcl_SwXParagraph_getPropertyState( - *pTxtNode, &pAttrSet, *pEntry, bAttrSetFetched ); + rTxtNode, &pAttrSet, *pEntry, bAttrSetFetched ); rResult.State = eState; // if (bDirectValuesOnly && PropertyState_DIRECT_VALUE != eState) // rResult.Result = beans::TolerantPropertySetResultType::NO_DIRECT_VALUE; // else rResult.Result = beans::TolerantPropertySetResultType::UNKNOWN_FAILURE; - if (!bDirectValuesOnly || beans::PropertyState_DIRECT_VALUE == eState) + if (!bDirectValuesOnly || + (beans::PropertyState_DIRECT_VALUE == eState)) { // get property value // (compare to SwXParagraph::getPropertyValue(s)) @@ -607,18 +792,21 @@ uno::Sequence< beans::GetDirectPropertyTolerantResult > SAL_CALL SwXParagraph::G if (!SwXParagraph::getDefaultTextContentValue( aValue, pProp[i], pEntry->nWID ) ) { - SwPosition aPos( *pTxtNode ); + SwPosition aPos( rTxtNode ); SwPaM aPam( aPos ); // handle properties that are not part of the attribute // and thus only pretendend to be paragraph attributes - BOOL bDone = FALSE; beans::PropertyState eTemp; - bDone = SwUnoCursorHelper::getCrsrPropertyValue( - *pEntry, aPam, &aValue, eTemp, pTxtNode ); + const bool bDone = + SwUnoCursorHelper::getCrsrPropertyValue( + *pEntry, aPam, &aValue, eTemp, &rTxtNode ); // if not found try the real paragraph attributes... if (!bDone) - m_pPropSet->getPropertyValue( *pEntry, rValueAttrSet, aValue ); + { + m_rPropSet.getPropertyValue( + *pEntry, rValueAttrSet, aValue ); + } } rResult.Value = aValue; @@ -661,7 +849,8 @@ uno::Sequence< beans::GetDirectPropertyTolerantResult > SAL_CALL SwXParagraph::G /* -----------------------------12.09.00 11:09-------------------------------- ---------------------------------------------------------------------------*/ -BOOL SwXParagraph::getDefaultTextContentValue(uno::Any& rAny, const OUString& rPropertyName, USHORT nWID) +bool SwXParagraph::getDefaultTextContentValue( + uno::Any& rAny, const OUString& rPropertyName, USHORT nWID) { if(!nWID) { @@ -694,35 +883,59 @@ BOOL SwXParagraph::getDefaultTextContentValue(uno::Any& rAny, const OUString& rP /*-- 11.12.98 08:12:50--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXParagraph::addPropertyChangeListener( - const OUString& /*PropertyName*/, - const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/) - throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +void SAL_CALL +SwXParagraph::addPropertyChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - DBG_WARNING("not implemented"); + OSL_ENSURE(false, + "SwXParagraph::addPropertyChangeListener(): not implemented"); } + /*-- 11.12.98 08:12:50--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXParagraph::removePropertyChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +void SAL_CALL +SwXParagraph::removePropertyChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - DBG_WARNING("not implemented"); + OSL_ENSURE(false, + "SwXParagraph::removePropertyChangeListener(): not implemented"); } + /*-- 11.12.98 08:12:50--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXParagraph::addVetoableChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +void SAL_CALL +SwXParagraph::addVetoableChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - DBG_WARNING("not implemented"); + OSL_ENSURE(false, + "SwXParagraph::addVetoableChangeListener(): not implemented"); } + /*-- 11.12.98 08:12:51--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXParagraph::removeVetoableChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/) - throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +void SAL_CALL +SwXParagraph::removeVetoableChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - DBG_WARNING("not implemented"); + OSL_ENSURE(false, + "SwXParagraph::removeVetoableChangeListener(): not implemented"); } + //----------------------------------------------------------------------------- beans::PropertyState lcl_SwXParagraph_getPropertyState( // SwUnoCrsr& rUnoCrsr, @@ -730,7 +943,7 @@ beans::PropertyState lcl_SwXParagraph_getPropertyState( const SwAttrSet** ppSet, const SfxItemPropertySimpleEntry& rEntry, sal_Bool &rAttrSetFetched ) - throw( beans::UnknownPropertyException) +throw (beans::UnknownPropertyException) { beans::PropertyState eRet = beans::PropertyState_DEFAULT_VALUE; @@ -786,348 +999,393 @@ beans::PropertyState lcl_SwXParagraph_getPropertyState( /*-- 05.03.99 11:37:30--------------------------------------------------- -----------------------------------------------------------------------*/ -beans::PropertyState SwXParagraph::getPropertyState(const OUString& rPropertyName) - throw( beans::UnknownPropertyException, uno::RuntimeException ) +beans::PropertyState SAL_CALL +SwXParagraph::getPropertyState(const OUString& rPropertyName) +throw (beans::UnknownPropertyException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - beans::PropertyState eRet = beans::PropertyState_DEFAULT_VALUE; - const SwTxtNode * const pTxtNode( GetTxtNode() ); - if (pTxtNode) + + SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow()); + + const SwAttrSet* pSet = 0; + SfxItemPropertySimpleEntry const*const pEntry = + m_pImpl->m_rPropSet.getPropertyMap()->getByName(rPropertyName); + if (!pEntry) { - const SwAttrSet* pSet = 0; - const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName( rPropertyName ); - if(!pEntry) - throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); - sal_Bool bDummy = sal_False; - eRet = lcl_SwXParagraph_getPropertyState( *pTxtNode, &pSet, *pEntry, - bDummy ); + throw beans::UnknownPropertyException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) + + rPropertyName, + static_cast(this)); } - else - throw uno::RuntimeException(); + sal_Bool bDummy = sal_False; + const beans::PropertyState eRet = + lcl_SwXParagraph_getPropertyState(rTxtNode, &pSet, *pEntry, bDummy); return eRet; } /*-- 05.03.99 11:37:32--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Sequence< beans::PropertyState > SwXParagraph::getPropertyStates( +uno::Sequence< beans::PropertyState > SAL_CALL +SwXParagraph::getPropertyStates( const uno::Sequence< OUString >& PropertyNames) - throw( beans::UnknownPropertyException, uno::RuntimeException ) +throw (beans::UnknownPropertyException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + + SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow()); + const OUString* pNames = PropertyNames.getConstArray(); uno::Sequence< beans::PropertyState > aRet(PropertyNames.getLength()); beans::PropertyState* pStates = aRet.getArray(); + SfxItemPropertyMap const*const pMap = m_pImpl->m_rPropSet.getPropertyMap(); + const SwAttrSet* pSet = 0; + sal_Bool bAttrSetFetched = sal_False; - const SwTxtNode * pTxtNode( GetTxtNode() ); - if (pTxtNode) + for (sal_Int32 i = 0, nEnd = PropertyNames.getLength(); i < nEnd; + ++i, ++pStates, ++pNames) { - const SfxItemPropertyMap* pMap = m_pPropSet->getPropertyMap(); - const SwAttrSet* pSet = 0; - sal_Bool bAttrSetFetched = sal_False; - for(sal_Int32 i = 0, nEnd = PropertyNames.getLength(); i < nEnd; i++,++pStates,++pNames ) + SfxItemPropertySimpleEntry const*const pEntry = + pMap->getByName( *pNames ); + if (!pEntry) { - const SfxItemPropertySimpleEntry* pEntry = pMap->getByName( *pNames ); - if(!pEntry) - throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + *pNames, static_cast < cppu::OWeakObject * > ( this ) ); + throw beans::UnknownPropertyException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) + + *pNames, + static_cast(this)); + } - if (bAttrSetFetched && !pSet && isATR(pEntry->nWID)) - { - *pStates = beans::PropertyState_DEFAULT_VALUE; - } - else - { - *pStates = lcl_SwXParagraph_getPropertyState( - *pTxtNode, &pSet, *pEntry, bAttrSetFetched ); - } + if (bAttrSetFetched && !pSet && isATR(pEntry->nWID)) + { + *pStates = beans::PropertyState_DEFAULT_VALUE; + } + else + { + *pStates = lcl_SwXParagraph_getPropertyState( + rTxtNode, &pSet, *pEntry, bAttrSetFetched ); } } - else - throw uno::RuntimeException(); return aRet; } + /*-- 05.03.99 11:37:33--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXParagraph::setPropertyToDefault(const OUString& rPropertyName) - throw( beans::UnknownPropertyException, uno::RuntimeException ) +void SAL_CALL +SwXParagraph::setPropertyToDefault(const OUString& rPropertyName) +throw (beans::UnknownPropertyException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - const SwTxtNode * pTxtNode( GetTxtNode() ); - if (pTxtNode) + + SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow()); + + SwPosition aPos( rTxtNode ); + SwCursor aCursor( aPos, 0, false ); + if (rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_ANCHOR_TYPE)) || + rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_ANCHOR_TYPES)) || + rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_TEXT_WRAP))) { - SwPosition aPos( *pTxtNode ); - SwCursor aCursor( aPos, 0, false ); - if( rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_ANCHOR_TYPE)) || - rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_ANCHOR_TYPES)) || - rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_TEXT_WRAP))) - return; + return; + } - // select paragraph - SwParaSelection aParaSel( & aCursor ); - const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName( rPropertyName ); - if(pEntry) - { - if ( pEntry->nFlags & beans::PropertyAttribute::READONLY) - throw uno::RuntimeException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only:" ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); + // select paragraph + SwParaSelection aParaSel( aCursor ); + SfxItemPropertySimpleEntry const*const pEntry = + m_pImpl->m_rPropSet.getPropertyMap()->getByName( rPropertyName ); + if (!pEntry) + { + throw beans::UnknownPropertyException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) + + rPropertyName, + static_cast(this)); + } - if(pEntry->nWID < RES_FRMATR_END) + if (pEntry->nFlags & beans::PropertyAttribute::READONLY) + { + throw uno::RuntimeException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Property is read-only: ")) + + rPropertyName, + static_cast(this)); + } + + if (pEntry->nWID < RES_FRMATR_END) + { + SvUShortsSort aWhichIds; + aWhichIds.Insert(pEntry->nWID); + if (pEntry->nWID < RES_PARATR_BEGIN) + { + aCursor.GetDoc()->ResetAttrs(aCursor, sal_True, &aWhichIds); + } + else + { + // for paragraph attributes the selection must be extended + // to paragraph boundaries + SwPosition aStart( *aCursor.Start() ); + SwPosition aEnd ( *aCursor.End() ); + ::std::auto_ptr pTemp( + aCursor.GetDoc()->CreateUnoCrsr(aStart, sal_False) ); + if(!SwUnoCursorHelper::IsStartOfPara(*pTemp)) { - SvUShortsSort aWhichIds; - aWhichIds.Insert(pEntry->nWID); - if(pEntry->nWID < RES_PARATR_BEGIN) - { - aCursor.GetDoc()->ResetAttrs(aCursor, sal_True, &aWhichIds); - } - else - { - // for paragraph attributes the selection must be extended - // to paragraph boundaries - SwPosition aStart( *aCursor.Start() ); - SwPosition aEnd ( *aCursor.End() ); - std::auto_ptr pTemp( - aCursor.GetDoc()->CreateUnoCrsr(aStart, sal_False) ); - if(!SwUnoCursorHelper::IsStartOfPara(*pTemp)) - { - pTemp->MovePara(fnParaCurr, fnParaStart); - } - pTemp->SetMark(); - *pTemp->GetPoint() = aEnd; - //pTemp->Exchange(); - SwXTextCursor::SelectPam(*pTemp, sal_True); - if(!SwUnoCursorHelper::IsEndOfPara(*pTemp)) - { - pTemp->MovePara(fnParaCurr, fnParaEnd); - } - pTemp->GetDoc()->ResetAttrs(*pTemp, sal_True, &aWhichIds); - } + pTemp->MovePara(fnParaCurr, fnParaStart); } - else + pTemp->SetMark(); + *pTemp->GetPoint() = aEnd; + //pTemp->Exchange(); + SwXTextCursor::SelectPam(*pTemp, sal_True); + if (!SwUnoCursorHelper::IsEndOfPara(*pTemp)) { - SwUnoCursorHelper::resetCrsrPropertyValue(*pEntry, aCursor); + pTemp->MovePara(fnParaCurr, fnParaEnd); } + pTemp->GetDoc()->ResetAttrs(*pTemp, sal_True, &aWhichIds); } - else - throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); } else - throw uno::RuntimeException(); + { + SwUnoCursorHelper::resetCrsrPropertyValue(*pEntry, aCursor); + } } + /*-- 05.03.99 11:37:33--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Any SwXParagraph::getPropertyDefault(const OUString& rPropertyName) - throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +uno::Any SAL_CALL +SwXParagraph::getPropertyDefault(const OUString& rPropertyName) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { + vos::OGuard g(Application::GetSolarMutex()); + + SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow()); + uno::Any aRet; - const SwTxtNode * pTxtNode( GetTxtNode() ); - if (pTxtNode) + if (SwXParagraph::getDefaultTextContentValue(aRet, rPropertyName)) { - if(SwXParagraph::getDefaultTextContentValue(aRet, rPropertyName)) - return aRet; + return aRet; + } - const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName( rPropertyName ); - if(pEntry) - { - if(pEntry->nWID < RES_FRMATR_END) - { - const SfxPoolItem& rDefItem = - pTxtNode->GetDoc()->GetAttrPool().GetDefaultItem( - pEntry->nWID); - rDefItem.QueryValue(aRet, pEntry->nMemberId); - } - } - else - throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); + SfxItemPropertySimpleEntry const*const pEntry = + m_pImpl->m_rPropSet.getPropertyMap()->getByName(rPropertyName); + if (!pEntry) + { + throw beans::UnknownPropertyException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) + + rPropertyName, + static_cast(this)); + } + + if (pEntry->nWID < RES_FRMATR_END) + { + const SfxPoolItem& rDefItem = + rTxtNode.GetDoc()->GetAttrPool().GetDefaultItem(pEntry->nWID); + rDefItem.QueryValue(aRet, pEntry->nMemberId); } - else - throw uno::RuntimeException(); return aRet; } + /*-- 11.12.98 08:12:51--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXParagraph::attach(const uno::Reference< text::XTextRange > & /*xTextRange*/) - throw( lang::IllegalArgumentException, uno::RuntimeException ) +void SAL_CALL +SwXParagraph::attach(const uno::Reference< text::XTextRange > & /*xTextRange*/) +throw (lang::IllegalArgumentException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - // SwXParagraph will only created in order to be inserteb by + // SwXParagraph will only created in order to be inserted by // 'insertTextContentBefore' or 'insertTextContentAfter' therefore // they cannot be attached throw uno::RuntimeException(); } + /*-- 11.12.98 08:12:51--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextRange > SwXParagraph::getAnchor(void) throw( uno::RuntimeException ) +uno::Reference< text::XTextRange > SAL_CALL +SwXParagraph::getAnchor() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< text::XTextRange > aRet; - const SwTxtNode * pTxtNode( GetTxtNode() ); - if (pTxtNode) - { - SwPosition aPos( *pTxtNode ); - SwCursor aCursor( aPos, 0, false ); - // select paragraph - SwParaSelection aParaSel( & aCursor ); - aRet = new SwXTextRange(aCursor, xParentText); - } - else - throw uno::RuntimeException(); - return aRet; + + SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow()); + + SwPosition aPos( rTxtNode ); + SwCursor aCursor( aPos, 0, false ); + // select paragraph + SwParaSelection aParaSel( aCursor ); + const uno::Reference< text::XTextRange > xRet = + new SwXTextRange(aCursor, m_pImpl->m_xParentText); + return xRet; } + /*-- 11.12.98 08:12:52--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXParagraph::dispose(void) throw( uno::RuntimeException ) +void SAL_CALL SwXParagraph::dispose() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwTxtNode * pTxtNode( GetTxtNode() ); + + SwTxtNode *const pTxtNode( m_pImpl->GetTxtNode() ); if (pTxtNode) { SwCursor aCursor( SwPosition( *pTxtNode ), 0, false ); // select paragraph { - SwParaSelection aParaSel( & aCursor ); + SwParaSelection aParaSel( aCursor ); pTxtNode->GetDoc()->DelFullPara(aCursor); } - aLstnrCntnr.Disposing(); + m_pImpl->m_ListenerContainer.Disposing(); } - else - throw uno::RuntimeException(); } + /*-- 11.12.98 08:12:52--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXParagraph::addEventListener(const uno::Reference< lang::XEventListener > & aListener) throw( uno::RuntimeException ) +void SAL_CALL SwXParagraph::addEventListener( + const uno::Reference< lang::XEventListener > & xListener) +throw (uno::RuntimeException) { - if(!GetRegisteredIn()) + vos::OGuard g(Application::GetSolarMutex()); + + if (!m_pImpl->GetTxtNode()) + { throw uno::RuntimeException(); - aLstnrCntnr.AddListener(aListener); + } + m_pImpl->m_ListenerContainer.AddListener(xListener); } /*-- 11.12.98 08:12:53--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXParagraph::removeEventListener(const uno::Reference< lang::XEventListener > & aListener) throw( uno::RuntimeException ) +void SAL_CALL SwXParagraph::removeEventListener( + const uno::Reference< lang::XEventListener > & xListener) +throw (uno::RuntimeException) { - if(!GetRegisteredIn() || !aLstnrCntnr.RemoveListener(aListener)) + vos::OGuard g(Application::GetSolarMutex()); + + if (!m_pImpl->GetTxtNode() || + !m_pImpl->m_ListenerContainer.RemoveListener(xListener)) + { throw uno::RuntimeException(); + } } + /*-- 11.12.98 08:12:53--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< container::XEnumeration > SwXParagraph::createEnumeration(void) throw( uno::RuntimeException ) +uno::Reference< container::XEnumeration > SAL_CALL +SwXParagraph::createEnumeration() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< container::XEnumeration > aRef; - const SwTxtNode * pTxtNode( GetTxtNode() ); - if (pTxtNode) - { - SwPosition aPos( *pTxtNode ); - SwPaM aPam ( aPos ); - aRef = new SwXTextPortionEnumeration(aPam, xParentText, - nSelectionStartPos, nSelectionEndPos); - } - else - throw uno::RuntimeException(); - return aRef; + SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow()); + + SwPosition aPos( rTxtNode ); + SwPaM aPam ( aPos ); + const uno::Reference< container::XEnumeration > xRef = + new SwXTextPortionEnumeration(aPam, m_pImpl->m_xParentText, + m_pImpl->m_nSelectionStartPos, m_pImpl->m_nSelectionEndPos); + return xRef; } + /*-- 11.12.98 08:12:54--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Type SwXParagraph::getElementType(void) throw( uno::RuntimeException ) +uno::Type SAL_CALL SwXParagraph::getElementType() throw (uno::RuntimeException) { - return ::getCppuType((uno::Reference*)0); + return text::XTextRange::static_type(); } /*-- 11.12.98 08:12:54--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXParagraph::hasElements(void) throw( uno::RuntimeException ) +sal_Bool SAL_CALL SwXParagraph::hasElements() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); return (GetTxtNode()) ? sal_True : sal_False; } + /*-- 11.12.98 08:12:55--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XText > SwXParagraph::getText(void) throw( uno::RuntimeException ) +uno::Reference< text::XText > SAL_CALL +SwXParagraph::getText() throw (uno::RuntimeException) { - return xParentText; + vos::OGuard g(Application::GetSolarMutex()); + + return m_pImpl->m_xParentText; } + /*-- 11.12.98 08:12:55--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextRange > SwXParagraph::getStart(void) throw( uno::RuntimeException ) +uno::Reference< text::XTextRange > SAL_CALL +SwXParagraph::getStart() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< text::XTextRange > xRet; - const SwTxtNode * pTxtNode( GetTxtNode() ); - if (pTxtNode) - { - SwPosition aPos( *pTxtNode ); - SwCursor aCursor( aPos, 0, false ); - SwParaSelection aParaSel( &aCursor ); - SwPaM aPam( *aCursor.Start() ); - uno::Reference< text::XText > xParent = getText(); - xRet = new SwXTextRange(aPam, xParent); - } - else - throw uno::RuntimeException(); + + SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow()); + + SwPosition aPos( rTxtNode ); + SwCursor aCursor( aPos, 0, false ); + SwParaSelection aParaSel( aCursor ); + SwPaM aPam( *aCursor.Start() ); + uno::Reference< text::XText > xParent = getText(); + const uno::Reference< text::XTextRange > xRet = + new SwXTextRange(aPam, xParent); return xRet; } /*-- 11.12.98 08:12:56--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextRange > SwXParagraph::getEnd(void) throw( uno::RuntimeException ) +uno::Reference< text::XTextRange > SAL_CALL +SwXParagraph::getEnd() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< text::XTextRange > xRet; - const SwTxtNode * pTxtNode( GetTxtNode() ); - if (pTxtNode) - { - SwPosition aPos( *pTxtNode ); - SwCursor aCursor( aPos, 0, false ); - SwParaSelection aParaSel( &aCursor ); - SwPaM aPam( *aCursor.End() ); - uno::Reference< text::XText > xParent = getText(); - xRet = new SwXTextRange(aPam, xParent); - } - else - throw uno::RuntimeException(); + + SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow()); + + SwPosition aPos( rTxtNode ); + SwCursor aCursor( aPos, 0, false ); + SwParaSelection aParaSel( aCursor ); + SwPaM aPam( *aCursor.End() ); + uno::Reference< text::XText > xParent = getText(); + const uno::Reference< text::XTextRange > xRet = + new SwXTextRange(aPam, xParent); return xRet; } + /*-- 11.12.98 08:12:56--------------------------------------------------- -----------------------------------------------------------------------*/ -OUString SwXParagraph::getString(void) throw( uno::RuntimeException ) +OUString SAL_CALL SwXParagraph::getString() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); OUString aRet; - const SwTxtNode * pTxtNode( GetTxtNode() ); + SwTxtNode const*const pTxtNode( GetTxtNode() ); if (pTxtNode) { SwPosition aPos( *pTxtNode ); SwCursor aCursor( aPos, 0, false ); - SwParaSelection aParaSel( & aCursor ); + SwParaSelection aParaSel( aCursor ); SwXTextCursor::getTextFromPam(aCursor, aRet); } - else if(IsDescriptor()) - aRet = m_sText; + else if (m_pImpl->IsDescriptor()) + { + aRet = m_pImpl->m_sText; + } else + { throw uno::RuntimeException(); + } return aRet; } /*-- 11.12.98 08:12:57--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXParagraph::setString(const OUString& aString) throw( uno::RuntimeException ) +void SAL_CALL SwXParagraph::setString(const OUString& aString) +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - const SwTxtNode * pTxtNode( GetTxtNode() ); + SwTxtNode const*const pTxtNode( GetTxtNode() ); if (pTxtNode) { SwPosition aPos( *pTxtNode ); @@ -1142,23 +1400,33 @@ void SwXParagraph::setString(const OUString& aString) throw( uno::RuntimeExcepti SwXTextCursor::SetString(aCursor, aString); SwXTextCursor::SelectPam(aCursor, sal_False); } - else if(IsDescriptor()) - m_sText = aString; + else if (m_pImpl->IsDescriptor()) + { + m_pImpl->m_sText = aString; + } else + { throw uno::RuntimeException(); - + } } + /* -----------------23.03.99 12:49------------------- * * --------------------------------------------------*/ -uno::Reference< container::XEnumeration > SwXParagraph::createContentEnumeration(const OUString& rServiceName) - throw( uno::RuntimeException ) +uno::Reference< container::XEnumeration > SAL_CALL +SwXParagraph::createContentEnumeration(const OUString& rServiceName) +throw (uno::RuntimeException) { - const SwTxtNode * pTxtNode( GetTxtNode() ); - if(!pTxtNode || !rServiceName.equalsAscii("com.sun.star.text.TextContent")) + vos::OGuard g(Application::GetSolarMutex()); + + if (!rServiceName.equalsAscii("com.sun.star.text.TextContent")) + { throw uno::RuntimeException(); + } - SwPosition aPos( *pTxtNode ); + SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow()); + + SwPosition aPos( rTxtNode ); SwPaM aPam( aPos ); uno::Reference< container::XEnumeration > xRet = new SwXParaFrameEnumeration(aPam, PARAFRAME_PORTION_PARAGRAPH); @@ -1167,50 +1435,31 @@ uno::Reference< container::XEnumeration > SwXParagraph::createContentEnumeratio /* -----------------23.03.99 12:49------------------- * * --------------------------------------------------*/ -uno::Sequence< OUString > SwXParagraph::getAvailableServiceNames(void) throw( uno::RuntimeException ) +uno::Sequence< OUString > SAL_CALL +SwXParagraph::getAvailableServiceNames() throw (uno::RuntimeException) { uno::Sequence< OUString > aRet(1); OUString* pArray = aRet.getArray(); pArray[0] = C2U("com.sun.star.text.TextContent"); return aRet; } -/*-- 11.12.98 08:12:58--------------------------------------------------- - - -----------------------------------------------------------------------*/ -void SwXParagraph::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew) -{ - ClientModify(this, pOld, pNew); - if(!GetRegisteredIn()) - aLstnrCntnr.Disposing(); -} - -const SwTxtNode * SwXParagraph::GetTxtNode() const -{ - return static_cast(GetRegisteredIn()); -} -SwTxtNode * SwXParagraph::GetTxtNode() -{ - return static_cast(pRegisteredIn); -} +// MetadatableMixin ::sfx2::Metadatable* SwXParagraph::GetCoreObject() { - SwTxtNode * pTxtNode( GetTxtNode() ); + SwTxtNode *const pTxtNode( m_pImpl->GetTxtNode() ); return pTxtNode; } uno::Reference SwXParagraph::GetModel() { - SwTxtNode * pTxtNode( GetTxtNode() ); + SwTxtNode *const pTxtNode( m_pImpl->GetTxtNode() ); if (pTxtNode) { - const SwDocShell * pShell( pTxtNode->GetDoc()->GetDocShell() ); + SwDocShell const*const pShell( pTxtNode->GetDoc()->GetDocShell() ); return (pShell) ? pShell->GetModel() : 0; } - else - { - return 0; - } + return 0; } diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index e571cd722f6c..75eebe7047b2 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -666,7 +666,10 @@ void SwXText::insertTextContentBefore( throw aRuntime; } - SwXParagraph* pPara = SwXParagraph::GetImplementation(xNewContent); + const uno::Reference xParaTunnel(xNewContent, + uno::UNO_QUERY); + SwXParagraph *const pPara = + ::sw::UnoTunnelGetImplementation(xParaTunnel); if(!pPara || !pPara->IsDescriptor() || !xSuccessor.is()) throw lang::IllegalArgumentException(); @@ -718,7 +721,10 @@ void SwXText::insertTextContentAfter( vos::OGuard aGuard(Application::GetSolarMutex()); if(!GetDoc()) throw uno::RuntimeException(); - SwXParagraph* pPara = SwXParagraph::GetImplementation(xNewContent); + const uno::Reference xParaTunnel(xNewContent, + uno::UNO_QUERY); + SwXParagraph *const pPara = + ::sw::UnoTunnelGetImplementation(xParaTunnel); if(!pPara || !pPara->IsDescriptor() || !xPredecessor.is()) throw lang::IllegalArgumentException(); @@ -1414,7 +1420,10 @@ uno::Reference< text::XTextRange > SwXText::finishOrAppendParagraph( } SwTxtNode * pTxtNode( aPam.Start()->nNode.GetNode().GetTxtNode() ); OSL_ENSURE(pTxtNode, "no SwTxtNode?"); - xRet = new SwXParagraph(this, pTxtNode); + if (pTxtNode) + { + xRet.set(SwXParagraph::CreateXParagraph(*pDoc, *pTxtNode, this), uno::UNO_QUERY); + } } return xRet; -- cgit From 77ca8486db12a970aef9aeafea3ac9a4c297d2b2 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 8 Jan 2010 17:13:51 +0100 Subject: swunolocking1: #i105557#: fix locking for SwXParagraphEnumeration: add Impl struct, and use UnoImplPtr to lock destructor. move all implementation details out of header, into Impl struct. use new XServiceInfo helpers. clean up the implementation a little. --- sw/inc/unoparagraph.hxx | 56 +---- sw/source/core/unocore/unoframe.cxx | 7 +- sw/source/core/unocore/unoftn.cxx | 8 +- sw/source/core/unocore/unoobj2.cxx | 445 ++++++++++++++++++++-------------- sw/source/core/unocore/unoredline.cxx | 8 +- sw/source/core/unocore/unotbl.cxx | 13 +- sw/source/core/unocore/unotext.cxx | 15 +- 7 files changed, 303 insertions(+), 249 deletions(-) (limited to 'sw') diff --git a/sw/inc/unoparagraph.hxx b/sw/inc/unoparagraph.hxx index d5c5e2ed2832..b14aeb7dc3d9 100644 --- a/sw/inc/unoparagraph.hxx +++ b/sw/inc/unoparagraph.hxx @@ -32,6 +32,8 @@ #ifndef SW_UNOPARAGRAPH_HXX #define SW_UNOPARAGRAPH_HXX +#include + #include #include #include @@ -47,16 +49,13 @@ #include -#include #include struct SwPosition; class SwPaM; class SwUnoCrsr; -class SwStartNode; class SwTxtNode; -class SwTable; class SwXText; @@ -327,60 +326,23 @@ public: --------------------------------------------------*/ class SwXParagraphEnumeration : public SwSimpleEnumeration_Base - , public SwClient { private: - ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > - xParentText; - ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > - xNextPara; - - const SwTable * pOwnTable; - /// Start node of the cell the enumeration belongs to. - /// Used to restrict the movement of the UNO cursor to the cell and its - /// embedded tables. - const SwStartNode * pOwnStartNode; - sal_Int32 nFirstParaStart; - sal_Int32 nLastParaEnd; - ULONG nEndIndex; - CursorType eCursorType; - BOOL bFirstParagraph; - - SwUnoCrsr* GetCrsr() {return (SwUnoCrsr*)GetRegisteredIn();} - -protected: + class Impl; + ::sw::UnoImplPtr m_pImpl; virtual ~SwXParagraphEnumeration(); - virtual ::com::sun::star::uno::Reference< - ::com::sun::star::text::XTextContent > SAL_CALL - NextElement_Impl() - throw (::com::sun::star::container::NoSuchElementException, - ::com::sun::star::lang::WrappedTargetException, - ::com::sun::star::uno::RuntimeException); - public: + /// takes ownership of cursor SwXParagraphEnumeration( - SwXText* pParent, SwPosition& rPos, CursorType eType); - SwXParagraphEnumeration( - SwXText* pParent, SwUnoCrsr* pCrsr, CursorType eType); - - // non-Uno functions - - void SetOwnTable(const SwTable* pTable) - { pOwnTable = pTable; } - const SwTable* GetOwnTable() const - { return pOwnTable; } - void SetOwnStartNode(const SwStartNode* pNode) - { pOwnStartNode = pNode; } - const SwStartNode* GetOwnStartNode() const - { return pOwnStartNode; } - - // SwClient - virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > + const & xParent, + ::std::auto_ptr pCursor, + const CursorType eType); // XServiceInfo virtual ::rtl::OUString SAL_CALL getImplementationName() diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx index 9d3fab300c03..8b3349332895 100644 --- a/sw/source/core/unocore/unoframe.cxx +++ b/sw/source/core/unocore/unoframe.cxx @@ -2700,14 +2700,15 @@ uno::Reference< container::XEnumeration > SwXTextFrame::createEnumeration(void) if(pFmt) { SwPosition aPos(pFmt->GetCntnt().GetCntntIdx()->GetNode()); - SwUnoCrsr* pUnoCrsr = GetDoc()->CreateUnoCrsr(aPos, sal_False); - pUnoCrsr->Move( fnMoveForward, fnGoNode ); + ::std::auto_ptr pUnoCursor( + GetDoc()->CreateUnoCrsr(aPos, sal_False)); + pUnoCursor->Move(fnMoveForward, fnGoNode); // // no Cursor in protected sections // SwCrsrSaveState aSave( *pUnoCrsr ); // if(pUnoCrsr->IsInProtectTable( sal_True ) || // pUnoCrsr->IsSelOvr( SELOVER_TOGGLE | SELOVER_CHANGEPOS )) // throw uno::RuntimeException() ); - aRef = new SwXParagraphEnumeration(this, pUnoCrsr, CURSOR_FRAME); + aRef = new SwXParagraphEnumeration(this, pUnoCursor, CURSOR_FRAME); } return aRef; } diff --git a/sw/source/core/unocore/unoftn.cxx b/sw/source/core/unocore/unoftn.cxx index 5ef6c3d3c5bc..f18a46d8ad37 100644 --- a/sw/source/core/unocore/unoftn.cxx +++ b/sw/source/core/unocore/unoftn.cxx @@ -439,10 +439,10 @@ uno::Reference< container::XEnumeration > SwXFootnote::createEnumeration() thro { const SwTxtFtn* pTxtFtn = pFmt->GetTxtFtn(); SwPosition aPos( *pTxtFtn->GetStartNode() ); - SwXTextCursor* pXCrsr = new SwXTextCursor(this, aPos, CURSOR_FOOTNOTE, GetDoc()); - SwUnoCrsr* pUnoCrsr = pXCrsr->GetCrsr(); - pUnoCrsr->Move(fnMoveForward, fnGoNode); - aRef = new SwXParagraphEnumeration(this, pUnoCrsr, CURSOR_FOOTNOTE); + ::std::auto_ptr pUnoCursor( + GetDoc()->CreateUnoCrsr(aPos, sal_False)); + pUnoCursor->Move(fnMoveForward, fnGoNode); + aRef = new SwXParagraphEnumeration(this, pUnoCursor, CURSOR_FOOTNOTE); } return aRef; } diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index b5c2ea2a6993..e3515d700d10 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -699,28 +699,22 @@ uno::Reference< XEnumeration > SwXTextCursor::createEnumeration(void) throw( Ru sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething(SwXText::getUnoTunnelId()) )); } DBG_ASSERT(pParentText, "parent is not a SwXText"); + if (!pParentText) + { + throw uno::RuntimeException(); + } - SwUnoCrsr* pNewCrsr = pUnoCrsr->GetDoc()->CreateUnoCrsr(*pUnoCrsr->GetPoint()); + ::std::auto_ptr pNewCrsr( + pUnoCrsr->GetDoc()->CreateUnoCrsr(*pUnoCrsr->GetPoint()) ); if(pUnoCrsr->HasMark()) { pNewCrsr->SetMark(); *pNewCrsr->GetMark() = *pUnoCrsr->GetMark(); } - CursorType eSetType = eType == CURSOR_TBLTEXT ? CURSOR_SELECTION_IN_TABLE : CURSOR_SELECTION; - SwXParagraphEnumeration *pEnum = + const CursorType eSetType = (CURSOR_TBLTEXT == eType) + ? CURSOR_SELECTION_IN_TABLE : CURSOR_SELECTION; + const uno::Reference< XEnumeration > xRet = new SwXParagraphEnumeration(pParentText, pNewCrsr, eSetType); - uno::Reference< XEnumeration > xRet = pEnum; - if (eType == CURSOR_TBLTEXT) - { - // for import of tables in tables we have to remember the actual - // table and start node of the current position in the enumeration. - SwTableNode *pStartN = pUnoCrsr->GetPoint()->nNode.GetNode().FindTableNode(); - if (pStartN) - { - pEnum->SetOwnTable( &pStartN->GetTable() ); - pEnum->SetOwnStartNode( pStartN ); - } - } return xRet; } @@ -959,103 +953,180 @@ void SwXTextCursor::GetCrsrAttr( SwPaM& rPam, /****************************************************************** * SwXParagraphEnumeration ******************************************************************/ -/* -----------------------------06.04.00 16:33-------------------------------- - ---------------------------------------------------------------------------*/ -OUString SwXParagraphEnumeration::getImplementationName(void) throw( RuntimeException ) +static SwStartNode * +lcl_InitStartNode(const CursorType eType, SwUnoCrsr *const pCursor) { - return C2U("SwXParagraphEnumeration"); + switch (eType) + { + case CURSOR_TBLTEXT: // table cell: pCursor points at first paragraph + return pCursor->Start()->nNode.GetNode().StartOfSectionNode(); + case CURSOR_SELECTION_IN_TABLE: // table + return pCursor->Start()->nNode.GetNode().FindTableNode(); + default: + return 0; + } } -/* -----------------------------06.04.00 16:33-------------------------------- - ---------------------------------------------------------------------------*/ -BOOL SwXParagraphEnumeration::supportsService(const OUString& rServiceName) throw( RuntimeException ) +static SwTable const* +lcl_InitTable(const CursorType eType, SwStartNode const*const pStartNode) { - return C2U("com.sun.star.text.ParagraphEnumeration") == rServiceName; -} -/* -----------------------------06.04.00 16:33-------------------------------- + switch (eType) + { + case CURSOR_TBLTEXT: // table cell + return & pStartNode->FindTableNode()->GetTable(); + case CURSOR_SELECTION_IN_TABLE: // table + return & static_cast(pStartNode)->GetTable(); + default: + return 0; + } +} + +class SwXParagraphEnumeration::Impl + : public SwClient +{ + +public: + + uno::Reference< text::XText > const m_xParentText; + const CursorType m_eCursorType; + /// Start node of the cell _or_ table the enumeration belongs to. + /// Used to restrict the movement of the UNO cursor to the cell and its + /// embedded tables. + SwStartNode const*const m_pOwnStartNode; + SwTable const*const m_pOwnTable; + const ULONG m_nEndIndex; + sal_Int32 m_nFirstParaStart; + sal_Int32 m_nLastParaEnd; + bool m_bFirstParagraph; + uno::Reference< text::XTextContent > m_xNextPara; + + Impl( uno::Reference< text::XText > const& xParent, + ::std::auto_ptr pCursor, + const CursorType eType) + : SwClient( pCursor.release() ) + , m_xParentText( xParent ) + , m_eCursorType( eType ) + // remember table and start node for later travelling + // (used in export of tables in tables) + , m_pOwnStartNode( lcl_InitStartNode(eType, GetCursor()) ) + // for import of tables in tables we have to remember the actual + // table and start node of the current position in the enumeration. + , m_pOwnTable( lcl_InitTable(eType, m_pOwnStartNode) ) + , m_nEndIndex( GetCursor()->End()->nNode.GetIndex() ) + , m_nFirstParaStart( -1 ) + , m_nLastParaEnd( -1 ) + , m_bFirstParagraph( true ) + { + OSL_ENSURE(m_xParentText.is(), "SwXParagraphEnumeration: no parent?"); + OSL_ENSURE(GetRegisteredIn(), "SwXParagraphEnumeration: no cursor?"); - ---------------------------------------------------------------------------*/ -Sequence< OUString > SwXParagraphEnumeration::getSupportedServiceNames(void) throw( RuntimeException ) -{ - Sequence< OUString > aRet(1); - OUString* pArray = aRet.getArray(); - pArray[0] = C2U("com.sun.star.text.ParagraphEnumeration"); - return aRet; -} -/*-- 10.12.98 11:52:12--------------------------------------------------- + if ((CURSOR_SELECTION == m_eCursorType) || + (CURSOR_SELECTION_IN_TABLE == m_eCursorType)) + { + SwUnoCrsr & rCursor = *GetCursor(); + rCursor.Normalize(); + m_nFirstParaStart = rCursor.GetPoint()->nContent.GetIndex(); + m_nLastParaEnd = rCursor.GetMark()->nContent.GetIndex(); + rCursor.DeleteMark(); + } + } - -----------------------------------------------------------------------*/ -SwXParagraphEnumeration::SwXParagraphEnumeration(SwXText* pParent, - SwPosition& rPos, - CursorType eType) : - xParentText(pParent), - nFirstParaStart(-1), - nLastParaEnd(-1), - nEndIndex(rPos.nNode.GetIndex()), - eCursorType(eType), - bFirstParagraph(sal_True) -{ - pOwnTable = 0; - pOwnStartNode = 0; - SwUnoCrsr* pUnoCrsr = pParent->GetDoc()->CreateUnoCrsr(rPos, sal_False); - pUnoCrsr->Add(this); + ~Impl() { + // Impl owns the cursor; delete it here: SolarMutex is locked + delete GetRegisteredIn(); + } + + SwUnoCrsr * GetCursor() { + return static_cast( + const_cast(GetRegisteredIn())); + } + + uno::Reference< text::XTextContent > NextElement_Impl() + throw (container::NoSuchElementException, lang::WrappedTargetException, + uno::RuntimeException); + + // SwClient + virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + +}; + +void SwXParagraphEnumeration::Impl::Modify(SfxPoolItem *pOld, SfxPoolItem *pNew) +{ + ClientModify(this, pOld, pNew); } /*-- 10.12.98 11:52:12--------------------------------------------------- -----------------------------------------------------------------------*/ -SwXParagraphEnumeration::SwXParagraphEnumeration(SwXText* pParent, - SwUnoCrsr* pCrsr, - CursorType eType) : - SwClient(pCrsr), - xParentText(pParent), - nFirstParaStart(-1), - nLastParaEnd(-1), - nEndIndex(pCrsr->End()->nNode.GetIndex()), - eCursorType(eType), - bFirstParagraph(sal_True) -{ - pOwnTable = 0; - pOwnStartNode = 0; - if(CURSOR_SELECTION == eCursorType || CURSOR_SELECTION_IN_TABLE == eCursorType) - { - if(*pCrsr->GetPoint() > *pCrsr->GetMark()) - pCrsr->Exchange(); - nFirstParaStart = pCrsr->GetPoint()->nContent.GetIndex(); - nLastParaEnd = pCrsr->GetMark()->nContent.GetIndex(); - if(pCrsr->HasMark()) - pCrsr->DeleteMark(); - } +SwXParagraphEnumeration::SwXParagraphEnumeration( + uno::Reference< text::XText > const& xParent, + ::std::auto_ptr pCursor, + const CursorType eType) + : m_pImpl( new SwXParagraphEnumeration::Impl(xParent, pCursor, eType) ) +{ } /*-- 10.12.98 11:52:12--------------------------------------------------- -----------------------------------------------------------------------*/ SwXParagraphEnumeration::~SwXParagraphEnumeration() { - vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) - delete pUnoCrsr; +} + +/* -----------------------------06.04.00 16:33-------------------------------- + + ---------------------------------------------------------------------------*/ +OUString SAL_CALL +SwXParagraphEnumeration::getImplementationName() throw (uno::RuntimeException) +{ + return C2U("SwXParagraphEnumeration"); +} +/* -----------------------------06.04.00 16:33-------------------------------- + + ---------------------------------------------------------------------------*/ +static char const*const g_ServicesParagraphEnum[] = +{ + "com.sun.star.text.ParagraphEnumeration", +}; +static const size_t g_nServicesParagraphEnum( + sizeof(g_ServicesParagraphEnum)/sizeof(g_ServicesParagraphEnum[0])); +sal_Bool SAL_CALL +SwXParagraphEnumeration::supportsService(const OUString& rServiceName) +throw (uno::RuntimeException) +{ + return ::sw::SupportsServiceImpl( + g_nServicesParagraphEnum, g_ServicesParagraphEnum, rServiceName); } +/* -----------------------------06.04.00 16:33-------------------------------- + + ---------------------------------------------------------------------------*/ +uno::Sequence< OUString > SAL_CALL +SwXParagraphEnumeration::getSupportedServiceNames() +throw (uno::RuntimeException) +{ + return ::sw::GetSupportedServiceNamesImpl( + g_nServicesParagraphEnum, g_ServicesParagraphEnum); +} + /*-- 10.12.98 11:52:13--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXParagraphEnumeration::hasMoreElements(void) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXParagraphEnumeration::hasMoreElements() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - return bFirstParagraph ? sal_True : xNextPara.is(); + + return (m_pImpl->m_bFirstParagraph) ? sal_True : m_pImpl->m_xNextPara.is(); } /*-- 14.08.03 13:10:14--------------------------------------------------- -----------------------------------------------------------------------*/ //!! compare to SwShellTableCrsr::FillRects() in viscrs.cxx -SwTableNode * lcl_FindTopLevelTable( - /*SwUnoCrsr* pUnoCrsr ,*/ - SwTableNode *pTblNode, - const SwTable *pOwnTable ) +static SwTableNode * +lcl_FindTopLevelTable( + SwTableNode *const pTblNode, SwTable const*const pOwnTable) { // find top-most table in current context (section) level @@ -1070,14 +1141,14 @@ SwTableNode * lcl_FindTopLevelTable( } -BOOL lcl_CursorIsInSection( - const SwUnoCrsr *pUnoCrsr, - const SwStartNode *pOwnStartNode ) +static bool +lcl_CursorIsInSection( + SwUnoCrsr const*const pUnoCrsr, SwStartNode const*const pOwnStartNode) { // returns true if the cursor is in the section (or in a sub section!) // represented by pOwnStartNode - BOOL bRes = TRUE; + bool bRes = true; if (pUnoCrsr && pOwnStartNode) { const SwEndNode * pOwnEndNode = pOwnStartNode->EndOfSectionNode(); @@ -1088,124 +1159,134 @@ BOOL lcl_CursorIsInSection( } -uno::Reference< XTextContent > SAL_CALL SwXParagraphEnumeration::NextElement_Impl(void) - throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException ) +uno::Reference< text::XTextContent > +SwXParagraphEnumeration::Impl::NextElement_Impl() +throw (container::NoSuchElementException, lang::WrappedTargetException, + uno::RuntimeException) { - uno::Reference< XTextContent > aRef; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) + SwUnoCrsr *const pUnoCrsr = GetCursor(); + if (!pUnoCrsr) { - // check for exceeding selections - if(!bFirstParagraph && - (CURSOR_SELECTION == eCursorType || CURSOR_SELECTION_IN_TABLE == eCursorType)) + throw uno::RuntimeException(); + } + + // check for exceeding selections + if (!m_bFirstParagraph && + ((CURSOR_SELECTION == m_eCursorType) || + (CURSOR_SELECTION_IN_TABLE == m_eCursorType))) + { + SwPosition* pStart = pUnoCrsr->Start(); + const ::std::auto_ptr aNewCrsr( + pUnoCrsr->GetDoc()->CreateUnoCrsr(*pStart, sal_False) ); + // one may also go into tables here + if ((CURSOR_TBLTEXT != m_eCursorType) && + (CURSOR_SELECTION_IN_TABLE != m_eCursorType)) { - SwPosition* pStart = pUnoCrsr->Start(); - ::std::auto_ptr aNewCrsr( pUnoCrsr->GetDoc()->CreateUnoCrsr(*pStart, sal_False) ); - //man soll hier auch in Tabellen landen duerfen - if(CURSOR_TBLTEXT != eCursorType && CURSOR_SELECTION_IN_TABLE != eCursorType) - aNewCrsr->SetRemainInSection( sal_False ); - - // os 2005-01-14: This part is only necessary to detect movements out of a selection - // if there is no selection we don't have to care - SwTableNode* pTblNode = aNewCrsr->GetNode()->FindTableNode(); - if((CURSOR_TBLTEXT != eCursorType && CURSOR_SELECTION_IN_TABLE != eCursorType) && pTblNode) - { - aNewCrsr->GetPoint()->nNode = pTblNode->EndOfSectionIndex(); - aNewCrsr->Move(fnMoveForward, fnGoNode); - } - else - aNewCrsr->MovePara(fnParaNext, fnParaStart); - if(nEndIndex < aNewCrsr->Start()->nNode.GetIndex()) - return aRef; // empty reference + aNewCrsr->SetRemainInSection( sal_False ); } - XText* pText = xParentText.get(); - sal_Bool bInTable = sal_False; - if(!bFirstParagraph) + // os 2005-01-14: This part is only necessary to detect movements out + // of a selection; if there is no selection we don't have to care + SwTableNode *const pTblNode = aNewCrsr->GetNode()->FindTableNode(); + if (((CURSOR_TBLTEXT != m_eCursorType) && + (CURSOR_SELECTION_IN_TABLE != m_eCursorType)) && pTblNode) { - //man soll hier auch in Tabellen landen duerfen - //if(CURSOR_TBLTEXT != eCursorType && CURSOR_SELECTION_IN_TABLE != eCursorType) - { - //BOOL bRemain = sal_False; - //pUnoCrsr->SetRemainInSection( bRemain ); - pUnoCrsr->SetRemainInSection( sal_False ); - //was mache ich, wenn ich schon in einer Tabelle stehe? - SwTableNode* pTblNode = pUnoCrsr->GetNode()->FindTableNode(); - pTblNode = lcl_FindTopLevelTable( /*pUnoCrsr,*/ pTblNode, pOwnTable ); - if(pTblNode && &pTblNode->GetTable() != pOwnTable) - { - // wir haben es mit einer fremden Tabelle zu tun - also ans Ende - pUnoCrsr->GetPoint()->nNode = pTblNode->EndOfSectionIndex(); - if(!pUnoCrsr->Move(fnMoveForward, fnGoNode)) - return aRef; - else - bInTable = sal_True; - - } - } + aNewCrsr->GetPoint()->nNode = pTblNode->EndOfSectionIndex(); + aNewCrsr->Move(fnMoveForward, fnGoNode); } + else + { + aNewCrsr->MovePara(fnParaNext, fnParaStart); + } + if (m_nEndIndex < aNewCrsr->Start()->nNode.GetIndex()) + { + return 0; + } + } - // the cursor must remain in the current section or a subsection - // before AND after the movement... - if( lcl_CursorIsInSection( pUnoCrsr, pOwnStartNode ) && - (bFirstParagraph || bInTable || - (pUnoCrsr->MovePara(fnParaNext, fnParaStart) && - lcl_CursorIsInSection( pUnoCrsr, pOwnStartNode ) ) ) ) + sal_Bool bInTable = sal_False; + if (!m_bFirstParagraph) + { + pUnoCrsr->SetRemainInSection( sal_False ); + // what to do if already in a table? + SwTableNode * pTblNode = pUnoCrsr->GetNode()->FindTableNode(); + pTblNode = lcl_FindTopLevelTable( pTblNode, m_pOwnTable ); + if (pTblNode && (&pTblNode->GetTable() != m_pOwnTable)) { - SwPosition* pStart = pUnoCrsr->Start(); - sal_Int32 nFirstContent = bFirstParagraph ? nFirstParaStart : -1; - sal_Int32 nLastContent = nEndIndex == pStart->nNode.GetIndex() ? nLastParaEnd : -1; - //steht man nun in einer Tabelle, oder in einem einfachen Absatz? - - SwTableNode* pTblNode = pUnoCrsr->GetNode()->FindTableNode(); - pTblNode = lcl_FindTopLevelTable( /*pUnoCrsr,*/ pTblNode, pOwnTable ); - if(/*CURSOR_TBLTEXT != eCursorType && CURSOR_SELECTION_IN_TABLE != eCursorType && */ - pTblNode && &pTblNode->GetTable() != pOwnTable) + // this is a foreign table: go to end + pUnoCrsr->GetPoint()->nNode = pTblNode->EndOfSectionIndex(); + if (!pUnoCrsr->Move(fnMoveForward, fnGoNode)) { - // wir haben es mit einer fremden Tabelle zu tun - SwFrmFmt* pTableFmt = (SwFrmFmt*)pTblNode->GetTable().GetFrmFmt(); - XTextTable* pTable = SwXTextTables::GetObject( *pTableFmt ); - aRef = (XTextContent*)(SwXTextTable*)pTable; - } - else - { - aRef = SwXParagraph::CreateXParagraph(*pUnoCrsr->GetDoc(), - *pStart->nNode.GetNode().GetTxtNode(), - static_cast(pText), nFirstContent, nLastContent); + return 0; } + bInTable = sal_True; } } - else - throw uno::RuntimeException(); - return aRef; + uno::Reference< text::XTextContent > xRef; + // the cursor must remain in the current section or a subsection + // before AND after the movement... + if (lcl_CursorIsInSection( pUnoCrsr, m_pOwnStartNode ) && + (m_bFirstParagraph || bInTable || + (pUnoCrsr->MovePara(fnParaNext, fnParaStart) && + lcl_CursorIsInSection( pUnoCrsr, m_pOwnStartNode )))) + { + SwPosition* pStart = pUnoCrsr->Start(); + const sal_Int32 nFirstContent = + (m_bFirstParagraph) ? m_nFirstParaStart : -1; + const sal_Int32 nLastContent = + (m_nEndIndex == pStart->nNode.GetIndex()) ? m_nLastParaEnd : -1; + + // position in a table, or in a simple paragraph? + SwTableNode * pTblNode = pUnoCrsr->GetNode()->FindTableNode(); + pTblNode = lcl_FindTopLevelTable( pTblNode, m_pOwnTable ); + if (/*CURSOR_TBLTEXT != eCursorType && CURSOR_SELECTION_IN_TABLE != eCursorType && */ + pTblNode && (&pTblNode->GetTable() != m_pOwnTable)) + { + // this is a foreign table + SwFrmFmt* pTableFmt = + static_cast(pTblNode->GetTable().GetFrmFmt()); + text::XTextTable *const pTable = + SwXTextTables::GetObject( *pTableFmt ); + xRef = static_cast( + static_cast(pTable)); + } + else + { + text::XText *const pText = m_xParentText.get(); + xRef = SwXParagraph::CreateXParagraph(*pUnoCrsr->GetDoc(), + *pStart->nNode.GetNode().GetTxtNode(), + static_cast(pText), nFirstContent, nLastContent); + } + } + + return xRef; } /*-- 10.12.98 11:52:14--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Any SwXParagraphEnumeration::nextElement(void) - throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException ) +uno::Any SAL_CALL SwXParagraphEnumeration::nextElement() +throw (container::NoSuchElementException, lang::WrappedTargetException, + uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< XTextContent > aRef; - if (bFirstParagraph) + if (m_pImpl->m_bFirstParagraph) { - xNextPara = NextElement_Impl(); - bFirstParagraph = sal_False; + m_pImpl->m_xNextPara = m_pImpl->NextElement_Impl(); + m_pImpl->m_bFirstParagraph = false; } - aRef = xNextPara; - if (!aRef.is()) + const uno::Reference< text::XTextContent > xRef = m_pImpl->m_xNextPara; + if (!xRef.is()) + { throw container::NoSuchElementException(); - xNextPara = NextElement_Impl(); + } + m_pImpl->m_xNextPara = m_pImpl->NextElement_Impl(); - uno::Any aRet(&aRef, ::getCppuType((uno::Reference*)0)); + uno::Any aRet; + aRet <<= xRef; return aRet; } -void SwXParagraphEnumeration::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew) -{ - ClientModify(this, pOld, pNew); -} /****************************************************************** * SwXTextRange @@ -1727,7 +1808,7 @@ uno::Reference< XEnumeration > SwXTextRange::createEnumeration(void) throw( Runt ::sw::mark::IMark const * const pBkmk = GetBookmark(); if(!pBkmk) throw RuntimeException(); const SwPosition& rPoint = pBkmk->GetMarkPos(); - SwUnoCrsr* pNewCrsr = pDoc->CreateUnoCrsr(rPoint, FALSE); + ::std::auto_ptr pNewCrsr(pDoc->CreateUnoCrsr(rPoint, sal_False)); if(pBkmk->IsExpanded() && pBkmk->GetOtherMarkPos() != rPoint) { pNewCrsr->SetMark(); @@ -1741,8 +1822,14 @@ uno::Reference< XEnumeration > SwXTextRange::createEnumeration(void) throw( Runt sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething(SwXText::getUnoTunnelId()) )); } DBG_ASSERT(pParentText, "parent is not a SwXText"); - CursorType eSetType = RANGE_IN_CELL == eRangePosition ? CURSOR_SELECTION_IN_TABLE : CURSOR_SELECTION; - uno::Reference< XEnumeration > xRet = + if (!pParentText) + { + throw uno::RuntimeException(); + } + + const CursorType eSetType = (RANGE_IN_CELL == eRangePosition) + ? CURSOR_SELECTION_IN_TABLE : CURSOR_SELECTION; + const uno::Reference< XEnumeration > xRet = new SwXParagraphEnumeration(pParentText, pNewCrsr, eSetType); return xRet; } diff --git a/sw/source/core/unocore/unoredline.cxx b/sw/source/core/unocore/unoredline.cxx index 031f339773a2..9cfce5c31a62 100644 --- a/sw/source/core/unocore/unoredline.cxx +++ b/sw/source/core/unocore/unoredline.cxx @@ -198,7 +198,9 @@ uno::Reference SwXRedlineText::createEnumeration(void) vos::OGuard aGuard(Application::GetSolarMutex()); SwPaM aPam(aNodeIndex); aPam.Move(fnMoveForward, fnGoNode); - return new SwXParagraphEnumeration(this, *aPam.Start(), CURSOR_REDLINE); + ::std::auto_ptr pUnoCursor( + GetDoc()->CreateUnoCrsr(*aPam.Start(), sal_False)); + return new SwXParagraphEnumeration(this, pUnoCursor, CURSOR_REDLINE); } /* --------------------------------------------------------------------------- @@ -681,7 +683,9 @@ uno::Reference< container::XEnumeration > SwXRedline::createEnumeration(void) t { SwPaM aPam(*pNodeIndex); aPam.Move(fnMoveForward, fnGoNode); - xRet = new SwXParagraphEnumeration(this, *aPam.Start(), CURSOR_REDLINE); + ::std::auto_ptr pUnoCursor( + GetDoc()->CreateUnoCrsr(*aPam.Start(), sal_False)); + xRet = new SwXParagraphEnumeration(this, pUnoCursor, CURSOR_REDLINE); } return xRet; } diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index a6ad01ea7a4f..866c4979072e 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -1214,15 +1214,12 @@ uno::Reference< container::XEnumeration > SwXCell::createEnumeration(void) thro { const SwStartNode* pSttNd = pBox->GetSttNd(); SwPosition aPos(*pSttNd); - SwUnoCrsr* pUnoCrsr = GetDoc()->CreateUnoCrsr(aPos, sal_False); - pUnoCrsr->Move( fnMoveForward, fnGoNode ); + ::std::auto_ptr pUnoCursor( + GetDoc()->CreateUnoCrsr(aPos, sal_False)); + pUnoCursor->Move(fnMoveForward, fnGoNode); - SwXParagraphEnumeration *pEnum = new SwXParagraphEnumeration(this, pUnoCrsr, CURSOR_TBLTEXT); - const SwTableNode* pTblNode = pSttNd->FindTableNode(); - // remember table and start node for later travelling - // (used in export of tables in tables) - pEnum->SetOwnTable( &pTblNode->GetTable() ); - pEnum->SetOwnStartNode( pSttNd ); + SwXParagraphEnumeration *const pEnum = + new SwXParagraphEnumeration(this, pUnoCursor, CURSOR_TBLTEXT); aRef = pEnum; // // no Cursor in protected sections diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index 75eebe7047b2..8dadfc47cdf2 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -2412,9 +2412,10 @@ uno::Reference< container::XEnumeration > SwXBodyText::createEnumeration(void) { SwNode& rNode = GetDoc()->GetNodes().GetEndOfContent(); SwPosition aPos(rNode); - SwUnoCrsr* pUnoCrsr = GetDoc()->CreateUnoCrsr(aPos, sal_False); - pUnoCrsr->Move( fnMoveBackward, fnGoDoc ); - aRef = new SwXParagraphEnumeration(this, pUnoCrsr, CURSOR_BODY); + ::std::auto_ptr pUnoCursor( + GetDoc()->CreateUnoCrsr(aPos, sal_False)); + pUnoCursor->Move(fnMoveBackward, fnGoDoc); + aRef = new SwXParagraphEnumeration(this, pUnoCursor, CURSOR_BODY); } else { @@ -2653,9 +2654,11 @@ uno::Reference< container::XEnumeration > SwXHeadFootText::createEnumeration(vo const SwFmtCntnt& rFlyCntnt = pHeadFootFmt->GetCntnt(); const SwNode& rNode = rFlyCntnt.GetCntntIdx()->GetNode(); SwPosition aPos(rNode); - SwUnoCrsr* pUnoCrsr = GetDoc()->CreateUnoCrsr(aPos, sal_False); - pUnoCrsr->Move(fnMoveForward, fnGoNode); - aRef = new SwXParagraphEnumeration(this, pUnoCrsr, bIsHeader ? CURSOR_HEADER : CURSOR_FOOTER); + ::std::auto_ptr pUnoCursor( + GetDoc()->CreateUnoCrsr(aPos, sal_False)); + pUnoCursor->Move(fnMoveForward, fnGoNode); + aRef = new SwXParagraphEnumeration(this, pUnoCursor, + (bIsHeader) ? CURSOR_HEADER : CURSOR_FOOTER); } else { -- cgit From 2fee7963e992089b67eeb2fb60da27054037da32 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 8 Jan 2010 17:13:51 +0100 Subject: swunolocking1: #i105557#: fix locking for SwXTextSection: replace SwXTextSectionClient with Impl struct, use UnoImplPtr to lock dtor. move all implementation details out of header, into Impl struct. remove ugly destruction of SwUnoCrsr via Application::PostUserEvent. replace broken SwClient iteration with a WeakReference in SwSectionFmt. add factory function CreateXTextSection. use new XUnoTunnel and XServiceInfo helpers. clean up the implementation a little. --- sw/inc/frmfmt.hxx | 19 +- sw/inc/section.hxx | 20 + sw/inc/unosection.hxx | 102 +- sw/source/core/docnode/section.cxx | 5 + sw/source/core/layout/atrfrm.cxx | 5 + sw/source/core/unocore/unocoll.cxx | 13 +- sw/source/core/unocore/unosect.cxx | 2427 ++++++++++++++++++++---------------- sw/source/core/unocore/unotext.cxx | 20 +- 8 files changed, 1413 insertions(+), 1198 deletions(-) (limited to 'sw') diff --git a/sw/inc/frmfmt.hxx b/sw/inc/frmfmt.hxx index a86b1c6689a0..61663d131aad 100644 --- a/sw/inc/frmfmt.hxx +++ b/sw/inc/frmfmt.hxx @@ -30,11 +30,14 @@ #ifndef _FRMFMT_HXX #define _FRMFMT_HXX -#include - // --> OD 2004-08-06 #i28749# #include // <-- + +#include + +#include + #include "swdllapi.h" class SwFlyFrm; @@ -51,8 +54,9 @@ class SW_DLLPUBLIC SwFrmFmt: public SwFmt { friend class SwDoc; friend class SwPageDesc; //darf den protected CTor rufen. -// friend class SwSwgReader; // der SW2-Reader auch! -// friend class Sw3IoImp; // der SW3-Reader auch! + + ::com::sun::star::uno::WeakReference< + ::com::sun::star::uno::XInterface> m_wXObject; protected: SwFrmFmt( SwAttrPool& rPool, const sal_Char* pFmtNm, @@ -136,6 +140,13 @@ public: virtual String GetDescription() const; + SW_DLLPRIVATE ::com::sun::star::uno::WeakReference< + ::com::sun::star::uno::XInterface> const& GetXObject() const + { return m_wXObject; } + SW_DLLPRIVATE void SetXObject(::com::sun::star::uno::Reference< + ::com::sun::star::uno::XInterface> const& xObject) + { m_wXObject = xObject; } + DECL_FIXEDMEMPOOL_NEWDEL_DLL(SwFrmFmt) }; diff --git a/sw/inc/section.hxx b/sw/inc/section.hxx index c530c8280870..3acd8cab16cb 100644 --- a/sw/inc/section.hxx +++ b/sw/inc/section.hxx @@ -41,6 +41,11 @@ #include #include + +namespace com { namespace sun { namespace star { + namespace text { class XTextSection; } +} } } + // Forward Deklaration class SwSectionFmt; class SwDoc; @@ -230,6 +235,13 @@ class SW_DLLPUBLIC SwSectionFmt : public SwFrmFmt { friend class SwDoc; + /** why does this exist in addition to the m_wXObject in SwFrmFmt? + in case of an index, both a SwXDocumentIndex and a SwXTextSection + register at this SwSectionFmt, so we need to have two refs. + */ + ::com::sun::star::uno::WeakReference< + ::com::sun::star::text::XTextSection> m_wXTextSection; + /* SW_DLLPUBLIC */ SwSection* _GetSection() const; SW_DLLPRIVATE void UpdateParent(); // Parent wurde veraendert @@ -271,6 +283,14 @@ public: // ist die Section eine gueltige fuers GlobalDocument? const SwSection* GetGlobalDocSection() const; + + SW_DLLPRIVATE ::com::sun::star::uno::WeakReference< + ::com::sun::star::text::XTextSection> const& GetXTextSection() const + { return m_wXTextSection; } + SW_DLLPRIVATE void SetXTextSection(::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextSection> const& xTextSection) + { m_wXTextSection = xTextSection; } + }; // -------------- inlines --------------------------------- diff --git a/sw/inc/unosection.hxx b/sw/inc/unosection.hxx index 31d15d7010d4..6f3eb1794c84 100644 --- a/sw/inc/unosection.hxx +++ b/sw/inc/unosection.hxx @@ -43,14 +43,9 @@ #include -#include -#include +#include -#include -#include - -class SfxItemPropertySet; class SwSectionFmt; @@ -58,51 +53,6 @@ class SwSectionFmt; --------------------------------------------------*/ -class SwXTextSection; - -class SwXTextSectionClient - : public SwClient -{ - -private: - - friend class SwXTextSection; - - SwXTextSection * m_pSection; - ::com::sun::star::uno::WeakReference< - ::com::sun::star::text::XTextSection > m_xReference; - - // SwClient - virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); - - SwXTextSectionClient( - SwSectionFmt& rFmt, - SwXTextSection& rTextSection, - ::com::sun::star::uno::Reference< - ::com::sun::star::text::XTextSection > xSection); - - virtual ~SwXTextSectionClient(); - - DECL_STATIC_LINK( SwXTextSectionClient, RemoveSectionClient_Impl, - SwXTextSectionClient* ); - -public: - - TYPEINFO(); - - ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextSection > - GetXTextSection(); - - static ::com::sun::star::uno::Reference< - ::com::sun::star::text::XTextSection > - CreateXTextSection(SwSectionFmt* pFmt = 0, BOOL bIndexHeader = FALSE); - static SwXTextSectionClient* Create( - SwXTextSection& rSection, - ::com::sun::star::uno::Reference< - ::com::sun::star::text::XTextSection > xSection, - SwSectionFmt& rFmt); -}; - struct SwTextSectionProperties_Impl; @@ -122,57 +72,21 @@ class SwXTextSection private: - friend class SwXTextSectionClient; - - SwEventListenerContainer aLstnrCntnr; - const SfxItemPropertySet* m_pPropSet; + class Impl; + ::sw::UnoImplPtr m_pImpl; - BOOL m_bIsDescriptor; - BOOL m_bIndexHeader; - String m_sName; - SwTextSectionProperties_Impl* pProps; - SwXTextSectionClient* m_pClient; - -protected: - - void SAL_CALL SetPropertyValues_Impl( - const ::com::sun::star::uno::Sequence< ::rtl::OUString >& - rPropertyNames, - const ::com::sun::star::uno::Sequence< - ::com::sun::star::uno::Any >& aValues) - throw (::com::sun::star::beans::UnknownPropertyException, - ::com::sun::star::beans::PropertyVetoException, - ::com::sun::star::lang::IllegalArgumentException, - ::com::sun::star::lang::WrappedTargetException, - ::com::sun::star::uno::RuntimeException); - ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL - GetPropertyValues_Impl( - const ::com::sun::star::uno::Sequence< ::rtl::OUString >& - rPropertyNames) - throw (::com::sun::star::beans::UnknownPropertyException, - ::com::sun::star::lang::WrappedTargetException, - ::com::sun::star::uno::RuntimeException); - - SwXTextSection(sal_Bool bWithFormat, sal_Bool bIndexHeader = FALSE); + SwXTextSection(SwSectionFmt *const pFmt, const bool bIndexHeader = false); virtual ~SwXTextSection(); - void ResetClient() { m_pClient = 0; } - void SetClient(SwXTextSectionClient* pClient) { m_pClient = pClient; } - public: - void attachToRange( - const ::com::sun::star::uno::Reference< - ::com::sun::star::text::XTextRange > & xTextRange) - throw (::com::sun::star::lang::IllegalArgumentException, - ::com::sun::star::uno::RuntimeException); - SwSectionFmt* GetFmt() const; - static SwXTextSection* GetImplementation( - ::com::sun::star::uno::Reference< - ::com::sun::star::uno::XInterface> xRef); + static ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextSection > + CreateXTextSection(SwSectionFmt *const pFmt = 0, + const bool bIndexHeader = false); static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId(); diff --git a/sw/source/core/docnode/section.cxx b/sw/source/core/docnode/section.cxx index 1a174d9d54de..46f494643f9e 100644 --- a/sw/source/core/docnode/section.cxx +++ b/sw/source/core/docnode/section.cxx @@ -835,6 +835,11 @@ void SwSectionFmt::Modify( SfxPoolItem* pOld, SfxPoolItem* pNew ) break; } SwFrmFmt::Modify( pOld, pNew ); + + if (pOld && (RES_REMOVE_UNO_OBJECT == pOld->Which())) + { // invalidate cached uno object + SetXTextSection(uno::Reference(0)); + } } // erfrage vom Format Informationen diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx index f5963931f545..061826e764f0 100644 --- a/sw/source/core/layout/atrfrm.cxx +++ b/sw/source/core/layout/atrfrm.cxx @@ -2480,6 +2480,11 @@ void SwFrmFmt::Modify( SfxPoolItem* pOld, SfxPoolItem* pNew ) // wegen RESET_FMTWRITTEN. // if ( GetDepends() ) SwFmt::Modify( pOld, pNew ); + + if (pOld && (RES_REMOVE_UNO_OBJECT == pOld->Which())) + { // invalidate cached uno object + SetXObject(uno::Reference(0)); + } } //Vernichtet alle Frms, die in aDepend angemeldet sind. diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx index 87f96ba72346..079ba1fa0b95 100644 --- a/sw/source/core/unocore/unocoll.cxx +++ b/sw/source/core/unocore/unocoll.cxx @@ -447,7 +447,8 @@ uno::Reference< uno::XInterface > SwXServiceProvider::MakeInstance(sal_uInt16 break; case SW_SERVICE_INDEX_HEADER_SECTION : case SW_SERVICE_TEXT_SECTION : - xRet = SwXTextSectionClient::CreateXTextSection( 0, SW_SERVICE_INDEX_HEADER_SECTION == nObjectType); + xRet = SwXTextSection::CreateXTextSection(0, + (SW_SERVICE_INDEX_HEADER_SECTION == nObjectType)); break; case SW_SERVICE_REFERENCE_MARK : @@ -1473,15 +1474,7 @@ sal_Bool SwXTextSections::hasElements(void) throw( uno::RuntimeException ) -----------------------------------------------------------------------*/ uno::Reference< XTextSection > SwXTextSections::GetObject( SwSectionFmt& rFmt ) { - SwXTextSectionClient* pClient = (SwXTextSectionClient*)SwClientIter( rFmt ). - First( TYPE( SwXTextSectionClient )); - uno::Reference< XTextSection > xRet; - if( pClient ) - xRet = pClient->GetXTextSection(); - // it is possible that the client is still registered but the reference is already invalid - if( !xRet.is() ) - xRet = SwXTextSectionClient::CreateXTextSection(&rFmt); - return xRet; + return SwXTextSection::CreateXTextSection(&rFmt); } OUString SwXBookmarks::getImplementationName(void) throw( RuntimeException ) diff --git a/sw/source/core/unocore/unosect.cxx b/sw/source/core/unocore/unosect.cxx index 9f599533eec9..c47a3aef1345 100644 --- a/sw/source/core/unocore/unosect.cxx +++ b/sw/source/core/unocore/unosect.cxx @@ -36,6 +36,7 @@ #include #include +#include #include #include #include @@ -71,182 +72,171 @@ using namespace ::com::sun::star; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::text; -using namespace ::com::sun::star::container; -using namespace ::com::sun::star::beans; using ::rtl::OUString; -TYPEINIT1(SwXTextSectionClient, SwClient); -/*-- 20.12.2005 09:56:33--------------------------------------------------- +/****************************************************************** + * + ******************************************************************/ +struct SwTextSectionProperties_Impl +{ + uno::Sequence m_Password; + ::rtl::OUString m_sCondition; + ::rtl::OUString m_sLinkFileName; + ::rtl::OUString m_sSectionFilter; + ::rtl::OUString m_sSectionRegion; + + ::std::auto_ptr m_pColItem; + ::std::auto_ptr m_pBrushItem; + ::std::auto_ptr m_pFtnItem; + ::std::auto_ptr m_pEndItem; + ::std::auto_ptr m_pXMLAttr; + ::std::auto_ptr m_pNoBalanceItem; + ::std::auto_ptr m_pFrameDirItem; + ::std::auto_ptr m_pLRSpaceItem; // #109700# + + bool m_bDDE; + bool m_bHidden; + bool m_bCondHidden; + bool m_bProtect; + // --> FME 2004-06-22 #114856# edit in readonly sections + bool m_bEditInReadonly; + // <-- + bool m_bUpdateType; - -----------------------------------------------------------------------*/ -SwXTextSectionClient::SwXTextSectionClient( - SwSectionFmt& rFmt, - SwXTextSection& rTextSection, - uno::Reference< text::XTextSection > xSection ) : - SwClient(&rFmt), - m_pSection( &rTextSection ), - m_xReference( xSection ) + SwTextSectionProperties_Impl() + : m_bDDE(false) + , m_bHidden(false) + , m_bCondHidden(false) + , m_bProtect(false) + // --> FME 2004-06-22 #114856# edit in readonly sections + , m_bEditInReadonly(false) + // <-- + , m_bUpdateType(true) + { + } -{ - m_pSection->SetClient( this ); -} -/*-- 20.12.2005 09:56:33--------------------------------------------------- +}; - -----------------------------------------------------------------------*/ -SwXTextSectionClient::~SwXTextSectionClient() + +class SwXTextSection::Impl + : public SwClient { - uno::Reference< text::XTextSection > xSection( m_xReference ); - if(xSection.is()) + +public: + + SwXTextSection & m_rThis; + const SfxItemPropertySet & m_rPropSet; + SwEventListenerContainer m_ListenerContainer; + const bool m_bIndexHeader; + bool m_bIsDescriptor; + ::rtl::OUString m_sName; + ::std::auto_ptr m_pProps; + + Impl( SwXTextSection & rThis, + SwSectionFmt *const pFmt, const bool bIndexHeader) + : SwClient(pFmt) + , m_rThis(rThis) + , m_rPropSet(*aSwMapProvider.GetPropertySet(PROPERTY_MAP_SECTION)) + , m_ListenerContainer(static_cast< ::cppu::OWeakObject* >(&rThis)) + , m_bIndexHeader(bIndexHeader) + , m_bIsDescriptor(0 == pFmt) + , m_pProps((pFmt) ? 0 : new SwTextSectionProperties_Impl()) { - m_pSection->SetClient( 0 ); } -} -/*-- 20.12.2005 09:56:35--------------------------------------------------- - -----------------------------------------------------------------------*/ -uno::Reference< text::XTextSection > SwXTextSectionClient::GetXTextSection() -{ - return uno::Reference< text::XTextSection >( m_xReference ); -} + SwSectionFmt * GetSectionFmt() const + { + return static_cast(const_cast( + GetRegisteredIn())); + } -/*-- 29.12.2005 11:29:30--------------------------------------------------- + SwSectionFmt & GetSectionFmtOrThrow() const { + SwSectionFmt *const pFmt( GetSectionFmt() ); + if (!pFmt) { + throw uno::RuntimeException(OUString(RTL_CONSTASCII_USTRINGPARAM( + "SwXTextSection: disposed or invalid")), 0); + } + return *pFmt; + } - -----------------------------------------------------------------------*/ -/*SwXTextSection* SwXTextSectionClient::GetSwTextSection() -{ - if( m_xReference.is() ) - return m_pSection;; -} */ + void SAL_CALL SetPropertyValues_Impl( + const uno::Sequence< ::rtl::OUString >& rPropertyNames, + const uno::Sequence< uno::Any >& aValues) + throw (beans::UnknownPropertyException, beans::PropertyVetoException, + lang::IllegalArgumentException, lang::WrappedTargetException, + uno::RuntimeException); + uno::Sequence< uno::Any > SAL_CALL + GetPropertyValues_Impl( + const uno::Sequence< ::rtl::OUString >& rPropertyNames) + throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException); + + // SwClient + virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + +}; /*-- 10.12.98 14:42:52--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextSectionClient::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew) +void SwXTextSection::Impl::Modify(SfxPoolItem *pOld, SfxPoolItem *pNew) { - if(pOld && pOld->Which() == RES_REMOVE_UNO_OBJECT && - (void*)GetRegisteredIn() == ((SwPtrMsgPoolItem *)pOld)->pObject ) - ((SwModify*)GetRegisteredIn())->Remove(this); - else - ClientModify(this, pOld, pNew); - if(!GetRegisteredIn()) + ClientModify(this, pOld, pNew); + if (!GetRegisteredIn()) { - uno::Reference< text::XTextSection > xSection( m_xReference ); - if(xSection.is()) - { - m_pSection->SetClient( 0 ); - m_pSection->aLstnrCntnr.Disposing(); - m_xReference = uno::Reference< text::XTextSection >(); - - Application::PostUserEvent( - STATIC_LINK( this, SwXTextSectionClient, RemoveSectionClient_Impl ), this ); - } + m_ListenerContainer.Disposing(); } } -/*-- 29.12.2005 13:04:57--------------------------------------------------- +/*-- 20.12.2005 10:27:33--------------------------------------------------- -----------------------------------------------------------------------*/ -IMPL_STATIC_LINK_NOINSTANCE( SwXTextSectionClient, RemoveSectionClient_Impl, - SwXTextSectionClient*, pClient ) +SwSectionFmt * SwXTextSection::GetFmt() const { - delete pClient; - return 0; + return m_pImpl->GetSectionFmt(); } /*-- 20.12.2005 09:56:36--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextSection > SwXTextSectionClient::CreateXTextSection( - SwSectionFmt* pFmt, BOOL bIndexHeader ) +uno::Reference< text::XTextSection > +SwXTextSection::CreateXTextSection( + SwSectionFmt *const pFmt, const bool bIndexHeader) { - SwXTextSection* pNew; - uno::Reference< text::XTextSection > xSection = pNew = new SwXTextSection( pFmt != 0, bIndexHeader ); - if(pFmt) - new SwXTextSectionClient( *pFmt, *pNew, xSection ); + // re-use existing SwXTextSection + // #i105557#: do not iterate over the registered clients: race condition + uno::Reference< text::XTextSection > xSection; + if (pFmt) + { + xSection.set(pFmt->GetXTextSection()); + } + if ( !xSection.is() ) + { + SwXTextSection *const pNew = new SwXTextSection(pFmt, bIndexHeader); + xSection.set(pNew); + if (pFmt) + { + pFmt->SetXTextSection(xSection); + } + } return xSection; } -/*-- 29.12.2005 10:23:37--------------------------------------------------- +/*-- 10.12.98 14:47:05--------------------------------------------------- -----------------------------------------------------------------------*/ -SwXTextSectionClient* SwXTextSectionClient::Create(SwXTextSection& rSection, - uno::Reference< text::XTextSection >xSection, SwSectionFmt& rFmt ) +SwXTextSection::SwXTextSection( + SwSectionFmt *const pFmt, const bool bIndexHeader) + : m_pImpl( new SwXTextSection::Impl(*this, pFmt, bIndexHeader) ) { - return new SwXTextSectionClient( rFmt, rSection, xSection ); } -/****************************************************************** - * - ******************************************************************/ -struct SwTextSectionProperties_Impl -{ - - String sCondition; - String sLinkFileName; - String sSectionFilter; - String sSectionRegion; - uno::Sequence aPassword; - - SwFmtCol* pColItem; - SvxBrushItem* pBrushItem; - SwFmtFtnAtTxtEnd* pFtnItem; - SwFmtEndAtTxtEnd* pEndItem; - SvXMLAttrContainerItem *pXMLAttr; - SwFmtNoBalancedColumns *pNoBalanceItem; - SvxFrameDirectionItem *pFrameDirItem; - SvxLRSpaceItem *pLRSpaceItem; // #109700# - sal_Bool bDDE; - sal_Bool bHidden; - sal_Bool bCondHidden; - sal_Bool bProtect; - // --> FME 2004-06-22 #114856# edit in readonly sections - sal_Bool bEditInReadonly; - // <-- - sal_Bool bUpdateType; - - SwTextSectionProperties_Impl() : - pColItem(0), - pBrushItem(0), - pFtnItem(0), - pEndItem(0), - pXMLAttr(0), - pNoBalanceItem(0), - pFrameDirItem(0), - pLRSpaceItem(0), // #109700# - bDDE(0), - bHidden(0), - bCondHidden(0), - bProtect(0), - // --> FME 2004-06-22 #114856# edit in readonly sections - bEditInReadonly(0), - // <-- - bUpdateType(sal_True){} - ~SwTextSectionProperties_Impl() - { - delete pColItem; - delete pBrushItem; - delete pFtnItem; - delete pEndItem; - delete pXMLAttr; - delete pNoBalanceItem; - delete pFrameDirItem; - delete pLRSpaceItem; // #109700# - } -}; -/* -----------------------------11.07.00 12:10-------------------------------- +/*-- 10.12.98 14:47:07--------------------------------------------------- - ---------------------------------------------------------------------------*/ -SwXTextSection* SwXTextSection::GetImplementation(uno::Reference< XInterface> xRef ) + -----------------------------------------------------------------------*/ +SwXTextSection::~SwXTextSection() { - uno::Reference xTunnel( xRef, uno::UNO_QUERY); - if(xTunnel.is()) - return reinterpret_cast< SwXTextSection * >( - sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething(SwXTextSection::getUnoTunnelId()) )); - return 0; } /* -----------------------------13.03.00 12:15-------------------------------- @@ -260,258 +250,230 @@ const uno::Sequence< sal_Int8 > & SwXTextSection::getUnoTunnelId() /* -----------------------------10.03.00 18:04-------------------------------- ---------------------------------------------------------------------------*/ -sal_Int64 SAL_CALL SwXTextSection::getSomething( const uno::Sequence< sal_Int8 >& rId ) - throw(uno::RuntimeException) -{ - if( rId.getLength() == 16 - && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), - rId.getConstArray(), 16 ) ) - { - return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >( this ) ); - } - return 0; -} -/*-- 10.12.98 14:47:05--------------------------------------------------- - - -----------------------------------------------------------------------*/ -SwXTextSection::SwXTextSection(sal_Bool bWithFormat, sal_Bool bIndexHeader) : -// SwClient(pFmt), - aLstnrCntnr( (text::XTextContent*)this), - m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_SECTION)), - m_bIsDescriptor(!bWithFormat), - m_bIndexHeader(bIndexHeader), - pProps(bWithFormat ? 0 : new SwTextSectionProperties_Impl()), - m_pClient( 0 ) +sal_Int64 SAL_CALL +SwXTextSection::getSomething(const uno::Sequence< sal_Int8 >& rId) +throw (uno::RuntimeException) { - + return ::sw::UnoTunnelImpl(rId, this); } -/*-- 10.12.98 14:47:07--------------------------------------------------- - -----------------------------------------------------------------------*/ -SwXTextSection::~SwXTextSection() -{ - vos::OGuard aGuard(Application::GetSolarMutex()); - delete m_pClient; - delete pProps; -} /*-- 10.12.98 14:47:08--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextSection > SwXTextSection::getParentSection(void) throw( uno::RuntimeException ) +uno::Reference< text::XTextSection > SAL_CALL +SwXTextSection::getParentSection() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< text::XTextSection > aRef; - SwSectionFmt* pSectFmt = GetFmt(); - if(pSectFmt) - { - SwSectionFmt* pParentFmt = pSectFmt->GetParent(); - if(pParentFmt) - { - SwXTextSectionClient* pClient = (SwXTextSectionClient*)SwClientIter(*pParentFmt). - First(TYPE(SwXTextSectionClient)); - if(pClient) - aRef = pClient->GetXTextSection(); - else - aRef = SwXTextSectionClient::CreateXTextSection(pParentFmt); - } - } - else - throw uno::RuntimeException(); - return aRef; + + SwSectionFmt & rSectionFmt( m_pImpl->GetSectionFmtOrThrow() ); + + SwSectionFmt *const pParentFmt = rSectionFmt.GetParent(); + const uno::Reference< text::XTextSection > xRet = + (pParentFmt) ? CreateXTextSection(pParentFmt) : 0; + return xRet; } + /*-- 10.12.98 14:47:08--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Sequence< uno::Reference< text::XTextSection > > SwXTextSection::getChildSections(void) - throw( uno::RuntimeException ) +uno::Sequence< uno::Reference< text::XTextSection > > SAL_CALL +SwXTextSection::getChildSections() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Sequence > aSeq; - SwSectionFmt* pSectFmt = GetFmt(); - if(pSectFmt) - { - SwSections aChildren; - pSectFmt->GetChildSections(aChildren, SORTSECT_NOT, sal_False); - aSeq.realloc(aChildren.Count()); - uno::Reference< text::XTextSection > * pArray = aSeq.getArray(); - for(sal_uInt16 i = 0; i < aChildren.Count(); i++) - { - SwSectionFmt* pChild = aChildren.GetObject(i)->GetFmt(); - SwXTextSectionClient* pClient = (SwXTextSectionClient*)SwClientIter(*pChild). - First(TYPE(SwXTextSectionClient)); - if(pClient) - pArray[i] = pClient->GetXTextSection(); - else - pArray[i] = SwXTextSectionClient::CreateXTextSection(pChild); - } + SwSectionFmt & rSectionFmt( m_pImpl->GetSectionFmtOrThrow() ); + + SwSections aChildren; + rSectionFmt.GetChildSections(aChildren, SORTSECT_NOT, sal_False); + uno::Sequence > aSeq(aChildren.Count()); + uno::Reference< text::XTextSection > * pArray = aSeq.getArray(); + for (sal_uInt16 i = 0; i < aChildren.Count(); i++) + { + SwSectionFmt *const pChild = aChildren.GetObject(i)->GetFmt(); + pArray[i] = CreateXTextSection(pChild); } return aSeq; - } + /* -----------------18.02.99 13:31------------------- * * --------------------------------------------------*/ -void SwXTextSection::attachToRange(const uno::Reference< text::XTextRange > & xTextRange) - throw( lang::IllegalArgumentException, uno::RuntimeException ) +void SAL_CALL +SwXTextSection::attach(const uno::Reference< text::XTextRange > & xTextRange) +throw (lang::IllegalArgumentException, uno::RuntimeException) { - if(!m_bIsDescriptor) + vos::OGuard g(Application::GetSolarMutex()); + + if (!m_pImpl->m_bIsDescriptor) + { throw uno::RuntimeException(); + } uno::Reference xRangeTunnel( xTextRange, uno::UNO_QUERY); SwXTextRange* pRange = 0; OTextCursorHelper* pCursor = 0; if(xRangeTunnel.is()) { - pRange = reinterpret_cast< SwXTextRange * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXTextRange::getUnoTunnelId()) )); - pCursor = reinterpret_cast< OTextCursorHelper * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( OTextCursorHelper::getUnoTunnelId()) )); + pRange = ::sw::UnoTunnelGetImplementation(xRangeTunnel); + pCursor = + ::sw::UnoTunnelGetImplementation(xRangeTunnel); } - SwDoc* pDoc = pRange ? (SwDoc*)pRange->GetDoc() : pCursor ? (SwDoc*)pCursor->GetDoc() : 0; - if(pDoc) + SwDoc *const pDoc = + (pRange) ? pRange->GetDoc() : ((pCursor) ? pCursor->GetDoc() : 0); + if (!pDoc) { - SwUnoInternalPaM aPam(*pDoc); - //das muss jetzt sal_True liefern - SwXTextRange::XTextRangeToSwPaM(aPam, xTextRange); - UnoActionContext aCont(pDoc); - pDoc->StartUndo( UNDO_INSSECTION, NULL ); - - SwSection* pRet = 0; - if(!m_sName.Len()) - m_sName = C2S("TextSection"); - SectionType eType = pProps->bDDE ? DDE_LINK_SECTION : - pProps->sLinkFileName.Len() || pProps->sSectionRegion.Len() ? FILE_LINK_SECTION : - CONTENT_SECTION; - // index header section? - if(m_bIndexHeader) + throw lang::IllegalArgumentException(); + } + + SwUnoInternalPaM aPam(*pDoc); + //das muss jetzt sal_True liefern + SwXTextRange::XTextRangeToSwPaM(aPam, xTextRange); + UnoActionContext aCont(pDoc); + pDoc->StartUndo( UNDO_INSSECTION, NULL ); + + if (!m_pImpl->m_sName.getLength()) + { + m_pImpl->m_sName = C2U("TextSection"); + } + SectionType eType = (m_pImpl->m_pProps->m_bDDE) + ? DDE_LINK_SECTION + : ((m_pImpl->m_pProps->m_sLinkFileName.getLength() || + m_pImpl->m_pProps->m_sSectionRegion.getLength()) + ? FILE_LINK_SECTION : CONTENT_SECTION); + // index header section? + if (m_pImpl->m_bIndexHeader) + { + // caller wants an index header section, but will only + // give him one if a) we are inside an index, and b) said + // index doesn't yet have a header section. + const SwTOXBase* pBase = aPam.GetDoc()->GetCurTOX(*aPam.Start()); + + // are we inside an index? + if (pBase) { - // caller wants an index header section, but will only - // give him one if a) we are inside an index, and b) said - // index doesn't yet have a header section. - const SwTOXBase* pBase = aPam.GetDoc()->GetCurTOX( - *aPam.Start() ); - - // are we inside an index? - if (pBase) + // get all child sections + SwSections aSectionsArr; + static_cast(pBase)->GetFmt()-> + GetChildSections(aSectionsArr); + + // and search for current header section + const sal_uInt16 nCount = aSectionsArr.Count(); + sal_Bool bHeaderPresent = sal_False; + for(sal_uInt16 i = 0; i < nCount; i++) { - // get all child sections - SwSections aSectionsArr; - ((SwTOXBaseSection*)pBase)->GetFmt()-> - GetChildSections(aSectionsArr); - - // and search for current header section - sal_uInt16 nCount = aSectionsArr.Count(); - sal_Bool bHeaderPresent = sal_False; - for(sal_uInt16 i = 0; i < nCount; i++) - { - bHeaderPresent |= - (aSectionsArr[i]->GetType() == TOX_HEADER_SECTION); - } - if (! bHeaderPresent) - { - eType = TOX_HEADER_SECTION; - } + bHeaderPresent |= + (aSectionsArr[i]->GetType() == TOX_HEADER_SECTION); + } + if (! bHeaderPresent) + { + eType = TOX_HEADER_SECTION; } } + } - SwSection aSect(eType, pDoc->GetUniqueSectionName(&m_sName)); - aSect.SetCondition(pProps->sCondition); - String sLinkName(pProps->sLinkFileName); - sLinkName += sfx2::cTokenSeperator; - sLinkName += pProps->sSectionFilter; - sLinkName += sfx2::cTokenSeperator; - sLinkName += pProps->sSectionRegion; - aSect.SetLinkFileName(sLinkName); - - aSect.SetHidden(pProps->bHidden); - aSect.SetProtect(pProps->bProtect); - // --> FME 2004-06-22 #114856# edit in readonly sections - aSect.SetEditInReadonly(pProps->bEditInReadonly); - // <-- + String tmp(m_pImpl->m_sName); + SwSection aSect(eType, pDoc->GetUniqueSectionName(&tmp)); + aSect.SetCondition(m_pImpl->m_pProps->m_sCondition); + ::rtl::OUStringBuffer sLinkNameBuf(m_pImpl->m_pProps->m_sLinkFileName); + sLinkNameBuf.append(sfx2::cTokenSeperator); + sLinkNameBuf.append(m_pImpl->m_pProps->m_sSectionFilter); + sLinkNameBuf.append(sfx2::cTokenSeperator); + sLinkNameBuf.append(m_pImpl->m_pProps->m_sSectionRegion); + aSect.SetLinkFileName(sLinkNameBuf.makeStringAndClear()); + + aSect.SetHidden(m_pImpl->m_pProps->m_bHidden); + aSect.SetProtect(m_pImpl->m_pProps->m_bProtect); + // --> FME 2004-06-22 #114856# edit in readonly sections + aSect.SetEditInReadonly(m_pImpl->m_pProps->m_bEditInReadonly); + // <-- - SfxItemSet aSet(pDoc->GetAttrPool(), - RES_COL, RES_COL, - RES_BACKGROUND, RES_BACKGROUND, - RES_FTN_AT_TXTEND, RES_FRAMEDIR, - RES_LR_SPACE, RES_LR_SPACE, // #109700# - RES_UNKNOWNATR_CONTAINER,RES_UNKNOWNATR_CONTAINER, - 0); - if(pProps->pBrushItem) - aSet.Put(*pProps->pBrushItem); - if(pProps->pColItem) - aSet.Put(*pProps->pColItem); - if(pProps->pFtnItem) - aSet.Put(*pProps->pFtnItem); - if(pProps->pEndItem) - aSet.Put(*pProps->pEndItem); - if(pProps->pXMLAttr) - aSet.Put(*pProps->pXMLAttr); - if(pProps->pNoBalanceItem) - aSet.Put(*pProps->pNoBalanceItem); - if(pProps->pFrameDirItem) - aSet.Put(*pProps->pFrameDirItem); - /* #109700# */ - if(pProps->pLRSpaceItem) - aSet.Put(*pProps->pLRSpaceItem); - - // section password - if (pProps->aPassword.getLength() > 0) - aSect.SetPasswd(pProps->aPassword); - - pRet = pDoc->InsertSwSection( aPam, aSect, aSet.Count() ? &aSet : 0 ); - // now create the client - m_refCount++; - // keep block to remove Reference before the refcount is decremented - { - uno::Reference< text::XTextSection> xSection( this ); - m_pClient = SwXTextSectionClient::Create(*this, xSection, *pRet->GetFmt()); - } - m_refCount--; + SfxItemSet aSet(pDoc->GetAttrPool(), + RES_COL, RES_COL, + RES_BACKGROUND, RES_BACKGROUND, + RES_FTN_AT_TXTEND, RES_FRAMEDIR, + RES_LR_SPACE, RES_LR_SPACE, // #109700# + RES_UNKNOWNATR_CONTAINER,RES_UNKNOWNATR_CONTAINER, + 0); + if (m_pImpl->m_pProps->m_pBrushItem.get()) + { + aSet.Put(*m_pImpl->m_pProps->m_pBrushItem); + } + if (m_pImpl->m_pProps->m_pColItem.get()) + { + aSet.Put(*m_pImpl->m_pProps->m_pColItem); + } + if (m_pImpl->m_pProps->m_pFtnItem.get()) + { + aSet.Put(*m_pImpl->m_pProps->m_pFtnItem); + } + if (m_pImpl->m_pProps->m_pEndItem.get()) + { + aSet.Put(*m_pImpl->m_pProps->m_pEndItem); + } + if (m_pImpl->m_pProps->m_pXMLAttr.get()) + { + aSet.Put(*m_pImpl->m_pProps->m_pXMLAttr); + } + if (m_pImpl->m_pProps->m_pNoBalanceItem.get()) + { + aSet.Put(*m_pImpl->m_pProps->m_pNoBalanceItem); + } + if (m_pImpl->m_pProps->m_pFrameDirItem.get()) + { + aSet.Put(*m_pImpl->m_pProps->m_pFrameDirItem); + } + /* #109700# */ + if (m_pImpl->m_pProps->m_pLRSpaceItem.get()) + { + aSet.Put(*m_pImpl->m_pProps->m_pLRSpaceItem); + } + // section password + if (m_pImpl->m_pProps->m_Password.getLength() > 0) + { + aSect.SetPasswd(m_pImpl->m_pProps->m_Password); + } - // #97450# XML import must hide sections depending on their old - // condition status - if( pProps->sCondition.Len() != 0 ) - pRet->SetCondHidden(pProps->bCondHidden); + SwSection *const pRet = + pDoc->InsertSwSection( aPam, aSect, aSet.Count() ? &aSet : 0 ); + pRet->GetFmt()->Add(m_pImpl.get()); + pRet->GetFmt()->SetXObject(static_cast< ::cppu::OWeakObject*>(this)); - // set update type if DDE link (and connect, if necessary) - if (pProps->bDDE) + // #97450# XML import must hide sections depending on their old + // condition status + if (m_pImpl->m_pProps->m_sCondition.getLength() != 0) + { + pRet->SetCondHidden(m_pImpl->m_pProps->m_bCondHidden); + } + + // set update type if DDE link (and connect, if necessary) + if (m_pImpl->m_pProps->m_bDDE) + { + if (! pRet->IsConnected()) { - if (! pRet->IsConnected()) - { - pRet->CreateLink(CREATE_CONNECT); - } - pRet->SetUpdateType( static_cast< USHORT >(pProps->bUpdateType ? - sfx2::LINKUPDATE_ALWAYS : sfx2::LINKUPDATE_ONCALL) ); + pRet->CreateLink(CREATE_CONNECT); } - - // Undo-Klammerung hier beenden - pDoc->EndUndo( UNDO_INSSECTION, NULL ); - DELETEZ(pProps); - m_bIsDescriptor = sal_False; + pRet->SetUpdateType( static_cast< USHORT >( + (m_pImpl->m_pProps->m_bUpdateType) ? + sfx2::LINKUPDATE_ALWAYS : sfx2::LINKUPDATE_ONCALL) ); } - else - throw lang::IllegalArgumentException(); -} -/*-- 10.12.98 14:47:09--------------------------------------------------- - -----------------------------------------------------------------------*/ -void SwXTextSection::attach(const uno::Reference< text::XTextRange > & xTextRange) - throw( lang::IllegalArgumentException, uno::RuntimeException ) -{ - vos::OGuard aGuard(Application::GetSolarMutex()); - attachToRange( xTextRange ); + // Undo-Klammerung hier beenden + pDoc->EndUndo( UNDO_INSSECTION, NULL ); + m_pImpl->m_pProps.reset(); + m_pImpl->m_bIsDescriptor = false; } /*-- 10.12.98 14:47:09--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextRange > SwXTextSection::getAnchor(void) throw( uno::RuntimeException ) +uno::Reference< text::XTextRange > SAL_CALL +SwXTextSection::getAnchor() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + uno::Reference< text::XTextRange > xRet; - SwSectionFmt* pSectFmt = GetFmt(); + SwSectionFmt *const pSectFmt = m_pImpl->GetSectionFmt(); if(pSectFmt) { const SwSection* pSect; @@ -535,677 +497,858 @@ uno::Reference< text::XTextRange > SwXTextSection::getAnchor(void) throw( uno:: /*-- 10.12.98 14:47:09--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextSection::dispose(void) throw( uno::RuntimeException ) +void SAL_CALL SwXTextSection::dispose() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwSectionFmt* pSectFmt = GetFmt(); - if(pSectFmt) + + SwSectionFmt *const pSectFmt = m_pImpl->GetSectionFmt(); + if (pSectFmt) + { pSectFmt->GetDoc()->DelSectionFmt( pSectFmt ); - else - throw uno::RuntimeException(); + } } /*-- 10.12.98 14:47:10--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextSection::addEventListener(const uno::Reference< lang::XEventListener > & aListener) - throw( uno::RuntimeException ) +void SAL_CALL SwXTextSection::addEventListener( + const uno::Reference< lang::XEventListener > & xListener) +throw (uno::RuntimeException) { - if(!GetFmt()) + vos::OGuard g(Application::GetSolarMutex()); + + if (!m_pImpl->GetSectionFmt()) + { throw uno::RuntimeException(); - aLstnrCntnr.AddListener(aListener); + } + m_pImpl->m_ListenerContainer.AddListener(xListener); } /*-- 10.12.98 14:47:10--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextSection::removeEventListener(const uno::Reference< lang::XEventListener > & aListener) - throw( uno::RuntimeException ) +void SAL_CALL SwXTextSection::removeEventListener( + const uno::Reference< lang::XEventListener > & xListener) +throw (uno::RuntimeException) { - if(!GetFmt() || !aLstnrCntnr.RemoveListener(aListener)) + vos::OGuard g(Application::GetSolarMutex()); + + if (!m_pImpl->GetSectionFmt() || + !m_pImpl->m_ListenerContainer.RemoveListener(xListener)) + { throw uno::RuntimeException(); + } } /*-- 10.12.98 14:47:11--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< beans::XPropertySetInfo > SwXTextSection::getPropertySetInfo(void) throw( uno::RuntimeException ) +uno::Reference< beans::XPropertySetInfo > SAL_CALL +SwXTextSection::getPropertySetInfo() throw (uno::RuntimeException) { - static uno::Reference< beans::XPropertySetInfo > aRef = m_pPropSet->getPropertySetInfo(); + vos::OGuard g(Application::GetSolarMutex()); + + static const uno::Reference< beans::XPropertySetInfo > aRef = + m_pImpl->m_rPropSet.getPropertySetInfo(); return aRef; } -/* -----------------------------12.02.01 10:29-------------------------------- - ---------------------------------------------------------------------------*/ -struct SwSectItemSet_Impl -{ - - SfxItemSet* pItemSet; - SwSectItemSet_Impl() : - pItemSet(0){} - ~SwSectItemSet_Impl() - {delete pItemSet;} -}; /* -----------------------------12.02.01 10:45-------------------------------- ---------------------------------------------------------------------------*/ -void SAL_CALL SwXTextSection::SetPropertyValues_Impl( +void SwXTextSection::Impl::SetPropertyValues_Impl( const uno::Sequence< OUString >& rPropertyNames, - const uno::Sequence< Any >& rValues ) - throw( UnknownPropertyException, PropertyVetoException, IllegalArgumentException, - WrappedTargetException, RuntimeException) + const uno::Sequence< uno::Any >& rValues) +throw (beans::UnknownPropertyException, beans::PropertyVetoException, + lang::IllegalArgumentException, lang::WrappedTargetException, + uno::RuntimeException) { - SwSectionFmt* pFmt = GetFmt(); if(rPropertyNames.getLength() != rValues.getLength()) - throw IllegalArgumentException(); - if(pFmt || m_bIsDescriptor) { - SwSection aSection(CONTENT_SECTION, aEmptyStr); - SwSection* pSect = pFmt ? pFmt->GetSection() : 0; - if(pFmt) - aSection = *pSect; - const OUString* pPropertyNames = rPropertyNames.getConstArray(); - const Any* pValues = rValues.getConstArray(); - SwSectItemSet_Impl aItemSet; - - sal_Bool bLinkModeChanged = sal_False; - sal_Bool bLinkMode = sal_False; - for(sal_Int16 nProperty = 0; nProperty < rPropertyNames.getLength(); nProperty++) + throw lang::IllegalArgumentException(); + } + SwSectionFmt *const pFmt = GetSectionFmt(); + if (!pFmt && !m_bIsDescriptor) + { + throw uno::RuntimeException(); + } + + SwSection aSection(CONTENT_SECTION, aEmptyStr); + SwSection *const pSect = (pFmt) ? pFmt->GetSection() : 0; + if (pFmt) + { + aSection = *pSect; + } + OUString const*const pPropertyNames = rPropertyNames.getConstArray(); + uno::Any const*const pValues = rValues.getConstArray(); + ::std::auto_ptr pItemSet; + sal_Bool bLinkModeChanged = sal_False; + sal_Bool bLinkMode = sal_False; + + for (sal_Int32 nProperty = 0; nProperty < rPropertyNames.getLength(); + nProperty++) + { + SfxItemPropertySimpleEntry const*const pEntry = + m_rPropSet.getPropertyMap()->getByName(pPropertyNames[nProperty]); + if (!pEntry) { - const SfxItemPropertySimpleEntry* pEntry = - m_pPropSet->getPropertyMap()->getByName( pPropertyNames[nProperty] ); - if(!pEntry) - throw UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pPropertyNames[nProperty], static_cast < cppu::OWeakObject * > ( this ) ); - else + throw beans::UnknownPropertyException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) + + pPropertyNames[nProperty], + static_cast(& m_rThis)); + } + if (pEntry->nFlags & beans::PropertyAttribute::READONLY) + { + throw beans::PropertyVetoException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Property is read-only: ")) + + pPropertyNames[nProperty], + static_cast(& m_rThis)); + } + switch (pEntry->nWID) + { + case WID_SECT_CONDITION: + { + OUString uTmp; + pValues[nProperty] >>= uTmp; + if (m_bIsDescriptor) + { + m_pProps->m_sCondition = uTmp; + } + else + { + aSection.SetCondition(uTmp); + } + } + break; + case WID_SECT_DDE_TYPE: + case WID_SECT_DDE_FILE: + case WID_SECT_DDE_ELEMENT: { - if ( pEntry->nFlags & PropertyAttribute::READONLY) - throw PropertyVetoException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + pPropertyNames[nProperty], static_cast < cppu::OWeakObject * > ( this ) ); - switch(pEntry->nWID) + OUString uTmp; + pValues[nProperty] >>= uTmp; + String sTmp(uTmp); + if (m_bIsDescriptor) { - case WID_SECT_CONDITION: + if (!m_pProps->m_bDDE) { - OUString uTmp; - pValues[nProperty] >>= uTmp; - if(m_bIsDescriptor) - pProps->sCondition = String(uTmp); - else - aSection.SetCondition(uTmp); + ::rtl::OUStringBuffer buf; + buf.append(sfx2::cTokenSeperator); + buf.append(sfx2::cTokenSeperator); + m_pProps->m_sLinkFileName = buf.makeStringAndClear(); + m_pProps->m_bDDE = true; + } + String sLinkFileName(m_pProps->m_sLinkFileName); + sLinkFileName.SetToken(pEntry->nWID - WID_SECT_DDE_TYPE, + sfx2::cTokenSeperator, sTmp); + m_pProps->m_sLinkFileName = sLinkFileName; + } + else + { + String sLinkFileName(aSection.GetLinkFileName()); + if (aSection.GetType() != DDE_LINK_SECTION) + { + sLinkFileName = sfx2::cTokenSeperator; + sLinkFileName += sfx2::cTokenSeperator; + aSection.SetType(DDE_LINK_SECTION); + } + sLinkFileName.SetToken(pEntry->nWID - WID_SECT_DDE_TYPE, + sfx2::cTokenSeperator, sTmp); + aSection.SetLinkFileName(sLinkFileName); + } + } + break; + case WID_SECT_DDE_AUTOUPDATE: + { + sal_Bool bVal(sal_False); + if (!(pValues[nProperty] >>= bVal)) + { + throw lang::IllegalArgumentException(); + } + if (m_bIsDescriptor) + { + m_pProps->m_bUpdateType = bVal; + } + else + { + bLinkModeChanged = sal_True; + bLinkMode = bVal; + } + } + break; + case WID_SECT_LINK: + { + text::SectionFileLink aLink; + if (!(pValues[nProperty] >>= aLink)) + { + throw lang::IllegalArgumentException(); + } + if (m_bIsDescriptor) + { + m_pProps->m_bDDE = sal_False; + m_pProps->m_sLinkFileName = aLink.FileURL; + m_pProps->m_sSectionFilter = aLink.FilterName; + } + else + { + if (aSection.GetType() != FILE_LINK_SECTION && + aLink.FileURL.getLength()) + { + aSection.SetType(FILE_LINK_SECTION); + } + ::rtl::OUStringBuffer sFileNameBuf; + if (aLink.FileURL.getLength()) + { + sFileNameBuf.append( URIHelper::SmartRel2Abs( + pFmt->GetDoc()->GetDocShell()->GetMedium() + ->GetURLObject(), + aLink.FileURL, URIHelper::GetMaybeFileHdl())); } - break; - case WID_SECT_DDE_TYPE : - case WID_SECT_DDE_FILE : - case WID_SECT_DDE_ELEMENT : + sFileNameBuf.append(sfx2::cTokenSeperator); + sFileNameBuf.append(aLink.FilterName); + sFileNameBuf.append(sfx2::cTokenSeperator); + sFileNameBuf.append( + aSection.GetLinkFileName().GetToken(2, + sfx2::cTokenSeperator)); + const ::rtl::OUString sFileName( + sFileNameBuf.makeStringAndClear()); + aSection.SetLinkFileName(sFileName); + if (sFileName.getLength() < 3) { - OUString uTmp; - pValues[nProperty] >>= uTmp; - String sTmp(uTmp); - if(m_bIsDescriptor) + aSection.SetType(CONTENT_SECTION); + } + } + } + break; + case WID_SECT_REGION: + { + OUString sLink; + pValues[nProperty] >>= sLink; + if (m_bIsDescriptor) + { + m_pProps->m_bDDE = sal_False; + m_pProps->m_sSectionRegion = sLink; + } + else + { + if (aSection.GetType() != FILE_LINK_SECTION && + sLink.getLength()) + { + aSection.SetType(FILE_LINK_SECTION); + } + String sSectLink(aSection.GetLinkFileName()); + while (3 < sSectLink.GetTokenCount(sfx2::cTokenSeperator)) + { + sSectLink += sfx2::cTokenSeperator; + } + sSectLink.SetToken(2, sfx2::cTokenSeperator, sLink); + aSection.SetLinkFileName(sSectLink); + if (sSectLink.Len() < 3) + { + aSection.SetType(CONTENT_SECTION); + } + } + } + break; + case WID_SECT_VISIBLE: + { + sal_Bool bVal(sal_False); + if (!(pValues[nProperty] >>= bVal)) + { + throw lang::IllegalArgumentException(); + } + if (m_bIsDescriptor) + { + m_pProps->m_bHidden = !bVal; + } + else + { + aSection.SetHidden(!bVal); + } + } + break; + case WID_SECT_CURRENTLY_VISIBLE: + { + sal_Bool bVal(sal_False); + if (!(pValues[nProperty] >>= bVal)) + { + throw lang::IllegalArgumentException(); + } + if (m_bIsDescriptor) + { + m_pProps->m_bCondHidden = !bVal; + } + else + { + if (aSection.GetCondition().Len() != 0) + { + aSection.SetCondHidden(!bVal); + } + } + } + break; + case WID_SECT_PROTECTED: + { + sal_Bool bVal(sal_False); + if (!(pValues[nProperty] >>= bVal)) + { + throw lang::IllegalArgumentException(); + } + if (m_bIsDescriptor) + { + m_pProps->m_bProtect = bVal; + } + else + { + aSection.SetProtect(bVal); + } + } + break; + // --> FME 2004-06-22 #114856# edit in readonly sections + case WID_SECT_EDIT_IN_READONLY: + { + sal_Bool bVal(sal_False); + if (!(pValues[nProperty] >>= bVal)) + { + throw lang::IllegalArgumentException(); + } + if (m_bIsDescriptor) + { + m_pProps->m_bEditInReadonly = bVal; + } + else + { + aSection.SetEditInReadonly(bVal); + } + } + // <-- + break; + case WID_SECT_PASSWORD: + { + uno::Sequence aSeq; + pValues[nProperty] >>= aSeq; + if (m_bIsDescriptor) + { + m_pProps->m_Password = aSeq; + } + else + { + aSection.SetPasswd(aSeq); + } + } + break; + default: + { + if (pFmt) + { + const SfxItemSet& rOldAttrSet = pFmt->GetAttrSet(); + pItemSet.reset( new SfxItemSet(*rOldAttrSet.GetPool(), + pEntry->nWID, pEntry->nWID, 0)); + pItemSet->Put(rOldAttrSet); + m_rPropSet.setPropertyValue(*pEntry, + pValues[nProperty], *pItemSet); + } + else + { + SfxPoolItem* pPutItem = 0; + if (RES_COL == pEntry->nWID) + { + if (!m_pProps->m_pColItem.get()) { - if(!pProps->bDDE) - { - pProps->sLinkFileName = sfx2::cTokenSeperator; - pProps->sLinkFileName += sfx2::cTokenSeperator; - pProps->bDDE = sal_True; - } - pProps->sLinkFileName.SetToken(pEntry->nWID - WID_SECT_DDE_TYPE,sfx2::cTokenSeperator,sTmp); + m_pProps->m_pColItem.reset(new SwFmtCol); } - else + pPutItem = m_pProps->m_pColItem.get(); + } + else if (RES_BACKGROUND == pEntry->nWID) + { + if (!m_pProps->m_pBrushItem.get()) { - String sLinkFileName(aSection.GetLinkFileName()); - if(aSection.GetType() != DDE_LINK_SECTION) - { - sLinkFileName = sfx2::cTokenSeperator; - sLinkFileName += sfx2::cTokenSeperator; - aSection.SetType(DDE_LINK_SECTION); - } - sLinkFileName.SetToken(pEntry->nWID - WID_SECT_DDE_TYPE,sfx2::cTokenSeperator, sTmp); - aSection.SetLinkFileName(sLinkFileName); + m_pProps->m_pBrushItem.reset( + new SvxBrushItem(RES_BACKGROUND)); } + pPutItem = m_pProps->m_pBrushItem.get(); } - break; - case WID_SECT_DDE_AUTOUPDATE: + else if (RES_FTN_AT_TXTEND == pEntry->nWID) { - sal_Bool bVal = *(sal_Bool*)pValues[nProperty].getValue(); - if(m_bIsDescriptor) + if (!m_pProps->m_pFtnItem.get()) { - pProps->bUpdateType = bVal; + m_pProps->m_pFtnItem.reset(new SwFmtFtnAtTxtEnd); } - else + pPutItem = m_pProps->m_pFtnItem.get(); + } + else if (RES_END_AT_TXTEND == pEntry->nWID) + { + if (!m_pProps->m_pEndItem.get()) { - bLinkModeChanged = sal_True; - bLinkMode = bVal; + m_pProps->m_pEndItem.reset(new SwFmtEndAtTxtEnd); } + pPutItem = m_pProps->m_pEndItem.get(); } - break; - case WID_SECT_LINK : + else if (RES_UNKNOWNATR_CONTAINER== pEntry->nWID) { - text::SectionFileLink aLink; - if(pValues[nProperty] >>= aLink) + if (!m_pProps->m_pXMLAttr.get()) { - if(m_bIsDescriptor) - { - pProps->bDDE = sal_False; - pProps->sLinkFileName = String(aLink.FileURL); - pProps->sSectionFilter = String(aLink.FilterName); - } - else - { - if(aSection.GetType() != FILE_LINK_SECTION && - aLink.FileURL.getLength()) - aSection.SetType(FILE_LINK_SECTION); - String sFileName; - if(aLink.FileURL.getLength()) - { - sFileName += URIHelper::SmartRel2Abs( - pFmt->GetDoc()->GetDocShell()->GetMedium()->GetURLObject(), - aLink.FileURL, - URIHelper::GetMaybeFileHdl()); - } - sFileName += sfx2::cTokenSeperator; - sFileName += String(aLink.FilterName); - sFileName += sfx2::cTokenSeperator; - sFileName += aSection.GetLinkFileName().GetToken( 2, sfx2::cTokenSeperator ); - aSection.SetLinkFileName(sFileName); - if(sFileName.Len() < 3) - aSection.SetType(CONTENT_SECTION); - } + m_pProps->m_pXMLAttr.reset( + new SvXMLAttrContainerItem( + RES_UNKNOWNATR_CONTAINER)); } - else - throw lang::IllegalArgumentException(); + pPutItem = m_pProps->m_pXMLAttr.get(); } - break; - case WID_SECT_REGION : + else if (RES_COLUMNBALANCE== pEntry->nWID) { - OUString uTmp; - pValues[nProperty] >>= uTmp; - String sLink(uTmp); - if(m_bIsDescriptor) + if (!m_pProps->m_pNoBalanceItem.get()) { - pProps->bDDE = sal_False; - pProps->sSectionRegion = sLink; + m_pProps->m_pNoBalanceItem.reset( + new SwFmtNoBalancedColumns(RES_COLUMNBALANCE)); } - else + pPutItem = m_pProps->m_pNoBalanceItem.get(); + } + else if (RES_FRAMEDIR == pEntry->nWID) + { + if (!m_pProps->m_pFrameDirItem.get()) { - if(aSection.GetType() != FILE_LINK_SECTION && - sLink.Len()) - aSection.SetType(FILE_LINK_SECTION); - String sSectLink(aSection.GetLinkFileName()); - while( 3 < sSectLink.GetTokenCount( sfx2::cTokenSeperator )) - { - sSectLink += sfx2::cTokenSeperator; - } - sSectLink.SetToken(2, sfx2::cTokenSeperator, sLink); - aSection.SetLinkFileName(sSectLink); - if(sSectLink.Len() < 3) - aSection.SetType(CONTENT_SECTION); + m_pProps->m_pFrameDirItem.reset( + new SvxFrameDirectionItem( + FRMDIR_HORI_LEFT_TOP, RES_FRAMEDIR)); } + pPutItem = m_pProps->m_pFrameDirItem.get(); } - break; - case WID_SECT_VISIBLE : + else if (RES_LR_SPACE == pEntry->nWID) { - sal_Bool bVal = *(sal_Bool*)pValues[nProperty].getValue(); - if(m_bIsDescriptor) - pProps->bHidden = !bVal; - else - aSection.SetHidden(!bVal); + // #109700# + if (!m_pProps->m_pLRSpaceItem.get()) + { + m_pProps->m_pLRSpaceItem.reset( + new SvxLRSpaceItem( RES_LR_SPACE )); + } + pPutItem = m_pProps->m_pLRSpaceItem.get(); } - break; - case WID_SECT_CURRENTLY_VISIBLE: + if (pPutItem) { - sal_Bool bVal = *(sal_Bool*)pValues[nProperty].getValue(); - if(m_bIsDescriptor) - pProps->bCondHidden = !bVal; - else - if( aSection.GetCondition().Len() != 0 ) - aSection.SetCondHidden(!bVal); + pPutItem->PutValue(pValues[nProperty], + pEntry->nMemberId); } - break; - case WID_SECT_PROTECTED: + } + } + } + } + + if (pFmt) + { + SwDoc* pDoc = pFmt->GetDoc(); + const SwSectionFmts& rFmts = pDoc->GetSections(); + UnoActionContext aContext(pDoc); + for (sal_uInt16 i = 0; i < rFmts.Count(); i++) + { + if (rFmts[i]->GetSection()->GetName() == pSect->GetName()) + { + pDoc->ChgSection(i, aSection, pItemSet.get(), + pDoc->IsInReading()); + { + // temporarily remove actions to allow cursor update + UnoActionRemoveContext aRemoveContext( pDoc ); + } + + //SwSection* pSect = pFmt->GetSection(); + if (bLinkModeChanged && pSect->GetType() == DDE_LINK_SECTION) + { + // set update type; needs an established link + if (!pSect->IsConnected()) { - sal_Bool bVal = *(sal_Bool*)pValues[nProperty].getValue(); - if(m_bIsDescriptor) - pProps->bProtect = bVal; - else - aSection.SetProtect(bVal); + pSect->CreateLink(CREATE_CONNECT); } - break; - // --> FME 2004-06-22 #114856# edit in readonly sections - case WID_SECT_EDIT_IN_READONLY: + pSect->SetUpdateType( static_cast< USHORT >((bLinkMode) ? + sfx2::LINKUPDATE_ALWAYS : sfx2::LINKUPDATE_ONCALL) ); + } + // section found and processed: break from loop + break; + } + } + } +} + +void SAL_CALL +SwXTextSection::setPropertyValues( + const uno::Sequence< ::rtl::OUString >& rPropertyNames, + const uno::Sequence< uno::Any >& rValues) +throw (beans::PropertyVetoException, lang::IllegalArgumentException, + lang::WrappedTargetException, uno::RuntimeException) +{ + vos::OGuard aGuard(Application::GetSolarMutex()); + + // workaround for bad designed API + try + { + m_pImpl->SetPropertyValues_Impl( rPropertyNames, rValues ); + } + catch (beans::UnknownPropertyException &rException) + { + // wrap the original (here not allowed) exception in + // a WrappedTargetException that gets thrown instead. + lang::WrappedTargetException aWExc; + aWExc.TargetException <<= rException; + throw aWExc; + } +} +/*-- 10.12.98 14:47:11--------------------------------------------------- + + -----------------------------------------------------------------------*/ +void SwXTextSection::setPropertyValue( + const OUString& rPropertyName, const uno::Any& rValue) +throw (beans::UnknownPropertyException, beans::PropertyVetoException, + lang::IllegalArgumentException, lang::WrappedTargetException, + uno::RuntimeException ) +{ + vos::OGuard aGuard(Application::GetSolarMutex()); + + uno::Sequence< ::rtl::OUString > aPropertyNames(1); + aPropertyNames.getArray()[0] = rPropertyName; + uno::Sequence< uno::Any > aValues(1); + aValues.getArray()[0] = rValue; + m_pImpl->SetPropertyValues_Impl( aPropertyNames, aValues ); +} + +/* -----------------------------12.02.01 10:43-------------------------------- + + ---------------------------------------------------------------------------*/ +uno::Sequence< uno::Any > +SwXTextSection::Impl::GetPropertyValues_Impl( + const uno::Sequence< OUString > & rPropertyNames ) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) +{ + SwSectionFmt *const pFmt = GetSectionFmt(); + if (!pFmt && !m_bIsDescriptor) + { + throw uno::RuntimeException(); + } + + uno::Sequence< uno::Any > aRet(rPropertyNames.getLength()); + uno::Any* pRet = aRet.getArray(); + SwSection *const pSect = (pFmt) ? pFmt->GetSection() : 0; + const OUString* pPropertyNames = rPropertyNames.getConstArray(); + + for (sal_Int32 nProperty = 0; nProperty < rPropertyNames.getLength(); + nProperty++) + { + SfxItemPropertySimpleEntry const*const pEntry = + m_rPropSet.getPropertyMap()->getByName(pPropertyNames[nProperty]); + if (!pEntry) + { + throw beans::UnknownPropertyException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) + + pPropertyNames[nProperty], + static_cast(& m_rThis)); + } + switch(pEntry->nWID) + { + case WID_SECT_CONDITION: + { + OUString uTmp( (m_bIsDescriptor) + ? m_pProps->m_sCondition + : ::rtl::OUString(pSect->GetCondition())); + pRet[nProperty] <<= uTmp; + } + break; + case WID_SECT_DDE_TYPE: + case WID_SECT_DDE_FILE: + case WID_SECT_DDE_ELEMENT: + { + ::rtl::OUString sRet; + if (m_bIsDescriptor) + { + if (m_pProps->m_bDDE) { - sal_Bool bVal = *(sal_Bool*)pValues[nProperty].getValue(); - if(m_bIsDescriptor) - pProps->bEditInReadonly = bVal; - else - aSection.SetEditInReadonly(bVal); + sRet = m_pProps->m_sLinkFileName; } - // <-- - break; - case WID_SECT_PASSWORD: + } + else if (DDE_LINK_SECTION == pSect->GetType()) + { + sRet = pSect->GetLinkFileName(); + } + sal_Int32 nDummy(0); + sRet = sRet.getToken(pEntry->nWID - WID_SECT_DDE_TYPE, + sfx2::cTokenSeperator, nDummy); + pRet[nProperty] <<= sRet; + } + break; + case WID_SECT_DDE_AUTOUPDATE: + { + // GetUpdateType() returns .._ALWAYS or .._ONCALL + if (pSect && pSect->IsLinkType() && pSect->IsConnected()) // lijian i73247 + { + const sal_Bool bTemp = + (pSect->GetUpdateType() == sfx2::LINKUPDATE_ALWAYS); + pRet[nProperty] <<= bTemp; + } + } + break; + case WID_SECT_LINK : + { + text::SectionFileLink aLink; + if (m_bIsDescriptor) + { + if (!m_pProps->m_bDDE) { - uno::Sequence aSeq; - pValues[nProperty] >>= aSeq; - if (m_bIsDescriptor) - pProps->aPassword = aSeq; - else - aSection.SetPasswd(aSeq); + aLink.FileURL = m_pProps->m_sLinkFileName; + aLink.FilterName = m_pProps->m_sSectionFilter; } - break; - default: - if(pFmt) - { - const SfxItemSet& rOldAttrSet = pFmt->GetAttrSet(); - aItemSet.pItemSet = new SfxItemSet(*rOldAttrSet.GetPool(), - pEntry->nWID, pEntry->nWID, 0); - aItemSet.pItemSet->Put(rOldAttrSet); - m_pPropSet->setPropertyValue(*pEntry, pValues[nProperty], *aItemSet.pItemSet); - } - else - { - SfxPoolItem* pPutItem = 0; - if(RES_COL == pEntry->nWID) - { - if(!pProps->pColItem) - pProps->pColItem = new SwFmtCol; - pPutItem = pProps->pColItem; - } - else if(RES_BACKGROUND == pEntry->nWID) - { - if(!pProps->pBrushItem) - pProps->pBrushItem = new SvxBrushItem(RES_BACKGROUND); - pPutItem = pProps->pBrushItem; - } - else if(RES_FTN_AT_TXTEND == pEntry->nWID) - { - if(!pProps->pFtnItem) - pProps->pFtnItem = new SwFmtFtnAtTxtEnd; - pPutItem = pProps->pFtnItem; - } - else if(RES_END_AT_TXTEND == pEntry->nWID) - { - if(!pProps->pEndItem) - pProps->pEndItem = new SwFmtEndAtTxtEnd; - pPutItem = pProps->pEndItem; - } - else if(RES_UNKNOWNATR_CONTAINER== pEntry->nWID) - { - if(!pProps->pXMLAttr) - pProps->pXMLAttr= new SvXMLAttrContainerItem( RES_UNKNOWNATR_CONTAINER ); - pPutItem = pProps->pXMLAttr; - } - else if(RES_COLUMNBALANCE== pEntry->nWID) - { - if(!pProps->pNoBalanceItem) - pProps->pNoBalanceItem= new SwFmtNoBalancedColumns( RES_COLUMNBALANCE ); - pPutItem = pProps->pNoBalanceItem; - } - else if(RES_FRAMEDIR == pEntry->nWID) - { - if(!pProps->pFrameDirItem) - pProps->pFrameDirItem = new SvxFrameDirectionItem( FRMDIR_HORI_LEFT_TOP, RES_FRAMEDIR ); - pPutItem = pProps->pFrameDirItem; - } - else if(RES_LR_SPACE == pEntry->nWID) - { - // #109700# - if(!pProps->pLRSpaceItem) - pProps->pLRSpaceItem = new SvxLRSpaceItem( RES_LR_SPACE ); - pPutItem = pProps->pLRSpaceItem; - } - if(pPutItem) - pPutItem->PutValue(pValues[nProperty], pEntry->nMemberId); - } } + else if (FILE_LINK_SECTION == pSect->GetType()) + { + ::rtl::OUString sRet( pSect->GetLinkFileName() ); + sal_Int32 nIndex(0); + aLink.FileURL = + sRet.getToken(0, sfx2::cTokenSeperator, nIndex); + aLink.FilterName = + sRet.getToken(0, sfx2::cTokenSeperator, nIndex); + } + pRet[nProperty] <<= aLink; } - } - if(pFmt) - { - SwDoc* pDoc = pFmt->GetDoc(); - const SwSectionFmts& rFmts = pDoc->GetSections(); - UnoActionContext aContext(pDoc); - for( sal_uInt16 i = 0; i < rFmts.Count(); i++ ) + break; + case WID_SECT_REGION : + { + ::rtl::OUString sRet; + if (m_bIsDescriptor) + { + sRet = m_pProps->m_sSectionRegion; + } + else if (FILE_LINK_SECTION == pSect->GetType()) + { + sRet = pSect->GetLinkFileName().GetToken(2, + sfx2::cTokenSeperator); + } + pRet[nProperty] <<= sRet; + } + break; + case WID_SECT_VISIBLE : + { + const sal_Bool bTemp = (m_bIsDescriptor) + ? !m_pProps->m_bHidden : !pSect->IsHidden(); + pRet[nProperty] <<= bTemp; + } + break; + case WID_SECT_CURRENTLY_VISIBLE: + { + const sal_Bool bTemp = (m_bIsDescriptor) + ? !m_pProps->m_bCondHidden : !pSect->IsCondHidden(); + pRet[nProperty] <<= bTemp; + } + break; + case WID_SECT_PROTECTED: + { + const sal_Bool bTemp = (m_bIsDescriptor) + ? m_pProps->m_bProtect : pSect->IsProtect(); + pRet[nProperty] <<= bTemp; + } + break; + // --> FME 2004-06-22 #114856# edit in readonly sections + case WID_SECT_EDIT_IN_READONLY: + { + const sal_Bool bTemp = (m_bIsDescriptor) + ? m_pProps->m_bEditInReadonly : pSect->IsEditInReadonly(); + pRet[nProperty] <<= bTemp; + } + break; + // <-- + case FN_PARAM_LINK_DISPLAY_NAME: + { + if (pFmt) + { + pRet[nProperty] <<= OUString(pFmt->GetSection()->GetName()); + } + } + break; + case WID_SECT_DOCUMENT_INDEX: + { + // search enclosing index + SwSection* pEnclosingSection = pSect; + while ((pEnclosingSection != NULL) && + (TOX_CONTENT_SECTION != pEnclosingSection->GetType())) + { + pEnclosingSection = pEnclosingSection->GetParent(); + } + if (pEnclosingSection) + { + // convert section to TOXBase and get SwXDocumentIndex + SwTOXBaseSection *const pTOXBaseSect = + PTR_CAST(SwTOXBaseSection, pEnclosingSection); + const uno::Reference xIndex = + SwXDocumentIndexes::GetObject(pTOXBaseSect); + pRet[nProperty] <<= xIndex; + } + // else: no enclosing index found -> empty return value + } + break; + case WID_SECT_IS_GLOBAL_DOC_SECTION: + { + const sal_Bool bRet = (NULL == pFmt) ? sal_False : + static_cast(NULL != pFmt->GetGlobalDocSection()); + pRet[nProperty] <<= bRet; + } + break; + case FN_UNO_ANCHOR_TYPES: + case FN_UNO_TEXT_WRAP: + case FN_UNO_ANCHOR_TYPE: + SwXParagraph::getDefaultTextContentValue( + pRet[nProperty], OUString(), pEntry->nWID); + break; + case FN_UNO_REDLINE_NODE_START: + case FN_UNO_REDLINE_NODE_END: { - if(rFmts[i]->GetSection()->GetName() == pSect->GetName()) + if (!pFmt) + break; // lijian i73247 + SwNode* pSectNode = pFmt->GetSectionNode(); + if (FN_UNO_REDLINE_NODE_END == pEntry->nWID) { - pDoc->ChgSection( i, aSection, aItemSet.pItemSet, pDoc->IsInReading()); - - { - // temporarily remove actions to allow cursor update - UnoActionRemoveContext aRemoveContext( pDoc ); - } - - //SwSection* pSect = pFmt->GetSection(); - if( bLinkModeChanged && pSect->GetType() == DDE_LINK_SECTION) + pSectNode = pSectNode->EndOfSectionNode(); + } + const SwRedlineTbl& rRedTbl = + pFmt->GetDoc()->GetRedlineTbl(); + for (USHORT nRed = 0; nRed < rRedTbl.Count(); nRed++) + { + const SwRedline* pRedline = rRedTbl[nRed]; + SwNode const*const pRedPointNode = pRedline->GetNode(TRUE); + SwNode const*const pRedMarkNode = pRedline->GetNode(FALSE); + if ((pRedPointNode == pSectNode) || + (pRedMarkNode == pSectNode)) { - // set update type; needs an established link - if(!pSect->IsConnected()) - { - pSect->CreateLink(CREATE_CONNECT); - } - pSect->SetUpdateType( static_cast< USHORT >(bLinkMode ? - sfx2::LINKUPDATE_ALWAYS : sfx2::LINKUPDATE_ONCALL) ); + SwNode const*const pStartOfRedline = + (SwNodeIndex(*pRedPointNode) <= + SwNodeIndex(*pRedMarkNode)) + ? pRedPointNode : pRedMarkNode; + const bool bIsStart = (pStartOfRedline == pSectNode); + pRet[nProperty] <<= + SwXRedlinePortion::CreateRedlineProperties( + *pRedline, bIsStart); + break; } - // section found and processed: break from loop - break; } } - } - } - else - throw uno::RuntimeException(); -} - -void SwXTextSection::setPropertyValues( - const Sequence< ::rtl::OUString >& rPropertyNames, - const Sequence< Any >& rValues ) - throw(PropertyVetoException, lang::IllegalArgumentException, - lang::WrappedTargetException, RuntimeException) -{ - vos::OGuard aGuard(Application::GetSolarMutex()); - - // workaround for bad designed API - try - { - SetPropertyValues_Impl( rPropertyNames, rValues ); - } - catch (UnknownPropertyException &rException) - { - // wrap the original (here not allowed) exception in - // a WrappedTargetException that gets thrown instead. - WrappedTargetException aWExc; - aWExc.TargetException <<= rException; - throw aWExc; - } -} -/*-- 10.12.98 14:47:11--------------------------------------------------- - - -----------------------------------------------------------------------*/ -void SwXTextSection::setPropertyValue( - const OUString& rPropertyName, const uno::Any& aValue) - throw( beans::UnknownPropertyException, beans::PropertyVetoException, - lang::IllegalArgumentException, lang::WrappedTargetException, - uno::RuntimeException ) -{ - vos::OGuard aGuard(Application::GetSolarMutex()); - Sequence< ::rtl::OUString > aPropertyNames(1); - aPropertyNames.getArray()[0] = rPropertyName; - Sequence< Any > aValues(1); - aValues.getArray()[0] = aValue; - SetPropertyValues_Impl( aPropertyNames, aValues ); -} -/* -----------------------------12.02.01 10:43-------------------------------- - - ---------------------------------------------------------------------------*/ -uno::Sequence< Any > SAL_CALL SwXTextSection::GetPropertyValues_Impl( - const uno::Sequence< OUString > & rPropertyNames ) - throw( UnknownPropertyException, WrappedTargetException, RuntimeException) -{ - Sequence< Any > aRet(rPropertyNames.getLength()); - Any* pRet = aRet.getArray(); - SwSectionFmt* pFmt = GetFmt(); - if(pFmt||m_bIsDescriptor) - { - SwSection* pSect = pFmt ? pFmt->GetSection() : 0; - const OUString* pPropertyNames = rPropertyNames.getConstArray(); - for(sal_Int32 nProperty = 0; nProperty < rPropertyNames.getLength(); nProperty++) - { - const SfxItemPropertySimpleEntry* pEntry = - m_pPropSet->getPropertyMap()->getByName( pPropertyNames[nProperty]); - if(pEntry) + break; + case WID_SECT_PASSWORD: { - switch(pEntry->nWID) + pRet[nProperty] <<= (m_bIsDescriptor) + ? m_pProps->m_Password : pSect->GetPasswd(); + } + break; + default: + { + if (pFmt) { - case WID_SECT_CONDITION: - { - OUString uTmp( - m_bIsDescriptor ? pProps->sCondition : pSect->GetCondition()); - pRet[nProperty] <<= uTmp; - } - break; - case WID_SECT_DDE_TYPE : - case WID_SECT_DDE_FILE : - case WID_SECT_DDE_ELEMENT : + m_rPropSet.getPropertyValue(*pEntry, + pFmt->GetAttrSet(), pRet[nProperty]); + } + else + { + const SfxPoolItem* pQueryItem = 0; + if (RES_COL == pEntry->nWID) { - String sRet; - if(m_bIsDescriptor) - { - if(pProps->bDDE) - sRet = pProps->sLinkFileName; - } - else if( DDE_LINK_SECTION == pSect->GetType() ) + if (!m_pProps->m_pColItem.get()) { - sRet = pSect->GetLinkFileName(); + m_pProps->m_pColItem.reset(new SwFmtCol); } - sRet = sRet.GetToken(pEntry->nWID - WID_SECT_DDE_TYPE, sfx2::cTokenSeperator); - pRet[nProperty] <<= OUString(sRet); + pQueryItem = m_pProps->m_pColItem.get(); } - break; - case WID_SECT_DDE_AUTOUPDATE: + else if (RES_BACKGROUND == pEntry->nWID) { - // GetUpdateType() returns .._ALWAYS or .._ONCALL - if ( pSect && pSect->IsLinkType() && pSect->IsConnected() ) // lijian i73247 + if (!m_pProps->m_pBrushItem.get()) { - sal_Bool bTemp = - (pSect->GetUpdateType() == sfx2::LINKUPDATE_ALWAYS); - pRet[nProperty].setValue( &bTemp, ::getCppuBooleanType()); + m_pProps->m_pBrushItem.reset( + new SvxBrushItem(RES_BACKGROUND)); } + pQueryItem = m_pProps->m_pBrushItem.get(); } - break; - case WID_SECT_LINK : + else if (RES_FTN_AT_TXTEND == pEntry->nWID) { - text::SectionFileLink aLink; - if(m_bIsDescriptor) - { - if(!pProps->bDDE) - { - aLink.FileURL = pProps->sLinkFileName; - aLink.FilterName = pProps->sSectionFilter; - } - } - else if( FILE_LINK_SECTION == pSect->GetType() ) + if (!m_pProps->m_pFtnItem.get()) { - String sRet( pSect->GetLinkFileName() ); - aLink.FileURL = sRet.GetToken(0, sfx2::cTokenSeperator ); - aLink.FilterName = sRet.GetToken(1, sfx2::cTokenSeperator ); + m_pProps->m_pFtnItem.reset(new SwFmtFtnAtTxtEnd); } - pRet[nProperty].setValue(&aLink, ::getCppuType((text::SectionFileLink*)0)); + pQueryItem = m_pProps->m_pFtnItem.get(); } - break; - case WID_SECT_REGION : + else if (RES_END_AT_TXTEND == pEntry->nWID) { - String sRet; - if(m_bIsDescriptor) + if (!m_pProps->m_pEndItem.get()) { - sRet = pProps->sSectionRegion; + m_pProps->m_pEndItem.reset(new SwFmtEndAtTxtEnd); } - else if( FILE_LINK_SECTION == pSect->GetType() ) - sRet = pSect->GetLinkFileName().GetToken(2, sfx2::cTokenSeperator); - pRet[nProperty] <<= OUString(sRet); - } - break; - case WID_SECT_VISIBLE : - { - sal_Bool bTemp = m_bIsDescriptor ? !pProps->bHidden : !pSect->IsHidden(); - pRet[nProperty].setValue( &bTemp, ::getCppuBooleanType()); - } - break; - case WID_SECT_CURRENTLY_VISIBLE: - { - sal_Bool bTmp = m_bIsDescriptor ? !pProps->bCondHidden : !pSect->IsCondHidden(); - pRet[nProperty].setValue( &bTmp, ::getCppuBooleanType()); - } - break; - case WID_SECT_PROTECTED: - { - sal_Bool bTemp = m_bIsDescriptor ? pProps->bProtect : pSect->IsProtect(); - pRet[nProperty].setValue( &bTemp, ::getCppuBooleanType()); - } - break; - // --> FME 2004-06-22 #114856# edit in readonly sections - case WID_SECT_EDIT_IN_READONLY: - { - sal_Bool bTemp = m_bIsDescriptor ? pProps->bEditInReadonly : pSect->IsEditInReadonly(); - pRet[nProperty].setValue( &bTemp, ::getCppuBooleanType()); - } - break; - // <-- - case FN_PARAM_LINK_DISPLAY_NAME: - { - if(pFmt) - pRet[nProperty] <<= OUString(pFmt->GetSection()->GetName()); + pQueryItem = m_pProps->m_pEndItem.get(); } - break; - case WID_SECT_DOCUMENT_INDEX: + else if (RES_UNKNOWNATR_CONTAINER== pEntry->nWID) { - // search enclosing index - SwSection* pEnclosingSection = pSect; - while ( (pEnclosingSection != NULL) && - (TOX_CONTENT_SECTION != - pEnclosingSection->GetType()) ) + if (!m_pProps->m_pXMLAttr.get()) { - pEnclosingSection = pEnclosingSection->GetParent(); + m_pProps->m_pXMLAttr.reset( + new SvXMLAttrContainerItem); } - if (pEnclosingSection) + pQueryItem = m_pProps->m_pXMLAttr.get(); + } + else if (RES_COLUMNBALANCE== pEntry->nWID) + { + if (!m_pProps->m_pNoBalanceItem.get()) { - // convert section to TOXBase and get SwXDocumentIndex - SwTOXBaseSection* pTOXBaseSect = - PTR_CAST(SwTOXBaseSection, pEnclosingSection); - uno::Reference xIndex = - SwXDocumentIndexes::GetObject(pTOXBaseSect); - pRet[nProperty] <<= xIndex; + m_pProps->m_pNoBalanceItem.reset( + new SwFmtNoBalancedColumns); } - // else: no enclosing index found -> empty return value + pQueryItem = m_pProps->m_pNoBalanceItem.get(); } - break; - case WID_SECT_IS_GLOBAL_DOC_SECTION: + else if (RES_FRAMEDIR == pEntry->nWID) { - sal_Bool bRet = (NULL == pFmt) ? sal_False : - static_cast< sal_Bool >(NULL != pFmt->GetGlobalDocSection()); - pRet[nProperty].setValue( &bRet, ::getCppuBooleanType()); + if (!m_pProps->m_pFrameDirItem.get()) + { + m_pProps->m_pFrameDirItem.reset( + new SvxFrameDirectionItem( + FRMDIR_ENVIRONMENT, RES_FRAMEDIR)); + } + pQueryItem = m_pProps->m_pFrameDirItem.get(); } - break; - case FN_UNO_ANCHOR_TYPES: - case FN_UNO_TEXT_WRAP: - case FN_UNO_ANCHOR_TYPE: - SwXParagraph::getDefaultTextContentValue(pRet[nProperty], OUString(), pEntry->nWID); - break; - case FN_UNO_REDLINE_NODE_START: - case FN_UNO_REDLINE_NODE_END: + /* -> #109700# */ + else if (RES_LR_SPACE == pEntry->nWID) { - if(!pFmt) - break; // lijian i73247 - SwNode* pSectNode = pFmt->GetSectionNode(); - if(FN_UNO_REDLINE_NODE_END == pEntry->nWID) - pSectNode = pSectNode->EndOfSectionNode(); - const SwRedlineTbl& rRedTbl = pFmt->GetDoc()->GetRedlineTbl(); - for(USHORT nRed = 0; nRed < rRedTbl.Count(); nRed++) + if (!m_pProps->m_pLRSpaceItem.get()) { - const SwRedline* pRedline = rRedTbl[nRed]; - const SwNode* pRedPointNode = pRedline->GetNode(TRUE); - const SwNode* pRedMarkNode = pRedline->GetNode(FALSE); - if(pRedPointNode == pSectNode || pRedMarkNode == pSectNode) - { - const SwNode* pStartOfRedline = SwNodeIndex(*pRedPointNode) <= SwNodeIndex(*pRedMarkNode) ? - pRedPointNode : pRedMarkNode; - BOOL bIsStart = pStartOfRedline == pSectNode; - pRet[nProperty] <<= SwXRedlinePortion::CreateRedlineProperties(*pRedline, bIsStart); - break; - } + m_pProps->m_pLRSpaceItem.reset( + new SvxLRSpaceItem( RES_LR_SPACE )); } + pQueryItem = m_pProps->m_pLRSpaceItem.get(); } - break; - case WID_SECT_PASSWORD: + /* <- #109700# */ + if (pQueryItem) { - pRet[nProperty] <<= m_bIsDescriptor ? pProps->aPassword : pSect->GetPasswd(); + pQueryItem->QueryValue(pRet[nProperty], + pEntry->nMemberId); } - break; - default: - if(pFmt) - m_pPropSet->getPropertyValue(*pEntry, pFmt->GetAttrSet(), pRet[nProperty]); - else - { - const SfxPoolItem* pQueryItem = 0; - if(RES_COL == pEntry->nWID) - { - if(!pProps->pColItem) - pProps->pColItem = new SwFmtCol; - pQueryItem = pProps->pColItem; - } - else if(RES_BACKGROUND == pEntry->nWID) - { - if(!pProps->pBrushItem) - pProps->pBrushItem = new SvxBrushItem(RES_BACKGROUND); - pQueryItem = pProps->pBrushItem; - } - else if(RES_FTN_AT_TXTEND == pEntry->nWID) - { - if(!pProps->pFtnItem) - pProps->pFtnItem = new SwFmtFtnAtTxtEnd; - pQueryItem = pProps->pFtnItem; - } - else if(RES_END_AT_TXTEND == pEntry->nWID) - { - if(!pProps->pEndItem) - pProps->pEndItem = new SwFmtEndAtTxtEnd; - pQueryItem = pProps->pEndItem; - } - else if(RES_UNKNOWNATR_CONTAINER== pEntry->nWID) - { - if(!pProps->pXMLAttr) - pProps->pXMLAttr= new SvXMLAttrContainerItem ; - pQueryItem = pProps->pXMLAttr; - } - else if(RES_COLUMNBALANCE== pEntry->nWID) - { - if(!pProps->pNoBalanceItem) - pProps->pNoBalanceItem= new SwFmtNoBalancedColumns; - pQueryItem = pProps->pNoBalanceItem; - } - else if(RES_FRAMEDIR == pEntry->nWID) - { - if(!pProps->pFrameDirItem) - pProps->pFrameDirItem = new SvxFrameDirectionItem(FRMDIR_ENVIRONMENT, RES_FRAMEDIR); - pQueryItem = pProps->pFrameDirItem; - } - /* -> #109700# */ - else if(RES_LR_SPACE == pEntry->nWID) - { - if(!pProps->pLRSpaceItem) - pProps->pLRSpaceItem = new SvxLRSpaceItem( RES_LR_SPACE ); - pQueryItem = pProps->pLRSpaceItem; - } - /* <- #109700# */ - if(pQueryItem) - pQueryItem->QueryValue(pRet[nProperty], pEntry->nMemberId); - } } } - else - throw UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pPropertyNames[nProperty], static_cast < cppu::OWeakObject * > ( this ) ); } } - else - throw uno::RuntimeException(); return aRet; } + /* -----------------------------04.11.03 10:43-------------------------------- ---------------------------------------------------------------------------*/ -Sequence< Any > SwXTextSection::getPropertyValues( - const Sequence< ::rtl::OUString >& rPropertyNames ) - throw(RuntimeException) +uno::Sequence< uno::Any > SAL_CALL +SwXTextSection::getPropertyValues( + const uno::Sequence< ::rtl::OUString >& rPropertyNames) +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - Sequence< Any > aValues; + uno::Sequence< uno::Any > aValues; // workaround for bad designed API try { - aValues = GetPropertyValues_Impl( rPropertyNames ); + aValues = m_pImpl->GetPropertyValues_Impl( rPropertyNames ); } - catch (UnknownPropertyException &) + catch (beans::UnknownPropertyException &) { - throw RuntimeException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property exception caught" ) ), static_cast < cppu::OWeakObject * > ( this ) ); + throw uno::RuntimeException(OUString( + RTL_CONSTASCII_USTRINGPARAM("Unknown property exception caught")), + static_cast(this)); } - catch (WrappedTargetException &) + catch (lang::WrappedTargetException &) { - throw RuntimeException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "WrappedTargetException caught" ) ), static_cast < cppu::OWeakObject * > ( this ) ); + throw uno::RuntimeException(OUString( + RTL_CONSTASCII_USTRINGPARAM("WrappedTargetException caught")), + static_cast(this)); } return aValues; @@ -1213,279 +1356,373 @@ Sequence< Any > SwXTextSection::getPropertyValues( /*-- 10.12.98 14:47:12--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Any SwXTextSection::getPropertyValue(const OUString& rPropertyName) - throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +uno::Any SAL_CALL +SwXTextSection::getPropertyValue(const OUString& rPropertyName) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - Sequence< ::rtl::OUString > aPropertyNames(1); + + uno::Sequence< ::rtl::OUString > aPropertyNames(1); aPropertyNames.getArray()[0] = rPropertyName; - return GetPropertyValues_Impl(aPropertyNames).getConstArray()[0]; + return m_pImpl->GetPropertyValues_Impl(aPropertyNames).getConstArray()[0]; } /* -----------------------------12.02.01 10:30-------------------------------- ---------------------------------------------------------------------------*/ -void SwXTextSection::addPropertiesChangeListener( - const uno::Sequence< ::rtl::OUString >& /*aPropertyNames*/, - const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ ) throw(RuntimeException) +void SAL_CALL SwXTextSection::addPropertiesChangeListener( + const uno::Sequence< OUString >& /*aPropertyNames*/, + const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ ) +throw (uno::RuntimeException) { - DBG_WARNING("not implemented"); + OSL_ENSURE(false, + "SwXTextSection::addPropertiesChangeListener(): not implemented"); } + /* -----------------------------12.02.01 10:30-------------------------------- ---------------------------------------------------------------------------*/ -void SwXTextSection::removePropertiesChangeListener( +void SAL_CALL SwXTextSection::removePropertiesChangeListener( const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ ) - throw(RuntimeException) +throw (uno::RuntimeException) { - DBG_WARNING("not implemented"); + OSL_ENSURE(false, + "SwXTextSection::removePropertiesChangeListener(): not implemented"); } + /* -----------------------------12.02.01 10:30-------------------------------- ---------------------------------------------------------------------------*/ -void SwXTextSection::firePropertiesChangeEvent( - const uno::Sequence< ::rtl::OUString >& /*aPropertyNames*/, +void SAL_CALL SwXTextSection::firePropertiesChangeEvent( + const uno::Sequence< OUString >& /*aPropertyNames*/, const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ ) - throw(RuntimeException) + throw(uno::RuntimeException) { - DBG_WARNING("not implemented"); + OSL_ENSURE(false, + "SwXTextSection::firePropertiesChangeEvent(): not implemented"); } + /*-- 10.12.98 14:47:13--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextSection::addPropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +void SAL_CALL +SwXTextSection::addPropertyChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - DBG_WARNING("not implemented"); + OSL_ENSURE(false, + "SwXTextSection::addPropertyChangeListener(): not implemented"); } -/*-- 10.12.98 14:47:13--------------------------------------------------- - -----------------------------------------------------------------------*/ -void SwXTextSection::removePropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +void SAL_CALL +SwXTextSection::removePropertyChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - DBG_WARNING("not implemented"); + OSL_ENSURE(false, + "SwXTextSection::removePropertyChangeListener(): not implemented"); } -/*-- 10.12.98 14:47:14--------------------------------------------------- - -----------------------------------------------------------------------*/ -void SwXTextSection::addVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +void SAL_CALL +SwXTextSection::addVetoableChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - DBG_WARNING("not implemented"); + OSL_ENSURE(false, + "SwXTextSection::addVetoableChangeListener(): not implemented"); } -/*-- 10.12.98 14:47:14--------------------------------------------------- - -----------------------------------------------------------------------*/ -void SwXTextSection::removeVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +void SAL_CALL +SwXTextSection::removeVetoableChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - DBG_WARNING("not implemented"); + OSL_ENSURE(false, + "SwXTextSection::removeVetoableChangeListener(): not implemented"); } /*-- 08.11.00 10:47:55--------------------------------------------------- -----------------------------------------------------------------------*/ -PropertyState SwXTextSection::getPropertyState( const OUString& rPropertyName ) - throw(UnknownPropertyException, RuntimeException) +beans::PropertyState SAL_CALL +SwXTextSection::getPropertyState(const OUString& rPropertyName) +throw (beans::UnknownPropertyException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - Sequence< OUString > aNames(1); + + uno::Sequence< OUString > aNames(1); aNames.getArray()[0] = rPropertyName; return getPropertyStates(aNames).getConstArray()[0]; } /*-- 08.11.00 10:47:55--------------------------------------------------- -----------------------------------------------------------------------*/ -Sequence< PropertyState > SwXTextSection::getPropertyStates( - const Sequence< OUString >& rPropertyNames ) - throw(UnknownPropertyException, RuntimeException) +uno::Sequence< beans::PropertyState > SAL_CALL +SwXTextSection::getPropertyStates( + const uno::Sequence< OUString >& rPropertyNames) +throw (beans::UnknownPropertyException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - Sequence< PropertyState > aStates(rPropertyNames.getLength()); - SwSectionFmt* pFmt = GetFmt(); - if(pFmt||m_bIsDescriptor) + + SwSectionFmt *const pFmt = m_pImpl->GetSectionFmt(); + if (!pFmt && !m_pImpl->m_bIsDescriptor) + { + throw uno::RuntimeException(); + } + + uno::Sequence< beans::PropertyState > aStates(rPropertyNames.getLength()); + beans::PropertyState *const pStates = aStates.getArray(); + const OUString* pNames = rPropertyNames.getConstArray(); + for (sal_Int32 i = 0; i < rPropertyNames.getLength(); i++) { - PropertyState* pStates = aStates.getArray(); - const OUString* pNames = rPropertyNames.getConstArray(); - for(sal_Int32 i = 0; i < rPropertyNames.getLength(); i++) + pStates[i] = beans::PropertyState_DEFAULT_VALUE; + SfxItemPropertySimpleEntry const*const pEntry = + m_pImpl->m_rPropSet.getPropertyMap()->getByName( pNames[i]); + if (!pEntry) + { + throw beans::UnknownPropertyException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) + + pNames[i], static_cast< cppu::OWeakObject* >(this)); + } + switch (pEntry->nWID) { - pStates[i] = PropertyState_DEFAULT_VALUE; - const SfxItemPropertySimpleEntry* pEntry = - m_pPropSet->getPropertyMap()->getByName( pNames[i]); - if(!pEntry) - throw UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pNames[i], static_cast < cppu::OWeakObject * > ( this ) ); - switch(pEntry->nWID) + case WID_SECT_CONDITION: + case WID_SECT_DDE_TYPE: + case WID_SECT_DDE_FILE: + case WID_SECT_DDE_ELEMENT: + case WID_SECT_DDE_AUTOUPDATE: + case WID_SECT_LINK: + case WID_SECT_REGION : + case WID_SECT_VISIBLE: + case WID_SECT_PROTECTED: + // --> FME 2004-06-22 #114856# edit in readonly sections + case WID_SECT_EDIT_IN_READONLY: + // <-- + case FN_PARAM_LINK_DISPLAY_NAME: + case FN_UNO_ANCHOR_TYPES: + case FN_UNO_TEXT_WRAP: + case FN_UNO_ANCHOR_TYPE: + pStates[i] = beans::PropertyState_DIRECT_VALUE; + break; + default: { - case WID_SECT_CONDITION: - case WID_SECT_DDE_TYPE : - case WID_SECT_DDE_FILE : - case WID_SECT_DDE_ELEMENT : - case WID_SECT_DDE_AUTOUPDATE: - case WID_SECT_LINK : - case WID_SECT_REGION : - case WID_SECT_VISIBLE : - case WID_SECT_PROTECTED: - // --> FME 2004-06-22 #114856# edit in readonly sections - case WID_SECT_EDIT_IN_READONLY: - // <-- - case FN_PARAM_LINK_DISPLAY_NAME: - case FN_UNO_ANCHOR_TYPES: - case FN_UNO_TEXT_WRAP: - case FN_UNO_ANCHOR_TYPE: - pStates[i] = PropertyState_DIRECT_VALUE; - break; - default: - if(pFmt) - pStates[i] = m_pPropSet->getPropertyState(pNames[i], pFmt->GetAttrSet()); - else + if (pFmt) + { + pStates[i] = m_pImpl->m_rPropSet.getPropertyState( + pNames[i], pFmt->GetAttrSet()); + } + else + { + if (RES_COL == pEntry->nWID) + { + if (!m_pImpl->m_pProps->m_pColItem.get()) + { + pStates[i] = beans::PropertyState_DEFAULT_VALUE; + } + else + { + pStates[i] = beans::PropertyState_DIRECT_VALUE; + } + } + else //if(RES_BACKGROUND == pEntry->nWID) { - if(RES_COL == pEntry->nWID) + if (!m_pImpl->m_pProps->m_pBrushItem.get()) { - if(!pProps->pColItem) - pStates[i] = PropertyState_DEFAULT_VALUE; - else - pStates[i] = PropertyState_DIRECT_VALUE; + pStates[i] = beans::PropertyState_DEFAULT_VALUE; } - else //if(RES_BACKGROUND == pEntry->nWID) + else { - if(!pProps->pBrushItem) - pStates[i] = PropertyState_DEFAULT_VALUE; - else - pStates[i] = PropertyState_DIRECT_VALUE; + pStates[i] = beans::PropertyState_DIRECT_VALUE; } } + } } } } - else - throw RuntimeException(); return aStates; } + /*-- 08.11.00 10:47:55--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextSection::setPropertyToDefault( const OUString& rPropertyName ) - throw(UnknownPropertyException, RuntimeException) +void SAL_CALL +SwXTextSection::setPropertyToDefault(const OUString& rPropertyName) +throw (beans::UnknownPropertyException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwSectionFmt* pFmt = GetFmt(); - if(pFmt||m_bIsDescriptor) + + SwSectionFmt *const pFmt = m_pImpl->GetSectionFmt(); + if (!pFmt && !m_pImpl->m_bIsDescriptor) { - SwSection aSection(CONTENT_SECTION, aEmptyStr); - SwSection* pSect = pFmt ? pFmt->GetSection() : 0; - if(pFmt) - aSection = *pSect; - const SfxItemPropertySimpleEntry* pEntry = - m_pPropSet->getPropertyMap()->getByName( rPropertyName ); - if(!pEntry) - throw UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); - if ( pEntry->nFlags & PropertyAttribute::READONLY) - throw RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "setPropertyToDefault: property is read-only: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); - SfxItemSet* pNewAttrSet = 0; - switch(pEntry->nWID) + throw uno::RuntimeException(); + } + + SwSection aSection(CONTENT_SECTION, aEmptyStr); + SwSection *const pSect = (pFmt) ? pFmt->GetSection() : 0; + if (pFmt) + { + aSection = *pSect; + } + SfxItemPropertySimpleEntry const*const pEntry = + m_pImpl->m_rPropSet.getPropertyMap()->getByName(rPropertyName); + if (!pEntry) + { + throw beans::UnknownPropertyException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) + + rPropertyName, static_cast< cppu::OWeakObject* >(this)); + } + if (pEntry->nFlags & beans::PropertyAttribute::READONLY) + { + throw uno::RuntimeException(OUString(RTL_CONSTASCII_USTRINGPARAM( + "setPropertyToDefault: property is read-only: ")) + + rPropertyName, + static_cast(this)); + } + + ::std::auto_ptr pNewAttrSet; + switch (pEntry->nWID) + { + case WID_SECT_CONDITION: { - case WID_SECT_CONDITION: + if (m_pImpl->m_bIsDescriptor) { - if(m_bIsDescriptor) - pProps->sCondition = aEmptyStr; - else - aSection.SetCondition(aEmptyStr); + m_pImpl->m_pProps->m_sCondition = aEmptyStr; } - break; - case WID_SECT_DDE_TYPE : - case WID_SECT_DDE_FILE : - case WID_SECT_DDE_ELEMENT : - case WID_SECT_LINK : - case WID_SECT_REGION : - aSection.SetType(CONTENT_SECTION); - break; - case WID_SECT_DDE_AUTOUPDATE: - aSection.SetUpdateType(sfx2::LINKUPDATE_ALWAYS); - break; - case WID_SECT_VISIBLE : + else { - if(m_bIsDescriptor) - pProps->bHidden = FALSE; - else - aSection.SetHidden(FALSE); + aSection.SetCondition(aEmptyStr); } - break; - case WID_SECT_PROTECTED: + } + break; + case WID_SECT_DDE_TYPE : + case WID_SECT_DDE_FILE : + case WID_SECT_DDE_ELEMENT : + case WID_SECT_LINK : + case WID_SECT_REGION : + aSection.SetType(CONTENT_SECTION); + break; + case WID_SECT_DDE_AUTOUPDATE: + aSection.SetUpdateType(sfx2::LINKUPDATE_ALWAYS); + break; + case WID_SECT_VISIBLE : + { + if (m_pImpl->m_bIsDescriptor) { - if(m_bIsDescriptor) - pProps->bProtect = FALSE; - else - aSection.SetProtect(FALSE); + m_pImpl->m_pProps->m_bHidden = false; } - break; - // --> FME 2004-06-22 #114856# edit in readonly sections - case WID_SECT_EDIT_IN_READONLY: + else { - if(m_bIsDescriptor) - pProps->bEditInReadonly = FALSE; - else - aSection.SetEditInReadonly(FALSE); + aSection.SetHidden(FALSE); } - break; - // <-- + } + break; + case WID_SECT_PROTECTED: + { + if (m_pImpl->m_bIsDescriptor) + { + m_pImpl->m_pProps->m_bProtect = false; + } + else + { + aSection.SetProtect(FALSE); + } + } + break; + // --> FME 2004-06-22 #114856# edit in readonly sections + case WID_SECT_EDIT_IN_READONLY: + { + if (m_pImpl->m_bIsDescriptor) + { + m_pImpl->m_pProps->m_bEditInReadonly = false; + } + else + { + aSection.SetEditInReadonly(FALSE); + } + } + break; + // <-- - case FN_UNO_ANCHOR_TYPES: - case FN_UNO_TEXT_WRAP: - case FN_UNO_ANCHOR_TYPE: - break; - default: - if(pEntry->nWID <= SFX_WHICH_MAX) + case FN_UNO_ANCHOR_TYPES: + case FN_UNO_TEXT_WRAP: + case FN_UNO_ANCHOR_TYPE: + break; + default: + { + if (pEntry->nWID <= SFX_WHICH_MAX) + { + if (pFmt) + { + const SfxItemSet& rOldAttrSet = pFmt->GetAttrSet(); + pNewAttrSet.reset( new SfxItemSet(*rOldAttrSet.GetPool(), + pEntry->nWID, pEntry->nWID, 0)); + pNewAttrSet->ClearItem(pEntry->nWID); + } + else { - if(pFmt) + if (RES_COL == pEntry->nWID) { - const SfxItemSet& rOldAttrSet = pFmt->GetAttrSet(); - pNewAttrSet = new SfxItemSet(*rOldAttrSet.GetPool(), - pEntry->nWID, pEntry->nWID, 0); - pNewAttrSet->ClearItem(pEntry->nWID); + m_pImpl->m_pProps->m_pColItem.reset(); } - else + else if (RES_BACKGROUND == pEntry->nWID) { - if(RES_COL == pEntry->nWID) - DELETEZ(pProps->pColItem); - else if(RES_BACKGROUND == pEntry->nWID) - DELETEZ(pProps->pBrushItem); + m_pImpl->m_pProps->m_pBrushItem.reset(); } } + } } - if(pFmt) + } + + if (pFmt) + { + SwDoc *const pDoc = pFmt->GetDoc(); + const SwSectionFmts& rFmts = pDoc->GetSections(); + UnoActionContext aContext(pDoc); + for (sal_uInt16 i = 0; i < rFmts.Count(); i++) { - SwDoc* pDoc = pFmt->GetDoc(); - const SwSectionFmts& rFmts = pDoc->GetSections(); - UnoActionContext aContext(pDoc); - for( sal_uInt16 i = 0; i < rFmts.Count(); i++ ) + if (rFmts[i]->GetSection()->GetName() == pSect->GetName()) { - if(rFmts[i]->GetSection()->GetName() == pSect->GetName()) + pDoc->ChgSection(i, aSection, pNewAttrSet.get(), + pDoc->IsInReading()); { - pDoc->ChgSection( i, aSection, pNewAttrSet, pDoc->IsInReading()); - - { - // temporarily remove actions to allow cursor update - UnoActionRemoveContext aRemoveContext( pDoc ); - } - - break; + // temporarily remove actions to allow cursor update + UnoActionRemoveContext aRemoveContext( pDoc ); } + break; } - delete pNewAttrSet; } } - else - throw RuntimeException(); } + /*-- 08.11.00 10:47:56--------------------------------------------------- -----------------------------------------------------------------------*/ -Any SwXTextSection::getPropertyDefault( const OUString& rPropertyName ) - throw(UnknownPropertyException, WrappedTargetException, RuntimeException) +uno::Any SAL_CALL +SwXTextSection::getPropertyDefault(const OUString& rPropertyName) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + uno::Any aRet; - SwSectionFmt* pFmt = GetFmt(); - const SfxItemPropertySimpleEntry* pEntry = - m_pPropSet->getPropertyMap()->getByName( rPropertyName ); + SwSectionFmt *const pFmt = m_pImpl->GetSectionFmt(); + SfxItemPropertySimpleEntry const*const pEntry = + m_pImpl->m_rPropSet.getPropertyMap()->getByName(rPropertyName); if (!pEntry) - throw UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); + { + throw beans::UnknownPropertyException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) + + rPropertyName, + static_cast(this)); + } switch(pEntry->nWID) { @@ -1498,7 +1735,7 @@ Any SwXTextSection::getPropertyDefault( const OUString& rPropertyName ) aRet <<= OUString(); break; case WID_SECT_LINK : - aRet <<= SectionFileLink(); + aRet <<= text::SectionFileLink(); break; case WID_SECT_DDE_AUTOUPDATE: case WID_SECT_VISIBLE : @@ -1524,7 +1761,7 @@ Any SwXTextSection::getPropertyDefault( const OUString& rPropertyName ) default: if(pFmt && pEntry->nWID <= SFX_WHICH_MAX) { - SwDoc* pDoc = pFmt->GetDoc(); + SwDoc *const pDoc = pFmt->GetDoc(); const SfxPoolItem& rDefItem = pDoc->GetAttrPool().GetDefaultItem(pEntry->nWID); rDefItem.QueryValue(aRet, pEntry->nMemberId); @@ -1532,33 +1769,43 @@ Any SwXTextSection::getPropertyDefault( const OUString& rPropertyName ) } return aRet; } + /*-- 10.12.98 14:47:15--------------------------------------------------- -----------------------------------------------------------------------*/ -OUString SwXTextSection::getName(void) throw( uno::RuntimeException ) +OUString SAL_CALL SwXTextSection::getName() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - String sRet; - const SwSectionFmt* pFmt = GetFmt(); + + ::rtl::OUString sRet; + SwSectionFmt const*const pFmt = m_pImpl->GetSectionFmt(); if(pFmt) + { sRet = pFmt->GetSection()->GetName(); - else if(m_bIsDescriptor) - sRet = m_sName; + } + else if (m_pImpl->m_bIsDescriptor) + { + sRet = m_pImpl->m_sName; + } else + { throw uno::RuntimeException(); + } return sRet; } /*-- 10.12.98 14:47:16--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextSection::setName(const OUString& rName) throw( uno::RuntimeException ) +void SAL_CALL SwXTextSection::setName(const OUString& rName) +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwSectionFmt* pFmt = GetFmt(); + + SwSectionFmt *const pFmt = m_pImpl->GetSectionFmt(); if(pFmt) { SwSection aSection(CONTENT_SECTION, aEmptyStr); - SwSection* pSect = pFmt->GetSection(); + SwSection *const pSect = pFmt->GetSection(); aSection = *pSect; String sNewName(rName); aSection.SetName(sNewName); @@ -1568,9 +1815,13 @@ void SwXTextSection::setName(const OUString& rName) throw( uno::RuntimeException for( sal_uInt16 i = 0; i < rFmts.Count(); i++ ) { if(rFmts[i]->GetSection() == pSect) + { nApplyPos = i; + } else if(sNewName == rFmts[i]->GetSection()->GetName()) + { throw uno::RuntimeException(); + } } if(nApplyPos != USHRT_MAX) { @@ -1584,46 +1835,50 @@ void SwXTextSection::setName(const OUString& rName) throw( uno::RuntimeException } } } - else if(m_bIsDescriptor) - m_sName = String(rName); + else if (m_pImpl->m_bIsDescriptor) + { + m_pImpl->m_sName = rName; + } else + { throw uno::RuntimeException(); + } } /* -----------------02.11.99 11:30------------------- --------------------------------------------------*/ -OUString SwXTextSection::getImplementationName(void) throw( uno::RuntimeException ) +OUString SAL_CALL +SwXTextSection::getImplementationName() throw (uno::RuntimeException) { return C2U("SwXTextSection"); } + /* -----------------02.11.99 11:30------------------- --------------------------------------------------*/ -sal_Bool SwXTextSection::supportsService(const OUString& rServiceName) throw( uno::RuntimeException ) +static char const*const g_ServicesTextSection[] = { - return !rServiceName.compareToAscii("com.sun.star.text.TextSection") || - !rServiceName.compareToAscii("com.sun.star.document.LinkTarget") || - !rServiceName.compareToAscii("com.sun.star.text.TextContent"); -} -/* -----------------02.11.99 11:30------------------- + "com.sun.star.text.TextContent", + "com.sun.star.text.TextSection", + "com.sun.star.document.LinkTarget", +}; +static const size_t g_nServicesTextSection( + sizeof(g_ServicesTextSection)/sizeof(g_ServicesTextSection[0])); - --------------------------------------------------*/ -uno::Sequence< OUString > SwXTextSection::getSupportedServiceNames(void) throw( uno::RuntimeException ) +sal_Bool SAL_CALL SwXTextSection::supportsService(const OUString& rServiceName) +throw (uno::RuntimeException) { - uno::Sequence< OUString > aRet(3); - OUString* pArr = aRet.getArray(); - pArr[0] = C2U("com.sun.star.text.TextSection"); - pArr[1] = C2U("com.sun.star.document.LinkTarget"); - pArr[2] = C2U("com.sun.star.text.TextContent"); - return aRet; + return ::sw::SupportsServiceImpl( + g_nServicesTextSection, g_ServicesTextSection, rServiceName); } -/*-- 20.12.2005 10:27:33--------------------------------------------------- +/* -----------------02.11.99 11:30------------------- - -----------------------------------------------------------------------*/ -SwSectionFmt* SwXTextSection::GetFmt()const + --------------------------------------------------*/ +uno::Sequence< OUString > SAL_CALL +SwXTextSection::getSupportedServiceNames() throw (uno::RuntimeException) { - return m_pClient ? - const_cast(static_cast< const SwSectionFmt* >(m_pClient->GetRegisteredIn())) - : 0; + return ::sw::GetSupportedServiceNamesImpl( + g_nServicesTextSection, g_ServicesTextSection); } + diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index 8dadfc47cdf2..4b0a259f2120 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -674,7 +674,10 @@ void SwXText::insertTextContentBefore( throw lang::IllegalArgumentException(); sal_Bool bRet = sal_False; - SwXTextSection* pXSection = SwXTextSection::GetImplementation( xSuccessor ); + const uno::Reference xSuccTunnel(xSuccessor, + uno::UNO_QUERY); + SwXTextSection *const pXSection = + ::sw::UnoTunnelGetImplementation(xSuccTunnel); SwXTextTable* pXTable = SwXTextTable::GetImplementation(xSuccessor ); SwFrmFmt* pTableFmt = pXTable ? pXTable->GetFrmFmt() : 0; SwTxtNode * pTxtNode = 0; @@ -728,7 +731,10 @@ void SwXText::insertTextContentAfter( if(!pPara || !pPara->IsDescriptor() || !xPredecessor.is()) throw lang::IllegalArgumentException(); - SwXTextSection* pXSection = SwXTextSection::GetImplementation( xPredecessor ); + const uno::Reference xPredTunnel(xPredecessor, + uno::UNO_QUERY); + SwXTextSection *const pXSection = + ::sw::UnoTunnelGetImplementation(xPredTunnel); SwXTextTable* pXTable = SwXTextTable::GetImplementation(xPredecessor ); SwFrmFmt* pTableFmt = pXTable ? pXTable->GetFrmFmt() : 0; sal_Bool bRet = sal_False; @@ -779,7 +785,10 @@ void SwXText::removeTextContentBefore( } sal_Bool bRet = sal_False; - SwXTextSection* pXSection = SwXTextSection::GetImplementation( xSuccessor ); + const uno::Reference xSuccTunnel(xSuccessor, + uno::UNO_QUERY); + SwXTextSection *const pXSection = + ::sw::UnoTunnelGetImplementation(xSuccTunnel); SwXTextTable* pXTable = SwXTextTable::GetImplementation( xSuccessor ); SwFrmFmt* pTableFmt = pXTable ? pXTable->GetFrmFmt() : 0; if(pTableFmt && pTableFmt->GetDoc() == GetDoc()) @@ -826,7 +835,10 @@ void SwXText::removeTextContentAfter(const uno::Reference< text::XTextContent>& } sal_Bool bRet = sal_False; - SwXTextSection* pXSection = SwXTextSection::GetImplementation( xPredecessor ); + const uno::Reference xPredTunnel(xPredecessor, + uno::UNO_QUERY); + SwXTextSection *const pXSection = + ::sw::UnoTunnelGetImplementation(xPredTunnel); SwXTextTable* pXTable = SwXTextTable::GetImplementation(xPredecessor ); SwFrmFmt* pTableFmt = pXTable ? pXTable->GetFrmFmt() : 0; if(pTableFmt && pTableFmt->GetDoc() == GetDoc()) -- cgit From 30bfe9b171379f987c470761acf6735a8b48fe67 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 8 Jan 2010 17:13:51 +0100 Subject: swunolocking1: #i105557#: fix locking for SwXTextRanges: add Impl struct, and use UnoImplPtr to lock destructor. move all implementation details out of header, into Impl struct. use new XServiceInfo helpers. replace SvWeirdArray with STL vector. clean up the implementation a little. --- sw/inc/unotextrange.hxx | 33 ++--- sw/source/core/unocore/unoobj2.cxx | 285 ++++++++++++++++++++----------------- sw/source/ui/uno/unotxdoc.cxx | 5 +- sw/source/ui/uno/unotxvw.cxx | 20 +-- 4 files changed, 169 insertions(+), 174 deletions(-) (limited to 'sw') diff --git a/sw/inc/unotextrange.hxx b/sw/inc/unotextrange.hxx index a7d13daf4848..94d4996b4633 100644 --- a/sw/inc/unotextrange.hxx +++ b/sw/inc/unotextrange.hxx @@ -45,10 +45,9 @@ #include #include -#include - #include #include +#include class String; @@ -85,6 +84,13 @@ public: }; +namespace sw { + + void DeepCopyPaM(SwPaM const & rSource, SwPaM & rTarget); + +} // namespace sw + + typedef ::cppu::WeakImplHelper8 < ::com::sun::star::lang::XUnoTunnel , ::com::sun::star::lang::XServiceInfo @@ -300,9 +306,6 @@ public: /* -----------------15.05.98 08:29------------------- * * --------------------------------------------------*/ -typedef ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > * - XTextRangeRefPtr; -SV_DECL_PTRARR(XTextRangeArr, XTextRangeRefPtr, 4, 4) typedef ::cppu::WeakImplHelper3 < ::com::sun::star::lang::XUnoTunnel @@ -312,32 +315,20 @@ typedef ::cppu::WeakImplHelper3 class SwXTextRanges : public SwXTextRanges_Base - , public SwClient { private: - XTextRangeArr* pRangeArr; - ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > - xParentText; - XTextRangeArr* GetRangesArray(); - SwUnoCrsr* GetCrsr() const { return (SwUnoCrsr*)GetRegisteredIn(); } - -protected: + class Impl; + ::sw::UnoImplPtr m_pImpl; virtual ~SwXTextRanges(); public: - SwXTextRanges(); - SwXTextRanges(SwPaM* pCrsr); + SwXTextRanges(SwPaM *const pCrsr); - const SwUnoCrsr* GetCursor() const { - return (const SwUnoCrsr*)(GetRegisteredIn()); - } - - // SwClient - virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + const SwUnoCrsr* GetCursor() const; static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId(); diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index e3515d700d10..57c533833985 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -177,6 +177,29 @@ GetSupportedServiceNamesImpl( } // namespace sw +namespace sw { + +void DeepCopyPaM(SwPaM const & rSource, SwPaM & rTarget) +{ + rTarget = rSource; + + if (rSource.GetNext() != &rSource) + { + SwPaM *pPam = static_cast(rSource.GetNext()); + do + { + // create new PaM + SwPaM *const pNew = new SwPaM(*pPam); + // insert into ring + pNew->MoveTo(&rTarget); + pPam = static_cast(pPam->GetNext()); + } + while (pPam != &rSource); + } +} + +} // namespace sw + struct FrameDependSortListLess { bool operator() (FrameDependSortListEntry const& r1, @@ -1971,6 +1994,96 @@ void SwXTextRange::makeRedline( /****************************************************************** * SwXTextRanges ******************************************************************/ + +class SwXTextRanges::Impl + : public SwClient +{ + +public: + + ::std::vector< uno::Reference< text::XTextRange > > m_Ranges; + + Impl(SwPaM *const pPaM) + : SwClient( (pPaM) + ? pPaM->GetDoc()->CreateUnoCrsr(*pPaM->GetPoint()) + : 0 ) + { + if (pPaM) + { + ::sw::DeepCopyPaM(*pPaM, *GetCursor()); + } + MakeRanges(); + } + + ~Impl() { + // Impl owns the cursor; delete it here: SolarMutex is locked + delete GetRegisteredIn(); + } + + SwUnoCrsr * GetCursor() { + return static_cast( + const_cast(GetRegisteredIn())); + } + + void MakeRanges(); + + // SwClient + virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + +}; + +/*-- 10.12.98 13:57:02--------------------------------------------------- + + -----------------------------------------------------------------------*/ +void SwXTextRanges::Impl::Modify(SfxPoolItem *pOld, SfxPoolItem *pNew) +{ + ClientModify(this, pOld, pNew); +} + +/* -----------------10.12.98 14:25------------------- + * + * --------------------------------------------------*/ +void SwXTextRanges::Impl::MakeRanges() +{ + SwUnoCrsr *const pCursor = GetCursor(); + if (pCursor) + { + SwPaM *pTmpCursor = pCursor; + do { + const uno::Reference< text::XTextRange > xRange( + SwXTextRange::CreateTextRangeFromPosition( + pTmpCursor->GetDoc(), + *pTmpCursor->GetPoint(), pTmpCursor->GetMark())); + if (xRange.is()) + { + m_Ranges.push_back(xRange); + } + pTmpCursor = static_cast(pTmpCursor->GetNext()); + } + while (pTmpCursor != pCursor); + } +} + +const SwUnoCrsr* SwXTextRanges::GetCursor() const +{ + return m_pImpl->GetCursor(); +} + +/*-- 10.12.98 13:57:22--------------------------------------------------- + + -----------------------------------------------------------------------*/ +SwXTextRanges::SwXTextRanges(SwPaM *const pPaM) + : m_pImpl( new SwXTextRanges::Impl(pPaM) ) +{ +} + +/*-- 10.12.98 13:57:22--------------------------------------------------- + + -----------------------------------------------------------------------*/ +SwXTextRanges::~SwXTextRanges() +{ +} + /* -----------------------------13.03.00 12:15-------------------------------- ---------------------------------------------------------------------------*/ @@ -1982,188 +2095,98 @@ const uno::Sequence< sal_Int8 > & SwXTextRanges::getUnoTunnelId() /* -----------------------------10.03.00 18:04-------------------------------- ---------------------------------------------------------------------------*/ -sal_Int64 SAL_CALL SwXTextRanges::getSomething( const uno::Sequence< sal_Int8 >& rId ) - throw(uno::RuntimeException) +sal_Int64 SAL_CALL +SwXTextRanges::getSomething(const uno::Sequence< sal_Int8 >& rId) +throw (uno::RuntimeException) { - if( rId.getLength() == 16 - && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), - rId.getConstArray(), 16 ) ) - { - return sal::static_int_cast< sal_Int64 >( reinterpret_cast (this) ); - } - return 0; + return ::sw::UnoTunnelImpl(rId, this); } + /**************************************************************************** * Text positions * Bis zum ersten Zugriff auf eine TextPosition wird ein SwCursor gehalten, * danach wird ein Array mit uno::Reference< XTextPosition > angelegt * ****************************************************************************/ -SV_IMPL_PTRARR(XTextRangeArr, XTextRangeRefPtr); /* -----------------------------06.04.00 16:36-------------------------------- ---------------------------------------------------------------------------*/ -OUString SwXTextRanges::getImplementationName(void) throw( RuntimeException ) +OUString SAL_CALL +SwXTextRanges::getImplementationName() throw (uno::RuntimeException) { return C2U("SwXTextRanges"); } /* -----------------------------06.04.00 16:36-------------------------------- ---------------------------------------------------------------------------*/ -BOOL SwXTextRanges::supportsService(const OUString& rServiceName) throw( RuntimeException ) -{ - return C2U("com.sun.star.text.TextRanges") == rServiceName; -} -/* -----------------------------06.04.00 16:36-------------------------------- - - ---------------------------------------------------------------------------*/ -Sequence< OUString > SwXTextRanges::getSupportedServiceNames(void) throw( RuntimeException ) +static char const*const g_ServicesTextRanges[] = { - Sequence< OUString > aRet(1); - OUString* pArray = aRet.getArray(); - pArray[0] = C2U("com.sun.star.text.TextRanges"); - return aRet; -} -/*-- 10.12.98 13:57:20--------------------------------------------------- + "com.sun.star.text.TextRanges", +}; +static const size_t g_nServicesTextRanges( + sizeof(g_ServicesTextRanges)/sizeof(g_ServicesTextRanges[0])); - -----------------------------------------------------------------------*/ -SwXTextRanges::SwXTextRanges() : - pRangeArr(0) +sal_Bool SAL_CALL SwXTextRanges::supportsService(const OUString& rServiceName) +throw (uno::RuntimeException) { - + return ::sw::SupportsServiceImpl( + g_nServicesTextRanges, g_ServicesTextRanges, rServiceName); } -/*-- 10.12.98 13:57:22--------------------------------------------------- +/* -----------------------------06.04.00 16:36-------------------------------- - -----------------------------------------------------------------------*/ -SwXTextRanges::SwXTextRanges(SwPaM* pCrsr) : - pRangeArr(0) + ---------------------------------------------------------------------------*/ +uno::Sequence< OUString > SAL_CALL +SwXTextRanges::getSupportedServiceNames() throw (uno::RuntimeException) { - SwUnoCrsr* pUnoCrsr = pCrsr->GetDoc()->CreateUnoCrsr(*pCrsr->GetPoint()); - if(pCrsr->HasMark()) - { - pUnoCrsr->SetMark(); - *pUnoCrsr->GetMark() = *pCrsr->GetMark(); - } - if(pCrsr->GetNext() != pCrsr) - { - SwPaM *_pStartCrsr = (SwPaM *)pCrsr->GetNext(); - do - { - //neuen PaM erzeugen - SwPaM* pPaM = _pStartCrsr->HasMark() ? - new SwPaM(*_pStartCrsr->GetMark(), *_pStartCrsr->GetPoint()) : - new SwPaM(*_pStartCrsr->GetPoint()); - //und in den Ring einfuegen - pPaM->MoveTo(pUnoCrsr); - - } while( (_pStartCrsr=(SwPaM *)_pStartCrsr->GetNext()) != pCrsr ); - } - - pUnoCrsr->Add(this); + return ::sw::GetSupportedServiceNamesImpl( + g_nServicesTextRanges, g_ServicesTextRanges); } -/*-- 10.12.98 13:57:22--------------------------------------------------- - -----------------------------------------------------------------------*/ -SwXTextRanges::~SwXTextRanges() -{ - vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pCrsr = GetCrsr(); - delete pCrsr; - if(pRangeArr) - { - pRangeArr->DeleteAndDestroy(0, pRangeArr->Count()); - delete pRangeArr; - } -} /*-- 10.12.98 13:57:24--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Int32 SwXTextRanges::getCount(void) throw( uno::RuntimeException ) +sal_Int32 SAL_CALL SwXTextRanges::getCount() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - sal_Int32 nRet = 0; - SwUnoCrsr* pCrsr = GetCrsr(); - if(pCrsr) - { - SwPaM *pTmpCrsr = pCrsr; - do { - nRet++; - pTmpCrsr = static_cast(pTmpCrsr->GetNext()); - } while ( pTmpCrsr != pCrsr ); - } - else if(pRangeArr) - nRet = pRangeArr->Count(); - return nRet; + + return static_cast(m_pImpl->m_Ranges.size()); } /*-- 10.12.98 13:57:25--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Any SwXTextRanges::getByIndex(sal_Int32 nIndex) - throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException ) +uno::Any SAL_CALL SwXTextRanges::getByIndex(sal_Int32 nIndex) +throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, + uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< XTextRange > aRef; - XTextRangeArr* pArr = ((SwXTextRanges*)this)->GetRangesArray(); - if(pArr && 0 <= nIndex && nIndex < pArr->Count()) + + if ((nIndex < 0) || + (static_cast(nIndex) >= m_pImpl->m_Ranges.size())) { - XTextRangeRefPtr pRef = pArr->GetObject( USHORT( nIndex )); - aRef = *pRef; - } - else throw lang::IndexOutOfBoundsException(); - uno::Any aRet(&aRef, ::getCppuType((uno::Reference*)0)); - return aRet; + } + uno::Any ret; + ret <<= (m_pImpl->m_Ranges.at(nIndex)); + return ret; } + /*-- 10.12.98 13:57:25--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Type SwXTextRanges::getElementType(void) throw( uno::RuntimeException ) +uno::Type SAL_CALL +SwXTextRanges::getElementType() throw (uno::RuntimeException) { - return ::getCppuType((uno::Reference*)0); + return text::XTextRange::static_type(); } /*-- 10.12.98 13:57:26--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXTextRanges::hasElements(void) throw( uno::RuntimeException ) +sal_Bool SAL_CALL SwXTextRanges::hasElements() throw (uno::RuntimeException) { - vos::OGuard aGuard(Application::GetSolarMutex()); + // no mutex necessary: getCount() does locking return getCount() > 0; } -/* -----------------10.12.98 14:25------------------- - * - * --------------------------------------------------*/ -XTextRangeArr* SwXTextRanges::GetRangesArray() -{ - SwUnoCrsr* pCrsr = GetCrsr(); - if(!pRangeArr && pCrsr) - { - pRangeArr = new XTextRangeArr(); - SwPaM *pTmpCrsr = pCrsr; - do { - - uno::Reference< XTextRange >* pPtr = - new uno::Reference( - SwXTextRange::CreateTextRangeFromPosition( - pTmpCrsr->GetDoc(), - *pTmpCrsr->GetPoint(), pTmpCrsr->GetMark())); -// new uno::Reference( SwXTextRange::createTextRangeFromPaM(*pTmpCrsr, xParentText)); - if(pPtr->is()) - pRangeArr->Insert(pPtr, pRangeArr->Count()); - - pTmpCrsr = static_cast(pTmpCrsr->GetNext()); - } while ( pTmpCrsr != pCrsr ); - pCrsr->Remove( this ); - } - return pRangeArr; -} -/*-- 10.12.98 13:57:02--------------------------------------------------- - - -----------------------------------------------------------------------*/ -void SwXTextRanges::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew) -{ - ClientModify(this, pOld, pNew); -} /* -----------------11.12.98 10:07------------------- * diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index ca29279c132b..22d683a0f29d 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -971,10 +971,7 @@ Reference< XIndexAccess > if(!pResultCrsr) throw RuntimeException(); Reference< XIndexAccess > xRet; - if(nResult) - xRet = new SwXTextRanges(pResultCrsr); - else - xRet = new SwXTextRanges(); + xRet = new SwXTextRanges( (nResult) ? pResultCrsr : 0 ); delete pResultCrsr; return xRet; } diff --git a/sw/source/ui/uno/unotxvw.cxx b/sw/source/ui/uno/unotxvw.cxx index 35a4c5a2f92c..6df8553be298 100644 --- a/sw/source/ui/uno/unotxvw.cxx +++ b/sw/source/ui/uno/unotxvw.cxx @@ -108,24 +108,8 @@ SV_IMPL_PTRARR( SelectionChangeListenerArr, XSelectionChangeListenerPtr ); * --------------------------------------------------*/ SwPaM* lcl_createPamCopy(const SwPaM& rPam) { - SwPaM* pRet = new SwPaM(*rPam.GetPoint()); - if(rPam.HasMark()) - { - pRet->SetMark(); - *pRet->GetMark() = *rPam.GetMark(); - } - if(rPam.GetNext() != (const Ring*)&rPam) - { - SwPaM *_pStartCrsr = (SwPaM *)rPam.GetNext(); - do - { - //neuen PaM erzeugen - SwPaM* pPaM = new SwPaM(*_pStartCrsr); - //und in den Ring einfuegen - pPaM->MoveTo(pRet); - - } while( (_pStartCrsr=(SwPaM *)_pStartCrsr->GetNext()) != rPam.GetNext() ); - } + SwPaM *const pRet = new SwPaM(*rPam.GetPoint()); + ::sw::DeepCopyPaM(rPam, *pRet); return pRet; } /****************************************************************** -- cgit From 220dc1e003f4a26a2d92b6c9bb2464a9b9d63b0e Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 8 Jan 2010 17:13:52 +0100 Subject: swunolocking1: #i105557#: SwXTextRange: try to hide the implementation detail that SwXTextRange registers at a bookmark from its clients by using SwXTextRange::GetPositions(). --- sw/inc/unotext.hxx | 5 +- sw/inc/unotextrange.hxx | 6 +- sw/source/core/inc/unometa.hxx | 4 +- sw/source/core/unocore/unoobj.cxx | 87 ++++++++---------------- sw/source/core/unocore/unoobj2.cxx | 8 +-- sw/source/core/unocore/unorefmk.cxx | 63 +++++------------- sw/source/core/unocore/unotext.cxx | 128 ++++++++++++++---------------------- sw/source/ui/uno/unoatxt.cxx | 48 ++++++-------- sw/source/ui/uno/unotxvw.cxx | 9 ++- 9 files changed, 130 insertions(+), 228 deletions(-) (limited to 'sw') diff --git a/sw/inc/unotext.hxx b/sw/inc/unotext.hxx index 499e0620dae4..97a45ece73cf 100644 --- a/sw/inc/unotext.hxx +++ b/sw/inc/unotext.hxx @@ -93,7 +93,7 @@ private: virtual void PrepareForAttach( ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xRange, - SwXTextRange const * const pRange, SwPaM const * const pPam); + SwPaM const & rPam); protected: @@ -136,8 +136,7 @@ public: throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); virtual bool CheckForOwnMemberMeta( - const SwXTextRange* const pRange, - const SwPaM* const pPam, bool bAbsorb) + const SwPaM & rPam, const bool bAbsorb) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); diff --git a/sw/inc/unotextrange.hxx b/sw/inc/unotextrange.hxx index 94d4996b4633..079296d2a441 100644 --- a/sw/inc/unotextrange.hxx +++ b/sw/inc/unotextrange.hxx @@ -130,7 +130,9 @@ private: xParentText; ::sw::mark::IMark* pMark; - void _CreateNewBookmark(SwPaM& rPam); + const ::sw::mark::IMark * GetBookmark() const + { return pMark; } + void SetPositions(SwPaM const& rPam); //TODO: new exception type for protected content void DeleteAndInsert(const String& rText, const bool bForceExpandHints) throw (::com::sun::star::uno::RuntimeException); @@ -153,8 +155,6 @@ public: { return pDoc; } SwDoc* GetDoc() { return pDoc; } - const ::sw::mark::IMark * GetBookmark() const - { return pMark; } static BOOL XTextRangeToSwPaM(SwUnoInternalPaM& rToFill, const ::com::sun::star::uno::Reference< diff --git a/sw/source/core/inc/unometa.hxx b/sw/source/core/inc/unometa.hxx index 5568aa88b52e..39f81caa902a 100755 --- a/sw/source/core/inc/unometa.hxx +++ b/sw/source/core/inc/unometa.hxx @@ -52,7 +52,6 @@ typedef ::std::deque< ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > > TextRangeList_t; -class SwXTextRange; class SwPaM; class SwTxtNode; @@ -117,8 +116,7 @@ public: ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > GetParentText() const; - bool CheckForOwnMemberMeta(const SwXTextRange* const pRange, - const SwPaM* const pPam, bool bAbsorb) + bool CheckForOwnMemberMeta(const SwPaM & rPam, const bool bAbsorb) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx index eb89201cf978..b48451b90cf9 100644 --- a/sw/source/core/unocore/unoobj.cxx +++ b/sw/source/core/unocore/unoobj.cxx @@ -1181,17 +1181,26 @@ void SwXTextCursor::gotoRange(const uno::Reference< XTextRange > & xRange, sal_B const SwStartNode* pOwnStartNode = pOwnCursor->GetNode()-> FindSttNodeByType(eSearchNodeType); - const SwNode* pSrcNode = 0; - if(pCursor && pCursor->GetPaM()) + SwPaM aPam(GetDoc()->GetNodes()); + const SwPaM * pPam(0); + if (pCursor) { - pSrcNode = pCursor->GetPaM()->GetNode(); + pPam = pCursor->GetPaM(); } - else if(pRange && pRange->GetBookmark()) + else if (pRange) { - ::sw::mark::IMark const * const pBkmk = pRange->GetBookmark(); - pSrcNode = &pBkmk->GetMarkPos().nNode.GetNode(); + if (pRange->GetPositions(aPam)) + { + pPam = & aPam; + } + } + + if (!pPam) + { + throw uno::RuntimeException(); } - const SwStartNode* pTmp = pSrcNode ? pSrcNode->FindSttNodeByType(eSearchNodeType) : 0; + const SwStartNode* pTmp = + pPam->GetNode()->FindSttNodeByType(eSearchNodeType); //SectionNodes ueberspringen while(pTmp && pTmp->IsSectionNode()) @@ -1209,16 +1218,9 @@ void SwXTextCursor::gotoRange(const uno::Reference< XTextRange > & xRange, sal_B if (CURSOR_META == eType) { - const SwPosition & rPoint( (pRange) - ? pRange->GetBookmark()->GetMarkPos() - : *pCursor->GetPaM()->GetPoint() ); - const SwPosition & rMark ( (pRange) - ? ((pRange->GetBookmark()->IsExpanded()) - ? pRange->GetBookmark()->GetOtherMarkPos() : rPoint) - : *pCursor->GetPaM()->GetMark() ); - SwPaM aPam(rPoint, rMark); + SwPaM CopyPam(*pPam->GetMark(), *pPam->GetPoint()); const bool bNotForced( - lcl_ForceIntoMeta(aPam, xParentText, META_CHECK_BOTH) ); + lcl_ForceIntoMeta(CopyPam, xParentText, META_CHECK_BOTH) ); if (!bNotForced) { throw uno::RuntimeException( @@ -1241,26 +1243,9 @@ void SwXTextCursor::gotoRange(const uno::Reference< XTextRange > & xRange, sal_B aOwnLeft = aOwnRight; aOwnRight = aTmp; } - SwPosition* pParamLeft; - SwPosition* pParamRight; - if(pCursor) - { - const SwPaM* pTmp2 = pCursor->GetPaM(); - pParamLeft = new SwPosition(*pTmp2->GetPoint()); - pParamRight = new SwPosition(pTmp2->HasMark() ? *pTmp2->GetMark() : *pParamLeft); - } - else - { - ::sw::mark::IMark const * const pBkmk = pRange->GetBookmark(); - pParamLeft = new SwPosition(pBkmk->GetMarkPos()); - pParamRight = new SwPosition(pBkmk->IsExpanded() ? pBkmk->GetOtherMarkPos() : *pParamLeft); - } - if(*pParamRight < *pParamLeft) - { - SwPosition* pTmp2 = pParamLeft; - pParamLeft = pParamRight; - pParamRight = pTmp2; - } + SwPosition const* pParamLeft = pPam->Start(); + SwPosition const* pParamRight = pPam->End(); + // jetzt sind vier SwPositions da, zwei davon werden gebraucht, also welche? if(aOwnRight > *pParamRight) *pOwnCursor->GetPoint() = aOwnRight; @@ -1271,35 +1256,19 @@ void SwXTextCursor::gotoRange(const uno::Reference< XTextRange > & xRange, sal_B *pOwnCursor->GetMark() = aOwnLeft; else *pOwnCursor->GetMark() = *pParamLeft; - delete pParamLeft; - delete pParamRight; } else { - //der Cursor soll dem uebergebenen Range entsprechen - if(pCursor) + // cursor should be the given range + *pOwnCursor->GetPoint() = *pPam->GetPoint(); + if (pPam->HasMark()) { - const SwPaM* pTmp2 = pCursor->GetPaM(); - *pOwnCursor->GetPoint() = *pTmp2->GetPoint(); - if(pTmp2->HasMark()) - { - pOwnCursor->SetMark(); - *pOwnCursor->GetMark() = *pTmp2->GetMark(); - } - else - pOwnCursor->DeleteMark(); + pOwnCursor->SetMark(); + *pOwnCursor->GetMark() = *pPam->GetMark(); } else { - ::sw::mark::IMark const * const pBkmk = pRange->GetBookmark(); - *pOwnCursor->GetPoint() = pBkmk->GetMarkPos(); - if(pBkmk->IsExpanded()) - { - pOwnCursor->SetMark(); - *pOwnCursor->GetMark() = pBkmk->GetOtherMarkPos(); - } - else - pOwnCursor->DeleteMark(); + pOwnCursor->DeleteMark(); } } } @@ -1923,7 +1892,7 @@ void SwXTextCursor::setString(const OUString& aString) throw( uno::RuntimeExcept const bool bForceExpandHints( (CURSOR_META != eType) ? false : dynamic_cast(xParentText.get())->CheckForOwnMemberMeta( - 0, GetPaM(), true) ); + *GetPaM(), true) ); DeleteAndInsert(aString, bForceExpandHints); } /* -----------------------------03.05.00 12:56-------------------------------- diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index 57c533833985..6ca031d041ba 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -1377,7 +1377,7 @@ SwXTextRange::SwXTextRange(SwPaM& rPam, xParentText(rxParent), pMark(NULL) { - _CreateNewBookmark(rPam); + SetPositions(rPam); } SwXTextRange::SwXTextRange(SwFrmFmt& rTblFmt) : @@ -1394,7 +1394,7 @@ SwXTextRange::SwXTextRange(SwFrmFmt& rTblFmt) : SwPosition aPosition( *pTblNode ); SwPaM aPam( aPosition ); - _CreateNewBookmark( aPam ); + SetPositions( aPam ); } SwXTextRange::~SwXTextRange() @@ -1405,7 +1405,7 @@ SwXTextRange::~SwXTextRange() pDoc->getIDocumentMarkAccess()->deleteMark(pBkmk); } -void SwXTextRange::_CreateNewBookmark(SwPaM& rPam) +void SwXTextRange::SetPositions(const SwPaM& rPam) { IDocumentMarkAccess* const pMarkAccess = pDoc->getIDocumentMarkAccess(); @@ -1452,7 +1452,7 @@ void SwXTextRange::DeleteAndInsert( SwXTextCursor::SelectPam(aNewCrsr, sal_True); aNewCrsr.Left(rText.Len(), CRSR_SKIP_CHARS, FALSE, FALSE); } - _CreateNewBookmark(aNewCrsr); + SetPositions(aNewCrsr); pDoc->EndUndo(UNDO_INSERT, NULL); } } diff --git a/sw/source/core/unocore/unorefmk.cxx b/sw/source/core/unocore/unorefmk.cxx index 39e93acd19dc..68516a923eb7 100644 --- a/sw/source/core/unocore/unorefmk.cxx +++ b/sw/source/core/unocore/unorefmk.cxx @@ -586,12 +586,10 @@ private: SwXMeta & m_rMeta; virtual void PrepareForAttach(uno::Reference< text::XTextRange > & xRange, - const SwXTextRange* const pRange, const SwPaM * const pPam); + const SwPaM & rPam); - virtual bool CheckForOwnMemberMeta(const SwXTextRange* const pRange, - const SwPaM* const pPam, bool bAbsorb) - throw (::com::sun::star::lang::IllegalArgumentException, - ::com::sun::star::uno::RuntimeException); + virtual bool CheckForOwnMemberMeta(const SwPaM & rPam, const bool bAbsorb) + throw (lang::IllegalArgumentException, uno::RuntimeException); protected: virtual const SwStartNode *GetStartNode() const; @@ -637,41 +635,18 @@ const SwStartNode *SwXMetaText::GetStartNode() const } void SwXMetaText::PrepareForAttach( uno::Reference & xRange, - const SwXTextRange* const pRange, const SwPaM * const pPam) + const SwPaM & rPam) { - SwPosition const* pPoint(0); - SwPosition const* pMark (0); - if (pRange) - { - ::sw::mark::IMark const& rIMark(*pRange->GetBookmark()); - pMark = &rIMark.GetMarkPos(); - if (rIMark.IsExpanded()) - { - pMark = &rIMark.GetOtherMarkPos(); - } - } - else if (pPam) - { - pPoint = pPam->GetPoint(); - if (pPam->HasMark()) - { - pMark = pPam->GetMark(); - } - } // create a new cursor to prevent modifying SwXTextRange - if (pPoint) - { - xRange = static_cast( - new SwXTextCursor(&m_rMeta, *pPoint, CURSOR_META, GetDoc(), pMark)); - } + xRange = static_cast( + new SwXTextCursor(&m_rMeta, *rPam.GetPoint(), CURSOR_META, + GetDoc(), (rPam.HasMark()) ? rPam.GetMark() : 0)); } -bool SwXMetaText::CheckForOwnMemberMeta(const SwXTextRange* const pRange, - const SwPaM* const pPam, bool bAbsorb) - throw (::com::sun::star::lang::IllegalArgumentException, - ::com::sun::star::uno::RuntimeException) +bool SwXMetaText::CheckForOwnMemberMeta(const SwPaM & rPam, const bool bAbsorb) + throw (lang::IllegalArgumentException, uno::RuntimeException) { - return m_rMeta.CheckForOwnMemberMeta(pRange, pPam, bAbsorb); + return m_rMeta.CheckForOwnMemberMeta(rPam, bAbsorb); } uno::Reference< text::XTextCursor > SwXMetaText::createCursor() @@ -884,11 +859,9 @@ bool SwXMeta::SetContentRange( return false; } -bool SwXMeta::CheckForOwnMemberMeta(const SwXTextRange* const pRange, - const SwPaM* const pPam, bool bAbsorb) +bool SwXMeta::CheckForOwnMemberMeta(const SwPaM & rPam, const bool bAbsorb) throw (lang::IllegalArgumentException, uno::RuntimeException) { - ASSERT((pPam && !pRange) || (!pPam && pRange), "ERROR: pam xor range"); SwTxtNode * pTxtNode; xub_StrLen nMetaStart; xub_StrLen nMetaEnd; @@ -896,9 +869,8 @@ bool SwXMeta::CheckForOwnMemberMeta(const SwXTextRange* const pRange, ASSERT(bSuccess, "no pam?"); if (!bSuccess) throw lang::DisposedException(); - SwPosition const * const pStartPos( (pPam) - ? pPam->Start() - : &pRange->GetBookmark()->GetMarkStart() ); + + SwPosition const * const pStartPos( rPam.Start() ); if (&pStartPos->nNode.GetNode() != pTxtNode) { throw lang::IllegalArgumentException( @@ -921,14 +893,9 @@ bool SwXMeta::CheckForOwnMemberMeta(const SwXTextRange* const pRange, { bForceExpandHints = true; } - const bool bHasEnd( (pPam) - ? pPam->HasMark() - : pRange->GetBookmark()->IsExpanded()); - if (bHasEnd && bAbsorb) + if (rPam.HasMark() && bAbsorb) { - SwPosition const * const pEndPos( (pPam) - ? pPam->End() - : &pRange->GetBookmark()->GetMarkEnd() ); + SwPosition const * const pEndPos( rPam.End() ); if (&pEndPos->nNode.GetNode() != pTxtNode) { throw lang::IllegalArgumentException( diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index 4b0a259f2120..7c0fe114b489 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -91,16 +91,13 @@ const sal_Char cInvalidObject[] = "this object is invalid"; -----------------------------------------------------------------------*/ -void SwXText::PrepareForAttach( ::com::sun::star::uno::Reference< - ::com::sun::star::text::XTextRange > &, - const SwXTextRange* const, const SwPaM * const) +void +SwXText::PrepareForAttach(uno::Reference< text::XTextRange > &, const SwPaM &) { } -bool SwXText::CheckForOwnMemberMeta(const SwXTextRange* const, - const SwPaM* const, bool) - throw (::com::sun::star::lang::IllegalArgumentException, - ::com::sun::star::uno::RuntimeException) +bool SwXText::CheckForOwnMemberMeta(const SwPaM &, const bool) + throw (lang::IllegalArgumentException, uno::RuntimeException) { ASSERT(CURSOR_META != eCrsrType, "should not be called!"); return false; @@ -285,35 +282,43 @@ void SwXText::insertString(const uno::Reference< text::XTextRange >& xTextRange, if(pRange && pRange->GetDoc() == GetDoc() || pCursor && pCursor->GetDoc() == GetDoc()) { - const SwStartNode* pOwnStartNode = GetStartNode(); - if(pCursor) + const SwStartNode *const pOwnStartNode = GetStartNode(); + SwPaM aPam(GetDoc()->GetNodes()); + const SwPaM * pPam(0); + if (pCursor) { - const SwStartNode* pTmp = pCursor->GetPaM()->GetNode()->StartOfSectionNode(); - while(pTmp && pTmp->IsSectionNode()) - { - pTmp = pTmp->StartOfSectionNode(); - } - if( !pOwnStartNode || pOwnStartNode != pTmp) + pPam = pCursor->GetPaM(); + } + else // pRange + { + if (pRange->GetPositions(aPam)) { - throw uno::RuntimeException(); + pPam = &aPam; } } - else //dann pRange + if (!pPam) { - ::sw::mark::IMark const * const pBkmk = pRange->GetBookmark(); - const SwStartNode* pTmp = pBkmk->GetMarkPos().nNode.GetNode().StartOfSectionNode(); - while(pTmp && pTmp->IsSectionNode()) + throw uno::RuntimeException(); + } + else + { + const SwStartNode* pTmp(pPam->GetNode()->StartOfSectionNode()); + while (pTmp && pTmp->IsSectionNode()) + { pTmp = pTmp->StartOfSectionNode(); - if(!pOwnStartNode || pOwnStartNode != pTmp) + } + if (!pOwnStartNode || (pOwnStartNode != pTmp)) + { throw uno::RuntimeException(); + } } + bool bForceExpandHints( false ); if (CURSOR_META == eCrsrType) { try { - bForceExpandHints = CheckForOwnMemberMeta( - pRange, (pCursor) ? pCursor->GetPaM() : 0, bAbsorb); + bForceExpandHints = CheckForOwnMemberMeta(*pPam, bAbsorb); } catch (lang::IllegalArgumentException & iae) { @@ -348,10 +353,7 @@ void SwXText::insertString(const uno::Reference< text::XTextRange >& xTextRange, //hier wird ein PaM angelegt, der vor dem Parameter-PaM liegt, damit der //Text davor eingefuegt wird UnoActionContext aContext(GetDoc()); - const SwPosition* pPos = pCursor - ? pCursor->GetPaM()->Start() - : &pRange->GetBookmark()->GetMarkStart(); - SwPaM aInsertPam(*pPos); + SwPaM aInsertPam(*pPam->Start()); const sal_Bool bGroupUndo = GetDoc()->DoesGroupUndo(); GetDoc()->DoGroupUndo(sal_False); @@ -382,8 +384,7 @@ void SwXText::insertControlCharacter(const uno::Reference< text::XTextRange > & SwUnoInternalPaM aPam(*GetDoc()); if(SwXTextRange::XTextRangeToSwPaM(aPam, xTextRange)) { - const bool bForceExpandHints( - CheckForOwnMemberMeta( 0, &aPam, bAbsorb) ); + const bool bForceExpandHints(CheckForOwnMemberMeta(aPam, bAbsorb)); const enum IDocumentContentOperations::InsertFlags nInsertFlags = (bForceExpandHints) @@ -424,7 +425,7 @@ void SwXText::insertControlCharacter(const uno::Reference< text::XTextRange > & } if(pRange) { - pRange->_CreateNewBookmark(aTmp); + pRange->SetPositions(aTmp); } else if(pCursor) { @@ -462,7 +463,9 @@ void SwXText::insertControlCharacter(const uno::Reference< text::XTextRange > & aCrsr.Left(1, CRSR_SKIP_CHARS, FALSE, FALSE); //hier muss der uebergebene PaM umgesetzt werden: if(pRange) - pRange->_CreateNewBookmark(aCrsr); + { + pRange->SetPositions(aCrsr); + } else { SwPaM* pUnoCrsr = pCursor->GetPaM(); @@ -541,33 +544,8 @@ void SwXText::insertTextContent(const uno::Reference< text::XTextRange > & xRang ; } - const SwNode* pSrcNode = 0; - if(pCursor && pCursor->GetPaM()) - { - pSrcNode = pCursor->GetPaM()->GetNode(); - } - else if (pRange && pRange->GetBookmark()) - { - ::sw::mark::IMark const * const pBkmk = pRange->GetBookmark(); - pSrcNode = &pBkmk->GetMarkPos().nNode.GetNode(); - } - else if (pPortion && pPortion->GetCursor()) - { - pSrcNode = pPortion->GetCursor()->GetNode(); - } - else if (pText) - { - uno::Reference xTextCursor = pText->createCursor(); - xTextCursor->gotoEnd(sal_True); - uno::Reference xCrsrTunnel( xTextCursor, uno::UNO_QUERY ); - pCursor = reinterpret_cast< OTextCursorHelper * >( - sal::static_int_cast< sal_IntPtr >( xCrsrTunnel->getSomething( OTextCursorHelper::getUnoTunnelId()) )); - pSrcNode = pCursor->GetPaM()->GetNode(); - } - else - throw lang::IllegalArgumentException(); - - const SwStartNode* pTmp = pSrcNode->FindSttNodeByType(eSearchNodeType); + const SwStartNode* pTmp = + aPam.GetNode()->FindSttNodeByType(eSearchNodeType); //SectionNodes ueberspringen while(pTmp && pTmp->IsSectionNode()) @@ -587,8 +565,7 @@ void SwXText::insertTextContent(const uno::Reference< text::XTextRange > & xRang throw aRunException; } - const bool bForceExpandHints( CheckForOwnMemberMeta( - pRange, (pCursor) ? pCursor->GetPaM() : 0, bAbsorb) ); + const bool bForceExpandHints(CheckForOwnMemberMeta(aPam, bAbsorb)); // Sonderbehandlung fuer Contents, die den Range nicht ersetzen, sonder darueber gelegt werden // Bookmarks, IndexEntry @@ -627,8 +604,7 @@ void SwXText::insertTextContent(const uno::Reference< text::XTextRange > & xRang if (bForceExpandHints) { // if necessary, replace xTempRange with a new SwXTextCursor - PrepareForAttach(xTempRange, pRange, - (pCursor) ? pCursor->GetPaM() : 0); + PrepareForAttach(xTempRange, aPam); } xContent->attach(xTempRange); } @@ -1047,13 +1023,19 @@ sal_Bool SwXText::CheckForOwnMember( } const SwNode* pSrcNode; - if(pCursor) + if (pCursor) + { pSrcNode = pCursor->GetPaM()->GetNode(); - else //dann pRange + } + else // pRange { - ::sw::mark::IMark const * const pBkmk = pRange->GetBookmark(); - pSrcNode = &pBkmk->GetMarkPos().nNode.GetNode(); + SwPaM aPam(pRange->GetDoc()->GetNodes().GetEndOfContent()); + if (pRange->GetPositions(aPam)) + { + pSrcNode = aPam.GetNode(); + } } + if (!pSrcNode) { return sal_False; } const SwStartNode* pTmp = pSrcNode->FindSttNodeByType(eSearchNodeType); //SectionNodes ueberspringen @@ -1107,18 +1089,8 @@ sal_Int16 SwXText::ComparePositions( if(CheckForOwnMember(pRange1, pCursor1) && CheckForOwnMember( pRange2, pCursor2)) { - const SwPosition *pStart1 = 0; - const SwPosition *pStart2 = 0; - - if(pRange1) - pStart1 = pRange1->GetBookmark() ? &(pRange1->GetBookmark()->GetMarkStart()) : 0; - else - pStart1 = pCursor1->GetPaM() ? pCursor1->GetPaM()->Start() : 0; - - if(pRange2) - pStart2 = pRange2->GetBookmark() ? &(pRange2->GetBookmark()->GetMarkStart()) : 0; - else - pStart2 = pCursor2->GetPaM() ? pCursor2->GetPaM()->Start() : 0; + SwPosition const*const pStart1 = aPam1.Start(); + SwPosition const*const pStart2 = aPam2.Start(); if(pStart1 && pStart2) { diff --git a/sw/source/ui/uno/unoatxt.cxx b/sw/source/ui/uno/unoatxt.cxx index 87d27b15a76b..d3e03aa307a6 100644 --- a/sw/source/ui/uno/unoatxt.cxx +++ b/sw/source/ui/uno/unoatxt.cxx @@ -411,25 +411,25 @@ sal_Bool lcl_CopySelToDoc( SwDoc* pInsDoc, OTextCursorHelper* pxCursor, SwXTextR SwCntntNode * pNd = aIdx.GetNode().GetCntntNode(); SwPosition aPos( aIdx, SwIndex( pNd, pNd->Len() )); - sal_Bool bRet = sal_False; + bool bRet = false; pInsDoc->LockExpFlds(); { + SwDoc *const pDoc((pxCursor) ? pxCursor->GetDoc() : pxRange->GetDoc()); + SwPaM aPam(pDoc->GetNodes()); + SwPaM * pPam(0); if(pxCursor) { - SwPaM* pUnoCrsr = pxCursor->GetPaM(); - bRet = pxCursor->GetDoc()->CopyRange( *pUnoCrsr, aPos, false ) - || bRet; + pPam = pxCursor->GetPaM(); } else { - const ::sw::mark::IMark* const pBkmk = pxRange->GetBookmark(); - if(pBkmk && pBkmk->IsExpanded()) + if (pxRange->GetPositions(aPam)) { - SwPaM aTmp(pBkmk->GetOtherMarkPos(), pBkmk->GetMarkPos()); - bRet = pxRange->GetDoc()->CopyRange(aTmp, aPos, false) - || bRet; + pPam = & aPam; } } + if (!pPam) { return false; } + bRet = pDoc->CopyRange( *pPam, aPos, false ) || bRet; } pInsDoc->UnlockExpFlds(); @@ -1113,7 +1113,7 @@ void SwXAutoTextEntry::applyTo(const uno::Reference< text::XTextRange > & xTextR } SwDoc* pDoc = 0; - if ( pRange && pRange->GetBookmark()) + if (pRange) pDoc = pRange->GetDoc(); else if ( pCursor ) pDoc = pCursor->GetDoc(); @@ -1131,29 +1131,23 @@ void SwXAutoTextEntry::applyTo(const uno::Reference< text::XTextRange > & xTextR if(!pDoc) throw uno::RuntimeException(); - SwPaM* pInsertPaM = 0; - if(pRange) + + SwPaM InsertPaM(pDoc->GetNodes()); + if (pRange) { - const ::sw::mark::IMark* const pBkmk = pRange->GetBookmark(); - if(pBkmk->IsExpanded()) - pInsertPaM = new SwPaM(pBkmk->GetOtherMarkPos(), pBkmk->GetMarkPos()); - else - pInsertPaM = new SwPaM(pBkmk->GetMarkPos()); + if (!pRange->GetPositions(InsertPaM)) + { + throw uno::RuntimeException(); + } } else { - SwPaM* pCrsr = pCursor->GetPaM(); - if(pCrsr->HasMark()) - pInsertPaM = new SwPaM(*pCrsr->GetPoint(), *pCrsr->GetMark()); - else - pInsertPaM = new SwPaM(*pCrsr->GetPoint()); + InsertPaM = *pCursor->GetPaM(); } - SwTextBlocks* pBlock = pGlossaries->GetGroupDoc(sGroupName); - sal_Bool bResult = pBlock && !pBlock->GetError() && - pDoc->InsertGlossary( *pBlock, sEntryName, *pInsertPaM); - delete pBlock; - delete pInsertPaM; + ::std::auto_ptr pBlock(pGlossaries->GetGroupDoc(sGroupName)); + const bool bResult = pBlock.get() && !pBlock->GetError() + && pDoc->InsertGlossary( *pBlock, sEntryName, InsertPaM); if(!bResult) throw uno::RuntimeException(); diff --git a/sw/source/ui/uno/unotxvw.cxx b/sw/source/ui/uno/unotxvw.cxx index 6df8553be298..9e637ca58260 100644 --- a/sw/source/ui/uno/unotxvw.cxx +++ b/sw/source/ui/uno/unotxvw.cxx @@ -1418,10 +1418,13 @@ void SwXTextViewCursor::gotoRange( { pSrcNode = pCursor->GetPaM()->GetNode(); } - else if(pRange && pRange->GetBookmark()) + else if (pRange) { - const ::sw::mark::IMark* const pBkmk = pRange->GetBookmark(); - pSrcNode = &(pBkmk->GetMarkPos().nNode.GetNode()); + SwPaM aPam(pRange->GetDoc()->GetNodes()); + if (pRange->GetPositions(aPam)) + { + pSrcNode = aPam.GetNode(); + } } else if (pPara && pPara->GetTxtNode()) { -- cgit From 1f8d8b1e17487074cf77595ab9d9569858e6f04e Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 8 Jan 2010 17:13:52 +0100 Subject: swunolocking1: #i105557#: fix locking for SwXTextRange: add Impl struct, and use UnoImplPtr to lock destructor. move all implementation details out of header, into Impl struct. use new XUnoTunnel and XServiceInfo helpers. clean up the implementation a little. --- sw/inc/unotextrange.hxx | 54 +--- sw/source/core/unocore/unoobj2.cxx | 641 ++++++++++++++++++++++--------------- sw/source/core/unocore/unotext.cxx | 8 +- 3 files changed, 395 insertions(+), 308 deletions(-) (limited to 'sw') diff --git a/sw/inc/unotextrange.hxx b/sw/inc/unotextrange.hxx index 079296d2a441..8b34ce7f94c1 100644 --- a/sw/inc/unotextrange.hxx +++ b/sw/inc/unotextrange.hxx @@ -45,26 +45,15 @@ #include #include -#include #include #include -class String; -class SfxItemPropertySet; class SwDoc; -class SwStartNode; struct SwPosition; class SwPaM; class SwUnoCrsr; class SwFrmFmt; -class SwTableBox; - -namespace sw { - namespace mark { - class IMark; - } -} /* -----------------29.04.98 07:35------------------- * @@ -104,13 +93,15 @@ typedef ::cppu::WeakImplHelper8 class SW_DLLPUBLIC SwXTextRange : public SwXTextRange_Base - , private SwClient { private: friend class SwXText; + class Impl; + ::sw::UnoImplPtr m_pImpl; + enum RangePosition { RANGE_IN_TEXT, // "ordinary" ::com::sun::star::text::TextRange @@ -118,26 +109,14 @@ private: RANGE_IN_CELL, // position created with a cell that has no uno object RANGE_IS_TABLE, // anchor of a table RANGE_INVALID // created by NewInstance - } eRangePosition; - - SwDoc* pDoc; - SwTableBox* pBox; - const SwStartNode* pBoxStartNode; - SwDepend aObjectDepend; // register at format of table or frame - const SfxItemPropertySet* m_pPropSet; - //SwDepend aFrameDepend; - ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > - xParentText; - ::sw::mark::IMark* pMark; - - const ::sw::mark::IMark * GetBookmark() const - { return pMark; } + }; + void SetPositions(SwPaM const& rPam); //TODO: new exception type for protected content - void DeleteAndInsert(const String& rText, const bool bForceExpandHints) + void DeleteAndInsert( + const ::rtl::OUString& rText, const bool bForceExpandHints) throw (::com::sun::star::uno::RuntimeException); - -protected: + void Invalidate(); virtual ~SwXTextRange(); @@ -146,31 +125,26 @@ public: SwXTextRange(SwPaM& rPam, const ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > & xParent, - enum RangePosition eRange = RANGE_IN_TEXT); + const enum RangePosition eRange = RANGE_IN_TEXT); // only for RANGE_IS_TABLE SwXTextRange(SwFrmFmt& rTblFmt); - BOOL GetPositions(SwPaM& rToFill) const; - const SwDoc* GetDoc() const - { return pDoc; } - SwDoc* GetDoc() - { return pDoc; } + const SwDoc* GetDoc() const; + SwDoc* GetDoc(); + bool GetPositions(SwPaM & rToFill) const; static BOOL XTextRangeToSwPaM(SwUnoInternalPaM& rToFill, const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xTextRange); + static ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > CreateTextRangeFromPosition( SwDoc* pDoc, const SwPosition& rPos, const SwPosition* pMark); + static ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > CreateParentXText(SwDoc* pDoc, const SwPosition& rPos); - TYPEINFO(); - - // SwClient - virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); - static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId(); // XUnoTunnel diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index 6ca031d041ba..0af4a74b52ff 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -1314,83 +1314,97 @@ throw (container::NoSuchElementException, lang::WrappedTargetException, /****************************************************************** * SwXTextRange ******************************************************************/ -TYPEINIT1(SwXTextRange, SwClient); -const uno::Sequence< sal_Int8 > & SwXTextRange::getUnoTunnelId() +class SwXTextRange::Impl + : public SwClient { - static uno::Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId(); - return aSeq; -} -//XUnoTunnel -sal_Int64 SAL_CALL SwXTextRange::getSomething( - const uno::Sequence< sal_Int8 >& rId ) - throw(uno::RuntimeException) -{ - if( rId.getLength() == 16 - && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), - rId.getConstArray(), 16 ) ) +public: + + const SfxItemPropertySet & m_rPropSet; + const enum RangePosition m_eRangePosition; + SwDoc & m_rDoc; + uno::Reference m_xParentText; + SwDepend m_ObjectDepend; // register at format of table or frame + ::sw::mark::IMark * m_pMark; + + Impl( SwDoc & rDoc, const enum RangePosition eRange, + SwFrmFmt *const pTblFmt = 0, + const uno::Reference< text::XText > & xParent = 0) + : SwClient() + , m_rPropSet(*aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR)) + , m_eRangePosition(eRange) + , m_rDoc(rDoc) + , m_xParentText(xParent) + , m_ObjectDepend(this, pTblFmt) + , m_pMark(0) + { + } + + ~Impl() + { + // Impl owns the bookmark; delete it here: SolarMutex is locked + Invalidate(); + } + + void Invalidate() + { + if (m_pMark) { - return sal::static_int_cast< sal_Int64 >( reinterpret_cast (this) ); + m_rDoc.getIDocumentMarkAccess()->deleteMark(m_pMark); + m_pMark = 0; } - return 0; -} + } -OUString SwXTextRange::getImplementationName(void) throw( RuntimeException ) -{ - return OUString::createFromAscii("SwXTextRange"); -} + const ::sw::mark::IMark * GetBookmark() const { return m_pMark; } -BOOL SwXTextRange::supportsService(const OUString& rServiceName) throw( RuntimeException ) -{ - String sServiceName(rServiceName); - return sServiceName.EqualsAscii("com.sun.star.text.TextRange") || - sServiceName.EqualsAscii("com.sun.star.style.CharacterProperties")|| - sServiceName.EqualsAscii("com.sun.star.style.CharacterPropertiesAsian")|| - sServiceName.EqualsAscii("com.sun.star.style.CharacterPropertiesComplex")|| - sServiceName.EqualsAscii("com.sun.star.style.ParagraphProperties") || - sServiceName.EqualsAscii("com.sun.star.style.ParagraphPropertiesAsian") || - sServiceName.EqualsAscii("com.sun.star.style.ParagraphPropertiesComplex"); -} + // SwClient + virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); -Sequence< OUString > SwXTextRange::getSupportedServiceNames(void) throw( RuntimeException ) +}; + +void SwXTextRange::Impl::Modify(SfxPoolItem *pOld, SfxPoolItem *pNew) { - Sequence< OUString > aRet(7); - aRet[0] = OUString::createFromAscii("com.sun.star.text.TextRange"); - aRet[1] = OUString::createFromAscii("com.sun.star.style.CharacterProperties"); - aRet[2] = OUString::createFromAscii("com.sun.star.style.CharacterPropertiesAsian"); - aRet[3] = OUString::createFromAscii("com.sun.star.style.CharacterPropertiesComplex"); - aRet[4] = OUString::createFromAscii("com.sun.star.style.ParagraphProperties"); - aRet[5] = OUString::createFromAscii("com.sun.star.style.ParagraphPropertiesAsian"); - aRet[6] = OUString::createFromAscii("com.sun.star.style.ParagraphPropertiesComplex"); - return aRet; + const bool bAlreadyRegistered = 0 != GetRegisteredIn(); + ClientModify(this, pOld, pNew); + if (m_ObjectDepend.GetRegisteredIn()) + { + ClientModify(&m_ObjectDepend, pOld, pNew); + // if the depend was removed then the range must be removed too + if (!m_ObjectDepend.GetRegisteredIn() && GetRegisteredIn()) + { + const_cast(GetRegisteredIn())->Remove(this); + } + // or if the range has been removed but the depend ist still + // connected then the depend must be removed + else if (bAlreadyRegistered && !GetRegisteredIn() && + m_ObjectDepend.GetRegisteredIn()) + { + const_cast(m_ObjectDepend.GetRegisteredIn()) + ->Remove(& m_ObjectDepend); + } + } + if (!GetRegisteredIn()) + { + m_pMark = 0; + } } + SwXTextRange::SwXTextRange(SwPaM& rPam, - const uno::Reference< XText > & rxParent, enum RangePosition eRange) : - eRangePosition(eRange), - pDoc(rPam.GetDoc()), - pBox(0), - pBoxStartNode(0), - aObjectDepend(this, 0), - m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR)), - xParentText(rxParent), - pMark(NULL) + const uno::Reference< text::XText > & xParent, + const enum RangePosition eRange) + : m_pImpl( new SwXTextRange::Impl(*rPam.GetDoc(), eRange, 0, xParent) ) { SetPositions(rPam); } -SwXTextRange::SwXTextRange(SwFrmFmt& rTblFmt) : - eRangePosition(RANGE_IS_TABLE), - pDoc(rTblFmt.GetDoc()), - pBox(0), - pBoxStartNode(0), - aObjectDepend(this, &rTblFmt), - m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR)), - pMark(NULL) +SwXTextRange::SwXTextRange(SwFrmFmt& rTblFmt) + : m_pImpl( + new SwXTextRange::Impl(*rTblFmt.GetDoc(), RANGE_IS_TABLE, &rTblFmt) ) { - SwTable* pTable = SwTable::FindTable( &rTblFmt ); - SwTableNode* pTblNode = pTable->GetTableNode( ); + SwTable *const pTable = SwTable::FindTable( &rTblFmt ); + SwTableNode *const pTblNode = pTable->GetTableNode(); SwPosition aPosition( *pTblNode ); SwPaM aPam( aPosition ); @@ -1399,181 +1413,221 @@ SwXTextRange::SwXTextRange(SwFrmFmt& rTblFmt) : SwXTextRange::~SwXTextRange() { - vos::OGuard aGuard(Application::GetSolarMutex()); - ::sw::mark::IMark const * const pBkmk = GetBookmark(); - if(pBkmk) - pDoc->getIDocumentMarkAccess()->deleteMark(pBkmk); } -void SwXTextRange::SetPositions(const SwPaM& rPam) +const SwDoc * SwXTextRange::GetDoc() const { - IDocumentMarkAccess* const pMarkAccess = pDoc->getIDocumentMarkAccess(); + return & m_pImpl->m_rDoc; +} - ::sw::mark::IMark const * const pBkmk = GetBookmark(); - if(pBkmk) - pMarkAccess->deleteMark(pBkmk); - pMark = pMarkAccess->makeMark(rPam, ::rtl::OUString(), IDocumentMarkAccess::UNO_BOOKMARK); - pMark->Add(this); +SwDoc * SwXTextRange::GetDoc() +{ + return & m_pImpl->m_rDoc; +} + + +void SwXTextRange::Invalidate() +{ + m_pImpl->Invalidate(); +} + +void SwXTextRange::SetPositions(const SwPaM& rPam) +{ + m_pImpl->Invalidate(); + IDocumentMarkAccess* const pMA = m_pImpl->m_rDoc.getIDocumentMarkAccess(); + m_pImpl->m_pMark = pMA->makeMark(rPam, ::rtl::OUString(), + IDocumentMarkAccess::UNO_BOOKMARK); + m_pImpl->m_pMark->Add(m_pImpl.get()); } void SwXTextRange::DeleteAndInsert( - const String& rText, const bool bForceExpandHints) - throw(uno::RuntimeException) + const ::rtl::OUString& rText, const bool bForceExpandHints) +throw (uno::RuntimeException) { - if (RANGE_IS_TABLE == eRangePosition) + if (RANGE_IS_TABLE == m_pImpl->m_eRangePosition) { // setString on table not allowed throw uno::RuntimeException(); } - ::sw::mark::IMark const * const pBkmk = GetBookmark(); - if(pBkmk) + const SwPosition aPos(GetDoc()->GetNodes().GetEndOfContent()); + SwCursor aCursor(aPos, 0, false); + if (GetPositions(aCursor)) { - const SwPosition& rPoint = pBkmk->GetMarkStart(); - SwCursor aNewCrsr(rPoint, 0, false); - if(pBkmk->IsExpanded()) - { - aNewCrsr.SetMark(); - const SwPosition& rMark = pBkmk->GetMarkEnd(); - *aNewCrsr.GetMark() = rMark; - } - UnoActionContext aAction(pDoc); - pDoc->StartUndo(UNDO_INSERT, NULL); - if(aNewCrsr.HasMark()) + UnoActionContext aAction(& m_pImpl->m_rDoc); + m_pImpl->m_rDoc.StartUndo(UNDO_INSERT, NULL); + if (aCursor.HasMark()) { - pDoc->DeleteAndJoin(aNewCrsr); + m_pImpl->m_rDoc.DeleteAndJoin(aCursor); } - if(rText.Len()) + if (rText.getLength()) { SwUnoCursorHelper::DocInsertStringSplitCR( - *pDoc, aNewCrsr, rText, bForceExpandHints); + m_pImpl->m_rDoc, aCursor, rText, bForceExpandHints); - SwXTextCursor::SelectPam(aNewCrsr, sal_True); - aNewCrsr.Left(rText.Len(), CRSR_SKIP_CHARS, FALSE, FALSE); + SwXTextCursor::SelectPam(aCursor, sal_True); + aCursor.Left(rText.getLength(), CRSR_SKIP_CHARS, FALSE, FALSE); } - SetPositions(aNewCrsr); - pDoc->EndUndo(UNDO_INSERT, NULL); + SetPositions(aCursor); + m_pImpl->m_rDoc.EndUndo(UNDO_INSERT, NULL); } } -uno::Reference< XText > SwXTextRange::getText(void) throw( uno::RuntimeException ) +const uno::Sequence< sal_Int8 > & SwXTextRange::getUnoTunnelId() +{ + static uno::Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId(); + return aSeq; +} + +// XUnoTunnel +sal_Int64 SAL_CALL +SwXTextRange::getSomething(const uno::Sequence< sal_Int8 >& rId) +throw (uno::RuntimeException) +{ + return ::sw::UnoTunnelImpl(rId, this); +} + +OUString SAL_CALL +SwXTextRange::getImplementationName() throw (uno::RuntimeException) +{ + return OUString::createFromAscii("SwXTextRange"); +} + +static char const*const g_ServicesTextRange[] = +{ + "com.sun.star.text.TextRange", + "com.sun.star.style.CharacterProperties", + "com.sun.star.style.CharacterPropertiesAsian", + "com.sun.star.style.CharacterPropertiesComplex", + "com.sun.star.style.ParagraphProperties", + "com.sun.star.style.ParagraphPropertiesAsian", + "com.sun.star.style.ParagraphPropertiesComplex", +}; +static const size_t g_nServicesTextRange( + sizeof(g_ServicesTextRange)/sizeof(g_ServicesTextRange[0])); + +sal_Bool SAL_CALL SwXTextRange::supportsService(const OUString& rServiceName) +throw (uno::RuntimeException) +{ + return ::sw::SupportsServiceImpl( + g_nServicesTextRange, g_ServicesTextRange, rServiceName); +} + +uno::Sequence< OUString > SAL_CALL +SwXTextRange::getSupportedServiceNames() throw (uno::RuntimeException) +{ + return ::sw::GetSupportedServiceNamesImpl( + g_nServicesTextRange, g_ServicesTextRange); +} + +uno::Reference< text::XText > SAL_CALL +SwXTextRange::getText() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - if (!xParentText.is()) + + if (!m_pImpl->m_xParentText.is()) { - if (eRangePosition == RANGE_IS_TABLE && - aObjectDepend.GetRegisteredIn() ) - { - SwFrmFmt* pTblFmt = (SwFrmFmt*)aObjectDepend.GetRegisteredIn(); - SwTable* pTable = SwTable::FindTable( pTblFmt ); - SwTableNode* pTblNode = pTable->GetTableNode(); - SwPosition aPosition( *pTblNode ); - uno::Reference< XTextRange > xRange = - SwXTextRange::CreateTextRangeFromPosition(pDoc, aPosition, 0); - xParentText = xRange->getText(); - } - else + if (m_pImpl->m_eRangePosition == RANGE_IS_TABLE && + m_pImpl->m_ObjectDepend.GetRegisteredIn()) { - OSL_ENSURE(false, "SwXTextRange::getText: no text"); + SwFrmFmt const*const pTblFmt = static_cast( + m_pImpl->m_ObjectDepend.GetRegisteredIn()); + SwTable const*const pTable = SwTable::FindTable( pTblFmt ); + SwTableNode const*const pTblNode = pTable->GetTableNode(); + const SwPosition aPosition( *pTblNode ); + const uno::Reference< text::XTextRange > xRange = + SwXTextRange::CreateTextRangeFromPosition( + &m_pImpl->m_rDoc, aPosition, 0); + m_pImpl->m_xParentText = xRange->getText(); } } - return xParentText; + OSL_ENSURE(m_pImpl->m_xParentText.is(), "SwXTextRange::getText: no text"); + return m_pImpl->m_xParentText; } -uno::Reference< XTextRange > SwXTextRange::getStart(void) throw( uno::RuntimeException ) +uno::Reference< text::XTextRange > SAL_CALL +SwXTextRange::getStart() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< XTextRange > xRet; - ::sw::mark::IMark const * const pBkmk = GetBookmark(); - if(!xParentText.is()) + uno::Reference< text::XTextRange > xRet; + ::sw::mark::IMark const * const pBkmk = m_pImpl->GetBookmark(); + if (!m_pImpl->m_xParentText.is()) + { getText(); + } if(pBkmk) { SwPaM aPam(pBkmk->GetMarkStart()); - xRet = new SwXTextRange(aPam, xParentText); + xRet = new SwXTextRange(aPam, m_pImpl->m_xParentText); } - else if(eRangePosition == RANGE_IS_TABLE) + else if (RANGE_IS_TABLE == m_pImpl->m_eRangePosition) { - //start and end are this, if its a table + // start and end are this, if its a table xRet = this; } else + { throw uno::RuntimeException(); + } return xRet; } -uno::Reference< XTextRange > SwXTextRange::getEnd(void) throw( uno::RuntimeException ) +uno::Reference< text::XTextRange > SAL_CALL +SwXTextRange::getEnd() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< XTextRange > xRet; - ::sw::mark::IMark const * const pBkmk = GetBookmark(); - if(!xParentText.is()) + + uno::Reference< text::XTextRange > xRet; + ::sw::mark::IMark const * const pBkmk = m_pImpl->GetBookmark(); + if (!m_pImpl->m_xParentText.is()) + { getText(); + } if(pBkmk) { SwPaM aPam(pBkmk->GetMarkEnd()); - xRet = new SwXTextRange(aPam, xParentText); + xRet = new SwXTextRange(aPam, m_pImpl->m_xParentText); } - else if(eRangePosition == RANGE_IS_TABLE) + else if (RANGE_IS_TABLE == m_pImpl->m_eRangePosition) { - //start and end are this, if its a table + // start and end are this, if its a table xRet = this; } else + { throw uno::RuntimeException(); + } return xRet; } -OUString SwXTextRange::getString(void) throw( uno::RuntimeException ) +OUString SAL_CALL SwXTextRange::getString() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + OUString sRet; - ::sw::mark::IMark const * const pBkmk = GetBookmark(); // for tables there is no bookmark, thus also no text // one could export the table as ASCII here maybe? - if(pBkmk && pBkmk->IsExpanded()) + SwPaM aPaM(GetDoc()->GetNodes()); + if (GetPositions(aPaM) && aPaM.HasMark()) { - const SwPosition& rPoint = pBkmk->GetMarkPos(); - const SwPosition& rMark = pBkmk->GetOtherMarkPos(); - SwPaM aCrsr(rMark, rPoint); - SwXTextCursor::getTextFromPam(aCrsr, sRet); + SwXTextCursor::getTextFromPam(aPaM, sRet); } return sRet; } -void SwXTextRange::setString(const OUString& aString) - throw( uno::RuntimeException ) +void SAL_CALL SwXTextRange::setString(const OUString& rString) +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - DeleteAndInsert(aString, false); -} -void SwXTextRange::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew) -{ - sal_Bool bAlreadyRegisterred = 0 != GetRegisteredIn(); - ClientModify(this, pOld, pNew); - if(aObjectDepend.GetRegisteredIn()) - { - ClientModify(&aObjectDepend, pOld, pNew); - // if the depend was removed then the range must be removed too - if(!aObjectDepend.GetRegisteredIn() && GetRegisteredIn()) - ((SwModify*)GetRegisteredIn())->Remove(this); - // or if the range has been removed but the depend ist still - // connected then the depend must be removed - else if(bAlreadyRegisterred && !GetRegisteredIn() && - aObjectDepend.GetRegisteredIn()) - ((SwModify*)aObjectDepend.GetRegisteredIn())->Remove(&aObjectDepend); - } - if(!GetRegisteredIn()) - pMark = NULL; + DeleteAndInsert(rString, false); } -sal_Bool SwXTextRange::GetPositions(SwPaM& rToFill) const +bool SwXTextRange::GetPositions(SwPaM& rToFill) const { - sal_Bool bRet = sal_False; - ::sw::mark::IMark const * const pBkmk = GetBookmark(); + ::sw::mark::IMark const * const pBkmk = m_pImpl->GetBookmark(); if(pBkmk) { *rToFill.GetPoint() = pBkmk->GetMarkPos(); @@ -1583,10 +1637,12 @@ sal_Bool SwXTextRange::GetPositions(SwPaM& rToFill) const *rToFill.GetMark() = pBkmk->GetOtherMarkPos(); } else + { rToFill.DeleteMark(); - bRet = sal_True; + } + return true; } - return bRet; + return false; } sal_Bool SwXTextRange::XTextRangeToSwPaM( SwUnoInternalPaM& rToFill, @@ -1806,187 +1862,248 @@ uno::Reference< XText > SwXTextRange::CreateParentXText(SwDoc* pDoc, return xParentText; } -uno::Reference< XEnumeration > SAL_CALL SwXTextRange::createContentEnumeration( - const OUString& rServiceName) - throw(RuntimeException) +uno::Reference< container::XEnumeration > SAL_CALL +SwXTextRange::createContentEnumeration(const OUString& rServiceName) +throw (uno::RuntimeException) { - ::sw::mark::IMark const * const pBkmk = GetBookmark(); - if( !pBkmk || COMPARE_EQUAL != rServiceName.compareToAscii("com.sun.star.text.TextContent") ) - throw RuntimeException(); + vos::OGuard g(Application::GetSolarMutex()); - const SwPosition& rPoint = pBkmk->GetMarkPos(); - SwUnoCrsr* pNewCrsr = pDoc->CreateUnoCrsr(rPoint, FALSE); - if(pBkmk->IsExpanded() && pBkmk->GetOtherMarkPos() != rPoint) + if (!rServiceName.equalsAscii("com.sun.star.text.TextContent")) { - pNewCrsr->SetMark(); - *pNewCrsr->GetMark() = pBkmk->GetOtherMarkPos(); + throw uno::RuntimeException(); } - uno::Reference< XEnumeration > xRet = new SwXParaFrameEnumeration(*pNewCrsr, PARAFRAME_PORTION_TEXTRANGE); - delete pNewCrsr; + + if (!GetDoc() || !m_pImpl->GetBookmark()) + { + throw uno::RuntimeException(); + } + const SwPosition aPos(GetDoc()->GetNodes().GetEndOfContent()); + const ::std::auto_ptr pNewCrsr( + m_pImpl->m_rDoc.CreateUnoCrsr(aPos, FALSE)); + if (!GetPositions(*pNewCrsr)) + { + throw uno::RuntimeException(); + } + + const uno::Reference< container::XEnumeration > xRet = + new SwXParaFrameEnumeration(*pNewCrsr, PARAFRAME_PORTION_TEXTRANGE); return xRet; } -uno::Reference< XEnumeration > SwXTextRange::createEnumeration(void) throw( RuntimeException ) +uno::Reference< container::XEnumeration > SAL_CALL +SwXTextRange::createEnumeration() throw (uno::RuntimeException) { - ::sw::mark::IMark const * const pBkmk = GetBookmark(); - if(!pBkmk) throw RuntimeException(); - const SwPosition& rPoint = pBkmk->GetMarkPos(); - ::std::auto_ptr pNewCrsr(pDoc->CreateUnoCrsr(rPoint, sal_False)); - if(pBkmk->IsExpanded() && pBkmk->GetOtherMarkPos() != rPoint) + vos::OGuard g(Application::GetSolarMutex()); + + if (!GetDoc() || !m_pImpl->GetBookmark()) { - pNewCrsr->SetMark(); - *pNewCrsr->GetMark() = pBkmk->GetOtherMarkPos(); + throw uno::RuntimeException(); } - uno::Reference xTunnel(xParentText, UNO_QUERY); - SwXText* pParentText = 0; - if(xTunnel.is()) + const SwPosition aPos(GetDoc()->GetNodes().GetEndOfContent()); + ::std::auto_ptr pNewCrsr( + m_pImpl->m_rDoc.CreateUnoCrsr(aPos, FALSE)); + if (!GetPositions(*pNewCrsr)) { - pParentText = reinterpret_cast< SwXText * >( - sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething(SwXText::getUnoTunnelId()) )); + throw uno::RuntimeException(); } - DBG_ASSERT(pParentText, "parent is not a SwXText"); - if (!pParentText) + if (!m_pImpl->m_xParentText.is()) { - throw uno::RuntimeException(); + getText(); } - const CursorType eSetType = (RANGE_IN_CELL == eRangePosition) + const CursorType eSetType = (RANGE_IN_CELL == m_pImpl->m_eRangePosition) ? CURSOR_SELECTION_IN_TABLE : CURSOR_SELECTION; - const uno::Reference< XEnumeration > xRet = - new SwXParagraphEnumeration(pParentText, pNewCrsr, eSetType); + const uno::Reference< container::XEnumeration > xRet = + new SwXParagraphEnumeration(m_pImpl->m_xParentText, pNewCrsr, eSetType); return xRet; } -uno::Type SwXTextRange::getElementType(void) throw( RuntimeException ) +uno::Type SAL_CALL SwXTextRange::getElementType() throw (uno::RuntimeException) { - return ::getCppuType((uno::Reference*)0); + return text::XTextRange::static_type(); } -sal_Bool SwXTextRange::hasElements(void) throw( RuntimeException ) +sal_Bool SAL_CALL SwXTextRange::hasElements() throw (uno::RuntimeException) { return sal_True; } -Sequence< OUString > SAL_CALL SwXTextRange::getAvailableServiceNames(void) throw( RuntimeException ) +uno::Sequence< OUString > SAL_CALL +SwXTextRange::getAvailableServiceNames() throw (uno::RuntimeException) { - Sequence< OUString > aRet(1); + uno::Sequence< OUString > aRet(1); OUString* pArray = aRet.getArray(); pArray[0] = OUString::createFromAscii("com.sun.star.text.TextContent"); return aRet; } -uno::Reference< XPropertySetInfo > SAL_CALL SwXTextRange::getPropertySetInfo( ) throw(RuntimeException) +uno::Reference< beans::XPropertySetInfo > SAL_CALL +SwXTextRange::getPropertySetInfo() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - static uno::Reference< XPropertySetInfo > xRef = m_pPropSet->getPropertySetInfo(); + + static uno::Reference< beans::XPropertySetInfo > xRef = + m_pImpl->m_rPropSet.getPropertySetInfo(); return xRef; } -void SAL_CALL SwXTextRange::setPropertyValue( - const OUString& rPropertyName, const Any& rValue ) - throw(UnknownPropertyException, PropertyVetoException, - IllegalArgumentException, WrappedTargetException, RuntimeException) +void SAL_CALL +SwXTextRange::setPropertyValue( + const OUString& rPropertyName, const uno::Any& rValue) +throw (beans::UnknownPropertyException, beans::PropertyVetoException, + lang::IllegalArgumentException, lang::WrappedTargetException, + uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(!GetDoc() || !GetBookmark()) - throw RuntimeException(); + + if (!GetDoc() || !m_pImpl->GetBookmark()) + { + throw uno::RuntimeException(); + } SwPaM aPaM(GetDoc()->GetNodes()); - SwXTextRange::GetPositions(aPaM); - SwXTextCursor::SetPropertyValue(aPaM, *m_pPropSet, rPropertyName, rValue); + GetPositions(aPaM); + SwXTextCursor::SetPropertyValue(aPaM, m_pImpl->m_rPropSet, + rPropertyName, rValue); } -Any SAL_CALL SwXTextRange::getPropertyValue( const OUString& rPropertyName ) - throw(UnknownPropertyException, WrappedTargetException, RuntimeException) +uno::Any SAL_CALL +SwXTextRange::getPropertyValue(const OUString& rPropertyName) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(!GetDoc() || !GetBookmark()) - throw RuntimeException(); - SwPaM aPaM(((SwDoc*)GetDoc())->GetNodes()); - SwXTextRange::GetPositions(aPaM); - return SwXTextCursor::GetPropertyValue(aPaM, *m_pPropSet, rPropertyName); + + if (!GetDoc() || !m_pImpl->GetBookmark()) + { + throw uno::RuntimeException(); + } + SwPaM aPaM(GetDoc()->GetNodes()); + GetPositions(aPaM); + return SwXTextCursor::GetPropertyValue(aPaM, m_pImpl->m_rPropSet, + rPropertyName); } -void SAL_CALL SwXTextRange::addPropertyChangeListener( - const OUString& /*PropertyName*/, const uno::Reference< beans::XPropertyChangeListener >& /*aListener*/ ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +void SAL_CALL +SwXTextRange::addPropertyChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - DBG_WARNING("not implemented"); + OSL_ENSURE(false, + "SwXTextRange::addPropertyChangeListener(): not implemented"); } -void SAL_CALL SwXTextRange::removePropertyChangeListener( - const OUString& /*PropertyName*/, const uno::Reference< beans::XPropertyChangeListener >& /*aListener*/ ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +void SAL_CALL +SwXTextRange::removePropertyChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - DBG_WARNING("not implemented"); + OSL_ENSURE(false, + "SwXTextRange::removePropertyChangeListener(): not implemented"); } -void SAL_CALL SwXTextRange::addVetoableChangeListener( - const OUString& /*PropertyName*/, const uno::Reference< XVetoableChangeListener >& /*aListener*/ ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +void SAL_CALL +SwXTextRange::addVetoableChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - DBG_WARNING("not implemented"); + OSL_ENSURE(false, + "SwXTextRange::addVetoableChangeListener(): not implemented"); } -void SAL_CALL SwXTextRange::removeVetoableChangeListener( - const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener >& /*aListener*/ ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +void SAL_CALL +SwXTextRange::removeVetoableChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - DBG_WARNING("not implemented"); + OSL_ENSURE(false, + "SwXTextRange::removeVetoableChangeListener(): not implemented"); } -PropertyState SAL_CALL SwXTextRange::getPropertyState( const OUString& rPropertyName ) - throw(UnknownPropertyException, RuntimeException) +beans::PropertyState SAL_CALL +SwXTextRange::getPropertyState(const OUString& rPropertyName) +throw (beans::UnknownPropertyException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(!GetDoc() || !GetBookmark()) - throw RuntimeException(); - SwPaM aPaM(((SwDoc*)GetDoc())->GetNodes()); - SwXTextRange::GetPositions(aPaM); - return SwXTextCursor::GetPropertyState(aPaM, *m_pPropSet, rPropertyName); + + if (!GetDoc() || !m_pImpl->GetBookmark()) + { + throw uno::RuntimeException(); + } + SwPaM aPaM(GetDoc()->GetNodes()); + GetPositions(aPaM); + return SwXTextCursor::GetPropertyState(aPaM, m_pImpl->m_rPropSet, + rPropertyName); } -Sequence< PropertyState > SAL_CALL SwXTextRange::getPropertyStates( - const Sequence< OUString >& rPropertyName ) throw(UnknownPropertyException, RuntimeException) +uno::Sequence< beans::PropertyState > SAL_CALL +SwXTextRange::getPropertyStates(const uno::Sequence< OUString >& rPropertyName) +throw (beans::UnknownPropertyException, uno::RuntimeException) { - NAMESPACE_VOS(OGuard) aGuard(Application::GetSolarMutex()); - if(!GetDoc() || !GetBookmark()) - throw RuntimeException(); - SwPaM aPaM(((SwDoc*)GetDoc())->GetNodes()); - SwXTextRange::GetPositions(aPaM); - return SwXTextCursor::GetPropertyStates(aPaM, *m_pPropSet, rPropertyName); + vos::OGuard g(Application::GetSolarMutex()); + + if (!GetDoc() || !m_pImpl->GetBookmark()) + { + throw uno::RuntimeException(); + } + SwPaM aPaM(GetDoc()->GetNodes()); + GetPositions(aPaM); + return SwXTextCursor::GetPropertyStates(aPaM, m_pImpl->m_rPropSet, + rPropertyName); } -void SAL_CALL SwXTextRange::setPropertyToDefault( const OUString& rPropertyName ) - throw(UnknownPropertyException, RuntimeException) +void SAL_CALL SwXTextRange::setPropertyToDefault(const OUString& rPropertyName) +throw (beans::UnknownPropertyException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(!GetDoc() || !GetBookmark()) - throw RuntimeException(); - SwPaM aPaM(((SwDoc*)GetDoc())->GetNodes()); - SwXTextRange::GetPositions(aPaM); - SwXTextCursor::SetPropertyToDefault(aPaM, *m_pPropSet, rPropertyName); + + if (!GetDoc() || !m_pImpl->GetBookmark()) + { + throw uno::RuntimeException(); + } + SwPaM aPaM(GetDoc()->GetNodes()); + GetPositions(aPaM); + SwXTextCursor::SetPropertyToDefault(aPaM, m_pImpl->m_rPropSet, + rPropertyName); } -Any SAL_CALL SwXTextRange::getPropertyDefault( const OUString& rPropertyName ) - throw(UnknownPropertyException, WrappedTargetException, RuntimeException) +uno::Any SAL_CALL +SwXTextRange::getPropertyDefault(const OUString& rPropertyName) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(!GetDoc() || !GetBookmark()) - throw RuntimeException(); - SwPaM aPaM(((SwDoc*)GetDoc())->GetNodes()); - SwXTextRange::GetPositions(aPaM); - return SwXTextCursor::GetPropertyDefault(aPaM, *m_pPropSet, rPropertyName); + + if (!GetDoc() || !m_pImpl->GetBookmark()) + { + throw uno::RuntimeException(); + } + SwPaM aPaM(GetDoc()->GetNodes()); + GetPositions(aPaM); + return SwXTextCursor::GetPropertyDefault(aPaM, m_pImpl->m_rPropSet, + rPropertyName); } -void SwXTextRange::makeRedline( +void SAL_CALL +SwXTextRange::makeRedline( const ::rtl::OUString& rRedlineType, const uno::Sequence< beans::PropertyValue >& rRedlineProperties ) - throw (lang::IllegalArgumentException, uno::RuntimeException) +throw (lang::IllegalArgumentException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(!GetDoc() || !GetBookmark()) - throw RuntimeException(); - SwPaM aPaM(((SwDoc*)GetDoc())->GetNodes()); + + if (!GetDoc() || !m_pImpl->GetBookmark()) + { + throw uno::RuntimeException(); + } + SwPaM aPaM(GetDoc()->GetNodes()); SwXTextRange::GetPositions(aPaM); SwUnoCursorHelper::makeRedline( aPaM, rRedlineType, rRedlineProperties ); } diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index 7c0fe114b489..023290984ebf 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -1594,15 +1594,11 @@ uno::Reference< text::XTextContent > SwXText::convertToTextFrame( //bookmarks have to be removed before the referenced text node is deleted in DelFullPara if(pStartRange) { - ::sw::mark::IMark const * const pStartBookmark = pStartRange->GetBookmark(); - if(pStartBookmark) - pDoc->getIDocumentMarkAccess()->deleteMark(pStartBookmark); + pStartRange->Invalidate(); } if(pEndRange) { - ::sw::mark::IMark const * const pEndBookmark = pEndRange->GetBookmark(); - if(pEndBookmark) - pDoc->getIDocumentMarkAccess()->deleteMark(pEndBookmark); + pEndRange->Invalidate(); } pDoc->StartUndo( UNDO_START, NULL ); -- cgit From 5d6da5c1f774b02973085816bb0717d8a2c891a3 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 8 Jan 2010 17:13:53 +0100 Subject: swunolocking1: #i105557#: SwXTextRange: move static methods to namespace sw. clean up the implementation a little. --- sw/inc/unotextrange.hxx | 22 ++- sw/source/core/access/accpara.cxx | 6 +- sw/source/core/crsr/crsrsh.cxx | 4 +- sw/source/core/unocore/unobkm.cxx | 6 +- sw/source/core/unocore/unodraw.cxx | 12 +- sw/source/core/unocore/unofield.cxx | 6 +- sw/source/core/unocore/unoflatpara.cxx | 8 +- sw/source/core/unocore/unoframe.cxx | 8 +- sw/source/core/unocore/unoftn.cxx | 7 +- sw/source/core/unocore/unoidx.cxx | 6 +- sw/source/core/unocore/unoobj2.cxx | 175 +++++++++++++---------- sw/source/core/unocore/unoparagraph.cxx | 2 +- sw/source/core/unocore/unoredline.cxx | 7 +- sw/source/core/unocore/unorefmk.cxx | 17 +-- sw/source/core/unocore/unosect.cxx | 4 +- sw/source/core/unocore/unotbl.cxx | 5 +- sw/source/core/unocore/unotext.cxx | 20 +-- sw/source/filter/xml/XMLRedlineImportHelper.cxx | 4 +- sw/source/filter/xml/swxml.cxx | 5 +- sw/source/filter/xml/xmlimp.cxx | 6 +- sw/source/filter/xml/xmltbli.cxx | 4 +- sw/source/ui/dialog/SwSpellDialogChildWindow.cxx | 9 +- sw/source/ui/uno/unotxdoc.cxx | 18 ++- sw/source/ui/uno/unotxvw.cxx | 14 +- 24 files changed, 198 insertions(+), 177 deletions(-) (limited to 'sw') diff --git a/sw/inc/unotextrange.hxx b/sw/inc/unotextrange.hxx index 8b34ce7f94c1..c3c3d362db6b 100644 --- a/sw/inc/unotextrange.hxx +++ b/sw/inc/unotextrange.hxx @@ -77,6 +77,13 @@ namespace sw { void DeepCopyPaM(SwPaM const & rSource, SwPaM & rTarget); + bool XTextRangeToSwPaM(SwUnoInternalPaM& rToFill, + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xTextRange); + + ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > + CreateParentXText(SwDoc & rDoc, const SwPosition& rPos); + } // namespace sw @@ -105,10 +112,8 @@ private: enum RangePosition { RANGE_IN_TEXT, // "ordinary" ::com::sun::star::text::TextRange - RANGE_IN_FRAME, // position created with a frame that has no uno object RANGE_IN_CELL, // position created with a cell that has no uno object RANGE_IS_TABLE, // anchor of a table - RANGE_INVALID // created by NewInstance }; void SetPositions(SwPaM const& rPam); @@ -133,17 +138,10 @@ public: SwDoc* GetDoc(); bool GetPositions(SwPaM & rToFill) const; - static BOOL XTextRangeToSwPaM(SwUnoInternalPaM& rToFill, - const ::com::sun::star::uno::Reference< - ::com::sun::star::text::XTextRange > & xTextRange); - static ::com::sun::star::uno::Reference< - ::com::sun::star::text::XTextRange > CreateTextRangeFromPosition( - SwDoc* pDoc, - const SwPosition& rPos, const SwPosition* pMark); - - static ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > - CreateParentXText(SwDoc* pDoc, const SwPosition& rPos); + ::com::sun::star::text::XTextRange > CreateXTextRange( + SwDoc & rDoc, + const SwPosition& rPos, const SwPosition *const pMark); static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId(); diff --git a/sw/source/core/access/accpara.cxx b/sw/source/core/access/accpara.cxx index 29464206c24b..950a0d3fc81c 100644 --- a/sw/source/core/access/accpara.cxx +++ b/sw/source/core/access/accpara.cxx @@ -2105,8 +2105,10 @@ sal_Bool SwAccessibleParagraph::replaceText( aEndPos.nContent = nEnd; // now create XTextRange as helper and set string - SwXTextRange::CreateTextRangeFromPosition( - pNode->GetDoc(), aStartPos, &aEndPos)->setString(sReplacement); + const uno::Reference xRange( + SwXTextRange::CreateXTextRange( + *pNode->GetDoc(), aStartPos, &aEndPos)); + xRange->setString(sReplacement); // delete portion data ClearPortionData(); diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx index f4b7e0a0b10d..59c8570ba212 100644 --- a/sw/source/core/crsr/crsrsh.cxx +++ b/sw/source/core/crsr/crsrsh.cxx @@ -3372,8 +3372,8 @@ void lcl_FillTextRange( uno::Reference& rRange, SwPosition aEndPos( aStartPos ); aEndPos.nContent = nBegin + nLen; - uno::Reference xRange = - SwXTextRange::CreateTextRangeFromPosition( rNode.GetDoc(), aStartPos, &aEndPos); + const uno::Reference xRange = + SwXTextRange::CreateXTextRange(*rNode.GetDoc(), aStartPos, &aEndPos); rRange = xRange; } diff --git a/sw/source/core/unocore/unobkm.cxx b/sw/source/core/unocore/unobkm.cxx index 86b8b3ee8403..ad35f1f28b33 100644 --- a/sw/source/core/unocore/unobkm.cxx +++ b/sw/source/core/unocore/unobkm.cxx @@ -237,7 +237,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException) m_pImpl->m_pDoc = pDoc; SwUnoInternalPaM aPam(*m_pImpl->m_pDoc); - SwXTextRange::XTextRangeToSwPaM(aPam, xTextRange); + ::sw::XTextRangeToSwPaM(aPam, xTextRange); UnoActionContext aCont(m_pImpl->m_pDoc); if (!m_pImpl->m_sMarkName.getLength()) { @@ -294,8 +294,8 @@ SwXBookmark::getAnchor() throw (uno::RuntimeException) { throw uno::RuntimeException(); } - return SwXTextRange::CreateTextRangeFromPosition( - m_pImpl->m_pDoc, + return SwXTextRange::CreateXTextRange( + *m_pImpl->m_pDoc, m_pImpl->m_pRegisteredBookmark->GetMarkPos(), (m_pImpl->m_pRegisteredBookmark->IsExpanded()) ? &m_pImpl->m_pRegisteredBookmark->GetOtherMarkPos() : NULL); diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx index 9a2eb1dfae45..c8a0b78bb48c 100644 --- a/sw/source/core/unocore/unodraw.cxx +++ b/sw/source/core/unocore/unodraw.cxx @@ -784,7 +784,7 @@ void SwXDrawPage::add(const uno::Reference< drawing::XShape > & xShape) if( pDesc && (xRg = pDesc->GetTextRange()).is() ) { pInternalPam = new SwUnoInternalPaM(*pDoc); - if(SwXTextRange::XTextRangeToSwPaM(*pInternalPam, xRg)) + if (::sw::XTextRangeToSwPaM(*pInternalPam, xRg)) { if(FLY_AT_FLY == aAnchor.GetAnchorId() && !pInternalPam->GetNode()->FindFlyStartNode()) @@ -1302,7 +1302,7 @@ void SwXShape::setPropertyValue(const rtl::OUString& rPropertyName, const uno::A new SwUnoInternalPaM( *(pFmt->GetDoc()) ); uno::Reference< text::XTextRange > xRg; aValue >>= xRg; - if ( SwXTextRange::XTextRangeToSwPaM(*pInternalPam, xRg) ) + if (::sw::XTextRangeToSwPaM(*pInternalPam, xRg) ) { if (aAnchor.GetAnchorId() == FLY_AS_CHAR) { @@ -1634,9 +1634,9 @@ uno::Any SwXShape::getPropertyValue(const rtl::OUString& rPropertyName) { if ( aAnchor.GetCntntAnchor() ) { - uno::Reference< text::XTextRange > xTextRange = - SwXTextRange::CreateTextRangeFromPosition( - pFmt->GetDoc(), + const uno::Reference< text::XTextRange > xTextRange + = SwXTextRange::CreateXTextRange( + *pFmt->GetDoc(), *aAnchor.GetCntntAnchor(), 0L ); aRet.setValue(&xTextRange, ::getCppuType((uno::Reference*)0)); @@ -2203,7 +2203,7 @@ uno::Reference< text::XTextRange > SwXShape::getAnchor(void) throw( uno::Runtim (rAnchor.GetCntntAnchor() && !rAnchor.GetPageNum())) { const SwPosition &rPos = *(pFmt->GetAnchor().GetCntntAnchor()); - aRef = SwXTextRange::CreateTextRangeFromPosition(pFmt->GetDoc(), rPos, 0); + aRef = SwXTextRange::CreateXTextRange(*pFmt->GetDoc(), rPos, 0); } } else diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx index 59954b6a954e..eb8af4d93673 100644 --- a/sw/source/core/unocore/unofield.cxx +++ b/sw/source/core/unocore/unofield.cxx @@ -1305,7 +1305,7 @@ void SwXTextField::attachToRange( { SwUnoInternalPaM aPam(*pDoc); //das muss jetzt sal_True liefern - SwXTextRange::XTextRangeToSwPaM(aPam, xTextRange); + ::sw::XTextRangeToSwPaM(aPam, xTextRange); SwField* pFld = 0; switch(m_nServiceId) { @@ -1880,8 +1880,8 @@ uno::Reference< text::XTextRange > SwXTextField::getAnchor(void) throw( uno::Ru SwPaM aPam(rTxtNode, *pTxtFld->GetStart() + 1, rTxtNode, *pTxtFld->GetStart()); - aRef = SwXTextRange::CreateTextRangeFromPosition(m_pDoc, - *aPam.GetPoint(), aPam.GetMark()); + aRef = SwXTextRange::CreateXTextRange( + *m_pDoc, *aPam.GetPoint(), aPam.GetMark()); } return aRef; diff --git a/sw/source/core/unocore/unoflatpara.cxx b/sw/source/core/unocore/unoflatpara.cxx index 42f2934c5b01..d68fc43a3abc 100644 --- a/sw/source/core/unocore/unoflatpara.cxx +++ b/sw/source/core/unocore/unoflatpara.cxx @@ -218,7 +218,9 @@ void SAL_CALL SwXFlatParagraph::changeText(::sal_Int32 nPos, ::sal_Int32 nLen, c UnoActionContext aAction( mpTxtNode->GetDoc() ); - uno::Reference< text::XTextRange > xRange = SwXTextRange::CreateTextRangeFromPosition( mpTxtNode->GetDoc(), *aPaM.GetPoint(), aPaM.GetMark() ); + const uno::Reference< text::XTextRange > xRange = + SwXTextRange::CreateXTextRange( + *mpTxtNode->GetDoc(), *aPaM.GetPoint(), aPaM.GetMark() ); uno::Reference< beans::XPropertySet > xPropSet( xRange, uno::UNO_QUERY ); if ( xPropSet.is() ) { @@ -246,7 +248,9 @@ void SAL_CALL SwXFlatParagraph::changeAttributes(::sal_Int32 nPos, ::sal_Int32 n UnoActionContext aAction( mpTxtNode->GetDoc() ); - uno::Reference< text::XTextRange > xRange = SwXTextRange::CreateTextRangeFromPosition( mpTxtNode->GetDoc(), *aPaM.GetPoint(), aPaM.GetMark() ); + const uno::Reference< text::XTextRange > xRange = + SwXTextRange::CreateXTextRange( + *mpTxtNode->GetDoc(), *aPaM.GetPoint(), aPaM.GetMark() ); uno::Reference< beans::XPropertySet > xPropSet( xRange, uno::UNO_QUERY ); if ( xPropSet.is() ) { diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx index 8b3349332895..ac2dc2d55529 100644 --- a/sw/source/core/unocore/unoframe.cxx +++ b/sw/source/core/unocore/unoframe.cxx @@ -2056,7 +2056,7 @@ uno::Reference< text::XTextRange > SwXFrame::getAnchor(void) throw( uno::Runtim (rAnchor.GetCntntAnchor() && !rAnchor.GetPageNum())) { const SwPosition &rPos = *(rAnchor.GetCntntAnchor()); - aRef = SwXTextRange::CreateTextRangeFromPosition(pFmt->GetDoc(), rPos, 0); + aRef = SwXTextRange::CreateXTextRange(*pFmt->GetDoc(), rPos, 0); } } else @@ -2098,7 +2098,7 @@ void SwXFrame::attachToRange(const uno::Reference< text::XTextRange > & xTextRan { SwUnoInternalPaM aIntPam(*pDoc); //das muss jetzt sal_True liefern - SwXTextRange::XTextRangeToSwPaM(aIntPam, xTextRange); + ::sw::XTextRangeToSwPaM(aIntPam, xTextRange); SwNode& rNode = pDoc->GetNodes().GetEndOfContent(); SwPaM aPam(rNode); @@ -2430,7 +2430,7 @@ void SwXFrame::attach(const uno::Reference< text::XTextRange > & xTextRange) } SwDoc* pDoc = pFmt->GetDoc(); SwUnoInternalPaM aIntPam(*pDoc); - if(SwXTextRange::XTextRangeToSwPaM(aIntPam, xTextRange)) + if (::sw::XTextRangeToSwPaM(aIntPam, xTextRange)) { SfxItemSet aSet( pDoc->GetAttrPool(), RES_ANCHOR, RES_ANCHOR ); @@ -2672,7 +2672,7 @@ uno::Reference< text::XTextCursor > SwXTextFrame::createTextCursorByRange(const uno::Reference< text::XTextCursor > aRef; SwFrmFmt* pFmt = GetFrmFmt(); SwUnoInternalPaM aPam(*GetDoc()); - if(pFmt && SwXTextRange::XTextRangeToSwPaM(aPam, aTextPosition)) + if (pFmt && ::sw::XTextRangeToSwPaM(aPam, aTextPosition)) { SwNode& rNode = pFmt->GetCntnt().GetCntntIdx()->GetNode(); #if OSL_DEBUG_LEVEL > 1 diff --git a/sw/source/core/unocore/unoftn.cxx b/sw/source/core/unocore/unoftn.cxx index f18a46d8ad37..3d24e282f7c8 100644 --- a/sw/source/core/unocore/unoftn.cxx +++ b/sw/source/core/unocore/unoftn.cxx @@ -251,7 +251,7 @@ void SwXFootnote::attachToRange(const uno::Reference< text::XTextRange > & xText { SwUnoInternalPaM aPam(*pNewDoc); //das muss jetzt sal_True liefern - SwXTextRange::XTextRangeToSwPaM(aPam, xTextRange); + ::sw::XTextRangeToSwPaM(aPam, xTextRange); UnoActionContext aCont(pNewDoc); SwTxtAttr* pTxtAttr = 0; @@ -315,7 +315,8 @@ uno::Reference< text::XTextRange > SwXFootnote::getAnchor(void) throw( uno::Run SwPosition aMark( *aPam.Start() ); aPam.SetMark(); aPam.GetMark()->nContent++; - aRef = SwXTextRange::CreateTextRangeFromPosition((SwDoc*)GetDoc(), *aPam.Start(), aPam.End()); + aRef = SwXTextRange::CreateXTextRange( + *GetDoc(), *aPam.Start(), aPam.End()); } else throw uno::RuntimeException(); @@ -412,7 +413,7 @@ uno::Reference< text::XTextCursor > SwXFootnote::createTextCursorByRange( throw uno::RuntimeException(); uno::Reference< text::XTextCursor > aRef; SwUnoInternalPaM aPam(*GetDoc()); - if(SwXTextRange::XTextRangeToSwPaM(aPam, aTextPosition)) + if (::sw::XTextRangeToSwPaM(aPam, aTextPosition)) { const SwTxtFtn* pTxtFtn = pFmt->GetTxtFtn(); const SwNode* pFtnStartNode = &pTxtFtn->GetStartNode()->GetNode(); diff --git a/sw/source/core/unocore/unoidx.cxx b/sw/source/core/unocore/unoidx.cxx index 92309d6368cf..7119f3708711 100644 --- a/sw/source/core/unocore/unoidx.cxx +++ b/sw/source/core/unocore/unoidx.cxx @@ -1030,7 +1030,7 @@ void SwXDocumentIndex::attachToRange(const uno::Reference< text::XTextRange > & { SwUnoInternalPaM aPam(*pDoc); //das muss jetzt sal_True liefern - SwXTextRange::XTextRangeToSwPaM(aPam, xTextRange); + ::sw::XTextRangeToSwPaM(aPam, xTextRange); const SwTOXBase* pOld = pDoc->GetCurTOX( *aPam.Start() ); if(!pOld) @@ -1092,7 +1092,7 @@ uno::Reference< text::XTextRange > SwXDocumentIndex::getAnchor(void) throw( uno aPaM.SetMark(); aPaM.GetPoint()->nNode = *pIdx->GetNode().EndOfSectionNode(); aPaM.Move( fnMoveBackward, fnGoCntnt ); - xRet = SwXTextRange::CreateTextRangeFromPosition(pSectFmt->GetDoc(), + xRet = SwXTextRange::CreateXTextRange(*pSectFmt->GetDoc(), *aPaM.GetMark(), aPaM.GetPoint()); } } @@ -1469,7 +1469,7 @@ void SwXDocumentIndexMark::attachToRange(const uno::Reference< text::XTextRange SwUnoInternalPaM aPam(*pDoc); //das muss jetzt sal_True liefern - SwXTextRange::XTextRangeToSwPaM(aPam, xTextRange); + ::sw::XTextRangeToSwPaM(aPam, xTextRange); SwTOXMark aMark (pTOXType); if(sAltText.Len()) aMark.SetAlternativeText(sAltText); diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index 0af4a74b52ff..0027d8ef0b02 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -1536,10 +1536,8 @@ SwXTextRange::getText() throw (uno::RuntimeException) SwTable const*const pTable = SwTable::FindTable( pTblFmt ); SwTableNode const*const pTblNode = pTable->GetTableNode(); const SwPosition aPosition( *pTblNode ); - const uno::Reference< text::XTextRange > xRange = - SwXTextRange::CreateTextRangeFromPosition( - &m_pImpl->m_rDoc, aPosition, 0); - m_pImpl->m_xParentText = xRange->getText(); + m_pImpl->m_xParentText = + ::sw::CreateParentXText(m_pImpl->m_rDoc, aPosition); } } OSL_ENSURE(m_pImpl->m_xParentText.is(), "SwXTextRange::getText: no text"); @@ -1645,10 +1643,12 @@ bool SwXTextRange::GetPositions(SwPaM& rToFill) const return false; } -sal_Bool SwXTextRange::XTextRangeToSwPaM( SwUnoInternalPaM& rToFill, - const uno::Reference< XTextRange > & xTextRange) +namespace sw { + +bool XTextRangeToSwPaM( SwUnoInternalPaM & rToFill, + const uno::Reference< text::XTextRange > & xTextRange) { - sal_Bool bRet = sal_False; + bool bRet = false; uno::Reference xRangeTunnel( xTextRange, uno::UNO_QUERY); SwXTextRange* pRange = 0; @@ -1658,27 +1658,26 @@ sal_Bool SwXTextRange::XTextRangeToSwPaM( SwUnoInternalPaM& rToFill, SwXParagraph* pPara = 0; if(xRangeTunnel.is()) { - pRange = reinterpret_cast< SwXTextRange * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXTextRange::getUnoTunnelId()) )); - pCursor = reinterpret_cast< OTextCursorHelper * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( OTextCursorHelper::getUnoTunnelId()) )); - pPortion = reinterpret_cast< SwXTextPortion * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXTextPortion::getUnoTunnelId()) )); - pText = reinterpret_cast< SwXText * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXText::getUnoTunnelId()) )); - pPara = reinterpret_cast< SwXParagraph * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXParagraph::getUnoTunnelId()) )); + pRange = ::sw::UnoTunnelGetImplementation(xRangeTunnel); + pCursor = + ::sw::UnoTunnelGetImplementation(xRangeTunnel); + pPortion= + ::sw::UnoTunnelGetImplementation(xRangeTunnel); + pText = ::sw::UnoTunnelGetImplementation(xRangeTunnel); + pPara = ::sw::UnoTunnelGetImplementation(xRangeTunnel); } - //if it's a text cursor then create a temporary cursor there and re-use the pCursor variable - uno::Reference< XTextCursor > xTextCursor; + // if it's a text then create a temporary cursor there and re-use + // the pCursor variable if(pText) { - xTextCursor = pText->createCursor(); + const uno::Reference< text::XTextCursor > xTextCursor = + pText->createCursor(); xTextCursor->gotoEnd(sal_True); - uno::Reference xCrsrTunnel( xTextCursor, UNO_QUERY); - pCursor = reinterpret_cast< OTextCursorHelper * >( - sal::static_int_cast< sal_IntPtr >( xCrsrTunnel->getSomething( OTextCursorHelper::getUnoTunnelId()) )); + const uno::Reference xCrsrTunnel( + xTextCursor, uno::UNO_QUERY); + pCursor = + ::sw::UnoTunnelGetImplementation(xCrsrTunnel); } if(pRange && pRange->GetDoc() == rToFill.GetDoc()) { @@ -1698,8 +1697,9 @@ sal_Bool SwXTextRange::XTextRangeToSwPaM( SwUnoInternalPaM& rToFill, : ((pPortion) ? pPortion->GetCursor() : 0); if (pUnoCrsr && pDoc == rToFill.GetDoc()) { - DBG_ASSERT((SwPaM*)pUnoCrsr->GetNext() == pUnoCrsr, "was machen wir mit Ringen?" ); - bRet = sal_True; + DBG_ASSERT((SwPaM*)pUnoCrsr->GetNext() == pUnoCrsr, + "what to do about rings?"); + bRet = true; *rToFill.GetPoint() = *pUnoCrsr->GetPoint(); if (pUnoCrsr->HasMark()) { @@ -1714,53 +1714,65 @@ sal_Bool SwXTextRange::XTextRangeToSwPaM( SwUnoInternalPaM& rToFill, return bRet; } -sal_Bool lcl_IsStartNodeInFormat(sal_Bool bHeader, SwStartNode* pSttNode, - const SwFrmFmt* pFrmFmt, SwFrmFmt*& rpFormat) +static bool +lcl_IsStartNodeInFormat(const bool bHeader, SwStartNode *const pSttNode, + SwFrmFmt const*const pFrmFmt, SwFrmFmt*& rpFormat) { - sal_Bool bRet = sal_False; + bool bRet = false; const SfxItemSet& rSet = pFrmFmt->GetAttrSet(); const SfxPoolItem* pItem; - SwFrmFmt* pHeadFootFmt; - if(SFX_ITEM_SET == rSet.GetItemState( static_cast< USHORT >(bHeader ? RES_HEADER : RES_FOOTER), sal_True, &pItem) && - 0 != (pHeadFootFmt = bHeader ? - ((SwFmtHeader*)pItem)->GetHeaderFmt() : - ((SwFmtFooter*)pItem)->GetFooterFmt())) - { - const SwFmtCntnt& rFlyCntnt = pHeadFootFmt->GetCntnt(); - const SwNode& rNode = rFlyCntnt.GetCntntIdx()->GetNode(); - const SwStartNode* pCurSttNode = rNode.FindSttNodeByType( - bHeader ? SwHeaderStartNode : SwFooterStartNode); - if(pCurSttNode && pCurSttNode == pSttNode) + if (SFX_ITEM_SET == rSet.GetItemState( + static_cast(bHeader ? RES_HEADER : RES_FOOTER), + sal_True, &pItem)) + { + SfxPoolItem *const pItemNonConst(const_cast(pItem)); + SwFrmFmt *const pHeadFootFmt = (bHeader) ? + static_cast(pItemNonConst)->GetHeaderFmt() : + static_cast(pItemNonConst)->GetFooterFmt(); + if (pHeadFootFmt) { - bRet = sal_True; - rpFormat = pHeadFootFmt; + const SwFmtCntnt& rFlyCntnt = pHeadFootFmt->GetCntnt(); + const SwNode& rNode = rFlyCntnt.GetCntntIdx()->GetNode(); + SwStartNode const*const pCurSttNode = rNode.FindSttNodeByType( + (bHeader) ? SwHeaderStartNode : SwFooterStartNode); + if (pCurSttNode && (pCurSttNode == pSttNode)) + { + rpFormat = pHeadFootFmt; + bRet = true; + } } } return bRet; } -uno::Reference< XTextRange > SwXTextRange::CreateTextRangeFromPosition( - SwDoc* pDoc, const SwPosition& rPos, const SwPosition* pMark) +} // namespace sw + +uno::Reference< text::XTextRange > +SwXTextRange::CreateXTextRange( + SwDoc & rDoc, const SwPosition& rPos, const SwPosition *const pMark) { - uno::Reference< XText > xParentText( CreateParentXText(pDoc, rPos) ); - std::auto_ptr pNewCrsr( pDoc->CreateUnoCrsr(rPos, sal_False) ); + const uno::Reference xParentText( + ::sw::CreateParentXText(rDoc, rPos)); + const ::std::auto_ptr pNewCrsr( + rDoc.CreateUnoCrsr(rPos, sal_False)); if(pMark) { pNewCrsr->SetMark(); *pNewCrsr->GetMark() = *pMark; } - bool isCell( dynamic_cast(xParentText.get()) ); - uno::Reference< XTextRange > xRet( + const bool isCell( dynamic_cast(xParentText.get()) ); + const uno::Reference< text::XTextRange > xRet( new SwXTextRange(*pNewCrsr, xParentText, isCell ? RANGE_IN_CELL : RANGE_IN_TEXT) ); return xRet; - } -uno::Reference< XText > SwXTextRange::CreateParentXText(SwDoc* pDoc, - const SwPosition& rPos) +namespace sw { + +uno::Reference< text::XText > +CreateParentXText(SwDoc & rDoc, const SwPosition& rPos) { - uno::Reference< XText > xParentText; + uno::Reference< text::XText > xParentText; SwStartNode* pSttNode = rPos.nNode.GetNode().StartOfSectionNode(); while(pSttNode && pSttNode->IsSectionNode()) { @@ -1771,18 +1783,19 @@ uno::Reference< XText > SwXTextRange::CreateParentXText(SwDoc* pDoc, { case SwTableBoxStartNode: { - const SwTableNode* pTblNode = pSttNode->FindTableNode(); - SwFrmFmt* pTableFmt = (SwFrmFmt*)pTblNode->GetTable().GetFrmFmt(); - SwTableBox* pBox = pSttNode->GetTblBox(); + SwTableNode const*const pTblNode = pSttNode->FindTableNode(); + SwFrmFmt *const pTableFmt = + static_cast(pTblNode->GetTable().GetFrmFmt()); + SwTableBox *const pBox = pSttNode->GetTblBox(); - xParentText = pBox + xParentText = (pBox) ? SwXCell::CreateXCell( pTableFmt, pBox ) : new SwXCell( pTableFmt, *pSttNode ); } break; case SwFlyStartNode: { - SwFrmFmt* pFmt = pSttNode->GetFlyFmt(); + SwFrmFmt *const pFmt = pSttNode->GetFlyFmt(); if (0 != pFmt) { SwXTextFrame* pFrame( static_cast( @@ -1794,18 +1807,23 @@ uno::Reference< XText > SwXTextRange::CreateParentXText(SwDoc* pDoc, case SwHeaderStartNode: case SwFooterStartNode: { - sal_Bool bHeader = SwHeaderStartNode == eType; - sal_uInt16 nPDescCount = pDoc->GetPageDescCnt(); + const bool bHeader = (SwHeaderStartNode == eType); + const sal_uInt16 nPDescCount = rDoc.GetPageDescCnt(); for(sal_uInt16 i = 0; i < nPDescCount; i++) { - const SwPageDesc& rDesc = const_cast(pDoc) - ->GetPageDesc( i ); + const SwPageDesc& rDesc = + // C++ is retarded + const_cast(rDoc).GetPageDesc( i ); const SwFrmFmt* pFrmFmtMaster = &rDesc.GetMaster(); const SwFrmFmt* pFrmFmtLeft = &rDesc.GetLeft(); SwFrmFmt* pHeadFootFmt = 0; - if(!lcl_IsStartNodeInFormat(bHeader, pSttNode, pFrmFmtMaster, pHeadFootFmt)) - lcl_IsStartNodeInFormat(bHeader, pSttNode, pFrmFmtLeft, pHeadFootFmt); + if (!lcl_IsStartNodeInFormat(bHeader, pSttNode, pFrmFmtMaster, + pHeadFootFmt)) + { + lcl_IsStartNodeInFormat(bHeader, pSttNode, pFrmFmtLeft, + pHeadFootFmt); + } if(pHeadFootFmt) { @@ -1813,7 +1831,10 @@ uno::Reference< XText > SwXTextRange::CreateParentXText(SwDoc* pDoc, First( TYPE( SwXHeadFootText )); xParentText = pxHdFt; if(!pxHdFt) - xParentText = new SwXHeadFootText(*pHeadFootFmt, bHeader); + { + xParentText = + new SwXHeadFootText(*pHeadFootFmt, bHeader); + } break; } } @@ -1821,15 +1842,16 @@ uno::Reference< XText > SwXTextRange::CreateParentXText(SwDoc* pDoc, break; case SwFootnoteStartNode: { - sal_uInt16 n, nFtnCnt = pDoc->GetFtnIdxs().Count(); - uno::Reference< XFootnote > xRef; - for( n = 0; n < nFtnCnt; ++n ) + const sal_uInt16 nFtnCnt = rDoc.GetFtnIdxs().Count(); + uno::Reference< text::XFootnote > xRef; + for (sal_uInt16 n = 0; n < nFtnCnt; ++n ) { - const SwTxtFtn* pTxtFtn = pDoc->GetFtnIdxs()[ n ]; + const SwTxtFtn* pTxtFtn = rDoc.GetFtnIdxs()[ n ]; const SwFmtFtn& rFtn = pTxtFtn->GetFtn(); pTxtFtn = rFtn.GetTxtFtn(); #if OSL_DEBUG_LEVEL > 1 - const SwStartNode* pTmpSttNode = pTxtFtn->GetStartNode()->GetNode(). + const SwStartNode* pTmpSttNode = + pTxtFtn->GetStartNode()->GetNode(). FindSttNodeByType(SwFootnoteStartNode); (void)pTmpSttNode; #endif @@ -1837,11 +1859,12 @@ uno::Reference< XText > SwXTextRange::CreateParentXText(SwDoc* pDoc, if (pSttNode == pTxtFtn->GetStartNode()->GetNode(). FindSttNodeByType(SwFootnoteStartNode)) { - xParentText = ((SwUnoCallBack*)pDoc->GetUnoCallBack())-> + xParentText = + static_cast(rDoc.GetUnoCallBack())-> GetFootnote(rFtn); if (!xParentText.is()) { - xParentText = new SwXFootnote(pDoc, rFtn); + xParentText = new SwXFootnote(&rDoc, rFtn); } break; } @@ -1851,9 +1874,9 @@ uno::Reference< XText > SwXTextRange::CreateParentXText(SwDoc* pDoc, default: { // then it is the body text - uno::Reference xModel = - pDoc->GetDocShell()->GetBaseModel(); - uno::Reference< XTextDocument > xDoc( + const uno::Reference xModel = + rDoc.GetDocShell()->GetBaseModel(); + const uno::Reference< text::XTextDocument > xDoc( xModel, uno::UNO_QUERY); xParentText = xDoc->getText(); } @@ -1862,6 +1885,8 @@ uno::Reference< XText > SwXTextRange::CreateParentXText(SwDoc* pDoc, return xParentText; } +} // namespace sw + uno::Reference< container::XEnumeration > SAL_CALL SwXTextRange::createContentEnumeration(const OUString& rServiceName) throw (uno::RuntimeException) @@ -2168,8 +2193,8 @@ void SwXTextRanges::Impl::MakeRanges() SwPaM *pTmpCursor = pCursor; do { const uno::Reference< text::XTextRange > xRange( - SwXTextRange::CreateTextRangeFromPosition( - pTmpCursor->GetDoc(), + SwXTextRange::CreateXTextRange( + *pTmpCursor->GetDoc(), *pTmpCursor->GetPoint(), pTmpCursor->GetMark())); if (xRange.is()) { diff --git a/sw/source/core/unocore/unoparagraph.cxx b/sw/source/core/unocore/unoparagraph.cxx index 404a93005a19..17336d80f64c 100644 --- a/sw/source/core/unocore/unoparagraph.cxx +++ b/sw/source/core/unocore/unoparagraph.cxx @@ -263,7 +263,7 @@ SwXParagraph::CreateXParagraph(SwDoc & rDoc, SwTxtNode& rTxtNode, if (!xParentText.is()) { SwPosition Pos( rTxtNode ); - xParentText.set(SwXTextRange::CreateParentXText( &rDoc, Pos )); + xParentText.set(::sw::CreateParentXText( rDoc, Pos )); } SwXParagraph *const pXPara( new SwXParagraph(xParentText, rTxtNode, nSelStart, nSelEnd) ); diff --git a/sw/source/core/unocore/unoredline.cxx b/sw/source/core/unocore/unoredline.cxx index 9cfce5c31a62..e1680cabecc2 100644 --- a/sw/source/core/unocore/unoredline.cxx +++ b/sw/source/core/unocore/unoredline.cxx @@ -591,11 +591,8 @@ uno::Any SwXRedline::getPropertyValue( const OUString& rPropertyName ) pPoint = pRedline->GetPoint(); else pPoint = pRedline->GetMark(); - SwPaM aTmp(*pPoint); - uno::Reference xTmpParent; -// uno::Reference< text::XTextRange > xRange = SwXTextRange::createTextRangeFromPaM(aTmp); - uno::ReferencexRange = - SwXTextRange::CreateTextRangeFromPosition( pDoc, *pPoint, 0 ); + const uno::Reference xRange = + SwXTextRange::CreateXTextRange(*pDoc, *pPoint, 0); xRet = xRange.get(); } break; diff --git a/sw/source/core/unocore/unorefmk.cxx b/sw/source/core/unocore/unorefmk.cxx index 68516a923eb7..a0903b6ea145 100644 --- a/sw/source/core/unocore/unorefmk.cxx +++ b/sw/source/core/unocore/unorefmk.cxx @@ -309,7 +309,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException) SwUnoInternalPaM aPam(*pDocument); //das muss jetzt sal_True liefern - SwXTextRange::XTextRangeToSwPaM(aPam, xTextRange); + ::sw::XTextRangeToSwPaM(aPam, xTextRange); m_pImpl->InsertRefMark(aPam, dynamic_cast(pCursor)); m_pImpl->m_bIsDescriptor = sal_False; m_pImpl->m_pDoc = pDocument; @@ -342,8 +342,8 @@ SwXReferenceMark::getAnchor() throw (uno::RuntimeException) rTxtNode, *pTxtMark->GetStart()) : new SwPaM( rTxtNode, *pTxtMark->GetStart()) ); - return SwXTextRange::CreateTextRangeFromPosition( - m_pImpl->m_pDoc, *pPam->Start(), pPam->End()); + return SwXTextRange::CreateXTextRange( + *m_pImpl->m_pDoc, *pPam->Start(), pPam->End()); } } } @@ -820,8 +820,7 @@ SwXMeta::CreateXMeta(::sw::Meta & rMeta, OSL_ENSURE(pTxtAttr, "CreateXMeta: no text attr?"); if (!pTxtAttr) { return 0; } const SwPosition aPos(*pTxtNode, *pTxtAttr->GetStart()); - xParentText.set( - SwXTextRange::CreateParentXText(pTxtNode->GetDoc(), aPos) ); + xParentText.set( ::sw::CreateParentXText(*pTxtNode->GetDoc(), aPos) ); } if (!xParentText.is()) { return 0; } SwXMeta *const pXMeta( (RES_TXTATR_META == rMeta.GetFmtMeta()->Which()) @@ -1072,7 +1071,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException) } SwUnoInternalPaM aPam(*pDoc); - SwXTextRange::XTextRangeToSwPaM(aPam, i_xTextRange); + ::sw::XTextRangeToSwPaM(aPam, i_xTextRange); UnoActionContext aContext(pDoc); @@ -1109,8 +1108,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException) pMeta->Add(m_pImpl.get()); pMeta->SetXMeta(uno::Reference(this)); - m_pImpl->m_xParentText = - SwXTextRange::CreateParentXText(pDoc, *aPam.GetPoint()); + m_pImpl->m_xParentText = ::sw::CreateParentXText(*pDoc, *aPam.GetPoint()); m_pImpl->m_bIsDescriptor = false; } @@ -1153,8 +1151,7 @@ SwXMeta::getAnchor() throw (uno::RuntimeException) const SwPosition start(*pTxtNode, nMetaStart - 1); // -1 due to CH_TXTATR const SwPosition end(*pTxtNode, nMetaEnd); - return SwXTextRange::CreateTextRangeFromPosition( - pTxtNode->GetDoc(), start, &end); + return SwXTextRange::CreateXTextRange(*pTxtNode->GetDoc(), start, &end); } // XTextRange diff --git a/sw/source/core/unocore/unosect.cxx b/sw/source/core/unocore/unosect.cxx index c47a3aef1345..d9d6bafa31a1 100644 --- a/sw/source/core/unocore/unosect.cxx +++ b/sw/source/core/unocore/unosect.cxx @@ -328,7 +328,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException) SwUnoInternalPaM aPam(*pDoc); //das muss jetzt sal_True liefern - SwXTextRange::XTextRangeToSwPaM(aPam, xTextRange); + ::sw::XTextRangeToSwPaM(aPam, xTextRange); UnoActionContext aCont(pDoc); pDoc->StartUndo( UNDO_INSSECTION, NULL ); @@ -488,7 +488,7 @@ SwXTextSection::getAnchor() throw (uno::RuntimeException) const SwEndNode* pEndNode = pIdx->GetNode().EndOfSectionNode(); SwPaM aEnd(*pEndNode); aEnd.Move( fnMoveBackward, fnGoCntnt ); - xRet = SwXTextRange::CreateTextRangeFromPosition(pSectFmt->GetDoc(), + xRet = SwXTextRange::CreateXTextRange(*pSectFmt->GetDoc(), *aPaM.Start(), aEnd.Start()); } } diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index 866c4979072e..6143e7ed2661 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -1062,7 +1062,8 @@ uno::Reference< text::XTextCursor > SwXCell::createTextCursorByRange(const uno: vos::OGuard aGuard(Application::GetSolarMutex()); uno::Reference< text::XTextCursor > aRef; SwUnoInternalPaM aPam(*GetDoc()); - if((pStartNode || IsValid()) && SwXTextRange::XTextRangeToSwPaM(aPam, xTextPosition)) + if ((pStartNode || IsValid()) + && ::sw::XTextRangeToSwPaM(aPam, xTextPosition)) { const SwStartNode* pSttNd = pStartNode ? pStartNode : pBox->GetSttNd(); //skip sections @@ -2468,7 +2469,7 @@ void SwXTextTable::attachToRange(const uno::Reference< text::XTextRange > & xTex { SwUnoInternalPaM aPam(*pDoc); //das muss jetzt sal_True liefern - SwXTextRange::XTextRangeToSwPaM(aPam, xTextRange); + ::sw::XTextRangeToSwPaM(aPam, xTextRange); { UnoActionContext aCont( pDoc ); diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index 023290984ebf..415a3aaf6933 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -382,7 +382,7 @@ void SwXText::insertControlCharacter(const uno::Reference< text::XTextRange > & if (GetDoc()) { SwUnoInternalPaM aPam(*GetDoc()); - if(SwXTextRange::XTextRangeToSwPaM(aPam, xTextRange)) + if (::sw::XTextRangeToSwPaM(aPam, xTextRange)) { const bool bForceExpandHints(CheckForOwnMemberMeta(aPam, bAbsorb)); @@ -504,7 +504,7 @@ void SwXText::insertTextContent(const uno::Reference< text::XTextRange > & xRang if(xRange.is() && xContent.is()) { SwUnoInternalPaM aPam(*GetDoc()); - if(SwXTextRange::XTextRangeToSwPaM(aPam, xRange)) + if (::sw::XTextRangeToSwPaM(aPam, xRange)) { uno::Reference xRangeTunnel( xRange, uno::UNO_QUERY); SwXTextRange* pRange = 0; @@ -1060,8 +1060,8 @@ sal_Int16 SwXText::ComparePositions( SwUnoInternalPaM aPam2(*GetDoc()); BOOL bExcept = FALSE; - if(SwXTextRange::XTextRangeToSwPaM(aPam1, xPos1) && - SwXTextRange::XTextRangeToSwPaM(aPam2, xPos2)) + if (::sw::XTextRangeToSwPaM(aPam1, xPos1) && + ::sw::XTextRangeToSwPaM(aPam2, xPos2)) { uno::Reference xRangeTunnel1( xPos1, uno::UNO_QUERY); SwXTextRange* pRange1 = 0; @@ -1582,8 +1582,8 @@ uno::Reference< text::XTextContent > SwXText::convertToTextFrame( uno::Reference< text::XTextContent > xRet; SwUnoInternalPaM aStartPam(*GetDoc()); std::auto_ptr < SwUnoInternalPaM > pEndPam( new SwUnoInternalPaM(*GetDoc())); - if(SwXTextRange::XTextRangeToSwPaM(aStartPam, xStart) && - SwXTextRange::XTextRangeToSwPaM(*pEndPam, xEnd) ) + if (::sw::XTextRangeToSwPaM(aStartPam, xStart) && + ::sw::XTextRangeToSwPaM(*pEndPam, xEnd)) { uno::Reference xStartRangeTunnel( xStart, uno::UNO_QUERY); SwXTextRange* pStartRange = reinterpret_cast< SwXTextRange * >( @@ -1826,8 +1826,8 @@ uno::Reference< text::XTextTable > SwXText::convertToTable( // !!! TODO - PaMs in tables and sections do not work here - the same applies to PaMs in frames !!! - if(!SwXTextRange::XTextRangeToSwPaM(aStartCellPam, xStartRange) || - !SwXTextRange::XTextRangeToSwPaM(aEndCellPam, xEndRange) ) + if (!::sw::XTextRangeToSwPaM(aStartCellPam, xStartRange) || + !::sw::XTextRangeToSwPaM(aEndCellPam, xEndRange)) throw lang::IllegalArgumentException(); /** check the nodes between start and end it is allowed to have pairs of StartNode/EndNodes @@ -2361,7 +2361,7 @@ uno::Reference< text::XTextCursor > SwXBodyText::createTextCursorByRange( throw aRuntime; } SwUnoInternalPaM aPam(*GetDoc()); - if(SwXTextRange::XTextRangeToSwPaM(aPam, aTextPosition)) + if (::sw::XTextRangeToSwPaM(aPam, aTextPosition)) { SwNode& rNode = GetDoc()->GetNodes().GetEndOfContent(); @@ -2603,7 +2603,7 @@ uno::Reference< text::XTextCursor > SwXHeadFootText::createTextCursorByRange( uno::Reference< text::XTextCursor > xRet; SwFrmFmt* pHeadFootFmt = GetFmt(); SwUnoInternalPaM aPam(*GetDoc()); - if(pHeadFootFmt && SwXTextRange::XTextRangeToSwPaM(aPam, aTextPosition)) + if (pHeadFootFmt && ::sw::XTextRangeToSwPaM(aPam, aTextPosition)) { SwNode& rNode = pHeadFootFmt->GetCntnt().GetCntntIdx()->GetNode(); SwPosition aPos(rNode); diff --git a/sw/source/filter/xml/XMLRedlineImportHelper.cxx b/sw/source/filter/xml/XMLRedlineImportHelper.cxx index 4b89f042977f..bd1dea07179e 100644 --- a/sw/source/filter/xml/XMLRedlineImportHelper.cxx +++ b/sw/source/filter/xml/XMLRedlineImportHelper.cxx @@ -162,7 +162,7 @@ void XTextRangeOrNodeIndexPosition::SetAsNodeIndex( #ifdef DBG_UTIL sal_Bool bSuccess = #endif - SwXTextRange::XTextRangeToSwPaM( aPaM, rRange); + ::sw::XTextRangeToSwPaM(aPaM, rRange); DBG_ASSERT(bSuccess, "illegal range"); // PaM -> Index @@ -180,7 +180,7 @@ void XTextRangeOrNodeIndexPosition::CopyPositionInto(SwPosition& rPos) #ifdef DBG_UTIL sal_Bool bSuccess = #endif - SwXTextRange::XTextRangeToSwPaM(aUnoPaM, xRange); + ::sw::XTextRangeToSwPaM(aUnoPaM, xRange); DBG_ASSERT(bSuccess, "illegal range"); rPos = *aUnoPaM.GetPoint(); diff --git a/sw/source/filter/xml/swxml.cxx b/sw/source/filter/xml/swxml.cxx index d53261ea3fe5..704b6af7fa74 100644 --- a/sw/source/filter/xml/swxml.cxx +++ b/sw/source/filter/xml/swxml.cxx @@ -788,9 +788,8 @@ ULONG XMLReader::Read( SwDoc &rDoc, const String& rBaseURL, SwPaM &rPaM, const S } else if( bInsertMode ) { - uno::Reference xInsertTextRange = - SwXTextRange::CreateTextRangeFromPosition( &rDoc, *rPaM.GetPoint(), - 0 ); + const uno::Reference xInsertTextRange = + SwXTextRange::CreateXTextRange(rDoc, *rPaM.GetPoint(), 0); OUString sTextInsertModeRange( RTL_CONSTASCII_USTRINGPARAM("TextInsertModeRange")); xInfoSet->setPropertyValue( sTextInsertModeRange, diff --git a/sw/source/filter/xml/xmlimp.cxx b/sw/source/filter/xml/xmlimp.cxx index 003318dbe989..9059b98db6b8 100644 --- a/sw/source/filter/xml/xmlimp.cxx +++ b/sw/source/filter/xml/xmlimp.cxx @@ -713,9 +713,9 @@ void SwXMLImport::startDocument( void ) } if( pCrsrSh ) { - Reference xInsertTextRange( - SwXTextRange::CreateTextRangeFromPosition( - pDoc, *pCrsrSh->GetCrsr()->GetPoint(), 0 ) ); + const uno::Reference xInsertTextRange( + SwXTextRange::CreateXTextRange( + *pDoc, *pCrsrSh->GetCrsr()->GetPoint(), 0 ) ); setTextInsertMode( xInsertTextRange ); xTextCursor = GetTextImport()->GetCursor(); pTxtCrsr = 0; diff --git a/sw/source/filter/xml/xmltbli.cxx b/sw/source/filter/xml/xmltbli.cxx index e2b154178b29..0cf164489eb4 100644 --- a/sw/source/filter/xml/xmltbli.cxx +++ b/sw/source/filter/xml/xmltbli.cxx @@ -2926,8 +2926,8 @@ const SwStartNode *SwXMLTableContext::InsertTableSection( SwPosition aPos( *pCNd ); aPos.nContent.Assign( pCNd, 0U ); - Reference < XTextRange > xTextRange = - SwXTextRange::CreateTextRangeFromPosition( pDoc, aPos, 0 ); + const uno::Reference< text::XTextRange > xTextRange = + SwXTextRange::CreateXTextRange( *pDoc, aPos, 0 ); Reference < XText > xText = xTextRange->getText(); Reference < XTextCursor > xTextCursor = xText->createTextCursorByRange( xTextRange ); diff --git a/sw/source/ui/dialog/SwSpellDialogChildWindow.cxx b/sw/source/ui/dialog/SwSpellDialogChildWindow.cxx index 85838652d370..0332dfa7058b 100644 --- a/sw/source/ui/dialog/SwSpellDialogChildWindow.cxx +++ b/sw/source/ui/dialog/SwSpellDialogChildWindow.cxx @@ -258,8 +258,10 @@ svx::SpellPortions SwSpellDialogChildWindow::GetNextWrongSentence (void) //mark the start position only if not at start of doc if(!pWrtShell->IsStartOfDoc()) { - m_pSpellState->m_xStartRange = SwXTextRange::CreateTextRangeFromPosition( - pWrtShell->GetDoc(), *pCrsr->Start(), pCrsr->End()); + m_pSpellState->m_xStartRange = + SwXTextRange::CreateXTextRange( + *pWrtShell->GetDoc(), + *pCrsr->Start(), pCrsr->End()); } pWrtShell->SpellStart( DOCPOS_START, DOCPOS_END, DOCPOS_CURR, FALSE ); } @@ -390,7 +392,8 @@ svx::SpellPortions SwSpellDialogChildWindow::GetNextWrongSentence (void) if(RET_YES == nRet) { SwUnoInternalPaM aPam(*pWrtShell->GetDoc()); - if(SwXTextRange::XTextRangeToSwPaM(aPam, m_pSpellState->m_xStartRange)) + if (::sw::XTextRangeToSwPaM(aPam, + m_pSpellState->m_xStartRange)) { pWrtShell->SetSelection(aPam); pWrtShell->SpellStart(DOCPOS_START, DOCPOS_CURR, DOCPOS_START); diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index 22d683a0f29d..3bb65ea4e900 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -991,11 +991,10 @@ Reference< XInterface > SwXTextDocument::findFirst(const Reference< util::XSear Reference< XInterface > xRet; if(nResult) { - Reference< XTextRange > xTempRange = SwXTextRange::CreateTextRangeFromPosition( - pDocShell->GetDoc(), - *pResultCrsr->GetPoint(), - pResultCrsr->GetMark()); - xRet = *new SwXTextCursor(xTempRange->getText(), pResultCrsr); + const uno::Reference< text::XText > xParent = + ::sw::CreateParentXText(*pDocShell->GetDoc(), + *pResultCrsr->GetPoint()); + xRet = *new SwXTextCursor(xParent, pResultCrsr); delete pResultCrsr; } return xRet; @@ -1019,12 +1018,11 @@ Reference< XInterface > SwXTextDocument::findNext(const Reference< XInterface > Reference< XInterface > xRet; if(nResult) { - Reference< XTextRange > xTempRange = SwXTextRange::CreateTextRangeFromPosition( - pDocShell->GetDoc(), - *pResultCrsr->GetPoint(), - pResultCrsr->GetMark()); + const uno::Reference< text::XText > xParent = + ::sw::CreateParentXText(*pDocShell->GetDoc(), + *pResultCrsr->GetPoint()); - xRet = *new SwXTextCursor(xTempRange->getText(), pResultCrsr); + xRet = *new SwXTextCursor(xParent, pResultCrsr); delete pResultCrsr; } return xRet; diff --git a/sw/source/ui/uno/unotxvw.cxx b/sw/source/ui/uno/unotxvw.cxx index 9e637ca58260..6d001b95f378 100644 --- a/sw/source/ui/uno/unotxvw.cxx +++ b/sw/source/ui/uno/unotxvw.cxx @@ -334,7 +334,7 @@ sal_Bool SwXTextView::select(const uno::Any& aInterface) throw( lang::IllegalArg else if(!pFrame && !pCell && xPos.is()) { SwUnoInternalPaM aPam(*pDoc); - if(SwXTextRange::XTextRangeToSwPaM(aPam, xPos)) + if (::sw::XTextRangeToSwPaM(aPam, xPos)) { pPam = lcl_createPamCopy(aPam); } @@ -1362,7 +1362,7 @@ void SwXTextViewCursor::gotoRange( throw uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "no text selection" ) ), static_cast < cppu::OWeakObject * > ( this ) ); SwUnoInternalPaM rDestPam(*m_pView->GetDocShell()->GetDoc()); - if(!SwXTextRange::XTextRangeToSwPaM( rDestPam, xRange)) + if (!::sw::XTextRangeToSwPaM(rDestPam, xRange)) throw IllegalArgumentException(); ShellModes eSelMode = m_pView->GetShellMode(); @@ -1699,9 +1699,7 @@ uno::Reference< text::XText > SwXTextViewCursor::getText(void) throw( uno::Runt SwWrtShell& rSh = m_pView->GetWrtShell(); SwPaM* pShellCrsr = rSh.GetCrsr(); SwDoc* pDoc = m_pView->GetDocShell()->GetDoc(); - uno::Reference< text::XTextRange > xRg = SwXTextRange::CreateTextRangeFromPosition(pDoc, - *pShellCrsr->Start(), 0); - xRet = xRg->getText(); + xRet = ::sw::CreateParentXText(*pDoc, *pShellCrsr->Start()); } else throw uno::RuntimeException(); @@ -1722,8 +1720,7 @@ uno::Reference< text::XTextRange > SwXTextViewCursor::getStart(void) throw( uno SwWrtShell& rSh = m_pView->GetWrtShell(); SwPaM* pShellCrsr = rSh.GetCrsr(); SwDoc* pDoc = m_pView->GetDocShell()->GetDoc(); - xRet = SwXTextRange::CreateTextRangeFromPosition(pDoc, - *pShellCrsr->Start(), 0); + xRet = SwXTextRange::CreateXTextRange(*pDoc, *pShellCrsr->Start(), 0); } else throw uno::RuntimeException(); @@ -1744,8 +1741,7 @@ uno::Reference< text::XTextRange > SwXTextViewCursor::getEnd(void) throw( uno:: SwWrtShell& rSh = m_pView->GetWrtShell(); SwPaM* pShellCrsr = rSh.GetCrsr(); SwDoc* pDoc = m_pView->GetDocShell()->GetDoc(); - xRet = SwXTextRange::CreateTextRangeFromPosition(pDoc, - *pShellCrsr->End(), 0); + xRet = SwXTextRange::CreateXTextRange(*pDoc, *pShellCrsr->End(), 0); } else throw uno::RuntimeException(); -- cgit From 0a3b5f8b3edacaf2e58de0b661077683e5973db5 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 8 Jan 2010 17:13:54 +0100 Subject: swunolocking1: #i105557#: fix locking for SwXParaFrameEnumeration: add Impl struct, and use UnoImplPtr to lock destructor. move all implementation details out of header, into Impl struct. replace PARAFRAME_PORTION_ macros with an enum. use new XServiceInfo helpers. clean up the implementation a little. --- sw/inc/unoparaframeenum.hxx | 29 ++-- sw/source/core/unocore/unoobj2.cxx | 271 +++++++++++++++++++++---------------- 2 files changed, 165 insertions(+), 135 deletions(-) (limited to 'sw') diff --git a/sw/inc/unoparaframeenum.hxx b/sw/inc/unoparaframeenum.hxx index d05fccfed46d..7e5b43f1e637 100644 --- a/sw/inc/unoparaframeenum.hxx +++ b/sw/inc/unoparaframeenum.hxx @@ -42,13 +42,12 @@ #include -#include -#include +#include +class SwDepend; class SwNodeIndex; class SwPaM; -class SwUnoCrsr; class SwFrmFmt; @@ -80,10 +79,12 @@ void CollectFrameAtNode( SwClient& rClnt, const SwNodeIndex& rIdx, * * --------------------------------------------------*/ -#define PARAFRAME_PORTION_PARAGRAPH 0 -#define PARAFRAME_PORTION_CHAR 1 -#define PARAFRAME_PORTION_TEXTRANGE 2 - +enum ParaFrameMode +{ + PARAFRAME_PORTION_PARAGRAPH, + PARAFRAME_PORTION_CHAR, + PARAFRAME_PORTION_TEXTRANGE, +}; typedef ::cppu::WeakImplHelper2 < ::com::sun::star::lang::XServiceInfo @@ -92,27 +93,19 @@ typedef ::cppu::WeakImplHelper2 class SwXParaFrameEnumeration : public SwXParaFrameEnumeration_Base - , public SwClient { private: - ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > - m_xNextObject; // created by hasMoreElements - FrameDependList_t m_Frames; - - SwUnoCrsr* GetCursor() const - {return static_cast(const_cast(GetRegisteredIn()));} + class Impl; + ::sw::UnoImplPtr m_pImpl; virtual ~SwXParaFrameEnumeration(); public: SwXParaFrameEnumeration(const SwPaM& rPaM, - sal_uInt8 nParaFrameMode, SwFrmFmt* pFmt = 0); - - // SwClient - virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + const enum ParaFrameMode eParaFrameMode, SwFrmFmt *const pFmt = 0); // XServiceInfo virtual ::rtl::OUString SAL_CALL getImplementationName() diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index 0027d8ef0b02..1f53b5130e51 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -2359,6 +2359,68 @@ void SwXTextCursor::SetString(SwCursor& rCrsr, const OUString& rString) * SwXParaFrameEnumeration ******************************************************************/ +class SwXParaFrameEnumeration::Impl + : public SwClient +{ + +public: + + // created by hasMoreElements + uno::Reference< text::XTextContent > m_xNextObject; + FrameDependList_t m_Frames; + + Impl(SwPaM const & rPaM) + : SwClient(rPaM.GetDoc()->CreateUnoCrsr(*rPaM.GetPoint(), sal_False)) + { + if (rPaM.HasMark()) + { + GetCursor()->SetMark(); + *GetCursor()->GetMark() = *rPaM.GetMark(); + } + } + + ~Impl() { + // Impl owns the cursor; delete it here: SolarMutex is locked + delete GetRegisteredIn(); + } + + SwUnoCrsr * GetCursor() { + return static_cast( + const_cast(GetRegisteredIn())); + } + + // SwClient + virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + +}; + +/*-- 23.03.99 13:22:37--------------------------------------------------- + + -----------------------------------------------------------------------*/ + +struct InvalidFrameDepend { + bool operator() (::boost::shared_ptr const & rEntry) + { return !rEntry->GetRegisteredIn(); } +}; + +void SwXParaFrameEnumeration::Impl::Modify(SfxPoolItem *pOld, SfxPoolItem *pNew) +{ + ClientModify(this, pOld, pNew); + if(!GetRegisteredIn()) + { + m_Frames.clear(); + m_xNextObject = 0; + } + else + { + // check if any frame went away... + FrameDependList_t::iterator const iter = + ::std::remove_if(m_Frames.begin(), m_Frames.end(), + InvalidFrameDepend()); + m_Frames.erase(iter, m_Frames.end()); + } +} + /* -----------------23.03.99 13:38------------------- * * --------------------------------------------------*/ @@ -2370,7 +2432,7 @@ lcl_CreateNextObject(SwUnoCrsr& i_rUnoCrsr, if (!i_rFrames.size()) return sal_False; - SwFrmFmt* pFormat = static_cast(const_cast( + SwFrmFmt *const pFormat = static_cast(const_cast( i_rFrames.front()->GetRegisteredIn())); i_rFrames.pop_front(); // the format should be valid here, otherwise the client @@ -2391,7 +2453,7 @@ lcl_CreateNextObject(SwUnoCrsr& i_rUnoCrsr, { const SwNodeIndex* pIdx = pFormat->GetCntnt().GetCntntIdx(); DBG_ASSERT(pIdx, "where is the index?"); - const SwNode* pNd = + SwNode const*const pNd = i_rUnoCrsr.GetDoc()->GetNodes()[ pIdx->GetIndex() + 1 ]; const FlyCntType eType = (!pNd->IsNoTxtNode()) ? FLYCNTTYPE_FRM @@ -2410,11 +2472,12 @@ lcl_CreateNextObject(SwUnoCrsr& i_rUnoCrsr, and fill the frame into the array ---------------------------------------------------------------------------*/ static void -lcl_FillFrame(SwXParaFrameEnumeration & rEnum, SwUnoCrsr& rUnoCrsr, +lcl_FillFrame(SwClient & rEnum, SwUnoCrsr& rUnoCrsr, FrameDependList_t & rFrames) { // search for objects at the cursor - anchored at/as char - const SwTxtAttr * pTxtAttr = rUnoCrsr.GetNode()->GetTxtNode()->GetTxtAttr( + SwTxtAttr const*const pTxtAttr = + rUnoCrsr.GetNode()->GetTxtNode()->GetTxtAttr( rUnoCrsr.GetPoint()->nContent, RES_TXTATR_FLYCNT); if (pTxtAttr) { @@ -2425,93 +2488,64 @@ lcl_FillFrame(SwXParaFrameEnumeration & rEnum, SwUnoCrsr& rUnoCrsr, } } -/* -----------------------------06.04.00 16:39-------------------------------- - - ---------------------------------------------------------------------------*/ -OUString SwXParaFrameEnumeration::getImplementationName() -throw( RuntimeException ) -{ - return C2U("SwXParaFrameEnumeration"); -} -/* -----------------------------06.04.00 16:39-------------------------------- - - ---------------------------------------------------------------------------*/ -sal_Bool SwXParaFrameEnumeration::supportsService(const OUString& rServiceName) -throw( RuntimeException ) -{ - return C2U("com.sun.star.util.ContentEnumeration") == rServiceName; -} -/* -----------------------------06.04.00 16:39-------------------------------- - - ---------------------------------------------------------------------------*/ -Sequence< OUString > SwXParaFrameEnumeration::getSupportedServiceNames() -throw( RuntimeException ) -{ - Sequence< OUString > aRet(1); - OUString* pArray = aRet.getArray(); - pArray[0] = C2U("com.sun.star.util.ContentEnumeration"); - return aRet; -} /*-- 23.03.99 13:22:29--------------------------------------------------- -----------------------------------------------------------------------*/ -SwXParaFrameEnumeration::SwXParaFrameEnumeration(const SwPaM& rPaM, - sal_uInt8 nParaFrameMode, - SwFrmFmt* pFmt) +SwXParaFrameEnumeration::SwXParaFrameEnumeration( + const SwPaM& rPaM, const enum ParaFrameMode eParaFrameMode, + SwFrmFmt *const pFmt) + : m_pImpl( new SwXParaFrameEnumeration::Impl(rPaM) ) { - SwDoc* pDoc = rPaM.GetDoc(); - SwUnoCrsr* pUnoCrsr = pDoc->CreateUnoCrsr(*rPaM.GetPoint(), sal_False); - if (rPaM.HasMark()) - { - pUnoCrsr->SetMark(); - *pUnoCrsr->GetMark() = *rPaM.GetMark(); - } - pUnoCrsr->Add(this); - - if (PARAFRAME_PORTION_PARAGRAPH == nParaFrameMode) + if (PARAFRAME_PORTION_PARAGRAPH == eParaFrameMode) { FrameDependSortList_t frames; - ::CollectFrameAtNode( *this, rPaM.GetPoint()->nNode, frames, false ); + ::CollectFrameAtNode(*m_pImpl.get(), rPaM.GetPoint()->nNode, + frames, false); ::std::transform(frames.begin(), frames.end(), - ::std::back_inserter(m_Frames), + ::std::back_inserter(m_pImpl->m_Frames), ::boost::bind(&FrameDependSortListEntry::pFrameDepend, _1)); } else if (pFmt) { - //jetzt einen SwDepend anlegen und in das Array einfuegen - SwDepend* pNewDepend = new SwDepend(this, pFmt); - m_Frames.push_back( ::boost::shared_ptr(pNewDepend) ); + // create SwDepend for frame and insert into array + SwDepend *const pNewDepend = new SwDepend(m_pImpl.get(), pFmt); + m_pImpl->m_Frames.push_back(::boost::shared_ptr(pNewDepend)); } - else if((PARAFRAME_PORTION_CHAR == nParaFrameMode) || - (PARAFRAME_PORTION_TEXTRANGE == nParaFrameMode)) + else if ((PARAFRAME_PORTION_CHAR == eParaFrameMode) || + (PARAFRAME_PORTION_TEXTRANGE == eParaFrameMode)) { - if(PARAFRAME_PORTION_TEXTRANGE == nParaFrameMode) + if (PARAFRAME_PORTION_TEXTRANGE == eParaFrameMode) { SwPosFlyFrms aFlyFrms; //get all frames that are bound at paragraph or at character - pDoc->GetAllFlyFmts(aFlyFrms, pUnoCrsr);//, bDraw); + rPaM.GetDoc()->GetAllFlyFmts(aFlyFrms, m_pImpl->GetCursor()); for(USHORT i = 0; i < aFlyFrms.Count(); i++) { SwPosFlyFrm* pPosFly = aFlyFrms[i]; - SwFrmFmt* pFrmFmt = (SwFrmFmt*)&pPosFly->GetFmt(); - //jetzt einen SwDepend anlegen und in das Array einfuegen - SwDepend* pNewDepend = new SwDepend(this, pFrmFmt); - m_Frames.push_back( ::boost::shared_ptr(pNewDepend) ); + SwFrmFmt *const pFrmFmt = + const_cast(&pPosFly->GetFmt()); + // create SwDepend for frame and insert into array + SwDepend *const pNewDepend = + new SwDepend(m_pImpl.get(), pFrmFmt); + m_pImpl->m_Frames.push_back( + ::boost::shared_ptr(pNewDepend) ); } //created from any text range - if(pUnoCrsr->HasMark()) + if (m_pImpl->GetCursor()->HasMark()) { - if(pUnoCrsr->Start() != pUnoCrsr->GetPoint()) - pUnoCrsr->Exchange(); + m_pImpl->GetCursor()->Normalize(); do { - lcl_FillFrame(*this, *pUnoCrsr, m_Frames); - pUnoCrsr->Right(1, CRSR_SKIP_CHARS, FALSE, FALSE); + lcl_FillFrame(*m_pImpl.get(), *m_pImpl->GetCursor(), + m_pImpl->m_Frames); + m_pImpl->GetCursor()->Right( + 1, CRSR_SKIP_CHARS, FALSE, FALSE); } - while(*pUnoCrsr->GetPoint() < *pUnoCrsr->GetMark()); + while (*m_pImpl->GetCursor()->GetPoint() < + *m_pImpl->GetCursor()->GetMark()); } } - lcl_FillFrame(*this, *pUnoCrsr, m_Frames); + lcl_FillFrame(*m_pImpl.get(), *m_pImpl->GetCursor(), m_pImpl->m_Frames); } } /*-- 23.03.99 13:22:30--------------------------------------------------- @@ -2519,89 +2553,92 @@ SwXParaFrameEnumeration::SwXParaFrameEnumeration(const SwPaM& rPaM, -----------------------------------------------------------------------*/ SwXParaFrameEnumeration::~SwXParaFrameEnumeration() { - vos::OGuard aGuard(Application::GetSolarMutex()); - - SwUnoCrsr* pUnoCrsr = GetCursor(); - delete pUnoCrsr; } /*-- 23.03.99 13:22:32--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXParaFrameEnumeration::hasMoreElements() -throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXParaFrameEnumeration::hasMoreElements() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - if (!GetCursor()) + if (!m_pImpl->GetCursor()) throw uno::RuntimeException(); - return m_xNextObject.is() ? sal_True : - lcl_CreateNextObject(*GetCursor(), m_xNextObject, m_Frames); + return (m_pImpl->m_xNextObject.is()) + ? sal_True + : lcl_CreateNextObject(*m_pImpl->GetCursor(), + m_pImpl->m_xNextObject, m_pImpl->m_Frames); } /*-- 23.03.99 13:22:33--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Any SwXParaFrameEnumeration::nextElement() - throw( container::NoSuchElementException, - lang::WrappedTargetException, uno::RuntimeException ) +uno::Any SAL_CALL SwXParaFrameEnumeration::nextElement() +throw (container::NoSuchElementException, + lang::WrappedTargetException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - if (!GetCursor()) + if (!m_pImpl->GetCursor()) + { throw uno::RuntimeException(); + } - if (!m_xNextObject.is() && m_Frames.size()) + if (!m_pImpl->m_xNextObject.is() && m_pImpl->m_Frames.size()) { - lcl_CreateNextObject(*GetCursor(), m_xNextObject, m_Frames); + lcl_CreateNextObject(*m_pImpl->GetCursor(), + m_pImpl->m_xNextObject, m_pImpl->m_Frames); } - if(!m_xNextObject.is()) + if (!m_pImpl->m_xNextObject.is()) + { throw container::NoSuchElementException(); - uno::Any aRet(&m_xNextObject, - ::getCppuType((uno::Reference*)0)); - m_xNextObject = 0; + } + uno::Any aRet; + aRet <<= m_pImpl->m_xNextObject; + m_pImpl->m_xNextObject = 0; return aRet; } -struct InvalidFrameDepend { - bool operator() (::boost::shared_ptr const & rEntry) - { return !rEntry->GetRegisteredIn(); } -}; +/* -----------------------------06.04.00 16:39-------------------------------- -/*-- 23.03.99 13:22:37--------------------------------------------------- + ---------------------------------------------------------------------------*/ +OUString SAL_CALL +SwXParaFrameEnumeration::getImplementationName() throw (uno::RuntimeException) +{ + return C2U("SwXParaFrameEnumeration"); +} - -----------------------------------------------------------------------*/ -void SwXParaFrameEnumeration::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew) +/* -----------------------------06.04.00 16:39-------------------------------- + + ---------------------------------------------------------------------------*/ +static char const*const g_ServicesParaFrameEnum[] = { - switch( pOld ? pOld->Which() : 0 ) - { - case RES_REMOVE_UNO_OBJECT: - case RES_OBJECTDYING: - if( (void*)GetRegisteredIn() == ((SwPtrMsgPoolItem *)pOld)->pObject ) - ((SwModify*)GetRegisteredIn())->Remove(this); - break; + "com.sun.star.util.ContentEnumeration", +}; +static const size_t g_nServicesParaFrameEnum( + sizeof(g_ServicesParaFrameEnum)/sizeof(g_ServicesParaFrameEnum[0])); - case RES_FMT_CHG: - // wurden wir an das neue umgehaengt und wird das alte geloscht? - if( ((SwFmtChg*)pNew)->pChangedFmt == GetRegisteredIn() && - ((SwFmtChg*)pOld)->pChangedFmt->IsFmtInDTOR() ) - ((SwModify*)GetRegisteredIn())->Remove(this); - break; - } - if(!GetRegisteredIn()) - { - m_Frames.clear(); - m_xNextObject = 0; - } - else - { - // check if any frame went away... - FrameDependList_t::iterator iter = - ::std::remove_if(m_Frames.begin(), m_Frames.end(), - InvalidFrameDepend()); - m_Frames.erase(iter, m_Frames.end()); - } +sal_Bool SAL_CALL +SwXParaFrameEnumeration::supportsService(const OUString& rServiceName) +throw (uno::RuntimeException) +{ + return ::sw::SupportsServiceImpl( + g_nServicesParaFrameEnum, g_ServicesParaFrameEnum, rServiceName); +} + +/* -----------------------------06.04.00 16:39-------------------------------- + + ---------------------------------------------------------------------------*/ +uno::Sequence< OUString > SAL_CALL +SwXParaFrameEnumeration::getSupportedServiceNames() +throw (uno::RuntimeException) +{ + return ::sw::GetSupportedServiceNamesImpl( + g_nServicesParaFrameEnum, g_ServicesParaFrameEnum); } + + // ----------------------------------------------------------------------------- IMPLEMENT_FORWARD_REFCOUNT( SwXTextCursor,SwXTextCursor_Base ) -- cgit From 2245100b4ac33d68ba6033871e22c3573bc10047 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 8 Jan 2010 17:13:54 +0100 Subject: swunolocking1: #i105557#: SwXTextCursor: move implementation of all non-static methods into unoobj.cxx. --- sw/source/core/unocore/unoobj.cxx | 603 +++++++++++++++++++++++++++++++++++++ sw/source/core/unocore/unoobj2.cxx | 512 ------------------------------- 2 files changed, 603 insertions(+), 512 deletions(-) (limited to 'sw') diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx index b48451b90cf9..a0b08fffc879 100644 --- a/sw/source/core/unocore/unoobj.cxx +++ b/sw/source/core/unocore/unoobj.cxx @@ -31,9 +31,11 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" +#include #include #include +#include #include #include #include @@ -115,6 +117,7 @@ #define _SVSTDARR_USHORTSSORT #include #include +#include #include #include #include @@ -122,6 +125,8 @@ #include #include #include +#include +#include using namespace ::com::sun::star; @@ -708,6 +713,96 @@ SwFmtColl* SwXTextCursor::GetCurTxtFmtColl(SwPaM& rPaM, BOOL bConditional) * SwXTextCursor ******************************************************************/ +/*-- 09.12.98 14:19:00--------------------------------------------------- + + -----------------------------------------------------------------------*/ +IMPL_STATIC_LINK( SwXTextCursor, RemoveCursor_Impl, + uno::Reference< XInterface >*, EMPTYARG ) +{ + ASSERT( pThis != NULL, "no reference?" ); + //ASSERT( pArg != NULL, "no reference?" ); + + // --> FME 2006-03-07 #126177# Tell the SwXTextCursor that the user event + // has been executed. It is not necessary to remove the user event in + // ~SwXTextCursor + pThis->DoNotRemoveUserEvent(); + // <-- + + SwUnoCrsr* pCursor = pThis->GetCrsr(); + if( pCursor != NULL ) + { + pCursor->Remove( pThis ); + delete pCursor; + } + + // --> FME 2006-03-07 #126177# + //delete pArg; + // <-- + + return 0; +} + +void SwXTextCursor::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew) +{ + ClientModify(this, pOld, pNew); + + // if the cursor leaves its designated section, it becomes invalid + if( !mbRemoveUserEvent && ( pOld != NULL ) && ( pOld->Which() == RES_UNOCURSOR_LEAVES_SECTION ) ) + { + // --> FME 2006-03-07 #126177# We don't need to create a reference + // to the SwXTextCursor to prevent its deletion. If the destructor + // of the SwXTextCursor is called before the user event is executed, + // the user event will be removed. This is necessary, because an other + // thread might be currently waiting in ~SwXTextCursor. In this case + // the pRef = new ... stuff did not work! + + // create reference to this object to prevent deletion before + // the STATIC_LINK is executed. The link will delete the + // reference. + //uno::Reference* pRef = + //new uno::Reference( static_cast( this ) ); + + mbRemoveUserEvent = true; + // <-- + + mnUserEventId = Application::PostUserEvent( + STATIC_LINK( this, SwXTextCursor, RemoveCursor_Impl ), this ); + } + + if(!GetRegisteredIn()) + aLstnrCntnr.Disposing(); + +} + +/*-- 09.12.98 14:19:01--------------------------------------------------- + + -----------------------------------------------------------------------*/ +const SwPaM* SwXTextCursor::GetPaM() const +{ + return GetCrsr() ? GetCrsr() : 0; +} + +SwPaM* SwXTextCursor::GetPaM() +{ + return GetCrsr() ? GetCrsr() : 0; +} + +/*-- 09.12.98 14:19:02--------------------------------------------------- + + -----------------------------------------------------------------------*/ +const SwDoc* SwXTextCursor::GetDoc()const +{ + return GetCrsr() ? GetCrsr()->GetDoc() : 0; +} +/* -----------------22.07.99 13:52------------------- + + --------------------------------------------------*/ +SwDoc* SwXTextCursor::GetDoc() +{ + return GetCrsr() ? GetCrsr()->GetDoc() : 0; +} + + /*-- 09.12.98 14:19:19--------------------------------------------------- -----------------------------------------------------------------------*/ @@ -2447,3 +2542,511 @@ void SwXTextCursor::makeRedline( else throw uno::RuntimeException(); } + +/*-- 09.12.98 14:18:58--------------------------------------------------- + + -----------------------------------------------------------------------*/ +void SAL_CALL SwXTextCursor::insertDocumentFromURL(const OUString& rURL, + const uno::Sequence< beans::PropertyValue >& rOptions) +throw (lang::IllegalArgumentException, io::IOException, + uno::RuntimeException) +{ + vos::OGuard aGuard(Application::GetSolarMutex()); + + SwUnoCrsr* pUnoCrsr = GetCrsr(); + if (!pUnoCrsr) + { + throw uno::RuntimeException(); + } + SwUnoCursorHelper::InsertFile(pUnoCrsr, rURL, rOptions); +} + +/* -----------------------------15.12.00 14:01-------------------------------- + + ---------------------------------------------------------------------------*/ +uno::Sequence< beans::PropertyValue > +SwXTextCursor::createSortDescriptor(sal_Bool bFromTable) +{ + uno::Sequence< beans::PropertyValue > aRet(5); + beans::PropertyValue* pArray = aRet.getArray(); + + uno::Any aVal; + aVal.setValue( &bFromTable, ::getCppuBooleanType()); + pArray[0] = beans::PropertyValue(C2U("IsSortInTable"), -1, aVal, + beans::PropertyState_DIRECT_VALUE); + + String sSpace(String::CreateFromAscii(" ")); + sal_Unicode uSpace = sSpace.GetChar(0); + + aVal <<= uSpace; + pArray[1] = beans::PropertyValue(C2U("Delimiter"), -1, aVal, + beans::PropertyState_DIRECT_VALUE); + + aVal <<= (sal_Bool) sal_False; + pArray[2] = beans::PropertyValue(C2U("IsSortColumns"), -1, aVal, + beans::PropertyState_DIRECT_VALUE); + + aVal <<= (sal_Int32) 3; + pArray[3] = beans::PropertyValue(C2U("MaxSortFieldsCount"), -1, aVal, + beans::PropertyState_DIRECT_VALUE); + + uno::Sequence< table::TableSortField > aFields(3); + table::TableSortField* pFields = aFields.getArray(); + + Locale aLang( SvxCreateLocale( LANGUAGE_SYSTEM ) ); + // get collator algorithm to be used for the locale + uno::Sequence< OUString > aSeq( + GetAppCollator().listCollatorAlgorithms( aLang ) ); + INT32 nLen = aSeq.getLength(); + DBG_ASSERT( nLen > 0, "list of collator algorithms is empty!"); + OUString aCollAlg; + if (nLen > 0) + aCollAlg = aSeq.getConstArray()[0]; + +#if OSL_DEBUG_LEVEL > 1 + const OUString *pTxt = aSeq.getConstArray(); + (void)pTxt; +#endif + + pFields[0].Field = 1; + pFields[0].IsAscending = sal_True; + pFields[0].IsCaseSensitive = sal_False; + pFields[0].FieldType = table::TableSortFieldType_ALPHANUMERIC; + pFields[0].CollatorLocale = aLang; + pFields[0].CollatorAlgorithm = aCollAlg; + + pFields[1].Field = 1; + pFields[1].IsAscending = sal_True; + pFields[1].IsCaseSensitive = sal_False; + pFields[1].FieldType = table::TableSortFieldType_ALPHANUMERIC; + pFields[1].CollatorLocale = aLang; + pFields[1].CollatorAlgorithm = aCollAlg; + + pFields[2].Field = 1; + pFields[2].IsAscending = sal_True; + pFields[2].IsCaseSensitive = sal_False; + pFields[2].FieldType = table::TableSortFieldType_ALPHANUMERIC; + pFields[2].CollatorLocale = aLang; + pFields[2].CollatorAlgorithm = aCollAlg; + + aVal <<= aFields; + pArray[4] = beans::PropertyValue(C2U("SortFields"), -1, aVal, + beans::PropertyState_DIRECT_VALUE); + + return aRet; +} + +/*-- 09.12.98 14:18:58--------------------------------------------------- + + -----------------------------------------------------------------------*/ +uno::Sequence< beans::PropertyValue > SAL_CALL +SwXTextCursor::createSortDescriptor() throw (uno::RuntimeException) +{ + vos::OGuard aGuard(Application::GetSolarMutex()); + return SwXTextCursor::createSortDescriptor(sal_False); +} + +/* -----------------------------15.12.00 14:06-------------------------------- + + ---------------------------------------------------------------------------*/ +sal_Bool SwXTextCursor::convertSortProperties( + const uno::Sequence< beans::PropertyValue >& rDescriptor, + SwSortOptions& rSortOpt) +{ + sal_Bool bRet = sal_True; + const beans::PropertyValue* pProperties = rDescriptor.getConstArray(); + + rSortOpt.bTable = sal_False; + rSortOpt.cDeli = ' '; + rSortOpt.eDirection = SRT_COLUMNS; //!! UI text may be contrary though !! + + SwSortKey* pKey1 = new SwSortKey; + pKey1->nColumnId = USHRT_MAX; + pKey1->bIsNumeric = TRUE; + pKey1->eSortOrder = SRT_ASCENDING; + + SwSortKey* pKey2 = new SwSortKey; + pKey2->nColumnId = USHRT_MAX; + pKey2->bIsNumeric = TRUE; + pKey2->eSortOrder = SRT_ASCENDING; + + SwSortKey* pKey3 = new SwSortKey; + pKey3->nColumnId = USHRT_MAX; + pKey3->bIsNumeric = TRUE; + pKey3->eSortOrder = SRT_ASCENDING; + SwSortKey* aKeys[3] = {pKey1, pKey2, pKey3}; + + sal_Bool bOldSortdescriptor(sal_False); + sal_Bool bNewSortdescriptor(sal_False); + + for (int n = 0; n < rDescriptor.getLength(); ++n) + { + uno::Any aValue( pProperties[n].Value ); +// String sPropName = pProperties[n].Name; + const OUString& rPropName = pProperties[n].Name; + + // old and new sortdescriptor + if (COMPARE_EQUAL == rPropName.compareToAscii("IsSortInTable")) + { + if (aValue.getValueType() == ::getBooleanCppuType()) + { + rSortOpt.bTable = *(sal_Bool*)aValue.getValue(); + } + else + { + bRet = sal_False; + } + } + else if (COMPARE_EQUAL == rPropName.compareToAscii("Delimiter")) + { + sal_Unicode uChar = sal_Unicode(); + if (aValue >>= uChar) + { + rSortOpt.cDeli = uChar; + } + else + { + bRet = sal_False; + } + } + // old sortdescriptor + else if (COMPARE_EQUAL == rPropName.compareToAscii("SortColumns")) + { + bOldSortdescriptor = sal_True; + if (aValue.getValueType() == ::getBooleanCppuType()) + { + sal_Bool bTemp = *(sal_Bool*)aValue.getValue(); + rSortOpt.eDirection = bTemp ? SRT_COLUMNS : SRT_ROWS; + } + else + { + bRet = sal_False; + } + } + else if (COMPARE_EQUAL == rPropName.compareToAscii("IsCaseSensitive")) + { + bOldSortdescriptor = sal_True; + if (aValue.getValueType() == ::getBooleanCppuType()) + { + sal_Bool bTemp = *(sal_Bool*)aValue.getValue(); + rSortOpt.bIgnoreCase = !bTemp; + } + else + { + bRet = sal_False; + } + } + else if (COMPARE_EQUAL == rPropName.compareToAscii("CollatorLocale")) + { + bOldSortdescriptor = sal_True; + Locale aLocale; + if (aValue >>= aLocale) + { + rSortOpt.nLanguage = SvxLocaleToLanguage( aLocale ); + } + else + { + bRet = sal_False; + } + } + else if (COMPARE_EQUAL == rPropName.compareToAscii("CollatorAlgorithm", + 17) && + rPropName.getLength() == 18 && + (rPropName.getStr()[17] >= '0' && rPropName.getStr()[17] <= '9')) + { + bOldSortdescriptor = sal_True; + sal_uInt16 nIndex = rPropName.getStr()[17]; + nIndex -= '0'; + OUString aTxt; + if ((aValue >>= aTxt) && nIndex < 3) + { + aKeys[nIndex]->sSortType = aTxt; + } + else + { + bRet = sal_False; + } + } + else if (COMPARE_EQUAL == rPropName.compareToAscii("SortRowOrColumnNo", + 17) && + rPropName.getLength() == 18 && + (rPropName.getStr()[17] >= '0' && rPropName.getStr()[17] <= '9')) + { + bOldSortdescriptor = sal_True; + sal_uInt16 nIndex = rPropName.getStr()[17]; + nIndex -= '0'; + sal_Int16 nCol = -1; + if (aValue.getValueType() == ::getCppuType((const sal_Int16*)0) + && nIndex < 3) + { + aValue >>= nCol; + } + if (nCol >= 0) + { + aKeys[nIndex]->nColumnId = nCol; + } + else + { + bRet = sal_False; + } + } + else if (0 == rPropName.indexOf(C2U("IsSortNumeric")) && + rPropName.getLength() == 14 && + (rPropName.getStr()[13] >= '0' && rPropName.getStr()[13] <= '9')) + { + bOldSortdescriptor = sal_True; + sal_uInt16 nIndex = rPropName.getStr()[13]; + nIndex = nIndex - '0'; + if (aValue.getValueType() == ::getBooleanCppuType() && nIndex < 3) + { + sal_Bool bTemp = *(sal_Bool*)aValue.getValue(); + aKeys[nIndex]->bIsNumeric = bTemp; + } + else + { + bRet = sal_False; + } + } + else if (0 == rPropName.indexOf(C2U("IsSortAscending")) && + rPropName.getLength() == 16 && + (rPropName.getStr()[15] >= '0' && rPropName.getStr()[15] <= '9')) + { + bOldSortdescriptor = sal_True; + sal_uInt16 nIndex = rPropName.getStr()[15]; + nIndex -= '0'; + if (aValue.getValueType() == ::getBooleanCppuType() && nIndex < 3) + { + sal_Bool bTemp = *(sal_Bool*)aValue.getValue(); + aKeys[nIndex]->eSortOrder = (bTemp) + ? SRT_ASCENDING : SRT_DESCENDING; + } + else + { + bRet = sal_False; + } + } + // new sortdescriptor + else if (COMPARE_EQUAL == rPropName.compareToAscii("IsSortColumns")) + { + bNewSortdescriptor = sal_True; + if (aValue.getValueType() == ::getBooleanCppuType()) + { + sal_Bool bTemp = *(sal_Bool*)aValue.getValue(); + rSortOpt.eDirection = bTemp ? SRT_COLUMNS : SRT_ROWS; + } + else + { + bRet = sal_False; + } + } + else if (COMPARE_EQUAL == rPropName.compareToAscii("SortFields")) + { + bNewSortdescriptor = sal_True; + uno::Sequence < table::TableSortField > aFields; + if (aValue >>= aFields) + { + sal_Int32 nCount(aFields.getLength()); + if (nCount <= 3) + { + table::TableSortField* pFields = aFields.getArray(); + for (sal_Int32 i = 0; i < nCount; ++i) + { + rSortOpt.bIgnoreCase = !pFields[i].IsCaseSensitive; + rSortOpt.nLanguage = + SvxLocaleToLanguage( pFields[i].CollatorLocale ); + aKeys[i]->sSortType = pFields[i].CollatorAlgorithm; + aKeys[i]->nColumnId = + static_cast(pFields[i].Field); + aKeys[i]->bIsNumeric = (pFields[i].FieldType == + table::TableSortFieldType_NUMERIC); + aKeys[i]->eSortOrder = (pFields[i].IsAscending) + ? SRT_ASCENDING : SRT_DESCENDING; + } + } + else + { + bRet = sal_False; + } + } + else + { + bRet = sal_False; + } + } + } + + if (bNewSortdescriptor && bOldSortdescriptor) + { + DBG_ERROR("someone tried to set the old deprecated and " + "the new sortdescriptor"); + bRet = sal_False; + } + + if (pKey1->nColumnId != USHRT_MAX) + { + rSortOpt.aKeys.C40_INSERT(SwSortKey, pKey1, rSortOpt.aKeys.Count()); + } + if (pKey2->nColumnId != USHRT_MAX) + { + rSortOpt.aKeys.C40_INSERT(SwSortKey, pKey2, rSortOpt.aKeys.Count()); + } + if (pKey3->nColumnId != USHRT_MAX) + { + rSortOpt.aKeys.C40_INSERT(SwSortKey, pKey3, rSortOpt.aKeys.Count()); + } + + return bRet && rSortOpt.aKeys.Count() > 0; +} + +/*-- 09.12.98 14:19:00--------------------------------------------------- + + -----------------------------------------------------------------------*/ +void SAL_CALL +SwXTextCursor::sort(const uno::Sequence< beans::PropertyValue >& rDescriptor) +throw (uno::RuntimeException) +{ + vos::OGuard aGuard(Application::GetSolarMutex()); + + SwSortOptions aSortOpt; + SwUnoCrsr* pUnoCrsr = GetCrsr(); + + if (!pUnoCrsr) + { + throw uno::RuntimeException(); + } + + if (pUnoCrsr->HasMark()) + { + if (!SwXTextCursor::convertSortProperties(rDescriptor, aSortOpt)) + { + throw uno::RuntimeException(); + } + UnoActionContext aContext( pUnoCrsr->GetDoc() ); + + SwPosition* pStart = pUnoCrsr->Start(); + SwPosition* pEnd = pUnoCrsr->End(); + + SwNodeIndex aPrevIdx( pStart->nNode, -1 ); + ULONG nOffset = pEnd->nNode.GetIndex() - pStart->nNode.GetIndex(); + xub_StrLen nCntStt = pStart->nContent.GetIndex(); + + pUnoCrsr->GetDoc()->SortText(*pUnoCrsr, aSortOpt); + + // Selektion wieder setzen + pUnoCrsr->DeleteMark(); + pUnoCrsr->GetPoint()->nNode.Assign( aPrevIdx.GetNode(), +1 ); + SwCntntNode* pCNd = pUnoCrsr->GetCntntNode(); + xub_StrLen nLen = pCNd->Len(); + if (nLen > nCntStt) + { + nLen = nCntStt; + } + pUnoCrsr->GetPoint()->nContent.Assign(pCNd, nLen ); + pUnoCrsr->SetMark(); + + pUnoCrsr->GetPoint()->nNode += nOffset; + pCNd = pUnoCrsr->GetCntntNode(); + pUnoCrsr->GetPoint()->nContent.Assign( pCNd, pCNd->Len() ); + } +} + +/* -----------------------------03.04.00 09:11-------------------------------- + + ---------------------------------------------------------------------------*/ +uno::Reference< container::XEnumeration > SAL_CALL +SwXTextCursor::createContentEnumeration(const OUString& rServiceName) +throw (uno::RuntimeException) +{ + SwUnoCrsr* pUnoCrsr = GetCrsr(); + if (!pUnoCrsr || + 0 != rServiceName.compareToAscii("com.sun.star.text.TextContent")) + { + throw uno::RuntimeException(); + } + + uno::Reference< container::XEnumeration > xRet = + new SwXParaFrameEnumeration(*pUnoCrsr, PARAFRAME_PORTION_TEXTRANGE); + return xRet; +} + +/* -----------------------------07.03.01 14:53-------------------------------- + + ---------------------------------------------------------------------------*/ +uno::Reference< container::XEnumeration > SAL_CALL +SwXTextCursor::createEnumeration() throw (uno::RuntimeException) +{ + SwUnoCrsr* pUnoCrsr = GetCrsr(); + if (!pUnoCrsr) + { + throw uno::RuntimeException(); + } + uno::Reference xTunnel(xParentText, UNO_QUERY); + SwXText* pParentText = 0; + if (xTunnel.is()) + { + pParentText = reinterpret_cast< SwXText *>( + sal::static_int_cast< sal_IntPtr >( + xTunnel->getSomething(SwXText::getUnoTunnelId()) )); + } + DBG_ASSERT(pParentText, "parent is not a SwXText"); + if (!pParentText) + { + throw uno::RuntimeException(); + } + + ::std::auto_ptr pNewCrsr( + pUnoCrsr->GetDoc()->CreateUnoCrsr(*pUnoCrsr->GetPoint()) ); + if (pUnoCrsr->HasMark()) + { + pNewCrsr->SetMark(); + *pNewCrsr->GetMark() = *pUnoCrsr->GetMark(); + } + const CursorType eSetType = (CURSOR_TBLTEXT == eType) + ? CURSOR_SELECTION_IN_TABLE : CURSOR_SELECTION; + const uno::Reference< XEnumeration > xRet = + new SwXParagraphEnumeration(pParentText, pNewCrsr, eSetType); + + return xRet; +} + +/* -----------------------------07.03.01 15:43-------------------------------- + + ---------------------------------------------------------------------------*/ +uno::Type SAL_CALL +SwXTextCursor::getElementType() throw (uno::RuntimeException) +{ + return ::getCppuType((uno::Reference*)0); +} + +/* -----------------------------07.03.01 15:43-------------------------------- + + ---------------------------------------------------------------------------*/ +sal_Bool SAL_CALL SwXTextCursor::hasElements() throw (uno::RuntimeException) +{ + return sal_True; +} + +/* -----------------------------03.04.00 09:11-------------------------------- + + ---------------------------------------------------------------------------*/ +uno::Sequence< OUString > SAL_CALL +SwXTextCursor::getAvailableServiceNames() throw (uno::RuntimeException) +{ + uno::Sequence< OUString > aRet(1); + OUString* pArray = aRet.getArray(); + pArray[0] = OUString::createFromAscii("com.sun.star.text.TextContent"); + return aRet; +} + +// --------------------------------------------------------------------------- +IMPLEMENT_FORWARD_REFCOUNT( SwXTextCursor,SwXTextCursor_Base ) + +uno::Any SAL_CALL +SwXTextCursor::queryInterface(const uno::Type& rType) +throw (uno::RuntimeException) +{ + return (rType == lang::XUnoTunnel::static_type()) + ? OTextCursorHelper::queryInterface(rType) + : SwXTextCursor_Base::queryInterface(rType); +} + diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index 1f53b5130e51..a71fe16f7024 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -94,7 +94,6 @@ #include #include #include -#include #include #include #include @@ -106,8 +105,6 @@ #include #include #include -#include -#include #include #include #include @@ -336,342 +333,6 @@ UnoActionRemoveContext::~UnoActionRemoveContext() } -/*-- 09.12.98 14:18:58--------------------------------------------------- - - -----------------------------------------------------------------------*/ -void SwXTextCursor::insertDocumentFromURL(const OUString& rURL, - const uno::Sequence< beans::PropertyValue >& rOptions) - throw( lang::IllegalArgumentException, io::IOException, uno::RuntimeException ) -{ - vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) - { - SwUnoCursorHelper::InsertFile(pUnoCrsr, rURL, rOptions); - } - else - throw uno::RuntimeException(); -} -/* -----------------------------15.12.00 14:01-------------------------------- - - ---------------------------------------------------------------------------*/ -uno::Sequence< beans::PropertyValue > SwXTextCursor::createSortDescriptor(sal_Bool bFromTable) -{ - uno::Sequence< beans::PropertyValue > aRet(5); - beans::PropertyValue* pArray = aRet.getArray(); - - uno::Any aVal; - aVal.setValue( &bFromTable, ::getCppuBooleanType()); - pArray[0] = beans::PropertyValue(C2U("IsSortInTable"), -1, aVal, beans::PropertyState_DIRECT_VALUE); - - String sSpace(String::CreateFromAscii(" ")); - sal_Unicode uSpace = sSpace.GetChar(0); - - aVal <<= uSpace; - pArray[1] = beans::PropertyValue(C2U("Delimiter"), -1, aVal, beans::PropertyState_DIRECT_VALUE); - - aVal <<= (sal_Bool) sal_False; - pArray[2] = beans::PropertyValue(C2U("IsSortColumns"), -1, aVal, beans::PropertyState_DIRECT_VALUE); - - aVal <<= (sal_Int32) 3; - pArray[3] = beans::PropertyValue(C2U("MaxSortFieldsCount"), -1, aVal, beans::PropertyState_DIRECT_VALUE); - - uno::Sequence< table::TableSortField > aFields(3); - table::TableSortField* pFields = aFields.getArray(); - - Locale aLang( SvxCreateLocale( LANGUAGE_SYSTEM ) ); - // get collator algorithm to be used for the locale - Sequence < OUString > aSeq( GetAppCollator().listCollatorAlgorithms( aLang ) ); - INT32 nLen = aSeq.getLength(); - DBG_ASSERT( nLen > 0, "list of collator algorithms is empty!"); - OUString aCollAlg; - if (nLen > 0) - aCollAlg = aSeq.getConstArray()[0]; - -#if OSL_DEBUG_LEVEL > 1 - const OUString *pTxt = aSeq.getConstArray(); - (void)pTxt; -#endif - - pFields[0].Field = 1; - pFields[0].IsAscending = sal_True; - pFields[0].IsCaseSensitive = sal_False; - pFields[0].FieldType = table::TableSortFieldType_ALPHANUMERIC; - pFields[0].CollatorLocale = aLang; - pFields[0].CollatorAlgorithm = aCollAlg; - - pFields[1].Field = 1; - pFields[1].IsAscending = sal_True; - pFields[1].IsCaseSensitive = sal_False; - pFields[1].FieldType = table::TableSortFieldType_ALPHANUMERIC; - pFields[1].CollatorLocale = aLang; - pFields[1].CollatorAlgorithm = aCollAlg; - - pFields[2].Field = 1; - pFields[2].IsAscending = sal_True; - pFields[2].IsCaseSensitive = sal_False; - pFields[2].FieldType = table::TableSortFieldType_ALPHANUMERIC; - pFields[2].CollatorLocale = aLang; - pFields[2].CollatorAlgorithm = aCollAlg; - - aVal <<= aFields; - pArray[4] = beans::PropertyValue(C2U("SortFields"), -1, aVal, beans::PropertyState_DIRECT_VALUE); - - return aRet; -} - -/*-- 09.12.98 14:18:58--------------------------------------------------- - - -----------------------------------------------------------------------*/ -uno::Sequence< beans::PropertyValue > SwXTextCursor::createSortDescriptor(void) throw( uno::RuntimeException ) -{ - vos::OGuard aGuard(Application::GetSolarMutex()); - return SwXTextCursor::createSortDescriptor(sal_False); -} -/* -----------------------------15.12.00 14:06-------------------------------- - - ---------------------------------------------------------------------------*/ -sal_Bool SwXTextCursor::convertSortProperties( - const uno::Sequence< beans::PropertyValue >& rDescriptor, SwSortOptions& rSortOpt) -{ - sal_Bool bRet = sal_True; - const beans::PropertyValue* pProperties = rDescriptor.getConstArray(); - - rSortOpt.bTable = sal_False; - rSortOpt.cDeli = ' '; - rSortOpt.eDirection = SRT_COLUMNS; //!! UI text may be contrary though !! - - SwSortKey* pKey1 = new SwSortKey; - pKey1->nColumnId = USHRT_MAX; - pKey1->bIsNumeric = TRUE; - pKey1->eSortOrder = SRT_ASCENDING; - - SwSortKey* pKey2 = new SwSortKey; - pKey2->nColumnId = USHRT_MAX; - pKey2->bIsNumeric = TRUE; - pKey2->eSortOrder = SRT_ASCENDING; - - SwSortKey* pKey3 = new SwSortKey; - pKey3->nColumnId = USHRT_MAX; - pKey3->bIsNumeric = TRUE; - pKey3->eSortOrder = SRT_ASCENDING; - SwSortKey* aKeys[3] = {pKey1, pKey2, pKey3}; - - sal_Bool bOldSortdescriptor(sal_False); - sal_Bool bNewSortdescriptor(sal_False); - - for( int n = 0; n < rDescriptor.getLength(); ++n ) - { - uno::Any aValue( pProperties[n].Value ); -// String sPropName = pProperties[n].Name; - const OUString& rPropName = pProperties[n].Name; - - // old and new sortdescriptor - if( COMPARE_EQUAL == rPropName.compareToAscii("IsSortInTable")) - { - if ( aValue.getValueType() == ::getBooleanCppuType() ) - rSortOpt.bTable = *(sal_Bool*)aValue.getValue(); - else - bRet = sal_False; - } - else if(COMPARE_EQUAL == rPropName.compareToAscii("Delimiter")) - { - sal_Unicode uChar = sal_Unicode(); - if( aValue >>= uChar ) - rSortOpt.cDeli = uChar; - else - bRet = sal_False; - } - // old sortdescriptor - else if(COMPARE_EQUAL == rPropName.compareToAscii("SortColumns")) - { - bOldSortdescriptor = sal_True; - if ( aValue.getValueType() == ::getBooleanCppuType() ) - { - sal_Bool bTemp = *(sal_Bool*)aValue.getValue(); - rSortOpt.eDirection = bTemp ? SRT_COLUMNS : SRT_ROWS; - } - else - bRet = sal_False; - } - else if(COMPARE_EQUAL == rPropName.compareToAscii("IsCaseSensitive")) - { - bOldSortdescriptor = sal_True; - if ( aValue.getValueType() == ::getBooleanCppuType() ) - { - sal_Bool bTemp = *(sal_Bool*)aValue.getValue(); - rSortOpt.bIgnoreCase = !bTemp; - } - else - bRet = sal_False; - } - else if(COMPARE_EQUAL == rPropName.compareToAscii("CollatorLocale")) - { - bOldSortdescriptor = sal_True; - Locale aLocale; - if (aValue >>= aLocale) - rSortOpt.nLanguage = SvxLocaleToLanguage( aLocale ); - else - bRet = sal_False; - } - else if(COMPARE_EQUAL == rPropName.compareToAscii("CollatorAlgorithm", 17) && - rPropName.getLength() == 18 && - (rPropName.getStr()[17] >= '0' && rPropName.getStr()[17] <= '9')) - { - bOldSortdescriptor = sal_True; - sal_uInt16 nIndex = rPropName.getStr()[17]; - nIndex -= '0'; - OUString aTxt; - if ((aValue >>= aTxt) && nIndex < 3) - aKeys[nIndex]->sSortType = aTxt; - else - bRet = sal_False; - } - else if(COMPARE_EQUAL == rPropName.compareToAscii("SortRowOrColumnNo", 17) && - rPropName.getLength() == 18 && - (rPropName.getStr()[17] >= '0' && rPropName.getStr()[17] <= '9')) - { - bOldSortdescriptor = sal_True; - sal_uInt16 nIndex = rPropName.getStr()[17]; - nIndex -= '0'; - sal_Int16 nCol = -1; - if( aValue.getValueType() == ::getCppuType((const sal_Int16*)0) && nIndex < 3) - aValue >>= nCol; - if( nCol >= 0 ) - aKeys[nIndex]->nColumnId = nCol; - else - bRet = sal_False; - } - else if(0 == rPropName.indexOf(C2U("IsSortNumeric")) && - rPropName.getLength() == 14 && - (rPropName.getStr()[13] >= '0' && rPropName.getStr()[13] <= '9')) - { - bOldSortdescriptor = sal_True; - sal_uInt16 nIndex = rPropName.getStr()[13]; - nIndex = nIndex - '0'; - if ( aValue.getValueType() == ::getBooleanCppuType() && nIndex < 3 ) - { - sal_Bool bTemp = *(sal_Bool*)aValue.getValue(); - aKeys[nIndex]->bIsNumeric = bTemp; - } - else - bRet = sal_False; - } - else if(0 == rPropName.indexOf(C2U("IsSortAscending")) && - rPropName.getLength() == 16 && - (rPropName.getStr()[15] >= '0' && rPropName.getStr()[15] <= '9')) - { - bOldSortdescriptor = sal_True; - sal_uInt16 nIndex = rPropName.getStr()[15]; - nIndex -= '0'; - if ( aValue.getValueType() == ::getBooleanCppuType() && nIndex < 3 ) - { - sal_Bool bTemp = *(sal_Bool*)aValue.getValue(); - aKeys[nIndex]->eSortOrder = bTemp ? SRT_ASCENDING : SRT_DESCENDING; - } - else - bRet = sal_False; - } - // new sortdescriptor - else if(COMPARE_EQUAL == rPropName.compareToAscii("IsSortColumns")) - { - bNewSortdescriptor = sal_True; - if ( aValue.getValueType() == ::getBooleanCppuType() ) - { - sal_Bool bTemp = *(sal_Bool*)aValue.getValue(); - rSortOpt.eDirection = bTemp ? SRT_COLUMNS : SRT_ROWS; - } - else - bRet = sal_False; - } - else if (COMPARE_EQUAL == rPropName.compareToAscii("SortFields")) - { - bNewSortdescriptor = sal_True; - uno::Sequence < table::TableSortField > aFields; - if ( aValue >>= aFields ) - { - sal_Int32 nCount(aFields.getLength()); - if (nCount <= 3) - { - table::TableSortField* pFields = aFields.getArray(); - for (sal_Int32 i = 0; i < nCount; ++i) - { - rSortOpt.bIgnoreCase = !pFields[i].IsCaseSensitive; - rSortOpt.nLanguage = SvxLocaleToLanguage( pFields[i].CollatorLocale ); - aKeys[i]->sSortType = pFields[i].CollatorAlgorithm; - aKeys[i]->nColumnId = static_cast< USHORT >(pFields[i].Field); - aKeys[i]->bIsNumeric = (pFields[i].FieldType == table::TableSortFieldType_NUMERIC); - aKeys[i]->eSortOrder = pFields[i].IsAscending ? SRT_ASCENDING : SRT_DESCENDING; - } - } - else - bRet = sal_False; - } - else - bRet = sal_False; - } - } - - if (bNewSortdescriptor && bOldSortdescriptor) - { - DBG_ERROR("someone tried to set the old deprecated and the new sortdescriptor"); - bRet = sal_False; - } - - if(pKey1->nColumnId != USHRT_MAX) - rSortOpt.aKeys.C40_INSERT(SwSortKey, pKey1, rSortOpt.aKeys.Count()); - if(pKey2->nColumnId != USHRT_MAX) - rSortOpt.aKeys.C40_INSERT(SwSortKey, pKey2, rSortOpt.aKeys.Count()); - if(pKey3->nColumnId != USHRT_MAX) - rSortOpt.aKeys.C40_INSERT(SwSortKey, pKey3, rSortOpt.aKeys.Count()); - - return bRet && rSortOpt.aKeys.Count() > 0; -} -/*-- 09.12.98 14:19:00--------------------------------------------------- - - -----------------------------------------------------------------------*/ -void SwXTextCursor::sort(const uno::Sequence< beans::PropertyValue >& rDescriptor) - throw( uno::RuntimeException ) -{ - vos::OGuard aGuard(Application::GetSolarMutex()); - SwSortOptions aSortOpt; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - - if(pUnoCrsr) - { - if(pUnoCrsr->HasMark()) - { - if(!SwXTextCursor::convertSortProperties(rDescriptor, aSortOpt)) - throw uno::RuntimeException(); - UnoActionContext aContext( pUnoCrsr->GetDoc() ); - - SwPosition* pStart = pUnoCrsr->Start(); - SwPosition* pEnd = pUnoCrsr->End(); - - SwNodeIndex aPrevIdx( pStart->nNode, -1 ); - ULONG nOffset = pEnd->nNode.GetIndex() - pStart->nNode.GetIndex(); - xub_StrLen nCntStt = pStart->nContent.GetIndex(); - - pUnoCrsr->GetDoc()->SortText(*pUnoCrsr, aSortOpt); - - // Selektion wieder setzen - pUnoCrsr->DeleteMark(); - pUnoCrsr->GetPoint()->nNode.Assign( aPrevIdx.GetNode(), +1 ); - SwCntntNode* pCNd = pUnoCrsr->GetCntntNode(); - xub_StrLen nLen = pCNd->Len(); - if( nLen > nCntStt ) - nLen = nCntStt; - pUnoCrsr->GetPoint()->nContent.Assign(pCNd, nLen ); - pUnoCrsr->SetMark(); - - pUnoCrsr->GetPoint()->nNode += nOffset; - pCNd = pUnoCrsr->GetCntntNode(); - pUnoCrsr->GetPoint()->nContent.Assign( pCNd, pCNd->Len() ); - } - } - else - throw uno::RuntimeException(); -} /*-- 10.12.98 11:52:15--------------------------------------------------- -----------------------------------------------------------------------*/ @@ -694,166 +355,6 @@ void ClientModify(SwClient* pClient, SfxPoolItem *pOld, SfxPoolItem *pNew) } } -/* -----------------------------03.04.00 09:11-------------------------------- - - ---------------------------------------------------------------------------*/ -uno::Reference< XEnumeration > SAL_CALL SwXTextCursor::createContentEnumeration(const OUString& rServiceName) throw( RuntimeException ) -{ - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if( !pUnoCrsr || 0 != rServiceName.compareToAscii("com.sun.star.text.TextContent") ) - throw RuntimeException(); - - uno::Reference< XEnumeration > xRet = new SwXParaFrameEnumeration(*pUnoCrsr, PARAFRAME_PORTION_TEXTRANGE); - return xRet; -} -/* -----------------------------07.03.01 14:53-------------------------------- - - ---------------------------------------------------------------------------*/ -uno::Reference< XEnumeration > SwXTextCursor::createEnumeration(void) throw( RuntimeException ) -{ - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if( !pUnoCrsr ) - throw RuntimeException(); - uno::Reference xTunnel(xParentText, UNO_QUERY); - SwXText* pParentText = 0; - if(xTunnel.is()) - { - pParentText = reinterpret_cast< SwXText *>( - sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething(SwXText::getUnoTunnelId()) )); - } - DBG_ASSERT(pParentText, "parent is not a SwXText"); - if (!pParentText) - { - throw uno::RuntimeException(); - } - - ::std::auto_ptr pNewCrsr( - pUnoCrsr->GetDoc()->CreateUnoCrsr(*pUnoCrsr->GetPoint()) ); - if(pUnoCrsr->HasMark()) - { - pNewCrsr->SetMark(); - *pNewCrsr->GetMark() = *pUnoCrsr->GetMark(); - } - const CursorType eSetType = (CURSOR_TBLTEXT == eType) - ? CURSOR_SELECTION_IN_TABLE : CURSOR_SELECTION; - const uno::Reference< XEnumeration > xRet = - new SwXParagraphEnumeration(pParentText, pNewCrsr, eSetType); - - return xRet; -} -/* -----------------------------07.03.01 15:43-------------------------------- - - ---------------------------------------------------------------------------*/ -uno::Type SwXTextCursor::getElementType(void) throw( RuntimeException ) -{ - return ::getCppuType((uno::Reference*)0); -} -/* -----------------------------07.03.01 15:43-------------------------------- - - ---------------------------------------------------------------------------*/ -sal_Bool SwXTextCursor::hasElements(void) throw( RuntimeException ) -{ - return sal_True; -} -/* -----------------------------03.04.00 09:11-------------------------------- - - ---------------------------------------------------------------------------*/ -Sequence< OUString > SAL_CALL SwXTextCursor::getAvailableServiceNames(void) throw( RuntimeException ) -{ - Sequence< OUString > aRet(1); - OUString* pArray = aRet.getArray(); - pArray[0] = OUString::createFromAscii("com.sun.star.text.TextContent"); - return aRet; -} -/*-- 09.12.98 14:19:00--------------------------------------------------- - - -----------------------------------------------------------------------*/ - -IMPL_STATIC_LINK( SwXTextCursor, RemoveCursor_Impl, - uno::Reference< XInterface >*, EMPTYARG ) -{ - ASSERT( pThis != NULL, "no reference?" ); - //ASSERT( pArg != NULL, "no reference?" ); - - // --> FME 2006-03-07 #126177# Tell the SwXTextCursor that the user event - // has been executed. It is not necessary to remove the user event in - // ~SwXTextCursor - pThis->DoNotRemoveUserEvent(); - // <-- - - SwUnoCrsr* pCursor = pThis->GetCrsr(); - if( pCursor != NULL ) - { - pCursor->Remove( pThis ); - delete pCursor; - } - - // --> FME 2006-03-07 #126177# - //delete pArg; - // <-- - - return 0; -} - -void SwXTextCursor::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew) -{ - ClientModify(this, pOld, pNew); - - // if the cursor leaves its designated section, it becomes invalid - if( !mbRemoveUserEvent && ( pOld != NULL ) && ( pOld->Which() == RES_UNOCURSOR_LEAVES_SECTION ) ) - { - // --> FME 2006-03-07 #126177# We don't need to create a reference - // to the SwXTextCursor to prevent its deletion. If the destructor - // of the SwXTextCursor is called before the user event is executed, - // the user event will be removed. This is necessary, because an other - // thread might be currently waiting in ~SwXTextCursor. In this case - // the pRef = new ... stuff did not work! - - // create reference to this object to prevent deletion before - // the STATIC_LINK is executed. The link will delete the - // reference. - //uno::Reference* pRef = - //new uno::Reference( static_cast( this ) ); - - mbRemoveUserEvent = true; - // <-- - - mnUserEventId = Application::PostUserEvent( - STATIC_LINK( this, SwXTextCursor, RemoveCursor_Impl ), this ); - } - - if(!GetRegisteredIn()) - aLstnrCntnr.Disposing(); - -} -/*-- 09.12.98 14:19:01--------------------------------------------------- - - -----------------------------------------------------------------------*/ -const SwPaM* SwXTextCursor::GetPaM() const -{ - return GetCrsr() ? GetCrsr() : 0; -} -// ----------------------------------------------------------------------------- -SwPaM* SwXTextCursor::GetPaM() -{ - return GetCrsr() ? GetCrsr() : 0; -} - -/*-- 09.12.98 14:19:02--------------------------------------------------- - - -----------------------------------------------------------------------*/ -const SwDoc* SwXTextCursor::GetDoc()const -{ - return GetCrsr() ? GetCrsr()->GetDoc() : 0; -} -/* -----------------22.07.99 13:52------------------- - - --------------------------------------------------*/ -SwDoc* SwXTextCursor::GetDoc() -{ - return GetCrsr() ? GetCrsr()->GetDoc() : 0; -} - /*-- 09.12.98 14:19:03--------------------------------------------------- @@ -2638,16 +2139,3 @@ throw (uno::RuntimeException) g_nServicesParaFrameEnum, g_ServicesParaFrameEnum); } - -// ----------------------------------------------------------------------------- -IMPLEMENT_FORWARD_REFCOUNT( SwXTextCursor,SwXTextCursor_Base ) - -uno::Any SAL_CALL SwXTextCursor::queryInterface( const uno::Type& _rType ) throw (uno::RuntimeException) -{ - if( _rType == ::getCppuType( (uno::Reference*)0) ) - return OTextCursorHelper::queryInterface( _rType ); - else - return SwXTextCursor_Base::queryInterface( _rType ); -} - - -- cgit From aa16ebadc706825e9884378ba41b311eaad069b9 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 8 Jan 2010 17:13:54 +0100 Subject: swunolocking1: #i105557#: SwXTextCursor: move enum SwGetPropertyStatesCaller to unocrsrhelper.hxx. move static methods of SwXTextCursor to namespace SwUnoCursorHelper. move various not-actually-local functions with declarations in multiple cxx files to namespace SwUnoCursorHelper. clean up the implementation a little. --- sw/inc/unocrsrhelper.hxx | 111 +++- sw/inc/unotextcursor.hxx | 84 --- sw/source/core/access/accpara.cxx | 4 +- sw/source/core/edit/editsh.cxx | 4 +- sw/source/core/unocore/SwXTextDefaults.cxx | 11 +- sw/source/core/unocore/unocrsrhelper.cxx | 12 +- sw/source/core/unocore/unoobj.cxx | 991 +++++++++++++++++------------ sw/source/core/unocore/unoobj2.cxx | 168 +++-- sw/source/core/unocore/unoparagraph.cxx | 17 +- sw/source/core/unocore/unoport.cxx | 23 +- sw/source/core/unocore/unoportenum.cxx | 4 +- sw/source/core/unocore/unosect.cxx | 2 +- sw/source/core/unocore/unotbl.cxx | 59 +- sw/source/core/unocore/unotext.cxx | 22 +- sw/source/ui/uno/unotxvw.cxx | 31 +- 15 files changed, 862 insertions(+), 681 deletions(-) (limited to 'sw') diff --git a/sw/inc/unocrsrhelper.hxx b/sw/inc/unocrsrhelper.hxx index 613a5e51eb89..b7e92df88b30 100644 --- a/sw/inc/unocrsrhelper.hxx +++ b/sw/inc/unocrsrhelper.hxx @@ -30,12 +30,25 @@ #ifndef _UNOCRSRHELPER_HXX #define _UNOCRSRHELPER_HXX -#include -#include #include +#include +#include + +#include +#include + + +class String; +class SfxItemSet; +class SfxItemPropertySet; struct SfxItemPropertySimpleEntry; +class SwTxtNode; class SwPaM; +class SwCursor; +class SwUnoCrsr; +class SwFmtColl; +struct SwSortOptions; class SwDoc; namespace com{ namespace sun{ namespace star{ @@ -47,6 +60,17 @@ namespace com{ namespace sun{ namespace star{ } }}} +/* -----------------03.12.98 12:16------------------- + * + * --------------------------------------------------*/ +enum SwGetPropertyStatesCaller +{ + SW_PROPERTY_STATE_CALLER_DEFAULT, + SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION, + SW_PROPERTY_STATE_CALLER_SINGLE_VALUE_ONLY, + SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION_TOLERANT +}; + /* -----------------------------14.12.00 15:06-------------------------------- ---------------------------------------------------------------------------*/ @@ -62,6 +86,7 @@ namespace SwUnoCursorHelper void SetValue( USHORT nWhichId, USHORT nMemberId, const com::sun::star::uno::Any& rAny ); bool FillValue( USHORT nWhichId, USHORT nMemberId, const com::sun::star::uno::Any*& pAny ); }; + sal_Bool getCrsrPropertyValue(const SfxItemPropertySimpleEntry& rEntry , SwPaM& rPam , com::sun::star::uno::Any *pAny @@ -102,6 +127,88 @@ namespace SwUnoCursorHelper const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& RedlineProperties ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + + /// @param bTableMode: attributes should be applied to a table selection + void SetCrsrAttr(SwPaM & rPam, const SfxItemSet & rSet, + const SetAttrMode nAttrMode, + const bool bTableMode = false); + void GetCrsrAttr(SwPaM & rPam, SfxItemSet & rSet, + const bool bOnlyTxtAttr = false, + const bool bGetFromChrFmt = true); + void GetTextFromPam(SwPaM & rPam, ::rtl::OUString & rBuffer); + SwFmtColl * GetCurTxtFmtColl(SwPaM & rPam, const bool bConditional); + + void SelectPam(SwPaM & rPam, const bool bExpand); + void SetString(SwCursor & rCursor, const ::rtl::OUString & rString); + + ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > + CreateSortDescriptor(const bool bFromTable); + sal_Bool ConvertSortProperties( + const ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue >& rDescriptor, + SwSortOptions & rSortOpt); + + /// @param bTableMode: attributes should be applied to a table selection + void SetPropertyValue( + SwPaM& rPaM, + const SfxItemPropertySet & rPropSet, + const ::rtl::OUString & rPropertyName, + const ::com::sun::star::uno::Any & rValue, + const SetAttrMode nAttrMode = nsSetAttrMode::SETATTR_DEFAULT, + const bool bTableMode = false) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::beans::PropertyVetoException, + ::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + ::com::sun::star::uno::Any GetPropertyValue( + SwPaM& rPaM, + const SfxItemPropertySet & rPropSet, + const ::rtl::OUString & rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyState > GetPropertyStates( + SwPaM & rPaM, + const SfxItemPropertySet & rPropSet, + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& + rPropertyNames, + const SwGetPropertyStatesCaller eCaller = + SW_PROPERTY_STATE_CALLER_DEFAULT) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::uno::RuntimeException); + ::com::sun::star::beans::PropertyState GetPropertyState( + SwPaM & rPaM, + const SfxItemPropertySet & rPropSet, + const ::rtl::OUString & rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::uno::RuntimeException); + void SetPropertyToDefault( + SwPaM & rPaM, + const SfxItemPropertySet & rPropSet, + const ::rtl::OUString & rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::uno::RuntimeException); + ::com::sun::star::uno::Any GetPropertyDefault( + SwPaM & rPaM, + const SfxItemPropertySet & rPropSet, + const ::rtl::OUString & rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + + bool SetPageDesc( + const ::com::sun::star::uno::Any& rValue, + SwDoc & rDoc, SfxItemSet & rSet); + void SetTxtFmtColl(const ::com::sun::star::uno::Any & rAny, SwPaM & rPaM) + throw (::com::sun::star::lang::IllegalArgumentException); + bool SetCursorPropertyValue( + SfxItemPropertySimpleEntry const& rEntry, + ::com::sun::star::uno::Any const& rValue, + SwPaM & rPam, SfxItemSet & rItemSet) + throw (::com::sun::star::lang::IllegalArgumentException); + } // namespace SwUnoCursorHelper #endif diff --git a/sw/inc/unotextcursor.hxx b/sw/inc/unotextcursor.hxx index ce91bd295267..fe9b2602180f 100644 --- a/sw/inc/unotextcursor.hxx +++ b/sw/inc/unotextcursor.hxx @@ -58,32 +58,13 @@ #include -class SfxItemSet; class SfxItemPropertySet; class SwDoc; struct SwPosition; -class SwCursor; class SwUnoCrsr; -class SwFmtColl; struct SwSortOptions; -/* -----------------03.12.98 12:16------------------- - * - * --------------------------------------------------*/ -enum SwGetPropertyStatesCaller -{ - SW_PROPERTY_STATE_CALLER_DEFAULT, - SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION, - SW_PROPERTY_STATE_CALLER_SINGLE_VALUE_ONLY, - SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION_TOLERANT -}; - -/// attributes should be applied to a table selection -#define CRSR_ATTR_MODE_TABLE 1 -/// attributes should be added, not replaced -#define CRSR_ATTR_MODE_DONTREPLACE 2 - typedef ::cppu::WeakImplHelper12 < ::com::sun::star::lang::XServiceInfo , ::com::sun::star::beans::XPropertySet @@ -152,71 +133,6 @@ public: void DeleteAndInsert(const String& rText, const bool bForceExpandHints); - static void SetCrsrAttr(SwPaM& rPam, const SfxItemSet& rSet, - USHORT nAttrMode); - static void GetCrsrAttr( SwPaM& rPam, SfxItemSet& rSet, - BOOL bOnlyTxtAttr = FALSE, BOOL bGetFromChrFmt = TRUE ); - static void getTextFromPam(SwPaM& aCrsr, ::rtl::OUString& rBuffer); - static SwFmtColl* GetCurTxtFmtColl(SwPaM& rPam, BOOL bConditional); - - static void SelectPam(SwPaM& rCrsr, sal_Bool bExpand); - static void SetString(SwCursor& rCrsr, const ::rtl::OUString& rString); - - static ::com::sun::star::uno::Sequence< - ::com::sun::star::beans::PropertyValue > - createSortDescriptor(sal_Bool bFromTable); - static sal_Bool convertSortProperties( - const ::com::sun::star::uno::Sequence< - ::com::sun::star::beans::PropertyValue >& rDescriptor, - SwSortOptions& rSortOpt); - - static void SetPropertyValue( - SwPaM& rPaM, - const SfxItemPropertySet& rPropSet, - const ::rtl::OUString& rPropertyName, - const ::com::sun::star::uno::Any& aValue, - USHORT nAttrMode = 0) - throw (::com::sun::star::beans::UnknownPropertyException, - ::com::sun::star::beans::PropertyVetoException, - ::com::sun::star::lang::IllegalArgumentException, - ::com::sun::star::lang::WrappedTargetException, - ::com::sun::star::uno::RuntimeException); - static ::com::sun::star::uno::Any GetPropertyValue( - SwPaM& rPaM, - const SfxItemPropertySet& rPropSet, - const ::rtl::OUString& rPropertyName) - throw (::com::sun::star::beans::UnknownPropertyException, - ::com::sun::star::lang::WrappedTargetException, - ::com::sun::star::uno::RuntimeException); - static ::com::sun::star::uno::Sequence< - ::com::sun::star::beans::PropertyState > GetPropertyStates( - SwPaM& rPaM, - const SfxItemPropertySet& rPropSet, - const ::com::sun::star::uno::Sequence< ::rtl::OUString >& - rPropertyNames, - SwGetPropertyStatesCaller eCaller=SW_PROPERTY_STATE_CALLER_DEFAULT) - throw (::com::sun::star::beans::UnknownPropertyException, - ::com::sun::star::uno::RuntimeException); - static ::com::sun::star::beans::PropertyState GetPropertyState( - SwPaM& rPaM, - const SfxItemPropertySet& rPropSet, - const ::rtl::OUString& rPropertyName) - throw (::com::sun::star::beans::UnknownPropertyException, - ::com::sun::star::uno::RuntimeException); - static void SetPropertyToDefault( - SwPaM& rPaM, - const SfxItemPropertySet& rPropSet, - const ::rtl::OUString& rPropertyName) - throw (::com::sun::star::beans::UnknownPropertyException, - ::com::sun::star::uno::RuntimeException); - static ::com::sun::star::uno::Any GetPropertyDefault( - SwPaM& rPaM, - const SfxItemPropertySet& rPropSet, - const ::rtl::OUString& rPropertyName) - throw (::com::sun::star::beans::UnknownPropertyException, - ::com::sun::star::lang::WrappedTargetException, - ::com::sun::star::uno::RuntimeException); - virtual const SwPaM* GetPaM() const; virtual SwPaM* GetPaM(); virtual const SwDoc* GetDoc() const; diff --git a/sw/source/core/access/accpara.cxx b/sw/source/core/access/accpara.cxx index 950a0d3fc81c..9fd8059894f4 100644 --- a/sw/source/core/access/accpara.cxx +++ b/sw/source/core/access/accpara.cxx @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include #include #include "fesh.hxx" @@ -1533,7 +1533,7 @@ void SwAccessibleParagraph::_getRunAttributesImpl( SfxItemSet aCharAttrsAtPaM( pPaM->GetDoc()->GetAttrPool(), RES_CHRATR_BEGIN, RES_CHRATR_END -1, 0 ); - SwXTextCursor::GetCrsrAttr( *pPaM, aCharAttrsAtPaM, TRUE, TRUE ); + SwUnoCursorHelper::GetCrsrAttr(*pPaM, aCharAttrsAtPaM, TRUE, TRUE); aSet.Put( aCharAttrsAtPaM ); } // <-- diff --git a/sw/source/core/edit/editsh.cxx b/sw/source/core/edit/editsh.cxx index 796905fd49f5..554e66a56ed8 100644 --- a/sw/source/core/edit/editsh.cxx +++ b/sw/source/core/edit/editsh.cxx @@ -63,7 +63,7 @@ #include #include #include -#include +#include #include #include #include @@ -1111,7 +1111,7 @@ String SwEditShell::DeleteExtTextInput( SwExtTextInput* pDel, BOOL bInsText ) if( pDel ) { rtl::OUString sTmp; - SwXTextCursor::getTextFromPam(*pDel, sTmp); + SwUnoCursorHelper::GetTextFromPam(*pDel, sTmp); sRet = sTmp; SET_CURR_SHELL( this ); StartAllAction(); diff --git a/sw/source/core/unocore/SwXTextDefaults.cxx b/sw/source/core/unocore/SwXTextDefaults.cxx index 43c1743023d7..81a2cf34e93a 100644 --- a/sw/source/core/unocore/SwXTextDefaults.cxx +++ b/sw/source/core/unocore/SwXTextDefaults.cxx @@ -30,9 +30,12 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" + +#include + #include #include -#include + #include #include #include @@ -44,6 +47,7 @@ #include #include #include +#include #include #include @@ -56,9 +60,6 @@ using namespace ::com::sun::star::uno; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::lang; -// declarations -void lcl_setPageDesc(SwDoc*, const uno::Any&, SfxItemSet& ); // from unoobj.cxx - SwXTextDefaults::SwXTextDefaults ( SwDoc * pNewDoc ) : m_pPropSet( aSwMapProvider.GetPropertySet( PROPERTY_MAP_TEXT_DEFAULT ) ), @@ -97,7 +98,7 @@ void SAL_CALL SwXTextDefaults::setPropertyValue( const OUString& rPropertyName, { SfxItemSet aSet( m_pDoc->GetAttrPool(), RES_PAGEDESC, RES_PAGEDESC ); aSet.Put(rItem); - lcl_setPageDesc( m_pDoc, aValue, aSet ); + SwUnoCursorHelper::SetPageDesc( aValue, *m_pDoc, aSet ); m_pDoc->SetDefault(aSet.Get(RES_PAGEDESC)); } else if ((RES_PARATR_DROP == pMap->nWID && MID_DROPCAP_CHAR_STYLE_NAME == pMap->nMemberId) || diff --git a/sw/source/core/unocore/unocrsrhelper.cxx b/sw/source/core/unocore/unocrsrhelper.cxx index 1138f5ee273e..4d179f133446 100644 --- a/sw/source/core/unocore/unocrsrhelper.cxx +++ b/sw/source/core/unocore/unocrsrhelper.cxx @@ -32,12 +32,13 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" +#include + #include #include #include #include -#include #include #include #include @@ -45,6 +46,7 @@ #include #include #include +#include #include #include #include @@ -103,8 +105,9 @@ using ::rtl::OUString; namespace SwUnoCursorHelper { + /* -----------------16.09.98 12:27------------------- - * Lesen spezieller Properties am Cursor +* Lesen spezieller Properties am Cursor * --------------------------------------------------*/ sal_Bool getCrsrPropertyValue(const SfxItemPropertySimpleEntry& rEntry , SwPaM& rPam @@ -196,7 +199,10 @@ sal_Bool getCrsrPropertyValue(const SfxItemPropertySimpleEntry& rEntry pFmt = FN_UNO_PARA_CONDITIONAL_STYLE_NAME == rEntry.nWID ? pNode->GetFmtColl() : &pNode->GetAnyFmtColl(); else - pFmt = SwXTextCursor::GetCurTxtFmtColl(rPam, FN_UNO_PARA_CONDITIONAL_STYLE_NAME == rEntry.nWID); + { + pFmt = SwUnoCursorHelper::GetCurTxtFmtColl(rPam, + FN_UNO_PARA_CONDITIONAL_STYLE_NAME == rEntry.nWID); + } if(pFmt) { if( pAny ) diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx index a0b08fffc879..837caa62634b 100644 --- a/sw/source/core/unocore/unoobj.cxx +++ b/sw/source/core/unocore/unoobj.cxx @@ -46,6 +46,7 @@ #include #include #include +#include #include #include #include @@ -195,25 +196,30 @@ SwUnoInternalPaM& SwUnoInternalPaM::operator=(const SwPaM& rPaM) /*-----------------09.03.98 08:29------------------- --------------------------------------------------*/ -void SwXTextCursor::SelectPam(SwPaM& rCrsr, sal_Bool bExpand) +void SwUnoCursorHelper::SelectPam(SwPaM & rPam, const bool bExpand) { - if(bExpand) + if (bExpand) { - if(!rCrsr.HasMark()) - rCrsr.SetMark(); + if (!rPam.HasMark()) + { + rPam.SetMark(); + } + } + else if (rPam.HasMark()) + { + rPam.DeleteMark(); } - else if(rCrsr.HasMark()) - rCrsr.DeleteMark(); - } /* -----------------20.05.98 14:59------------------- * * --------------------------------------------------*/ -void SwXTextCursor::getTextFromPam(SwPaM& aCrsr, OUString& rBuffer) +void SwUnoCursorHelper::GetTextFromPam(SwPaM & rPam, OUString & rBuffer) { - if(!aCrsr.HasMark()) + if (!rPam.HasMark()) + { return; + } SvCacheStream aStream( 20480 ); #ifdef OSL_BIGENDIAN aStream.SetNumberFormatInt( NUMBERFORMAT_INT_BIGENDIAN ); @@ -225,7 +231,7 @@ void SwXTextCursor::getTextFromPam(SwPaM& aCrsr, OUString& rBuffer) SwReaderWriter::GetWriter( C2S(FILTER_TEXT_DLG), String(), xWrt ); if( xWrt.Is() ) { - SwWriter aWriter( aStream, aCrsr ); + SwWriter aWriter( aStream, rPam ); xWrt->bASCII_NoLastLineEnd = sal_True; xWrt->bExportPargraphNumbering = sal_False; SwAsciiOptions aOpt = xWrt->GetAsciiOptions(); @@ -253,10 +259,15 @@ void SwXTextCursor::getTextFromPam(SwPaM& aCrsr, OUString& rBuffer) String sBuf; sal_Int32 nLocalLen = 0; if( lUniLen >= STRING_MAXLEN ) + { nLocalLen = STRING_MAXLEN - 1; + } else + { nLocalLen = lUniLen; - sal_Unicode* pStrBuf = sBuf.AllocBuffer( xub_StrLen( nLocalLen + 1)); + } + sal_Unicode *const pStrBuf = + sBuf.AllocBuffer( xub_StrLen( nLocalLen + 1)); aStream.Read( pStrBuf, 2 * nLocalLen ); pStrBuf[ nLocalLen ] = '\0'; aStrBuffer.append( pStrBuf, nLocalLen ); @@ -271,46 +282,52 @@ void SwXTextCursor::getTextFromPam(SwPaM& aCrsr, OUString& rBuffer) /* -----------------06.07.98 07:33------------------- * * --------------------------------------------------*/ -void lcl_setCharStyle(SwDoc* pDoc, const uno::Any aValue, SfxItemSet& rSet) - throw (lang::IllegalArgumentException) +static void +lcl_setCharStyle(SwDoc *const pDoc, const uno::Any & rValue, SfxItemSet & rSet) +throw (lang::IllegalArgumentException) { - SwDocShell* pDocSh = pDoc->GetDocShell(); + SwDocShell *const pDocSh = pDoc->GetDocShell(); if(pDocSh) { OUString uStyle; - aValue >>= uStyle; - String sStyle; - SwStyleNameMapper::FillUIName(uStyle, sStyle, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, sal_True ); - SwDocStyleSheet* pStyle = - (SwDocStyleSheet*)pDocSh->GetStyleSheetPool()->Find(sStyle, SFX_STYLE_FAMILY_CHAR); - if(pStyle) + if (!(rValue >>= uStyle)) { - SwFmtCharFmt aFmt(pStyle->GetCharFmt()); - rSet.Put(aFmt); + throw lang::IllegalArgumentException(); } - else + String sStyle; + SwStyleNameMapper::FillUIName(uStyle, sStyle, + nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, sal_True); + SwDocStyleSheet *const pStyle = static_cast( + pDocSh->GetStyleSheetPool()->Find(sStyle, SFX_STYLE_FAMILY_CHAR)); + if (!pStyle) { - throw lang::IllegalArgumentException(); + throw lang::IllegalArgumentException(); } - + const SwFmtCharFmt aFmt(pStyle->GetCharFmt()); + rSet.Put(aFmt); } }; /* -----------------08.06.06 10:43------------------- * * --------------------------------------------------*/ -void lcl_setAutoStyle(IStyleAccess& rStyleAccess, const uno::Any aValue, SfxItemSet& rSet, bool bPara ) - throw (lang::IllegalArgumentException) +static void +lcl_setAutoStyle(IStyleAccess & rStyleAccess, const uno::Any & rValue, + SfxItemSet & rSet, const bool bPara) +throw (lang::IllegalArgumentException) { OUString uStyle; - aValue >>= uStyle; - String sStyle; + if (!(rValue >>= uStyle)) + { + throw lang::IllegalArgumentException(); + } StylePool::SfxItemSet_Pointer_t pStyle = bPara ? rStyleAccess.getByName(uStyle, IStyleAccess::AUTO_STYLE_PARA ): rStyleAccess.getByName(uStyle, IStyleAccess::AUTO_STYLE_CHAR ); if(pStyle.get()) { - SwFmtAutoFmt aFmt( bPara ? sal::static_int_cast< USHORT >(RES_AUTO_STYLE) - : sal::static_int_cast< USHORT >(RES_TXTATR_AUTOFMT) ); + SwFmtAutoFmt aFmt( (bPara) + ? sal::static_int_cast< USHORT >(RES_AUTO_STYLE) + : sal::static_int_cast< USHORT >(RES_TXTATR_AUTOFMT) ); aFmt.SetStyleHandle( pStyle ); rSet.Put(aFmt); } @@ -322,71 +339,77 @@ void lcl_setAutoStyle(IStyleAccess& rStyleAccess, const uno::Any aValue, SfxItem /* -----------------30.06.98 08:46------------------- * * --------------------------------------------------*/ -void lcl_SetTxtFmtColl(const uno::Any& rAny, SwPaM& rPaM) - throw (lang::IllegalArgumentException) +void +SwUnoCursorHelper::SetTxtFmtColl(const uno::Any & rAny, SwPaM & rPaM) +throw (lang::IllegalArgumentException) { - SwDoc* pDoc = rPaM.GetDoc(); - SwDocShell* pDocSh = pDoc->GetDocShell(); + SwDoc *const pDoc = rPaM.GetDoc(); + SwDocShell *const pDocSh = pDoc->GetDocShell(); if(!pDocSh) return; OUString uStyle; rAny >>= uStyle; String sStyle; - SwStyleNameMapper::FillUIName(uStyle, sStyle, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True ); - SwDocStyleSheet* pStyle = - (SwDocStyleSheet*)pDocSh->GetStyleSheetPool()->Find(sStyle, SFX_STYLE_FAMILY_PARA); - if(pStyle) - { - SwTxtFmtColl *pLocal = pStyle->GetCollection(); - UnoActionContext aAction(pDoc); - pDoc->StartUndo( UNDO_START, NULL ); - SwPaM *pTmpCrsr = &rPaM; - do { - pDoc->SetTxtFmtColl(*pTmpCrsr, pLocal); - pTmpCrsr = static_cast(pTmpCrsr->GetNext()); - } while ( pTmpCrsr != &rPaM ); - pDoc->EndUndo( UNDO_END, NULL ); - } - else + SwStyleNameMapper::FillUIName(uStyle, sStyle, + nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True ); + SwDocStyleSheet *const pStyle = static_cast( + pDocSh->GetStyleSheetPool()->Find(sStyle, SFX_STYLE_FAMILY_PARA)); + if (!pStyle) { throw lang::IllegalArgumentException(); } + SwTxtFmtColl *const pLocal = pStyle->GetCollection(); + UnoActionContext aAction(pDoc); + pDoc->StartUndo( UNDO_START, NULL ); + SwPaM *pTmpCrsr = &rPaM; + do { + pDoc->SetTxtFmtColl(*pTmpCrsr, pLocal); + pTmpCrsr = static_cast(pTmpCrsr->GetNext()); + } while ( pTmpCrsr != &rPaM ); + pDoc->EndUndo( UNDO_END, NULL ); } + /* -----------------06.07.98 07:38------------------- * * --------------------------------------------------*/ - void lcl_setPageDesc(SwDoc* pDoc, const uno::Any& aValue, SfxItemSet& rSet) - { - if(aValue.getValueType() != ::getCppuType((const OUString*)0)) - return; - SwFmtPageDesc *pNewDesc = 0 ; +bool +SwUnoCursorHelper::SetPageDesc( + const uno::Any& rValue, SwDoc & rDoc, SfxItemSet & rSet) +{ + OUString uDescName; + if (!(rValue >>= uDescName)) + { + return false; + } + ::std::auto_ptr pNewDesc; const SfxPoolItem* pItem; if(SFX_ITEM_SET == rSet.GetItemState( RES_PAGEDESC, sal_True, &pItem ) ) { - pNewDesc = new SwFmtPageDesc(*((SwFmtPageDesc*)pItem)); + pNewDesc.reset(new SwFmtPageDesc( + *static_cast(pItem))); + } + if (!pNewDesc.get()) + { + pNewDesc.reset(new SwFmtPageDesc()); } - if(!pNewDesc) - pNewDesc = new SwFmtPageDesc(); - OUString uDescName; - aValue >>= uDescName; String sDescName; - SwStyleNameMapper::FillUIName(uDescName, sDescName, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, sal_True ); - if(!pNewDesc->GetPageDesc() || pNewDesc->GetPageDesc()->GetName() != sDescName) + SwStyleNameMapper::FillUIName(uDescName, sDescName, + nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, sal_True); + if (!pNewDesc->GetPageDesc() || + (pNewDesc->GetPageDesc()->GetName() != sDescName)) { sal_Bool bPut = sal_False; if(sDescName.Len()) { - SwPageDesc* pPageDesc = ::GetPageDescByName_Impl(*pDoc, sDescName); - if(pPageDesc) - { - pPageDesc->Add( pNewDesc ); - bPut = sal_True; - } - else + SwPageDesc *const pPageDesc = + ::GetPageDescByName_Impl(rDoc, sDescName); + if (!pPageDesc) { throw lang::IllegalArgumentException(); } + pPageDesc->Add( pNewDesc.get() ); + bPut = sal_True; } if(!bPut) { @@ -394,17 +417,21 @@ void lcl_SetTxtFmtColl(const uno::Any& rAny, SwPaM& rPaM) rSet.Put(SwFmtPageDesc()); } else + { rSet.Put(*pNewDesc); + } } - delete pNewDesc; + return true; } + /* -----------------30.06.98 10:29------------------- * * --------------------------------------------------*/ -void lcl_SetNodeNumStart( SwPaM& rCrsr, uno::Any aValue ) +static void +lcl_SetNodeNumStart(SwPaM & rCrsr, uno::Any const& rValue) { sal_Int16 nTmp = 1; - aValue >>= nTmp; + rValue >>= nTmp; sal_uInt16 nStt = (nTmp < 0 ? USHRT_MAX : (sal_uInt16)nTmp); SwDoc* pDoc = rCrsr.GetDoc(); UnoActionContext aAction(pDoc); @@ -429,215 +456,264 @@ void lcl_SetNodeNumStart( SwPaM& rCrsr, uno::Any aValue ) } } +static bool +lcl_setCharFmtSequence(SwPaM & rPam, uno::Any const& rValue) +{ + uno::Sequence aCharStyles; + if (!(rValue >>= aCharStyles)) + { + return false; + } + + for (sal_Int32 nStyle = 0; nStyle < aCharStyles.getLength(); nStyle++) + { + uno::Any aStyle; + rPam.GetDoc()->StartUndo(UNDO_START, NULL); + aStyle <<= aCharStyles.getConstArray()[nStyle]; + // create a local set and apply each format directly + SfxItemSet aSet(rPam.GetDoc()->GetAttrPool(), + RES_TXTATR_CHARFMT, RES_TXTATR_CHARFMT); + lcl_setCharStyle(rPam.GetDoc(), aStyle, aSet); + // the first style should replace the current attributes, + // all other have to be added + SwUnoCursorHelper::SetCrsrAttr(rPam, aSet, (nStyle) + ? nsSetAttrMode::SETATTR_DONTREPLACE + : nsSetAttrMode::SETATTR_DEFAULT); + rPam.GetDoc()->EndUndo(UNDO_START, NULL); + } + return true; +} + +static void +lcl_setDropcapCharStyle(SwPaM & rPam, SfxItemSet & rItemSet, + uno::Any const& rValue) +{ + OUString uStyle; + if (!(rValue >>= uStyle)) + { + throw lang::IllegalArgumentException(); + } + String sStyle; + SwStyleNameMapper::FillUIName(uStyle, sStyle, + nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, sal_True); + SwDoc *const pDoc = rPam.GetDoc(); + //default character style must not be set as default format + SwDocStyleSheet *const pStyle = static_cast( + pDoc->GetDocShell() + ->GetStyleSheetPool()->Find(sStyle, SFX_STYLE_FAMILY_CHAR)); + if (!pStyle || + (static_cast(pStyle)->GetCharFmt() == + pDoc->GetDfltCharFmt())) + { + throw lang::IllegalArgumentException(); + } + ::std::auto_ptr pDrop; + SfxPoolItem const* pItem(0); + if (SFX_ITEM_SET == + rItemSet.GetItemState(RES_PARATR_DROP, sal_True, &pItem)) + { + pDrop.reset(new SwFmtDrop(*static_cast(pItem))); + } + if (!pDrop.get()) + { + pDrop.reset(new SwFmtDrop); + } + const rtl::Reference xStyle(new SwDocStyleSheet(*pStyle)); + pDrop->SetCharFmt(xStyle->GetCharFmt()); + rItemSet.Put(*pDrop); +} + +static void +lcl_setRubyCharstyle(SfxItemSet & rItemSet, uno::Any const& rValue) +{ + OUString sTmp; + if (!(rValue >>= sTmp)) + { + throw lang::IllegalArgumentException(); + } + + ::std::auto_ptr pRuby; + const SfxPoolItem* pItem; + if (SFX_ITEM_SET == + rItemSet.GetItemState(RES_TXTATR_CJK_RUBY, sal_True, &pItem)) + { + pRuby.reset(new SwFmtRuby(*static_cast(pItem))); + } + if (!pRuby.get()) + { + pRuby.reset(new SwFmtRuby(aEmptyStr)); + } + String sStyle; + SwStyleNameMapper::FillUIName(sTmp, sStyle, + nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, sal_True ); + pRuby->SetCharFmtName(sStyle); + pRuby->SetCharFmtId(0); + if (sStyle.Len() > 0) + { + const sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName( + sStyle, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT); + pRuby->SetCharFmtId(nId); + } + rItemSet.Put(*pRuby); +} + /* -----------------17.09.98 09:44------------------- * * --------------------------------------------------*/ -sal_Bool lcl_setCrsrPropertyValue(const SfxItemPropertySimpleEntry* pEntry, - SwPaM& rPam, - SfxItemSet& rItemSet, - const uno::Any& aValue ) throw (lang::IllegalArgumentException) -{ - sal_Bool bRet = sal_True; - if(0 == ( pEntry->nFlags&PropertyAttribute::MAYBEVOID ) && - aValue.getValueType() == ::getCppuVoidType()) - bRet = sal_False; - else - { - switch(pEntry->nWID) +bool +SwUnoCursorHelper::SetCursorPropertyValue( + SfxItemPropertySimpleEntry const& rEntry, const uno::Any& rValue, + SwPaM & rPam, SfxItemSet & rItemSet) +throw (lang::IllegalArgumentException) +{ + if (!(rEntry.nFlags & beans::PropertyAttribute::MAYBEVOID) && + (rValue.getValueType() == ::getCppuVoidType())) + { + return false; + } + bool bRet = true; + switch (rEntry.nWID) + { + case RES_TXTATR_CHARFMT: + lcl_setCharStyle(rPam.GetDoc(), rValue, rItemSet); + break; + case RES_TXTATR_AUTOFMT: + lcl_setAutoStyle(rPam.GetDoc()->GetIStyleAccess(), + rValue, rItemSet, false); + break; + case FN_UNO_CHARFMT_SEQUENCE: + lcl_setCharFmtSequence(rPam, rValue); + break; + case FN_UNO_PARA_STYLE : + SwUnoCursorHelper::SetTxtFmtColl(rValue, rPam); + break; + case RES_AUTO_STYLE: + lcl_setAutoStyle(rPam.GetDoc()->GetIStyleAccess(), + rValue, rItemSet, true); + break; + case FN_UNO_PAGE_STYLE: + //FIXME nothing here? + break; + case FN_UNO_NUM_START_VALUE: + lcl_SetNodeNumStart( rPam, rValue ); + break; + case FN_UNO_NUM_LEVEL: + // --> OD 2008-07-14 #i91601# + case FN_UNO_LIST_ID: + // <-- + case FN_UNO_IS_NUMBER: { - case RES_TXTATR_CHARFMT: - lcl_setCharStyle(rPam.GetDoc(), aValue, rItemSet ); - break; - case RES_TXTATR_AUTOFMT: - lcl_setAutoStyle(rPam.GetDoc()->GetIStyleAccess(), aValue, rItemSet, false ); - break; - case FN_UNO_CHARFMT_SEQUENCE: + // multi selection is not considered + SwTxtNode *const pTxtNd = rPam.GetNode()->GetTxtNode(); + // --> OD 2008-05-14 #refactorlists# - check on list style not needed +// const SwNumRule* pRule = pTxtNd->GetNumRule(); +// if( FN_UNO_NUM_LEVEL == rEntry.nWID && pRule != NULL ) + if (FN_UNO_NUM_LEVEL == rEntry.nWID) + // <-- { - Sequence aCharStyles; - if(aValue >>= aCharStyles) + sal_Int16 nLevel = 0; + if (rValue >>= nLevel) { - for(sal_Int32 nStyle = 0; nStyle < aCharStyles.getLength(); nStyle++) - { - Any aStyle; - rPam.GetDoc()->StartUndo( UNDO_START, NULL); - aStyle <<= aCharStyles.getConstArray()[nStyle]; - //create a local set and apply each format directly - SfxItemSet aSet(rPam.GetDoc()->GetAttrPool(), RES_TXTATR_CHARFMT, RES_TXTATR_CHARFMT ); - lcl_setCharStyle(rPam.GetDoc(), aStyle, aSet ); - //the first style should replace the current attributes, all other have to be added - SwXTextCursor::SetCrsrAttr(rPam, aSet, nStyle ? CRSR_ATTR_MODE_DONTREPLACE : 0); - rPam.GetDoc()->EndUndo( UNDO_START, NULL ); - } + pTxtNd->SetAttrListLevel(nLevel); } - else - bRet = sal_False; } - break; - case FN_UNO_PARA_STYLE : - lcl_SetTxtFmtColl(aValue, rPam); - break; - case RES_AUTO_STYLE: - lcl_setAutoStyle(rPam.GetDoc()->GetIStyleAccess(), aValue, rItemSet, true ); - break; - case FN_UNO_PAGE_STYLE : - break; - case FN_UNO_NUM_START_VALUE : - lcl_SetNodeNumStart( rPam, aValue ); - break; - case FN_UNO_NUM_LEVEL : // --> OD 2008-07-14 #i91601# - case FN_UNO_LIST_ID: - // <-- - case FN_UNO_IS_NUMBER : + else if (FN_UNO_LIST_ID == rEntry.nWID) { - // multi selection is not considered - SwTxtNode* pTxtNd = rPam.GetNode()->GetTxtNode(); - // --> OD 2008-05-14 #refactorlists# - check on list style not needed -// const SwNumRule* pRule = pTxtNd->GetNumRule(); -// if( FN_UNO_NUM_LEVEL == pEntry->nWID && pRule != NULL ) - if ( FN_UNO_NUM_LEVEL == pEntry->nWID ) - // <-- - { - sal_Int16 nLevel = 0; - aValue >>= nLevel; - - pTxtNd->SetAttrListLevel(nLevel); - - } - // --> OD 2008-07-14 #i91601# - else if( FN_UNO_LIST_ID == pEntry->nWID ) + ::rtl::OUString sListId; + if (rValue >>= sListId) { - ::rtl::OUString sListId; - aValue >>= sListId; pTxtNd->SetListId( sListId ); } - // <-- - else if( FN_UNO_IS_NUMBER == pEntry->nWID ) + } + // <-- + else if (FN_UNO_IS_NUMBER == rEntry.nWID) + { + sal_Bool bIsNumber(sal_False); + if (rValue >>= bIsNumber) { - BOOL bIsNumber = *(sal_Bool*) aValue.getValue(); - if(!bIsNumber) + if (!bIsNumber) + { pTxtNd->SetCountedInList( false ); + } } - //PROPERTY_MAYBEVOID! } - break; - case FN_NUMBER_NEWSTART : + //PROPERTY_MAYBEVOID! + } + break; + case FN_NUMBER_NEWSTART: + { + sal_Bool bVal = sal_False; + if (!(rValue >>= bVal)) { - sal_Bool bVal = sal_False; - if (aValue >>= bVal) - rPam.GetDoc()->SetNumRuleStart(*rPam.GetPoint(), bVal); - else - throw lang::IllegalArgumentException(); + throw lang::IllegalArgumentException(); } - break; - case FN_UNO_NUM_RULES: - SwUnoCursorHelper::setNumberingProperty(aValue, rPam); - break; - case RES_PARATR_DROP: + rPam.GetDoc()->SetNumRuleStart(*rPam.GetPoint(), bVal); + } + break; + case FN_UNO_NUM_RULES: + SwUnoCursorHelper::setNumberingProperty(rValue, rPam); + break; + case RES_PARATR_DROP: + { + if (MID_DROPCAP_CHAR_STYLE_NAME == rEntry.nMemberId) { - if( MID_DROPCAP_CHAR_STYLE_NAME == pEntry->nMemberId) - { - OUString uStyle; - if(aValue >>= uStyle) - { - String sStyle; - SwStyleNameMapper::FillUIName(uStyle, sStyle, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, sal_True ); - SwDoc* pDoc = rPam.GetDoc(); - //default character style mustn't be set as default format - SwDocStyleSheet* pStyle = - (SwDocStyleSheet*)pDoc->GetDocShell()->GetStyleSheetPool()->Find(sStyle, SFX_STYLE_FAMILY_CHAR); - SwFmtDrop* pDrop = 0; - if(pStyle && - ((SwDocStyleSheet*)pStyle)->GetCharFmt() != pDoc->GetDfltCharFmt()) - { - const SfxPoolItem* pItem; - if(SFX_ITEM_SET == rItemSet.GetItemState( RES_PARATR_DROP, sal_True, &pItem ) ) - pDrop = new SwFmtDrop(*((SwFmtDrop*)pItem)); - if(!pDrop) - pDrop = new SwFmtDrop(); - rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *(SwDocStyleSheet*)pStyle ) ); - pDrop->SetCharFmt(xStyle->GetCharFmt()); - } - else - throw lang::IllegalArgumentException(); - rItemSet.Put(*pDrop); - delete pDrop; - } - else - throw lang::IllegalArgumentException(); - } - else - bRet = sal_False; + lcl_setDropcapCharStyle(rPam, rItemSet, rValue); } - break; - case RES_TXTATR_CJK_RUBY: - if(MID_RUBY_CHARSTYLE == pEntry->nMemberId ) - { - OUString sTmp; - if(aValue >>= sTmp) - { - SwFmtRuby* pRuby = 0; - const SfxPoolItem* pItem; - if(SFX_ITEM_SET == rItemSet.GetItemState( RES_TXTATR_CJK_RUBY, sal_True, &pItem ) ) - pRuby = new SwFmtRuby(*((SwFmtRuby*)pItem)); - if(!pRuby) - pRuby = new SwFmtRuby(aEmptyStr); - String sStyle; - SwStyleNameMapper::FillUIName(sTmp, sStyle, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, sal_True ); - pRuby->SetCharFmtName( sStyle ); - pRuby->SetCharFmtId( 0 ); - if(sStyle.Len() > 0) - { - sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName( sStyle, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT ); - pRuby->SetCharFmtId(nId); - } - rItemSet.Put(*pRuby); - delete pRuby; - } - else - throw lang::IllegalArgumentException(); - bRet = sal_True; - } - else - bRet = sal_False; - break; - case RES_PAGEDESC : - if(MID_PAGEDESC_PAGEDESCNAME == pEntry->nMemberId ) + else { - lcl_setPageDesc(rPam.GetDoc(), aValue, rItemSet); - break; + bRet = false; } - //hier kein break - default: bRet = sal_False; } + break; + case RES_TXTATR_CJK_RUBY: + { + if (MID_RUBY_CHARSTYLE == rEntry.nMemberId) + { + lcl_setRubyCharstyle(rItemSet, rValue); + } + else + { + bRet = false; + } + } + break; + case RES_PAGEDESC: + { + if (MID_PAGEDESC_PAGEDESCNAME == rEntry.nMemberId) + { + SwUnoCursorHelper::SetPageDesc( + rValue, *rPam.GetDoc(), rItemSet); + } + else + { + bRet = false; + } + } + break; + default: + bRet = false; } -return bRet; + return bRet; } /* -----------------30.06.98 08:39------------------- * * --------------------------------------------------*/ -SwFmtColl* SwXTextCursor::GetCurTxtFmtColl(SwPaM& rPaM, BOOL bConditional) +SwFmtColl * +SwUnoCursorHelper::GetCurTxtFmtColl(SwPaM & rPaM, const bool bConditional) { static const sal_uInt16 nMaxLookup = 1000; SwFmtColl *pFmt = 0; // if ( GetCrsrCnt() > nMaxLookup ) // return 0; - sal_Bool bError = sal_False; + bool bError = false; SwPaM *pTmpCrsr = &rPaM; - do { - - ULONG nSttNd = pTmpCrsr->GetMark()->nNode.GetIndex(); - ULONG nEndNd = pTmpCrsr->GetPoint()->nNode.GetIndex(); - xub_StrLen nSttCnt = pTmpCrsr->GetMark()->nContent.GetIndex(); - xub_StrLen nEndCnt = pTmpCrsr->GetPoint()->nContent.GetIndex(); - - if( nSttNd > nEndNd || ( nSttNd == nEndNd && nSttCnt > nEndCnt )) - { - sal_uInt32 nTmp = nSttNd; nSttNd = nEndNd; nEndNd = nTmp; - nTmp = nSttCnt; nSttCnt = nEndCnt; nEndCnt = (sal_uInt16)nTmp; - } + do + { + const ULONG nSttNd = pTmpCrsr->Start()->nNode.GetIndex(); + const ULONG nEndNd = pTmpCrsr->End()->nNode.GetIndex(); if( nEndNd - nSttNd >= nMaxLookup ) { @@ -648,33 +724,33 @@ SwFmtColl* SwXTextCursor::GetCurTxtFmtColl(SwPaM& rPaM, BOOL bConditional) const SwNodes& rNds = rPaM.GetDoc()->GetNodes(); for( ULONG n = nSttNd; n <= nEndNd; ++n ) { - const SwTxtNode* pNd = rNds[ n ]->GetTxtNode(); + SwTxtNode const*const pNd = rNds[ n ]->GetTxtNode(); if( pNd ) { - SwFmtColl* pNdFmt = bConditional ? pNd->GetFmtColl() - : &pNd->GetAnyFmtColl(); + SwFmtColl *const pNdFmt = (bConditional) + ? pNd->GetFmtColl() : &pNd->GetAnyFmtColl(); if( !pFmt ) + { pFmt = pNdFmt; + } else if( pFmt != pNdFmt ) { - bError = sal_True; + bError = true; break; } } } - if(bError) - break; pTmpCrsr = static_cast(pTmpCrsr->GetNext()); } while ( pTmpCrsr != &rPaM ); - return bError ? 0 : pFmt; + return (bError) ? 0 : pFmt; } /* -----------------26.06.98 16:20------------------- * Hilfsfunktion fuer PageDesc * --------------------------------------------------*/ - SwPageDesc* GetPageDescByName_Impl(SwDoc& rDoc, const String& rName) - { +SwPageDesc* GetPageDescByName_Impl(SwDoc& rDoc, const String& rName) +{ SwPageDesc* pRet = 0; sal_uInt16 nDCount = rDoc.GetPageDescCnt(); sal_uInt16 i; @@ -695,7 +771,8 @@ SwFmtColl* SwXTextCursor::GetCurTxtFmtColl(SwPaM& rPaM, BOOL bConditional) const String aFmtName(SW_RES(i)); if(aFmtName == rName) { - pRet = rDoc.GetPageDescFromPool( static_cast< sal_uInt16 >(RES_POOLPAGE_BEGIN + i - RC_POOLPAGEDESC_BEGIN) ); + pRet = rDoc.GetPageDescFromPool( static_cast< sal_uInt16 >( + RES_POOLPAGE_BEGIN + i - RC_POOLPAGEDESC_BEGIN) ); break; } } @@ -934,7 +1011,7 @@ void SwXTextCursor::DeleteAndInsert(const String& rText, DBG_ASSERT( bSuccess, "Doc->Insert(Str) failed." ); (void) bSuccess; - SwXTextCursor::SelectPam(*pUnoCrsr, sal_True); + SwUnoCursorHelper::SelectPam(*pUnoCrsr, true); _pStartCrsr->Left(rText.Len(), CRSR_SKIP_CHARS, FALSE, FALSE); } } while( (_pStartCrsr=(SwCursor*)_pStartCrsr->GetNext()) != pUnoCrsr ); @@ -945,7 +1022,8 @@ void SwXTextCursor::DeleteAndInsert(const String& rText, enum ForceIntoMetaMode { META_CHECK_BOTH, META_INIT_START, META_INIT_END }; -sal_Bool lcl_ForceIntoMeta(SwPaM & rCursor, +static sal_Bool +lcl_ForceIntoMeta(SwPaM & rCursor, uno::Reference const & xParentText, const enum ForceIntoMetaMode eMode) { @@ -1106,7 +1184,7 @@ sal_Bool SwXTextCursor::goLeft(sal_Int16 nCount, sal_Bool Expand) throw( uno::Ru SwUnoCrsr* pUnoCrsr = GetCrsr(); if(pUnoCrsr) { - SwXTextCursor::SelectPam(*pUnoCrsr, Expand); + SwUnoCursorHelper::SelectPam(*pUnoCrsr, Expand); bRet = pUnoCrsr->Left( nCount, CRSR_SKIP_CHARS, FALSE, FALSE); if (CURSOR_META == eType) { @@ -1130,7 +1208,7 @@ sal_Bool SwXTextCursor::goRight(sal_Int16 nCount, sal_Bool Expand) throw( uno::R SwUnoCrsr* pUnoCrsr = GetCrsr(); if(pUnoCrsr) { - SwXTextCursor::SelectPam(*pUnoCrsr, Expand); + SwUnoCursorHelper::SelectPam(*pUnoCrsr, Expand); bRet = pUnoCrsr->Right(nCount, CRSR_SKIP_CHARS, FALSE, FALSE); if (CURSOR_META == eType) { @@ -1153,7 +1231,7 @@ void SwXTextCursor::gotoStart(sal_Bool Expand) throw( uno::RuntimeException ) SwUnoCrsr* pUnoCrsr = GetCrsr(); if(pUnoCrsr) { - SwXTextCursor::SelectPam(*pUnoCrsr, Expand); + SwUnoCursorHelper::SelectPam(*pUnoCrsr, Expand); if(eType == CURSOR_BODY) { pUnoCrsr->Move( fnMoveBackward, fnGoDoc ); @@ -1209,7 +1287,7 @@ void SwXTextCursor::gotoEnd(sal_Bool Expand) throw( uno::RuntimeException ) SwUnoCrsr* pUnoCrsr = GetCrsr(); if(pUnoCrsr) { - SwXTextCursor::SelectPam(*pUnoCrsr, Expand); + SwUnoCursorHelper::SelectPam(*pUnoCrsr, Expand); if(eType == CURSOR_BODY) { pUnoCrsr->Move( fnMoveForward, fnGoDoc ); @@ -1424,7 +1502,7 @@ sal_Bool SwXTextCursor::gotoNextWord(sal_Bool Expand) throw( uno::RuntimeExcepti SwNode *pOldNode = &pPoint->nNode.GetNode(); xub_StrLen nOldIndex = pPoint->nContent.GetIndex(); - SwXTextCursor::SelectPam(*pUnoCrsr, Expand); + SwUnoCursorHelper::SelectPam(*pUnoCrsr, Expand); //Absatzende? if(pUnoCrsr->GetCntntNode() && pPoint->nContent == pUnoCrsr->GetCntntNode()->Len()) @@ -1470,7 +1548,7 @@ sal_Bool SwXTextCursor::gotoPreviousWord(sal_Bool Expand) throw( uno::RuntimeExc SwNode *pOldNode = &pPoint->nNode.GetNode(); xub_StrLen nOldIndex = pPoint->nContent.GetIndex(); - SwXTextCursor::SelectPam(*pUnoCrsr, Expand); + SwUnoCursorHelper::SelectPam(*pUnoCrsr, Expand); //Absatzanfang ? if(pPoint->nContent == 0) { @@ -1514,7 +1592,7 @@ sal_Bool SwXTextCursor::gotoEndOfWord(sal_Bool Expand) throw( uno::RuntimeExcept xub_StrLen nOldIndex = pPoint->nContent.GetIndex(); sal_Int16 nWordType = i18n::WordType::DICTIONARY_WORD; - SwXTextCursor::SelectPam(*pUnoCrsr, Expand); + SwUnoCursorHelper::SelectPam(*pUnoCrsr, Expand); if(!pUnoCrsr->IsEndWordWT( nWordType )) pUnoCrsr->GoEndWordWT( nWordType ); @@ -1554,7 +1632,7 @@ sal_Bool SwXTextCursor::gotoStartOfWord(sal_Bool Expand) throw( uno::RuntimeExce xub_StrLen nOldIndex = pPoint->nContent.GetIndex(); sal_Int16 nWordType = i18n::WordType::DICTIONARY_WORD; - SwXTextCursor::SelectPam(*pUnoCrsr, Expand); + SwUnoCursorHelper::SelectPam(*pUnoCrsr, Expand); if(!pUnoCrsr->IsStartWordWT( nWordType )) pUnoCrsr->GoStartWordWT( nWordType ); @@ -1646,7 +1724,7 @@ sal_Bool SwXTextCursor::gotoNextSentence(sal_Bool Expand) throw( uno::RuntimeExc if(pUnoCrsr) { BOOL bWasEOS = isEndOfSentence(); - SwXTextCursor::SelectPam(*pUnoCrsr, Expand); + SwUnoCursorHelper::SelectPam(*pUnoCrsr, Expand); bRet = pUnoCrsr->GoSentence(SwCursor::NEXT_SENT); if(!bRet) bRet = pUnoCrsr->MovePara(fnParaNext, fnParaStart); @@ -1680,7 +1758,7 @@ sal_Bool SwXTextCursor::gotoPreviousSentence(sal_Bool Expand) throw( uno::Runtim SwUnoCrsr* pUnoCrsr = GetCrsr(); if(pUnoCrsr) { - SwXTextCursor::SelectPam(*pUnoCrsr, Expand); + SwUnoCursorHelper::SelectPam(*pUnoCrsr, Expand); bRet = pUnoCrsr->GoSentence(SwCursor::PREV_SENT); if(!bRet) { @@ -1712,7 +1790,7 @@ sal_Bool SwXTextCursor::gotoStartOfSentence(sal_Bool Expand) throw( uno::Runtime SwUnoCrsr* pUnoCrsr = GetCrsr(); if(pUnoCrsr) { - SwXTextCursor::SelectPam(*pUnoCrsr, Expand); + SwUnoCursorHelper::SelectPam(*pUnoCrsr, Expand); // if we're at the para start then we wont move // but bRet is also true if GoSentence failed but // the start of the sentence is reached @@ -1739,7 +1817,7 @@ sal_Bool SwXTextCursor::gotoEndOfSentence(sal_Bool Expand) throw( uno::RuntimeEx SwUnoCrsr* pUnoCrsr = GetCrsr(); if(pUnoCrsr) { - SwXTextCursor::SelectPam(*pUnoCrsr, Expand); + SwUnoCursorHelper::SelectPam(*pUnoCrsr, Expand); // bRet is true if GoSentence() succeeded or if the // MovePara() succeeded while the end of the para is // not reached already @@ -1798,7 +1876,7 @@ sal_Bool SwXTextCursor::gotoStartOfParagraph(sal_Bool Expand) throw( uno::Runtim SwUnoCrsr* pUnoCrsr = GetCrsr(); if(pUnoCrsr ) { - SwXTextCursor::SelectPam(*pUnoCrsr, Expand); + SwUnoCursorHelper::SelectPam(*pUnoCrsr, Expand); bRet = SwUnoCursorHelper::IsStartOfPara(*pUnoCrsr); if(!bRet) bRet = pUnoCrsr->MovePara(fnParaCurr, fnParaStart); @@ -1824,7 +1902,7 @@ sal_Bool SwXTextCursor::gotoEndOfParagraph(sal_Bool Expand) throw( uno::RuntimeE SwUnoCrsr* pUnoCrsr = GetCrsr(); if(pUnoCrsr) { - SwXTextCursor::SelectPam(*pUnoCrsr, Expand); + SwUnoCursorHelper::SelectPam(*pUnoCrsr, Expand); bRet = SwUnoCursorHelper::IsEndOfPara(*pUnoCrsr); if(!bRet) bRet = pUnoCrsr->MovePara(fnParaCurr, fnParaEnd); @@ -1850,7 +1928,7 @@ sal_Bool SwXTextCursor::gotoNextParagraph(sal_Bool Expand) throw( uno::RuntimeEx SwUnoCrsr* pUnoCrsr = GetCrsr(); if(pUnoCrsr) { - SwXTextCursor::SelectPam(*pUnoCrsr, Expand); + SwUnoCursorHelper::SelectPam(*pUnoCrsr, Expand); bRet = pUnoCrsr->MovePara(fnParaNext, fnParaStart); } else @@ -1869,7 +1947,7 @@ sal_Bool SwXTextCursor::gotoPreviousParagraph(sal_Bool Expand) throw( uno::Runti SwUnoCrsr* pUnoCrsr = GetCrsr(); if(pUnoCrsr) { - SwXTextCursor::SelectPam(*pUnoCrsr, Expand); + SwUnoCursorHelper::SelectPam(*pUnoCrsr, Expand); bRet = pUnoCrsr->MovePara(fnParaPrev, fnParaStart); } else @@ -1967,7 +2045,7 @@ OUString SwXTextCursor::getString(void) throw( uno::RuntimeException ) else */ { //Text ueber mehrere Absaetze - SwXTextCursor::getTextFromPam(*pUnoCrsr, aTxt); + SwUnoCursorHelper::GetTextFromPam(*pUnoCrsr, aTxt); } } else @@ -1993,242 +2071,307 @@ void SwXTextCursor::setString(const OUString& aString) throw( uno::RuntimeExcept /* -----------------------------03.05.00 12:56-------------------------------- ---------------------------------------------------------------------------*/ -Any SwXTextCursor::GetPropertyValue( +uno::Any SwUnoCursorHelper::GetPropertyValue( SwPaM& rPaM, const SfxItemPropertySet& rPropSet, const OUString& rPropertyName) - throw( UnknownPropertyException, WrappedTargetException, RuntimeException) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - Any aAny; - const SfxItemPropertySimpleEntry* pEntry = rPropSet.getPropertyMap()->getByName( - rPropertyName); - if(pEntry) + uno::Any aAny; + SfxItemPropertySimpleEntry const*const pEntry = + rPropSet.getPropertyMap()->getByName(rPropertyName); + + if (!pEntry) { - PropertyState eTemp; - BOOL bDone = SwUnoCursorHelper::getCrsrPropertyValue( *pEntry, rPaM, &aAny, eTemp ); - if(!bDone) - { - SfxItemSet aSet(rPaM.GetDoc()->GetAttrPool(), - RES_CHRATR_BEGIN, RES_FRMATR_END -1, - RES_TXTATR_UNKNOWN_CONTAINER, RES_TXTATR_UNKNOWN_CONTAINER, - RES_UNKNOWNATR_CONTAINER, RES_UNKNOWNATR_CONTAINER, - 0L); - SwXTextCursor::GetCrsrAttr(rPaM, aSet); + throw beans::UnknownPropertyException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) + + rPropertyName, static_cast(0)); + } - rPropSet.getPropertyValue(*pEntry, aSet, aAny); - } + beans::PropertyState eTemp; + const sal_Bool bDone = SwUnoCursorHelper::getCrsrPropertyValue( + *pEntry, rPaM, &aAny, eTemp ); + + if (!bDone) + { + SfxItemSet aSet(rPaM.GetDoc()->GetAttrPool(), + RES_CHRATR_BEGIN, RES_FRMATR_END - 1, + RES_TXTATR_UNKNOWN_CONTAINER, RES_TXTATR_UNKNOWN_CONTAINER, + RES_UNKNOWNATR_CONTAINER, RES_UNKNOWNATR_CONTAINER, + 0L); + SwUnoCursorHelper::GetCrsrAttr(rPaM, aSet); + + rPropSet.getPropertyValue(*pEntry, aSet, aAny); } - else - throw UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( 0 ) ); return aAny; } /* -----------------------------03.05.00 12:57-------------------------------- ---------------------------------------------------------------------------*/ -void SwXTextCursor::SetPropertyValue( - SwPaM& rPaM, const SfxItemPropertySet& rPropSet, const OUString& rPropertyName, - const Any& aValue, USHORT nAttrMode) - throw (UnknownPropertyException, PropertyVetoException, - IllegalArgumentException, WrappedTargetException, RuntimeException) +void SwUnoCursorHelper::SetPropertyValue( + SwPaM& rPaM, const SfxItemPropertySet& rPropSet, + const OUString& rPropertyName, + const uno::Any& rValue, + const SetAttrMode nAttrMode, const bool bTableMode) +throw (beans::UnknownPropertyException, beans::PropertyVetoException, + lang::IllegalArgumentException, lang::WrappedTargetException, + uno::RuntimeException) { - SwDoc* pDoc = rPaM.GetDoc(); - const SfxItemPropertySimpleEntry* pEntry = rPropSet.getPropertyMap()->getByName(rPropertyName); - if(pEntry) + SwDoc *const pDoc = rPaM.GetDoc(); + SfxItemPropertySimpleEntry const*const pEntry = + rPropSet.getPropertyMap()->getByName(rPropertyName); + if (!pEntry) { - if( pEntry->nFlags & PropertyAttribute::READONLY) - throw PropertyVetoException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( 0 ) ); + throw beans::UnknownPropertyException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) + + rPropertyName, + static_cast(0)); + } - SfxItemSet aItemSet( pDoc->GetAttrPool(), pEntry->nWID, pEntry->nWID ); - SwXTextCursor::GetCrsrAttr( rPaM, aItemSet ); + if (pEntry->nFlags & beans::PropertyAttribute::READONLY) + { + throw beans::PropertyVetoException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Property is read-only: ")) + + rPropertyName, + static_cast(0)); + } + + SfxItemSet aItemSet( pDoc->GetAttrPool(), pEntry->nWID, pEntry->nWID ); + SwUnoCursorHelper::GetCrsrAttr( rPaM, aItemSet ); - if(!lcl_setCrsrPropertyValue( pEntry, rPaM, aItemSet, aValue )) - rPropSet.setPropertyValue(*pEntry, aValue, aItemSet ); - SwXTextCursor::SetCrsrAttr(rPaM, aItemSet, nAttrMode ); + if (!SwUnoCursorHelper::SetCursorPropertyValue( + *pEntry, rValue, rPaM, aItemSet)) + { + rPropSet.setPropertyValue(*pEntry, rValue, aItemSet ); } - else - throw UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( 0 ) ); + SwUnoCursorHelper::SetCrsrAttr(rPaM, aItemSet, nAttrMode, bTableMode); } + /* -----------------------------03.05.00 13:16-------------------------------- ---------------------------------------------------------------------------*/ -Sequence< PropertyState > SwXTextCursor::GetPropertyStates( +uno::Sequence< beans::PropertyState > +SwUnoCursorHelper::GetPropertyStates( SwPaM& rPaM, const SfxItemPropertySet& rPropSet, - const Sequence< OUString >& PropertyNames, - SwGetPropertyStatesCaller eCaller ) - throw(UnknownPropertyException, RuntimeException) + const uno::Sequence< OUString >& rPropertyNames, + const SwGetPropertyStatesCaller eCaller) +throw (beans::UnknownPropertyException, uno::RuntimeException) { - const OUString* pNames = PropertyNames.getConstArray(); - Sequence< PropertyState > aRet ( PropertyNames.getLength() ); - PropertyState* pStates = aRet.getArray(); + const OUString* pNames = rPropertyNames.getConstArray(); + uno::Sequence< beans::PropertyState > aRet(rPropertyNames.getLength()); + beans::PropertyState* pStates = aRet.getArray(); + SfxItemPropertyMap const*const pMap = rPropSet.getPropertyMap(); + ::std::auto_ptr pSet; + ::std::auto_ptr pSetParent; - SfxItemSet *pSet = 0, *pSetParent = 0; - const SfxItemPropertyMap *pMap = rPropSet.getPropertyMap(); - for( INT32 i = 0, nEnd = PropertyNames.getLength(); i < nEnd; i++ ) + for (sal_Int32 i = 0, nEnd = rPropertyNames.getLength(); i < nEnd; i++) { - const SfxItemPropertySimpleEntry* pEntry = pMap->getByName( pNames[i] ); + SfxItemPropertySimpleEntry const*const pEntry = + pMap->getByName( pNames[i] ); if(!pEntry) { - if(pNames[i].equalsAsciiL( SW_PROP_NAME(UNO_NAME_IS_SKIP_HIDDEN_TEXT)) || - pNames[i].equalsAsciiL( SW_PROP_NAME(UNO_NAME_IS_SKIP_PROTECTED_TEXT))) + if (pNames[i].equalsAsciiL( SW_PROP_NAME(UNO_NAME_IS_SKIP_HIDDEN_TEXT)) || + pNames[i].equalsAsciiL( SW_PROP_NAME(UNO_NAME_IS_SKIP_PROTECTED_TEXT))) { pStates[i] = beans::PropertyState_DEFAULT_VALUE; continue; } - else if( SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION_TOLERANT == eCaller ) + else if (SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION_TOLERANT == + eCaller) { //this values marks the element as unknown property pStates[i] = beans::PropertyState_MAKE_FIXED_SIZE; continue; } else - throw UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pNames[i], static_cast < cppu::OWeakObject * > ( 0 ) ); + { + throw beans::UnknownPropertyException( + OUString( RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) + + pNames[i], + static_cast(0)); + } } - if ((eCaller == SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION || eCaller == SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION_TOLERANT) && + if (((SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION == eCaller) || + (SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION_TOLERANT == eCaller)) && pEntry->nWID < FN_UNO_RANGE_BEGIN && pEntry->nWID > FN_UNO_RANGE_END && pEntry->nWID < RES_CHRATR_BEGIN && pEntry->nWID > RES_TXTATR_END ) + { pStates[i] = beans::PropertyState_DEFAULT_VALUE; + } else { if ( pEntry->nWID >= FN_UNO_RANGE_BEGIN && pEntry->nWID <= FN_UNO_RANGE_END ) - SwUnoCursorHelper::getCrsrPropertyValue(*pEntry, rPaM, 0, pStates[i] ); + { + SwUnoCursorHelper::getCrsrPropertyValue( + *pEntry, rPaM, 0, pStates[i] ); + } else { - if( !pSet ) + if (!pSet.get()) { switch ( eCaller ) { case SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION_TOLERANT: case SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION: - pSet = new SfxItemSet( rPaM.GetDoc()->GetAttrPool(), - RES_CHRATR_BEGIN, RES_TXTATR_END ); + pSet.reset( + new SfxItemSet( rPaM.GetDoc()->GetAttrPool(), + RES_CHRATR_BEGIN, RES_TXTATR_END )); break; case SW_PROPERTY_STATE_CALLER_SINGLE_VALUE_ONLY: - pSet = new SfxItemSet( rPaM.GetDoc()->GetAttrPool(), - pEntry->nWID, pEntry->nWID ); + pSet.reset( + new SfxItemSet( rPaM.GetDoc()->GetAttrPool(), + pEntry->nWID, pEntry->nWID )); break; default: - pSet = new SfxItemSet( rPaM.GetDoc()->GetAttrPool(), + pSet.reset( new SfxItemSet( + rPaM.GetDoc()->GetAttrPool(), RES_CHRATR_BEGIN, RES_FRMATR_END - 1, RES_UNKNOWNATR_CONTAINER, RES_UNKNOWNATR_CONTAINER, RES_TXTATR_UNKNOWN_CONTAINER, RES_TXTATR_UNKNOWN_CONTAINER, - 0L ); + 0L )); } // --> OD 2006-07-12 #i63870# - SwXTextCursor::GetCrsrAttr( rPaM, *pSet ); + SwUnoCursorHelper::GetCrsrAttr( rPaM, *pSet ); // <-- } - if( pSet->Count() ) - pStates[i] = rPropSet.getPropertyState( *pEntry, *pSet ); - else - pStates[i] = PropertyState_DEFAULT_VALUE; + pStates[i] = ( pSet->Count() ) + ? rPropSet.getPropertyState( *pEntry, *pSet ) + : beans::PropertyState_DEFAULT_VALUE; //try again to find out if a value has been inherited if( beans::PropertyState_DIRECT_VALUE == pStates[i] ) { - if( !pSetParent ) + if (!pSetParent.get()) { - pSetParent = pSet->Clone( FALSE ); + pSetParent.reset( pSet->Clone( FALSE ) ); // --> OD 2006-07-12 #i63870# - SwXTextCursor::GetCrsrAttr( rPaM, *pSetParent, TRUE, FALSE ); + SwUnoCursorHelper::GetCrsrAttr( + rPaM, *pSetParent, TRUE, FALSE ); // <-- } - if( (pSetParent)->Count() ) - pStates[i] = rPropSet.getPropertyState( *pEntry, *pSetParent ); - else - pStates[i] = PropertyState_DEFAULT_VALUE; + pStates[i] = ( (pSetParent)->Count() ) + ? rPropSet.getPropertyState( *pEntry, *pSetParent ) + : beans::PropertyState_DEFAULT_VALUE; } } } } - delete pSet; - delete pSetParent; return aRet; } /* -----------------------------03.05.00 13:17-------------------------------- ---------------------------------------------------------------------------*/ -PropertyState SwXTextCursor::GetPropertyState( - SwPaM& rPaM, const SfxItemPropertySet& rPropSet, const OUString& rPropertyName) - throw(UnknownPropertyException, RuntimeException) +beans::PropertyState SwUnoCursorHelper::GetPropertyState( + SwPaM& rPaM, const SfxItemPropertySet& rPropSet, + const OUString& rPropertyName) +throw (beans::UnknownPropertyException, uno::RuntimeException) { - Sequence < OUString > aStrings ( 1 ); + uno::Sequence< OUString > aStrings ( 1 ); aStrings[0] = rPropertyName; - Sequence < PropertyState > aSeq = GetPropertyStates( rPaM, rPropSet, aStrings, SW_PROPERTY_STATE_CALLER_SINGLE_VALUE_ONLY ); + uno::Sequence< beans::PropertyState > aSeq = + GetPropertyStates(rPaM, rPropSet, aStrings, + SW_PROPERTY_STATE_CALLER_SINGLE_VALUE_ONLY ); return aSeq[0]; } /* -----------------------------03.05.00 13:20-------------------------------- ---------------------------------------------------------------------------*/ -void lcl_SelectParaAndReset ( SwPaM &rPaM, SwDoc* pDoc, const SvUShortsSort* pWhichIds = 0 ) +static void +lcl_SelectParaAndReset( SwPaM &rPaM, SwDoc & rDoc, + SvUShortsSort const*const pWhichIds = 0 ) { // if we are reseting paragraph attributes, we need to select the full paragraph first SwPosition aStart = *rPaM.Start(); SwPosition aEnd = *rPaM.End(); - auto_ptr < SwUnoCrsr > pTemp ( pDoc->CreateUnoCrsr(aStart, FALSE) ); + ::std::auto_ptr< SwUnoCrsr > pTemp ( rDoc.CreateUnoCrsr(aStart, FALSE) ); if(!SwUnoCursorHelper::IsStartOfPara(*pTemp)) + { pTemp->MovePara(fnParaCurr, fnParaStart); + } pTemp->SetMark(); *pTemp->GetPoint() = aEnd; - SwXTextCursor::SelectPam(*pTemp, sal_True); + SwUnoCursorHelper::SelectPam(*pTemp, true); if(!SwUnoCursorHelper::IsEndOfPara(*pTemp)) + { pTemp->MovePara(fnParaCurr, fnParaEnd); - pDoc->ResetAttrs(*pTemp, sal_True, pWhichIds); + } + rDoc.ResetAttrs(*pTemp, sal_True, pWhichIds); } -void SwXTextCursor::SetPropertyToDefault( +void SwUnoCursorHelper::SetPropertyToDefault( SwPaM& rPaM, const SfxItemPropertySet& rPropSet, const OUString& rPropertyName) - throw(UnknownPropertyException, RuntimeException) +throw (beans::UnknownPropertyException, uno::RuntimeException) { - NAMESPACE_VOS(OGuard) aGuard(Application::GetSolarMutex()); - SwDoc* pDoc = rPaM.GetDoc(); - const SfxItemPropertySimpleEntry* pEntry = rPropSet.getPropertyMap()->getByName( rPropertyName); - if(pEntry) + SwDoc & rDoc = *rPaM.GetDoc(); + SfxItemPropertySimpleEntry const*const pEntry = + rPropSet.getPropertyMap()->getByName(rPropertyName); + if (!pEntry) + { + throw beans::UnknownPropertyException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) + + rPropertyName, static_cast(0)); + } + + if (pEntry->nFlags & beans::PropertyAttribute::READONLY) + { + throw uno::RuntimeException(OUString(RTL_CONSTASCII_USTRINGPARAM( + "setPropertyToDefault: property is read-only: ")) + + rPropertyName, 0); + } + + if (pEntry->nWID < RES_FRMATR_END) { - if ( pEntry->nFlags & PropertyAttribute::READONLY) - throw RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "setPropertyToDefault: property is read-only: " ) ) + rPropertyName, 0 ); - if(pEntry->nWID < RES_FRMATR_END) + SvUShortsSort aWhichIds; + aWhichIds.Insert(pEntry->nWID); + if (pEntry->nWID < RES_PARATR_BEGIN) { - SvUShortsSort aWhichIds; - aWhichIds.Insert(pEntry->nWID); - if(pEntry->nWID < RES_PARATR_BEGIN) - pDoc->ResetAttrs(rPaM, sal_True, &aWhichIds); - else - lcl_SelectParaAndReset ( rPaM, pDoc, &aWhichIds ); + rDoc.ResetAttrs(rPaM, sal_True, &aWhichIds); } else - SwUnoCursorHelper::resetCrsrPropertyValue(*pEntry, rPaM); + { + lcl_SelectParaAndReset ( rPaM, rDoc, &aWhichIds ); + } } else - throw UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( 0 ) ); + { + SwUnoCursorHelper::resetCrsrPropertyValue(*pEntry, rPaM); + } } + /* -----------------------------03.05.00 13:19-------------------------------- ---------------------------------------------------------------------------*/ -Any SwXTextCursor::GetPropertyDefault( +uno::Any SwUnoCursorHelper::GetPropertyDefault( SwPaM& rPaM, const SfxItemPropertySet& rPropSet, const OUString& rPropertyName) - throw( UnknownPropertyException, WrappedTargetException, RuntimeException) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - Any aRet; - SwDoc* pDoc = rPaM.GetDoc(); - const SfxItemPropertySimpleEntry* pEntry = rPropSet.getPropertyMap()->getByName( rPropertyName); - if(pEntry) + SfxItemPropertySimpleEntry const*const pEntry = + rPropSet.getPropertyMap()->getByName(rPropertyName); + if (!pEntry) { - if(pEntry->nWID < RES_FRMATR_END) - { - const SfxPoolItem& rDefItem = pDoc->GetAttrPool().GetDefaultItem(pEntry->nWID); - rDefItem.QueryValue(aRet, pEntry->nMemberId); - } + throw beans::UnknownPropertyException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) + + rPropertyName, static_cast(0)); + } + + uno::Any aRet; + if (pEntry->nWID < RES_FRMATR_END) + { + SwDoc & rDoc = *rPaM.GetDoc(); + const SfxPoolItem& rDefItem = + rDoc.GetAttrPool().GetDefaultItem(pEntry->nWID); + rDefItem.QueryValue(aRet, pEntry->nMemberId); } - else - throw UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( 0 ) ); return aRet; } /*-- 09.12.98 14:18:54--------------------------------------------------- @@ -2276,7 +2419,10 @@ void SwXTextCursor::setPropertyValue(const OUString& rPropertyName, const uno::A pUnoCrsr->SetSkipOverProtectSections(bSet); } else - SetPropertyValue(*pUnoCrsr, *m_pPropSet, rPropertyName, aValue); + { + SwUnoCursorHelper::SetPropertyValue(*pUnoCrsr, + *m_pPropSet, rPropertyName, aValue); + } } else throw uno::RuntimeException(); @@ -2304,7 +2450,10 @@ Any SwXTextCursor::getPropertyValue(const OUString& rPropertyName) aAny.setValue(&bSet, ::getBooleanCppuType()); } else - aAny = GetPropertyValue(*pUnoCrsr, *m_pPropSet, rPropertyName); + { + aAny = SwUnoCursorHelper::GetPropertyValue(*pUnoCrsr, + *m_pPropSet, rPropertyName); + } } else throw uno::RuntimeException(); @@ -2350,7 +2499,8 @@ beans::PropertyState SwXTextCursor::getPropertyState(const OUString& rPropertyNa SwUnoCrsr* pUnoCrsr = GetCrsr(); if(pUnoCrsr) { - eRet = GetPropertyState(*pUnoCrsr, *m_pPropSet, rPropertyName); + eRet = SwUnoCursorHelper::GetPropertyState( + *pUnoCrsr, *m_pPropSet, rPropertyName); } else throw RuntimeException(); @@ -2367,7 +2517,8 @@ uno::Sequence< beans::PropertyState > SwXTextCursor::getPropertyStates( SwUnoCrsr* pUnoCrsr = GetCrsr(); if(!pUnoCrsr) throw RuntimeException(); - return GetPropertyStates(*pUnoCrsr, *m_pPropSet, PropertyNames); + return SwUnoCursorHelper::GetPropertyStates( + *pUnoCrsr, *m_pPropSet, PropertyNames); } /*-- 05.03.99 11:36:12--------------------------------------------------- @@ -2430,7 +2581,7 @@ void SAL_CALL SwXTextCursor::setAllPropertiesToDefault() } } if (aParaWhichIds.Count()) - lcl_SelectParaAndReset( *pUnoCrsr, pUnoCrsr->GetDoc(), &aParaWhichIds ); + lcl_SelectParaAndReset( *pUnoCrsr, *pUnoCrsr->GetDoc(), &aParaWhichIds ); if (aWhichIds.Count() ) pUnoCrsr->GetDoc()->ResetAttrs( *pUnoCrsr, sal_True, &aWhichIds ); } @@ -2479,7 +2630,7 @@ void SAL_CALL SwXTextCursor::setPropertiesToDefault( const Sequence< OUString >& } if ( aParaWhichIds.Count() ) - lcl_SelectParaAndReset ( *pUnoCrsr, pDoc, &aParaWhichIds ); + lcl_SelectParaAndReset ( *pUnoCrsr, *pDoc, &aParaWhichIds ); if (aWhichIds.Count() ) pDoc->ResetAttrs(*pUnoCrsr, sal_True, &aWhichIds); } @@ -2565,7 +2716,7 @@ throw (lang::IllegalArgumentException, io::IOException, ---------------------------------------------------------------------------*/ uno::Sequence< beans::PropertyValue > -SwXTextCursor::createSortDescriptor(sal_Bool bFromTable) +SwUnoCursorHelper::CreateSortDescriptor(const bool bFromTable) { uno::Sequence< beans::PropertyValue > aRet(5); beans::PropertyValue* pArray = aRet.getArray(); @@ -2575,10 +2726,7 @@ SwXTextCursor::createSortDescriptor(sal_Bool bFromTable) pArray[0] = beans::PropertyValue(C2U("IsSortInTable"), -1, aVal, beans::PropertyState_DIRECT_VALUE); - String sSpace(String::CreateFromAscii(" ")); - sal_Unicode uSpace = sSpace.GetChar(0); - - aVal <<= uSpace; + aVal <<= sal_Unicode(' '); pArray[1] = beans::PropertyValue(C2U("Delimiter"), -1, aVal, beans::PropertyState_DIRECT_VALUE); @@ -2593,15 +2741,17 @@ SwXTextCursor::createSortDescriptor(sal_Bool bFromTable) uno::Sequence< table::TableSortField > aFields(3); table::TableSortField* pFields = aFields.getArray(); - Locale aLang( SvxCreateLocale( LANGUAGE_SYSTEM ) ); + lang::Locale aLang( SvxCreateLocale( LANGUAGE_SYSTEM ) ); // get collator algorithm to be used for the locale uno::Sequence< OUString > aSeq( GetAppCollator().listCollatorAlgorithms( aLang ) ); - INT32 nLen = aSeq.getLength(); + const sal_Int32 nLen = aSeq.getLength(); DBG_ASSERT( nLen > 0, "list of collator algorithms is empty!"); OUString aCollAlg; if (nLen > 0) + { aCollAlg = aSeq.getConstArray()[0]; + } #if OSL_DEBUG_LEVEL > 1 const OUString *pTxt = aSeq.getConstArray(); @@ -2643,13 +2793,14 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SwXTextCursor::createSortDescriptor() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - return SwXTextCursor::createSortDescriptor(sal_False); + + return SwUnoCursorHelper::CreateSortDescriptor(false); } /* -----------------------------15.12.00 14:06-------------------------------- ---------------------------------------------------------------------------*/ -sal_Bool SwXTextCursor::convertSortProperties( +sal_Bool SwUnoCursorHelper::ConvertSortProperties( const uno::Sequence< beans::PropertyValue >& rDescriptor, SwSortOptions& rSortOpt) { @@ -2679,14 +2830,14 @@ sal_Bool SwXTextCursor::convertSortProperties( sal_Bool bOldSortdescriptor(sal_False); sal_Bool bNewSortdescriptor(sal_False); - for (int n = 0; n < rDescriptor.getLength(); ++n) + for (sal_Int32 n = 0; n < rDescriptor.getLength(); ++n) { uno::Any aValue( pProperties[n].Value ); // String sPropName = pProperties[n].Name; const OUString& rPropName = pProperties[n].Name; // old and new sortdescriptor - if (COMPARE_EQUAL == rPropName.compareToAscii("IsSortInTable")) + if (rPropName.equalsAscii("IsSortInTable")) { if (aValue.getValueType() == ::getBooleanCppuType()) { @@ -2697,7 +2848,7 @@ sal_Bool SwXTextCursor::convertSortProperties( bRet = sal_False; } } - else if (COMPARE_EQUAL == rPropName.compareToAscii("Delimiter")) + else if (rPropName.equalsAscii("Delimiter")) { sal_Unicode uChar = sal_Unicode(); if (aValue >>= uChar) @@ -2710,12 +2861,12 @@ sal_Bool SwXTextCursor::convertSortProperties( } } // old sortdescriptor - else if (COMPARE_EQUAL == rPropName.compareToAscii("SortColumns")) + else if (rPropName.equalsAscii("SortColumns")) { bOldSortdescriptor = sal_True; - if (aValue.getValueType() == ::getBooleanCppuType()) + sal_Bool bTemp(sal_False); + if (aValue >>= bTemp) { - sal_Bool bTemp = *(sal_Bool*)aValue.getValue(); rSortOpt.eDirection = bTemp ? SRT_COLUMNS : SRT_ROWS; } else @@ -2723,12 +2874,12 @@ sal_Bool SwXTextCursor::convertSortProperties( bRet = sal_False; } } - else if (COMPARE_EQUAL == rPropName.compareToAscii("IsCaseSensitive")) + else if ( rPropName.equalsAscii("IsCaseSensitive")) { bOldSortdescriptor = sal_True; - if (aValue.getValueType() == ::getBooleanCppuType()) + sal_Bool bTemp(sal_False); + if (aValue >>= bTemp) { - sal_Bool bTemp = *(sal_Bool*)aValue.getValue(); rSortOpt.bIgnoreCase = !bTemp; } else @@ -2736,10 +2887,10 @@ sal_Bool SwXTextCursor::convertSortProperties( bRet = sal_False; } } - else if (COMPARE_EQUAL == rPropName.compareToAscii("CollatorLocale")) + else if (rPropName.equalsAscii("CollatorLocale")) { bOldSortdescriptor = sal_True; - Locale aLocale; + lang::Locale aLocale; if (aValue >>= aLocale) { rSortOpt.nLanguage = SvxLocaleToLanguage( aLocale ); @@ -2749,8 +2900,7 @@ sal_Bool SwXTextCursor::convertSortProperties( bRet = sal_False; } } - else if (COMPARE_EQUAL == rPropName.compareToAscii("CollatorAlgorithm", - 17) && + else if (rPropName.matchAsciiL("CollatorAlgorithm", 17) && rPropName.getLength() == 18 && (rPropName.getStr()[17] >= '0' && rPropName.getStr()[17] <= '9')) { @@ -2767,8 +2917,7 @@ sal_Bool SwXTextCursor::convertSortProperties( bRet = sal_False; } } - else if (COMPARE_EQUAL == rPropName.compareToAscii("SortRowOrColumnNo", - 17) && + else if (rPropName.matchAsciiL("SortRowOrColumnNo", 17) && rPropName.getLength() == 18 && (rPropName.getStr()[17] >= '0' && rPropName.getStr()[17] <= '9')) { @@ -2826,7 +2975,7 @@ sal_Bool SwXTextCursor::convertSortProperties( } } // new sortdescriptor - else if (COMPARE_EQUAL == rPropName.compareToAscii("IsSortColumns")) + else if (rPropName.equalsAscii("IsSortColumns")) { bNewSortdescriptor = sal_True; if (aValue.getValueType() == ::getBooleanCppuType()) @@ -2839,7 +2988,7 @@ sal_Bool SwXTextCursor::convertSortProperties( bRet = sal_False; } } - else if (COMPARE_EQUAL == rPropName.compareToAscii("SortFields")) + else if (rPropName.equalsAscii("SortFields")) { bNewSortdescriptor = sal_True; uno::Sequence < table::TableSortField > aFields; @@ -2917,7 +3066,7 @@ throw (uno::RuntimeException) if (pUnoCrsr->HasMark()) { - if (!SwXTextCursor::convertSortProperties(rDescriptor, aSortOpt)) + if (!SwUnoCursorHelper::ConvertSortProperties(rDescriptor, aSortOpt)) { throw uno::RuntimeException(); } diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index a71fe16f7024..84d276e6618e 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -80,7 +80,6 @@ #include #include #include -#include #include #include #include @@ -132,14 +131,6 @@ using namespace ::com::sun::star; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::text; -using namespace ::com::sun::star::container; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::drawing; - using ::rtl::OUString; @@ -359,28 +350,29 @@ void ClientModify(SwClient* pClient, SfxPoolItem *pOld, SfxPoolItem *pNew) /*-- 09.12.98 14:19:03--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextCursor::SetCrsrAttr(SwPaM& rPam, const SfxItemSet& rSet, USHORT nAttrMode) +void SwUnoCursorHelper::SetCrsrAttr(SwPaM & rPam, + const SfxItemSet& rSet, + const SetAttrMode nAttrMode, const bool bTableMode) { - sal_uInt16 nFlags = nsSetAttrMode::SETATTR_APICALL | (nAttrMode & nsSetAttrMode::SETATTR_NOFORMATATTR); - if(nAttrMode & CRSR_ATTR_MODE_DONTREPLACE) - nFlags |= nsSetAttrMode::SETATTR_DONTREPLACE; + const SetAttrMode nFlags = nAttrMode | nsSetAttrMode::SETATTR_APICALL; SwDoc* pDoc = rPam.GetDoc(); //StartEndAction UnoActionContext aAction(pDoc); - SwPaM* pCrsr = &rPam; - if( pCrsr->GetNext() != pCrsr ) // Ring von Cursorn + if (rPam.GetNext() != &rPam) // Ring of Cursors { pDoc->StartUndo(UNDO_INSATTR, NULL); - SwPaM *_pStartCrsr = &rPam; + SwPaM *pCurrent = &rPam; do { - if( _pStartCrsr->HasMark() && ( (CRSR_ATTR_MODE_TABLE & nAttrMode) || - *_pStartCrsr->GetPoint() != *_pStartCrsr->GetMark() )) + if (pCurrent->HasMark() && + ( (bTableMode) || + (*pCurrent->GetPoint() != *pCurrent->GetMark()) )) { - pDoc->InsertItemSet(*_pStartCrsr, rSet, nFlags); + pDoc->InsertItemSet(*pCurrent, rSet, nFlags); } - } while( (_pStartCrsr=(SwPaM *)_pStartCrsr->GetNext()) != &rPam ); + pCurrent= static_cast(pCurrent->GetNext()); + } while (pCurrent != &rPam); pDoc->EndUndo(UNDO_INSATTR, NULL); } @@ -388,7 +380,7 @@ void SwXTextCursor::SetCrsrAttr(SwPaM& rPam, const SfxItemSet& rSet, USHORT nAtt { // if( !HasSelection() ) // UpdateAttr(); - pDoc->InsertItemSet( *pCrsr, rSet, nFlags ); + pDoc->InsertItemSet( rPam, rSet, nFlags ); } //#outline level,add by zhaojianwei if( rSet.GetItemState( RES_PARATR_OUTLINELEVEL, false ) >= SFX_ITEM_AVAILABLE ) @@ -398,7 +390,6 @@ void SwXTextCursor::SetCrsrAttr(SwPaM& rPam, const SfxItemSet& rSet, USHORT nAtt { rPam.GetDoc()->GetNodes().UpdateOutlineNode( *pTmpNode ); } - } //<-end,zhaojianwei } @@ -408,72 +399,72 @@ void SwXTextCursor::SetCrsrAttr(SwPaM& rPam, const SfxItemSet& rSet, USHORT nAtt // --> OD 2006-07-12 #i63870# // split third parameter into new parameters // and to get better control about resulting -void SwXTextCursor::GetCrsrAttr( SwPaM& rPam, - SfxItemSet& rSet, - BOOL bOnlyTxtAttr, - BOOL bGetFromChrFmt ) +void SwUnoCursorHelper::GetCrsrAttr(SwPaM & rPam, + SfxItemSet & rSet, const bool bOnlyTxtAttr, const bool bGetFromChrFmt) { static const sal_uInt16 nMaxLookup = 1000; SfxItemSet aSet( *rSet.GetPool(), rSet.GetRanges() ); SfxItemSet *pSet = &rSet; - SwPaM *_pStartCrsr = &rPam; + SwPaM *pCurrent = & rPam; do { - ULONG nSttNd = _pStartCrsr->GetMark()->nNode.GetIndex(), - nEndNd = _pStartCrsr->GetPoint()->nNode.GetIndex(); - xub_StrLen nSttCnt = _pStartCrsr->GetMark()->nContent.GetIndex(), - nEndCnt = _pStartCrsr->GetPoint()->nContent.GetIndex(); - - if( nSttNd > nEndNd || ( nSttNd == nEndNd && nSttCnt > nEndCnt )) - { - sal_uInt32 nTmp = nSttNd; nSttNd = nEndNd; nEndNd = nTmp; - nTmp = nSttCnt; nSttCnt = nEndCnt; nEndCnt = (sal_uInt16)nTmp; - } + SwPosition const & rStart( *pCurrent->Start() ); + SwPosition const & rEnd( *pCurrent->End() ); + const ULONG nSttNd = rStart.nNode.GetIndex(); + const ULONG nEndNd = rEnd .nNode.GetIndex(); - if( nEndNd - nSttNd >= nMaxLookup ) - { - rSet.ClearItem(); - rSet.InvalidateAllItems(); - return;// uno::Any(); - } + if (nEndNd - nSttNd >= nMaxLookup) + { + rSet.ClearItem(); + rSet.InvalidateAllItems(); + return;// uno::Any(); + } - // beim 1.Node traegt der Node die Werte in den GetSet ein (Initial) - // alle weiteren Nodes werden zum GetSet zu gemergt - for( ULONG n = nSttNd; n <= nEndNd; ++n ) + // the first node inserts the values into the get set + // all other nodes merge their values into the get set + for (ULONG n = nSttNd; n <= nEndNd; ++n) + { + SwNode *const pNd = rPam.GetDoc()->GetNodes()[ n ]; + switch (pNd->GetNodeType()) { - SwNode* pNd = rPam.GetDoc()->GetNodes()[ n ]; - switch( pNd->GetNodeType() ) - { case ND_TEXTNODE: - { - xub_StrLen nStt = n == nSttNd ? nSttCnt : 0, - nEnd = n == nEndNd ? nEndCnt - : ((SwTxtNode*)pNd)->GetTxt().Len(); - ((SwTxtNode*)pNd)->GetAttr( *pSet, nStt, nEnd, bOnlyTxtAttr, bGetFromChrFmt ); - } - break; + { + const xub_StrLen nStart = (n == nSttNd) + ? rStart.nContent.GetIndex() : 0; + const xub_StrLen nEnd = (n == nEndNd) + ? rEnd.nContent.GetIndex() + : static_cast(pNd)->GetTxt().Len(); + static_cast(pNd)->GetAttr( + *pSet, nStart, nEnd, bOnlyTxtAttr, bGetFromChrFmt); + } + break; case ND_GRFNODE: case ND_OLENODE: - ((SwCntntNode*)pNd)->GetAttr( *pSet ); - break; + static_cast(pNd)->GetAttr( *pSet ); + break; default: - pNd = 0; - } - - if( pNd ) - { - if( pSet != &rSet ) - rSet.MergeValues( aSet ); - - if( aSet.Count() ) - aSet.ClearItem(); + continue; // skip this node + } - } + if (pSet != &rSet) + { + rSet.MergeValues( aSet ); + } + else + { pSet = &aSet; } - } while( (_pStartCrsr=(SwPaM *)_pStartCrsr->GetNext()) != &rPam ); + + if (aSet.Count()) + { + aSet.ClearItem(); + } + } + pCurrent= static_cast(pCurrent->GetNext()); + } while ( pCurrent != &rPam ); } + /****************************************************************** * SwXParagraphEnumeration ******************************************************************/ @@ -967,7 +958,7 @@ throw (uno::RuntimeException) SwUnoCursorHelper::DocInsertStringSplitCR( m_pImpl->m_rDoc, aCursor, rText, bForceExpandHints); - SwXTextCursor::SelectPam(aCursor, sal_True); + SwUnoCursorHelper::SelectPam(aCursor, true); aCursor.Left(rText.getLength(), CRSR_SKIP_CHARS, FALSE, FALSE); } SetPositions(aCursor); @@ -1111,7 +1102,7 @@ OUString SAL_CALL SwXTextRange::getString() throw (uno::RuntimeException) SwPaM aPaM(GetDoc()->GetNodes()); if (GetPositions(aPaM) && aPaM.HasMark()) { - SwXTextCursor::getTextFromPam(aPaM, sRet); + SwUnoCursorHelper::GetTextFromPam(aPaM, sRet); } return sRet; } @@ -1488,7 +1479,7 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException, } SwPaM aPaM(GetDoc()->GetNodes()); GetPositions(aPaM); - SwXTextCursor::SetPropertyValue(aPaM, m_pImpl->m_rPropSet, + SwUnoCursorHelper::SetPropertyValue(aPaM, m_pImpl->m_rPropSet, rPropertyName, rValue); } @@ -1505,7 +1496,7 @@ throw (beans::UnknownPropertyException, lang::WrappedTargetException, } SwPaM aPaM(GetDoc()->GetNodes()); GetPositions(aPaM); - return SwXTextCursor::GetPropertyValue(aPaM, m_pImpl->m_rPropSet, + return SwUnoCursorHelper::GetPropertyValue(aPaM, m_pImpl->m_rPropSet, rPropertyName); } @@ -1565,7 +1556,7 @@ throw (beans::UnknownPropertyException, uno::RuntimeException) } SwPaM aPaM(GetDoc()->GetNodes()); GetPositions(aPaM); - return SwXTextCursor::GetPropertyState(aPaM, m_pImpl->m_rPropSet, + return SwUnoCursorHelper::GetPropertyState(aPaM, m_pImpl->m_rPropSet, rPropertyName); } @@ -1581,7 +1572,7 @@ throw (beans::UnknownPropertyException, uno::RuntimeException) } SwPaM aPaM(GetDoc()->GetNodes()); GetPositions(aPaM); - return SwXTextCursor::GetPropertyStates(aPaM, m_pImpl->m_rPropSet, + return SwUnoCursorHelper::GetPropertyStates(aPaM, m_pImpl->m_rPropSet, rPropertyName); } @@ -1596,7 +1587,7 @@ throw (beans::UnknownPropertyException, uno::RuntimeException) } SwPaM aPaM(GetDoc()->GetNodes()); GetPositions(aPaM); - SwXTextCursor::SetPropertyToDefault(aPaM, m_pImpl->m_rPropSet, + SwUnoCursorHelper::SetPropertyToDefault(aPaM, m_pImpl->m_rPropSet, rPropertyName); } @@ -1613,7 +1604,7 @@ throw (beans::UnknownPropertyException, lang::WrappedTargetException, } SwPaM aPaM(GetDoc()->GetNodes()); GetPositions(aPaM); - return SwXTextCursor::GetPropertyDefault(aPaM, m_pImpl->m_rPropSet, + return SwUnoCursorHelper::GetPropertyDefault(aPaM, m_pImpl->m_rPropSet, rPropertyName); } @@ -1834,24 +1825,25 @@ sal_Bool SAL_CALL SwXTextRanges::hasElements() throw (uno::RuntimeException) /* -----------------11.12.98 10:07------------------- * * --------------------------------------------------*/ -void SwXTextCursor::SetString(SwCursor& rCrsr, const OUString& rString) +void SwUnoCursorHelper::SetString(SwCursor & rCursor, const OUString& rString) { // Start/EndAction - SwDoc* pDoc = rCrsr.GetDoc(); + SwDoc *const pDoc = rCursor.GetDoc(); UnoActionContext aAction(pDoc); - String aText(rString); - xub_StrLen nTxtLen = aText.Len(); pDoc->StartUndo(UNDO_INSERT, NULL); - if(rCrsr.HasMark()) - pDoc->DeleteAndJoin(rCrsr); - if(nTxtLen) + if (rCursor.HasMark()) + { + pDoc->DeleteAndJoin(rCursor); + } + if (rString.getLength()) { + String aText(rString); const bool bSuccess( SwUnoCursorHelper::DocInsertStringSplitCR( - *pDoc, rCrsr, aText, false ) ); + *pDoc, rCursor, aText, false ) ); DBG_ASSERT( bSuccess, "DocInsertStringSplitCR" ); (void) bSuccess; - SwXTextCursor::SelectPam(rCrsr, sal_True); - rCrsr.Left(nTxtLen, CRSR_SKIP_CHARS, FALSE, FALSE); + SwUnoCursorHelper::SelectPam(rCursor, true); + rCursor.Left(rString.getLength(), CRSR_SKIP_CHARS, FALSE, FALSE); } pDoc->EndUndo(UNDO_INSERT, NULL); } diff --git a/sw/source/core/unocore/unoparagraph.cxx b/sw/source/core/unocore/unoparagraph.cxx index 17336d80f64c..8d6ee3f3a65d 100644 --- a/sw/source/core/unocore/unoparagraph.cxx +++ b/sw/source/core/unocore/unoparagraph.cxx @@ -37,7 +37,6 @@ #include #include #include -#include #include #include #include @@ -457,7 +456,7 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException, + pPropertyNames[nProp], static_cast< cppu::OWeakObject * >(&m_rThis)); } - SwXTextCursor::SetPropertyValue(aCursor, m_rPropSet, + SwUnoCursorHelper::SetPropertyValue(aCursor, m_rPropSet, pPropertyNames[nProp], pValues[nProp]); } } @@ -659,7 +658,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException) } else { - SwXTextCursor::SetPropertyValue( + SwUnoCursorHelper::SetPropertyValue( aCursor, m_pImpl->m_rPropSet, pProp[i], pValue[i]); } } @@ -973,7 +972,7 @@ throw (beans::UnknownPropertyException) case FN_UNO_PARA_STYLE: case FN_UNO_PARA_CONDITIONAL_STYLE_NAME: { - SwFmtColl* pFmt = SwXTextCursor::GetCurTxtFmtColl( + SwFmtColl* pFmt = SwUnoCursorHelper::GetCurTxtFmtColl( aPam, rEntry.nWID == FN_UNO_PARA_CONDITIONAL_STYLE_NAME); eRet = pFmt ? beans::PropertyState_DIRECT_VALUE : beans::PropertyState_AMBIGUOUS_VALUE; @@ -1132,7 +1131,7 @@ throw (beans::UnknownPropertyException, uno::RuntimeException) pTemp->SetMark(); *pTemp->GetPoint() = aEnd; //pTemp->Exchange(); - SwXTextCursor::SelectPam(*pTemp, sal_True); + SwUnoCursorHelper::SelectPam(*pTemp, true); if (!SwUnoCursorHelper::IsEndOfPara(*pTemp)) { pTemp->MovePara(fnParaCurr, fnParaEnd); @@ -1365,7 +1364,7 @@ OUString SAL_CALL SwXParagraph::getString() throw (uno::RuntimeException) SwPosition aPos( *pTxtNode ); SwCursor aCursor( aPos, 0, false ); SwParaSelection aParaSel( aCursor ); - SwXTextCursor::getTextFromPam(aCursor, aRet); + SwUnoCursorHelper::GetTextFromPam(aCursor, aRet); } else if (m_pImpl->IsDescriptor()) { @@ -1393,12 +1392,12 @@ throw (uno::RuntimeException) if (!SwUnoCursorHelper::IsStartOfPara(aCursor)) { aCursor.MovePara(fnParaCurr, fnParaStart); } - SwXTextCursor::SelectPam(aCursor, sal_True); + SwUnoCursorHelper::SelectPam(aCursor, true); if (pTxtNode->GetTxt().Len()) { aCursor.MovePara(fnParaCurr, fnParaEnd); } - SwXTextCursor::SetString(aCursor, aString); - SwXTextCursor::SelectPam(aCursor, sal_False); + SwUnoCursorHelper::SetString(aCursor, aString); + SwUnoCursorHelper::SelectPam(aCursor, false); } else if (m_pImpl->IsDescriptor()) { diff --git a/sw/source/core/unocore/unoport.cxx b/sw/source/core/unocore/unoport.cxx index 909c7bc7a450..55f8754d34b1 100644 --- a/sw/source/core/unocore/unoport.cxx +++ b/sw/source/core/unocore/unoport.cxx @@ -41,7 +41,6 @@ #include #include #include -#include #include #include #include @@ -241,7 +240,7 @@ void SwXTextPortion::setString(const OUString& aString) throw( uno::RuntimeExcep if (!pUnoCrsr) throw uno::RuntimeException(); - SwXTextCursor::SetString(*pUnoCrsr, aString); + SwUnoCursorHelper::SetString(*pUnoCrsr, aString); } /*-- 11.12.98 09:56:57--------------------------------------------------- @@ -275,7 +274,7 @@ void SwXTextPortion::setPropertyValue(const OUString& rPropertyName, if (!pUnoCrsr) throw uno::RuntimeException(); - SwXTextCursor::SetPropertyValue(*pUnoCrsr, *m_pPropSet, + SwUnoCursorHelper::SetPropertyValue(*pUnoCrsr, *m_pPropSet, rPropertyName, aValue); } /*-- 04.11.03 09:56:58--------------------------------------------------- @@ -426,7 +425,7 @@ void SwXTextPortion::GetPropertyValue( RES_UNKNOWNATR_CONTAINER, RES_UNKNOWNATR_CONTAINER, RES_TXTATR_UNKNOWN_CONTAINER, RES_TXTATR_UNKNOWN_CONTAINER, 0L); - SwXTextCursor::GetCrsrAttr(*pUnoCrsr, *pSet); + SwUnoCursorHelper::GetCrsrAttr(*pUnoCrsr, *pSet); } m_pPropSet->getPropertyValue(rEntry, *pSet, rVal); } @@ -503,7 +502,7 @@ void SAL_CALL SwXTextPortion::SetPropertyValues_Impl( if ( pEntry->nFlags & beans::PropertyAttribute::READONLY) throw beans::PropertyVetoException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + pPropertyNames[nProp], static_cast < cppu::OWeakObject * > ( this ) ); - SwXTextCursor::SetPropertyValue( *pUnoCrsr, *m_pPropSet, + SwUnoCursorHelper::SetPropertyValue( *pUnoCrsr, *m_pPropSet, pPropertyNames[nProp], pValues[nProp]); } } @@ -606,7 +605,7 @@ uno::Sequence< beans::SetPropertyTolerantFailed > SAL_CALL SwXTextPortion::setPr pFailed[ nFailed++ ].Result = beans::TolerantPropertySetResultType::PROPERTY_VETO; else { - SwXTextCursor::SetPropertyValue( + SwUnoCursorHelper::SetPropertyValue( *pUnoCrsr, *m_pPropSet, pProp[i], pValue[i] ); } } @@ -683,7 +682,8 @@ uno::Sequence< beans::GetDirectPropertyTolerantResult > SAL_CALL SwXTextPortion: const SfxItemPropertyMap* pPropMap = m_pPropSet->getPropertyMap(); - uno::Sequence< beans::PropertyState > aPropertyStates = SwXTextCursor::GetPropertyStates( + uno::Sequence< beans::PropertyState > aPropertyStates = + SwUnoCursorHelper::GetPropertyStates( *pUnoCrsr, *m_pPropSet, rPropertyNames, SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION_TOLERANT ); @@ -832,7 +832,7 @@ beans::PropertyState SwXTextPortion::getPropertyState(const OUString& rPropertyN } else { - eRet = SwXTextCursor::GetPropertyState(*pUnoCrsr, *m_pPropSet, + eRet = SwUnoCursorHelper::GetPropertyState(*pUnoCrsr, *m_pPropSet, rPropertyName); } return eRet; @@ -850,7 +850,7 @@ uno::Sequence< beans::PropertyState > SwXTextPortion::getPropertyStates( throw uno::RuntimeException(); uno::Sequence< beans::PropertyState > aRet = - SwXTextCursor::GetPropertyStates(*pUnoCrsr, *m_pPropSet, + SwUnoCursorHelper::GetPropertyStates(*pUnoCrsr, *m_pPropSet, rPropertyNames, SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION); if(GetTextPortionType() == PORTION_RUBY_START) @@ -876,7 +876,8 @@ void SwXTextPortion::setPropertyToDefault(const OUString& rPropertyName) if (!pUnoCrsr) throw uno::RuntimeException(); - SwXTextCursor::SetPropertyToDefault(*pUnoCrsr, *m_pPropSet, rPropertyName); + SwUnoCursorHelper::SetPropertyToDefault( + *pUnoCrsr, *m_pPropSet, rPropertyName); } /*-- 08.03.99 09:41:48--------------------------------------------------- @@ -890,7 +891,7 @@ uno::Any SwXTextPortion::getPropertyDefault(const OUString& rPropertyName) if (!pUnoCrsr) throw uno::RuntimeException(); - aRet = SwXTextCursor::GetPropertyDefault(*pUnoCrsr, *m_pPropSet, + aRet = SwUnoCursorHelper::GetPropertyDefault(*pUnoCrsr, *m_pPropSet, rPropertyName); return aRet; } diff --git a/sw/source/core/unocore/unoportenum.cxx b/sw/source/core/unocore/unoportenum.cxx index 605554253bf8..e780e95c361e 100644 --- a/sw/source/core/unocore/unoportenum.cxx +++ b/sw/source/core/unocore/unoportenum.cxx @@ -48,7 +48,7 @@ #include #include #include -#include +#include #include #include #include @@ -1150,7 +1150,7 @@ lcl_CreatePortions( // text at nCurrentIndex; i.e. it must be set _once_ per iteration uno::Reference< XTextRange > xRef; - SwXTextCursor::SelectPam(*pUnoCrsr, sal_True); // set mark + SwUnoCursorHelper::SelectPam(*pUnoCrsr, true); // set mark const sal_Int32 nFirstFrameIndex = lcl_ExportFrames( *PortionStack.top().first, diff --git a/sw/source/core/unocore/unosect.cxx b/sw/source/core/unocore/unosect.cxx index d9d6bafa31a1..fbe7e6e7eb5d 100644 --- a/sw/source/core/unocore/unosect.cxx +++ b/sw/source/core/unocore/unosect.cxx @@ -48,7 +48,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index 6143e7ed2661..2806a5984d24 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -109,10 +109,6 @@ using ::rtl::OUString; //----------------------------------------------------------------------------- -// from unoobj.cxx -extern void lcl_SetTxtFmtColl(const uno::Any& rAny, SwPaM& rPaM) throw (lang::IllegalArgumentException); -extern void lcl_setCharStyle(SwDoc* pDoc, const uno::Any aValue, SfxItemSet& rSet) throw (lang::IllegalArgumentException); - // from swtable.cxx extern void lcl_GetTblBoxColStr( sal_uInt16 nCol, String& rNm ); @@ -1854,12 +1850,6 @@ uno::Reference< beans::XPropertySetInfo > SwXTextTableCursor::getPropertySetInf /*-- 11.12.98 12:16:17--------------------------------------------------- -----------------------------------------------------------------------*/ -extern sal_Bool lcl_setCrsrPropertyValue(const SfxItemPropertySimpleEntry* pEntry, - SwPaM& rPam, - SfxItemSet& rSet, - const uno::Any& aValue ) throw (lang::IllegalArgumentException); - - void SwXTextTableCursor::setPropertyValue(const OUString& rPropertyName, const uno::Any& aValue) throw( beans::UnknownPropertyException, @@ -1903,16 +1893,21 @@ void SwXTextTableCursor::setPropertyValue(const OUString& rPropertyName, } break; case FN_UNO_PARA_STYLE: - lcl_SetTxtFmtColl(aValue, *pUnoCrsr); + SwUnoCursorHelper::SetTxtFmtColl(aValue, *pUnoCrsr); break; default: { SfxItemSet aItemSet( pDoc->GetAttrPool(), pEntry->nWID, pEntry->nWID ); - SwXTextCursor::GetCrsrAttr( pTblCrsr->GetSelRing(), aItemSet ); + SwUnoCursorHelper::GetCrsrAttr(pTblCrsr->GetSelRing(), + aItemSet); - if(!lcl_setCrsrPropertyValue( pEntry, pTblCrsr->GetSelRing(), aItemSet, aValue )) - m_pPropSet->setPropertyValue( *pEntry, aValue, aItemSet ); - SwXTextCursor::SetCrsrAttr( pTblCrsr->GetSelRing(), aItemSet, CRSR_ATTR_MODE_TABLE ); + if (!SwUnoCursorHelper::SetCursorPropertyValue( + *pEntry, aValue, pTblCrsr->GetSelRing(), aItemSet)) + { + m_pPropSet->setPropertyValue(*pEntry, aValue, aItemSet); + } + SwUnoCursorHelper::SetCrsrAttr(pTblCrsr->GetSelRing(), + aItemSet, nsSetAttrMode::SETATTR_DEFAULT, true); } } } @@ -1956,7 +1951,8 @@ uno::Any SwXTextTableCursor::getPropertyValue(const OUString& rPropertyName) break; case FN_UNO_PARA_STYLE: { - SwFmtColl* pFmt = SwXTextCursor::GetCurTxtFmtColl(*pUnoCrsr, FALSE); + SwFmtColl *const pFmt = + SwUnoCursorHelper::GetCurTxtFmtColl(*pUnoCrsr, FALSE); OUString sRet; if(pFmt) sRet = pFmt->GetName(); @@ -1970,7 +1966,8 @@ uno::Any SwXTextTableCursor::getPropertyValue(const OUString& rPropertyName) RES_UNKNOWNATR_CONTAINER, RES_UNKNOWNATR_CONTAINER, 0L); // erstmal die Attribute des Cursors - SwXTextCursor::GetCrsrAttr(pTblCrsr->GetSelRing(), aSet); + SwUnoCursorHelper::GetCrsrAttr(pTblCrsr->GetSelRing(), + aSet); m_pPropSet->getPropertyValue(*pEntry, aSet, aRet); } } @@ -3162,7 +3159,8 @@ uno::Sequence< beans::PropertyValue > SwXTextTable::createSortDescriptor(void) throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - return SwXTextCursor::createSortDescriptor(sal_True); + + return SwUnoCursorHelper::CreateSortDescriptor(true); } /*-- 11.12.98 12:42:49--------------------------------------------------- @@ -3174,7 +3172,7 @@ void SwXTextTable::sort(const uno::Sequence< beans::PropertyValue >& rDescriptor SwSortOptions aSortOpt; SwFrmFmt* pFmt = GetFrmFmt(); if(pFmt && - SwXTextCursor::convertSortProperties(rDescriptor, aSortOpt)) + SwUnoCursorHelper::ConvertSortProperties(rDescriptor, aSortOpt)) { SwTable* pTable = SwTable::FindTable( pFmt ); SwSelBoxes aBoxes; @@ -4157,11 +4155,16 @@ void SwXCellRange::setPropertyValue(const OUString& rPropertyName, default: { SfxItemSet aItemSet( pDoc->GetAttrPool(), pEntry->nWID, pEntry->nWID ); - SwXTextCursor::GetCrsrAttr( pCrsr->GetSelRing(), aItemSet ); + SwUnoCursorHelper::GetCrsrAttr(pCrsr->GetSelRing(), + aItemSet); - if(!lcl_setCrsrPropertyValue( pEntry, pCrsr->GetSelRing(), aItemSet, aValue )) - m_pPropSet->setPropertyValue(*pEntry, aValue, aItemSet ); - SwXTextCursor::SetCrsrAttr(pCrsr->GetSelRing(), aItemSet, CRSR_ATTR_MODE_TABLE ); + if (!SwUnoCursorHelper::SetCursorPropertyValue( + *pEntry, aValue, pCrsr->GetSelRing(), aItemSet)) + { + m_pPropSet->setPropertyValue(*pEntry, aValue, aItemSet); + } + SwUnoCursorHelper::SetCrsrAttr(pCrsr->GetSelRing(), + aItemSet, nsSetAttrMode::SETATTR_DEFAULT, true); } } } @@ -4214,7 +4217,8 @@ uno::Any SwXCellRange::getPropertyValue(const OUString& rPropertyName) throw( be break; case FN_UNO_PARA_STYLE: { - SwFmtColl* pTmpFmt = SwXTextCursor::GetCurTxtFmtColl(*pTblCrsr, FALSE); + SwFmtColl *const pTmpFmt = + SwUnoCursorHelper::GetCurTxtFmtColl(*pTblCrsr, FALSE); OUString sRet; if(pFmt) sRet = pTmpFmt->GetName(); @@ -4242,7 +4246,7 @@ uno::Any SwXCellRange::getPropertyValue(const OUString& rPropertyName) throw( be 0L); // erstmal die Attribute des Cursors SwUnoTableCrsr* pCrsr = dynamic_cast(pTblCrsr); - SwXTextCursor::GetCrsrAttr(pCrsr->GetSelRing(), aSet); + SwUnoCursorHelper::GetCrsrAttr(pCrsr->GetSelRing(), aSet); m_pPropSet->getPropertyValue(*pEntry, aSet, aRet); } } @@ -4875,7 +4879,8 @@ double SwXCellRange::getNotANumber(void) throw( uno::RuntimeException ) uno::Sequence< beans::PropertyValue > SwXCellRange::createSortDescriptor(void) throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - return SwXTextCursor::createSortDescriptor(sal_True); + + return SwUnoCursorHelper::CreateSortDescriptor(true); } /*-- 11.12.98 14:27:39--------------------------------------------------- @@ -4887,7 +4892,7 @@ void SAL_CALL SwXCellRange::sort(const uno::Sequence< beans::PropertyValue >& rD SwSortOptions aSortOpt; SwFrmFmt* pFmt = GetFrmFmt(); if(pFmt && - SwXTextCursor::convertSortProperties(rDescriptor, aSortOpt)) + SwUnoCursorHelper::ConvertSortProperties(rDescriptor, aSortOpt)) { SwUnoTableCrsr* pTableCrsr = dynamic_cast(pTblCrsr); pTableCrsr->MakeBoxSels(); diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index 415a3aaf6933..d3eebeae8af5 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -459,7 +459,7 @@ void SwXText::insertControlCharacter(const uno::Reference< text::XTextRange > & } SwCursor aCrsr(*aTmp.GetPoint(),0,false); - SwXTextCursor::SelectPam(aCrsr, sal_True); + SwUnoCursorHelper::SelectPam(aCrsr, true); aCrsr.Left(1, CRSR_SKIP_CHARS, FALSE, FALSE); //hier muss der uebergebene PaM umgesetzt werden: if(pRange) @@ -1359,11 +1359,9 @@ uno::Reference< text::XTextRange > SwXText::finishOrAppendParagraph( { try { - SwXTextCursor::SetPropertyValue( - aPam, - *pParaPropSet, - pValues[nProp].Name, - pValues[nProp].Value); + SwUnoCursorHelper::SetPropertyValue( + aPam, *pParaPropSet, + pValues[nProp].Name, pValues[nProp].Value); } catch( lang::IllegalArgumentException& rIllegal ) { @@ -1448,7 +1446,7 @@ uno::Reference< text::XTextRange > SwXText::appendTextPortion( xub_StrLen nContentPos = pCursor->GetPoint()->nContent.GetIndex(); SwUnoCursorHelper::DocInsertStringSplitCR( *pDoc, *pCursor, rText, false ); - SwXTextCursor::SelectPam(*pCursor, sal_True); + SwUnoCursorHelper::SelectPam(*pCursor, true); pCursor->GetPoint()->nContent = nContentPos; } @@ -1463,12 +1461,10 @@ uno::Reference< text::XTextRange > SwXText::appendTextPortion( { try { - SwXTextCursor::SetPropertyValue( - *pCursor, - *pCursorPropSet, - pValues[nProp].Name, - pValues[nProp].Value, - nsSetAttrMode::SETATTR_NOFORMATATTR); + SwUnoCursorHelper::SetPropertyValue( + *pCursor, *pCursorPropSet, + pValues[nProp].Name, pValues[nProp].Value, + nsSetAttrMode::SETATTR_NOFORMATATTR); } catch( lang::IllegalArgumentException& rIllegal ) { diff --git a/sw/source/ui/uno/unotxvw.cxx b/sw/source/ui/uno/unotxvw.cxx index 6d001b95f378..c83db6909045 100644 --- a/sw/source/ui/uno/unotxvw.cxx +++ b/sw/source/ui/uno/unotxvw.cxx @@ -79,7 +79,7 @@ #include #include #include -#include +#include #include #include @@ -317,8 +317,9 @@ sal_Bool SwXTextView::select(const uno::Any& aInterface) throw( lang::IllegalArg : 0; if(pCursor && pCursor->GetDoc() == GetView()->GetDocShell()->GetDoc()) - pPam = lcl_createPamCopy(*((SwXTextCursor*)pCursor)->GetPaM()); - + { + pPam = lcl_createPamCopy(*pCursor->GetPaM()); + } } else if(xPosN.is() && xIfcTunnel.is() && @@ -1773,7 +1774,7 @@ OUString SwXTextViewCursor::getString(void) throw( uno::RuntimeException ) { SwWrtShell& rSh = m_pView->GetWrtShell(); SwPaM* pShellCrsr = rSh.GetCrsr(); - SwXTextCursor::getTextFromPam(*pShellCrsr, uRet); + SwUnoCursorHelper::GetTextFromPam(*pShellCrsr, uRet); } default:;//prevent warning } @@ -1805,7 +1806,7 @@ void SwXTextViewCursor::setString(const OUString& aString) throw( uno::RuntimeEx { SwWrtShell& rSh = m_pView->GetWrtShell(); SwCursor* pShellCrsr = rSh.GetSwCrsr(); - SwXTextCursor::SetString( *pShellCrsr, aString ); + SwUnoCursorHelper::SetString(*pShellCrsr, aString); } default:;//prevent warning } @@ -1834,7 +1835,10 @@ void SwXTextViewCursor::setPropertyValue( const OUString& rPropertyName, const SwPaM* pShellCrsr = rSh.GetCrsr(); SwNode *pNode = pShellCrsr->GetNode(); if (pNode && pNode->IsTxtNode()) - SwXTextCursor::SetPropertyValue(*pShellCrsr, *m_pPropSet, rPropertyName, aValue ); + { + SwUnoCursorHelper::SetPropertyValue( + *pShellCrsr, *m_pPropSet, rPropertyName, aValue ); + } else throw RuntimeException(); } @@ -1853,7 +1857,8 @@ Any SwXTextViewCursor::getPropertyValue( const OUString& rPropertyName ) { SwWrtShell& rSh = m_pView->GetWrtShell(); SwPaM* pShellCrsr = rSh.GetCrsr(); - aRet = SwXTextCursor::GetPropertyValue( *pShellCrsr, *m_pPropSet, rPropertyName); + aRet = SwUnoCursorHelper::GetPropertyValue( + *pShellCrsr, *m_pPropSet, rPropertyName); } else throw RuntimeException(); @@ -1902,7 +1907,8 @@ PropertyState SwXTextViewCursor::getPropertyState( const OUString& rPropertyNam { SwWrtShell& rSh = m_pView->GetWrtShell(); SwPaM* pShellCrsr = rSh.GetCrsr(); - eState = SwXTextCursor::GetPropertyState( *pShellCrsr, *m_pPropSet, rPropertyName); + eState = SwUnoCursorHelper::GetPropertyState( + *pShellCrsr, *m_pPropSet, rPropertyName); } else throw RuntimeException(); @@ -1920,7 +1926,8 @@ Sequence< PropertyState > SwXTextViewCursor::getPropertyStates( { SwWrtShell& rSh = m_pView->GetWrtShell(); SwPaM* pShellCrsr = rSh.GetCrsr(); - aRet = SwXTextCursor::GetPropertyStates(*pShellCrsr, *m_pPropSet, rPropertyNames); + aRet = SwUnoCursorHelper::GetPropertyStates( + *pShellCrsr, *m_pPropSet, rPropertyNames); } return aRet; } @@ -1935,7 +1942,8 @@ void SwXTextViewCursor::setPropertyToDefault( const OUString& rPropertyName ) { SwWrtShell& rSh = m_pView->GetWrtShell(); SwPaM* pShellCrsr = rSh.GetCrsr(); - SwXTextCursor::SetPropertyToDefault( *pShellCrsr, *m_pPropSet, rPropertyName); + SwUnoCursorHelper::SetPropertyToDefault( + *pShellCrsr, *m_pPropSet, rPropertyName); } } /*-- 29.06.00 17:33:43--------------------------------------------------- @@ -1950,7 +1958,8 @@ Any SwXTextViewCursor::getPropertyDefault( const OUString& rPropertyName ) { SwWrtShell& rSh = m_pView->GetWrtShell(); SwPaM* pShellCrsr = rSh.GetCrsr(); - aRet = SwXTextCursor::GetPropertyDefault( *pShellCrsr, *m_pPropSet, rPropertyName); + aRet = SwUnoCursorHelper::GetPropertyDefault( + *pShellCrsr, *m_pPropSet, rPropertyName); } return aRet; } -- cgit From 2db8914dbed3ba6148f53d7548c126d92a1f9b90 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 8 Jan 2010 17:13:55 +0100 Subject: swunolocking1: #i105557#: SwXParagraph: move static methods to namespace sw. --- sw/inc/unoparagraph.hxx | 3 --- sw/inc/unotextrange.hxx | 3 +++ sw/source/core/unocore/unobkm.cxx | 3 +-- sw/source/core/unocore/unoftn.cxx | 2 +- sw/source/core/unocore/unoidx.cxx | 5 +++-- sw/source/core/unocore/unoparagraph.cxx | 10 +++++----- sw/source/core/unocore/unorefmk.cxx | 3 +-- sw/source/core/unocore/unosect.cxx | 5 ++--- sw/source/core/unocore/unotbl.cxx | 3 ++- 9 files changed, 18 insertions(+), 19 deletions(-) (limited to 'sw') diff --git a/sw/inc/unoparagraph.hxx b/sw/inc/unoparagraph.hxx index b14aeb7dc3d9..add936e9c702 100644 --- a/sw/inc/unoparagraph.hxx +++ b/sw/inc/unoparagraph.hxx @@ -111,9 +111,6 @@ public: /// for SwXText void attachToText(SwXText & rParent, SwTxtNode & rTxtNode); - static bool getDefaultTextContentValue(::com::sun::star::uno::Any& rAny, - const ::rtl::OUString& rPropertyName, USHORT nWID = 0); - // MetadatableMixin virtual ::sfx2::Metadatable* GetCoreObject(); virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > diff --git a/sw/inc/unotextrange.hxx b/sw/inc/unotextrange.hxx index c3c3d362db6b..164b35b703da 100644 --- a/sw/inc/unotextrange.hxx +++ b/sw/inc/unotextrange.hxx @@ -84,6 +84,9 @@ namespace sw { ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > CreateParentXText(SwDoc & rDoc, const SwPosition& rPos); + bool GetDefaultTextContentValue(::com::sun::star::uno::Any& rAny, + const ::rtl::OUString& rPropertyName, USHORT nWID = 0); + } // namespace sw diff --git a/sw/source/core/unocore/unobkm.cxx b/sw/source/core/unocore/unobkm.cxx index ad35f1f28b33..97e90488172a 100644 --- a/sw/source/core/unocore/unobkm.cxx +++ b/sw/source/core/unocore/unobkm.cxx @@ -37,7 +37,6 @@ #include #include -#include #include #include #include @@ -461,7 +460,7 @@ throw (beans::UnknownPropertyException, lang::WrappedTargetException, vos::OGuard g(Application::GetSolarMutex()); uno::Any aRet; - if(!SwXParagraph::getDefaultTextContentValue(aRet, rPropertyName)) + if (! ::sw::GetDefaultTextContentValue(aRet, rPropertyName)) { if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_LINK_DISPLAY_NAME))) { diff --git a/sw/source/core/unocore/unoftn.cxx b/sw/source/core/unocore/unoftn.cxx index 3d24e282f7c8..4511b455b5c9 100644 --- a/sw/source/core/unocore/unoftn.cxx +++ b/sw/source/core/unocore/unoftn.cxx @@ -526,7 +526,7 @@ uno::Any SwXFootnote::getPropertyValue( const OUString& rPropertyName ) { vos::OGuard aGuard(Application::GetSolarMutex()); uno::Any aRet; - if(!SwXParagraph::getDefaultTextContentValue(aRet, rPropertyName)) + if (! ::sw::GetDefaultTextContentValue(aRet, rPropertyName)) { if(rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_START_REDLINE))|| rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_END_REDLINE))) diff --git a/sw/source/core/unocore/unoidx.cxx b/sw/source/core/unocore/unoidx.cxx index 7119f3708711..8fad219d742e 100644 --- a/sw/source/core/unocore/unoidx.cxx +++ b/sw/source/core/unocore/unoidx.cxx @@ -57,7 +57,6 @@ #include #include #include -#include #include #include #include @@ -1784,8 +1783,10 @@ uno::Any SwXDocumentIndexMark::getPropertyValue(const OUString& rPropertyName) const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName(rPropertyName); if (!pEntry) throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); - if(SwXParagraph::getDefaultTextContentValue(aRet, rPropertyName, pEntry->nWID)) + if (::sw::GetDefaultTextContentValue(aRet, rPropertyName, pEntry->nWID)) + { return aRet; + } if(pType && m_pTOXMark) { switch(pEntry->nWID) diff --git a/sw/source/core/unocore/unoparagraph.cxx b/sw/source/core/unocore/unoparagraph.cxx index 8d6ee3f3a65d..8b04e34ac84e 100644 --- a/sw/source/core/unocore/unoparagraph.cxx +++ b/sw/source/core/unocore/unoparagraph.cxx @@ -512,8 +512,8 @@ throw (beans::UnknownPropertyException, lang::WrappedTargetException, + pPropertyNames[nProp], static_cast< cppu::OWeakObject * >(&m_rThis)); } - if (!SwXParagraph::getDefaultTextContentValue( - pValues[nProp], pPropertyNames[nProp], pEntry->nWID)) + if (! ::sw::GetDefaultTextContentValue( + pValues[nProp], pPropertyNames[nProp], pEntry->nWID)) { beans::PropertyState eTemp; const bool bDone = SwUnoCursorHelper::getCrsrPropertyValue( @@ -788,7 +788,7 @@ throw (uno::RuntimeException) // get property value // (compare to SwXParagraph::getPropertyValue(s)) uno::Any aValue; - if (!SwXParagraph::getDefaultTextContentValue( + if (! ::sw::GetDefaultTextContentValue( aValue, pProp[i], pEntry->nWID ) ) { SwPosition aPos( rTxtNode ); @@ -848,7 +848,7 @@ throw (uno::RuntimeException) /* -----------------------------12.09.00 11:09-------------------------------- ---------------------------------------------------------------------------*/ -bool SwXParagraph::getDefaultTextContentValue( +bool ::sw::GetDefaultTextContentValue( uno::Any& rAny, const OUString& rPropertyName, USHORT nWID) { if(!nWID) @@ -1158,7 +1158,7 @@ throw (beans::UnknownPropertyException, lang::WrappedTargetException, SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow()); uno::Any aRet; - if (SwXParagraph::getDefaultTextContentValue(aRet, rPropertyName)) + if (::sw::GetDefaultTextContentValue(aRet, rPropertyName)) { return aRet; } diff --git a/sw/source/core/unocore/unorefmk.cxx b/sw/source/core/unocore/unorefmk.cxx index a0903b6ea145..6b3ed8e04dd8 100644 --- a/sw/source/core/unocore/unorefmk.cxx +++ b/sw/source/core/unocore/unorefmk.cxx @@ -37,7 +37,6 @@ #include #include #include -#include #include #include #include @@ -510,7 +509,7 @@ throw (beans::UnknownPropertyException, lang::WrappedTargetException, { // does not seem to need SolarMutex uno::Any aRet; - if(!SwXParagraph::getDefaultTextContentValue(aRet, rPropertyName)) + if (! ::sw::GetDefaultTextContentValue(aRet, rPropertyName)) { throw beans::UnknownPropertyException(); } diff --git a/sw/source/core/unocore/unosect.cxx b/sw/source/core/unocore/unosect.cxx index fbe7e6e7eb5d..907a2a617c9b 100644 --- a/sw/source/core/unocore/unosect.cxx +++ b/sw/source/core/unocore/unosect.cxx @@ -47,7 +47,6 @@ #include #include #include -#include #include #include #include @@ -1186,7 +1185,7 @@ throw (beans::UnknownPropertyException, lang::WrappedTargetException, case FN_UNO_ANCHOR_TYPES: case FN_UNO_TEXT_WRAP: case FN_UNO_ANCHOR_TYPE: - SwXParagraph::getDefaultTextContentValue( + ::sw::GetDefaultTextContentValue( pRet[nProperty], OUString(), pEntry->nWID); break; case FN_UNO_REDLINE_NODE_START: @@ -1756,7 +1755,7 @@ throw (beans::UnknownPropertyException, lang::WrappedTargetException, case FN_UNO_ANCHOR_TYPES: case FN_UNO_TEXT_WRAP: case FN_UNO_ANCHOR_TYPE: - SwXParagraph::getDefaultTextContentValue(aRet, OUString(), pEntry->nWID); + ::sw::GetDefaultTextContentValue(aRet, OUString(), pEntry->nWID); break; default: if(pFmt && pEntry->nWID <= SFX_WHICH_MAX) diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index 2806a5984d24..b75d9dd93c0c 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -3472,7 +3472,8 @@ uno::Any SwXTextTable::getPropertyValue(const OUString& rPropertyName) throw( be case FN_UNO_ANCHOR_TYPES: case FN_UNO_TEXT_WRAP: case FN_UNO_ANCHOR_TYPE: - SwXParagraph::getDefaultTextContentValue(aRet, OUString(), pEntry->nWID); + ::sw::GetDefaultTextContentValue( + aRet, OUString(), pEntry->nWID); break; case FN_UNO_RANGE_ROW_LABEL: { -- cgit From 8b1fb77c76b7a3c1616af58aac9d8eb8f97c019e Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 8 Jan 2010 17:13:55 +0100 Subject: swunolocking1: #i105557#: SwXBodyText: make SwXBodyText::CreateTextCursor() return a pointer, not a UNO reference. --- sw/inc/unotextbodyhf.hxx | 4 +-- sw/source/core/unocore/unotext.cxx | 50 ++++++++++++++++++++------------------ sw/source/ui/uno/unotxdoc.cxx | 15 +++--------- 3 files changed, 33 insertions(+), 36 deletions(-) (limited to 'sw') diff --git a/sw/inc/unotextbodyhf.hxx b/sw/inc/unotextbodyhf.hxx index 8e7a64c18669..baab8bc15845 100644 --- a/sw/inc/unotextbodyhf.hxx +++ b/sw/inc/unotextbodyhf.hxx @@ -45,6 +45,7 @@ class SwDoc; class SwFrmFmt; +class SwXTextCursor; typedef ::cppu::WeakAggImplHelper2 @@ -65,8 +66,7 @@ public: SwXBodyText(SwDoc* pDoc); - ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > - CreateTextCursor(sal_Bool bIgnoreTables = sal_False); + SwXTextCursor * CreateTextCursor(const bool bIgnoreTables = false); // XInterface virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index d3eebeae8af5..72a86050fadf 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -2301,46 +2301,50 @@ throw (uno::RuntimeException) /* -----------------------------05.01.00 11:07-------------------------------- ---------------------------------------------------------------------------*/ -uno::Reference< text::XTextCursor > SwXBodyText::CreateTextCursor(sal_Bool bIgnoreTables) +SwXTextCursor * SwXBodyText::CreateTextCursor(const bool bIgnoreTables) { - uno::Reference< text::XTextCursor > xRet; - if(IsValid()) + if(!IsValid()) { - SwNode& rNode = GetDoc()->GetNodes().GetEndOfContent(); - //the cursor has to skip tables contained in this text - SwPaM aPam(rNode); - aPam.Move( fnMoveBackward, fnGoDoc ); - if(!bIgnoreTables) + return 0; + } + + // the cursor has to skip tables contained in this text + SwPaM aPam(GetDoc()->GetNodes().GetEndOfContent()); + aPam.Move( fnMoveBackward, fnGoDoc ); + if (!bIgnoreTables) + { + SwTableNode * pTblNode = aPam.GetNode()->FindTableNode(); + SwCntntNode * pCont = 0; + while (pTblNode) { - SwTableNode* pTblNode = aPam.GetNode()->FindTableNode(); - SwCntntNode* pCont = 0; - while( pTblNode ) - { - aPam.GetPoint()->nNode = *pTblNode->EndOfSectionNode(); - pCont = GetDoc()->GetNodes().GoNext(&aPam.GetPoint()->nNode); - pTblNode = pCont->FindTableNode(); - } - if(pCont) - aPam.GetPoint()->nContent.Assign(pCont, 0); + aPam.GetPoint()->nNode = *pTblNode->EndOfSectionNode(); + pCont = GetDoc()->GetNodes().GoNext(&aPam.GetPoint()->nNode); + pTblNode = pCont->FindTableNode(); + } + if (pCont) + { + aPam.GetPoint()->nContent.Assign(pCont, 0); } - xRet = (text::XWordCursor*)new SwXTextCursor(this, *aPam.GetPoint(), CURSOR_BODY, GetDoc()); } - return xRet; + return new SwXTextCursor(this, *aPam.GetPoint(), CURSOR_BODY, GetDoc()); } + /*-- 10.12.98 11:17:29--------------------------------------------------- -----------------------------------------------------------------------*/ uno::Reference< text::XTextCursor > SwXBodyText::createTextCursor(void) throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< text::XTextCursor > aRef = CreateTextCursor(sal_False); - if(!aRef.is()) + + const uno::Reference< text::XTextCursor > xRef( + static_cast(CreateTextCursor(false)) ); + if (!xRef.is()) { uno::RuntimeException aRuntime; aRuntime.Message = C2U(cInvalidObject); throw aRuntime; } - return aRef; + return xRef; } /*-- 10.12.98 11:17:29--------------------------------------------------- diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index 3bb65ea4e900..374ee9ab0133 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -728,19 +728,12 @@ Reference< util::XReplaceDescriptor > SwXTextDocument::createReplaceDescriptor( SwUnoCrsr* SwXTextDocument::CreateCursorForSearch(Reference< XTextCursor > & xCrsr) { getText(); - XText* pText = xBodyText.get(); + XText *const pText = xBodyText.get(); SwXBodyText* pBText = (SwXBodyText*)pText; - xCrsr = pBText->CreateTextCursor(sal_True); + SwXTextCursor *const pXTextCursor = pBText->CreateTextCursor(true); + xCrsr.set( static_cast(pXTextCursor) ); - Reference xRangeTunnel( xCrsr, UNO_QUERY); - SwXTextCursor* pxUnoCrsr = 0; - if(xRangeTunnel.is()) - { - pxUnoCrsr = reinterpret_cast(xRangeTunnel->getSomething( - SwXTextCursor::getUnoTunnelId())); - } - - SwUnoCrsr* pUnoCrsr = pxUnoCrsr->GetCrsr(); + SwUnoCrsr *const pUnoCrsr = pXTextCursor->GetCrsr(); pUnoCrsr->SetRemainInSection(sal_False); return pUnoCrsr; } -- cgit From 456e9d587f26b98929d7821b6d9e14d328c024b5 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 8 Jan 2010 17:13:55 +0100 Subject: swunolocking1: #i105557#: SwXTextCursor: add Impl struct, and use UnoImplPtr to lock destructor. move all implementation details out of header, into Impl struct. remove ugly destruction of SwUnoCrsr via Application::PostUserEvent. use new XUnoTunnel and XServiceInfo helpers. clean up the implementation a little. --- sw/inc/unotextcursor.hxx | 54 +- sw/source/core/unocore/unoframe.cxx | 14 +- sw/source/core/unocore/unoftn.cxx | 11 +- sw/source/core/unocore/unoobj.cxx | 1884 ++++++++++++----------- sw/source/core/unocore/unoredline.cxx | 15 +- sw/source/core/unocore/unorefmk.cxx | 7 +- sw/source/core/unocore/unotbl.cxx | 13 +- sw/source/core/unocore/unotext.cxx | 28 +- sw/source/filter/xml/XMLRedlineImportHelper.cxx | 10 +- sw/source/ui/uno/unotxdoc.cxx | 6 +- 10 files changed, 1022 insertions(+), 1020 deletions(-) (limited to 'sw') diff --git a/sw/inc/unotextcursor.hxx b/sw/inc/unotextcursor.hxx index fe9b2602180f..e976af91e147 100644 --- a/sw/inc/unotextcursor.hxx +++ b/sw/inc/unotextcursor.hxx @@ -49,20 +49,14 @@ #include #include -#include -#include -#include -#include #include #include -class SfxItemPropertySet; class SwDoc; struct SwPosition; class SwUnoCrsr; -struct SwSortOptions; typedef ::cppu::WeakImplHelper12 @@ -82,65 +76,45 @@ typedef ::cppu::WeakImplHelper12 class SwXTextCursor : public SwXTextCursor_Base - , public SwClient , public OTextCursorHelper { private: - SwEventListenerContainer aLstnrCntnr; - const SfxItemPropertySet* m_pPropSet; - ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > xParentText; - SwSortOptions* pLastSortOptions; - - CursorType eType; - - // --> FME 2006-03-07 #126177# We need to track if the RemoveCursor_Impl - // user event has been posted. In this case we have to remove the user - // event in ~SwXTextCursor(). - ULONG mnUserEventId; - bool mbRemoveUserEvent; - // <-- - - DECL_STATIC_LINK(SwXTextCursor, RemoveCursor_Impl, - ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>*); - -protected: + class Impl; + ::sw::UnoImplPtr m_pImpl; virtual ~SwXTextCursor(); public: SwXTextCursor( + SwDoc & rDoc, ::com::sun::star::uno::Reference< - ::com::sun::star::text::XText > xParent, - const SwPosition& rPos, - CursorType eSet, SwDoc* pDoc, const SwPosition* pMark = 0); + ::com::sun::star::text::XText > const& xParent, + const enum CursorType eType, + SwPosition const& rPos, + SwPosition const*const pMark = 0); SwXTextCursor( ::com::sun::star::uno::Reference< - ::com::sun::star::text::XText > xParent, - SwUnoCrsr* pSourceCrsr, CursorType eSet = CURSOR_ALL); - - SwUnoCrsr* GetCrsr() {return (SwUnoCrsr*)GetRegisteredIn();} - const SwUnoCrsr* GetCrsr() const {return (SwUnoCrsr*)GetRegisteredIn();} + ::com::sun::star::text::XText > const& xParent, + SwPaM const& rSourceCursor, + const enum CursorType eType = CURSOR_ALL); - // --> FME 2006-03-07 #126177# - void DoNotRemoveUserEvent() { mbRemoveUserEvent = false; } - // <-- + SwUnoCrsr * GetCursor(); + const SwUnoCrsr * GetCursor() const; bool IsAtEndOfMeta() const; - void DeleteAndInsert(const String& rText, + void DeleteAndInsert(::rtl::OUString const& rText, const bool bForceExpandHints); + // OTextCursorHelper virtual const SwPaM* GetPaM() const; virtual SwPaM* GetPaM(); virtual const SwDoc* GetDoc() const; virtual SwDoc* GetDoc(); - // SwClient - virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); - DECLARE_XINTERFACE() static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId(); diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx index ac2dc2d55529..c9e9771a3bae 100644 --- a/sw/source/core/unocore/unoframe.cxx +++ b/sw/source/core/unocore/unoframe.cxx @@ -2652,10 +2652,11 @@ uno::Reference< text::XTextCursor > SwXTextFrame::createTextCursor(void) throw( throw aExcept; } - SwXTextCursor* pXCrsr = new SwXTextCursor(this, *aPam.GetPoint(), CURSOR_FRAME, pFmt->GetDoc()); - aRef = (text::XWordCursor*)pXCrsr; + SwXTextCursor *const pXCursor = new SwXTextCursor( + *pFmt->GetDoc(), this, CURSOR_FRAME, *aPam.GetPoint()); + aRef = static_cast(pXCursor); #if OSL_DEBUG_LEVEL > 1 - SwUnoCrsr* pUnoCrsr = pXCrsr->GetCrsr(); + SwUnoCrsr *const pUnoCrsr = pXCursor->GetCursor(); (void) pUnoCrsr; #endif } @@ -2682,8 +2683,11 @@ uno::Reference< text::XTextCursor > SwXTextFrame::createTextCursorByRange(const (void)p2; #endif if(aPam.GetNode()->FindFlyStartNode() == rNode.FindFlyStartNode()) - aRef = (text::XWordCursor*)new SwXTextCursor(this , - *aPam.GetPoint(), CURSOR_FRAME, pFmt->GetDoc(), aPam.GetMark()); + { + aRef = static_cast( + new SwXTextCursor(*pFmt->GetDoc(), this, CURSOR_FRAME, + *aPam.GetPoint(), aPam.GetMark())); + } } else throw uno::RuntimeException(); diff --git a/sw/source/core/unocore/unoftn.cxx b/sw/source/core/unocore/unoftn.cxx index 4511b455b5c9..e98238967a11 100644 --- a/sw/source/core/unocore/unoftn.cxx +++ b/sw/source/core/unocore/unoftn.cxx @@ -391,9 +391,10 @@ uno::Reference< text::XTextCursor > SwXFootnote::createTextCursor(void) throw( { const SwTxtFtn* pTxtFtn = pFmt->GetTxtFtn(); SwPosition aPos( *pTxtFtn->GetStartNode() ); - SwXTextCursor* pXCrsr = new SwXTextCursor(this, aPos, CURSOR_FOOTNOTE, GetDoc()); - aRef = (text::XWordCursor*)pXCrsr; - SwUnoCrsr* pUnoCrsr = pXCrsr->GetCrsr(); + SwXTextCursor *const pXCursor = + new SwXTextCursor(*GetDoc(), this, CURSOR_FOOTNOTE, aPos); + aRef = static_cast(pXCursor); + SwUnoCrsr *const pUnoCrsr = pXCursor->GetCursor(); pUnoCrsr->Move(fnMoveForward, fnGoNode); } else @@ -422,7 +423,9 @@ uno::Reference< text::XTextCursor > SwXFootnote::createTextCursorByRange( if( pStart != pFtnStartNode ) throw uno::RuntimeException(); - aRef = (text::XWordCursor*)new SwXTextCursor(this , *aPam.GetPoint(), CURSOR_FOOTNOTE, GetDoc(), aPam.GetMark()); + aRef = static_cast( + new SwXTextCursor(*GetDoc(), this, CURSOR_FOOTNOTE, + *aPam.GetPoint(), aPam.GetMark())); } else throw uno::RuntimeException(); diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx index 837caa62634b..ba86f9c509b1 100644 --- a/sw/source/core/unocore/unoobj.cxx +++ b/sw/source/core/unocore/unoobj.cxx @@ -131,17 +131,10 @@ using namespace ::com::sun::star; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::text; -using namespace ::com::sun::star::container; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::drawing; -using std::auto_ptr; using ::rtl::OUString; using ::rtl::OUStringBuffer; + /**************************************************************************** static methods ****************************************************************************/ @@ -780,185 +773,146 @@ SwPageDesc* GetPageDescByName_Impl(SwDoc& rDoc, const String& rName) return pRet; } -/****************************************************************************** - ****************************************************************************** - ****************************************************************************** - * Taskforce ONE51 - ******************************************************************************/ /****************************************************************** * SwXTextCursor ******************************************************************/ -/*-- 09.12.98 14:19:00--------------------------------------------------- - - -----------------------------------------------------------------------*/ -IMPL_STATIC_LINK( SwXTextCursor, RemoveCursor_Impl, - uno::Reference< XInterface >*, EMPTYARG ) +class SwXTextCursor::Impl + : public SwClient { - ASSERT( pThis != NULL, "no reference?" ); - //ASSERT( pArg != NULL, "no reference?" ); - // --> FME 2006-03-07 #126177# Tell the SwXTextCursor that the user event - // has been executed. It is not necessary to remove the user event in - // ~SwXTextCursor - pThis->DoNotRemoveUserEvent(); - // <-- +public: + + const SfxItemPropertySet & m_rPropSet; + const enum CursorType m_eType; + const uno::Reference< text::XText > m_xParentText; + SwEventListenerContainer m_ListenerContainer; + bool m_bIsDisposed; - SwUnoCrsr* pCursor = pThis->GetCrsr(); - if( pCursor != NULL ) + Impl( SwXTextCursor & rThis, + SwDoc & rDoc, + const enum CursorType eType, + uno::Reference xParent, + SwPosition const& rPoint, SwPosition const*const pMark) + : SwClient(rDoc.CreateUnoCrsr(rPoint, sal_False)) + , m_rPropSet(*aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR)) + , m_eType(eType) + , m_xParentText(xParent) + , m_ListenerContainer(static_cast< ::cppu::OWeakObject* >(&rThis)) + , m_bIsDisposed(false) { - pCursor->Remove( pThis ); - delete pCursor; + if (pMark) + { + GetCursor()->SetMark(); + *GetCursor()->GetMark() = *pMark; + } } - // --> FME 2006-03-07 #126177# - //delete pArg; - // <-- + ~Impl() { + // Impl owns the cursor; delete it here: SolarMutex is locked + delete GetRegisteredIn(); + } - return 0; -} + SwUnoCrsr * GetCursor() { + return (m_bIsDisposed) ? 0 : + static_cast(const_cast(GetRegisteredIn())); + } -void SwXTextCursor::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew) -{ - ClientModify(this, pOld, pNew); + SwUnoCrsr & GetCursorOrThrow() { + SwUnoCrsr *const pUnoCursor( GetCursor() ); + if (!pUnoCursor) { + throw uno::RuntimeException(OUString(RTL_CONSTASCII_USTRINGPARAM( + "SwXTextCursor: disposed or invalid")), 0); + } + return *pUnoCursor; + } - // if the cursor leaves its designated section, it becomes invalid - if( !mbRemoveUserEvent && ( pOld != NULL ) && ( pOld->Which() == RES_UNOCURSOR_LEAVES_SECTION ) ) - { - // --> FME 2006-03-07 #126177# We don't need to create a reference - // to the SwXTextCursor to prevent its deletion. If the destructor - // of the SwXTextCursor is called before the user event is executed, - // the user event will be removed. This is necessary, because an other - // thread might be currently waiting in ~SwXTextCursor. In this case - // the pRef = new ... stuff did not work! + void Invalidate() { + m_bIsDisposed = true; + m_ListenerContainer.Disposing(); + } - // create reference to this object to prevent deletion before - // the STATIC_LINK is executed. The link will delete the - // reference. - //uno::Reference* pRef = - //new uno::Reference( static_cast( this ) ); + // SwClient + virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); - mbRemoveUserEvent = true; - // <-- +}; - mnUserEventId = Application::PostUserEvent( - STATIC_LINK( this, SwXTextCursor, RemoveCursor_Impl ), this ); +void SwXTextCursor::Impl::Modify(SfxPoolItem *pOld, SfxPoolItem *pNew) +{ + ClientModify(this, pOld, pNew); + + if (!GetRegisteredIn() || + // if the cursor leaves its designated section, it becomes invalid + (pOld != NULL) && (pOld->Which() == RES_UNOCURSOR_LEAVES_SECTION)) + { + Invalidate(); } +} + - if(!GetRegisteredIn()) - aLstnrCntnr.Disposing(); +SwUnoCrsr const* SwXTextCursor::GetCursor() const +{ + return m_pImpl->GetCursor(); +} +SwUnoCrsr * SwXTextCursor::GetCursor() +{ + return m_pImpl->GetCursor(); } /*-- 09.12.98 14:19:01--------------------------------------------------- -----------------------------------------------------------------------*/ -const SwPaM* SwXTextCursor::GetPaM() const +SwPaM const* SwXTextCursor::GetPaM() const { - return GetCrsr() ? GetCrsr() : 0; + return m_pImpl->GetCursor(); } -SwPaM* SwXTextCursor::GetPaM() +SwPaM * SwXTextCursor::GetPaM() { - return GetCrsr() ? GetCrsr() : 0; + return m_pImpl->GetCursor(); } /*-- 09.12.98 14:19:02--------------------------------------------------- -----------------------------------------------------------------------*/ -const SwDoc* SwXTextCursor::GetDoc()const +SwDoc const* SwXTextCursor::GetDoc() const { - return GetCrsr() ? GetCrsr()->GetDoc() : 0; + return m_pImpl->GetCursor() ? m_pImpl->GetCursor()->GetDoc() : 0; } /* -----------------22.07.99 13:52------------------- --------------------------------------------------*/ -SwDoc* SwXTextCursor::GetDoc() -{ - return GetCrsr() ? GetCrsr()->GetDoc() : 0; -} - - -/*-- 09.12.98 14:19:19--------------------------------------------------- - - -----------------------------------------------------------------------*/ -OUString SwXTextCursor::getImplementationName(void) throw( RuntimeException ) +SwDoc * SwXTextCursor::GetDoc() { - return C2U("SwXTextCursor"); + return m_pImpl->GetCursor() ? m_pImpl->GetCursor()->GetDoc() : 0; } -/*-- 09.12.98 14:19:19--------------------------------------------------- - -----------------------------------------------------------------------*/ -BOOL SwXTextCursor::supportsService(const OUString& rServiceName) throw( RuntimeException ) -{ - String sServiceName(rServiceName); - return sServiceName.EqualsAscii("com.sun.star.text.TextCursor") || - sServiceName.EqualsAscii("com.sun.star.style.CharacterProperties")|| - sServiceName.EqualsAscii("com.sun.star.style.CharacterPropertiesAsian")|| - sServiceName.EqualsAscii("com.sun.star.style.CharacterPropertiesComplex")|| - sServiceName.EqualsAscii("com.sun.star.style.ParagraphProperties") || - sServiceName.EqualsAscii("com.sun.star.style.ParagraphPropertiesAsian") || - sServiceName.EqualsAscii("com.sun.star.style.ParagraphPropertiesComplex") || - sServiceName.EqualsAscii("com.sun.star.text.TextSortable"); -} -/*-- 09.12.98 14:19:19--------------------------------------------------- - -----------------------------------------------------------------------*/ -Sequence< OUString > SwXTextCursor::getSupportedServiceNames(void) throw( RuntimeException ) -{ - Sequence< OUString > aRet(8); - OUString* pArray = aRet.getArray(); - pArray[0] = C2U("com.sun.star.text.TextCursor"); - pArray[1] = C2U("com.sun.star.style.CharacterProperties"); - pArray[2] = C2U("com.sun.star.style.CharacterPropertiesAsian"); - pArray[3] = C2U("com.sun.star.style.CharacterPropertiesComplex"); - pArray[4] = C2U("com.sun.star.style.ParagraphProperties"); - pArray[5] = C2U("com.sun.star.style.ParagraphPropertiesAsian"); - pArray[6] = C2U("com.sun.star.style.ParagraphPropertiesComplex"); - pArray[7] = C2U("com.sun.star.text.TextSortable"); - return aRet; -} /*-- 09.12.98 14:19:19--------------------------------------------------- -----------------------------------------------------------------------*/ -SwXTextCursor::SwXTextCursor(uno::Reference< XText > xParent, const SwPosition& rPos, - CursorType eSet, SwDoc* pDoc, const SwPosition* pMark) : - aLstnrCntnr(( util::XSortable*)this), - m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR)), - xParentText(xParent), - pLastSortOptions(0), - eType(eSet), - mbRemoveUserEvent( false ) +SwXTextCursor::SwXTextCursor( + SwDoc & rDoc, + uno::Reference< text::XText > const& xParent, + const enum CursorType eType, + const SwPosition& rPos, + SwPosition const*const pMark) + : m_pImpl( new SwXTextCursor::Impl(*this, rDoc, eType, xParent, + rPos, pMark ) ) { - SwUnoCrsr* pUnoCrsr = pDoc->CreateUnoCrsr(rPos, sal_False); - if(pMark) - { - pUnoCrsr->SetMark(); - *pUnoCrsr->GetMark() = *pMark; - } - pUnoCrsr->Add(this); } /* -----------------04.03.99 09:02------------------- * * --------------------------------------------------*/ -SwXTextCursor::SwXTextCursor(uno::Reference< XText > xParent, - SwUnoCrsr* pSourceCrsr, CursorType eSet) : - aLstnrCntnr( (util::XSortable*)this), - m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR)), - xParentText(xParent), - pLastSortOptions(0), - eType(eSet), - mbRemoveUserEvent( false ) +SwXTextCursor::SwXTextCursor(uno::Reference< text::XText > const& xParent, + SwPaM const& rSourceCursor, const enum CursorType eType) + : m_pImpl( new SwXTextCursor::Impl(*this, *rSourceCursor.GetDoc(), eType, + xParent, *rSourceCursor.GetPoint(), + rSourceCursor.HasMark() ? rSourceCursor.GetMark() : 0) ) { - SwUnoCrsr* pUnoCrsr = pSourceCrsr->GetDoc()->CreateUnoCrsr(*pSourceCrsr->GetPoint(), sal_False); - if(pSourceCrsr->HasMark()) - { - pUnoCrsr->SetMark(); - *pUnoCrsr->GetMark() = *pSourceCrsr->GetMark(); - } - pUnoCrsr->Add(this); } /*-- 09.12.98 14:19:20--------------------------------------------------- @@ -966,55 +920,43 @@ SwXTextCursor::SwXTextCursor(uno::Reference< XText > xParent, -----------------------------------------------------------------------*/ SwXTextCursor::~SwXTextCursor() { - vos::OGuard aGuard(Application::GetSolarMutex()); - - // --> FME 2006-03-07 #126177# A user event has been posted in order - // to delete the SwUnoCursor. Remove the user event if the SwXTextCursor - // is destroyed before the user event could be handled. - if ( mbRemoveUserEvent ) - { - mbRemoveUserEvent = false; - Application::RemoveUserEvent( mnUserEventId ); - } - // <-- - - SwUnoCrsr* pUnoCrsr = GetCrsr(); - delete pUnoCrsr; - delete pLastSortOptions; } + /*-- 09.12.98 14:19:18--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextCursor::DeleteAndInsert(const String& rText, +void SwXTextCursor::DeleteAndInsert(const ::rtl::OUString& rText, const bool bForceExpandHints) { - SwUnoCrsr* pUnoCrsr = GetCrsr(); + SwUnoCrsr *const pUnoCrsr = m_pImpl->GetCursor(); if(pUnoCrsr) { // Start/EndAction SwDoc* pDoc = pUnoCrsr->GetDoc(); UnoActionContext aAction(pDoc); - xub_StrLen nTxtLen = rText.Len(); + const xub_StrLen nTxtLen = rText.getLength(); pDoc->StartUndo(UNDO_INSERT, NULL); - SwCursor *_pStartCrsr = pUnoCrsr; + SwCursor * pCurrent = pUnoCrsr; do { - if(_pStartCrsr->HasMark()) + if (pCurrent->HasMark()) { - pDoc->DeleteAndJoin(*_pStartCrsr); + pDoc->DeleteAndJoin(*pCurrent); } if(nTxtLen) { const bool bSuccess( SwUnoCursorHelper::DocInsertStringSplitCR( - *pDoc, *_pStartCrsr, rText, bForceExpandHints ) ); + *pDoc, *pCurrent, rText, bForceExpandHints ) ); DBG_ASSERT( bSuccess, "Doc->Insert(Str) failed." ); (void) bSuccess; SwUnoCursorHelper::SelectPam(*pUnoCrsr, true); - _pStartCrsr->Left(rText.Len(), CRSR_SKIP_CHARS, FALSE, FALSE); + pCurrent->Left(rText.getLength(), + CRSR_SKIP_CHARS, FALSE, FALSE); } - } while( (_pStartCrsr=(SwCursor*)_pStartCrsr->GetNext()) != pUnoCrsr ); + pCurrent = static_cast(pCurrent->GetNext()); + } while (pCurrent != pUnoCrsr); pDoc->EndUndo(UNDO_INSERT, NULL); } } @@ -1068,10 +1010,11 @@ lcl_ForceIntoMeta(SwPaM & rCursor, bool SwXTextCursor::IsAtEndOfMeta() const { - if (CURSOR_META == eType) + if (CURSOR_META == m_pImpl->m_eType) { - SwUnoCrsr const * const pCursor( GetCrsr() ); - SwXMeta const*const pXMeta( dynamic_cast(xParentText.get()) ); + SwUnoCrsr const * const pCursor( m_pImpl->GetCursor() ); + SwXMeta const*const pXMeta( + dynamic_cast(m_pImpl->m_xParentText.get()) ); ASSERT(pXMeta, "no meta?"); if (pCursor && pXMeta) { @@ -1095,6 +1038,45 @@ bool SwXTextCursor::IsAtEndOfMeta() const return false; } +/*-- 09.12.98 14:19:19--------------------------------------------------- + + -----------------------------------------------------------------------*/ +OUString SwXTextCursor::getImplementationName() throw (uno::RuntimeException) +{ + return C2U("SwXTextCursor"); +} + +/*-- 09.12.98 14:19:19--------------------------------------------------- + + -----------------------------------------------------------------------*/ +static char const*const g_ServicesTextCursor[] = +{ + "com.sun.star.text.TextCursor", + "com.sun.star.style.CharacterProperties", + "com.sun.star.style.CharacterPropertiesAsian", + "com.sun.star.style.CharacterPropertiesComplex", + "com.sun.star.style.ParagraphProperties", + "com.sun.star.style.ParagraphPropertiesAsian", + "com.sun.star.style.ParagraphPropertiesComplex", + "com.sun.star.text.TextSortable", +}; +static const size_t g_nServicesTextCursor( + sizeof(g_ServicesTextCursor)/sizeof(g_ServicesTextCursor[0])); + +sal_Bool SAL_CALL SwXTextCursor::supportsService(const OUString& rServiceName) +throw (uno::RuntimeException) +{ + return ::sw::SupportsServiceImpl( + g_nServicesTextCursor, g_ServicesTextCursor, rServiceName); +} + +uno::Sequence< OUString > SAL_CALL +SwXTextCursor::getSupportedServiceNames() throw (uno::RuntimeException) +{ + return ::sw::GetSupportedServiceNamesImpl( + g_nServicesTextCursor, g_ServicesTextCursor); +} + /* -----------------------------10.03.00 18:02-------------------------------- ---------------------------------------------------------------------------*/ @@ -1106,231 +1088,219 @@ const uno::Sequence< sal_Int8 > & SwXTextCursor::getUnoTunnelId() /* -----------------------------10.03.00 18:04-------------------------------- ---------------------------------------------------------------------------*/ -sal_Int64 SAL_CALL SwXTextCursor::getSomething( const uno::Sequence< sal_Int8 >& rId ) - throw(uno::RuntimeException) +sal_Int64 SAL_CALL +SwXTextCursor::getSomething(const uno::Sequence< sal_Int8 >& rId) +throw (uno::RuntimeException) { - if( rId.getLength() == 16 - && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), - rId.getConstArray(), 16 ) ) - { - return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(this) ); - } - return OTextCursorHelper::getSomething(rId); + const sal_Int64 nRet( ::sw::UnoTunnelImpl(rId, this) ); + return (nRet) ? nRet : OTextCursorHelper::getSomething(rId); } /*-- 09.12.98 14:18:12--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextCursor::collapseToStart(void) throw( uno::RuntimeException ) +void SAL_CALL SwXTextCursor::collapseToStart() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + if (rUnoCursor.HasMark()) { - if(pUnoCrsr->HasMark()) + if (*rUnoCursor.GetPoint() > *rUnoCursor.GetMark()) { - if(*pUnoCrsr->GetPoint() > *pUnoCrsr->GetMark()) - pUnoCrsr->Exchange(); - pUnoCrsr->DeleteMark(); + rUnoCursor.Exchange(); } - } - else - { - throw uno::RuntimeException(); + rUnoCursor.DeleteMark(); } } /*-- 09.12.98 14:18:14--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextCursor::collapseToEnd(void) throw( uno::RuntimeException ) +void SAL_CALL SwXTextCursor::collapseToEnd() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + if (rUnoCursor.HasMark()) { - if(pUnoCrsr->HasMark()) + if (*rUnoCursor.GetPoint() < *rUnoCursor.GetMark()) { - if(*pUnoCrsr->GetPoint() < *pUnoCrsr->GetMark()) - pUnoCrsr->Exchange(); - pUnoCrsr->DeleteMark(); + rUnoCursor.Exchange(); } - } - else - { - throw uno::RuntimeException(); + rUnoCursor.DeleteMark(); } } /*-- 09.12.98 14:18:41--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXTextCursor::isCollapsed(void) throw( uno::RuntimeException ) +sal_Bool SAL_CALL SwXTextCursor::isCollapsed() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + sal_Bool bRet = sal_True; - SwUnoCrsr* pUnoCrsr = GetCrsr(); + SwUnoCrsr *const pUnoCrsr = m_pImpl->GetCursor(); if(pUnoCrsr && pUnoCrsr->GetMark()) { bRet = (*pUnoCrsr->GetPoint() == *pUnoCrsr->GetMark()); } return bRet; } + /*-- 09.12.98 14:18:42--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXTextCursor::goLeft(sal_Int16 nCount, sal_Bool Expand) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXTextCursor::goLeft(sal_Int16 nCount, sal_Bool Expand) +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - sal_Bool bRet = sal_False; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) - { - SwUnoCursorHelper::SelectPam(*pUnoCrsr, Expand); - bRet = pUnoCrsr->Left( nCount, CRSR_SKIP_CHARS, FALSE, FALSE); - if (CURSOR_META == eType) - { - bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH) - && bRet; - } - } - else + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + SwUnoCursorHelper::SelectPam(rUnoCursor, Expand); + sal_Bool bRet = rUnoCursor.Left( nCount, CRSR_SKIP_CHARS, FALSE, FALSE); + if (CURSOR_META == m_pImpl->m_eType) { - throw uno::RuntimeException(); + bRet = lcl_ForceIntoMeta(rUnoCursor, m_pImpl->m_xParentText, + META_CHECK_BOTH) + && bRet; } return bRet; } /*-- 09.12.98 14:18:42--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXTextCursor::goRight(sal_Int16 nCount, sal_Bool Expand) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXTextCursor::goRight(sal_Int16 nCount, sal_Bool Expand) +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - sal_Bool bRet = sal_False; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) - { - SwUnoCursorHelper::SelectPam(*pUnoCrsr, Expand); - bRet = pUnoCrsr->Right(nCount, CRSR_SKIP_CHARS, FALSE, FALSE); - if (CURSOR_META == eType) - { - bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH) - && bRet; - } - } - else + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + SwUnoCursorHelper::SelectPam(rUnoCursor, Expand); + sal_Bool bRet = rUnoCursor.Right(nCount, CRSR_SKIP_CHARS, FALSE, FALSE); + if (CURSOR_META == m_pImpl->m_eType) { - throw uno::RuntimeException(); + bRet = lcl_ForceIntoMeta(rUnoCursor, m_pImpl->m_xParentText, + META_CHECK_BOTH) + && bRet; } return bRet; } + /*-- 09.12.98 14:18:43--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextCursor::gotoStart(sal_Bool Expand) throw( uno::RuntimeException ) +void SAL_CALL +SwXTextCursor::gotoStart(sal_Bool Expand) throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + SwUnoCursorHelper::SelectPam(rUnoCursor, Expand); + if (CURSOR_BODY == m_pImpl->m_eType) { - SwUnoCursorHelper::SelectPam(*pUnoCrsr, Expand); - if(eType == CURSOR_BODY) + rUnoCursor.Move( fnMoveBackward, fnGoDoc ); + //check, that the cursor is not in a table + SwTableNode * pTblNode = rUnoCursor.GetNode()->FindTableNode(); + SwCntntNode * pCNode = 0; + while (pTblNode) { - pUnoCrsr->Move( fnMoveBackward, fnGoDoc ); - //check, that the cursor is not in a table - SwTableNode* pTblNode = pUnoCrsr->GetNode()->FindTableNode(); - SwCntntNode* pCont = 0; - while( pTblNode ) - { - pUnoCrsr->GetPoint()->nNode = *pTblNode->EndOfSectionNode(); - pCont = GetDoc()->GetNodes().GoNext(&pUnoCrsr->GetPoint()->nNode); - pTblNode = pCont ? pCont->FindTableNode() : 0; - } - if(pCont) - pUnoCrsr->GetPoint()->nContent.Assign(pCont, 0); - const SwStartNode* pTmp = pUnoCrsr->GetNode()->StartOfSectionNode(); - if(pTmp->IsSectionNode()) - { - SwSectionNode* pSectionStartNode = (SwSectionNode*)pTmp; - if(pSectionStartNode->GetSection().IsHiddenFlag()) - { - pCont = GetDoc()->GetNodes().GoNextSection( - &pUnoCrsr->GetPoint()->nNode, sal_True, sal_False); - if(pCont) - pUnoCrsr->GetPoint()->nContent.Assign(pCont, 0); - } - } + rUnoCursor.GetPoint()->nNode = *pTblNode->EndOfSectionNode(); + pCNode = GetDoc()->GetNodes().GoNext(&rUnoCursor.GetPoint()->nNode); + pTblNode = (pCNode) ? pCNode->FindTableNode() : 0; } - else if(eType == CURSOR_FRAME || - eType == CURSOR_TBLTEXT || - eType == CURSOR_HEADER || - eType == CURSOR_FOOTER || - eType == CURSOR_FOOTNOTE|| - eType == CURSOR_REDLINE) + if (pCNode) { - pUnoCrsr->MoveSection( fnSectionCurr, fnSectionStart); + rUnoCursor.GetPoint()->nContent.Assign(pCNode, 0); } - else if (CURSOR_META == eType) + SwStartNode const*const pTmp = + rUnoCursor.GetNode()->StartOfSectionNode(); + if (pTmp->IsSectionNode()) { - lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_INIT_START); + SwSectionNode const*const pSectionStartNode = + static_cast(pTmp); + if (pSectionStartNode->GetSection().IsHiddenFlag()) + { + pCNode = GetDoc()->GetNodes().GoNextSection( + &rUnoCursor.GetPoint()->nNode, sal_True, sal_False); + if (pCNode) + { + rUnoCursor.GetPoint()->nContent.Assign(pCNode, 0); + } + } } } - else + else if ( (CURSOR_FRAME == m_pImpl->m_eType) + || (CURSOR_TBLTEXT == m_pImpl->m_eType) + || (CURSOR_HEADER == m_pImpl->m_eType) + || (CURSOR_FOOTER == m_pImpl->m_eType) + || (CURSOR_FOOTNOTE== m_pImpl->m_eType) + || (CURSOR_REDLINE == m_pImpl->m_eType)) { - throw uno::RuntimeException(); + rUnoCursor.MoveSection(fnSectionCurr, fnSectionStart); + } + else if (CURSOR_META == m_pImpl->m_eType) + { + lcl_ForceIntoMeta(rUnoCursor, m_pImpl->m_xParentText, META_INIT_START); } } /*-- 09.12.98 14:18:43--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextCursor::gotoEnd(sal_Bool Expand) throw( uno::RuntimeException ) +void SAL_CALL +SwXTextCursor::gotoEnd(sal_Bool Expand) throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + SwUnoCursorHelper::SelectPam(rUnoCursor, Expand); + if (CURSOR_BODY == m_pImpl->m_eType) { - SwUnoCursorHelper::SelectPam(*pUnoCrsr, Expand); - if(eType == CURSOR_BODY) - { - pUnoCrsr->Move( fnMoveForward, fnGoDoc ); - } - else if(eType == CURSOR_FRAME || - eType == CURSOR_TBLTEXT || - eType == CURSOR_HEADER || - eType == CURSOR_FOOTER || - eType == CURSOR_FOOTNOTE|| - eType == CURSOR_REDLINE) - { - pUnoCrsr->MoveSection( fnSectionCurr, fnSectionEnd); - } - else if (CURSOR_META == eType) - { - lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_INIT_END); - } + rUnoCursor.Move( fnMoveForward, fnGoDoc ); } - else + else if ( (CURSOR_FRAME == m_pImpl->m_eType) + || (CURSOR_TBLTEXT == m_pImpl->m_eType) + || (CURSOR_HEADER == m_pImpl->m_eType) + || (CURSOR_FOOTER == m_pImpl->m_eType) + || (CURSOR_FOOTNOTE== m_pImpl->m_eType) + || (CURSOR_REDLINE == m_pImpl->m_eType)) { - throw uno::RuntimeException(); + rUnoCursor.MoveSection( fnSectionCurr, fnSectionEnd); + } + else if (CURSOR_META == m_pImpl->m_eType) + { + lcl_ForceIntoMeta(rUnoCursor, m_pImpl->m_xParentText, META_INIT_END); } } -void SwXTextCursor::gotoRange(const uno::Reference< XTextRange > & xRange, sal_Bool bExpand ) - throw( uno::RuntimeException ) +void SAL_CALL +SwXTextCursor::gotoRange( + const uno::Reference< text::XTextRange > & xRange, sal_Bool bExpand) +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pOwnCursor = GetCrsr(); - if(!pOwnCursor || !xRange.is()) + + if (!xRange.is()) { throw uno::RuntimeException(); } + SwUnoCrsr & rOwnCursor( m_pImpl->GetCursorOrThrow() ); + uno::Reference xRangeTunnel( xRange, uno::UNO_QUERY); SwXTextRange* pRange = 0; OTextCursorHelper* pCursor = 0; if(xRangeTunnel.is()) { - pRange = reinterpret_cast< SwXTextRange * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXTextRange::getUnoTunnelId()) )); - pCursor = reinterpret_cast< OTextCursorHelper * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( OTextCursorHelper::getUnoTunnelId()) )); + pRange = ::sw::UnoTunnelGetImplementation(xRangeTunnel); + pCursor = + ::sw::UnoTunnelGetImplementation(xRangeTunnel); } if (!pRange && !pCursor) @@ -1339,7 +1309,7 @@ void SwXTextCursor::gotoRange(const uno::Reference< XTextRange > & xRange, sal_B } SwStartNodeType eSearchNodeType = SwNormalStartNode; - switch(eType) + switch (m_pImpl->m_eType) { case CURSOR_FRAME: eSearchNodeType = SwFlyStartNode; break; case CURSOR_TBLTEXT: eSearchNodeType = SwTableBoxStartNode; break; @@ -1351,8 +1321,8 @@ void SwXTextCursor::gotoRange(const uno::Reference< XTextRange > & xRange, sal_B default: ; } - const SwStartNode* pOwnStartNode = pOwnCursor->GetNode()-> - FindSttNodeByType(eSearchNodeType); + const SwStartNode* pOwnStartNode = + rOwnCursor.GetNode()->FindSttNodeByType(eSearchNodeType); SwPaM aPam(GetDoc()->GetNodes()); const SwPaM * pPam(0); @@ -1389,11 +1359,11 @@ void SwXTextCursor::gotoRange(const uno::Reference< XTextRange > & xRange, sal_B throw uno::RuntimeException(); } - if (CURSOR_META == eType) + if (CURSOR_META == m_pImpl->m_eType) { SwPaM CopyPam(*pPam->GetMark(), *pPam->GetPoint()); - const bool bNotForced( - lcl_ForceIntoMeta(CopyPam, xParentText, META_CHECK_BOTH) ); + const bool bNotForced( lcl_ForceIntoMeta( + CopyPam, m_pImpl->m_xParentText, META_CHECK_BOTH) ); if (!bNotForced) { throw uno::RuntimeException( @@ -1408,40 +1378,30 @@ void SwXTextCursor::gotoRange(const uno::Reference< XTextRange > & xRange, sal_B { // der Cursor soll alles einschliessen, was bisher von ihm und dem uebergebenen // Range eingeschlossen wurde - SwPosition aOwnLeft(*pOwnCursor->GetPoint()); - SwPosition aOwnRight(pOwnCursor->HasMark() ? *pOwnCursor->GetMark() : aOwnLeft); - if(aOwnRight < aOwnLeft) - { - SwPosition aTmp = aOwnLeft; - aOwnLeft = aOwnRight; - aOwnRight = aTmp; - } - SwPosition const* pParamLeft = pPam->Start(); - SwPosition const* pParamRight = pPam->End(); + const SwPosition aOwnLeft(*rOwnCursor.Start()); + const SwPosition aOwnRight(*rOwnCursor.End()); + SwPosition const& rParamLeft = *pPam->Start(); + SwPosition const& rParamRight = *pPam->End(); // jetzt sind vier SwPositions da, zwei davon werden gebraucht, also welche? - if(aOwnRight > *pParamRight) - *pOwnCursor->GetPoint() = aOwnRight; - else - *pOwnCursor->GetPoint() = *pParamRight; - pOwnCursor->SetMark(); - if(aOwnLeft < *pParamLeft) - *pOwnCursor->GetMark() = aOwnLeft; - else - *pOwnCursor->GetMark() = *pParamLeft; + *rOwnCursor.GetPoint() = (aOwnRight > rParamRight) + ? aOwnRight : *rOwnCursor.GetPoint() = rParamRight; + rOwnCursor.SetMark(); + *rOwnCursor.GetMark() = (aOwnLeft < rParamLeft) + ? aOwnLeft : *rOwnCursor.GetMark() = rParamLeft; } else { // cursor should be the given range - *pOwnCursor->GetPoint() = *pPam->GetPoint(); + *rOwnCursor.GetPoint() = *pPam->GetPoint(); if (pPam->HasMark()) { - pOwnCursor->SetMark(); - *pOwnCursor->GetMark() = *pPam->GetMark(); + rOwnCursor.SetMark(); + *rOwnCursor.GetMark() = *pPam->GetMark(); } else { - pOwnCursor->DeleteMark(); + rOwnCursor.DeleteMark(); } } } @@ -1449,169 +1409,157 @@ void SwXTextCursor::gotoRange(const uno::Reference< XTextRange > & xRange, sal_B /*-- 09.12.98 14:18:44--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXTextCursor::isStartOfWord(void) throw( uno::RuntimeException ) +sal_Bool SAL_CALL SwXTextCursor::isStartOfWord() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - sal_Bool bRet = sal_False; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) - { - bRet = pUnoCrsr->IsStartWordWT( i18n::WordType::DICTIONARY_WORD ); - } - else - { - throw uno::RuntimeException(); - } + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + const sal_Bool bRet = + rUnoCursor.IsStartWordWT( i18n::WordType::DICTIONARY_WORD ); return bRet; } /*-- 09.12.98 14:18:44--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXTextCursor::isEndOfWord(void) throw( uno::RuntimeException ) +sal_Bool SAL_CALL SwXTextCursor::isEndOfWord() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - sal_Bool bRet = sal_False; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) - { - bRet = pUnoCrsr->IsEndWordWT( i18n::WordType::DICTIONARY_WORD ); - } - else - { - throw uno::RuntimeException(); - } + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + const sal_Bool bRet = + rUnoCursor.IsEndWordWT( i18n::WordType::DICTIONARY_WORD ); return bRet; } + /*-- 09.12.98 14:18:44--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXTextCursor::gotoNextWord(sal_Bool Expand) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXTextCursor::gotoNextWord(sal_Bool Expand) throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - //Probleme gibt's noch mit einem Absatzanfang, an dem kein Wort beginnt. - SwUnoCrsr* pUnoCrsr = GetCrsr(); + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + //Probleme gibt's noch mit einem Absatzanfang, an dem kein Wort beginnt. sal_Bool bRet = sal_False; - if(pUnoCrsr) - { - // remember old position to check if cursor has moved - // since the called functions are sometimes a bit unreliable - // in specific cases... - SwPosition *pPoint = pUnoCrsr->GetPoint(); - SwNode *pOldNode = &pPoint->nNode.GetNode(); - xub_StrLen nOldIndex = pPoint->nContent.GetIndex(); - - SwUnoCursorHelper::SelectPam(*pUnoCrsr, Expand); - //Absatzende? - if(pUnoCrsr->GetCntntNode() && - pPoint->nContent == pUnoCrsr->GetCntntNode()->Len()) - { - pUnoCrsr->Right(1, CRSR_SKIP_CHARS, FALSE, FALSE); - } - else - { - sal_Bool bTmp = pUnoCrsr->GoNextWordWT( i18n::WordType::DICTIONARY_WORD ); - //if there is no next word within the current paragraph try to go to the start of the next paragraph - if(!bTmp) - pUnoCrsr->MovePara(fnParaNext, fnParaStart); - } + // remember old position to check if cursor has moved + // since the called functions are sometimes a bit unreliable + // in specific cases... + SwPosition *const pPoint = rUnoCursor.GetPoint(); + SwNode *const pOldNode = &pPoint->nNode.GetNode(); + xub_StrLen const nOldIndex = pPoint->nContent.GetIndex(); - // return true if cursor has moved - bRet = &pPoint->nNode.GetNode() != pOldNode || - pPoint->nContent.GetIndex() != nOldIndex; - if (bRet && (CURSOR_META == eType)) + SwUnoCursorHelper::SelectPam(rUnoCursor, Expand); + // end of paragraph + if (rUnoCursor.GetCntntNode() && + (pPoint->nContent == rUnoCursor.GetCntntNode()->Len())) + { + rUnoCursor.Right(1, CRSR_SKIP_CHARS, FALSE, FALSE); + } + else + { + const bool bTmp = + rUnoCursor.GoNextWordWT( i18n::WordType::DICTIONARY_WORD ); + // if there is no next word within the current paragraph + // try to go to the start of the next paragraph + if (!bTmp) { - bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH); + rUnoCursor.MovePara(fnParaNext, fnParaStart); } } - else + + // return true if cursor has moved + bRet = (&pPoint->nNode.GetNode() != pOldNode) || + (pPoint->nContent.GetIndex() != nOldIndex); + if (bRet && (CURSOR_META == m_pImpl->m_eType)) { - throw uno::RuntimeException(); + bRet = lcl_ForceIntoMeta(rUnoCursor, m_pImpl->m_xParentText, + META_CHECK_BOTH); } return bRet; } + /*-- 09.12.98 14:18:45--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXTextCursor::gotoPreviousWord(sal_Bool Expand) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXTextCursor::gotoPreviousWord(sal_Bool Expand) throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - // hier machen Leerzeichen am Absatzanfang Probleme - SwUnoCrsr* pUnoCrsr = GetCrsr(); - sal_Bool bRet = sal_False; - if(pUnoCrsr) - { - SwPosition *pPoint = pUnoCrsr->GetPoint(); - SwNode *pOldNode = &pPoint->nNode.GetNode(); - xub_StrLen nOldIndex = pPoint->nContent.GetIndex(); + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); - SwUnoCursorHelper::SelectPam(*pUnoCrsr, Expand); - //Absatzanfang ? - if(pPoint->nContent == 0) - { - pUnoCrsr->Left(1, CRSR_SKIP_CHARS, FALSE, FALSE); - } - else - { - pUnoCrsr->GoPrevWordWT( i18n::WordType::DICTIONARY_WORD ); - if(pPoint->nContent == 0) - pUnoCrsr->Left(1, CRSR_SKIP_CHARS, FALSE, FALSE); - } + // hier machen Leerzeichen am Absatzanfang Probleme + sal_Bool bRet = sal_False; + SwPosition *const pPoint = rUnoCursor.GetPoint(); + SwNode *const pOldNode = &pPoint->nNode.GetNode(); + xub_StrLen const nOldIndex = pPoint->nContent.GetIndex(); - // return true if cursor has moved - bRet = &pPoint->nNode.GetNode() != pOldNode || - pPoint->nContent.GetIndex() != nOldIndex; - if (bRet && (CURSOR_META == eType)) + SwUnoCursorHelper::SelectPam(rUnoCursor, Expand); + // start of paragraph? + if (pPoint->nContent == 0) + { + rUnoCursor.Left(1, CRSR_SKIP_CHARS, FALSE, FALSE); + } + else + { + rUnoCursor.GoPrevWordWT( i18n::WordType::DICTIONARY_WORD ); + if (pPoint->nContent == 0) { - bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH); + rUnoCursor.Left(1, CRSR_SKIP_CHARS, FALSE, FALSE); } } - else + + // return true if cursor has moved + bRet = (&pPoint->nNode.GetNode() != pOldNode) || + (pPoint->nContent.GetIndex() != nOldIndex); + if (bRet && (CURSOR_META == m_pImpl->m_eType)) { - throw uno::RuntimeException(); + bRet = lcl_ForceIntoMeta(rUnoCursor, m_pImpl->m_xParentText, + META_CHECK_BOTH); } return bRet; } + /*-- 09.12.98 14:18:45--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXTextCursor::gotoEndOfWord(sal_Bool Expand) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXTextCursor::gotoEndOfWord(sal_Bool Expand) throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = GetCrsr(); + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); sal_Bool bRet = sal_False; - if(pUnoCrsr) - { - SwPosition *pPoint = pUnoCrsr->GetPoint(); - SwNode &rOldNode = pPoint->nNode.GetNode(); - xub_StrLen nOldIndex = pPoint->nContent.GetIndex(); + SwPosition *const pPoint = rUnoCursor.GetPoint(); + SwNode & rOldNode = pPoint->nNode.GetNode(); + xub_StrLen const nOldIndex = pPoint->nContent.GetIndex(); - sal_Int16 nWordType = i18n::WordType::DICTIONARY_WORD; - SwUnoCursorHelper::SelectPam(*pUnoCrsr, Expand); - if(!pUnoCrsr->IsEndWordWT( nWordType )) - pUnoCrsr->GoEndWordWT( nWordType ); + const sal_Int16 nWordType = i18n::WordType::DICTIONARY_WORD; + SwUnoCursorHelper::SelectPam(rUnoCursor, Expand); + if (!rUnoCursor.IsEndWordWT( nWordType )) + { + rUnoCursor.GoEndWordWT( nWordType ); + } - // restore old cursor if we are not at the end of a word by now - // otherwise use current one - bRet = pUnoCrsr->IsEndWordWT( nWordType ); - if (!bRet) - { - pPoint->nNode = rOldNode; - pPoint->nContent = nOldIndex; - } - else if (CURSOR_META == eType) - { - bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH); - } + // restore old cursor if we are not at the end of a word by now + // otherwise use current one + bRet = rUnoCursor.IsEndWordWT( nWordType ); + if (!bRet) + { + pPoint->nNode = rOldNode; + pPoint->nContent = nOldIndex; } - else + else if (CURSOR_META == m_pImpl->m_eType) { - throw uno::RuntimeException(); + bRet = lcl_ForceIntoMeta(rUnoCursor, m_pImpl->m_xParentText, + META_CHECK_BOTH); } return bRet; @@ -1619,270 +1567,266 @@ sal_Bool SwXTextCursor::gotoEndOfWord(sal_Bool Expand) throw( uno::RuntimeExcept /*-- 09.12.98 14:18:46--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXTextCursor::gotoStartOfWord(sal_Bool Expand) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXTextCursor::gotoStartOfWord(sal_Bool Expand) throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = GetCrsr(); + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); sal_Bool bRet = sal_False; - if(pUnoCrsr) - { - SwPosition *pPoint = pUnoCrsr->GetPoint(); - SwNode &rOldNode = pPoint->nNode.GetNode(); - xub_StrLen nOldIndex = pPoint->nContent.GetIndex(); + SwPosition *const pPoint = rUnoCursor.GetPoint(); + SwNode & rOldNode = pPoint->nNode.GetNode(); + xub_StrLen const nOldIndex = pPoint->nContent.GetIndex(); - sal_Int16 nWordType = i18n::WordType::DICTIONARY_WORD; - SwUnoCursorHelper::SelectPam(*pUnoCrsr, Expand); - if(!pUnoCrsr->IsStartWordWT( nWordType )) - pUnoCrsr->GoStartWordWT( nWordType ); + const sal_Int16 nWordType = i18n::WordType::DICTIONARY_WORD; + SwUnoCursorHelper::SelectPam(rUnoCursor, Expand); + if (!rUnoCursor.IsStartWordWT( nWordType )) + { + rUnoCursor.GoStartWordWT( nWordType ); + } - // restore old cursor if we are not at the start of a word by now - // otherwise use current one - bRet = pUnoCrsr->IsStartWordWT( nWordType ); - if (!bRet) - { - pPoint->nNode = rOldNode; - pPoint->nContent = nOldIndex; - } - else if (CURSOR_META == eType) - { - bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH); - } + // restore old cursor if we are not at the start of a word by now + // otherwise use current one + bRet = rUnoCursor.IsStartWordWT( nWordType ); + if (!bRet) + { + pPoint->nNode = rOldNode; + pPoint->nContent = nOldIndex; } - else + else if (CURSOR_META == m_pImpl->m_eType) { - throw uno::RuntimeException(); + bRet = lcl_ForceIntoMeta(rUnoCursor, m_pImpl->m_xParentText, + META_CHECK_BOTH); } return bRet; } + /*-- 09.12.98 14:18:46--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXTextCursor::isStartOfSentence(void) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXTextCursor::isStartOfSentence() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - sal_Bool bRet = sal_False; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + // start of paragraph? + sal_Bool bRet = rUnoCursor.GetPoint()->nContent == 0; + // with mark ->no sentence start + // (check if cursor is no selection, i.e. it does not have + // a mark or else point and mark are identical) + if (!bRet && (!rUnoCursor.HasMark() || + *rUnoCursor.GetPoint() == *rUnoCursor.GetMark())) { - // start of paragraph? - bRet = pUnoCrsr->GetPoint()->nContent == 0; - // with mark ->no sentence start - // (check if cursor is no selection, i.e. it does not have - // a mark or else point and mark are identical) - if(!bRet && (!pUnoCrsr->HasMark() || - *pUnoCrsr->GetPoint() == *pUnoCrsr->GetMark())) - { - SwCursor aCrsr(*pUnoCrsr->GetPoint(),0,false); - SwPosition aOrigPos = *aCrsr.GetPoint(); - aCrsr.GoSentence(SwCursor::START_SENT ); - bRet = aOrigPos == *aCrsr.GetPoint(); - } + SwCursor aCrsr(*rUnoCursor.GetPoint(),0,false); + SwPosition aOrigPos = *aCrsr.GetPoint(); + aCrsr.GoSentence(SwCursor::START_SENT ); + bRet = aOrigPos == *aCrsr.GetPoint(); } - else - throw uno::RuntimeException(); return bRet; } /*-- 09.12.98 14:18:47--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXTextCursor::isEndOfSentence(void) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXTextCursor::isEndOfSentence() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - sal_Bool bRet = sal_False; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + // end of paragraph? + sal_Bool bRet = rUnoCursor.GetCntntNode() && + (rUnoCursor.GetPoint()->nContent == rUnoCursor.GetCntntNode()->Len()); + // with mark->no sentence end + // (check if cursor is no selection, i.e. it does not have + // a mark or else point and mark are identical) + if (!bRet && (!rUnoCursor.HasMark() || + *rUnoCursor.GetPoint() == *rUnoCursor.GetMark())) { - //end of paragraph? - bRet = pUnoCrsr->GetCntntNode() && - pUnoCrsr->GetPoint()->nContent == pUnoCrsr->GetCntntNode()->Len(); - // with mark->no sentence end - // (check if cursor is no selection, i.e. it does not have - // a mark or else point and mark are identical) - if(!bRet && (!pUnoCrsr->HasMark() || - *pUnoCrsr->GetPoint() == *pUnoCrsr->GetMark())) - { - SwCursor aCrsr(*pUnoCrsr->GetPoint(),0,false); - SwPosition aOrigPos = *aCrsr.GetPoint(); - aCrsr.GoSentence(SwCursor::END_SENT ); - bRet = aOrigPos == *aCrsr.GetPoint(); - } + SwCursor aCrsr(*rUnoCursor.GetPoint(), 0, false); + SwPosition aOrigPos = *aCrsr.GetPoint(); + aCrsr.GoSentence(SwCursor::END_SENT); + bRet = aOrigPos == *aCrsr.GetPoint(); } - else - throw uno::RuntimeException(); return bRet; } + /*-- 09.12.98 14:18:47--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXTextCursor::gotoNextSentence(sal_Bool Expand) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXTextCursor::gotoNextSentence(sal_Bool Expand) throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - sal_Bool bRet = sal_False; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + const bool bWasEOS = isEndOfSentence(); + SwUnoCursorHelper::SelectPam(rUnoCursor, Expand); + sal_Bool bRet = rUnoCursor.GoSentence(SwCursor::NEXT_SENT); + if (!bRet) { - BOOL bWasEOS = isEndOfSentence(); - SwUnoCursorHelper::SelectPam(*pUnoCrsr, Expand); - bRet = pUnoCrsr->GoSentence(SwCursor::NEXT_SENT); - if(!bRet) - bRet = pUnoCrsr->MovePara(fnParaNext, fnParaStart); + bRet = rUnoCursor.MovePara(fnParaNext, fnParaStart); + } - // if at the end of the sentence (i.e. at the space after the '.') - // advance to next word in order for GoSentence to work properly - // next time and have isStartOfSentence return true after this call - if (!pUnoCrsr->IsStartWord()) - { - BOOL bNextWord = pUnoCrsr->GoNextWord(); - if (bWasEOS && !bNextWord) - bRet = sal_False; - } - if (CURSOR_META == eType) + // if at the end of the sentence (i.e. at the space after the '.') + // advance to next word in order for GoSentence to work properly + // next time and have isStartOfSentence return true after this call + if (!rUnoCursor.IsStartWord()) + { + const bool bNextWord = rUnoCursor.GoNextWord(); + if (bWasEOS && !bNextWord) { - bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH) - && bRet; + bRet = sal_False; } } - else - throw uno::RuntimeException(); + if (CURSOR_META == m_pImpl->m_eType) + { + bRet = lcl_ForceIntoMeta(rUnoCursor, m_pImpl->m_xParentText, + META_CHECK_BOTH) + && bRet; + } return bRet; } /*-- 09.12.98 14:18:47--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXTextCursor::gotoPreviousSentence(sal_Bool Expand) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXTextCursor::gotoPreviousSentence(sal_Bool Expand) +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - sal_Bool bRet = sal_False; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + SwUnoCursorHelper::SelectPam(rUnoCursor, Expand); + sal_Bool bRet = rUnoCursor.GoSentence(SwCursor::PREV_SENT); + if (!bRet) { - SwUnoCursorHelper::SelectPam(*pUnoCrsr, Expand); - bRet = pUnoCrsr->GoSentence(SwCursor::PREV_SENT); - if(!bRet) - { - if(0 != (bRet = pUnoCrsr->MovePara(fnParaPrev, fnParaStart))) - { - pUnoCrsr->MovePara(fnParaCurr, fnParaEnd); - //at the end of a paragraph move to the sentence end again - // - pUnoCrsr->GoSentence(SwCursor::PREV_SENT); - } - } - if (CURSOR_META == eType) + bRet = rUnoCursor.MovePara(fnParaPrev, fnParaStart); + if (bRet) { - bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH) - && bRet; + rUnoCursor.MovePara(fnParaCurr, fnParaEnd); + // at the end of a paragraph move to the sentence end again + rUnoCursor.GoSentence(SwCursor::PREV_SENT); } } - else - throw uno::RuntimeException(); + if (CURSOR_META == m_pImpl->m_eType) + { + bRet = lcl_ForceIntoMeta(rUnoCursor, m_pImpl->m_xParentText, + META_CHECK_BOTH) + && bRet; + } return bRet; } + /* -----------------15.10.99 08:24------------------- --------------------------------------------------*/ -sal_Bool SwXTextCursor::gotoStartOfSentence(sal_Bool Expand) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXTextCursor::gotoStartOfSentence(sal_Bool Expand) +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + sal_Bool bRet = sal_False; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) - { - SwUnoCursorHelper::SelectPam(*pUnoCrsr, Expand); - // if we're at the para start then we wont move - // but bRet is also true if GoSentence failed but - // the start of the sentence is reached - bRet = SwUnoCursorHelper::IsStartOfPara(*pUnoCrsr) - || pUnoCrsr->GoSentence(SwCursor::START_SENT) || - SwUnoCursorHelper::IsStartOfPara(*pUnoCrsr); - if (CURSOR_META == eType) - { - bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH) - && bRet; - } + SwUnoCursorHelper::SelectPam(rUnoCursor, Expand); + // if we're at the para start then we wont move + // but bRet is also true if GoSentence failed but + // the start of the sentence is reached + bRet = SwUnoCursorHelper::IsStartOfPara(rUnoCursor) + || rUnoCursor.GoSentence(SwCursor::START_SENT) + || SwUnoCursorHelper::IsStartOfPara(rUnoCursor); + if (CURSOR_META == m_pImpl->m_eType) + { + bRet = lcl_ForceIntoMeta(rUnoCursor, m_pImpl->m_xParentText, + META_CHECK_BOTH) + && bRet; } - else - throw uno::RuntimeException(); return bRet; } /* -----------------15.10.99 08:24------------------- --------------------------------------------------*/ -sal_Bool SwXTextCursor::gotoEndOfSentence(sal_Bool Expand) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXTextCursor::gotoEndOfSentence(sal_Bool Expand) throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + sal_Bool bRet = sal_False; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) - { - SwUnoCursorHelper::SelectPam(*pUnoCrsr, Expand); - // bRet is true if GoSentence() succeeded or if the - // MovePara() succeeded while the end of the para is - // not reached already - sal_Bool bAlreadyParaEnd = SwUnoCursorHelper::IsEndOfPara(*pUnoCrsr); - bRet = !bAlreadyParaEnd && - (pUnoCrsr->GoSentence(SwCursor::END_SENT) || - pUnoCrsr->MovePara(fnParaCurr, fnParaEnd)); - if (CURSOR_META == eType) - { - bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH) - && bRet; - } + SwUnoCursorHelper::SelectPam(rUnoCursor, Expand); + // bRet is true if GoSentence() succeeded or if the + // MovePara() succeeded while the end of the para is + // not reached already + sal_Bool bAlreadyParaEnd = SwUnoCursorHelper::IsEndOfPara(rUnoCursor); + bRet = !bAlreadyParaEnd + && (rUnoCursor.GoSentence(SwCursor::END_SENT) + || rUnoCursor.MovePara(fnParaCurr, fnParaEnd)); + if (CURSOR_META == m_pImpl->m_eType) + { + bRet = lcl_ForceIntoMeta(rUnoCursor, m_pImpl->m_xParentText, + META_CHECK_BOTH) + && bRet; } - else - throw uno::RuntimeException(); return bRet; } /*-- 09.12.98 14:18:48--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXTextCursor::isStartOfParagraph(void) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXTextCursor::isStartOfParagraph() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - sal_Bool bRet = sal_False; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) - bRet = SwUnoCursorHelper::IsStartOfPara(*pUnoCrsr); - else - throw uno::RuntimeException(); + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + const sal_Bool bRet = SwUnoCursorHelper::IsStartOfPara(rUnoCursor); return bRet; } /*-- 09.12.98 14:18:48--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXTextCursor::isEndOfParagraph(void) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXTextCursor::isEndOfParagraph() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - sal_Bool bRet = sal_False; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) - bRet = SwUnoCursorHelper::IsEndOfPara(*pUnoCrsr); - else - throw uno::RuntimeException(); + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + const sal_Bool bRet = SwUnoCursorHelper::IsEndOfPara(rUnoCursor); return bRet; } + /*-- 09.12.98 14:18:49--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXTextCursor::gotoStartOfParagraph(sal_Bool Expand) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXTextCursor::gotoStartOfParagraph(sal_Bool Expand) +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - sal_Bool bRet = sal_False; - if (CURSOR_META == eType) - return bRet; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr ) + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + if (CURSOR_META == m_pImpl->m_eType) { - SwUnoCursorHelper::SelectPam(*pUnoCrsr, Expand); - bRet = SwUnoCursorHelper::IsStartOfPara(*pUnoCrsr); - if(!bRet) - bRet = pUnoCrsr->MovePara(fnParaCurr, fnParaStart); + return sal_False; + } + SwUnoCursorHelper::SelectPam(rUnoCursor, Expand); + sal_Bool bRet = SwUnoCursorHelper::IsStartOfPara(rUnoCursor); + if (!bRet) + { + bRet = rUnoCursor.MovePara(fnParaCurr, fnParaStart); } - else - throw uno::RuntimeException(); // since MovePara(fnParaCurr, fnParaStart) only returns false // if we were already at the start of the paragraph this function @@ -1893,22 +1837,23 @@ sal_Bool SwXTextCursor::gotoStartOfParagraph(sal_Bool Expand) throw( uno::Runtim /*-- 09.12.98 14:18:49--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXTextCursor::gotoEndOfParagraph(sal_Bool Expand) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXTextCursor::gotoEndOfParagraph(sal_Bool Expand) throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - sal_Bool bRet = sal_False; - if (CURSOR_META == eType) - return bRet; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + if (CURSOR_META == m_pImpl->m_eType) { - SwUnoCursorHelper::SelectPam(*pUnoCrsr, Expand); - bRet = SwUnoCursorHelper::IsEndOfPara(*pUnoCrsr); - if(!bRet) - bRet = pUnoCrsr->MovePara(fnParaCurr, fnParaEnd); + return sal_False; + } + SwUnoCursorHelper::SelectPam(rUnoCursor, Expand); + sal_Bool bRet = SwUnoCursorHelper::IsEndOfPara(rUnoCursor); + if (!bRet) + { + bRet = rUnoCursor.MovePara(fnParaCurr, fnParaEnd); } - else - throw uno::RuntimeException(); // since MovePara(fnParaCurr, fnParaEnd) only returns false // if we were already at the end of the paragraph this function @@ -1916,158 +1861,144 @@ sal_Bool SwXTextCursor::gotoEndOfParagraph(sal_Bool Expand) throw( uno::RuntimeE DBG_ASSERT( bRet, "gotoEndOfParagraph failed" ); return bRet; } + /*-- 09.12.98 14:18:50--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXTextCursor::gotoNextParagraph(sal_Bool Expand) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXTextCursor::gotoNextParagraph(sal_Bool Expand) throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - sal_Bool bRet = sal_False; - if (CURSOR_META == eType) - return bRet; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + if (CURSOR_META == m_pImpl->m_eType) { - SwUnoCursorHelper::SelectPam(*pUnoCrsr, Expand); - bRet = pUnoCrsr->MovePara(fnParaNext, fnParaStart); + return sal_False; } - else - throw uno::RuntimeException(); + SwUnoCursorHelper::SelectPam(rUnoCursor, Expand); + const sal_Bool bRet = rUnoCursor.MovePara(fnParaNext, fnParaStart); return bRet; } /*-- 09.12.98 14:18:50--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXTextCursor::gotoPreviousParagraph(sal_Bool Expand) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXTextCursor::gotoPreviousParagraph(sal_Bool Expand) +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - sal_Bool bRet = sal_False; - if (CURSOR_META == eType) - return bRet; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + if (CURSOR_META == m_pImpl->m_eType) { - SwUnoCursorHelper::SelectPam(*pUnoCrsr, Expand); - bRet = pUnoCrsr->MovePara(fnParaPrev, fnParaStart); + return sal_False; } - else - throw uno::RuntimeException(); + SwUnoCursorHelper::SelectPam(rUnoCursor, Expand); + const sal_Bool bRet = rUnoCursor.MovePara(fnParaPrev, fnParaStart); return bRet; } + /*-- 09.12.98 14:18:50--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< XText > SwXTextCursor::getText(void) throw( uno::RuntimeException ) +uno::Reference< text::XText > SAL_CALL +SwXTextCursor::getText() throw (uno::RuntimeException) { - return xParentText; + vos::OGuard g(Application::GetSolarMutex()); + + return m_pImpl->m_xParentText; } + /*-- 09.12.98 14:18:50--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< XTextRange > SwXTextCursor::getStart(void) throw( uno::RuntimeException ) +uno::Reference< text::XTextRange > SAL_CALL +SwXTextCursor::getStart() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< XTextRange > xRet; - SwUnoCrsr* pUnoCrsr = ((SwXTextCursor*)this)->GetCrsr(); - if( pUnoCrsr) + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + uno::Reference< text::XTextRange > xRet; + SwPaM aPam(*rUnoCursor.Start()); + const uno::Reference< text::XText > xParent = getText(); + if (CURSOR_META == m_pImpl->m_eType) { - SwPaM aPam(*pUnoCrsr->Start()); - uno::Reference< XText > xParent = getText(); - if (CURSOR_META == eType) - { - // return cursor to prevent modifying SwXTextRange for META - SwXTextCursor * const pCursor( - new SwXTextCursor(xParent, *pUnoCrsr->GetPoint(), - CURSOR_META, pUnoCrsr->GetDoc()) ); - pCursor->gotoStart(sal_False); - xRet = static_cast(pCursor); - } - else - { - xRet = new SwXTextRange(aPam, xParent); - } + // return cursor to prevent modifying SwXTextRange for META + SwXTextCursor * const pXCursor( + new SwXTextCursor(*rUnoCursor.GetDoc(), xParent, CURSOR_META, + *rUnoCursor.GetPoint()) ); + pXCursor->gotoStart(sal_False); + xRet = static_cast(pXCursor); } else - throw uno::RuntimeException(); + { + xRet = new SwXTextRange(aPam, xParent); + } return xRet; } /*-- 09.12.98 14:18:51--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< XTextRange > SwXTextCursor::getEnd(void) throw( uno::RuntimeException ) +uno::Reference< text::XTextRange > SAL_CALL +SwXTextCursor::getEnd() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< XTextRange > xRet; - SwUnoCrsr* pUnoCrsr = ((SwXTextCursor*)this)->GetCrsr(); - if( pUnoCrsr) + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + uno::Reference< text::XTextRange > xRet; + SwPaM aPam(*rUnoCursor.End()); + const uno::Reference< text::XText > xParent = getText(); + if (CURSOR_META == m_pImpl->m_eType) { - SwPaM aPam(*pUnoCrsr->End()); - uno::Reference< XText > xParent = getText(); - if (CURSOR_META == eType) - { - // return cursor to prevent modifying SwXTextRange for META - SwXTextCursor * const pCursor( - new SwXTextCursor(xParent, *pUnoCrsr->GetPoint(), - CURSOR_META, pUnoCrsr->GetDoc()) ); - pCursor->gotoEnd(sal_False); - xRet = static_cast(pCursor); - } - else - { - xRet = new SwXTextRange(aPam, xParent); - } + // return cursor to prevent modifying SwXTextRange for META + SwXTextCursor * const pXCursor( + new SwXTextCursor(*rUnoCursor.GetDoc(), xParent, CURSOR_META, + *rUnoCursor.GetPoint()) ); + pXCursor->gotoEnd(sal_False); + xRet = static_cast(pXCursor); } else - throw uno::RuntimeException(); + { + xRet = new SwXTextRange(aPam, xParent); + } return xRet; } + /*-- 09.12.98 14:18:51--------------------------------------------------- -----------------------------------------------------------------------*/ -OUString SwXTextCursor::getString(void) throw( uno::RuntimeException ) +OUString SAL_CALL SwXTextCursor::getString() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + OUString aTxt; - SwUnoCrsr* pUnoCrsr = ((SwXTextCursor*)this)->GetCrsr(); - if( pUnoCrsr) - { -/* if( pUnoCrsr->GetPoint()->nNode.GetIndex() == - pUnoCrsr->GetMark()->nNode.GetIndex() ) - { - SwTxtNode* pTxtNd = pUnoCrsr->GetNode()->GetTxtNode(); - if( pTxtNd ) - { - sal_uInt16 nStt = pUnoCrsr->Start()->nContent.GetIndex(); - aTxt = pTxtNd->GetExpandTxt( nStt, - pUnoCrsr->End()->nContent.GetIndex() - nStt ); - } - } - else -*/ { - //Text ueber mehrere Absaetze - SwUnoCursorHelper::GetTextFromPam(*pUnoCrsr, aTxt); - } - } - else - throw uno::RuntimeException(); + SwUnoCursorHelper::GetTextFromPam(rUnoCursor, aTxt); return aTxt; } /*-- 09.12.98 14:18:52--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextCursor::setString(const OUString& aString) throw( uno::RuntimeException ) +void SAL_CALL +SwXTextCursor::setString(const OUString& aString) throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(!pUnoCrsr) - throw uno::RuntimeException(); - const bool bForceExpandHints( (CURSOR_META != eType) + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + (void) rUnoCursor; // just to check if valid + + const bool bForceExpandHints( (CURSOR_META != m_pImpl->m_eType) ? false - : dynamic_cast(xParentText.get())->CheckForOwnMemberMeta( - *GetPaM(), true) ); + : dynamic_cast(m_pImpl->m_xParentText.get()) + ->CheckForOwnMemberMeta(*GetPaM(), true) ); DeleteAndInsert(aString, bForceExpandHints); } + /* -----------------------------03.05.00 12:56-------------------------------- ---------------------------------------------------------------------------*/ @@ -2374,11 +2305,15 @@ throw (beans::UnknownPropertyException, lang::WrappedTargetException, } return aRet; } + /*-- 09.12.98 14:18:54--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< beans::XPropertySetInfo > SwXTextCursor::getPropertySetInfo(void) throw( uno::RuntimeException ) +uno::Reference< beans::XPropertySetInfo > SAL_CALL +SwXTextCursor::getPropertySetInfo() throw (uno::RuntimeException) { + vos::OGuard g(Application::GetSolarMutex()); + static uno::Reference< beans::XPropertySetInfo > xRef; if(!xRef.is()) { @@ -2388,7 +2323,8 @@ uno::Reference< beans::XPropertySetInfo > SwXTextCursor::getPropertySetInfo(voi { SW_PROP_NAME(UNO_NAME_IS_SKIP_PROTECTED_TEXT), FN_SKIP_PROTECTED_TEXT, &::getBooleanCppuType(), PROPERTY_NONE, 0}, {0,0,0,0,0,0} }; - uno::Reference< beans::XPropertySetInfo > xInfo = m_pPropSet->getPropertySetInfo(); + const uno::Reference< beans::XPropertySetInfo > xInfo = + m_pImpl->m_rPropSet.getPropertySetInfo(); // PropertySetInfo verlaengern! const uno::Sequence aPropSeq = xInfo->getProperties(); xRef = new SfxExtItemPropertySetInfo( @@ -2397,283 +2333,361 @@ uno::Reference< beans::XPropertySetInfo > SwXTextCursor::getPropertySetInfo(voi } return xRef; } + /*-- 09.12.98 14:18:54--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextCursor::setPropertyValue(const OUString& rPropertyName, const uno::Any& aValue) - throw( beans::UnknownPropertyException, beans::PropertyVetoException, - lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +void SAL_CALL +SwXTextCursor::setPropertyValue( + const OUString& rPropertyName, const uno::Any& rValue) +throw (beans::UnknownPropertyException, beans::PropertyVetoException, + lang::IllegalArgumentException, lang::WrappedTargetException, + uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + if (rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_IS_SKIP_HIDDEN_TEXT))) { - if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_IS_SKIP_HIDDEN_TEXT))) + sal_Bool bSet(sal_False); + if (!(rValue >>= bSet)) { - sal_Bool bSet = *(sal_Bool*)aValue.getValue(); - pUnoCrsr->SetSkipOverHiddenSections(bSet); - } - else if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_IS_SKIP_PROTECTED_TEXT))) - { - sal_Bool bSet = *(sal_Bool*)aValue.getValue(); - pUnoCrsr->SetSkipOverProtectSections(bSet); + throw lang::IllegalArgumentException(); } - else + rUnoCursor.SetSkipOverHiddenSections(bSet); + } + else if (rPropertyName.equalsAsciiL( + SW_PROP_NAME(UNO_NAME_IS_SKIP_PROTECTED_TEXT))) + { + sal_Bool bSet(sal_False); + if (!(rValue >>= bSet)) { - SwUnoCursorHelper::SetPropertyValue(*pUnoCrsr, - *m_pPropSet, rPropertyName, aValue); + throw lang::IllegalArgumentException(); } + rUnoCursor.SetSkipOverProtectSections(bSet); } else - throw uno::RuntimeException(); - + { + SwUnoCursorHelper::SetPropertyValue(rUnoCursor, + m_pImpl->m_rPropSet, rPropertyName, rValue); + } } + /*-- 09.12.98 14:18:55--------------------------------------------------- -----------------------------------------------------------------------*/ -Any SwXTextCursor::getPropertyValue(const OUString& rPropertyName) - throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +uno::Any SAL_CALL +SwXTextCursor::getPropertyValue(const OUString& rPropertyName) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + uno::Any aAny; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) + if (rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_IS_SKIP_HIDDEN_TEXT))) { - if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_IS_SKIP_HIDDEN_TEXT))) - { - BOOL bSet = pUnoCrsr->IsSkipOverHiddenSections(); - aAny.setValue(&bSet, ::getBooleanCppuType()); - } - else if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_IS_SKIP_PROTECTED_TEXT))) - { - BOOL bSet = pUnoCrsr->IsSkipOverProtectSections(); - aAny.setValue(&bSet, ::getBooleanCppuType()); - } - else - { - aAny = SwUnoCursorHelper::GetPropertyValue(*pUnoCrsr, - *m_pPropSet, rPropertyName); - } + const sal_Bool bSet = rUnoCursor.IsSkipOverHiddenSections(); + aAny <<= bSet; + } + else if (rPropertyName.equalsAsciiL( + SW_PROP_NAME(UNO_NAME_IS_SKIP_PROTECTED_TEXT))) + { + const sal_Bool bSet = rUnoCursor.IsSkipOverProtectSections(); + aAny <<= bSet; } else - throw uno::RuntimeException(); + { + aAny = SwUnoCursorHelper::GetPropertyValue(rUnoCursor, + m_pImpl->m_rPropSet, rPropertyName); + } return aAny; - } + /*-- 09.12.98 14:18:55--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextCursor::addPropertyChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +void SAL_CALL +SwXTextCursor::addPropertyChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - DBG_WARNING("not implemented"); + OSL_ENSURE(false, + "SwXTextCursor::addPropertyChangeListener(): not implemented"); } + /*-- 09.12.98 14:18:57--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextCursor::removePropertyChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +void SAL_CALL +SwXTextCursor::removePropertyChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - DBG_WARNING("not implemented"); + OSL_ENSURE(false, + "SwXTextCursor::removePropertyChangeListener(): not implemented"); } + /*-- 09.12.98 14:18:57--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextCursor::addVetoableChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +void SAL_CALL +SwXTextCursor::addVetoableChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - DBG_WARNING("not implemented"); + OSL_ENSURE(false, + "SwXTextCursor::addVetoableChangeListener(): not implemented"); } + /*-- 09.12.98 14:18:58--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextCursor::removeVetoableChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +void SAL_CALL +SwXTextCursor::removeVetoableChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - DBG_WARNING("not implemented"); + OSL_ENSURE(false, + "SwXTextCursor::removeVetoableChangeListener(): not implemented"); } + /*-- 05.03.99 11:36:11--------------------------------------------------- -----------------------------------------------------------------------*/ -beans::PropertyState SwXTextCursor::getPropertyState(const OUString& rPropertyName) - throw( beans::UnknownPropertyException, uno::RuntimeException ) +beans::PropertyState SAL_CALL +SwXTextCursor::getPropertyState(const OUString& rPropertyName) +throw (beans::UnknownPropertyException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - beans::PropertyState eRet = beans::PropertyState_DEFAULT_VALUE; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) - { - eRet = SwUnoCursorHelper::GetPropertyState( - *pUnoCrsr, *m_pPropSet, rPropertyName); - } - else - throw RuntimeException(); + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + const beans::PropertyState eRet = SwUnoCursorHelper::GetPropertyState( + rUnoCursor, m_pImpl->m_rPropSet, rPropertyName); return eRet; } /*-- 05.03.99 11:36:11--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Sequence< beans::PropertyState > SwXTextCursor::getPropertyStates( - const uno::Sequence< OUString >& PropertyNames) - throw( beans::UnknownPropertyException, uno::RuntimeException ) +uno::Sequence< beans::PropertyState > SAL_CALL +SwXTextCursor::getPropertyStates( + const uno::Sequence< OUString >& rPropertyNames) +throw (beans::UnknownPropertyException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(!pUnoCrsr) - throw RuntimeException(); + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + return SwUnoCursorHelper::GetPropertyStates( - *pUnoCrsr, *m_pPropSet, PropertyNames); + rUnoCursor, m_pImpl->m_rPropSet, rPropertyNames); } + /*-- 05.03.99 11:36:12--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextCursor::setPropertyToDefault(const OUString& rPropertyName) - throw( beans::UnknownPropertyException, uno::RuntimeException ) +void SAL_CALL +SwXTextCursor::setPropertyToDefault(const OUString& rPropertyName) +throw (beans::UnknownPropertyException, uno::RuntimeException) { - Sequence < OUString > aSequence ( &rPropertyName, 1 ); + // forward: need no solar mutex here + uno::Sequence < OUString > aSequence ( &rPropertyName, 1 ); setPropertiesToDefault ( aSequence ); } /*-- 05.03.99 11:36:12--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Any SwXTextCursor::getPropertyDefault(const OUString& rPropertyName) - throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +uno::Any SAL_CALL +SwXTextCursor::getPropertyDefault(const OUString& rPropertyName) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - const Sequence < OUString > aSequence ( &rPropertyName, 1 ); + // forward: need no solar mutex here + const uno::Sequence < OUString > aSequence ( &rPropertyName, 1 ); return getPropertyDefaults ( aSequence ).getConstArray()[0]; } -void SAL_CALL SwXTextCursor::setAllPropertiesToDefault() - throw (RuntimeException) -{ - vos::OGuard aGuard(Application::GetSolarMutex()); +// para specific attribut ranges +static USHORT g_ParaResetableSetRange[] = { + RES_FRMATR_BEGIN, RES_FRMATR_END-1, + RES_PARATR_BEGIN, RES_PARATR_END-1, + // --> OD 2008-02-25 #refactorlists# + RES_PARATR_LIST_BEGIN, RES_PARATR_LIST_END-1, + // <-- + RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1, + 0 +}; + +// selection specific attribut ranges +static USHORT g_ResetableSetRange[] = { + RES_CHRATR_BEGIN, RES_CHRATR_END-1, + RES_TXTATR_INETFMT, RES_TXTATR_INETFMT, + RES_TXTATR_CHARFMT, RES_TXTATR_CHARFMT, + RES_TXTATR_CJK_RUBY, RES_TXTATR_CJK_RUBY, + RES_TXTATR_UNKNOWN_CONTAINER, RES_TXTATR_UNKNOWN_CONTAINER, + 0 +}; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if (pUnoCrsr) +static void +lcl_EnumerateIds(USHORT const* pIdRange, SvUShortsSort & rWhichIds) +{ + while (*pIdRange) { - // para specific attribut ranges - USHORT aParaResetableSetRange[] = { - RES_FRMATR_BEGIN, RES_FRMATR_END-1, - RES_PARATR_BEGIN, RES_PARATR_END-1, - // --> OD 2008-02-25 #refactorlists# - RES_PARATR_LIST_BEGIN, RES_PARATR_LIST_END-1, - // <-- - RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1, - 0 - }; - // selection specific attribut ranges - USHORT aResetableSetRange[] = { - RES_CHRATR_BEGIN, RES_CHRATR_END-1, - RES_TXTATR_INETFMT, RES_TXTATR_INETFMT, - RES_TXTATR_CHARFMT, RES_TXTATR_CHARFMT, - RES_TXTATR_CJK_RUBY, RES_TXTATR_CJK_RUBY, - RES_TXTATR_UNKNOWN_CONTAINER, RES_TXTATR_UNKNOWN_CONTAINER, - 0 - }; - SvUShortsSort aParaWhichIds; - SvUShortsSort aWhichIds; - for (USHORT k = 0; k < 2; ++k) + const USHORT nStart = sal::static_int_cast(*pIdRange++); + const USHORT nEnd = sal::static_int_cast(*pIdRange++); + for (USHORT nId = nStart + 1; nId <= nEnd; ++nId) { - SvUShortsSort &rWhichIds = k == 0? aParaWhichIds : aWhichIds; - USHORT *pResetableSetRange = k == 0? aParaResetableSetRange : aResetableSetRange; - while (*pResetableSetRange) - { - USHORT nStart = sal::static_int_cast< USHORT >(*pResetableSetRange++); - USHORT nEnd = sal::static_int_cast< USHORT >(*pResetableSetRange++); - for (USHORT nId = nStart + 1; nId <= nEnd; ++nId) - rWhichIds.Insert( nId ); - } + rWhichIds.Insert( nId ); } - if (aParaWhichIds.Count()) - lcl_SelectParaAndReset( *pUnoCrsr, *pUnoCrsr->GetDoc(), &aParaWhichIds ); - if (aWhichIds.Count() ) - pUnoCrsr->GetDoc()->ResetAttrs( *pUnoCrsr, sal_True, &aWhichIds ); } - else - throw uno::RuntimeException(); } -void SAL_CALL SwXTextCursor::setPropertiesToDefault( const Sequence< OUString >& aPropertyNames ) - throw (UnknownPropertyException, RuntimeException) +void SAL_CALL +SwXTextCursor::setAllPropertiesToDefault() +throw (uno::RuntimeException) +{ + vos::OGuard aGuard(Application::GetSolarMutex()); + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + SvUShortsSort aParaWhichIds; + SvUShortsSort aWhichIds; + lcl_EnumerateIds(g_ParaResetableSetRange, aParaWhichIds); + lcl_EnumerateIds(g_ResetableSetRange, aWhichIds); + if (aParaWhichIds.Count()) + { + lcl_SelectParaAndReset(rUnoCursor, *rUnoCursor.GetDoc(), + &aParaWhichIds); + } + if (aWhichIds.Count()) + { + rUnoCursor.GetDoc()->ResetAttrs(rUnoCursor, sal_True, &aWhichIds); + } +} + +void SAL_CALL +SwXTextCursor::setPropertiesToDefault( + const uno::Sequence< OUString >& rPropertyNames) +throw (beans::UnknownPropertyException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - sal_Int32 nCount = aPropertyNames.getLength(); + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + const sal_Int32 nCount = rPropertyNames.getLength(); if ( nCount ) { - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) + SwDoc & rDoc = *rUnoCursor.GetDoc(); + const OUString * pNames = rPropertyNames.getConstArray(); + SvUShortsSort aWhichIds; + SvUShortsSort aParaWhichIds; + for (sal_Int32 i = 0; i < nCount; i++) { - SwDoc* pDoc = pUnoCrsr->GetDoc(); - const OUString * pNames = aPropertyNames.getConstArray(); - SvUShortsSort aWhichIds, aParaWhichIds; - for ( sal_Int32 i = 0; i < nCount; i++ ) + SfxItemPropertySimpleEntry const*const pEntry = + m_pImpl->m_rPropSet.getPropertyMap()->getByName( pNames[i] ); + if (!pEntry) { - const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName( pNames[i] ); - if(!pEntry) + if (pNames[i].equalsAsciiL( + SW_PROP_NAME(UNO_NAME_IS_SKIP_HIDDEN_TEXT)) || + pNames[i].equalsAsciiL( + SW_PROP_NAME(UNO_NAME_IS_SKIP_PROTECTED_TEXT))) { - if(pNames[i].equalsAsciiL( SW_PROP_NAME(UNO_NAME_IS_SKIP_HIDDEN_TEXT)) || - pNames[i].equalsAsciiL( SW_PROP_NAME(UNO_NAME_IS_SKIP_PROTECTED_TEXT))) - { - continue; - } - else - throw UnknownPropertyException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pNames[i], static_cast < cppu::OWeakObject * > ( 0 ) ); + continue; } - if( pEntry->nFlags & PropertyAttribute::READONLY) - throw RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "setPropertiesToDefault: property is read-only: " ) ) + pNames[i], static_cast < cppu::OWeakObject * > ( this ) ); + throw beans::UnknownPropertyException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) + + pNames[i], + static_cast(this)); + } + if (pEntry->nFlags & beans::PropertyAttribute::READONLY) + { + throw uno::RuntimeException( + OUString(RTL_CONSTASCII_USTRINGPARAM( + "setPropertiesToDefault: property is read-only: ")) + + pNames[i], + static_cast(this)); + } - if( pEntry->nWID < RES_FRMATR_END) + if (pEntry->nWID < RES_FRMATR_END) + { + if (pEntry->nWID < RES_PARATR_BEGIN) { - if(pEntry->nWID < RES_PARATR_BEGIN) - aWhichIds.Insert(pEntry->nWID); - else - aParaWhichIds.Insert (pEntry->nWID); + aWhichIds.Insert(pEntry->nWID); } - else if ( pEntry->nWID == FN_UNO_NUM_START_VALUE ) - SwUnoCursorHelper::resetCrsrPropertyValue(*pEntry, *pUnoCrsr); + else + { + aParaWhichIds.Insert(pEntry->nWID); + } + } + else if (pEntry->nWID == FN_UNO_NUM_START_VALUE) + { + SwUnoCursorHelper::resetCrsrPropertyValue(*pEntry, rUnoCursor); } + } - if ( aParaWhichIds.Count() ) - lcl_SelectParaAndReset ( *pUnoCrsr, *pDoc, &aParaWhichIds ); - if (aWhichIds.Count() ) - pDoc->ResetAttrs(*pUnoCrsr, sal_True, &aWhichIds); + if (aParaWhichIds.Count()) + { + lcl_SelectParaAndReset(rUnoCursor, rDoc, &aParaWhichIds); + } + if (aWhichIds.Count()) + { + rDoc.ResetAttrs(rUnoCursor, sal_True, &aWhichIds); } - else - throw uno::RuntimeException(); } } -Sequence< Any > SAL_CALL SwXTextCursor::getPropertyDefaults( const Sequence< OUString >& aPropertyNames ) - throw (UnknownPropertyException, WrappedTargetException, RuntimeException) + +uno::Sequence< uno::Any > SAL_CALL +SwXTextCursor::getPropertyDefaults( + const uno::Sequence< OUString >& rPropertyNames) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - sal_Int32 nCount = aPropertyNames.getLength(); - Sequence < Any > aRet ( nCount ); + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + const sal_Int32 nCount = rPropertyNames.getLength(); + uno::Sequence< uno::Any > aRet(nCount); if ( nCount ) { - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if (pUnoCrsr) + SwDoc & rDoc = *rUnoCursor.GetDoc(); + const OUString *pNames = rPropertyNames.getConstArray(); + uno::Any *pAny = aRet.getArray(); + for (sal_Int32 i = 0; i < nCount; i++) { - SwDoc* pDoc = pUnoCrsr->GetDoc(); - const OUString *pNames = aPropertyNames.getConstArray(); - Any *pAny = aRet.getArray(); - for ( sal_Int32 i = 0; i < nCount; i++) + SfxItemPropertySimpleEntry const*const pEntry = + m_pImpl->m_rPropSet.getPropertyMap()->getByName( pNames[i] ); + if (!pEntry) { - const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName( pNames[i] ); - if(!pEntry) + if (pNames[i].equalsAsciiL( + SW_PROP_NAME(UNO_NAME_IS_SKIP_HIDDEN_TEXT)) || + pNames[i].equalsAsciiL( + SW_PROP_NAME(UNO_NAME_IS_SKIP_PROTECTED_TEXT))) { - if(pNames[i].equalsAsciiL( SW_PROP_NAME(UNO_NAME_IS_SKIP_HIDDEN_TEXT)) || - pNames[i].equalsAsciiL( SW_PROP_NAME(UNO_NAME_IS_SKIP_PROTECTED_TEXT))) - { - continue; - } - else - throw UnknownPropertyException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pNames[i], static_cast < cppu::OWeakObject * > ( 0 ) ); - } - if(pEntry->nWID < RES_FRMATR_END) - { - const SfxPoolItem& rDefItem = pDoc->GetAttrPool().GetDefaultItem(pEntry->nWID); - rDefItem.QueryValue(pAny[i], pEntry->nMemberId); + continue; } + throw beans::UnknownPropertyException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) + + pNames[i], + static_cast(0)); + } + if (pEntry->nWID < RES_FRMATR_END) + { + const SfxPoolItem& rDefItem = + rDoc.GetAttrPool().GetDefaultItem(pEntry->nWID); + rDefItem.QueryValue(pAny[i], pEntry->nMemberId); } } - else - throw UnknownPropertyException(); } return aRet; } @@ -2681,17 +2695,17 @@ Sequence< Any > SAL_CALL SwXTextCursor::getPropertyDefaults( const Sequence< OUS /*-- 10.03.2008 09:58:47--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextCursor::makeRedline( +void SAL_CALL +SwXTextCursor::makeRedline( const ::rtl::OUString& rRedlineType, - const uno::Sequence< beans::PropertyValue >& rRedlineProperties ) - throw (lang::IllegalArgumentException, uno::RuntimeException) + const uno::Sequence< beans::PropertyValue >& rRedlineProperties) +throw (lang::IllegalArgumentException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) - SwUnoCursorHelper::makeRedline( *pUnoCrsr, rRedlineType, rRedlineProperties ); - else - throw uno::RuntimeException(); + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + SwUnoCursorHelper::makeRedline(rUnoCursor, rRedlineType, rRedlineProperties); } /*-- 09.12.98 14:18:58--------------------------------------------------- @@ -2704,12 +2718,9 @@ throw (lang::IllegalArgumentException, io::IOException, { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if (!pUnoCrsr) - { - throw uno::RuntimeException(); - } - SwUnoCursorHelper::InsertFile(pUnoCrsr, rURL, rOptions); + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + SwUnoCursorHelper::InsertFile(&rUnoCursor, rURL, rOptions); } /* -----------------------------15.12.00 14:01-------------------------------- @@ -3056,46 +3067,41 @@ throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwSortOptions aSortOpt; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - - if (!pUnoCrsr) - { - throw uno::RuntimeException(); - } + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); - if (pUnoCrsr->HasMark()) + if (rUnoCursor.HasMark()) { + SwSortOptions aSortOpt; if (!SwUnoCursorHelper::ConvertSortProperties(rDescriptor, aSortOpt)) { - throw uno::RuntimeException(); + throw uno::RuntimeException(); } - UnoActionContext aContext( pUnoCrsr->GetDoc() ); + UnoActionContext aContext( rUnoCursor.GetDoc() ); - SwPosition* pStart = pUnoCrsr->Start(); - SwPosition* pEnd = pUnoCrsr->End(); + SwPosition & rStart = *rUnoCursor.Start(); + SwPosition & rEnd = *rUnoCursor.End(); - SwNodeIndex aPrevIdx( pStart->nNode, -1 ); - ULONG nOffset = pEnd->nNode.GetIndex() - pStart->nNode.GetIndex(); - xub_StrLen nCntStt = pStart->nContent.GetIndex(); + SwNodeIndex aPrevIdx( rStart.nNode, -1 ); + const ULONG nOffset = rEnd.nNode.GetIndex() - rStart.nNode.GetIndex(); + const xub_StrLen nCntStt = rStart.nContent.GetIndex(); - pUnoCrsr->GetDoc()->SortText(*pUnoCrsr, aSortOpt); + rUnoCursor.GetDoc()->SortText(rUnoCursor, aSortOpt); // Selektion wieder setzen - pUnoCrsr->DeleteMark(); - pUnoCrsr->GetPoint()->nNode.Assign( aPrevIdx.GetNode(), +1 ); - SwCntntNode* pCNd = pUnoCrsr->GetCntntNode(); + rUnoCursor.DeleteMark(); + rUnoCursor.GetPoint()->nNode.Assign( aPrevIdx.GetNode(), +1 ); + SwCntntNode *const pCNd = rUnoCursor.GetCntntNode(); xub_StrLen nLen = pCNd->Len(); if (nLen > nCntStt) { nLen = nCntStt; } - pUnoCrsr->GetPoint()->nContent.Assign(pCNd, nLen ); - pUnoCrsr->SetMark(); + rUnoCursor.GetPoint()->nContent.Assign(pCNd, nLen ); + rUnoCursor.SetMark(); - pUnoCrsr->GetPoint()->nNode += nOffset; - pCNd = pUnoCrsr->GetCntntNode(); - pUnoCrsr->GetPoint()->nContent.Assign( pCNd, pCNd->Len() ); + rUnoCursor.GetPoint()->nNode += nOffset; + SwCntntNode *const pCNd2 = rUnoCursor.GetCntntNode(); + rUnoCursor.GetPoint()->nContent.Assign( pCNd2, pCNd2->Len() ); } } @@ -3106,15 +3112,17 @@ uno::Reference< container::XEnumeration > SAL_CALL SwXTextCursor::createContentEnumeration(const OUString& rServiceName) throw (uno::RuntimeException) { - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if (!pUnoCrsr || - 0 != rServiceName.compareToAscii("com.sun.star.text.TextContent")) + vos::OGuard g(Application::GetSolarMutex()); + + if (!rServiceName.equalsAscii("com.sun.star.text.TextContent")) { throw uno::RuntimeException(); } + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + uno::Reference< container::XEnumeration > xRet = - new SwXParaFrameEnumeration(*pUnoCrsr, PARAFRAME_PORTION_TEXTRANGE); + new SwXParaFrameEnumeration(rUnoCursor, PARAFRAME_PORTION_TEXTRANGE); return xRet; } @@ -3124,18 +3132,16 @@ throw (uno::RuntimeException) uno::Reference< container::XEnumeration > SAL_CALL SwXTextCursor::createEnumeration() throw (uno::RuntimeException) { - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if (!pUnoCrsr) - { - throw uno::RuntimeException(); - } - uno::Reference xTunnel(xParentText, UNO_QUERY); + vos::OGuard g(Application::GetSolarMutex()); + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + const uno::Reference xTunnel( + m_pImpl->m_xParentText, uno::UNO_QUERY); SwXText* pParentText = 0; if (xTunnel.is()) { - pParentText = reinterpret_cast< SwXText *>( - sal::static_int_cast< sal_IntPtr >( - xTunnel->getSomething(SwXText::getUnoTunnelId()) )); + pParentText = ::sw::UnoTunnelGetImplementation(xTunnel); } DBG_ASSERT(pParentText, "parent is not a SwXText"); if (!pParentText) @@ -3144,15 +3150,15 @@ SwXTextCursor::createEnumeration() throw (uno::RuntimeException) } ::std::auto_ptr pNewCrsr( - pUnoCrsr->GetDoc()->CreateUnoCrsr(*pUnoCrsr->GetPoint()) ); - if (pUnoCrsr->HasMark()) + rUnoCursor.GetDoc()->CreateUnoCrsr(*rUnoCursor.GetPoint()) ); + if (rUnoCursor.HasMark()) { pNewCrsr->SetMark(); - *pNewCrsr->GetMark() = *pUnoCrsr->GetMark(); + *pNewCrsr->GetMark() = *rUnoCursor.GetMark(); } - const CursorType eSetType = (CURSOR_TBLTEXT == eType) + const CursorType eSetType = (CURSOR_TBLTEXT == m_pImpl->m_eType) ? CURSOR_SELECTION_IN_TABLE : CURSOR_SELECTION; - const uno::Reference< XEnumeration > xRet = + const uno::Reference< container::XEnumeration > xRet = new SwXParagraphEnumeration(pParentText, pNewCrsr, eSetType); return xRet; @@ -3164,7 +3170,7 @@ SwXTextCursor::createEnumeration() throw (uno::RuntimeException) uno::Type SAL_CALL SwXTextCursor::getElementType() throw (uno::RuntimeException) { - return ::getCppuType((uno::Reference*)0); + return text::XTextRange::static_type(); } /* -----------------------------07.03.01 15:43-------------------------------- diff --git a/sw/source/core/unocore/unoredline.cxx b/sw/source/core/unocore/unoredline.cxx index e1680cabecc2..a75bbd9ecfef 100644 --- a/sw/source/core/unocore/unoredline.cxx +++ b/sw/source/core/unocore/unoredline.cxx @@ -141,9 +141,9 @@ uno::Reference SwXRedlineText::createTextCursor(void) vos::OGuard aGuard(Application::GetSolarMutex()); SwPosition aPos(aNodeIndex); - SwXTextCursor* pCrsr = new SwXTextCursor(this, aPos, CURSOR_REDLINE, - GetDoc()); - SwUnoCrsr* pUnoCursor = pCrsr->GetCrsr(); + SwXTextCursor *const pXCursor = + new SwXTextCursor(*GetDoc(), this, CURSOR_REDLINE, aPos); + SwUnoCrsr *const pUnoCursor = pXCursor->GetCursor(); pUnoCursor->Move(fnMoveForward, fnGoNode); // #101929# prevent a newly created text cursor from running inside a table @@ -175,7 +175,7 @@ uno::Reference SwXRedlineText::createTextCursor(void) throw aExcept; } - return (text::XWordCursor*)pCrsr; + return static_cast(pXCursor); } /* --------------------------------------------------------------------------- @@ -716,8 +716,9 @@ uno::Reference< text::XTextCursor > SwXRedline::createTextCursor(void) throw( u if(pNodeIndex) { SwPosition aPos(*pNodeIndex); - SwXTextCursor* pCrsr = new SwXTextCursor(this, aPos, CURSOR_REDLINE, pDoc); - SwUnoCrsr* pUnoCrsr = pCrsr->GetCrsr(); + SwXTextCursor *const pXCursor = + new SwXTextCursor(*pDoc, this, CURSOR_REDLINE, aPos); + SwUnoCrsr *const pUnoCrsr = pXCursor->GetCursor(); pUnoCrsr->Move(fnMoveForward, fnGoNode); //steht hier eine Tabelle? @@ -731,7 +732,7 @@ uno::Reference< text::XTextCursor > SwXRedline::createTextCursor(void) throw( u } if(pCont) pUnoCrsr->GetPoint()->nContent.Assign(pCont, 0); - xRet = (text::XWordCursor*)pCrsr; + xRet = static_cast(pXCursor); } else { diff --git a/sw/source/core/unocore/unorefmk.cxx b/sw/source/core/unocore/unorefmk.cxx index 6b3ed8e04dd8..f084d1b63dfb 100644 --- a/sw/source/core/unocore/unorefmk.cxx +++ b/sw/source/core/unocore/unorefmk.cxx @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -638,8 +639,8 @@ void SwXMetaText::PrepareForAttach( uno::Reference & xRange, { // create a new cursor to prevent modifying SwXTextRange xRange = static_cast( - new SwXTextCursor(&m_rMeta, *rPam.GetPoint(), CURSOR_META, - GetDoc(), (rPam.HasMark()) ? rPam.GetMark() : 0)); + new SwXTextCursor(*GetDoc(), &m_rMeta, CURSOR_META, *rPam.GetPoint(), + (rPam.HasMark()) ? rPam.GetMark() : 0)); } bool SwXMetaText::CheckForOwnMemberMeta(const SwPaM & rPam, const bool bAbsorb) @@ -663,7 +664,7 @@ throw (uno::RuntimeException) { SwPosition aPos(*pTxtNode, nMetaStart); xRet = static_cast( - new SwXTextCursor(&m_rMeta, aPos, CURSOR_META, GetDoc())); + new SwXTextCursor(*GetDoc(), &m_rMeta, CURSOR_META, aPos)); } } return xRet; diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index b75d9dd93c0c..d0699acd82f4 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -1035,10 +1035,11 @@ uno::Reference< text::XTextCursor > SwXCell::createTextCursor(void) throw( uno: { const SwStartNode* pSttNd = pStartNode ? pStartNode : pBox->GetSttNd(); SwPosition aPos(*pSttNd); - SwXTextCursor* pCrsr = new SwXTextCursor(this, aPos, CURSOR_TBLTEXT, GetDoc()); - SwUnoCrsr* pUnoCrsr = pCrsr->GetCrsr(); + SwXTextCursor *const pXCursor = + new SwXTextCursor(*GetDoc(), this, CURSOR_TBLTEXT, aPos); + SwUnoCrsr *const pUnoCrsr = pXCursor->GetCursor(); pUnoCrsr->Move(fnMoveForward, fnGoNode); - aRef = (text::XWordCursor*)pCrsr; + aRef = static_cast(pXCursor); // // no Cursor in protected sections // SwCrsrSaveState aSave( *pUnoCrsr ); // if(pUnoCrsr->IsInProtectTable( sal_True ) || @@ -1068,7 +1069,11 @@ uno::Reference< text::XTextCursor > SwXCell::createTextCursorByRange(const uno: p1 = p1->StartOfSectionNode(); if( p1 == pSttNd ) - aRef = (text::XWordCursor*)new SwXTextCursor(this , *aPam.GetPoint(), CURSOR_TBLTEXT, GetDoc(), aPam.GetMark()); + { + aRef = static_cast( + new SwXTextCursor(*GetDoc(), this, CURSOR_TBLTEXT, + *aPam.GetPoint(), aPam.GetMark())); + } } else throw uno::RuntimeException(); diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index 72a86050fadf..d84ac7062981 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -116,7 +116,7 @@ uno::Reference< text::XTextCursor > SwXText::createCursor() throw (uno::Runtim SwNode& rNode = GetDoc()->GetNodes().GetEndOfContent(); SwPosition aPos(rNode); xRet = static_cast( - new SwXTextCursor(this, aPos, GetTextType(), GetDoc())); + new SwXTextCursor(*GetDoc(), this, GetTextType(), aPos)); xRet->gotoStart(sal_False); } return xRet; @@ -1437,7 +1437,7 @@ uno::Reference< text::XTextRange > SwXText::appendTextPortion( // SwPaM aPam(*pStartNode->EndOfSectionNode()); //aPam.Move( fnMoveBackward, fnGoNode ); - SwUnoCrsr* pCursor = pTextCursor->GetCrsr(); + SwUnoCrsr * pCursor = pTextCursor->GetCursor(); pCursor->MovePara( fnParaCurr, fnParaEnd ); pDoc->DontExpandFmt( *pCursor->Start() ); @@ -2326,7 +2326,7 @@ SwXTextCursor * SwXBodyText::CreateTextCursor(const bool bIgnoreTables) aPam.GetPoint()->nContent.Assign(pCont, 0); } } - return new SwXTextCursor(this, *aPam.GetPoint(), CURSOR_BODY, GetDoc()); + return new SwXTextCursor(*GetDoc(), this, CURSOR_BODY, *aPam.GetPoint()); } /*-- 10.12.98 11:17:29--------------------------------------------------- @@ -2374,7 +2374,11 @@ uno::Reference< text::XTextCursor > SwXBodyText::createTextCursorByRange( SwStartNode* p2 = rNode.StartOfSectionNode(); if(p1 == p2) - aRef = (text::XWordCursor*)new SwXTextCursor(this , *aPam.GetPoint(), CURSOR_BODY, GetDoc(), aPam.GetMark()); + { + aRef = static_cast( + new SwXTextCursor(*GetDoc(), this, CURSOR_BODY, + *aPam.GetPoint(), aPam.GetMark())); + } } if(!aRef.is()) throw uno::RuntimeException(); @@ -2554,8 +2558,9 @@ uno::Reference< text::XTextCursor > SwXHeadFootText::createTextCursor(void) thr const SwFmtCntnt& rFlyCntnt = pHeadFootFmt->GetCntnt(); const SwNode& rNode = rFlyCntnt.GetCntntIdx()->GetNode(); SwPosition aPos(rNode); - SwXTextCursor* pCrsr = new SwXTextCursor(this, aPos, bIsHeader ? CURSOR_HEADER : CURSOR_FOOTER, GetDoc()); - SwUnoCrsr* pUnoCrsr = pCrsr->GetCrsr(); + SwXTextCursor *const pXCursor = new SwXTextCursor(*GetDoc(), this, + (bIsHeader) ? CURSOR_HEADER : CURSOR_FOOTER, aPos); + SwUnoCrsr *const pUnoCrsr = pXCursor->GetCursor(); pUnoCrsr->Move(fnMoveForward, fnGoNode); //save current start node to be able to check if there is content after the table - @@ -2578,12 +2583,11 @@ uno::Reference< text::XTextCursor > SwXHeadFootText::createTextCursor(void) thr bIsHeader ? SwHeaderStartNode : SwFooterStartNode); if(!pNewStartNode || pNewStartNode != pOwnStartNode) { - pCrsr = NULL; uno::RuntimeException aExcept; aExcept.Message = S2U("no text available"); throw aExcept; } - xRet = (text::XWordCursor*)pCrsr; + xRet = static_cast(pXCursor); } else { @@ -2614,8 +2618,12 @@ uno::Reference< text::XTextCursor > SwXHeadFootText::createTextCursorByRange( SwStartNode* p1 = aPam.GetNode()->FindSttNodeByType( bIsHeader ? SwHeaderStartNode : SwFooterStartNode); if(p1 == pOwnStartNode) - xRet = (text::XWordCursor*)new SwXTextCursor(this, *aPam.GetPoint(), - bIsHeader ? CURSOR_HEADER : CURSOR_FOOTER, GetDoc(), aPam.GetMark()); + { + xRet = static_cast( + new SwXTextCursor(*GetDoc(), this, + (bIsHeader) ? CURSOR_HEADER : CURSOR_FOOTER, + *aPam.GetPoint(), aPam.GetMark())); + } } return xRet; } diff --git a/sw/source/filter/xml/XMLRedlineImportHelper.cxx b/sw/source/filter/xml/XMLRedlineImportHelper.cxx index bd1dea07179e..480cc3810e21 100644 --- a/sw/source/filter/xml/XMLRedlineImportHelper.cxx +++ b/sw/source/filter/xml/XMLRedlineImportHelper.cxx @@ -500,11 +500,11 @@ Reference XMLRedlineImportHelper::CreateRedlineTextSection( // create (UNO-) cursor SwPosition aPos(*pRedlineNode); - SwXTextCursor* pCursor = - new SwXTextCursor(pXText, aPos, CURSOR_REDLINE, pDoc); - pCursor->GetCrsr()->Move(fnMoveForward, fnGoNode); - - xReturn = (XWordCursor*)pCursor; // cast to avoid ambigiouty + SwXTextCursor *const pXCursor = + new SwXTextCursor(*pDoc, pXText, CURSOR_REDLINE, aPos); + pXCursor->GetCursor()->Move(fnMoveForward, fnGoNode); + // cast to avoid ambiguity + xReturn = static_cast(pXCursor); } // else: unknown redline -> Ignore diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index 374ee9ab0133..cc959988a767 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -733,7 +733,7 @@ SwUnoCrsr* SwXTextDocument::CreateCursorForSearch(Reference< XTextCursor > & xC SwXTextCursor *const pXTextCursor = pBText->CreateTextCursor(true); xCrsr.set( static_cast(pXTextCursor) ); - SwUnoCrsr *const pUnoCrsr = pXTextCursor->GetCrsr(); + SwUnoCrsr *const pUnoCrsr = pXTextCursor->GetCursor(); pUnoCrsr->SetRemainInSection(sal_False); return pUnoCrsr; } @@ -987,7 +987,7 @@ Reference< XInterface > SwXTextDocument::findFirst(const Reference< util::XSear const uno::Reference< text::XText > xParent = ::sw::CreateParentXText(*pDocShell->GetDoc(), *pResultCrsr->GetPoint()); - xRet = *new SwXTextCursor(xParent, pResultCrsr); + xRet = *new SwXTextCursor(xParent, *pResultCrsr); delete pResultCrsr; } return xRet; @@ -1015,7 +1015,7 @@ Reference< XInterface > SwXTextDocument::findNext(const Reference< XInterface > ::sw::CreateParentXText(*pDocShell->GetDoc(), *pResultCrsr->GetPoint()); - xRet = *new SwXTextCursor(xParent, pResultCrsr); + xRet = *new SwXTextCursor(xParent, *pResultCrsr); delete pResultCrsr; } return xRet; -- cgit From 817e682f25904005a810839d32a881df6760b8b6 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 8 Jan 2010 17:13:56 +0100 Subject: swunolocking1: #i105557#: fix locking for SwXText: add Impl struct, and use UnoImplPtr to lock destructor. move all implementation details out of header, into Impl struct. use new XUnoTunnel and XServiceInfo helpers. clean up the implementation a little. --- sw/inc/unofootnote.hxx | 2 +- sw/inc/unoframe.hxx | 8 +- sw/inc/unotbl.hxx | 10 +- sw/inc/unotext.hxx | 63 +- sw/inc/unotextbodyhf.hxx | 2 +- sw/source/core/unocore/unoframe.cxx | 3 +- sw/source/core/unocore/unoftn.cxx | 3 +- sw/source/core/unocore/unoobj2.cxx | 2 +- sw/source/core/unocore/unorefmk.cxx | 11 +- sw/source/core/unocore/unotbl.cxx | 21 +- sw/source/core/unocore/unotext.cxx | 2127 ++++++++++++++++++----------------- 11 files changed, 1154 insertions(+), 1098 deletions(-) (limited to 'sw') diff --git a/sw/inc/unofootnote.hxx b/sw/inc/unofootnote.hxx index d1c869404d32..8710f7effa03 100644 --- a/sw/inc/unofootnote.hxx +++ b/sw/inc/unofootnote.hxx @@ -85,7 +85,7 @@ protected: virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > - createCursor() + CreateCursor() throw (::com::sun::star::uno::RuntimeException); virtual ~SwXFootnote(); diff --git a/sw/inc/unoframe.hxx b/sw/inc/unoframe.hxx index d681e520d028..0aaaebbe7338 100644 --- a/sw/inc/unoframe.hxx +++ b/sw/inc/unoframe.hxx @@ -186,12 +186,18 @@ class SwXTextFrame : public SwXTextFrameBaseClass, protected: virtual const SwStartNode *GetStartNode() const; - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > createCursor()throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextCursor > + CreateCursor() + throw (::com::sun::star::uno::RuntimeException); + virtual ~SwXTextFrame(); public: SwXTextFrame(SwDoc *pDoc); SwXTextFrame(SwFrmFmt& rFmt); + // FIXME: EVIL HACK: make available for SwXFrame::attachToRange + void SetDoc(SwDoc *const pDoc) { SwXText::SetDoc(pDoc); }; virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw(::com::sun::star::uno::RuntimeException); virtual void SAL_CALL acquire( ) throw(); diff --git a/sw/inc/unotbl.hxx b/sw/inc/unotbl.hxx index a539c7384a39..d6daa705b739 100644 --- a/sw/inc/unotbl.hxx +++ b/sw/inc/unotbl.hxx @@ -106,13 +106,15 @@ class SwXCell : public SwXCellBaseClass, // table position where pBox was found last sal_uInt16 nFndPos; - using SwXText::IsValid; - protected: virtual const SwStartNode *GetStartNode() const; - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > createCursor()throw(::com::sun::star::uno::RuntimeException); - sal_Bool IsValid(); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextCursor > + CreateCursor() + throw (::com::sun::star::uno::RuntimeException); + + bool IsValid() const; virtual ~SwXCell(); diff --git a/sw/inc/unotext.hxx b/sw/inc/unotext.hxx index 97a45ece73cf..3c805da5127c 100644 --- a/sw/inc/unotext.hxx +++ b/sw/inc/unotext.hxx @@ -40,8 +40,6 @@ #include #include -#include - #include @@ -75,28 +73,24 @@ class SwXText private: - SwDoc* pDoc; - BOOL bObjectValid; - CursorType eCrsrType; - const SfxItemPropertySet* m_pPropSet; - - virtual ::com::sun::star::uno::Reference< - ::com::sun::star::text::XTextRange > SAL_CALL - finishOrAppendParagraph( - bool bFinish, - const ::com::sun::star::uno::Sequence< - ::com::sun::star::beans::PropertyValue >& - rCharacterAndParagraphProperties) - throw (::com::sun::star::lang::IllegalArgumentException, - ::com::sun::star::uno::RuntimeException); + class Impl; + ::sw::UnoImplPtr m_pImpl; virtual void PrepareForAttach( ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xRange, SwPaM const & rPam); + virtual bool CheckForOwnMemberMeta( + const SwPaM & rPam, const bool bAbsorb) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); protected: + bool IsValid() const; + void Invalidate(); + void SetDoc(SwDoc *const pDoc); + virtual ~SwXText(); public: /*not protected because C++ is retarded*/ @@ -104,41 +98,16 @@ public: /*not protected because C++ is retarded*/ public: - SwXText(SwDoc* pDc, CursorType eType); + SwXText(SwDoc *const pDoc, const enum CursorType eType); - const SwDoc* GetDoc() const { return pDoc; } - SwDoc* GetDoc() { return pDoc; } - - // SwDoc is set when SwXText is attached - void SetDoc(SwDoc* pDc) { - DBG_ASSERT(!pDoc || !pDc, "Doc schon gesetzt?"); - pDoc = pDc; - bObjectValid = 0 != pDc; - } - - void Invalidate() { bObjectValid = sal_False; } - BOOL IsValid() const { return bObjectValid; } - - CursorType GetTextType() { return eCrsrType; } + const SwDoc* GetDoc() const; + SwDoc* GetDoc(); virtual ::com::sun::star::uno::Reference< - ::com::sun::star::text::XTextCursor > createCursor() + ::com::sun::star::text::XTextCursor > + CreateCursor() throw (::com::sun::star::uno::RuntimeException); - INT16 ComparePositions( - const ::com::sun::star::uno::Reference< - ::com::sun::star::text::XTextRange>& xPos1, - const ::com::sun::star::uno::Reference< - ::com::sun::star::text::XTextRange>& xPos2) - throw (::com::sun::star::lang::IllegalArgumentException, - ::com::sun::star::uno::RuntimeException); - BOOL CheckForOwnMember(const SwXTextRange* pRange1, - const OTextCursorHelper* pCursor1) - throw (::com::sun::star::lang::IllegalArgumentException, - ::com::sun::star::uno::RuntimeException); - virtual bool CheckForOwnMemberMeta( - const SwPaM & rPam, const bool bAbsorb) - throw (::com::sun::star::lang::IllegalArgumentException, - ::com::sun::star::uno::RuntimeException); + // XInterface virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( diff --git a/sw/inc/unotextbodyhf.hxx b/sw/inc/unotextbodyhf.hxx index baab8bc15845..98656ca68c29 100644 --- a/sw/inc/unotextbodyhf.hxx +++ b/sw/inc/unotextbodyhf.hxx @@ -149,7 +149,7 @@ protected: virtual const SwStartNode *GetStartNode() const; virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > - createCursor() + CreateCursor() throw (::com::sun::star::uno::RuntimeException); virtual ~SwXHeadFootText(); diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx index c9e9771a3bae..5c5c10d1b80f 100644 --- a/sw/source/core/unocore/unoframe.cxx +++ b/sw/source/core/unocore/unoframe.cxx @@ -2611,7 +2611,8 @@ const SwStartNode *SwXTextFrame::GetStartNode() const return pSttNd; } -uno::Reference< text::XTextCursor > SwXTextFrame::createCursor() throw ( uno::RuntimeException) +uno::Reference< text::XTextCursor > +SwXTextFrame::CreateCursor() throw (uno::RuntimeException) { return createTextCursor(); } diff --git a/sw/source/core/unocore/unoftn.cxx b/sw/source/core/unocore/unoftn.cxx index e98238967a11..3d3937f56524 100644 --- a/sw/source/core/unocore/unoftn.cxx +++ b/sw/source/core/unocore/unoftn.cxx @@ -375,7 +375,8 @@ const SwStartNode *SwXFootnote::GetStartNode() const return pSttNd; } -uno::Reference< text::XTextCursor > SwXFootnote::createCursor() throw ( uno::RuntimeException) +uno::Reference< text::XTextCursor > +SwXFootnote::CreateCursor() throw (uno::RuntimeException) { return createTextCursor(); } diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index 84d276e6618e..857638d872dc 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -1164,7 +1164,7 @@ bool XTextRangeToSwPaM( SwUnoInternalPaM & rToFill, if(pText) { const uno::Reference< text::XTextCursor > xTextCursor = - pText->createCursor(); + pText->CreateCursor(); xTextCursor->gotoEnd(sal_True); const uno::Reference xCrsrTunnel( xTextCursor, uno::UNO_QUERY); diff --git a/sw/source/core/unocore/unorefmk.cxx b/sw/source/core/unocore/unorefmk.cxx index f084d1b63dfb..7acabb196e22 100644 --- a/sw/source/core/unocore/unorefmk.cxx +++ b/sw/source/core/unocore/unorefmk.cxx @@ -594,11 +594,14 @@ private: protected: virtual const SwStartNode *GetStartNode() const; virtual uno::Reference< text::XTextCursor > - createCursor() throw (uno::RuntimeException); + CreateCursor() throw (uno::RuntimeException); public: SwXMetaText(SwDoc & rDoc, SwXMeta & rMeta); + /// make available for SwXMeta + void Invalidate() { SwXText::Invalidate(); }; + // XInterface virtual void SAL_CALL acquire() throw() { OSL_ENSURE(false, "ERROR: SwXMetaText::acquire"); } @@ -649,7 +652,7 @@ bool SwXMetaText::CheckForOwnMemberMeta(const SwPaM & rPam, const bool bAbsorb) return m_rMeta.CheckForOwnMemberMeta(rPam, bAbsorb); } -uno::Reference< text::XTextCursor > SwXMetaText::createCursor() +uno::Reference< text::XTextCursor > SwXMetaText::CreateCursor() throw (uno::RuntimeException) { uno::Reference< text::XTextCursor > xRet; @@ -680,7 +683,7 @@ SwXMetaText::getImplementationId() throw (uno::RuntimeException) uno::Reference< text::XTextCursor > SAL_CALL SwXMetaText::createTextCursor() throw (uno::RuntimeException) { - return createCursor(); + return CreateCursor(); } uno::Reference< text::XTextCursor > SAL_CALL @@ -688,7 +691,7 @@ SwXMetaText::createTextCursorByRange( const uno::Reference & xTextPosition) throw (uno::RuntimeException) { - const uno::Reference xCursor( createCursor() ); + const uno::Reference xCursor( CreateCursor() ); xCursor->gotoRange(xTextPosition, sal_False); return xCursor; } diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index d0699acd82f4..e17ba707c1a8 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -893,25 +893,32 @@ const SwStartNode *SwXCell::GetStartNode() const return pSttNd; } -uno::Reference< text::XTextCursor > SwXCell::createCursor() throw (uno::RuntimeException) +uno::Reference< text::XTextCursor > +SwXCell::CreateCursor() throw (uno::RuntimeException) { return createTextCursor(); } /*-- 11.12.98 10:56:24--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXCell::IsValid() +bool SwXCell::IsValid() const { + // FIXME: this is now a const method, to make SwXText::IsValid invisible + // but the const_cast here are still ridiculous. TODO: find a better way. SwFrmFmt* pTblFmt = pBox ? GetFrmFmt() : 0; if(!pTblFmt) - pBox = 0; + { + const_cast(this)->pBox = 0; + } else { SwTable* pTable = SwTable::FindTable( pTblFmt ); - const SwTableBox* pFoundBox ; - pFoundBox = FindBox(pTable, pBox); - if(!pFoundBox) - pBox = 0; + SwTableBox const*const pFoundBox = + const_cast(this)->FindBox(pTable, pBox); + if (!pFoundBox) + { + const_cast(this)->pBox = 0; + } } return 0 != pBox; } diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index d84ac7062981..c45f8772a217 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -84,13 +84,92 @@ using ::rtl::OUString; const sal_Char cInvalidObject[] = "this object is invalid"; + /****************************************************************** * SwXText ******************************************************************/ + +class SwXText::Impl +{ + +public: + SwXText & m_rThis; + SfxItemPropertySet const& m_rPropSet; + const enum CursorType m_eType; + SwDoc * m_pDoc; + bool m_bIsValid; + + Impl( SwXText & rThis, + SwDoc *const pDoc, const enum CursorType eType) + : m_rThis(rThis) + , m_rPropSet(*aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT)) + , m_eType(eType) + , m_pDoc(pDoc) + , m_bIsValid(0 != pDoc) + { + } + + uno::Reference< text::XTextRange > + finishOrAppendParagraph( + const bool bFinish, + const uno::Sequence< beans::PropertyValue >& + rCharacterAndParagraphProperties) + throw (lang::IllegalArgumentException, uno::RuntimeException); + + sal_Int16 ComparePositions( + const uno::Reference& xPos1, + const uno::Reference& xPos2) + throw (lang::IllegalArgumentException, uno::RuntimeException); + + bool CheckForOwnMember(const SwPaM & rPaM) + throw (lang::IllegalArgumentException, uno::RuntimeException); +}; + +/* -----------------------------15.03.2002 12:39------------------------------ + + ---------------------------------------------------------------------------*/ +SwXText::SwXText(SwDoc *const pDoc, const enum CursorType eType) + : m_pImpl( new SwXText::Impl(*this, pDoc, eType) ) +{ +} +/*-- 09.12.98 12:43:55--------------------------------------------------- + + -----------------------------------------------------------------------*/ +SwXText::~SwXText() +{ +} + /*-- 09.12.98 12:44:07--------------------------------------------------- -----------------------------------------------------------------------*/ +const SwDoc * SwXText::GetDoc() const +{ + return m_pImpl->m_pDoc; +} + SwDoc * SwXText::GetDoc() +{ + return m_pImpl->m_pDoc; +} + +bool SwXText::IsValid() const +{ + return m_pImpl->m_bIsValid; +} + +void SwXText::Invalidate() +{ + m_pImpl->m_bIsValid = false; +} + +void SwXText::SetDoc(SwDoc *const pDoc) +{ + OSL_ENSURE(!m_pImpl->m_pDoc || !pDoc, + "SwXText::SetDoc: already have a doc?"); + m_pImpl->m_pDoc = pDoc; + m_pImpl->m_bIsValid = (0 != pDoc); +} + void SwXText::PrepareForAttach(uno::Reference< text::XTextRange > &, const SwPaM &) { @@ -99,7 +178,7 @@ SwXText::PrepareForAttach(uno::Reference< text::XTextRange > &, const SwPaM &) bool SwXText::CheckForOwnMemberMeta(const SwPaM &, const bool) throw (lang::IllegalArgumentException, uno::RuntimeException) { - ASSERT(CURSOR_META != eCrsrType, "should not be called!"); + ASSERT(CURSOR_META != m_pImpl->m_eType, "should not be called!"); return false; } @@ -108,7 +187,8 @@ const SwStartNode *SwXText::GetStartNode() const return GetDoc()->GetNodes().GetEndOfContent().StartOfSectionNode(); } -uno::Reference< text::XTextCursor > SwXText::createCursor() throw (uno::RuntimeException) +uno::Reference< text::XTextCursor > +SwXText::CreateCursor() throw (uno::RuntimeException) { uno::Reference< text::XTextCursor > xRet; if(IsValid()) @@ -116,525 +196,457 @@ uno::Reference< text::XTextCursor > SwXText::createCursor() throw (uno::Runtim SwNode& rNode = GetDoc()->GetNodes().GetEndOfContent(); SwPosition aPos(rNode); xRet = static_cast( - new SwXTextCursor(*GetDoc(), this, GetTextType(), aPos)); + new SwXTextCursor(*GetDoc(), this, m_pImpl->m_eType, aPos)); xRet->gotoStart(sal_False); } return xRet; } -/* -----------------------------15.03.2002 12:39------------------------------ - - ---------------------------------------------------------------------------*/ -SwXText::SwXText(SwDoc* pDc, CursorType eType) : - pDoc(pDc), - bObjectValid(0 != pDc), - eCrsrType(eType), - m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT)) -{ -} -/*-- 09.12.98 12:43:55--------------------------------------------------- - -----------------------------------------------------------------------*/ -SwXText::~SwXText() -{ -} /*-- 09.12.98 12:43:02--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Any SAL_CALL SwXText::queryInterface( const uno::Type& rType ) throw(uno::RuntimeException) -{ - const uno::Type& rXTextType = ::getCppuType((uno::Reference< text::XText >*)0); - const uno::Type& rXTextRangeCompareType = ::getCppuType((uno::Reference< text::XTextRangeCompare >*)0); - const uno::Type& rXSimpleTextType = ::getCppuType((const uno::Reference< XSimpleText >*)0); - const uno::Type& rXTextRangeType = ::getCppuType((uno::Reference< text::XTextRange >*)0); - const uno::Type& rXTypeProviderType = ::getCppuType((uno::Reference< lang::XTypeProvider >*)0); - const uno::Type& rXTextContentInsert = ::getCppuType((uno::Reference< text::XRelativeTextContentInsert >*)0); - const uno::Type& rXTextContentRemove = ::getCppuType((uno::Reference< text::XRelativeTextContentRemove >*)0); - const uno::Type& rXPropertySet = ::getCppuType((uno::Reference*)0); - const uno::Type& rXUnoTunnel = ::getCppuType((uno::Reference< lang::XUnoTunnel >*)0); - const uno::Type& rXTextPortionAppend = ::getCppuType((uno::Reference< text::XTextPortionAppend >*)0); - const uno::Type& rXParagraphAppend = ::getCppuType((uno::Reference< text::XParagraphAppend >*)0); - const uno::Type& rXTextContentAppend = ::getCppuType((uno::Reference< text::XTextContentAppend >*)0); - const uno::Type& rXTextConvert = ::getCppuType((uno::Reference< text::XTextConvert >*)0); - const uno::Type& rXTextAppend = ::getCppuType((uno::Reference< text::XTextAppend >*)0); - const uno::Type& rXTextAppendAndConvert = ::getCppuType((uno::Reference< text::XTextAppendAndConvert >*)0); - +uno::Any SAL_CALL +SwXText::queryInterface(const uno::Type& rType) throw (uno::RuntimeException) +{ uno::Any aRet; - if(rType == rXTextType) + if (rType == text::XText::static_type()) { - uno::Reference< text::XText > xRet = this; - aRet.setValue(&xRet, rXTextType); + aRet <<= uno::Reference< text::XText >(this); } - else if(rType == rXSimpleTextType) + else if (rType == text::XSimpleText::static_type()) { - uno::Reference< XSimpleText > xRet = this; - aRet.setValue(&xRet, rXSimpleTextType); + aRet <<= uno::Reference< text::XSimpleText >(this); } - else if(rType == rXTextRangeType) + else if (rType == text::XTextRange::static_type()) { - uno::Reference< text::XTextRange > xRet = this; - aRet.setValue(&xRet, rXTextRangeType); + aRet <<= uno::Reference< text::XTextRange>(this); } - else if(rType == rXTextRangeCompareType) + else if (rType == text::XTextRangeCompare::static_type()) { - uno::Reference< text::XTextRangeCompare > xRet = this; - aRet.setValue(&xRet, rXTextRangeCompareType); + aRet <<= uno::Reference< text::XTextRangeCompare >(this); } - else if(rType == rXTypeProviderType) + else if (rType == lang::XTypeProvider::static_type()) { - uno::Reference< lang::XTypeProvider > xRet = this; - aRet.setValue(&xRet, rXTypeProviderType); + aRet <<= uno::Reference< lang::XTypeProvider >(this); } - else if(rType == rXTextContentInsert) + else if (rType == text::XRelativeTextContentInsert::static_type()) { - uno::Reference< text::XRelativeTextContentInsert > xRet = this; - aRet.setValue(&xRet, rXTextContentInsert); + aRet <<= uno::Reference< text::XRelativeTextContentInsert >(this); } - else if(rType == rXTextContentRemove) + else if (rType == text::XRelativeTextContentRemove::static_type()) { - uno::Reference< text::XRelativeTextContentRemove > xRet = this; - aRet.setValue(&xRet, rXTextContentRemove); + aRet <<= uno::Reference< text::XRelativeTextContentRemove >(this); } - else if(rType == rXPropertySet) + else if (rType == beans::XPropertySet::static_type()) { - uno::Reference< beans::XPropertySet > xRet = this; - aRet.setValue(&xRet, rXPropertySet); + aRet <<= uno::Reference< beans::XPropertySet >(this); } - else if(rType == rXUnoTunnel ) + else if (rType == lang::XUnoTunnel::static_type()) { - uno::Reference< lang::XUnoTunnel > xRet = this; - aRet.setValue(&xRet, rXUnoTunnel); + aRet <<= uno::Reference< lang::XUnoTunnel >(this); } - else if(rType == rXTextAppendAndConvert ) + else if (rType == text::XTextAppendAndConvert::static_type()) { - uno::Reference< XTextAppendAndConvert > xRet = this; - aRet.setValue(&xRet, rXTextAppendAndConvert); + aRet <<= uno::Reference< text::XTextAppendAndConvert >(this); } - else if(rType == rXTextAppend ) + else if (rType == text::XTextAppend::static_type()) { - uno::Reference< XTextAppend > xRet = this; - aRet.setValue(&xRet, rXTextAppend); + aRet <<= uno::Reference< text::XTextAppend >(this); } - else if(rType == rXTextPortionAppend ) + else if (rType == text::XTextPortionAppend::static_type()) { - uno::Reference< XTextPortionAppend > xRet = this; - aRet.setValue(&xRet, rXTextPortionAppend); + aRet <<= uno::Reference< text::XTextPortionAppend >(this); } - else if(rType == rXParagraphAppend ) + else if (rType == text::XParagraphAppend::static_type()) { - uno::Reference< XParagraphAppend > xRet = this; - aRet.setValue(&xRet, rXParagraphAppend ); + aRet <<= uno::Reference< text::XParagraphAppend >(this); } - else if(rType == rXTextConvert ) + else if (rType == text::XTextConvert::static_type() ) { - uno::Reference< XTextConvert > xRet = this; - aRet.setValue(&xRet, rXParagraphAppend ); + aRet <<= uno::Reference< text::XTextConvert >(this); } - else if(rType == rXTextContentAppend ) + else if (rType == text::XTextContentAppend::static_type()) { - uno::Reference< XTextContentAppend > xRet = this; - aRet.setValue(&xRet, rXTextContentAppend ); + aRet <<= uno::Reference< text::XTextContentAppend >(this); } return aRet; } /* -----------------------------15.03.00 17:42-------------------------------- ---------------------------------------------------------------------------*/ -uno::Sequence< uno::Type > SAL_CALL SwXText::getTypes() throw(uno::RuntimeException) +uno::Sequence< uno::Type > SAL_CALL +SwXText::getTypes() throw (uno::RuntimeException) { uno::Sequence< uno::Type > aRet(12); uno::Type* pTypes = aRet.getArray(); - pTypes[0] = ::getCppuType((uno::Reference< text::XText >*)0); - pTypes[1] = ::getCppuType((uno::Reference< text::XTextRangeCompare >*)0); - pTypes[2] = ::getCppuType((uno::Reference< text::XRelativeTextContentInsert >*)0); - pTypes[3] = ::getCppuType((uno::Reference< text::XRelativeTextContentRemove >*)0); - pTypes[4] = ::getCppuType((uno::Reference< lang::XUnoTunnel >*)0); - pTypes[5] = ::getCppuType((uno::Reference< beans::XPropertySet >*)0); - pTypes[6] = ::getCppuType((uno::Reference< text::XTextPortionAppend >*)0); - pTypes[7] = ::getCppuType((uno::Reference< text::XParagraphAppend >*)0); - pTypes[8] = ::getCppuType((uno::Reference< text::XTextContentAppend >*)0); - pTypes[9] = ::getCppuType((uno::Reference< text::XTextConvert >*)0); - pTypes[10] = ::getCppuType((uno::Reference< text::XTextAppend >*)0); - pTypes[11] = ::getCppuType((uno::Reference< text::XTextAppendAndConvert >*)0); + pTypes[0] = text::XText::static_type(); + pTypes[1] = text::XTextRangeCompare::static_type(); + pTypes[2] = text::XRelativeTextContentInsert::static_type(); + pTypes[3] = text::XRelativeTextContentRemove::static_type(); + pTypes[4] = lang::XUnoTunnel::static_type(); + pTypes[5] = beans::XPropertySet::static_type(); + pTypes[6] = text::XTextPortionAppend::static_type(); + pTypes[7] = text::XParagraphAppend::static_type(); + pTypes[8] = text::XTextContentAppend::static_type(); + pTypes[9] = text::XTextConvert::static_type(); + pTypes[10] = text::XTextAppend::static_type(); + pTypes[11] = text::XTextAppendAndConvert::static_type(); return aRet; } // belongs the range in the text ? insert it then. -void SwXText::insertString(const uno::Reference< text::XTextRange >& xTextRange, - const OUString& aString, - sal_Bool bAbsorb) - throw( uno::RuntimeException ) +void SAL_CALL +SwXText::insertString(const uno::Reference< text::XTextRange >& xTextRange, + const OUString& rString, sal_Bool bAbsorb) +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(GetDoc() && xTextRange.is()) + + if (!xTextRange.is()) { - uno::Reference xRangeTunnel( xTextRange, uno::UNO_QUERY); - SwXTextRange* pRange = 0; - OTextCursorHelper* pCursor = 0; - if(xRangeTunnel.is()) + throw uno::RuntimeException(); + } + if (!GetDoc()) + { + throw uno::RuntimeException(); + } + const uno::Reference xRangeTunnel(xTextRange, + uno::UNO_QUERY); + SwXTextRange *const pRange = + ::sw::UnoTunnelGetImplementation(xRangeTunnel); + OTextCursorHelper *const pCursor = + ::sw::UnoTunnelGetImplementation(xRangeTunnel); + if ((!pRange || pRange ->GetDoc() != GetDoc()) && + (!pCursor || pCursor->GetDoc() != GetDoc())) + { + throw uno::RuntimeException(); + } + + const SwStartNode *const pOwnStartNode = GetStartNode(); + SwPaM aPam(GetDoc()->GetNodes()); + const SwPaM * pPam(0); + if (pCursor) + { + pPam = pCursor->GetPaM(); + } + else // pRange + { + if (pRange->GetPositions(aPam)) { - pRange = reinterpret_cast< SwXTextRange * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXTextRange::getUnoTunnelId()) )); - pCursor = reinterpret_cast< OTextCursorHelper * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( OTextCursorHelper::getUnoTunnelId()) )); + pPam = &aPam; } + } + if (!pPam) + { + throw uno::RuntimeException(); + } - if(pRange && pRange->GetDoc() == GetDoc() || - pCursor && pCursor->GetDoc() == GetDoc()) - { - const SwStartNode *const pOwnStartNode = GetStartNode(); - SwPaM aPam(GetDoc()->GetNodes()); - const SwPaM * pPam(0); - if (pCursor) - { - pPam = pCursor->GetPaM(); - } - else // pRange - { - if (pRange->GetPositions(aPam)) - { - pPam = &aPam; - } - } - if (!pPam) - { - throw uno::RuntimeException(); - } - else - { - const SwStartNode* pTmp(pPam->GetNode()->StartOfSectionNode()); - while (pTmp && pTmp->IsSectionNode()) - { - pTmp = pTmp->StartOfSectionNode(); - } - if (!pOwnStartNode || (pOwnStartNode != pTmp)) - { - throw uno::RuntimeException(); - } - } + const SwStartNode* pTmp(pPam->GetNode()->StartOfSectionNode()); + while (pTmp && pTmp->IsSectionNode()) + { + pTmp = pTmp->StartOfSectionNode(); + } + if (!pOwnStartNode || (pOwnStartNode != pTmp)) + { + throw uno::RuntimeException(); + } - bool bForceExpandHints( false ); - if (CURSOR_META == eCrsrType) - { - try - { - bForceExpandHints = CheckForOwnMemberMeta(*pPam, bAbsorb); - } - catch (lang::IllegalArgumentException & iae) - { - // stupid method not allowed to throw iae - throw uno::RuntimeException(iae.Message, 0); - } - } - if(bAbsorb) + bool bForceExpandHints( false ); + if (CURSOR_META == m_pImpl->m_eType) + { + try + { + bForceExpandHints = CheckForOwnMemberMeta(*pPam, bAbsorb); + } + catch (lang::IllegalArgumentException & iae) + { + // stupid method not allowed to throw iae + throw uno::RuntimeException(iae.Message, 0); + } + } + if (bAbsorb) + { + //!! scan for CR characters and inserting the paragraph breaks + //!! has to be done in the called function. + //!! Implemented in SwXTextRange::DeleteAndInsert + if (pCursor) + { + SwXTextCursor * const pTextCursor( + dynamic_cast(pCursor) ); + if (pTextCursor) { - //!! scan for CR characters and inserting the paragraph breaks - //!! has to be done in the called function. - //!! Implemented in SwXTextRange::DeleteAndInsert - if (pCursor) - { - SwXTextCursor * const pTextCursor( dynamic_cast(pCursor) ); - if (pTextCursor) - { - pTextCursor->DeleteAndInsert(aString, bForceExpandHints); - } - else - { - xTextRange->setString(aString); - } - } - else - { - pRange->DeleteAndInsert(aString, bForceExpandHints); - } + pTextCursor->DeleteAndInsert(rString, bForceExpandHints); } else { - //hier wird ein PaM angelegt, der vor dem Parameter-PaM liegt, damit der - //Text davor eingefuegt wird - UnoActionContext aContext(GetDoc()); - SwPaM aInsertPam(*pPam->Start()); - const sal_Bool bGroupUndo = GetDoc()->DoesGroupUndo(); - GetDoc()->DoGroupUndo(sal_False); - - SwUnoCursorHelper::DocInsertStringSplitCR( - *GetDoc(), aInsertPam, aString, bForceExpandHints ); - GetDoc()->DoGroupUndo(bGroupUndo); + xTextRange->setString(rString); } } else - throw uno::RuntimeException(); + { + pRange->DeleteAndInsert(rString, bForceExpandHints); + } } else - throw uno::RuntimeException(); + { + // create a PaM positioned before the parameter PaM, + // so the text is inserted before + UnoActionContext aContext(GetDoc()); + SwPaM aInsertPam(*pPam->Start()); + const sal_Bool bGroupUndo = GetDoc()->DoesGroupUndo(); + GetDoc()->DoGroupUndo(sal_False); + + SwUnoCursorHelper::DocInsertStringSplitCR( + *GetDoc(), aInsertPam, rString, bForceExpandHints ); + GetDoc()->DoGroupUndo(bGroupUndo); + } } /*-- 09.12.98 12:43:16--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXText::insertControlCharacter(const uno::Reference< text::XTextRange > & xTextRange, - sal_Int16 nControlCharacter, sal_Bool bAbsorb) - throw( lang::IllegalArgumentException, uno::RuntimeException ) +void SAL_CALL +SwXText::insertControlCharacter( + const uno::Reference< text::XTextRange > & xTextRange, + sal_Int16 nControlCharacter, sal_Bool bAbsorb) +throw (lang::IllegalArgumentException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + if (!xTextRange.is()) + { throw lang::IllegalArgumentException(); - if (GetDoc()) + } + if (!GetDoc()) { - SwUnoInternalPaM aPam(*GetDoc()); - if (::sw::XTextRangeToSwPaM(aPam, xTextRange)) + throw uno::RuntimeException(); + } + + SwUnoInternalPaM aPam(*GetDoc()); + if (!::sw::XTextRangeToSwPaM(aPam, xTextRange)) + { + throw uno::RuntimeException(); + } + const bool bForceExpandHints(CheckForOwnMemberMeta(aPam, bAbsorb)); + + const enum IDocumentContentOperations::InsertFlags nInsertFlags = + (bForceExpandHints) + ? static_cast( + IDocumentContentOperations::INS_FORCEHINTEXPAND | + IDocumentContentOperations::INS_EMPTYEXPAND) + : IDocumentContentOperations::INS_EMPTYEXPAND; + + SwPaM aTmp(*aPam.Start()); + if (bAbsorb && aPam.HasMark()) + { + m_pImpl->m_pDoc->DeleteAndJoin(aPam); + } + + sal_Unicode cIns = 0; + switch (nControlCharacter) + { + case text::ControlCharacter::PARAGRAPH_BREAK : + // a table cell now becomes an ordinary text cell! + m_pImpl->m_pDoc->ClearBoxNumAttrs( aTmp.GetPoint()->nNode ); + m_pImpl->m_pDoc->SplitNode( *aTmp.GetPoint(), sal_False ); + break; + case text::ControlCharacter::APPEND_PARAGRAPH: { - const bool bForceExpandHints(CheckForOwnMemberMeta(aPam, bAbsorb)); - - const enum IDocumentContentOperations::InsertFlags nInsertFlags = - (bForceExpandHints) - ? static_cast( - IDocumentContentOperations::INS_FORCEHINTEXPAND | - IDocumentContentOperations::INS_EMPTYEXPAND) - : IDocumentContentOperations::INS_EMPTYEXPAND; - - //Steuerzeichen einfuegen - SwPaM aTmp(*aPam.Start()); - if(bAbsorb && aPam.HasMark()) + m_pImpl->m_pDoc->ClearBoxNumAttrs( aTmp.GetPoint()->nNode ); + m_pImpl->m_pDoc->AppendTxtNode( *aTmp.GetPoint() ); + + const uno::Reference xRangeTunnel( + xTextRange, uno::UNO_QUERY); + SwXTextRange *const pRange = + ::sw::UnoTunnelGetImplementation(xRangeTunnel); + OTextCursorHelper *const pCursor = + ::sw::UnoTunnelGetImplementation( + xRangeTunnel); + if (pRange) { - pDoc->DeleteAndJoin(aPam); + pRange->SetPositions(aTmp); } - - sal_Unicode cIns = 0; - switch( nControlCharacter ) + else if (pCursor) { - case text::ControlCharacter::PARAGRAPH_BREAK : - // eine Tabellen Zelle wird jetzt zu einer normalen Textzelle! - pDoc->ClearBoxNumAttrs( aTmp.GetPoint()->nNode ); - pDoc->SplitNode( *aTmp.GetPoint(), sal_False ); - break; - case text::ControlCharacter::APPEND_PARAGRAPH: - { - pDoc->ClearBoxNumAttrs( aTmp.GetPoint()->nNode ); - pDoc->AppendTxtNode( *aTmp.GetPoint() ); - - uno::Reference xRangeTunnel( xTextRange, uno::UNO_QUERY); - SwXTextRange* pRange = 0; - OTextCursorHelper* pCursor = 0; - if(xRangeTunnel.is()) - { - pRange = reinterpret_cast< SwXTextRange * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXTextRange::getUnoTunnelId()) )); - pCursor = reinterpret_cast< OTextCursorHelper * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( OTextCursorHelper::getUnoTunnelId()) )); - } - if(pRange) - { - pRange->SetPositions(aTmp); - } - else if(pCursor) - { - SwPaM* pCrsr = pCursor->GetPaM(); - *pCrsr->GetPoint() = *aTmp.GetPoint(); - pCrsr->DeleteMark(); - } - } - break; - case text::ControlCharacter::LINE_BREAK: cIns = 10; break; - case text::ControlCharacter::SOFT_HYPHEN: cIns = CHAR_SOFTHYPHEN; break; - case text::ControlCharacter::HARD_HYPHEN: cIns = CHAR_HARDHYPHEN; break; - case text::ControlCharacter::HARD_SPACE: cIns = CHAR_HARDBLANK; break; + SwPaM *const pCrsr = pCursor->GetPaM(); + *pCrsr->GetPoint() = *aTmp.GetPoint(); + pCrsr->DeleteMark(); } - if( cIns ) + } + break; + case text::ControlCharacter::LINE_BREAK: cIns = 10; break; + case text::ControlCharacter::SOFT_HYPHEN: cIns = CHAR_SOFTHYPHEN; break; + case text::ControlCharacter::HARD_HYPHEN: cIns = CHAR_HARDHYPHEN; break; + case text::ControlCharacter::HARD_SPACE: cIns = CHAR_HARDBLANK; break; + } + if (cIns) + { + m_pImpl->m_pDoc->InsertString( aTmp, cIns, nInsertFlags ); + } + + if (bAbsorb) + { + const uno::Reference xRangeTunnel( + xTextRange, uno::UNO_QUERY); + SwXTextRange *const pRange = + ::sw::UnoTunnelGetImplementation(xRangeTunnel); + OTextCursorHelper *const pCursor = + ::sw::UnoTunnelGetImplementation(xRangeTunnel); + + SwCursor aCrsr(*aTmp.GetPoint(),0,false); + SwUnoCursorHelper::SelectPam(aCrsr, true); + aCrsr.Left(1, CRSR_SKIP_CHARS, FALSE, FALSE); + //hier muss der uebergebene PaM umgesetzt werden: + if (pRange) + { + pRange->SetPositions(aCrsr); + } + else + { + SwPaM *const pUnoCrsr = pCursor->GetPaM(); + *pUnoCrsr->GetPoint() = *aCrsr.GetPoint(); + if (aCrsr.HasMark()) { - pDoc->InsertString( aTmp, cIns, nInsertFlags ); + pUnoCrsr->SetMark(); + *pUnoCrsr->GetMark() = *aCrsr.GetMark(); } - - if(bAbsorb) + else { - uno::Reference xRangeTunnel( xTextRange, uno::UNO_QUERY); - SwXTextRange* pRange = 0; - OTextCursorHelper* pCursor = 0; - if(xRangeTunnel.is()) - { - pRange = reinterpret_cast< SwXTextRange * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXTextRange::getUnoTunnelId()) )); - pCursor = reinterpret_cast< OTextCursorHelper * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( OTextCursorHelper::getUnoTunnelId()) )); - } - - SwCursor aCrsr(*aTmp.GetPoint(),0,false); - SwUnoCursorHelper::SelectPam(aCrsr, true); - aCrsr.Left(1, CRSR_SKIP_CHARS, FALSE, FALSE); - //hier muss der uebergebene PaM umgesetzt werden: - if(pRange) - { - pRange->SetPositions(aCrsr); - } - else - { - SwPaM* pUnoCrsr = pCursor->GetPaM(); - *pUnoCrsr->GetPoint() = *aCrsr.GetPoint(); - if(aCrsr.HasMark()) - { - pUnoCrsr->SetMark(); - *pUnoCrsr->GetMark() = *aCrsr.GetMark(); - } - else - pUnoCrsr->DeleteMark(); - } + pUnoCrsr->DeleteMark(); } } } - else - throw uno::RuntimeException(); } + /*-- 09.12.98 12:43:17--------------------------------------------------- -----------------------------------------------------------------------*/ - -void SwXText::insertTextContent(const uno::Reference< text::XTextRange > & xRange, - const uno::Reference< text::XTextContent > & xContent, sal_Bool bAbsorb) - throw( lang::IllegalArgumentException, uno::RuntimeException ) +void SAL_CALL +SwXText::insertTextContent( + const uno::Reference< text::XTextRange > & xRange, + const uno::Reference< text::XTextContent > & xContent, + sal_Bool bAbsorb) +throw (lang::IllegalArgumentException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - // erstmal testen, ob der Range an der richtigen Stelle ist und dann - // am Sw-Content attachToRange aufrufen + + if (!xRange.is()) + { + lang::IllegalArgumentException aIllegal; + aIllegal.Message = C2U("first parameter invalid;"); + throw aIllegal; + } + if (!xContent.is()) + { + lang::IllegalArgumentException aIllegal; + aIllegal.Message += C2U("second parameter invalid"); + throw aIllegal; + } if(!GetDoc()) { uno::RuntimeException aRuntime; aRuntime.Message = C2U(cInvalidObject); throw aRuntime; } - if(xRange.is() && xContent.is()) - { - SwUnoInternalPaM aPam(*GetDoc()); - if (::sw::XTextRangeToSwPaM(aPam, xRange)) - { - uno::Reference xRangeTunnel( xRange, uno::UNO_QUERY); - SwXTextRange* pRange = 0; - OTextCursorHelper* pCursor = 0; - SwXTextPortion* pPortion = 0; - SwXText* pText = 0; - if(xRangeTunnel.is()) - { - pRange = reinterpret_cast< SwXTextRange * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXTextRange::getUnoTunnelId()) )); - pCursor = reinterpret_cast< OTextCursorHelper * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( OTextCursorHelper::getUnoTunnelId()) )); - pPortion = reinterpret_cast< SwXTextPortion * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXTextPortion::getUnoTunnelId()) )); - pText = reinterpret_cast< SwXText * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXText::getUnoTunnelId()) )); - } + SwUnoInternalPaM aPam(*GetDoc()); + if (!::sw::XTextRangeToSwPaM(aPam, xRange)) + { + lang::IllegalArgumentException aIllegal; + aIllegal.Message = C2U("first parameter invalid"); + throw aIllegal; + } + // first test if the range is at the right position, then call + // xContent->attach + const SwStartNode* pOwnStartNode = GetStartNode(); + SwStartNodeType eSearchNodeType = SwNormalStartNode; + switch (m_pImpl->m_eType) + { + case CURSOR_FRAME: eSearchNodeType = SwFlyStartNode; break; + case CURSOR_TBLTEXT: eSearchNodeType = SwTableBoxStartNode; break; + case CURSOR_FOOTNOTE: eSearchNodeType = SwFootnoteStartNode; break; + case CURSOR_HEADER: eSearchNodeType = SwHeaderStartNode; break; + case CURSOR_FOOTER: eSearchNodeType = SwFooterStartNode; break; + //case CURSOR_INVALID: + //case CURSOR_BODY: + default: + break; + } - uno::Reference< text::XTextCursor > xOwnCursor = createCursor(); - uno::Reference xOwnTunnel( xOwnCursor, uno::UNO_QUERY); -// OTextCursorHelper* pOwnCursor = reinterpret_cast< OTextCursorHelper * >( -// sal::static_int_cast< sal_IntPtr >( xOwnTunnel->getSomething( OTextCursorHelper::getUnoTunnelId()) )); + const SwStartNode* pTmp = + aPam.GetNode()->FindSttNodeByType(eSearchNodeType); - const SwStartNode* pOwnStartNode = GetStartNode(); - SwStartNodeType eSearchNodeType = SwNormalStartNode; - switch(eCrsrType) - { - case CURSOR_FRAME: eSearchNodeType = SwFlyStartNode; break; - case CURSOR_TBLTEXT: eSearchNodeType = SwTableBoxStartNode; break; - case CURSOR_FOOTNOTE: eSearchNodeType = SwFootnoteStartNode; break; - case CURSOR_HEADER: eSearchNodeType = SwHeaderStartNode; break; - case CURSOR_FOOTER: eSearchNodeType = SwFooterStartNode; break; - //case CURSOR_INVALID: - //case CURSOR_BODY: - default: - ; - } + // ignore SectionNodes + while (pTmp && pTmp->IsSectionNode()) + { + pTmp = pTmp->StartOfSectionNode(); + } + // if the document starts with a section + while (pOwnStartNode->IsSectionNode()) + { + pOwnStartNode = pOwnStartNode->StartOfSectionNode(); + } + // this checks if (this) and xRange are in the same text::XText interface + if (pOwnStartNode != pTmp) + { + uno::RuntimeException aRunException; + aRunException.Message = C2U("text interface and cursor not related"); + throw aRunException; + } - const SwStartNode* pTmp = - aPam.GetNode()->FindSttNodeByType(eSearchNodeType); + const bool bForceExpandHints(CheckForOwnMemberMeta(aPam, bAbsorb)); - //SectionNodes ueberspringen - while(pTmp && pTmp->IsSectionNode()) - { - pTmp = pTmp->StartOfSectionNode(); - } - //if the document starts with a section - while(pOwnStartNode->IsSectionNode()) - { - pOwnStartNode = pOwnStartNode->StartOfSectionNode(); - } - //this checks if (this) and xRange are in the same text::XText interface - if(pOwnStartNode != pTmp) - { - uno::RuntimeException aRunException; - aRunException.Message = C2U("text interface and cursor not related"); - throw aRunException; - } + // special treatment for Contents that do not replace the range, but + // instead are "overlaid" + const uno::Reference xContentTunnel(xContent, + uno::UNO_QUERY); + if (!xContentTunnel.is()) + { + lang::IllegalArgumentException aArgException; + aArgException.Message = + C2U("text content does not support lang::XUnoTunnel"); + throw aArgException; + } + SwXDocumentIndexMark *const pDocumentIndexMark = + ::sw::UnoTunnelGetImplementation(xContentTunnel); + SwXTextSection *const pSection = + ::sw::UnoTunnelGetImplementation(xContentTunnel); + SwXBookmark *const pBookmark = + ::sw::UnoTunnelGetImplementation(xContentTunnel); + SwXReferenceMark *const pReferenceMark = + ::sw::UnoTunnelGetImplementation(xContentTunnel); + SwXMeta *const pMeta = + ::sw::UnoTunnelGetImplementation(xContentTunnel); - const bool bForceExpandHints(CheckForOwnMemberMeta(aPam, bAbsorb)); + const bool bAttribute = pBookmark || pDocumentIndexMark + || pSection || pReferenceMark || pMeta; - // Sonderbehandlung fuer Contents, die den Range nicht ersetzen, sonder darueber gelegt werden - // Bookmarks, IndexEntry - uno::Reference xContentTunnel( xContent, uno::UNO_QUERY); - if(!xContentTunnel.is()) - { - lang::IllegalArgumentException aArgException; - aArgException.Message = C2U("text content doesn't support lang::XUnoTunnel"); - throw aArgException; - } - SwXDocumentIndexMark* pDocumentIndexMark = reinterpret_cast< SwXDocumentIndexMark * >( - sal::static_int_cast< sal_IntPtr >( xContentTunnel->getSomething( SwXDocumentIndexMark::getUnoTunnelId()) )); - SwXTextSection* pSection = reinterpret_cast< SwXTextSection * >( - sal::static_int_cast< sal_IntPtr >( xContentTunnel->getSomething( SwXTextSection::getUnoTunnelId()) )); - SwXBookmark* pBookmark = reinterpret_cast< SwXBookmark * >( - sal::static_int_cast< sal_IntPtr >( xContentTunnel->getSomething( SwXBookmark::getUnoTunnelId()) )); - SwXReferenceMark* pReferenceMark = reinterpret_cast< SwXReferenceMark * >( - sal::static_int_cast< sal_IntPtr >( xContentTunnel->getSomething( SwXReferenceMark::getUnoTunnelId()) )); - SwXMeta *const pMeta = reinterpret_cast< SwXMeta* >( - sal::static_int_cast< sal_IntPtr >( - xContentTunnel->getSomething( SwXMeta::getUnoTunnelId()))); - - const bool bAttribute = pBookmark || pDocumentIndexMark - || pSection || pReferenceMark || pMeta; - - if(bAbsorb && !bAttribute) - { - xRange->setString(aEmptyStr); - } - //hier wird tatsaechlich eingefuegt - uno::Reference< text::XTextRange > xTempRange; - if(bAttribute && bAbsorb) - xTempRange = xRange; - else - xTempRange = xRange->getStart(); - if (bForceExpandHints) - { - // if necessary, replace xTempRange with a new SwXTextCursor - PrepareForAttach(xTempRange, aPam); - } - xContent->attach(xTempRange); - } - else - { - lang::IllegalArgumentException aIllegal; - aIllegal.Message = C2U("first parameter invalid"); - throw aIllegal; - } + if (bAbsorb && !bAttribute) + { + xRange->setString(aEmptyStr); } - else + uno::Reference< text::XTextRange > xTempRange = + (bAttribute && bAbsorb) ? xRange : xRange->getStart(); + if (bForceExpandHints) { - lang::IllegalArgumentException aIllegal; - if(!xRange.is()) - aIllegal.Message = C2U("first parameter invalid;"); - if(!xContent.is()) - aIllegal.Message += C2U("second parameter invalid"); - throw aIllegal; + // if necessary, replace xTempRange with a new SwXTextCursor + PrepareForAttach(xTempRange, aPam); } - + xContent->attach(xTempRange); } + /* -----------------------------10.07.00 15:40-------------------------------- ---------------------------------------------------------------------------*/ -void SwXText::insertTextContentBefore( +void SAL_CALL +SwXText::insertTextContentBefore( const uno::Reference< text::XTextContent>& xNewContent, const uno::Reference< text::XTextContent>& xSuccessor) - throw(lang::IllegalArgumentException, uno::RuntimeException) +throw (lang::IllegalArgumentException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + if(!GetDoc()) { uno::RuntimeException aRuntime; @@ -646,35 +658,37 @@ void SwXText::insertTextContentBefore( uno::UNO_QUERY); SwXParagraph *const pPara = ::sw::UnoTunnelGetImplementation(xParaTunnel); - if(!pPara || !pPara->IsDescriptor() || !xSuccessor.is()) + if (!pPara || !pPara->IsDescriptor() || !xSuccessor.is()) + { throw lang::IllegalArgumentException(); + } sal_Bool bRet = sal_False; const uno::Reference xSuccTunnel(xSuccessor, uno::UNO_QUERY); SwXTextSection *const pXSection = ::sw::UnoTunnelGetImplementation(xSuccTunnel); - SwXTextTable* pXTable = SwXTextTable::GetImplementation(xSuccessor ); - SwFrmFmt* pTableFmt = pXTable ? pXTable->GetFrmFmt() : 0; + SwXTextTable *const pXTable = + ::sw::UnoTunnelGetImplementation(xSuccTunnel); + SwFrmFmt *const pTableFmt = (pXTable) ? pXTable->GetFrmFmt() : 0; SwTxtNode * pTxtNode = 0; if(pTableFmt && pTableFmt->GetDoc() == GetDoc()) { - SwTable* pTable = SwTable::FindTable( pTableFmt ); - SwTableNode* pTblNode = pTable->GetTableNode(); + SwTable *const pTable = SwTable::FindTable( pTableFmt ); + SwTableNode *const pTblNode = pTable->GetTableNode(); - SwNodeIndex aTblIdx( *pTblNode, -1 ); + const SwNodeIndex aTblIdx( *pTblNode, -1 ); SwPosition aBefore(aTblIdx); bRet = GetDoc()->AppendTxtNode( aBefore ); pTxtNode = aBefore.nNode.GetNode().GetTxtNode(); } - else if(pXSection && - pXSection->GetFmt() && + else if (pXSection && pXSection->GetFmt() && pXSection->GetFmt()->GetDoc() == GetDoc()) { - SwSectionFmt* pSectFmt = pXSection->GetFmt(); - SwSectionNode* pSectNode = pSectFmt->GetSectionNode(); + SwSectionFmt *const pSectFmt = pXSection->GetFmt(); + SwSectionNode *const pSectNode = pSectFmt->GetSectionNode(); - SwNodeIndex aSectIdx( *pSectNode, -1 ); + const SwNodeIndex aSectIdx( *pSectNode, -1 ); SwPosition aBefore(aSectIdx); bRet = GetDoc()->AppendTxtNode( aBefore ); pTxtNode = aBefore.nNode.GetNode().GetTxtNode(); @@ -683,55 +697,59 @@ void SwXText::insertTextContentBefore( { throw lang::IllegalArgumentException(); } - else - { - pPara->attachToText(*this, *pTxtNode); - } - + pPara->attachToText(*this, *pTxtNode); } + /* -----------------------------10.07.00 15:40-------------------------------- ---------------------------------------------------------------------------*/ -void SwXText::insertTextContentAfter( +void SAL_CALL +SwXText::insertTextContentAfter( const uno::Reference< text::XTextContent>& xNewContent, const uno::Reference< text::XTextContent>& xPredecessor) - throw(lang::IllegalArgumentException, uno::RuntimeException) +throw (lang::IllegalArgumentException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + if(!GetDoc()) + { throw uno::RuntimeException(); + } + const uno::Reference xParaTunnel(xNewContent, uno::UNO_QUERY); SwXParagraph *const pPara = ::sw::UnoTunnelGetImplementation(xParaTunnel); if(!pPara || !pPara->IsDescriptor() || !xPredecessor.is()) + { throw lang::IllegalArgumentException(); + } const uno::Reference xPredTunnel(xPredecessor, uno::UNO_QUERY); SwXTextSection *const pXSection = ::sw::UnoTunnelGetImplementation(xPredTunnel); - SwXTextTable* pXTable = SwXTextTable::GetImplementation(xPredecessor ); - SwFrmFmt* pTableFmt = pXTable ? pXTable->GetFrmFmt() : 0; + SwXTextTable *const pXTable = + ::sw::UnoTunnelGetImplementation(xPredTunnel); + SwFrmFmt *const pTableFmt = (pXTable) ? pXTable->GetFrmFmt() : 0; sal_Bool bRet = sal_False; SwTxtNode * pTxtNode = 0; if(pTableFmt && pTableFmt->GetDoc() == GetDoc()) { - SwTable* pTable = SwTable::FindTable( pTableFmt ); - SwTableNode* pTblNode = pTable->GetTableNode(); + SwTable *const pTable = SwTable::FindTable( pTableFmt ); + SwTableNode *const pTblNode = pTable->GetTableNode(); - SwEndNode* pTableEnd = pTblNode->EndOfSectionNode(); + SwEndNode *const pTableEnd = pTblNode->EndOfSectionNode(); SwPosition aTableEnd(*pTableEnd); bRet = GetDoc()->AppendTxtNode( aTableEnd ); pTxtNode = aTableEnd.nNode.GetNode().GetTxtNode(); } - else if(pXSection && - pXSection->GetFmt() && + else if (pXSection && pXSection->GetFmt() && pXSection->GetFmt()->GetDoc() == GetDoc()) { - SwSectionFmt* pSectFmt = pXSection->GetFmt(); - SwSectionNode* pSectNode = pSectFmt->GetSectionNode(); - SwEndNode* pEnd = pSectNode->EndOfSectionNode(); + SwSectionFmt *const pSectFmt = pXSection->GetFmt(); + SwSectionNode *const pSectNode = pSectFmt->GetSectionNode(); + SwEndNode *const pEnd = pSectNode->EndOfSectionNode(); SwPosition aEnd(*pEnd); bRet = GetDoc()->AppendTxtNode( aEnd ); pTxtNode = aEnd.nNode.GetNode().GetTxtNode(); @@ -740,19 +758,19 @@ void SwXText::insertTextContentAfter( { throw lang::IllegalArgumentException(); } - else - { - pPara->attachToText(*this, *pTxtNode); - } + pPara->attachToText(*this, *pTxtNode); } + /* -----------------------------10.07.00 15:40-------------------------------- ---------------------------------------------------------------------------*/ -void SwXText::removeTextContentBefore( +void SAL_CALL +SwXText::removeTextContentBefore( const uno::Reference< text::XTextContent>& xSuccessor) - throw(lang::IllegalArgumentException, uno::RuntimeException) +throw (lang::IllegalArgumentException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + if(!GetDoc()) { uno::RuntimeException aRuntime; @@ -765,28 +783,28 @@ void SwXText::removeTextContentBefore( uno::UNO_QUERY); SwXTextSection *const pXSection = ::sw::UnoTunnelGetImplementation(xSuccTunnel); - SwXTextTable* pXTable = SwXTextTable::GetImplementation( xSuccessor ); - SwFrmFmt* pTableFmt = pXTable ? pXTable->GetFrmFmt() : 0; + SwXTextTable *const pXTable = + ::sw::UnoTunnelGetImplementation(xSuccTunnel); + SwFrmFmt *const pTableFmt = (pXTable) ? pXTable->GetFrmFmt() : 0; if(pTableFmt && pTableFmt->GetDoc() == GetDoc()) { - SwTable* pTable = SwTable::FindTable( pTableFmt ); - SwTableNode* pTblNode = pTable->GetTableNode(); + SwTable *const pTable = SwTable::FindTable( pTableFmt ); + SwTableNode *const pTblNode = pTable->GetTableNode(); - SwNodeIndex aTblIdx( *pTblNode, -1 ); + const SwNodeIndex aTblIdx( *pTblNode, -1 ); if(aTblIdx.GetNode().IsTxtNode()) { SwPaM aBefore(aTblIdx); bRet = GetDoc()->DelFullPara( aBefore ); } } - else if(pXSection && - pXSection->GetFmt() && + else if (pXSection && pXSection->GetFmt() && pXSection->GetFmt()->GetDoc() == GetDoc()) { - SwSectionFmt* pSectFmt = pXSection->GetFmt(); - SwSectionNode* pSectNode = pSectFmt->GetSectionNode(); + SwSectionFmt *const pSectFmt = pXSection->GetFmt(); + SwSectionNode *const pSectNode = pSectFmt->GetSectionNode(); - SwNodeIndex aSectIdx( *pSectNode, -1 ); + const SwNodeIndex aSectIdx( *pSectNode, -1 ); if(aSectIdx.GetNode().IsTxtNode()) { SwPaM aBefore(aSectIdx); @@ -794,15 +812,21 @@ void SwXText::removeTextContentBefore( } } if(!bRet) + { throw lang::IllegalArgumentException(); + } } + /* -----------------------------10.07.00 15:40-------------------------------- ---------------------------------------------------------------------------*/ -void SwXText::removeTextContentAfter(const uno::Reference< text::XTextContent>& xPredecessor) - throw(lang::IllegalArgumentException, uno::RuntimeException) +void SAL_CALL +SwXText::removeTextContentAfter( + const uno::Reference< text::XTextContent>& xPredecessor) +throw (lang::IllegalArgumentException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + if(!GetDoc()) { uno::RuntimeException aRuntime; @@ -815,29 +839,29 @@ void SwXText::removeTextContentAfter(const uno::Reference< text::XTextContent>& uno::UNO_QUERY); SwXTextSection *const pXSection = ::sw::UnoTunnelGetImplementation(xPredTunnel); - SwXTextTable* pXTable = SwXTextTable::GetImplementation(xPredecessor ); - SwFrmFmt* pTableFmt = pXTable ? pXTable->GetFrmFmt() : 0; + SwXTextTable *const pXTable = + ::sw::UnoTunnelGetImplementation(xPredTunnel); + SwFrmFmt *const pTableFmt = (pXTable) ? pXTable->GetFrmFmt() : 0; if(pTableFmt && pTableFmt->GetDoc() == GetDoc()) { - SwTable* pTable = SwTable::FindTable( pTableFmt ); - SwTableNode* pTblNode = pTable->GetTableNode(); - SwEndNode* pTableEnd = pTblNode->EndOfSectionNode(); + SwTable *const pTable = SwTable::FindTable( pTableFmt ); + SwTableNode *const pTblNode = pTable->GetTableNode(); + SwEndNode *const pTableEnd = pTblNode->EndOfSectionNode(); - SwNodeIndex aTblIdx( *pTableEnd, 1 ); + const SwNodeIndex aTblIdx( *pTableEnd, 1 ); if(aTblIdx.GetNode().IsTxtNode()) { SwPaM aPaM(aTblIdx); bRet = GetDoc()->DelFullPara( aPaM ); } } - else if(pXSection && - pXSection->GetFmt() && + else if (pXSection && pXSection->GetFmt() && pXSection->GetFmt()->GetDoc() == GetDoc()) { - SwSectionFmt* pSectFmt = pXSection->GetFmt(); - SwSectionNode* pSectNode = pSectFmt->GetSectionNode(); - SwEndNode* pEnd = pSectNode->EndOfSectionNode(); - SwNodeIndex aSectIdx( *pEnd, 1 ); + SwSectionFmt *const pSectFmt = pXSection->GetFmt(); + SwSectionNode *const pSectNode = pSectFmt->GetSectionNode(); + SwEndNode *const pEnd = pSectNode->EndOfSectionNode(); + const SwNodeIndex aSectIdx( *pEnd, 1 ); if(aSectIdx.GetNode().IsTxtNode()) { SwPaM aAfter(aSectIdx); @@ -845,42 +869,50 @@ void SwXText::removeTextContentAfter(const uno::Reference< text::XTextContent>& } } if(!bRet) + { throw lang::IllegalArgumentException(); + } } + /*-- 09.12.98 12:43:19--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXText::removeTextContent(const uno::Reference< text::XTextContent > & xContent) - throw( container::NoSuchElementException, uno::RuntimeException ) +void SAL_CALL +SwXText::removeTextContent( + const uno::Reference< text::XTextContent > & xContent) +throw (container::NoSuchElementException, uno::RuntimeException) { - vos::OGuard aGuard(Application::GetSolarMutex()); + // forward: need no solar mutex here if(!xContent.is()) { uno::RuntimeException aRuntime; aRuntime.Message = C2U("first parameter invalid"); throw aRuntime; } - else - xContent->dispose(); + xContent->dispose(); } + /*-- 09.12.98 12:43:22--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XText > SwXText::getText(void) - throw( uno::RuntimeException ) +uno::Reference< text::XText > SAL_CALL +SwXText::getText() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< text::XText > xRet = (SwXText*)this; - return xRet; + const uno::Reference< text::XText > xRet(this); + return xRet; } + /*-- 09.12.98 12:43:24--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextRange > SwXText::getStart(void) throw( uno::RuntimeException ) +uno::Reference< text::XTextRange > SAL_CALL +SwXText::getStart() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< text::XTextCursor > xRef = createCursor(); + + const uno::Reference< text::XTextCursor > xRef = CreateCursor(); if(!xRef.is()) { uno::RuntimeException aRuntime; @@ -888,16 +920,18 @@ uno::Reference< text::XTextRange > SwXText::getStart(void) throw( uno::RuntimeE throw aRuntime; } xRef->gotoStart(sal_False); - uno::Reference< text::XTextRange > xRet(xRef, uno::UNO_QUERY); + const uno::Reference< text::XTextRange > xRet(xRef, uno::UNO_QUERY); return xRet; } /*-- 09.12.98 12:43:27--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextRange > SwXText::getEnd(void) throw( uno::RuntimeException ) +uno::Reference< text::XTextRange > SAL_CALL +SwXText::getEnd() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< text::XTextCursor > xRef = createCursor(); + + const uno::Reference< text::XTextCursor > xRef = CreateCursor(); if(!xRef.is()) { uno::RuntimeException aRuntime; @@ -905,42 +939,52 @@ uno::Reference< text::XTextRange > SwXText::getEnd(void) throw( uno::RuntimeExc throw aRuntime; } xRef->gotoEnd(sal_False); - uno::Reference< text::XTextRange > xRet(xRef, uno::UNO_QUERY); + const uno::Reference< text::XTextRange > xRet(xRef, uno::UNO_QUERY); return xRet; } + /*-- 09.12.98 12:43:29--------------------------------------------------- -----------------------------------------------------------------------*/ -OUString SwXText::getString(void) throw( uno::RuntimeException ) +OUString SAL_CALL SwXText::getString() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< text::XTextCursor > xRet = createCursor(); + + const uno::Reference< text::XTextCursor > xRet = CreateCursor(); if(!xRet.is()) { uno::RuntimeException aRuntime; aRuntime.Message = C2U(cInvalidObject); throw aRuntime; } - else - { - xRet->gotoEnd(sal_True); - } + xRet->gotoEnd(sal_True); return xRet->getString(); } /*-- 09.12.98 12:43:30--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXText::setString(const OUString& aString) throw( uno::RuntimeException ) +void SAL_CALL +SwXText::setString(const OUString& rString) throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + + if (!GetDoc()) + { + uno::RuntimeException aRuntime; + aRuntime.Message = C2U(cInvalidObject); + throw aRuntime; + } + const SwStartNode* pStartNode = GetStartNode(); - if(!pStartNode) + if (!pStartNode) + { throw uno::RuntimeException(); + } GetDoc()->StartUndo(UNDO_START, NULL); //insert an empty paragraph at the start and at the end to ensure that //all tables and sections can be removed by the selecting text::XTextCursor - if (CURSOR_META != eCrsrType) + if (CURSOR_META != m_pImpl->m_eType) { SwPosition aStartPos(*pStartNode); const SwEndNode* pEnd = pStartNode->EndOfSectionNode(); @@ -972,7 +1016,7 @@ void SwXText::setString(const OUString& aString) throw( uno::RuntimeException ) } } - uno::Reference< text::XTextCursor > xRet = createCursor(); + const uno::Reference< text::XTextCursor > xRet = CreateCursor(); if(!xRet.is()) { GetDoc()->EndUndo(UNDO_END, NULL); @@ -980,36 +1024,28 @@ void SwXText::setString(const OUString& aString) throw( uno::RuntimeException ) aRuntime.Message = C2U(cInvalidObject); throw aRuntime; } - else - { - xRet->gotoEnd(sal_True); - } - xRet->setString(aString); + xRet->gotoEnd(sal_True); + xRet->setString(rString); GetDoc()->EndUndo(UNDO_END, NULL); } //FIXME why is CheckForOwnMember duplicated in some insert methods? // Description: Checks if pRange/pCursor are member of the same text interface. // Only one of the pointers has to be set! -sal_Bool SwXText::CheckForOwnMember( - const SwXTextRange* pRange, - const OTextCursorHelper* pCursor) - throw(lang::IllegalArgumentException, uno::RuntimeException) +bool SwXText::Impl::CheckForOwnMember( + const SwPaM & rPaM) +throw (lang::IllegalArgumentException, uno::RuntimeException) { - DBG_ASSERT((!pRange || !pCursor) && (pRange || pCursor), "only one pointer will be checked" ); - uno::Reference xOwnCursor = createCursor(); + const uno::Reference xOwnCursor(m_rThis.CreateCursor()); - uno::Reference xTunnel( xOwnCursor, uno::UNO_QUERY); - OTextCursorHelper* pOwnCursor = 0; - if(xTunnel.is()) - { - pOwnCursor = reinterpret_cast< OTextCursorHelper * >( - sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething(OTextCursorHelper::getUnoTunnelId()) )); - } + const uno::Reference xTunnel(xOwnCursor, uno::UNO_QUERY); + OTextCursorHelper *const pOwnCursor = + ::sw::UnoTunnelGetImplementation(xTunnel); DBG_ASSERT(pOwnCursor, "OTextCursorHelper::getUnoTunnelId() ??? "); - const SwStartNode* pOwnStartNode = pOwnCursor->GetPaM()->GetNode()->StartOfSectionNode(); + const SwStartNode* pOwnStartNode = + pOwnCursor->GetPaM()->GetNode()->StartOfSectionNode(); SwStartNodeType eSearchNodeType = SwNormalStartNode; - switch(eCrsrType) + switch (m_eType) { case CURSOR_FRAME: eSearchNodeType = SwFlyStartNode; break; case CURSOR_TBLTEXT: eSearchNodeType = SwTableBoxStartNode; break; @@ -1022,101 +1058,62 @@ sal_Bool SwXText::CheckForOwnMember( ; } - const SwNode* pSrcNode; - if (pCursor) - { - pSrcNode = pCursor->GetPaM()->GetNode(); - } - else // pRange - { - SwPaM aPam(pRange->GetDoc()->GetNodes().GetEndOfContent()); - if (pRange->GetPositions(aPam)) - { - pSrcNode = aPam.GetNode(); - } - } - if (!pSrcNode) { return sal_False; } + SwNode const*const pSrcNode(rPaM.GetNode()); + if (!pSrcNode) { return false; } const SwStartNode* pTmp = pSrcNode->FindSttNodeByType(eSearchNodeType); //SectionNodes ueberspringen while(pTmp && pTmp->IsSectionNode()) + { pTmp = pTmp->StartOfSectionNode(); + } //if the document starts with a section while(pOwnStartNode->IsSectionNode()) + { pOwnStartNode = pOwnStartNode->StartOfSectionNode(); + } //this checks if (this) and xRange are in the same text::XText interface - return(pOwnStartNode == pTmp); + return (pOwnStartNode == pTmp); } -sal_Int16 SwXText::ComparePositions( +sal_Int16 +SwXText::Impl::ComparePositions( const uno::Reference& xPos1, const uno::Reference& xPos2) - throw(lang::IllegalArgumentException, uno::RuntimeException) +throw (lang::IllegalArgumentException, uno::RuntimeException) { - sal_Int16 nCompare = 0; - SwUnoInternalPaM aPam1(*GetDoc()); - SwUnoInternalPaM aPam2(*GetDoc()); + SwUnoInternalPaM aPam1(*m_pDoc); + SwUnoInternalPaM aPam2(*m_pDoc); - BOOL bExcept = FALSE; - if (::sw::XTextRangeToSwPaM(aPam1, xPos1) && - ::sw::XTextRangeToSwPaM(aPam2, xPos2)) + if (!::sw::XTextRangeToSwPaM(aPam1, xPos1) || + !::sw::XTextRangeToSwPaM(aPam2, xPos2)) { - uno::Reference xRangeTunnel1( xPos1, uno::UNO_QUERY); - SwXTextRange* pRange1 = 0; - OTextCursorHelper* pCursor1 = 0; - if(xRangeTunnel1.is()) - { - pRange1 = reinterpret_cast< SwXTextRange * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel1->getSomething( SwXTextRange::getUnoTunnelId()) )); - pCursor1 = reinterpret_cast< OTextCursorHelper * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel1->getSomething( OTextCursorHelper::getUnoTunnelId()) )); - } - uno::Reference xRangeTunnel2( xPos2, uno::UNO_QUERY); - SwXTextRange* pRange2 = 0; - OTextCursorHelper* pCursor2 = 0; - if(xRangeTunnel2.is()) - { - pRange2 = reinterpret_cast< SwXTextRange * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel2->getSomething( SwXTextRange::getUnoTunnelId()) )); - pCursor2 = reinterpret_cast< OTextCursorHelper * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel2->getSomething( OTextCursorHelper::getUnoTunnelId()) )); - } - - if((pRange1||pCursor1) && (pRange2||pCursor2)) - { - if(CheckForOwnMember(pRange1, pCursor1) - && CheckForOwnMember( pRange2, pCursor2)) - { - SwPosition const*const pStart1 = aPam1.Start(); - SwPosition const*const pStart2 = aPam2.Start(); + throw lang::IllegalArgumentException(); + } + if (!CheckForOwnMember(aPam1) || !CheckForOwnMember(aPam2)) + { + throw lang::IllegalArgumentException(); + } - if(pStart1 && pStart2) - { - if(*pStart1 < *pStart2) - nCompare = 1; - else if(*pStart1 > *pStart2) - nCompare = -1; - else - { - DBG_ASSERT(*pStart1 == *pStart2, "SwPositions should be equal here"); - nCompare = 0; - } - } - else - bExcept = TRUE; - } - else - bExcept = TRUE; - } - else - bExcept = TRUE; + sal_Int16 nCompare = 0; + SwPosition const*const pStart1 = aPam1.Start(); + SwPosition const*const pStart2 = aPam2.Start(); + if (*pStart1 < *pStart2) + { + nCompare = 1; + } + else if (*pStart1 > *pStart2) + { + nCompare = -1; } else - bExcept = TRUE; - if(bExcept) - throw lang::IllegalArgumentException(); + { + DBG_ASSERT(*pStart1 == *pStart2, + "SwPositions should be equal here"); + nCompare = 0; + } return nCompare; } @@ -1124,50 +1121,64 @@ sal_Int16 SwXText::ComparePositions( /*-- 28.03.00 10:37:22--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Int16 SwXText::compareRegionStarts( - const uno::Reference& xR1, - const uno::Reference& xR2) - throw(lang::IllegalArgumentException, uno::RuntimeException) +sal_Int16 SAL_CALL +SwXText::compareRegionStarts( + const uno::Reference& xRange1, + const uno::Reference& xRange2) +throw (lang::IllegalArgumentException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(!xR1.is() || !xR2.is()) + + if (!xRange1.is() || !xRange2.is()) + { throw lang::IllegalArgumentException(); - uno::Reference xStart1 = xR1->getStart(); - uno::Reference xStart2 = xR2->getStart(); + } + const uno::Reference xStart1 = xRange1->getStart(); + const uno::Reference xStart2 = xRange2->getStart(); - return ComparePositions(xStart1, xStart2); + return m_pImpl->ComparePositions(xStart1, xStart2); } /*-- 28.03.00 10:37:25--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Int16 SwXText::compareRegionEnds( - const uno::Reference& xR1, - const uno::Reference& xR2) - throw(lang::IllegalArgumentException, uno::RuntimeException) +sal_Int16 SAL_CALL +SwXText::compareRegionEnds( + const uno::Reference& xRange1, + const uno::Reference& xRange2) +throw (lang::IllegalArgumentException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(!xR1.is() || !xR2.is()) + + if (!xRange1.is() || !xRange2.is()) + { throw lang::IllegalArgumentException(); - uno::Reference xEnd1 = xR1->getEnd(); - uno::Reference xEnd2 = xR2->getEnd(); + } + uno::Reference xEnd1 = xRange1->getEnd(); + uno::Reference xEnd2 = xRange2->getEnd(); - return ComparePositions(xEnd1, xEnd2); + return m_pImpl->ComparePositions(xEnd1, xEnd2); } /*-- 15.03.2002 12:30:40--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< beans::XPropertySetInfo > SwXText::getPropertySetInfo( ) - throw(uno::RuntimeException) +uno::Reference< beans::XPropertySetInfo > SAL_CALL +SwXText::getPropertySetInfo() throw(uno::RuntimeException) { - static uno::Reference< beans::XPropertySetInfo > xInfo = m_pPropSet->getPropertySetInfo(); + vos::OGuard g(Application::GetSolarMutex()); + + static uno::Reference< beans::XPropertySetInfo > xInfo = + m_pImpl->m_rPropSet.getPropertySetInfo(); return xInfo; } + /*-- 15.03.2002 12:30:42--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXText::setPropertyValue( const ::rtl::OUString& /*aPropertyName*/, const uno::Any& /*aValue*/ ) - throw(beans::UnknownPropertyException, beans::PropertyVetoException, +void SAL_CALL +SwXText::setPropertyValue(const ::rtl::OUString& /*aPropertyName*/, + const uno::Any& /*aValue*/) +throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) { @@ -1176,100 +1187,113 @@ void SwXText::setPropertyValue( const ::rtl::OUString& /*aPropertyName*/, const /*-- 15.03.2002 12:30:42--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Any SwXText::getPropertyValue( - const ::rtl::OUString& rPropertyName ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, - uno::RuntimeException) +uno::Any SAL_CALL +SwXText::getPropertyValue( + const ::rtl::OUString& rPropertyName) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + if(!IsValid()) + { throw uno::RuntimeException(); - const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName(rPropertyName); + } + + SfxItemPropertySimpleEntry const*const pEntry = + m_pImpl->m_rPropSet.getPropertyMap()->getByName(rPropertyName); + if (!pEntry) + { + beans::UnknownPropertyException aExcept; + aExcept.Message = C2U("Unknown property: "); + aExcept.Message += rPropertyName; + throw aExcept; + } + uno::Any aRet; - if(pEntry) + switch (pEntry->nWID) { - switch(pEntry->nWID) - { // no code necessary - the redline is always located at the end node // case FN_UNO_REDLINE_NODE_START: // break; - case FN_UNO_REDLINE_NODE_END: + case FN_UNO_REDLINE_NODE_END: + { + const SwRedlineTbl& rRedTbl = GetDoc()->GetRedlineTbl(); + const USHORT nRedTblCount = rRedTbl.Count(); + if (nRedTblCount > 0) { - const SwRedlineTbl& rRedTbl = GetDoc()->GetRedlineTbl(); - USHORT nRedTblCount = rRedTbl.Count(); - if ( nRedTblCount > 0 ) + SwStartNode const*const pStartNode = GetStartNode(); + const ULONG nOwnIndex = pStartNode->EndOfSectionIndex(); + for (USHORT nRed = 0; nRed < nRedTblCount; nRed++) { - const SwStartNode* pStartNode = GetStartNode(); - ULONG nOwnIndex = pStartNode->EndOfSectionIndex(); - for(USHORT nRed = 0; nRed < nRedTblCount; nRed++) + SwRedline const*const pRedline = rRedTbl[nRed]; + SwPosition const*const pRedStart = pRedline->Start(); + const SwNodeIndex nRedNode = pRedStart->nNode; + if (nOwnIndex == nRedNode.GetIndex()) { - const SwRedline* pRedline = rRedTbl[nRed]; - const SwPosition* pRedStart = pRedline->Start(); - const SwNodeIndex nRedNode = pRedStart->nNode; - if(nOwnIndex == nRedNode.GetIndex()) - { - aRet <<= SwXRedlinePortion::CreateRedlineProperties(*pRedline, TRUE); - break; - } + aRet <<= SwXRedlinePortion::CreateRedlineProperties( + *pRedline, TRUE); + break; } } } - break; } - } - else - { - beans::UnknownPropertyException aExcept; - aExcept.Message = C2U("Unknown property: "); - aExcept.Message += rPropertyName; - throw aExcept; + break; } return aRet; - } + /*-- 15.03.2002 12:30:42--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXText::addPropertyChangeListener( - const ::rtl::OUString& /*aPropertyName*/, - const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/ ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, - uno::RuntimeException) +void SAL_CALL +SwXText::addPropertyChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - throw uno::RuntimeException(); + OSL_ENSURE(false, + "SwXText::addPropertyChangeListener(): not implemented"); } /*-- 15.03.2002 12:30:43--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXText::removePropertyChangeListener( - const ::rtl::OUString& /*aPropertyName*/, - const uno::Reference< beans::XPropertyChangeListener >& /*aListener*/ ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, - uno::RuntimeException) +void SAL_CALL +SwXText::removePropertyChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - throw uno::RuntimeException(); + OSL_ENSURE(false, + "SwXText::removePropertyChangeListener(): not implemented"); } /*-- 15.03.2002 12:30:43--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXText::addVetoableChangeListener( - const ::rtl::OUString& /*PropertyName*/, - const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/ ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, - uno::RuntimeException) +void SAL_CALL +SwXText::addVetoableChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - throw uno::RuntimeException(); + OSL_ENSURE(false, + "SwXText::addVetoableChangeListener(): not implemented"); } /*-- 15.03.2002 12:30:43--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXText::removeVetoableChangeListener( - const ::rtl::OUString& /*rPropertyName*/, - const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/ ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, +void SAL_CALL +SwXText::removeVetoableChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) { - throw uno::RuntimeException(); + OSL_ENSURE(false, + "SwXText::removeVetoableChangeListener(): not implemented"); } /* -----------------------------08.01.01 09:07-------------------------------- @@ -1283,488 +1307,527 @@ const uno::Sequence< sal_Int8 > & SwXText::getUnoTunnelId() /* -----------------------------08.01.01 09:07-------------------------------- ---------------------------------------------------------------------------*/ -sal_Int64 SwXText::getSomething( const uno::Sequence< sal_Int8 >& rId ) - throw(uno::RuntimeException) +sal_Int64 SAL_CALL +SwXText::getSomething(const uno::Sequence< sal_Int8 >& rId) +throw (uno::RuntimeException) { - if( rId.getLength() == 16 - && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), - rId.getConstArray(), 16 ) ) - { - return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(this) ); - } - return 0; + return ::sw::UnoTunnelImpl(rId, this); } + /*-- 23.06.2006 08:56:30--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextRange > SwXText::appendParagraph( - const uno::Sequence< beans::PropertyValue > & rProperties ) - throw (lang::IllegalArgumentException, uno::RuntimeException) +uno::Reference< text::XTextRange > SAL_CALL +SwXText::appendParagraph( + const uno::Sequence< beans::PropertyValue > & rProperties) +throw (lang::IllegalArgumentException, uno::RuntimeException) { - return finishOrAppendParagraph(false, rProperties); + vos::OGuard g(Application::GetSolarMutex()); + + return m_pImpl->finishOrAppendParagraph(false, rProperties); } /*-- 23.06.2006 08:56:22--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextRange > SwXText::finishParagraph( - const uno::Sequence< beans::PropertyValue > & rProperties ) - throw (lang::IllegalArgumentException, uno::RuntimeException) +uno::Reference< text::XTextRange > SAL_CALL +SwXText::finishParagraph( + const uno::Sequence< beans::PropertyValue > & rProperties) +throw (lang::IllegalArgumentException, uno::RuntimeException) { - return finishOrAppendParagraph(true, rProperties); + vos::OGuard g(Application::GetSolarMutex()); + + return m_pImpl->finishOrAppendParagraph(true, rProperties); } /*-- 08.05.2006 13:26:26--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextRange > SwXText::finishOrAppendParagraph( - bool bFinish, - const uno::Sequence< beans::PropertyValue > & rProperties ) - throw (lang::IllegalArgumentException, uno::RuntimeException) - +uno::Reference< text::XTextRange > +SwXText::Impl::finishOrAppendParagraph( + const bool bFinish, + const uno::Sequence< beans::PropertyValue > & rProperties) +throw (lang::IllegalArgumentException, uno::RuntimeException) { - vos::OGuard aGuard(Application::GetSolarMutex()); - if(!IsValid()) + if (!m_bIsValid) + { throw uno::RuntimeException(); - uno::Reference< text::XTextRange > xRet; + } - const SwStartNode* pStartNode = GetStartNode(); + const SwStartNode* pStartNode = m_rThis.GetStartNode(); if(!pStartNode) + { throw uno::RuntimeException(); + } + + uno::Reference< text::XTextRange > xRet; + bool bIllegalException = false; + bool bRuntimeException = false; + ::rtl::OUString sMessage; + m_pDoc->StartUndo(UNDO_START , NULL); + // find end node, go backward - don't skip tables because the new + // paragraph has to be the last node + //aPam.Move( fnMoveBackward, fnGoNode ); + SwPosition aInsertPosition( + SwNodeIndex( *pStartNode->EndOfSectionNode(), -1 ) ); + SwPaM aPam(aInsertPosition); + m_pDoc->AppendTxtNode( *aPam.GetPoint() ); + // remove attributes from the previous paragraph + m_pDoc->ResetAttrs(aPam); + // in case of finishParagraph the PaM needs to be moved to the + // previous paragraph + if (bFinish) { - bool bIllegalException = false; - bool bRuntimeException = false; - ::rtl::OUString sMessage; - pDoc->StartUndo(UNDO_START , NULL); - //find end node, go backward - don't skip tables because the new paragraph has to be the last node - //aPam.Move( fnMoveBackward, fnGoNode ); - SwPosition aInsertPosition( SwNodeIndex( *pStartNode->EndOfSectionNode(), -1 ) ); - SwPaM aPam(aInsertPosition); - pDoc->AppendTxtNode( *aPam.GetPoint() ); - //remove attributes from the previous paragraph - pDoc->ResetAttrs(aPam); - //in case of finishParagraph the PaM needs to be moved to the previous paragraph - if(bFinish) - aPam.Move( fnMoveBackward, fnGoNode ); - if(rProperties.getLength()) - { - // now set the properties - const SfxItemPropertySet* pParaPropSet = aSwMapProvider.GetPropertySet(PROPERTY_MAP_PARAGRAPH); - const SfxItemPropertyMap* pParagraphMap = pParaPropSet->getPropertyMap(); + aPam.Move( fnMoveBackward, fnGoNode ); + } + if (rProperties.getLength()) + { + // now set the properties + SfxItemPropertySet const*const pParaPropSet = + aSwMapProvider.GetPropertySet(PROPERTY_MAP_PARAGRAPH); + SfxItemPropertyMap const*const pParagraphMap = + pParaPropSet->getPropertyMap(); - const beans::PropertyValue* pValues = rProperties.getConstArray(); + const beans::PropertyValue* pValues = rProperties.getConstArray(); - for( sal_Int32 nProp = 0; nProp < rProperties.getLength(); ++nProp) + for (sal_Int32 nProp = 0; nProp < rProperties.getLength(); ++nProp) + { + if (!pParagraphMap->getByName(pValues[nProp].Name)) { - if(pParagraphMap->getByName( pValues[nProp].Name )) - { - try - { - SwUnoCursorHelper::SetPropertyValue( - aPam, *pParaPropSet, - pValues[nProp].Name, pValues[nProp].Value); - } - catch( lang::IllegalArgumentException& rIllegal ) - { - sMessage = rIllegal.Message; - bIllegalException = true; - } - catch( uno::RuntimeException& rRuntime ) - { - sMessage = rRuntime.Message; - bRuntimeException = true; - } - } - else - bIllegalException = true; - if( bIllegalException || bRuntimeException ) - { - break; - } + bIllegalException = true; + break; } - } - pDoc->EndUndo(UNDO_END, NULL); - if( bIllegalException || bRuntimeException ) - { - SwUndoIter aUndoIter( &aPam, UNDO_EMPTY ); - pDoc->Undo(aUndoIter); - if(bIllegalException) + try { - lang::IllegalArgumentException aEx; - aEx.Message = sMessage; - throw aEx; + SwUnoCursorHelper::SetPropertyValue(aPam, *pParaPropSet, + pValues[nProp].Name, pValues[nProp].Value); } - else //if(bRuntimeException) + catch (lang::IllegalArgumentException& rIllegal) { - uno::RuntimeException aEx; - aEx.Message = sMessage; - throw aEx; + sMessage = rIllegal.Message; + bIllegalException = true; + break; + } + catch (uno::RuntimeException& rRuntime) + { + sMessage = rRuntime.Message; + bRuntimeException = true; + break; } } - SwTxtNode * pTxtNode( aPam.Start()->nNode.GetNode().GetTxtNode() ); - OSL_ENSURE(pTxtNode, "no SwTxtNode?"); - if (pTxtNode) + } + m_pDoc->EndUndo(UNDO_END, NULL); + if (bIllegalException || bRuntimeException) + { + SwUndoIter aUndoIter( &aPam, UNDO_EMPTY ); + m_pDoc->Undo(aUndoIter); + if (bIllegalException) + { + lang::IllegalArgumentException aEx; + aEx.Message = sMessage; + throw aEx; + } + else // if(bRuntimeException) { - xRet.set(SwXParagraph::CreateXParagraph(*pDoc, *pTxtNode, this), uno::UNO_QUERY); + uno::RuntimeException aEx; + aEx.Message = sMessage; + throw aEx; } } + SwTxtNode *const pTxtNode( aPam.Start()->nNode.GetNode().GetTxtNode() ); + OSL_ENSURE(pTxtNode, "no SwTxtNode?"); + if (pTxtNode) + { + xRet.set(SwXParagraph::CreateXParagraph(*m_pDoc, *pTxtNode, &m_rThis), + uno::UNO_QUERY); + } return xRet; } + /*-- 08.05.2006 13:28:26--------------------------------------------------- Append text portions at the end of the last paragraph of the text interface. Support of import filters. -----------------------------------------------------------------------*/ -uno::Reference< text::XTextRange > SwXText::appendTextPortion( +uno::Reference< text::XTextRange > SAL_CALL +SwXText::appendTextPortion( const ::rtl::OUString& rText, - const uno::Sequence< beans::PropertyValue > & rCharacterAndParagraphProperties ) - throw (lang::IllegalArgumentException, uno::RuntimeException) + const uno::Sequence< beans::PropertyValue > & + rCharacterAndParagraphProperties) +throw (lang::IllegalArgumentException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + if(!IsValid()) + { throw uno::RuntimeException(); - uno::Reference< text::XTextRange > xRet; - uno::Reference< text::XTextCursor > xTextCursor = createCursor(); + } + uno::Reference< text::XTextRange > xRet; + const uno::Reference< text::XTextCursor > xTextCursor = CreateCursor(); xTextCursor->gotoEnd(sal_False); - uno::Reference< lang::XUnoTunnel > xRangeTunnel( xTextCursor, uno::UNO_QUERY_THROW ); - SwXTextCursor* pTextCursor = reinterpret_cast< SwXTextCursor * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXTextCursor::getUnoTunnelId()))); - { - bool bIllegalException = false; - bool bRuntimeException = false; - ::rtl::OUString sMessage; - pDoc->StartUndo(UNDO_INSERT, NULL); - -// SwPaM aPam(*pStartNode->EndOfSectionNode()); - //aPam.Move( fnMoveBackward, fnGoNode ); - SwUnoCrsr * pCursor = pTextCursor->GetCursor(); - pCursor->MovePara( fnParaCurr, fnParaEnd ); - pDoc->DontExpandFmt( *pCursor->Start() ); + const uno::Reference< lang::XUnoTunnel > xRangeTunnel( + xTextCursor, uno::UNO_QUERY_THROW ); + SwXTextCursor *const pTextCursor = + ::sw::UnoTunnelGetImplementation(xRangeTunnel); - if(rText.getLength()) - { - xub_StrLen nContentPos = pCursor->GetPoint()->nContent.GetIndex(); - SwUnoCursorHelper::DocInsertStringSplitCR( *pDoc, *pCursor, rText, - false ); - SwUnoCursorHelper::SelectPam(*pCursor, true); - pCursor->GetPoint()->nContent = nContentPos; - } + bool bIllegalException = false; + bool bRuntimeException = false; + ::rtl::OUString sMessage; + m_pImpl->m_pDoc->StartUndo(UNDO_INSERT, NULL); - if(rCharacterAndParagraphProperties.getLength()) +// SwPaM aPam(*pStartNode->EndOfSectionNode()); + //aPam.Move( fnMoveBackward, fnGoNode ); + SwUnoCrsr *const pCursor = pTextCursor->GetCursor(); + pCursor->MovePara( fnParaCurr, fnParaEnd ); + m_pImpl->m_pDoc->DontExpandFmt( *pCursor->Start() ); + + if (rText.getLength()) + { + const xub_StrLen nContentPos = pCursor->GetPoint()->nContent.GetIndex(); + SwUnoCursorHelper::DocInsertStringSplitCR( + *m_pImpl->m_pDoc, *pCursor, rText, false); + SwUnoCursorHelper::SelectPam(*pCursor, true); + pCursor->GetPoint()->nContent = nContentPos; + } + + if (rCharacterAndParagraphProperties.getLength()) + { + SfxItemPropertyMap const*const pCursorMap = + aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR) + ->getPropertyMap(); + beans::PropertyValue const*const pValues = + rCharacterAndParagraphProperties.getConstArray(); + SfxItemPropertySet const*const pCursorPropSet = + aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR); + const sal_Int32 nLen(rCharacterAndParagraphProperties.getLength()); + for (sal_Int32 nProp = 0; nProp < nLen; ++nProp) { - const SfxItemPropertyMap* pCursorMap = aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR)->getPropertyMap(); - const beans::PropertyValue* pValues = rCharacterAndParagraphProperties.getConstArray(); - const SfxItemPropertySet* pCursorPropSet = aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR); - for( sal_Int32 nProp = 0; nProp < rCharacterAndParagraphProperties.getLength(); ++nProp) + if (!pCursorMap->getByName( pValues[nProp].Name )) { - if( pCursorMap->getByName( pValues[nProp].Name ) ) - { - try - { - SwUnoCursorHelper::SetPropertyValue( - *pCursor, *pCursorPropSet, - pValues[nProp].Name, pValues[nProp].Value, - nsSetAttrMode::SETATTR_NOFORMATATTR); - } - catch( lang::IllegalArgumentException& rIllegal ) - { - sMessage = rIllegal.Message; - bIllegalException = true; - } - catch( uno::RuntimeException& rRuntime ) - { - sMessage = rRuntime.Message; - bRuntimeException = true; - } - } - else - bIllegalException = true; - if( bIllegalException || bRuntimeException ) - { - break; - } + bIllegalException = true; + break; } - } - pDoc->EndUndo(UNDO_INSERT, NULL); - if( bIllegalException || bRuntimeException ) - { - SwUndoIter aUndoIter( pCursor, UNDO_EMPTY ); - pDoc->Undo(aUndoIter); - delete pCursor; - pCursor = 0; - if(bIllegalException) + try { - lang::IllegalArgumentException aEx; - aEx.Message = sMessage; - throw aEx; + SwUnoCursorHelper::SetPropertyValue( + *pCursor, *pCursorPropSet, + pValues[nProp].Name, pValues[nProp].Value, + nsSetAttrMode::SETATTR_NOFORMATATTR); } - else //if(bRuntimeException) + catch( lang::IllegalArgumentException& rIllegal ) { - uno::RuntimeException aEx; - aEx.Message = sMessage; - throw aEx; + sMessage = rIllegal.Message; + bIllegalException = true; + break; } + catch( uno::RuntimeException& rRuntime ) + { + sMessage = rRuntime.Message; + bRuntimeException = true; + break; + } + } + } + m_pImpl->m_pDoc->EndUndo(UNDO_INSERT, NULL); + if (bIllegalException || bRuntimeException) + { + SwUndoIter aUndoIter( pCursor, UNDO_EMPTY ); + m_pImpl->m_pDoc->Undo(aUndoIter); + if (bIllegalException) + { + lang::IllegalArgumentException aEx; + aEx.Message = sMessage; + throw aEx; + } + else //if(bRuntimeException) + { + uno::RuntimeException aEx; + aEx.Message = sMessage; + throw aEx; } - xRet = new SwXTextRange(*pCursor, this); - delete pCursor; } - return xRet; + xRet = new SwXTextRange(*pCursor, this); + return xRet; } + /*-- 11.05.2006 15:46:26--------------------------------------------------- enable appending text contents like graphic objects, shapes and so on to support import filters -----------------------------------------------------------------------*/ -uno::Reference< text::XTextRange > SwXText::appendTextContent( +uno::Reference< text::XTextRange > SAL_CALL +SwXText::appendTextContent( const uno::Reference< text::XTextContent >& xTextContent, - const uno::Sequence< beans::PropertyValue >& rCharacterAndParagraphProperties ) - throw (lang::IllegalArgumentException, uno::RuntimeException) + const uno::Sequence< beans::PropertyValue >& + rCharacterAndParagraphProperties) +throw (lang::IllegalArgumentException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(!IsValid()) + + if (!IsValid()) + { throw uno::RuntimeException(); - const SwStartNode* pStartNode = GetStartNode(); + } + SwStartNode const*const pStartNode = GetStartNode(); if(!pStartNode) + { throw uno::RuntimeException(); + } + uno::Reference< text::XTextRange > xRet; + m_pImpl->m_pDoc->StartUndo(UNDO_INSERT, NULL); + // find end node, go backward - don't skip tables because the + // new paragraph has to be the last node + SwPaM aPam(*pStartNode->EndOfSectionNode()); + aPam.Move( fnMoveBackward, fnGoNode ); + // set cursor to the end of the last text node + SwCursor aCursor( *aPam.Start(), 0, false ); + xRet = new SwXTextRange(aCursor, this); + aCursor.MovePara( fnParaCurr, fnParaEnd ); + m_pImpl->m_pDoc->DontExpandFmt( *aCursor.Start() ); + // now attach the text content here + insertTextContent( xRet, xTextContent, false ); + // now apply the properties to the anchor + if (rCharacterAndParagraphProperties.getLength()) { - pDoc->StartUndo(UNDO_INSERT, NULL); - //find end node, go backward - don't skip tables because the new paragraph has to be the last node - SwPaM aPam(*pStartNode->EndOfSectionNode()); - aPam.Move( fnMoveBackward, fnGoNode ); - //set cursor to the end of the last text node - SwCursor* pCursor = new SwCursor( *aPam.Start(),0,false ); - xRet = new SwXTextRange(*pCursor, this); - pCursor->MovePara( fnParaCurr, fnParaEnd ); - pDoc->DontExpandFmt( *pCursor->Start() ); - //now attach the text content here - insertTextContent( xRet, xTextContent, false ); - //now apply the properties to the anchor - if( rCharacterAndParagraphProperties.getLength()) + try { - try + const sal_Int32 nLen(rCharacterAndParagraphProperties.getLength()); + const uno::Reference< beans::XPropertySet > xAnchor( + xTextContent->getAnchor(), uno::UNO_QUERY); + if (xAnchor.is()) { - uno::Reference< beans::XPropertySet > xAnchor( xTextContent->getAnchor(), uno::UNO_QUERY); - if( xAnchor.is() ) + for (sal_Int32 nElement = 0; nElement < nLen; ++nElement) { - for( sal_Int32 nElement = 0; nElement < rCharacterAndParagraphProperties.getLength(); ++nElement ) - { - xAnchor->setPropertyValue( rCharacterAndParagraphProperties[nElement].Name, rCharacterAndParagraphProperties[nElement].Value ); - } + xAnchor->setPropertyValue( + rCharacterAndParagraphProperties[nElement].Name, + rCharacterAndParagraphProperties[nElement].Value); } - - } - catch(const uno::Exception&) - { - throw uno::RuntimeException(); } } - delete pCursor; - pDoc->EndUndo(UNDO_INSERT, NULL); + catch (const uno::Exception&) + { + throw uno::RuntimeException(); + } } + m_pImpl->m_pDoc->EndUndo(UNDO_INSERT, NULL); return xRet; } // move previously appended paragraphs into a text frames // to support import filters -uno::Reference< text::XTextContent > SwXText::convertToTextFrame( +uno::Reference< text::XTextContent > SAL_CALL +SwXText::convertToTextFrame( const uno::Reference< text::XTextRange >& xStart, const uno::Reference< text::XTextRange >& xEnd, - const uno::Sequence< beans::PropertyValue >& rFrameProperties ) - throw (lang::IllegalArgumentException, uno::RuntimeException) + const uno::Sequence< beans::PropertyValue >& rFrameProperties) +throw (lang::IllegalArgumentException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + if(!IsValid()) + { throw uno::RuntimeException(); + } uno::Reference< text::XTextContent > xRet; SwUnoInternalPaM aStartPam(*GetDoc()); - std::auto_ptr < SwUnoInternalPaM > pEndPam( new SwUnoInternalPaM(*GetDoc())); - if (::sw::XTextRangeToSwPaM(aStartPam, xStart) && - ::sw::XTextRangeToSwPaM(*pEndPam, xEnd)) - { - uno::Reference xStartRangeTunnel( xStart, uno::UNO_QUERY); - SwXTextRange* pStartRange = reinterpret_cast< SwXTextRange * >( - sal::static_int_cast< sal_IntPtr >( xStartRangeTunnel->getSomething( SwXTextRange::getUnoTunnelId()) )); - uno::Reference xEndRangeTunnel( xEnd, uno::UNO_QUERY); - SwXTextRange* pEndRange = reinterpret_cast< SwXTextRange * >( - sal::static_int_cast< sal_IntPtr >( xEndRangeTunnel->getSomething( SwXTextRange::getUnoTunnelId()) )); - //bookmarks have to be removed before the referenced text node is deleted in DelFullPara - if(pStartRange) - { - pStartRange->Invalidate(); - } - if(pEndRange) - { - pEndRange->Invalidate(); - } + std::auto_ptr< SwUnoInternalPaM > pEndPam(new SwUnoInternalPaM(*GetDoc())); + if (!::sw::XTextRangeToSwPaM(aStartPam, xStart) || + !::sw::XTextRangeToSwPaM(*pEndPam, xEnd)) + { + throw lang::IllegalArgumentException(); + } - pDoc->StartUndo( UNDO_START, NULL ); - bool bIllegalException = false; - bool bRuntimeException = false; - ::rtl::OUString sMessage; - SwStartNode* pStartStartNode = aStartPam.GetNode()->StartOfSectionNode(); - while(pStartStartNode && pStartStartNode->IsSectionNode()) + const uno::Reference xStartRangeTunnel(xStart, + uno::UNO_QUERY); + SwXTextRange *const pStartRange = + ::sw::UnoTunnelGetImplementation(xStartRangeTunnel); + const uno::Reference xEndRangeTunnel(xEnd, + uno::UNO_QUERY); + SwXTextRange *const pEndRange = + ::sw::UnoTunnelGetImplementation(xEndRangeTunnel); + // bookmarks have to be removed before the referenced text node + // is deleted in DelFullPara + if (pStartRange) + { + pStartRange->Invalidate(); + } + if (pEndRange) + { + pEndRange->Invalidate(); + } + + m_pImpl->m_pDoc->StartUndo( UNDO_START, NULL ); + bool bIllegalException = false; + bool bRuntimeException = false; + ::rtl::OUString sMessage; + SwStartNode* pStartStartNode = aStartPam.GetNode()->StartOfSectionNode(); + while (pStartStartNode && pStartStartNode->IsSectionNode()) + { + pStartStartNode = pStartStartNode->StartOfSectionNode(); + } + SwStartNode* pEndStartNode = pEndPam->GetNode()->StartOfSectionNode(); + while (pEndStartNode && pEndStartNode->IsSectionNode()) + { + pEndStartNode = pEndStartNode->StartOfSectionNode(); + } + bool bParaAfterInserted = false; + bool bParaBeforeInserted = false; + if (pStartStartNode != pEndStartNode || pStartStartNode != GetStartNode()) + { + // todo: if the start/end is in a table then insert a paragraph + // before/after, move the start/end nodes, then convert and + // remove the addtional paragraphs in the end + if (pStartStartNode->GetStartNodeType() == SwTableBoxStartNode) { - pStartStartNode = pStartStartNode->StartOfSectionNode(); + SwTableNode *const pSartTableNode(pStartStartNode->FindTableNode()); + const SwNodeIndex aTblIdx( *pSartTableNode, -1 ); + SwPosition aBefore(aTblIdx); + bParaBeforeInserted = GetDoc()->AppendTxtNode( aBefore ); + aStartPam.DeleteMark(); + *aStartPam.GetPoint() = aBefore; + pStartStartNode = aStartPam.GetNode()->StartOfSectionNode(); } - SwStartNode* pEndStartNode = pEndPam->GetNode()->StartOfSectionNode(); - while(pEndStartNode && pEndStartNode->IsSectionNode()) + if (pEndStartNode->GetStartNodeType() == SwTableBoxStartNode) { - pEndStartNode = pEndStartNode->StartOfSectionNode(); + SwTableNode *const pEndTableNode = pEndStartNode->FindTableNode(); + SwEndNode *const pTableEnd = pEndTableNode->EndOfSectionNode(); + SwPosition aTableEnd(*pTableEnd); + bParaAfterInserted = GetDoc()->AppendTxtNode( aTableEnd ); + pEndPam->DeleteMark(); + *pEndPam->GetPoint() = aTableEnd; + pEndStartNode = pEndPam->GetNode()->StartOfSectionNode(); } - bool bParaAfterInserted = false; - bool bParaBeforeInserted = false; - if(pStartStartNode != pEndStartNode || pStartStartNode != GetStartNode()) + // now we should have the positions in the same hierarchy + if ((pStartStartNode != pEndStartNode) || + (pStartStartNode != GetStartNode())) { - //todo: if the start/end is in a table then insert a paragraph before/after, move - //the start/end nodes, then convert and remove the addtional paragraphs in the end - if( pStartStartNode->GetStartNodeType() == SwTableBoxStartNode ) - { - SwTableNode* pSartTableNode = pStartStartNode->FindTableNode(); - SwNodeIndex aTblIdx( *pSartTableNode, -1 ); - SwPosition aBefore(aTblIdx); - bParaBeforeInserted = GetDoc()->AppendTxtNode( aBefore ); - aStartPam.DeleteMark(); - *aStartPam.GetPoint() = aBefore; - pStartStartNode = aStartPam.GetNode()->StartOfSectionNode(); - } - if( pEndStartNode->GetStartNodeType() == SwTableBoxStartNode ) + // if not - remove the additional paragraphs and throw + if (bParaBeforeInserted) { - SwTableNode* pEndTableNode = pEndStartNode->FindTableNode(); - SwEndNode* pTableEnd = pEndTableNode->EndOfSectionNode(); - SwPosition aTableEnd(*pTableEnd); - bParaAfterInserted = GetDoc()->AppendTxtNode( aTableEnd ); - pEndPam->DeleteMark(); - *pEndPam->GetPoint() = aTableEnd; - pEndStartNode = pEndPam->GetNode()->StartOfSectionNode(); + SwCursor aDelete(*aStartPam.GetPoint(), 0, false); + aDelete.MovePara(fnParaCurr, fnParaStart); + aDelete.SetMark(); + aDelete.MovePara(fnParaCurr, fnParaEnd); + GetDoc()->DelFullPara(aDelete); } - //now we should have the positions in the same hierarchy - if(pStartStartNode != pEndStartNode || pStartStartNode != GetStartNode()) + if (bParaAfterInserted) { - //if not - remove the additional paragraphs and throw - if( bParaBeforeInserted ) - { - SwCursor aDelete(*aStartPam.GetPoint(), 0, false); - aDelete.MovePara(fnParaCurr, fnParaStart); - aDelete.SetMark(); - aDelete.MovePara(fnParaCurr, fnParaEnd); - GetDoc()->DelFullPara(aDelete); - } - if( bParaAfterInserted ) - { - SwCursor aDelete(*pEndPam->GetPoint(), 0, false); - aDelete.MovePara(fnParaCurr, fnParaStart); - aDelete.SetMark(); - aDelete.MovePara(fnParaCurr, fnParaEnd); - GetDoc()->DelFullPara(aDelete); - } - throw lang::IllegalArgumentException(); + SwCursor aDelete(*pEndPam->GetPoint(), 0, false); + aDelete.MovePara(fnParaCurr, fnParaStart); + aDelete.SetMark(); + aDelete.MovePara(fnParaCurr, fnParaEnd); + GetDoc()->DelFullPara(aDelete); } + throw lang::IllegalArgumentException(); } + } - //make a selection from aStartPam to a EndPam - SwSelBoxes aBoxes; - SfxItemSet aFrameItemSet(pDoc->GetAttrPool(), - RES_FRMATR_BEGIN, RES_FRMATR_END-1, - 0 ); + // make a selection from aStartPam to a EndPam + SwSelBoxes aBoxes; + SfxItemSet aFrameItemSet(m_pImpl->m_pDoc->GetAttrPool(), + RES_FRMATR_BEGIN, RES_FRMATR_END-1, + 0 ); - aStartPam.SetMark(); - *aStartPam.End() = *pEndPam->End(); - pEndPam.reset(0); + aStartPam.SetMark(); + *aStartPam.End() = *pEndPam->End(); + pEndPam.reset(0); - SwXTextFrame* pNewFrame; - uno::Reference< text::XTextFrame > xNewFrame = pNewFrame = new SwXTextFrame( pDoc ); - pNewFrame->SetSelection( aStartPam ); - try + SwXTextFrame *const pNewFrame = new SwXTextFrame(m_pImpl->m_pDoc); + const uno::Reference< text::XTextFrame > xNewFrame = pNewFrame; + pNewFrame->SetSelection( aStartPam ); + try + { + const beans::PropertyValue* pValues = rFrameProperties.getConstArray(); + for (sal_Int32 nProp = 0; nProp < rFrameProperties.getLength(); ++nProp) { - const beans::PropertyValue* pValues = rFrameProperties.getConstArray(); - for(sal_Int32 nProp = 0; nProp < rFrameProperties.getLength(); ++nProp) - pNewFrame->SwXFrame::setPropertyValue(pValues[nProp].Name, pValues[nProp].Value); - - {//has to be in a block to remove the SwIndexes before DelFullPara is called - uno::Reference< text::XTextRange> xInsertTextRange = new SwXTextRange(aStartPam, this); - pNewFrame->attach( xInsertTextRange ); - pNewFrame->setName(pDoc->GetUniqueFrameName()); - } + pNewFrame->SwXFrame::setPropertyValue( + pValues[nProp].Name, pValues[nProp].Value); + } - if( !aStartPam.GetTxt().Len() ) - { + { // has to be in a block to remove the SwIndexes before + // DelFullPara is called + const uno::Reference< text::XTextRange> xInsertTextRange = + new SwXTextRange(aStartPam, this); + pNewFrame->attach( xInsertTextRange ); + pNewFrame->setName(m_pImpl->m_pDoc->GetUniqueFrameName()); + } - bool bMoved = false; - {//has to be in a block to remove the SwIndexes before DelFullPara is called - SwPaM aMovePam( *aStartPam.GetNode() ); - if( aMovePam.Move( fnMoveForward, fnGoCntnt ) ) - { - //move the anchor to the next paragraph - SwFmtAnchor aNewAnchor( pNewFrame->GetFrmFmt()->GetAnchor() ); - aNewAnchor.SetAnchor( aMovePam.Start() ); - pDoc->SetAttr( aNewAnchor, *pNewFrame->GetFrmFmt() ); - } - bMoved = true; - } - if(bMoved) + if (!aStartPam.GetTxt().Len()) + { + bool bMoved = false; + { // has to be in a block to remove the SwIndexes before + // DelFullPara is called + SwPaM aMovePam( *aStartPam.GetNode() ); + if (aMovePam.Move( fnMoveForward, fnGoCntnt )) { - aStartPam.DeleteMark(); -// SwPaM aDelPam( *aStartPam.GetNode() ); - pDoc->DelFullPara(aStartPam/*aDelPam*/); + // move the anchor to the next paragraph + SwFmtAnchor aNewAnchor(pNewFrame->GetFrmFmt()->GetAnchor()); + aNewAnchor.SetAnchor( aMovePam.Start() ); + m_pImpl->m_pDoc->SetAttr( + aNewAnchor, *pNewFrame->GetFrmFmt() ); } + bMoved = true; + } + if (bMoved) + { + aStartPam.DeleteMark(); +// SwPaM aDelPam( *aStartPam.GetNode() ); + m_pImpl->m_pDoc->DelFullPara(aStartPam/*aDelPam*/); } } - catch( lang::IllegalArgumentException& rIllegal ) - { - sMessage = rIllegal.Message; - bIllegalException = true; - } - catch( uno::RuntimeException& rRuntime ) + } + catch (lang::IllegalArgumentException& rIllegal) + { + sMessage = rIllegal.Message; + bIllegalException = true; + } + catch (uno::RuntimeException& rRuntime) + { + sMessage = rRuntime.Message; + bRuntimeException = true; + } + xRet = pNewFrame; + if (bParaBeforeInserted || bParaAfterInserted) + { + const uno::Reference xFrameTextCursor = + pNewFrame->createTextCursor(); + const uno::Reference xTunnel(xFrameTextCursor, + uno::UNO_QUERY); + SwXTextCursor *const pFrameCursor = + ::sw::UnoTunnelGetImplementation(xTunnel); + if (bParaBeforeInserted) { - sMessage = rRuntime.Message; - bRuntimeException = true; + // todo: remove paragraph before frame + m_pImpl->m_pDoc->DelFullPara(*pFrameCursor->GetPaM()); } - xRet = pNewFrame; - uno::Reference xFrameTextCursor; - if( bParaBeforeInserted ) + if (bParaAfterInserted) { - //todo: remove paragraph before frame - xFrameTextCursor = pNewFrame->createTextCursor(); - uno::Reference xTunnel(xFrameTextCursor, uno::UNO_QUERY); - SwXTextCursor* pFrameCursor = reinterpret_cast< SwXTextCursor* >( - sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething(SwXTextCursor::getUnoTunnelId()) )); - pDoc->DelFullPara(*pFrameCursor->GetPaM()); + xFrameTextCursor->gotoEnd(sal_False); + m_pImpl->m_pDoc->DelFullPara(*pFrameCursor->GetPaM()); } - if( bParaAfterInserted ) + } + + m_pImpl->m_pDoc->EndUndo(UNDO_END, NULL); + if (bIllegalException || bRuntimeException) + { + SwUndoIter aUndoIter( &aStartPam, UNDO_EMPTY ); + m_pImpl->m_pDoc->Undo(aUndoIter); + if (bIllegalException) { - //todo: remove paragraph after frame - if( xFrameTextCursor.is() ) - xFrameTextCursor = pNewFrame->createTextCursor(); - xFrameTextCursor->gotoEnd( false ); - uno::Reference xTunnel(xFrameTextCursor, uno::UNO_QUERY); - SwXTextCursor* pFrameCursor = reinterpret_cast< SwXTextCursor* >( - sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething(SwXTextCursor::getUnoTunnelId()) )); - pDoc->DelFullPara(*pFrameCursor->GetPaM()); + lang::IllegalArgumentException aEx; + aEx.Message = sMessage; + throw aEx; } - - pDoc->EndUndo(UNDO_END, NULL); - if( bIllegalException || bRuntimeException ) + else //if(bRuntimeException) { - SwUndoIter aUndoIter( &aStartPam, UNDO_EMPTY ); - pDoc->Undo(aUndoIter); - if(bIllegalException) - { - lang::IllegalArgumentException aEx; - aEx.Message = sMessage; - throw aEx; - } - else //if(bRuntimeException) - { - uno::RuntimeException aEx; - aEx.Message = sMessage; - throw aEx; - } + uno::RuntimeException aEx; + aEx.Message = sMessage; + throw aEx; } } - else - throw lang::IllegalArgumentException(); return xRet; } + /*-- 11.05.2006 15:46:26--------------------------------------------------- Move previously imported paragraphs into a new text table. @@ -1788,12 +1851,15 @@ bool lcl_SimilarPosition( sal_Int32 nPos1, sal_Int32 nPos2 ) return abs( nPos1 - nPos2 ) < COL_POS_FUZZY; } -uno::Reference< text::XTextTable > SwXText::convertToTable( - const uno::Sequence< uno::Sequence< uno::Sequence< uno::Reference< text::XTextRange > > > >& rTableRanges, - const uno::Sequence< uno::Sequence< uno::Sequence< beans::PropertyValue > > >& rCellProperties, +uno::Reference< text::XTextTable > SAL_CALL +SwXText::convertToTable( + const uno::Sequence< uno::Sequence< uno::Sequence< + uno::Reference< text::XTextRange > > > >& rTableRanges, + const uno::Sequence< uno::Sequence< uno::Sequence< + beans::PropertyValue > > >& rCellProperties, const uno::Sequence< uno::Sequence< beans::PropertyValue > >& rRowProperties, - const uno::Sequence< beans::PropertyValue >& rTableProperties ) - throw (lang::IllegalArgumentException, uno::RuntimeException) + const uno::Sequence< beans::PropertyValue >& rTableProperties) +throw (lang::IllegalArgumentException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); if(!IsValid()) @@ -1804,7 +1870,7 @@ uno::Reference< text::XTextTable > SwXText::convertToTable( std::auto_ptr < SwPaM > pFirstPaM; std::vector< std::vector > aTableNodes; bool bExcept = false; - SwPaM aLastPaM(pDoc->GetNodes()); + SwPaM aLastPaM(m_pImpl->m_pDoc->GetNodes()); for( sal_Int32 nRow = 0; !bExcept && (nRow < rTableRanges.getLength()); ++nRow) { std::vector aRowNodes; @@ -1817,8 +1883,8 @@ uno::Reference< text::XTextTable > SwXText::convertToTable( throw lang::IllegalArgumentException(); const uno::Reference< text::XTextRange > xStartRange = pRow[nCell][0]; const uno::Reference< text::XTextRange > xEndRange = pRow[nCell][1]; - SwUnoInternalPaM aStartCellPam(*pDoc); - SwUnoInternalPaM aEndCellPam(*pDoc); + SwUnoInternalPaM aStartCellPam(*m_pImpl->m_pDoc); + SwUnoInternalPaM aEndCellPam(*m_pImpl->m_pDoc); // !!! TODO - PaMs in tables and sections do not work here - the same applies to PaMs in frames !!! @@ -1865,7 +1931,7 @@ uno::Reference< text::XTextTable > SwXText::convertToTable( { //align the beginning - if necessary if(aStartCellPam.Start()->nContent.GetIndex()) - pDoc->SplitNode(*aStartCellPam.Start(), sal_False); + m_pImpl->m_pDoc->SplitNode(*aStartCellPam.Start(), sal_False); } else { @@ -1880,7 +1946,7 @@ uno::Reference< text::XTextTable > SwXText::convertToTable( bExcept = true; else { - pDoc->SplitNode(*aStartCellPam.Start(), sal_False); + m_pImpl->m_pDoc->SplitNode(*aStartCellPam.Start(), sal_False); } } else if(nStartCellNodeIndex == ( nLastNodeEndIndex + 1)) @@ -1898,7 +1964,7 @@ uno::Reference< text::XTextTable > SwXText::convertToTable( //now check if there's a need to insert another paragraph break if( aEndCellPam.End()->nContent.GetIndex() < aEndCellPam.End()->nNode.GetNode().GetTxtNode()->Len()) { - pDoc->SplitNode(*aEndCellPam.End(), sal_False); + m_pImpl->m_pDoc->SplitNode(*aEndCellPam.End(), sal_False); //take care that the new start/endcell is moved to the right position //aStartCellPam has to point to the start of the new (previous) node //aEndCellPam has to point the the end of the new (previous) node @@ -1931,7 +1997,7 @@ uno::Reference< text::XTextTable > SwXText::convertToTable( if(bExcept) { SwUndoIter aUndoIter( &aLastPaM, UNDO_EMPTY ); - pDoc->Undo(aUndoIter); + m_pImpl->m_pDoc->Undo(aUndoIter); throw lang::IllegalArgumentException(); } @@ -1939,7 +2005,7 @@ uno::Reference< text::XTextTable > SwXText::convertToTable( std::vector< TableColumnSeparators > aRowSeparators(rRowProperties.getLength()); std::vector aMergedCells; - const SwTable* pTable = pDoc->TextToTable( aTableNodes ); + const SwTable* pTable = m_pImpl->m_pDoc->TextToTable( aTableNodes ); SwXTextTable* pTextTable = 0; uno::Reference< text::XTextTable > xRet = pTextTable = new SwXTextTable( *pTable->GetFrmFmt() ); uno::Reference< beans::XPropertySet > xPrSet = pTextTable; @@ -2159,12 +2225,12 @@ uno::Reference< text::XTextTable > SwXText::convertToTable( bool bIllegalException = false; bool bRuntimeException = false; ::rtl::OUString sMessage; - pDoc->StartUndo(UNDO_START, NULL); - pDoc->EndUndo(UNDO_START, NULL); + m_pImpl->m_pDoc->StartUndo(UNDO_START, NULL); + m_pImpl->m_pDoc->EndUndo(UNDO_START, NULL); if( bIllegalException || bRuntimeException ) { SwUndoIter aUndoIter( pFirstPaM.get(), UNDO_EMPTY ); - pDoc->Undo(aUndoIter); + m_pImpl->m_pDoc->Undo(aUndoIter); if(bIllegalException) { lang::IllegalArgumentException aEx; @@ -2493,7 +2559,8 @@ const SwStartNode *SwXHeadFootText::GetStartNode() const return pSttNd; } -uno::Reference< text::XTextCursor > SwXHeadFootText::createCursor() throw(uno::RuntimeException) +uno::Reference< text::XTextCursor > +SwXHeadFootText::CreateCursor() throw (uno::RuntimeException) { return createTextCursor(); } -- cgit From 150d65d3115d361f19df118c25e530d54a055937 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 8 Jan 2010 17:13:56 +0100 Subject: swunolocking1: #i105557#: clean up implementation of SwXText::convertToTable(). --- sw/source/core/unocore/unotext.cxx | 745 +++++++++++++++++++++---------------- 1 file changed, 422 insertions(+), 323 deletions(-) (limited to 'sw') diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index c45f8772a217..987f4e359752 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -123,6 +123,15 @@ public: bool CheckForOwnMember(const SwPaM & rPaM) throw (lang::IllegalArgumentException, uno::RuntimeException); + + void ConvertCell( + const bool bFirstCell, + const uno::Sequence< uno::Reference< text::XTextRange > > & rCell, + ::std::vector & rRowNodes, + ::std::auto_ptr< SwPaM > & rpFirstPaM, + SwPaM & rLastPaM, + bool & rbExcept); + }; /* -----------------------------15.03.2002 12:39------------------------------ @@ -1838,158 +1847,407 @@ struct VerticallyMergedCell sal_Int32 nLeftPosition; bool bOpen; - VerticallyMergedCell( uno::Reference< beans::XPropertySet >& rxCell, sal_Int32 nLeft ) : - nLeftPosition( nLeft ), - bOpen( true ) - { - aCells.push_back( rxCell ); - } + VerticallyMergedCell(uno::Reference< beans::XPropertySet > const& rxCell, + const sal_Int32 nLeft) + : nLeftPosition( nLeft ) + , bOpen( true ) + { + aCells.push_back( rxCell ); + } }; #define COL_POS_FUZZY 2 -bool lcl_SimilarPosition( sal_Int32 nPos1, sal_Int32 nPos2 ) +static bool lcl_SimilarPosition( const sal_Int32 nPos1, const sal_Int32 nPos2 ) { return abs( nPos1 - nPos2 ) < COL_POS_FUZZY; } -uno::Reference< text::XTextTable > SAL_CALL -SwXText::convertToTable( - const uno::Sequence< uno::Sequence< uno::Sequence< - uno::Reference< text::XTextRange > > > >& rTableRanges, - const uno::Sequence< uno::Sequence< uno::Sequence< - beans::PropertyValue > > >& rCellProperties, - const uno::Sequence< uno::Sequence< beans::PropertyValue > >& rRowProperties, - const uno::Sequence< beans::PropertyValue >& rTableProperties) -throw (lang::IllegalArgumentException, uno::RuntimeException) +void SwXText::Impl::ConvertCell( + const bool bFirstCell, + const uno::Sequence< uno::Reference< text::XTextRange > > & rCell, + ::std::vector & rRowNodes, + ::std::auto_ptr< SwPaM > & rpFirstPaM, + SwPaM & rLastPaM, + bool & rbExcept) { - vos::OGuard aGuard(Application::GetSolarMutex()); - if(!IsValid()) - throw uno::RuntimeException(); + if (rCell.getLength() != 2) + { + throw lang::IllegalArgumentException(); + } + const uno::Reference xStartRange = rCell[0]; + const uno::Reference xEndRange = rCell[1]; + SwUnoInternalPaM aStartCellPam(*m_pDoc); + SwUnoInternalPaM aEndCellPam(*m_pDoc); - //at first collect the text ranges as SwPaMs - const uno::Sequence< uno::Sequence< uno::Reference< text::XTextRange > > >* pTableRanges = rTableRanges.getConstArray(); - std::auto_ptr < SwPaM > pFirstPaM; - std::vector< std::vector > aTableNodes; - bool bExcept = false; - SwPaM aLastPaM(m_pImpl->m_pDoc->GetNodes()); - for( sal_Int32 nRow = 0; !bExcept && (nRow < rTableRanges.getLength()); ++nRow) + // !!! TODO - PaMs in tables and sections do not work here - + // the same applies to PaMs in frames !!! + + if (!::sw::XTextRangeToSwPaM(aStartCellPam, xStartRange) || + !::sw::XTextRangeToSwPaM(aEndCellPam, xEndRange)) { - std::vector aRowNodes; - const uno::Sequence< uno::Sequence< uno::Reference< text::XTextRange > > >& rRow = pTableRanges[nRow]; - const uno::Sequence< uno::Reference< text::XTextRange > >* pRow = pTableRanges[nRow].getConstArray(); + throw lang::IllegalArgumentException(); + } + /** check the nodes between start and end + it is allowed to have pairs of StartNode/EndNodes + */ + if (aStartCellPam.Start()->nNode < aEndCellPam.End()->nNode) + { + // increment on each StartNode and decrement on each EndNode + // we must reach zero at the end and must not go below zero + long nOpenNodeBlock = 0; + SwNodeIndex aCellIndex = aStartCellPam.Start()->nNode; + while (aCellIndex < aEndCellPam.End()->nNode.GetIndex()) + { + if (aCellIndex.GetNode().IsStartNode()) + { + ++nOpenNodeBlock; + } + else if (aCellIndex.GetNode().IsEndNode()) + { + --nOpenNodeBlock; + } + if (nOpenNodeBlock < 0) + { + rbExcept = true; + break; + } + ++aCellIndex; + } + if (nOpenNodeBlock != 0) + { + rbExcept = true; + return; + } + } - for( sal_Int32 nCell = 0; nCell < rRow.getLength(); ++nCell) + /** The vector NodeRanges has to contain consecutive nodes. + In rTableRanges the ranges don't need to be full paragraphs but + they have to follow each other. To process the ranges they + have to be aligned on paragraph borders by inserting paragraph + breaks. Non-consecutive ranges must initiate an exception. + */ + if (bFirstCell) + { + // align the beginning - if necessary + if (aStartCellPam.Start()->nContent.GetIndex()) { - if( pRow[nCell].getLength() != 2 ) - throw lang::IllegalArgumentException(); - const uno::Reference< text::XTextRange > xStartRange = pRow[nCell][0]; - const uno::Reference< text::XTextRange > xEndRange = pRow[nCell][1]; - SwUnoInternalPaM aStartCellPam(*m_pImpl->m_pDoc); - SwUnoInternalPaM aEndCellPam(*m_pImpl->m_pDoc); - - // !!! TODO - PaMs in tables and sections do not work here - the same applies to PaMs in frames !!! - - if (!::sw::XTextRangeToSwPaM(aStartCellPam, xStartRange) || - !::sw::XTextRangeToSwPaM(aEndCellPam, xEndRange)) - throw lang::IllegalArgumentException(); - /** check the nodes between start and end - it is allowed to have pairs of StartNode/EndNodes - */ - if(aStartCellPam.Start()->nNode < aEndCellPam.End()->nNode) + m_pDoc->SplitNode(*aStartCellPam.Start(), sal_False); + } + } + else + { + // check the predecessor + const ULONG nLastNodeIndex = rLastPaM.End()->nNode.GetIndex(); + const ULONG nStartCellNodeIndex = + aStartCellPam.Start()->nNode.GetIndex(); + const ULONG nLastNodeEndIndex = rLastPaM.End()->nNode.GetIndex(); + if (nLastNodeIndex == nStartCellNodeIndex) + { + // same node as predecessor then equal nContent? + if (rLastPaM.End()->nContent != aStartCellPam.Start()->nContent) { - // increment on each StartNode and decrement on each EndNode - // we must reach zero at the end and must not go below zero - long nOpenNodeBlock = 0; - SwNodeIndex aCellIndex = aStartCellPam.Start()->nNode; - while( aCellIndex < aEndCellPam.End()->nNode.GetIndex()) - { - if( aCellIndex.GetNode().IsStartNode() ) - ++nOpenNodeBlock; - else if(aCellIndex.GetNode().IsEndNode() ) - --nOpenNodeBlock; - if( nOpenNodeBlock < 0 ) - { - bExcept = true; - break; - } - ++aCellIndex; - } - if( nOpenNodeBlock != 0) - { - bExcept = true; - break; - } + rbExcept = true; } + else + { + m_pDoc->SplitNode(*aStartCellPam.Start(), sal_False); + } + } + else if (nStartCellNodeIndex == (nLastNodeEndIndex + 1)) + { + // next paragraph - now the content index of the new should be 0 + // and of the old one should be equal to the text length + // but if it isn't we don't care - the cell is being inserted on + // the node border anyway + } + else + { + rbExcept = true; + } + } + // now check if there's a need to insert another paragraph break + if (aEndCellPam.End()->nContent.GetIndex() < + aEndCellPam.End()->nNode.GetNode().GetTxtNode()->Len()) + { + m_pDoc->SplitNode(*aEndCellPam.End(), sal_False); + // take care that the new start/endcell is moved to the right position + // aStartCellPam has to point to the start of the new (previous) node + // aEndCellPam has to point to the end of the new (previous) node + aStartCellPam.DeleteMark(); + aStartCellPam.Move(fnMoveBackward, fnGoNode); + aStartCellPam.GetPoint()->nContent = 0; + aEndCellPam.DeleteMark(); + aEndCellPam.Move(fnMoveBackward, fnGoNode); + aEndCellPam.GetPoint()->nContent = + aEndCellPam.GetNode()->GetTxtNode()->Len(); + } + + *rLastPaM.GetPoint() = *aEndCellPam.Start(); + if (aStartCellPam.HasMark()) + { + rLastPaM.SetMark(); + *rLastPaM.GetMark() = *aEndCellPam.End(); + } + else + { + rLastPaM.DeleteMark(); + } + + SwNodeRange aCellRange(aStartCellPam.Start()->nNode, + aEndCellPam.End()->nNode); + rRowNodes.push_back(aCellRange); + if (bFirstCell) + { + rpFirstPaM.reset(new SwPaM(*aStartCellPam.Start())); + } +} + +typedef uno::Sequence< text::TableColumnSeparator > TableColumnSeparators; + +static void +lcl_ApplyRowProperties( + uno::Sequence const& rRowProperties, + uno::Any const& rRow, + TableColumnSeparators & rRowSeparators) +{ + uno::Reference< beans::XPropertySet > xRow; + rRow >>= xRow; + const beans::PropertyValue* pProperties = rRowProperties.getConstArray(); + for (sal_Int32 nProperty = 0; nProperty < rRowProperties.getLength(); + ++nProperty) + { + if (pProperties[ nProperty ].Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("TableColumnSeparators"))) + { + // add the separators to access the cell's positions + // for vertical merging later + TableColumnSeparators aSeparators; + pProperties[ nProperty ].Value >>= aSeparators; + rRowSeparators = aSeparators; + } + xRow->setPropertyValue( + pProperties[ nProperty ].Name, pProperties[ nProperty ].Value); + } +} + +#ifdef DEBUG +//-->debug cell properties of all rows +static void +lcl_DebugCellProperties( + const uno::Sequence< uno::Sequence< uno::Sequence< + beans::PropertyValue > > >& rCellProperties) +{ + ::rtl::OUString sNames; + for (sal_Int32 nDebugRow = 0; nDebugRow < rCellProperties.getLength(); + ++nDebugRow) + { + const uno::Sequence< beans::PropertyValues > aDebugCurrentRow = + rCellProperties[nDebugRow]; + sal_Int32 nDebugCells = aDebugCurrentRow.getLength(); + (void) nDebugCells; + for (sal_Int32 nDebugCell = 0; nDebugCell < nDebugCells; + ++nDebugCell) + { + const uno::Sequence< beans::PropertyValue >& + rDebugCellProperties = aDebugCurrentRow[nDebugCell]; + const sal_Int32 nDebugCellProperties = + rDebugCellProperties.getLength(); + for (sal_Int32 nDebugProperty = 0; + nDebugProperty < nDebugCellProperties; ++nDebugProperty) + { + const ::rtl::OUString sName = + rDebugCellProperties[nDebugProperty].Name; + sNames += sName; + sNames += ::rtl::OUString('-'); + } + sNames += ::rtl::OUString('+'); + } + sNames += ::rtl::OUString('|'); + } + (void)sNames; +} +//--< +#endif - /** The vector NodeRanges has to contain consecutive nodes. - In rTableRanges the ranges don't need to be full paragraphs but they have to follow - each other. To process the ranges they have to be aligned on paragraph borders - by inserting paragraph breaks. Non-consecutive ranges must initiate an - exception. - */ - if(!nRow && !nCell) +static void +lcl_ApplyCellProperties( + const sal_Int32 nCell, + TableColumnSeparators const& rRowSeparators, + const uno::Sequence< beans::PropertyValue >& rCellProperties, + uno::Reference< uno::XInterface > xCell, + ::std::vector & rMergedCells) +{ + const sal_Int32 nCellProperties = rCellProperties.getLength(); + const uno::Reference< beans::XPropertySet > xCellPS(xCell, uno::UNO_QUERY); + for (sal_Int32 nProperty = 0; nProperty < nCellProperties; ++nProperty) + { + const OUString & rName = rCellProperties[nProperty].Name; + const uno::Any & rValue = rCellProperties[nProperty].Value; + if (rName.equalsAscii("VerticalMerge")) + { + // determine left border position + // add the cell to a queue of merged cells + sal_Bool bMerge = sal_False; + rValue >>= bMerge; + sal_Int32 nLeftPos = -1; + if (!nCell) { - //align the beginning - if necessary - if(aStartCellPam.Start()->nContent.GetIndex()) - m_pImpl->m_pDoc->SplitNode(*aStartCellPam.Start(), sal_False); + nLeftPos = 0; } - else + else if (rRowSeparators.getLength() >= nCell) { - //check the predecessor - ULONG nLastNodeIndex = aLastPaM.End()->nNode.GetIndex(); - ULONG nStartCellNodeIndex = aStartCellPam.Start()->nNode.GetIndex(); - ULONG nLastNodeEndIndex = aLastPaM.End()->nNode.GetIndex(); - if( nLastNodeIndex == nStartCellNodeIndex) + const text::TableColumnSeparator* pSeparators = + rRowSeparators.getConstArray(); + nLeftPos = pSeparators[nCell - 1].Position; + } + if (bMerge) + { + // 'close' all the cell with the same left position + // if separate vertical merges in the same column exist + if (rMergedCells.size()) { - //- same node as predecessor then equal nContent? - if(aLastPaM.End()->nContent != aStartCellPam.Start()->nContent) - bExcept = true; - else + std::vector::iterator aMergedIter = + rMergedCells.begin(); + while (aMergedIter != rMergedCells.end()) { - m_pImpl->m_pDoc->SplitNode(*aStartCellPam.Start(), sal_False); + if (lcl_SimilarPosition(aMergedIter->nLeftPosition, + nLeftPos)) + { + aMergedIter->bOpen = false; + } + ++aMergedIter; } } - else if(nStartCellNodeIndex == ( nLastNodeEndIndex + 1)) - { - //next paragraph - now the content index of the new should be 0 - //and of the old one should be equal to the text length - //but if it isn't we don't care - the cell is being inserted on the - //node border anyway - } - else + // add the new group of merged cells + rMergedCells.push_back(VerticallyMergedCell(xCellPS, nLeftPos)); + } + else + { + // find the cell that + DBG_ASSERT(rMergedCells.size(), + "the first merged cell is missing"); + if (rMergedCells.size()) { - bExcept = true; + std::vector::iterator aMergedIter = + rMergedCells.begin(); +#if OSL_DEBUG_LEVEL > 1 + bool bDbgFound = false; +#endif + while (aMergedIter != rMergedCells.end()) + { + if (aMergedIter->bOpen && + lcl_SimilarPosition(aMergedIter->nLeftPosition, + nLeftPos)) + { + aMergedIter->aCells.push_back( xCellPS ); +#if OSL_DEBUG_LEVEL > 1 + bDbgFound = true; +#endif + } + ++aMergedIter; + } +#if OSL_DEBUG_LEVEL > 1 + DBG_ASSERT( bDbgFound, + "couldn't find first vertically merged cell" ); +#endif } } - //now check if there's a need to insert another paragraph break - if( aEndCellPam.End()->nContent.GetIndex() < aEndCellPam.End()->nNode.GetNode().GetTxtNode()->Len()) - { - m_pImpl->m_pDoc->SplitNode(*aEndCellPam.End(), sal_False); - //take care that the new start/endcell is moved to the right position - //aStartCellPam has to point to the start of the new (previous) node - //aEndCellPam has to point the the end of the new (previous) node - aStartCellPam.DeleteMark(); - aStartCellPam.Move(fnMoveBackward, fnGoNode); - aStartCellPam.GetPoint()->nContent = 0; - aEndCellPam.DeleteMark(); - aEndCellPam.Move(fnMoveBackward, fnGoNode); - aEndCellPam.GetPoint()->nContent = aEndCellPam.GetNode()->GetTxtNode()->Len(); - - } - - *aLastPaM.GetPoint() = *aEndCellPam.Start(); - if( aStartCellPam.HasMark() ) + } + else + { + try { - aLastPaM.SetMark(); - *aLastPaM.GetMark() = *aEndCellPam.End(); + xCellPS->setPropertyValue(rName, rValue); } - else - aLastPaM.DeleteMark(); + catch (uno::Exception const& e) + { + // Apply the paragraph and char properties to the cell's content + const uno::Reference< text::XText > xCellText(xCell, + uno::UNO_QUERY); + const uno::Reference< text::XTextCursor > xCellCurs = + xCellText->createTextCursor(); + xCellCurs->gotoStart( sal_False ); + xCellCurs->gotoEnd( sal_True ); + const uno::Reference< beans::XPropertySet > xCellTextProps( + xCellCurs, uno::UNO_QUERY); + xCellTextProps->setPropertyValue(rName, rValue); + } + } + } +} + +static void +lcl_MergeCells(::std::vector & rMergedCells) +{ + if (rMergedCells.size()) + { + std::vector::iterator aMergedIter = + rMergedCells.begin(); + while (aMergedIter != rMergedCells.end()) + { + sal_Int32 nCellCount = + static_cast(aMergedIter->aCells.size()); + std::vector >::iterator + aCellIter = aMergedIter->aCells.begin(); + bool bFirstCell = true; + // the first of the cells gets the number of cells set as RowSpan + // the others get the inverted number of remaining merged cells + // (3,-2,-1) + while (aCellIter != aMergedIter->aCells.end()) + { + (*aCellIter)->setPropertyValue( + C2U(SW_PROP_NAME_STR(UNO_NAME_ROW_SPAN)), + uno::makeAny(nCellCount)); + if (bFirstCell) + { + nCellCount *= -1; + bFirstCell = false; + } + ++nCellCount; + ++aCellIter; + } + ++aMergedIter; + } + } +} + +uno::Reference< text::XTextTable > SAL_CALL +SwXText::convertToTable( + const uno::Sequence< uno::Sequence< uno::Sequence< + uno::Reference< text::XTextRange > > > >& rTableRanges, + const uno::Sequence< uno::Sequence< uno::Sequence< + beans::PropertyValue > > >& rCellProperties, + const uno::Sequence< uno::Sequence< beans::PropertyValue > >& + rRowProperties, + const uno::Sequence< beans::PropertyValue >& rTableProperties) +throw (lang::IllegalArgumentException, uno::RuntimeException) +{ + vos::OGuard aGuard(Application::GetSolarMutex()); + + if(!IsValid()) + { + throw uno::RuntimeException(); + } + + //at first collect the text ranges as SwPaMs + const uno::Sequence< uno::Sequence< uno::Reference< text::XTextRange > > >* + pTableRanges = rTableRanges.getConstArray(); + std::auto_ptr < SwPaM > pFirstPaM; + std::vector< std::vector > aTableNodes; + bool bExcept = false; + SwPaM aLastPaM(m_pImpl->m_pDoc->GetNodes()); + for (sal_Int32 nRow = 0; !bExcept && (nRow < rTableRanges.getLength()); + ++nRow) + { + std::vector aRowNodes; + const uno::Sequence< uno::Reference< text::XTextRange > >* pRow = + pTableRanges[nRow].getConstArray(); + const sal_Int32 nCells(pTableRanges[nRow].getLength()); - SwNodeRange aCellRange( aStartCellPam.Start()->nNode, aEndCellPam.End()->nNode); - aRowNodes.push_back(aCellRange); - if( !nRow && !nCell ) - pFirstPaM.reset( new SwPaM(*aStartCellPam.Start())); + for (sal_Int32 nCell = 0; nCell < nCells; ++nCell) + { + m_pImpl->ConvertCell((nCell == 0) && (nRow == 0), pRow[nCell], + aRowNodes, pFirstPaM, aLastPaM, bExcept); } aTableNodes.push_back(aRowNodes); } @@ -2001,216 +2259,80 @@ throw (lang::IllegalArgumentException, uno::RuntimeException) throw lang::IllegalArgumentException(); } - typedef uno::Sequence< text::TableColumnSeparator > TableColumnSeparators; - std::vector< TableColumnSeparators > aRowSeparators(rRowProperties.getLength()); - std::vector aMergedCells; + std::vector< TableColumnSeparators > + aRowSeparators(rRowProperties.getLength()); + std::vector aMergedCells; - const SwTable* pTable = m_pImpl->m_pDoc->TextToTable( aTableNodes ); - SwXTextTable* pTextTable = 0; - uno::Reference< text::XTextTable > xRet = pTextTable = new SwXTextTable( *pTable->GetFrmFmt() ); - uno::Reference< beans::XPropertySet > xPrSet = pTextTable; - // set properties to the table - catch lang::WrappedTargetException and lang::IndexOutOfBoundsException + SwTable const*const pTable = m_pImpl->m_pDoc->TextToTable( aTableNodes ); + SwXTextTable *const pTextTable = new SwXTextTable( *pTable->GetFrmFmt() ); + const uno::Reference< text::XTextTable > xRet = pTextTable; + const uno::Reference< beans::XPropertySet > xPrSet = pTextTable; + // set properties to the table + // catch lang::WrappedTargetException and lang::IndexOutOfBoundsException try { //apply table properties - const beans::PropertyValue* pTableProperties = rTableProperties.getConstArray(); - sal_Int32 nProperty = 0; - for( ; nProperty < rTableProperties.getLength(); ++nProperty) + const beans::PropertyValue* pTableProperties = + rTableProperties.getConstArray(); + for (sal_Int32 nProperty = 0; nProperty < rTableProperties.getLength(); + ++nProperty) { try { - xPrSet->setPropertyValue( pTableProperties[nProperty].Name, pTableProperties[nProperty].Value ); + xPrSet->setPropertyValue( pTableProperties[nProperty].Name, + pTableProperties[nProperty].Value ); } - catch ( const uno::Exception e ) + catch ( uno::Exception const& e ) { #if DEBUG std::clog << "Exception when setting property: "; - std::clog << rtl::OUStringToOString( pTableProperties[nProperty].Name, RTL_TEXTENCODING_UTF8 ).getStr( ); + std::clog << rtl::OUStringToOString( + pTableProperties[nProperty].Name, RTL_TEXTENCODING_UTF8) + .getStr(); std::clog << ". Message: "; - std::clog << rtl::OUStringToOString( e.Message, RTL_TEXTENCODING_UTF8 ).getStr( ); + std::clog << rtl::OUStringToOString( e.Message, + RTL_TEXTENCODING_UTF8 ).getStr(); std::clog << std::endl; #endif } } //apply row properties - uno::Reference< table::XTableRows > xRows = xRet->getRows(); - const beans::PropertyValues* pRowProperties = rRowProperties.getConstArray(); - sal_Int32 nRow = 0; - for( ; nRow < xRows->getCount(); ++nRow) + const uno::Reference< table::XTableRows > xRows = xRet->getRows(); + + const beans::PropertyValues* pRowProperties = + rRowProperties.getConstArray(); + for (sal_Int32 nRow = 0; nRow < xRows->getCount(); ++nRow) { if( nRow >= rRowProperties.getLength()) { break; } - uno::Reference< beans::XPropertySet > xRow; - xRows->getByIndex( nRow ) >>= xRow; - const beans::PropertyValue* pProperties = pRowProperties[nRow].getConstArray(); - for( nProperty = 0; nProperty < pRowProperties[nRow].getLength(); ++nProperty) - { - if( pProperties[ nProperty ].Name.equalsAsciiL( - RTL_CONSTASCII_STRINGPARAM ( "TableColumnSeparators" ))) - { - //add the separators to access the cell's positions for vertical merging later - TableColumnSeparators aSeparators; - pProperties[ nProperty ].Value >>= aSeparators; - aRowSeparators[nRow] = aSeparators; - } - xRow->setPropertyValue( pProperties[ nProperty ].Name, pProperties[ nProperty ].Value ); - } + lcl_ApplyRowProperties(pRowProperties[nRow], + xRows->getByIndex(nRow), aRowSeparators[nRow]); } #ifdef DEBUG -//-->debug cell properties of all rows - { - ::rtl::OUString sNames; - for( sal_Int32 nDebugRow = 0; nDebugRow < rCellProperties.getLength(); ++nDebugRow) - { - const uno::Sequence< beans::PropertyValues > aDebugCurrentRow = rCellProperties[nDebugRow]; - sal_Int32 nDebugCells = aDebugCurrentRow.getLength(); - (void) nDebugCells; - for( sal_Int32 nDebugCell = 0; nDebugCell < nDebugCells; ++nDebugCell) - { - const uno::Sequence< beans::PropertyValue >& aDebugCellProperties = aDebugCurrentRow[nDebugCell]; - sal_Int32 nDebugCellProperties = aDebugCellProperties.getLength(); - for( sal_Int32 nDebugProperty = 0; nDebugProperty < nDebugCellProperties; ++nDebugProperty) - { - const ::rtl::OUString sName = aDebugCellProperties[nDebugProperty].Name; - sNames += sName; - sNames += ::rtl::OUString('-'); - } - sNames += ::rtl::OUString('+'); - } - sNames += ::rtl::OUString('|'); - } - (void)sNames; - } -//--< + lcl_DebugCellProperties(rCellProperties); #endif - //apply cell properties - for( nRow = 0; nRow < rCellProperties.getLength(); ++nRow) + for (sal_Int32 nRow = 0; nRow < rCellProperties.getLength(); ++nRow) { - const uno::Sequence< beans::PropertyValues > aCurrentRow = rCellProperties[nRow]; + const uno::Sequence< beans::PropertyValues > aCurrentRow = + rCellProperties[nRow]; sal_Int32 nCells = aCurrentRow.getLength(); - for( sal_Int32 nCell = 0; nCell < nCells; ++nCell) - { - const uno::Sequence< beans::PropertyValue >& aCellProperties = aCurrentRow[nCell]; - sal_Int32 nCellProperties = aCellProperties.getLength(); - uno::Reference< beans::XPropertySet > xCell( pTextTable->getCellByPosition(nCell, nRow), uno::UNO_QUERY ); - for( nProperty = 0; nProperty < nCellProperties; ++nProperty) - { - const OUString& rName = aCellProperties[nProperty].Name; - if( rName.equalsAsciiL( - RTL_CONSTASCII_STRINGPARAM ( "VerticalMerge"))) - { - //determine left border position - //add the cell to a queue of merged cells - // - sal_Bool bMerge = sal_False; - aCellProperties[nProperty].Value >>= bMerge; - sal_Int32 nLeftPos = -1; - if( !nCell ) - nLeftPos = 0; - else if( aRowSeparators[nRow].getLength() >= nCell ) - { - const text::TableColumnSeparator* pSeparators = aRowSeparators[nRow].getConstArray(); - nLeftPos = pSeparators[nCell - 1].Position; - } - if( bMerge ) - { - // 'close' all the cell with the same left position - // if separate vertical merges in the same column exist - if( aMergedCells.size() ) - { - std::vector::iterator aMergedIter = aMergedCells.begin(); - while( aMergedIter != aMergedCells.end()) - { - if( lcl_SimilarPosition( aMergedIter->nLeftPosition, nLeftPos) ) - { - aMergedIter->bOpen = false; - } - ++aMergedIter; - } - } - //add the new group of merged cells - aMergedCells.push_back(VerticallyMergedCell(xCell, nLeftPos )); - } - else - { - //find the cell that - DBG_ASSERT(aMergedCells.size(), "the first merged cell is missing"); - if( aMergedCells.size() ) - { - std::vector::iterator aMergedIter = aMergedCells.begin(); -#if OSL_DEBUG_LEVEL > 1 - bool bDbgFound = false; -#endif - while( aMergedIter != aMergedCells.end()) - { - if( aMergedIter->bOpen && - lcl_SimilarPosition( aMergedIter->nLeftPosition, nLeftPos) ) - { - aMergedIter->aCells.push_back( xCell ); -#if OSL_DEBUG_LEVEL > 1 - bDbgFound = true; -#endif - } - ++aMergedIter; - } -#if OSL_DEBUG_LEVEL > 1 - DBG_ASSERT( bDbgFound, "couldn't find first vertically merged cell" ); -#endif - } - } - } - else - { - try - { - xCell->setPropertyValue(rName, aCellProperties[nProperty].Value); - } - catch ( const uno::Exception e ) - { - // Apply the paragraph and char properties to the cell's content - uno::Reference< text::XText > xCellText( xCell, uno::UNO_QUERY ); - uno::Reference< text::XTextCursor > xCellCurs = xCellText->createTextCursor( ); - xCellCurs->gotoStart( false ); - xCellCurs->gotoEnd( true ); - - uno::Reference< beans::XPropertySet > xCellTextProps( xCellCurs, uno::UNO_QUERY ); - xCellTextProps->setPropertyValue( rName, aCellProperties[nProperty].Value ); - } - } - } - } - } - //now that the cell properties are set the vertical merge values have to be applied - if( aMergedCells.size() ) - { - std::vector::iterator aMergedIter = aMergedCells.begin(); - while( aMergedIter != aMergedCells.end()) + for (sal_Int32 nCell = 0; nCell < nCells; ++nCell) { - sal_Int32 nCellCount = (sal_Int32)aMergedIter->aCells.size(); - std::vector >::iterator aCellIter = aMergedIter->aCells.begin(); - bool bFirstCell = true; - //the first of the cells get's the number of cells set as RowSpan - //the others get the inverted number of remaining merged cells (3,-2,-1) - while( aCellIter != aMergedIter->aCells.end() ) - { - (*aCellIter)->setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_ROW_SPAN)), uno::makeAny( nCellCount )); - if( bFirstCell ) - { - nCellCount *= -1; - bFirstCell = false; - } - ++nCellCount; - ++aCellIter; - } - ++aMergedIter; + lcl_ApplyCellProperties(nCell, + aRowSeparators[nRow], aCurrentRow[nCell], + pTextTable->getCellByPosition(nCell, nRow), + aMergedCells); } } + // now that the cell properties are set the vertical merge values + // have to be applied + lcl_MergeCells(aMergedCells); } catch( const lang::WrappedTargetException& rWrapped ) { @@ -2221,29 +2343,6 @@ throw (lang::IllegalArgumentException, uno::RuntimeException) (void)rBounds; } - - bool bIllegalException = false; - bool bRuntimeException = false; - ::rtl::OUString sMessage; - m_pImpl->m_pDoc->StartUndo(UNDO_START, NULL); - m_pImpl->m_pDoc->EndUndo(UNDO_START, NULL); - if( bIllegalException || bRuntimeException ) - { - SwUndoIter aUndoIter( pFirstPaM.get(), UNDO_EMPTY ); - m_pImpl->m_pDoc->Undo(aUndoIter); - if(bIllegalException) - { - lang::IllegalArgumentException aEx; - aEx.Message = sMessage; - throw aEx; - } - else //if(bRuntimeException) - { - uno::RuntimeException aEx; - aEx.Message = sMessage; - throw aEx; - } - } return xRet; } -- cgit From 3356582b67bb91d6d438cbf356527a928070d7fa Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 8 Jan 2010 17:13:56 +0100 Subject: swunolocking1: #i105557#: fix locking for SwXBodyText: use new XServiceInfo helpers. clean up the implementation a little. --- sw/inc/unotextbodyhf.hxx | 2 +- sw/source/core/unocore/unotext.cxx | 145 ++++++++++++++++++++----------------- 2 files changed, 80 insertions(+), 67 deletions(-) (limited to 'sw') diff --git a/sw/inc/unotextbodyhf.hxx b/sw/inc/unotextbodyhf.hxx index 98656ca68c29..15c38044e4ff 100644 --- a/sw/inc/unotextbodyhf.hxx +++ b/sw/inc/unotextbodyhf.hxx @@ -64,7 +64,7 @@ protected: public: - SwXBodyText(SwDoc* pDoc); + SwXBodyText(SwDoc *const pDoc); SwXTextCursor * CreateTextCursor(const bool bIgnoreTables = false); diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index 987f4e359752..03bdaba7e6c4 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -36,9 +36,11 @@ #include #include +#include + #include #include -#include +#include #include #include @@ -2349,8 +2351,8 @@ throw (lang::IllegalArgumentException, uno::RuntimeException) /****************************************************************** * SwXBodyText ******************************************************************/ -SwXBodyText::SwXBodyText(SwDoc* _pDoc) : - SwXText(_pDoc, CURSOR_BODY) +SwXBodyText::SwXBodyText(SwDoc *const pDoc) + : SwXText(pDoc, CURSOR_BODY) { } @@ -2364,82 +2366,81 @@ SwXBodyText::~SwXBodyText() /* -----------------------------06.04.00 16:33-------------------------------- ---------------------------------------------------------------------------*/ -OUString SwXBodyText::getImplementationName(void) throw( uno::RuntimeException ) +OUString SAL_CALL +SwXBodyText::getImplementationName() throw (uno::RuntimeException) { return C2U("SwXBodyText"); } /* -----------------------------06.04.00 16:33-------------------------------- ---------------------------------------------------------------------------*/ -BOOL SwXBodyText::supportsService(const OUString& rServiceName) throw( uno::RuntimeException ) +static char const*const g_ServicesBodyText[] = { - return C2U("com.sun.star.text.Text") == rServiceName; + "com.sun.star.text.Text", +}; +static const size_t g_nServicesBodyText( + sizeof(g_ServicesBodyText)/sizeof(g_ServicesBodyText[0])); + +sal_Bool SAL_CALL SwXBodyText::supportsService(const OUString& rServiceName) +throw (uno::RuntimeException) +{ + return ::sw::SupportsServiceImpl( + g_nServicesBodyText, g_ServicesBodyText, rServiceName); } -/* -----------------------------06.04.00 16:33-------------------------------- - ---------------------------------------------------------------------------*/ -uno::Sequence< OUString > SwXBodyText::getSupportedServiceNames(void) throw( uno::RuntimeException ) +uno::Sequence< OUString > SAL_CALL +SwXBodyText::getSupportedServiceNames() throw (uno::RuntimeException) { - uno::Sequence< OUString > aRet(1); - OUString* pArray = aRet.getArray(); - pArray[0] = C2U("com.sun.star.text.Text"); - return aRet; + return ::sw::GetSupportedServiceNamesImpl( + g_nServicesBodyText, g_ServicesBodyText); } + /*-- 10.12.98 11:17:27--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Any SwXBodyText::queryAggregation( - const uno::Type& rType ) - throw(uno::RuntimeException) +uno::Any SAL_CALL +SwXBodyText::queryAggregation(const uno::Type& rType) +throw (uno::RuntimeException) { uno::Any aRet; - const uno::Type& rXEnumerationAccessType = ::getCppuType((uno::Reference< container::XEnumerationAccess >*)0); - const uno::Type& rXElementAccessType = ::getCppuType((uno::Reference< container::XElementAccess >*)0); - const uno::Type& rXServiceInfoType = ::getCppuType((uno::Reference< lang::XServiceInfo >*)0); - - if(rType == rXEnumerationAccessType) + if (rType == container::XEnumerationAccess::static_type()) { - uno::Reference xRet = this; - aRet.setValue(&xRet, rXEnumerationAccessType); + aRet <<= uno::Reference< container::XEnumerationAccess >(this); } - else if(rType == rXElementAccessType) + else if (rType == container::XElementAccess::static_type()) { - uno::Reference xRet = this; - aRet.setValue(&xRet, rXElementAccessType); + aRet <<= uno::Reference< container::XElementAccess >(this); } - else if(rType == rXServiceInfoType) + else if (rType == lang::XServiceInfo::static_type()) { - uno::Reference xRet = this; - aRet.setValue(&xRet, rXServiceInfoType); + aRet <<= uno::Reference< lang::XServiceInfo >(this); } else { aRet = SwXText::queryInterface( rType ); } if(aRet.getValueType() == ::getCppuVoidType()) + { aRet = OWeakAggObject::queryAggregation( rType ); + } return aRet; } /*-- 10.12.98 11:17:28--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Sequence< uno::Type > SwXBodyText::getTypes( ) throw(uno::RuntimeException) +uno::Sequence< uno::Type > SAL_CALL +SwXBodyText::getTypes() throw (uno::RuntimeException) { - uno::Sequence< uno::Type > aTypes = SwXBodyText_Base::getTypes(); - uno::Sequence< uno::Type > aTextTypes = SwXText::getTypes(); - long nIndex = aTypes.getLength(); - aTypes.realloc(aTypes.getLength() + aTextTypes.getLength()); - uno::Type* pTypes = aTypes.getArray(); - const uno::Type* pTextTypes = aTextTypes.getConstArray(); - for(int i = 0; i < aTextTypes.getLength(); i++) - pTypes[nIndex++] = pTextTypes[i]; - return aTypes; + const uno::Sequence< uno::Type > aTypes = SwXBodyText_Base::getTypes(); + const uno::Sequence< uno::Type > aTextTypes = SwXText::getTypes(); + return ::comphelper::concatSequences(aTypes, aTextTypes); } /* -----------------------------21.03.00 15:39-------------------------------- ---------------------------------------------------------------------------*/ -uno::Sequence< sal_Int8 > SwXBodyText::getImplementationId( ) throw(uno::RuntimeException) +uno::Sequence< sal_Int8 > SAL_CALL +SwXBodyText::getImplementationId() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); static uno::Sequence< sal_Int8 > aId( 16 ); @@ -2497,7 +2498,8 @@ SwXTextCursor * SwXBodyText::CreateTextCursor(const bool bIgnoreTables) /*-- 10.12.98 11:17:29--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextCursor > SwXBodyText::createTextCursor(void) throw( uno::RuntimeException ) +uno::Reference< text::XTextCursor > SAL_CALL +SwXBodyText::createTextCursor() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); @@ -2514,19 +2516,23 @@ uno::Reference< text::XTextCursor > SwXBodyText::createTextCursor(void) throw( /*-- 10.12.98 11:17:29--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextCursor > SwXBodyText::createTextCursorByRange( - const uno::Reference< text::XTextRange > & aTextPosition) throw( uno::RuntimeException ) +uno::Reference< text::XTextCursor > SAL_CALL +SwXBodyText::createTextCursorByRange( + const uno::Reference< text::XTextRange > & xTextPosition) +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< text::XTextCursor > aRef; + if(!IsValid()) { uno::RuntimeException aRuntime; aRuntime.Message = C2U(cInvalidObject); throw aRuntime; } + + uno::Reference< text::XTextCursor > aRef; SwUnoInternalPaM aPam(*GetDoc()); - if (::sw::XTextRangeToSwPaM(aPam, aTextPosition)) + if (::sw::XTextRangeToSwPaM(aPam, xTextPosition)) { SwNode& rNode = GetDoc()->GetNodes().GetEndOfContent(); @@ -2536,7 +2542,7 @@ uno::Reference< text::XTextCursor > SwXBodyText::createTextCursorByRange( { p1 = p1->StartOfSectionNode(); } - SwStartNode* p2 = rNode.StartOfSectionNode(); + SwStartNode *const p2 = rNode.StartOfSectionNode(); if(p1 == p2) { @@ -2546,57 +2552,64 @@ uno::Reference< text::XTextCursor > SwXBodyText::createTextCursorByRange( } } if(!aRef.is()) + { throw uno::RuntimeException(); + } return aRef; } + /*-- 10.12.98 11:17:30--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< container::XEnumeration > SwXBodyText::createEnumeration(void) - throw( uno::RuntimeException ) +uno::Reference< container::XEnumeration > SAL_CALL +SwXBodyText::createEnumeration() +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< container::XEnumeration > aRef; - if(IsValid()) - { - SwNode& rNode = GetDoc()->GetNodes().GetEndOfContent(); - SwPosition aPos(rNode); - ::std::auto_ptr pUnoCursor( - GetDoc()->CreateUnoCrsr(aPos, sal_False)); - pUnoCursor->Move(fnMoveBackward, fnGoDoc); - aRef = new SwXParagraphEnumeration(this, pUnoCursor, CURSOR_BODY); - } - else + + if (!IsValid()) { uno::RuntimeException aRuntime; aRuntime.Message = C2U(cInvalidObject); throw aRuntime; } - return aRef; + SwNode& rNode = GetDoc()->GetNodes().GetEndOfContent(); + SwPosition aPos(rNode); + ::std::auto_ptr pUnoCursor( + GetDoc()->CreateUnoCrsr(aPos, sal_False)); + pUnoCursor->Move(fnMoveBackward, fnGoDoc); + const uno::Reference< container::XEnumeration > xRet + = new SwXParagraphEnumeration(this, pUnoCursor, CURSOR_BODY); + return xRet; } + /* -----------------18.12.98 13:36------------------- * * --------------------------------------------------*/ -uno::Type SwXBodyText::getElementType(void) throw( uno::RuntimeException ) +uno::Type SAL_CALL +SwXBodyText::getElementType() throw (uno::RuntimeException) { - return ::getCppuType((uno::Reference*)0); + return text::XTextRange::static_type(); } /* -----------------18.12.98 13:36------------------- * * --------------------------------------------------*/ -sal_Bool SwXBodyText::hasElements(void) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXBodyText::hasElements() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(IsValid()) - return sal_True; - else + + if (!IsValid()) { uno::RuntimeException aRuntime; aRuntime.Message = C2U(cInvalidObject); throw aRuntime; } + + return sal_True; } + /****************************************************************** * SwXHeadFootText ******************************************************************/ -- cgit From 069dead98a0b185ff521a31ed26dd81d98a91b7c Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 8 Jan 2010 17:13:57 +0100 Subject: swunolocking1: #i105557#: fix locking for SwXHeadFootText: add Impl struct, and use UnoImplPtr to lock destructor. move all implementation details out of header, into Impl struct. replace broken SwClient iteration with a WeakReference in SwFrmFmt. make constructor protected, and add factory function CreateXHeadFootText. use new XUnoTunnel and XServiceInfo helpers. clean up the implementation a little. --- sw/inc/unotextbodyhf.hxx | 18 +- sw/source/core/layout/atrfrm.cxx | 3 +- sw/source/core/unocore/unoobj2.cxx | 13 +- sw/source/core/unocore/unostyle.cxx | 53 +++--- sw/source/core/unocore/unotext.cxx | 331 +++++++++++++++++++++--------------- 5 files changed, 242 insertions(+), 176 deletions(-) (limited to 'sw') diff --git a/sw/inc/unotextbodyhf.hxx b/sw/inc/unotextbodyhf.hxx index 15c38044e4ff..8fd4e8c2a442 100644 --- a/sw/inc/unotextbodyhf.hxx +++ b/sw/inc/unotextbodyhf.hxx @@ -38,8 +38,6 @@ #include -#include -#include #include @@ -136,13 +134,12 @@ typedef ::cppu::WeakImplHelper2 class SwXHeadFootText : public SwXHeadFootText_Base , public SwXText - , public SwClient { private: - SwFrmFmt* GetFmt() const { return (SwFrmFmt*)GetRegisteredIn(); } - BOOL bIsHeader; + class Impl; + ::sw::UnoImplPtr m_pImpl; protected: @@ -154,14 +151,13 @@ protected: virtual ~SwXHeadFootText(); -public: - - SwXHeadFootText(SwFrmFmt& rHeadFootFmt, BOOL bHeader); + SwXHeadFootText(SwFrmFmt & rHeadFootFmt, const bool bIsHeader); - TYPEINFO(); +public: - // SwClient - virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + static ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > + CreateXHeadFootText(SwFrmFmt & rHeadFootFmt, const bool bIsHeader); + static bool IsXHeadFootText(SwClient *const pClient); // XInterface virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx index 061826e764f0..9ed5687b075a 100644 --- a/sw/source/core/layout/atrfrm.cxx +++ b/sw/source/core/layout/atrfrm.cxx @@ -198,7 +198,8 @@ void DelHFFormat( SwClient *pToRemove, SwFrmFmt *pFmt ) SwClient *pLast = aIter.GoStart(); if( pLast ) do { - bDel = pLast->IsA( TYPE(SwFrm) )|| pLast->IsA(TYPE(SwXHeadFootText)); + bDel = pLast->IsA( TYPE(SwFrm) ) + || SwXHeadFootText::IsXHeadFootText(pLast); } while( bDel && 0 != ( pLast = aIter++ )); } diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index 857638d872dc..918ab49d45f0 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -1317,17 +1317,10 @@ CreateParentXText(SwDoc & rDoc, const SwPosition& rPos) pHeadFootFmt); } - if(pHeadFootFmt) + if (pHeadFootFmt) { - SwXHeadFootText* pxHdFt = (SwXHeadFootText*)SwClientIter( *pHeadFootFmt ). - First( TYPE( SwXHeadFootText )); - xParentText = pxHdFt; - if(!pxHdFt) - { - xParentText = - new SwXHeadFootText(*pHeadFootFmt, bHeader); - } - break; + xParentText = SwXHeadFootText::CreateXHeadFootText( + *pHeadFootFmt, bHeader); } } } diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index 1866613e8ab0..940c454b7401 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -3436,6 +3436,29 @@ void SwXPageStyle::setPropertyValues( /* -----------------------------04.11.03 13:50-------------------------------- ---------------------------------------------------------------------------*/ +static uno::Reference +lcl_makeHeaderFooter( + const sal_uInt16 nRes, const bool bHeader, SwFrmFmt const*const pFrmFmt) +{ + if (!pFrmFmt) { return 0; } + + const SfxItemSet& rSet = pFrmFmt->GetAttrSet(); + const SfxPoolItem* pItem; + if (SFX_ITEM_SET == rSet.GetItemState(nRes, sal_True, &pItem)) + { + SwFrmFmt *const pHeadFootFmt = (bHeader) + ? static_cast(const_cast(pItem))-> + GetHeaderFmt() + : static_cast(const_cast(pItem))-> + GetFooterFmt(); + if (pHeadFootFmt) + { + return SwXHeadFootText::CreateXHeadFootText(*pHeadFootFmt, bHeader); + } + } + return 0; +} + uno::Sequence< uno::Any > SAL_CALL SwXPageStyle::GetPropertyValues_Impl( const uno::Sequence< OUString >& rPropertyNames ) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) @@ -3468,7 +3491,8 @@ uno::Sequence< uno::Any > SAL_CALL SwXPageStyle::GetPropertyValues_Impl( GetBasePool()->SetSearchMask(GetFamily(), nSaveMask ); } sal_uInt16 nRes = 0; - sal_Bool bHeader = sal_False, bAll = sal_False, bLeft = sal_False, bRight = sal_False; + bool bHeader = false; + sal_Bool bAll = sal_False, bLeft = sal_False, bRight = sal_False; switch(pEntry->nWID) { case FN_UNO_HEADER_ON: @@ -3574,7 +3598,7 @@ uno::Sequence< uno::Any > SAL_CALL SwXPageStyle::GetPropertyValues_Impl( case FN_UNO_HEADER_RIGHT : bRight = sal_True; goto Header; Header: - bHeader = sal_True; + bHeader = true; nRes = RES_HEADER; goto MakeObject; case FN_UNO_FOOTER : bAll = sal_True; goto Footer; @@ -3595,27 +3619,18 @@ MakeObject: // TextRight does the same as Text and is for // comptability only. if( bLeft && !bShare ) + { pFrmFmt = &rDesc.GetLeft(); + } else + { pFrmFmt = &rDesc.GetMaster(); - if(pFrmFmt) + } + const uno::Reference< text::XText > xRet = + lcl_makeHeaderFooter(nRes, bHeader, pFrmFmt); + if (xRet.is()) { - const SfxItemSet& rSet = pFrmFmt->GetAttrSet(); - const SfxPoolItem* pItem; - SwFrmFmt* pHeadFootFmt; - if(SFX_ITEM_SET == rSet.GetItemState(nRes, sal_True, &pItem) && - 0 != (pHeadFootFmt = bHeader ? - ((SwFmtHeader*)pItem)->GetHeaderFmt() : - ((SwFmtFooter*)pItem)->GetFooterFmt())) - { - // gibt es schon ein Objekt dafuer? - SwXHeadFootText* pxHdFt = (SwXHeadFootText*)SwClientIter( *pHeadFootFmt ). - First( TYPE( SwXHeadFootText )); - uno::Reference< text::XText > xRet = pxHdFt; - if(!pxHdFt) - xRet = new SwXHeadFootText(*pHeadFootFmt, bHeader); - pRet[nProp].setValue(&xRet, ::getCppuType((uno::Reference*)0)); - } + pRet[nProp] <<= xRet; } } break; diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index 03bdaba7e6c4..4fb2a861be21 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -2613,60 +2613,136 @@ SwXBodyText::hasElements() throw (uno::RuntimeException) /****************************************************************** * SwXHeadFootText ******************************************************************/ -TYPEINIT1(SwXHeadFootText, SwClient); -/* -----------------------------06.04.00 16:40-------------------------------- - ---------------------------------------------------------------------------*/ -OUString SwXHeadFootText::getImplementationName(void) throw( uno::RuntimeException ) +class SwXHeadFootText::Impl + : public SwClient { - return C2U("SwXHeadFootText"); + +public: + + bool m_bIsHeader; + + Impl( SwXHeadFootText & /*rThis*/, + SwFrmFmt & rHeadFootFmt, const bool bIsHeader) + : SwClient(& rHeadFootFmt) + , m_bIsHeader(bIsHeader) + { + } + + SwFrmFmt * GetHeadFootFmt() const { + return static_cast( + const_cast(GetRegisteredIn())); + } + + SwFrmFmt & GetHeadFootFmtOrThrow() { + SwFrmFmt *const pFmt( GetHeadFootFmt() ); + if (!pFmt) { + throw uno::RuntimeException(OUString(RTL_CONSTASCII_USTRINGPARAM( + "SwXHeadFootText: disposed or invalid")), 0); + } + return *pFmt; + } + + // SwClient + virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + +}; + +/*-- 11.12.98 10:14:51--------------------------------------------------- + + -----------------------------------------------------------------------*/ +void SwXHeadFootText::Impl::Modify(SfxPoolItem *pOld, SfxPoolItem *pNew) +{ + ClientModify(this, pOld, pNew); } -/* -----------------------------06.04.00 16:40-------------------------------- - ---------------------------------------------------------------------------*/ -BOOL SwXHeadFootText::supportsService(const OUString& rServiceName) throw( uno::RuntimeException ) +bool SwXHeadFootText::IsXHeadFootText(SwClient *const pClient) { - return C2U("com.sun.star.text.Text") == rServiceName; + return 0 != dynamic_cast(pClient); } -/* -----------------------------06.04.00 16:40-------------------------------- - ---------------------------------------------------------------------------*/ -uno::Sequence< OUString > SwXHeadFootText::getSupportedServiceNames(void) throw( uno::RuntimeException ) +uno::Reference< text::XText > +SwXHeadFootText::CreateXHeadFootText( + SwFrmFmt & rHeadFootFmt, const bool bIsHeader) { - uno::Sequence< OUString > aRet(1); - OUString* pArray = aRet.getArray(); - pArray[0] = C2U("com.sun.star.text.Text"); - return aRet; + // re-use existing SwXHeadFootText + // #i105557#: do not iterate over the registered clients: race condition + uno::Reference< text::XText > xText(rHeadFootFmt.GetXObject(), + uno::UNO_QUERY); + if (!xText.is()) + { + SwXHeadFootText *const pXHFT( + new SwXHeadFootText(rHeadFootFmt, bIsHeader)); + xText.set(pXHFT); + rHeadFootFmt.SetXObject(xText); + } + return xText; } + /*-- 11.12.98 10:14:48--------------------------------------------------- -----------------------------------------------------------------------*/ -SwXHeadFootText::SwXHeadFootText(SwFrmFmt& rHeadFootFmt, BOOL bHeader) : - SwXText(rHeadFootFmt.GetDoc(), bHeader ? CURSOR_HEADER : CURSOR_FOOTER), - SwClient(&rHeadFootFmt), - bIsHeader(bHeader) +SwXHeadFootText::SwXHeadFootText(SwFrmFmt & rHeadFootFmt, const bool bIsHeader) + : SwXText(rHeadFootFmt.GetDoc(), + (bIsHeader) ? CURSOR_HEADER : CURSOR_FOOTER) + , m_pImpl( new SwXHeadFootText::Impl(*this, rHeadFootFmt, bIsHeader) ) { - } + /*-- 11.12.98 10:14:48--------------------------------------------------- -----------------------------------------------------------------------*/ SwXHeadFootText::~SwXHeadFootText() { +} + +/* -----------------------------06.04.00 16:40-------------------------------- + + ---------------------------------------------------------------------------*/ +OUString SAL_CALL +SwXHeadFootText::getImplementationName() throw (uno::RuntimeException) +{ + return C2U("SwXHeadFootText"); +} + +/* -----------------------------06.04.00 16:40-------------------------------- + + ---------------------------------------------------------------------------*/ +static char const*const g_ServicesHeadFootText[] = +{ + "com.sun.star.text.Text", +}; +static const size_t g_nServicesHeadFootText( + sizeof(g_ServicesHeadFootText)/sizeof(g_ServicesHeadFootText[0])); + +sal_Bool SAL_CALL SwXHeadFootText::supportsService(const OUString& rServiceName) +throw (uno::RuntimeException) +{ + return ::sw::SupportsServiceImpl( + g_nServicesHeadFootText, g_ServicesHeadFootText, rServiceName); +} +uno::Sequence< OUString > SAL_CALL +SwXHeadFootText::getSupportedServiceNames() throw (uno::RuntimeException) +{ + return ::sw::GetSupportedServiceNamesImpl( + g_nServicesHeadFootText, g_ServicesHeadFootText); } + /*-- 11.12.98 10:14:49--------------------------------------------------- -----------------------------------------------------------------------*/ const SwStartNode *SwXHeadFootText::GetStartNode() const { const SwStartNode *pSttNd = 0; - SwFrmFmt* pHeadFootFmt = GetFmt(); + SwFrmFmt *const pHeadFootFmt = m_pImpl->GetHeadFootFmt(); if(pHeadFootFmt) { const SwFmtCntnt& rFlyCntnt = pHeadFootFmt->GetCntnt(); if( rFlyCntnt.GetCntntIdx() ) + { pSttNd = rFlyCntnt.GetCntntIdx()->GetNode().GetStartNode(); + } } return pSttNd; } @@ -2679,28 +2755,19 @@ SwXHeadFootText::CreateCursor() throw (uno::RuntimeException) /* -----------------------------21.03.00 15:39-------------------------------- ---------------------------------------------------------------------------*/ -uno::Sequence< uno::Type > SwXHeadFootText::getTypes( ) throw(uno::RuntimeException) +uno::Sequence< uno::Type > SAL_CALL +SwXHeadFootText::getTypes() throw (uno::RuntimeException) { - uno::Sequence< uno::Type > aHFTypes = SwXHeadFootText_Base::getTypes(); - uno::Sequence< uno::Type > aTextTypes = SwXText::getTypes(); - - long nIndex = aHFTypes.getLength(); - aHFTypes.realloc( - aHFTypes.getLength() + - aTextTypes.getLength()); - - uno::Type* pHFTypes = aHFTypes.getArray(); - const uno::Type* pTextTypes = aTextTypes.getConstArray(); - for(long nPos = 0; nPos < aTextTypes.getLength(); nPos++) - pHFTypes[nIndex++] = pTextTypes[nPos]; - - return aHFTypes; + const uno::Sequence< uno::Type > aTypes = SwXHeadFootText_Base::getTypes(); + const uno::Sequence< uno::Type > aTextTypes = SwXText::getTypes(); + return ::comphelper::concatSequences(aTypes, aTextTypes); } /* -----------------------------21.03.00 15:39-------------------------------- ---------------------------------------------------------------------------*/ -uno::Sequence< sal_Int8 > SwXHeadFootText::getImplementationId( ) throw(uno::RuntimeException) +uno::Sequence< sal_Int8 > SAL_CALL +SwXHeadFootText::getImplementationId() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); static uno::Sequence< sal_Int8 > aId( 16 ); @@ -2715,7 +2782,8 @@ uno::Sequence< sal_Int8 > SwXHeadFootText::getImplementationId( ) throw(uno::Ru /* -----------------------------21.03.00 15:46-------------------------------- ---------------------------------------------------------------------------*/ -uno::Any SwXHeadFootText::queryInterface(const uno::Type& rType) +uno::Any SAL_CALL +SwXHeadFootText::queryInterface(const uno::Type& rType) throw (uno::RuntimeException) { const uno::Any ret = SwXHeadFootText_Base::queryInterface(rType); @@ -2727,135 +2795,128 @@ throw (uno::RuntimeException) /*-- 11.12.98 10:14:50--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextCursor > SwXHeadFootText::createTextCursor(void) throw( uno::RuntimeException ) +uno::Reference< text::XTextCursor > SAL_CALL +SwXHeadFootText::createTextCursor() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< text::XTextCursor > xRet; - SwFrmFmt* pHeadFootFmt = GetFmt(); - if(pHeadFootFmt) - { - const SwFmtCntnt& rFlyCntnt = pHeadFootFmt->GetCntnt(); - const SwNode& rNode = rFlyCntnt.GetCntntIdx()->GetNode(); - SwPosition aPos(rNode); - SwXTextCursor *const pXCursor = new SwXTextCursor(*GetDoc(), this, - (bIsHeader) ? CURSOR_HEADER : CURSOR_FOOTER, aPos); - SwUnoCrsr *const pUnoCrsr = pXCursor->GetCursor(); - pUnoCrsr->Move(fnMoveForward, fnGoNode); - - //save current start node to be able to check if there is content after the table - - //otherwise the cursor would be in the body text! - - const SwStartNode* pOwnStartNode = rNode.FindSttNodeByType( - bIsHeader ? SwHeaderStartNode : SwFooterStartNode); - //steht hier eine Tabelle? - SwTableNode* pTblNode = pUnoCrsr->GetNode()->FindTableNode(); - SwCntntNode* pCont = 0; - while( pTblNode ) - { - pUnoCrsr->GetPoint()->nNode = *pTblNode->EndOfSectionNode(); - pCont = GetDoc()->GetNodes().GoNext(&pUnoCrsr->GetPoint()->nNode); - pTblNode = pCont->FindTableNode(); - } - if(pCont) - pUnoCrsr->GetPoint()->nContent.Assign(pCont, 0); - const SwStartNode* pNewStartNode = pUnoCrsr->GetNode()->FindSttNodeByType( - bIsHeader ? SwHeaderStartNode : SwFooterStartNode); - if(!pNewStartNode || pNewStartNode != pOwnStartNode) - { - uno::RuntimeException aExcept; - aExcept.Message = S2U("no text available"); - throw aExcept; - } - xRet = static_cast(pXCursor); - } - else - { - uno::RuntimeException aRuntime; - aRuntime.Message = C2U(cInvalidObject); - throw aRuntime; + + SwFrmFmt & rHeadFootFmt( m_pImpl->GetHeadFootFmtOrThrow() ); + + uno::Reference< text::XTextCursor > xRet; + const SwFmtCntnt& rFlyCntnt = rHeadFootFmt.GetCntnt(); + const SwNode& rNode = rFlyCntnt.GetCntntIdx()->GetNode(); + SwPosition aPos(rNode); + SwXTextCursor *const pXCursor = new SwXTextCursor(*GetDoc(), this, + (m_pImpl->m_bIsHeader) ? CURSOR_HEADER : CURSOR_FOOTER, aPos); + SwUnoCrsr *const pUnoCrsr = pXCursor->GetCursor(); + pUnoCrsr->Move(fnMoveForward, fnGoNode); + + // save current start node to be able to check if there is content + // after the table - otherwise the cursor would be in the body text! + SwStartNode const*const pOwnStartNode = rNode.FindSttNodeByType( + (m_pImpl->m_bIsHeader) ? SwHeaderStartNode : SwFooterStartNode); + // is there a table here? + SwTableNode* pTblNode = pUnoCrsr->GetNode()->FindTableNode(); + SwCntntNode* pCont = 0; + while (pTblNode) + { + pUnoCrsr->GetPoint()->nNode = *pTblNode->EndOfSectionNode(); + pCont = GetDoc()->GetNodes().GoNext(&pUnoCrsr->GetPoint()->nNode); + pTblNode = pCont->FindTableNode(); + } + if (pCont) + { + pUnoCrsr->GetPoint()->nContent.Assign(pCont, 0); + } + SwStartNode const*const pNewStartNode = + pUnoCrsr->GetNode()->FindSttNodeByType( + (m_pImpl->m_bIsHeader) ? SwHeaderStartNode : SwFooterStartNode); + if (!pNewStartNode || (pNewStartNode != pOwnStartNode)) + { + uno::RuntimeException aExcept; + aExcept.Message = S2U("no text available"); + throw aExcept; } + xRet = static_cast(pXCursor); return xRet; } + /*-- 11.12.98 10:14:50--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextCursor > SwXHeadFootText::createTextCursorByRange( - const uno::Reference< text::XTextRange > & aTextPosition) throw( uno::RuntimeException ) +uno::Reference< text::XTextCursor > SAL_CALL +SwXHeadFootText::createTextCursorByRange( + const uno::Reference< text::XTextRange > & xTextPosition) +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< text::XTextCursor > xRet; - SwFrmFmt* pHeadFootFmt = GetFmt(); + + SwFrmFmt & rHeadFootFmt( m_pImpl->GetHeadFootFmtOrThrow() ); + SwUnoInternalPaM aPam(*GetDoc()); - if (pHeadFootFmt && ::sw::XTextRangeToSwPaM(aPam, aTextPosition)) + if (!::sw::XTextRangeToSwPaM(aPam, xTextPosition)) { - SwNode& rNode = pHeadFootFmt->GetCntnt().GetCntntIdx()->GetNode(); - SwPosition aPos(rNode); - SwPaM aHFPam(aPos); - aHFPam.Move(fnMoveForward, fnGoNode); - SwStartNode* pOwnStartNode = aHFPam.GetNode()->FindSttNodeByType( - bIsHeader ? SwHeaderStartNode : SwFooterStartNode); - SwStartNode* p1 = aPam.GetNode()->FindSttNodeByType( - bIsHeader ? SwHeaderStartNode : SwFooterStartNode); - if(p1 == pOwnStartNode) - { - xRet = static_cast( - new SwXTextCursor(*GetDoc(), this, - (bIsHeader) ? CURSOR_HEADER : CURSOR_FOOTER, - *aPam.GetPoint(), aPam.GetMark())); - } + uno::RuntimeException aRuntime; + aRuntime.Message = C2U(cInvalidObject); + throw aRuntime; + } + + uno::Reference< text::XTextCursor > xRet; + SwNode& rNode = rHeadFootFmt.GetCntnt().GetCntntIdx()->GetNode(); + SwPosition aPos(rNode); + SwPaM aHFPam(aPos); + aHFPam.Move(fnMoveForward, fnGoNode); + SwStartNode *const pOwnStartNode = aHFPam.GetNode()->FindSttNodeByType( + (m_pImpl->m_bIsHeader) ? SwHeaderStartNode : SwFooterStartNode); + SwStartNode *const p1 = aPam.GetNode()->FindSttNodeByType( + (m_pImpl->m_bIsHeader) ? SwHeaderStartNode : SwFooterStartNode); + if (p1 == pOwnStartNode) + { + xRet = static_cast( + new SwXTextCursor(*GetDoc(), this, + (m_pImpl->m_bIsHeader) ? CURSOR_HEADER : CURSOR_FOOTER, + *aPam.GetPoint(), aPam.GetMark())); } return xRet; } + /* -----------------19.03.99 15:44------------------- * * --------------------------------------------------*/ -uno::Reference< container::XEnumeration > SwXHeadFootText::createEnumeration(void) - throw( uno::RuntimeException ) +uno::Reference< container::XEnumeration > SAL_CALL +SwXHeadFootText::createEnumeration() +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + + SwFrmFmt & rHeadFootFmt( m_pImpl->GetHeadFootFmtOrThrow() ); + uno::Reference< container::XEnumeration > aRef; - //wenn this ungueltig ist, dann kommt die uno::Exception aus createTextCursor() - SwFrmFmt* pHeadFootFmt = GetFmt(); - if(pHeadFootFmt) - { - const SwFmtCntnt& rFlyCntnt = pHeadFootFmt->GetCntnt(); - const SwNode& rNode = rFlyCntnt.GetCntntIdx()->GetNode(); - SwPosition aPos(rNode); - ::std::auto_ptr pUnoCursor( - GetDoc()->CreateUnoCrsr(aPos, sal_False)); - pUnoCursor->Move(fnMoveForward, fnGoNode); - aRef = new SwXParagraphEnumeration(this, pUnoCursor, - (bIsHeader) ? CURSOR_HEADER : CURSOR_FOOTER); - } - else - { - uno::RuntimeException aRuntime; - aRuntime.Message = C2U(cInvalidObject); - throw aRuntime; - } + const SwFmtCntnt& rFlyCntnt = rHeadFootFmt.GetCntnt(); + const SwNode& rNode = rFlyCntnt.GetCntntIdx()->GetNode(); + SwPosition aPos(rNode); + ::std::auto_ptr pUnoCursor( + GetDoc()->CreateUnoCrsr(aPos, sal_False)); + pUnoCursor->Move(fnMoveForward, fnGoNode); + aRef = new SwXParagraphEnumeration(this, pUnoCursor, + (m_pImpl->m_bIsHeader) ? CURSOR_HEADER : CURSOR_FOOTER); return aRef; } + /* -----------------19.03.99 15:50------------------- * * --------------------------------------------------*/ -uno::Type SwXHeadFootText::getElementType(void) throw( uno::RuntimeException ) +uno::Type SAL_CALL +SwXHeadFootText::getElementType() throw (uno::RuntimeException) { - return ::getCppuType((uno::Reference*)0); + return text::XTextRange::static_type(); } /* -----------------19.03.99 15:50------------------- * * --------------------------------------------------*/ -sal_Bool SwXHeadFootText::hasElements(void) throw( uno::RuntimeException ) +sal_Bool SAL_CALL SwXHeadFootText::hasElements() throw (uno::RuntimeException) { return sal_True; } -/*-- 11.12.98 10:14:51--------------------------------------------------- - - -----------------------------------------------------------------------*/ -void SwXHeadFootText::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew) -{ - ClientModify( this, pOld, pNew); -} - -- cgit From 1f70baf3d1eaf363f0fb6281c7877a6ea783a667 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 8 Jan 2010 17:13:58 +0100 Subject: swunolocking1: #i105557#: fix locking for SwXFootnote: add Impl struct, and use UnoImplPtr to lock destructor. move all implementation details out of header, into Impl struct. disable broken SwClient iteration. make constructor protected, and add factory function CreateXFootnote. use new XUnoTunnel and XServiceInfo helpers. clean up the implementation a little. --- sw/inc/unofootnote.hxx | 37 +- sw/source/core/unocore/unoclbck.cxx | 15 +- sw/source/core/unocore/unocoll.cxx | 11 +- sw/source/core/unocore/unocrsrhelper.cxx | 5 +- sw/source/core/unocore/unoftn.cxx | 743 ++++++++++++++++++------------- sw/source/core/unocore/unoobj2.cxx | 8 +- 6 files changed, 461 insertions(+), 358 deletions(-) (limited to 'sw') diff --git a/sw/inc/unofootnote.hxx b/sw/inc/unofootnote.hxx index 8710f7effa03..8d9a65d963ae 100644 --- a/sw/inc/unofootnote.hxx +++ b/sw/inc/unofootnote.hxx @@ -41,14 +41,11 @@ #include -#include - -#include -#include #include class SwDoc; +class SwModify; class SwFmtFtn; @@ -66,18 +63,15 @@ typedef ::cppu::WeakImplHelper5 class SwXFootnote : public SwXFootnote_Base , public SwXText - , public SwClient { private: friend class SwXFootnotes; - SwEventListenerContainer aLstnrCntnr; - const SwFmtFtn* pFmtFtn; - BOOL m_bIsDescriptor; - String m_sLabel; - BOOL m_bIsEndnote; + class Impl; + ::sw::UnoImplPtr m_pImpl; + protected: @@ -90,24 +84,17 @@ protected: virtual ~SwXFootnote(); -public: - - SwXFootnote(BOOL bEndnote); - SwXFootnote(SwDoc* pDoc, const SwFmtFtn& rFmt); - - void attachToRange( - const ::com::sun::star::uno::Reference< - ::com::sun::star::text::XTextRange > & xTextRange) - throw (::com::sun::star::lang::IllegalArgumentException, - ::com::sun::star::uno::RuntimeException); + SwXFootnote(SwDoc & rDoc, const SwFmtFtn & rFmt); - const SwFmtFtn* FindFmt() const { return GetDoc() ? pFmtFtn : 0; } - void Invalidate(); +public: - TYPEINFO(); + SwXFootnote(const bool bEndnote); - // SwClient - virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + static SwXFootnote * + CreateXFootnote(SwDoc & rDoc, SwFmtFtn const& rFootnoteFmt); + /// may return 0 + static SwXFootnote * + GetXFootnote(SwModify const& rUnoCB, SwFmtFtn const& rFootnoteFmt); // XInterface virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( diff --git a/sw/source/core/unocore/unoclbck.cxx b/sw/source/core/unocore/unoclbck.cxx index 1d2185b381fb..6cc9cc0ee910 100644 --- a/sw/source/core/unocore/unoclbck.cxx +++ b/sw/source/core/unocore/unoclbck.cxx @@ -72,20 +72,7 @@ SwXReferenceMark* SwUnoCallBack::GetRefMark(const SwFmtRefMark& rMark) ---------------------------------------------------------------------------*/ SwXFootnote* SwUnoCallBack::GetFootnote(const SwFmtFtn& rMark) { - SwClientIter aIter( *this ); - SwXFootnote* pxFootnote = (SwXFootnote*)aIter.First( TYPE( SwXFootnote )); - while(pxFootnote) - { - SwDoc* pDoc = pxFootnote->GetDoc(); - if(pDoc) - { - const SwFmtFtn* pFtn = pxFootnote->FindFmt(); - if(pFtn == &rMark) - return pxFootnote; - } - pxFootnote = (SwXFootnote*)aIter.Next( ); - } - return 0; + return SwXFootnote::GetXFootnote(*this, rMark); } /* -----------------------------27.11.00 17:15-------------------------------- diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx index 079ba1fa0b95..57f9b05a9c01 100644 --- a/sw/source/core/unocore/unocoll.cxx +++ b/sw/source/core/unocore/unocoll.cxx @@ -1727,8 +1727,8 @@ uno::Any SwXFootnotes::getByIndex(sal_Int32 nIndex) if(nCount == nIndex) { - xRef = new SwXFootnote(GetDoc(), rFtn); - aRet.setValue(&xRef, ::getCppuType((uno::Reference*)0)); + xRef = SwXFootnote::CreateXFootnote(*GetDoc(), rFtn); + aRet <<= xRef; break; } nCount++; @@ -1762,12 +1762,7 @@ sal_Bool SwXFootnotes::hasElements(void) throw( uno::RuntimeException ) ---------------------------------------------------------------------------*/ Reference SwXFootnotes::GetObject( SwDoc& rDoc, const SwFmtFtn& rFmt ) { - Reference xContent = ((SwUnoCallBack*)rDoc.GetUnoCallBack())-> - GetFootnote(rFmt); - if(!xContent.is()) - xContent = new SwXFootnote(&rDoc, rFmt); - Reference xRet(xContent, UNO_QUERY); - return xRet; + return SwXFootnote::CreateXFootnote(rDoc, rFmt); } /****************************************************************** diff --git a/sw/source/core/unocore/unocrsrhelper.cxx b/sw/source/core/unocore/unocrsrhelper.cxx index 4d179f133446..29318ce49986 100644 --- a/sw/source/core/unocore/unocrsrhelper.cxx +++ b/sw/source/core/unocore/unocrsrhelper.cxx @@ -445,8 +445,9 @@ sal_Bool getCrsrPropertyValue(const SfxItemPropertySimpleEntry& rEntry { if( pAny ) { - uno::Reference< XFootnote > xFoot = new SwXFootnote(rPam.GetDoc(), rFtn); - pAny->setValue(&xFoot, ::getCppuType((uno::Reference*)0)); + const uno::Reference< text::XFootnote > xFootnote = + SwXFootnote::CreateXFootnote(*rPam.GetDoc(), rFtn); + *pAny <<= xFootnote; } } else diff --git a/sw/source/core/unocore/unoftn.cxx b/sw/source/core/unocore/unoftn.cxx index 3d3937f56524..777ebb3e114f 100644 --- a/sw/source/core/unocore/unoftn.cxx +++ b/sw/source/core/unocore/unoftn.cxx @@ -31,9 +31,11 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" +#include + #include #include -#include +#include #include #include @@ -42,6 +44,7 @@ #include #include #include +#include #include #include #include @@ -55,118 +58,233 @@ using namespace ::com::sun::star; using ::rtl::OUString; /****************************************************************** - * + * SwXFootnote ******************************************************************/ -/* -----------------------------13.03.00 12:15-------------------------------- - ---------------------------------------------------------------------------*/ -const uno::Sequence< sal_Int8 > & SwXFootnote::getUnoTunnelId() +class SwXFootnote::Impl + : public SwClient { - static uno::Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId(); - return aSeq; -} -/* -----------------------------10.03.00 18:04-------------------------------- - ---------------------------------------------------------------------------*/ -sal_Int64 SAL_CALL SwXFootnote::getSomething( const uno::Sequence< sal_Int8 >& rId ) - throw(uno::RuntimeException) -{ - if( rId.getLength() == 16 - && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), - rId.getConstArray(), 16 ) ) +public: + + SwXFootnote & m_rThis; + const bool m_bIsEndnote; + SwEventListenerContainer m_ListenerContainer; + bool m_bIsDescriptor; + const SwFmtFtn * m_pFmtFtn; + ::rtl::OUString m_sLabel; + + Impl( SwXFootnote & rThis, + SwDoc *const pDoc, SwFmtFtn const*const pFootnote, + const bool bIsEndnote) + : SwClient((pDoc) ? pDoc->GetUnoCallBack() : 0) + , m_rThis(rThis) + , m_bIsEndnote(bIsEndnote) + , m_ListenerContainer(static_cast< ::cppu::OWeakObject* >(&rThis)) + , m_bIsDescriptor(0 == pFootnote) + , m_pFmtFtn(pFootnote) { - return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(this) ); } - return SwXText::getSomething( rId ); -} -/* -----------------------------06.04.00 16:36-------------------------------- + + const SwFmtFtn* GetFootnoteFormat() const { + return m_rThis.GetDoc() ? m_pFmtFtn : 0; + } + + SwFmtFtn const& GetFootnoteFormatOrThrow() { + SwFmtFtn const*const pFootnote( GetFootnoteFormat() ); + if (!pFootnote) { + throw uno::RuntimeException(OUString(RTL_CONSTASCII_USTRINGPARAM( + "SwXFootnote: disposed or invalid")), 0); + } + return *pFootnote; + } + + void Invalidate(); + + // SwClient + virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + +}; + +/* -----------------------------07.01.00 12:39-------------------------------- ---------------------------------------------------------------------------*/ -OUString SwXFootnote::getImplementationName(void) throw( uno::RuntimeException ) +void SwXFootnote::Impl::Invalidate() { - return C2U("SwXFootnote"); + if (GetRegisteredIn()) + { + const_cast(GetRegisteredIn())->Remove(this); + } + m_ListenerContainer.Disposing(); + m_pFmtFtn = 0; + m_rThis.SetDoc(0); } -/* -----------------------------06.04.00 16:36-------------------------------- - ---------------------------------------------------------------------------*/ -BOOL SwXFootnote::supportsService(const OUString& rServiceName) throw( uno::RuntimeException ) +/* -----------------18.01.99 09:12------------------- + * + * --------------------------------------------------*/ +void SwXFootnote::Impl::Modify(SfxPoolItem *pOld, SfxPoolItem *pNew) { - return !rServiceName.compareToAscii("com.sun.star.text.Footnote") || - !rServiceName.compareToAscii("com.sun.star.text.TextContent") || - !rServiceName.compareToAscii("com.sun.star.text.Text") || - (m_bIsEndnote && !rServiceName.compareToAscii("com.sun.star.text.Endnote")); -; -} -/* -----------------------------06.04.00 16:36-------------------------------- + ClientModify(this, pOld, pNew); - ---------------------------------------------------------------------------*/ -uno::Sequence< OUString > SwXFootnote::getSupportedServiceNames(void) throw( uno::RuntimeException ) -{ - uno::Sequence< OUString > aRet(m_bIsEndnote ? 4 : 3); - OUString* pArray = aRet.getArray(); - pArray[0] = C2U("com.sun.star.text.Footnote"); - pArray[1] = C2U("com.sun.star.text.TextContent"); - pArray[2] = C2U("com.sun.star.text.Text"); - if(m_bIsEndnote) - pArray[3] = C2U("com.sun.star.text.Endnote"); - return aRet; + if (!GetRegisteredIn()) // removed => dispose + { + Invalidate(); + } + else if (pOld) + { + switch (pOld->Which()) + { + case RES_FOOTNOTE_DELETED: + if (static_cast(m_pFmtFtn) == + static_cast(pOld)->pObject) + { + Invalidate(); + } + break; + } + } } + /*-- 10.12.98 15:31:44--------------------------------------------------- -----------------------------------------------------------------------*/ -TYPEINIT1(SwXFootnote, SwClient); - -SwXFootnote::SwXFootnote(sal_Bool bEndnote) : - SwXText(0, CURSOR_FOOTNOTE), - aLstnrCntnr( (text::XTextContent*)this), - pFmtFtn(0), - m_bIsDescriptor(sal_True), - m_bIsEndnote(bEndnote) +SwXFootnote::SwXFootnote(const bool bEndnote) + : SwXText(0, CURSOR_FOOTNOTE) + , m_pImpl( new SwXFootnote::Impl(*this, 0, 0, bEndnote) ) { - } /*-- 10.12.98 15:31:45--------------------------------------------------- -----------------------------------------------------------------------*/ -SwXFootnote::SwXFootnote(SwDoc* _pDoc, const SwFmtFtn& rFmt) : - SwXText(_pDoc, CURSOR_FOOTNOTE), - aLstnrCntnr( (text::XTextContent*)this), - pFmtFtn(&rFmt), - m_bIsDescriptor(sal_False), - m_bIsEndnote(rFmt.IsEndNote()) +SwXFootnote::SwXFootnote(SwDoc & rDoc, const SwFmtFtn& rFmt) + : SwXText(& rDoc, CURSOR_FOOTNOTE) + , m_pImpl( new SwXFootnote::Impl(*this, &rDoc, &rFmt, rFmt.IsEndNote()) ) { - GetDoc()->GetUnoCallBack()->Add(this); } /*-- 10.12.98 15:31:45--------------------------------------------------- -----------------------------------------------------------------------*/ SwXFootnote::~SwXFootnote() { +} + +SwXFootnote * +SwXFootnote::GetXFootnote( + SwModify const& /*rUnoCB*/, SwFmtFtn const& /*rFootnoteFmt*/) +{ + // re-use existing SwXFootnote + // #i105557#: do not iterate over the registered clients: race condition + // to do this properly requires the SwXFootnote to register at the + // SwFmtFtn directly, not at the unocallback + // also this function must return a uno Reference! +#if 0 + SwClientIter aIter( rUnoCB ); + SwXFootnote::Impl * pXFootnote = static_cast( + aIter.First( TYPE( SwXFootnote::Impl ))); + while (pXFootnote) + { + SwDoc *const pDoc = pXFootnote->m_rThis.GetDoc(); + if (pDoc) + { + SwFmtFtn const*const pFtn = pXFootnote->GetFootnoteFormat(); + if (pFtn == &rFootnoteFmt) + { + return & pXFootnote->m_rThis; + } + } + pXFootnote = static_cast(aIter.Next()); + } +#endif + return 0; +} + +SwXFootnote * +SwXFootnote::CreateXFootnote(SwDoc & rDoc, SwFmtFtn const& rFootnoteFmt) +{ + SwXFootnote *const pXFootnote( + GetXFootnote(*rDoc.GetUnoCallBack(), rFootnoteFmt)); + return (pXFootnote) + ? pXFootnote + : new SwXFootnote(rDoc, rFootnoteFmt); +} +/* -----------------------------13.03.00 12:15-------------------------------- + + ---------------------------------------------------------------------------*/ +const uno::Sequence< sal_Int8 > & SwXFootnote::getUnoTunnelId() +{ + static uno::Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId(); + return aSeq; } -/* -----------------------------21.03.00 15:39-------------------------------- +/* -----------------------------10.03.00 18:04-------------------------------- + + ---------------------------------------------------------------------------*/ +sal_Int64 SAL_CALL +SwXFootnote::getSomething(const uno::Sequence< sal_Int8 >& rId) +throw (uno::RuntimeException) +{ + const sal_Int64 nRet( ::sw::UnoTunnelImpl(rId, this) ); + return (nRet) ? nRet : SwXText::getSomething(rId); +} + +/* -----------------------------06.04.00 16:36-------------------------------- + + ---------------------------------------------------------------------------*/ +OUString SAL_CALL +SwXFootnote::getImplementationName() throw (uno::RuntimeException) +{ + return C2U("SwXFootnote"); +} + +/* -----------------------------06.04.00 16:36-------------------------------- ---------------------------------------------------------------------------*/ -uno::Sequence< uno::Type > SAL_CALL SwXFootnote::getTypes( ) throw(uno::RuntimeException) +static char const*const g_ServicesFootnote[] = +{ + "com.sun.star.text.TextContent", + "com.sun.star.text.Footnote", + "com.sun.star.text.Text", + "com.sun.star.text.Endnote", // NB: only supported for endnotes! +}; +static const size_t g_nServicesEndnote( + sizeof(g_ServicesFootnote)/sizeof(g_ServicesFootnote[0])); +static const size_t g_nServicesFootnote( g_nServicesEndnote - 1 ); // NB: omit! + +sal_Bool SAL_CALL SwXFootnote::supportsService(const OUString& rServiceName) +throw (uno::RuntimeException) { - uno::Sequence< uno::Type > aFtnTypes = SwXFootnote_Base::getTypes(); - uno::Sequence< uno::Type > aTextTypes = SwXText::getTypes(); + vos::OGuard g(Application::GetSolarMutex()); + return ::sw::SupportsServiceImpl( + (m_pImpl->m_bIsEndnote) ? g_nServicesEndnote : g_nServicesFootnote, + g_ServicesFootnote, rServiceName); +} - long nIndex = aFtnTypes.getLength(); - aFtnTypes.realloc( aFtnTypes.getLength() + aTextTypes.getLength()); +uno::Sequence< OUString > SAL_CALL +SwXFootnote::getSupportedServiceNames() throw (uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + return ::sw::GetSupportedServiceNamesImpl( + (m_pImpl->m_bIsEndnote) ? g_nServicesEndnote : g_nServicesFootnote, + g_ServicesFootnote); +} - uno::Type* pFtnTypes = aFtnTypes.getArray(); - const uno::Type* pTextTypes = aTextTypes.getConstArray(); - for(long nPos = 0; nPos < aTextTypes.getLength(); nPos++) - pFtnTypes[nIndex++] = pTextTypes[nPos]; +/* -----------------------------21.03.00 15:39-------------------------------- - return aFtnTypes; + ---------------------------------------------------------------------------*/ +uno::Sequence< uno::Type > SAL_CALL +SwXFootnote::getTypes() throw (uno::RuntimeException) +{ + const uno::Sequence< uno::Type > aTypes = SwXFootnote_Base::getTypes(); + const uno::Sequence< uno::Type > aTextTypes = SwXText::getTypes(); + return ::comphelper::concatSequences(aTypes, aTextTypes); } /* -----------------------------21.03.00 15:39-------------------------------- ---------------------------------------------------------------------------*/ -uno::Sequence< sal_Int8 > SAL_CALL SwXFootnote::getImplementationId( ) throw(uno::RuntimeException) +uno::Sequence< sal_Int8 > SAL_CALL +SwXFootnote::getImplementationId() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); static uno::Sequence< sal_Int8 > aId( 16 ); @@ -181,7 +299,8 @@ uno::Sequence< sal_Int8 > SAL_CALL SwXFootnote::getImplementationId( ) throw(un /* -----------------------------21.03.00 15:46-------------------------------- ---------------------------------------------------------------------------*/ -uno::Any SAL_CALL SwXFootnote::queryInterface(const uno::Type& rType) +uno::Any SAL_CALL +SwXFootnote::queryInterface(const uno::Type& rType) throw (uno::RuntimeException) { const uno::Any ret = SwXFootnote_Base::queryInterface(rType); @@ -193,26 +312,36 @@ throw (uno::RuntimeException) /*-- 10.12.98 15:31:47--------------------------------------------------- -----------------------------------------------------------------------*/ -OUString SwXFootnote::getLabel(void) throw( uno::RuntimeException ) +OUString SAL_CALL SwXFootnote::getLabel() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - String sRet; - const SwFmtFtn* pFmt = SwXFootnote::FindFmt(); + + ::rtl::OUString sRet; + SwFmtFtn const*const pFmt = m_pImpl->GetFootnoteFormat(); if(pFmt) + { sRet = pFmt->GetNumStr(); - else if(m_bIsDescriptor) - return m_sLabel; + } + else if (m_pImpl->m_bIsDescriptor) + { + sRet = m_pImpl->m_sLabel; + } else + { throw uno::RuntimeException(); + } return sRet; } + /*-- 10.12.98 15:31:48--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXFootnote::setLabel(const OUString& aLabel) throw( uno::RuntimeException ) +void SAL_CALL +SwXFootnote::setLabel(const OUString& aLabel) throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - const SwFmtFtn* pFmt = FindFmt(); + + SwFmtFtn const*const pFmt = m_pImpl->GetFootnoteFormat(); if(pFmt) { const SwTxtFtn* pTxtFtn = pFmt->GetTxtFtn(); @@ -222,157 +351,172 @@ void SwXFootnote::setLabel(const OUString& aLabel) throw( uno::RuntimeException SwPaM aPam(rTxtNode, *pTxtFtn->GetStart()); GetDoc()->SetCurFtn(aPam, aLabel, pFmt->GetNumber(), pFmt->IsEndNote()); } - else if(m_bIsDescriptor) - m_sLabel = String(aLabel); + else if (m_pImpl->m_bIsDescriptor) + { + m_pImpl->m_sLabel = String(aLabel); + } else + { throw uno::RuntimeException(); - + } } + /* -----------------18.02.99 13:32------------------- * * --------------------------------------------------*/ -void SwXFootnote::attachToRange(const uno::Reference< text::XTextRange > & xTextRange) - throw( lang::IllegalArgumentException, uno::RuntimeException ) +void SAL_CALL +SwXFootnote::attach(const uno::Reference< text::XTextRange > & xTextRange) +throw (lang::IllegalArgumentException, uno::RuntimeException) { - if(!m_bIsDescriptor) + vos::OGuard aGuard(Application::GetSolarMutex()); + + if (!m_pImpl->m_bIsDescriptor) + { throw uno::RuntimeException(); - uno::Reference xRangeTunnel( xTextRange, uno::UNO_QUERY); - SwXTextRange* pRange = 0; - OTextCursorHelper* pCursor = 0; - if(xRangeTunnel.is()) + } + const uno::Reference xRangeTunnel( + xTextRange, uno::UNO_QUERY); + SwXTextRange *const pRange = + ::sw::UnoTunnelGetImplementation(xRangeTunnel); + OTextCursorHelper *const pCursor = + ::sw::UnoTunnelGetImplementation(xRangeTunnel); + SwDoc *const pNewDoc = + (pRange) ? pRange->GetDoc() : ((pCursor) ? pCursor->GetDoc() : 0); + if (!pNewDoc) + { + throw lang::IllegalArgumentException(); + } + + SwUnoInternalPaM aPam(*pNewDoc); + //das muss jetzt sal_True liefern + ::sw::XTextRangeToSwPaM(aPam, xTextRange); + + UnoActionContext aCont(pNewDoc); + pNewDoc->DeleteAndJoin(aPam); + aPam.DeleteMark(); + SwFmtFtn aFootNote(m_pImpl->m_bIsEndnote); + if (m_pImpl->m_sLabel.getLength()) { - pRange = reinterpret_cast< SwXTextRange * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXTextRange::getUnoTunnelId()) )); - pCursor = reinterpret_cast< OTextCursorHelper * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( OTextCursorHelper::getUnoTunnelId()) )); + aFootNote.SetNumStr(m_pImpl->m_sLabel); } - SwDoc* pNewDoc = pRange ? (SwDoc*)pRange->GetDoc() : pCursor ? (SwDoc*)pCursor->GetDoc() : 0; - if(pNewDoc) + + SwXTextCursor const*const pTextCursor( + dynamic_cast(pCursor)); + const bool bForceExpandHints( (pTextCursor) + ? pTextCursor->IsAtEndOfMeta() : false ); + const SetAttrMode nInsertFlags = (bForceExpandHints) + ? nsSetAttrMode::SETATTR_FORCEHINTEXPAND + : nsSetAttrMode::SETATTR_DEFAULT; + + pNewDoc->InsertPoolItem(aPam, aFootNote, nInsertFlags); + + SwTxtFtn *const pTxtAttr = static_cast( + aPam.GetNode()->GetTxtNode()->GetTxtAttrForCharAt( + aPam.GetPoint()->nContent.GetIndex()-1, RES_TXTATR_FTN )); + + if (pTxtAttr) { - SwUnoInternalPaM aPam(*pNewDoc); - //das muss jetzt sal_True liefern - ::sw::XTextRangeToSwPaM(aPam, xTextRange); - - UnoActionContext aCont(pNewDoc); - SwTxtAttr* pTxtAttr = 0; - pNewDoc->DeleteAndJoin(aPam); - aPam.DeleteMark(); - SwFmtFtn aFootNote(m_bIsEndnote); - if(m_sLabel.Len()) - aFootNote.SetNumStr(m_sLabel); - - SwXTextCursor const*const pTextCursor( - dynamic_cast(pCursor)); - const bool bForceExpandHints( (pTextCursor) - ? pTextCursor->IsAtEndOfMeta() : false ); - const SetAttrMode nInsertFlags = (bForceExpandHints) - ? nsSetAttrMode::SETATTR_FORCEHINTEXPAND - : nsSetAttrMode::SETATTR_DEFAULT; - - pNewDoc->InsertPoolItem(aPam, aFootNote, nInsertFlags); - - pTxtAttr = aPam.GetNode()->GetTxtNode()->GetTxtAttrForCharAt( - aPam.GetPoint()->nContent.GetIndex()-1, RES_TXTATR_FTN ); - - if(pTxtAttr) + const SwFmtFtn& rFtn = pTxtAttr->GetFtn(); + m_pImpl->m_pFmtFtn = &rFtn; + pNewDoc->GetUnoCallBack()->Add(m_pImpl.get()); + // force creation of sequence id - is used for references + if (pNewDoc->IsInReading()) + { + pTxtAttr->SetSeqNo(pNewDoc->GetFtnIdxs().Count()); + } + else { - const SwFmtFtn& rFtn = pTxtAttr->GetFtn(); - pFmtFtn = &rFtn; - pNewDoc->GetUnoCallBack()->Add(this); - //force creation of sequence id - is used for references - if(pNewDoc->IsInReading()) - ((SwTxtFtn*)pTxtAttr)->SetSeqNo(pNewDoc->GetFtnIdxs().Count()); - else - ((SwTxtFtn*)pTxtAttr)->SetSeqRefNo(); + pTxtAttr->SetSeqRefNo(); } - m_bIsDescriptor = sal_False; - SetDoc(pNewDoc); } - else - throw lang::IllegalArgumentException(); + m_pImpl->m_bIsDescriptor = sal_False; + SetDoc(pNewDoc); } -/*-- 10.12.98 15:31:48--------------------------------------------------- - -----------------------------------------------------------------------*/ -void SwXFootnote::attach(const uno::Reference< text::XTextRange > & xTextRange) - throw( lang::IllegalArgumentException, uno::RuntimeException ) -{ - vos::OGuard aGuard(Application::GetSolarMutex()); - attachToRange( xTextRange ); -} /*-- 10.12.98 15:31:48--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextRange > SwXFootnote::getAnchor(void) throw( uno::RuntimeException ) +uno::Reference< text::XTextRange > SAL_CALL +SwXFootnote::getAnchor() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< text::XTextRange > aRef; - const SwFmtFtn* pFmt = FindFmt(); - if(pFmt) - { - const SwTxtFtn* pTxtFtn = pFmt->GetTxtFtn(); - SwPaM aPam( pTxtFtn->GetTxtNode(), *pTxtFtn->GetStart() ); - SwPosition aMark( *aPam.Start() ); - aPam.SetMark(); - aPam.GetMark()->nContent++; - aRef = SwXTextRange::CreateXTextRange( - *GetDoc(), *aPam.Start(), aPam.End()); - } - else - throw uno::RuntimeException(); - return aRef; + + SwFmtFtn const& rFmt( m_pImpl->GetFootnoteFormatOrThrow() ); + + SwTxtFtn const*const pTxtFtn = rFmt.GetTxtFtn(); + SwPaM aPam( pTxtFtn->GetTxtNode(), *pTxtFtn->GetStart() ); + SwPosition aMark( *aPam.Start() ); + aPam.SetMark(); + aPam.GetMark()->nContent++; + const uno::Reference< text::XTextRange > xRet = + SwXTextRange::CreateXTextRange(*GetDoc(), *aPam.Start(), aPam.End()); + return xRet; } /*-- 10.12.98 15:31:49--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXFootnote::dispose(void) throw( uno::RuntimeException ) +void SAL_CALL SwXFootnote::dispose() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - const SwFmtFtn* pFmt = FindFmt(); - if(pFmt) - { - const SwTxtFtn* pTxtFtn = pFmt->GetTxtFtn(); - DBG_ASSERT(pTxtFtn, "kein TextNode?"); - SwTxtNode& rTxtNode = (SwTxtNode&)pTxtFtn->GetTxtNode(); - xub_StrLen nPos = *pTxtFtn->GetStart(); - SwPaM aPam(rTxtNode, nPos, rTxtNode, nPos+1 ); - GetDoc()->DeleteAndJoin( aPam ); - } - else - throw uno::RuntimeException(); + SwFmtFtn const& rFmt( m_pImpl->GetFootnoteFormatOrThrow() ); + + SwTxtFtn const*const pTxtFtn = rFmt.GetTxtFtn(); + DBG_ASSERT(pTxtFtn, "no TextNode?"); + SwTxtNode& rTxtNode = const_cast(pTxtFtn->GetTxtNode()); + const xub_StrLen nPos = *pTxtFtn->GetStart(); + SwPaM aPam(rTxtNode, nPos, rTxtNode, nPos+1); + GetDoc()->DeleteAndJoin( aPam ); } + /*-- 10.12.98 15:31:49--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXFootnote::addEventListener(const uno::Reference< lang::XEventListener > & aListener) throw( uno::RuntimeException ) +void SAL_CALL +SwXFootnote::addEventListener( + const uno::Reference< lang::XEventListener > & xListener) +throw (uno::RuntimeException) { - if(!GetRegisteredIn()) + vos::OGuard g(Application::GetSolarMutex()); + + if (!m_pImpl->GetFootnoteFormat()) + { throw uno::RuntimeException(); - aLstnrCntnr.AddListener(aListener); + } + m_pImpl->m_ListenerContainer.AddListener(xListener); } /*-- 10.12.98 15:31:50--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXFootnote::removeEventListener(const uno::Reference< lang::XEventListener > & aListener) throw( uno::RuntimeException ) +void SAL_CALL +SwXFootnote::removeEventListener( + const uno::Reference< lang::XEventListener > & xListener) +throw (uno::RuntimeException) { - if(!GetRegisteredIn() || !aLstnrCntnr.RemoveListener(aListener)) + vos::OGuard g(Application::GetSolarMutex()); + + if (!m_pImpl->GetFootnoteFormat() || + !m_pImpl->m_ListenerContainer.RemoveListener(xListener)) + { throw uno::RuntimeException(); + } } + /* -----------------06.05.99 15:31------------------- * * --------------------------------------------------*/ const SwStartNode *SwXFootnote::GetStartNode() const { - const SwStartNode *pSttNd = 0; - const SwFmtFtn* pFmt = FindFmt(); + SwFmtFtn const*const pFmt = m_pImpl->GetFootnoteFormat(); if(pFmt) { const SwTxtFtn* pTxtFtn = pFmt->GetTxtFtn(); if( pTxtFtn ) - pSttNd = pTxtFtn->GetStartNode()->GetNode().GetStartNode(); + { + return pTxtFtn->GetStartNode()->GetNode().GetStartNode(); + } } - return pSttNd; + return 0; } uno::Reference< text::XTextCursor > @@ -380,144 +524,119 @@ SwXFootnote::CreateCursor() throw (uno::RuntimeException) { return createTextCursor(); } + /*-- 10.12.98 15:31:50--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextCursor > SwXFootnote::createTextCursor(void) throw( uno::RuntimeException ) +uno::Reference< text::XTextCursor > SAL_CALL +SwXFootnote::createTextCursor() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< text::XTextCursor > aRef; - const SwFmtFtn* pFmt = FindFmt(); - if(pFmt) - { - const SwTxtFtn* pTxtFtn = pFmt->GetTxtFtn(); - SwPosition aPos( *pTxtFtn->GetStartNode() ); - SwXTextCursor *const pXCursor = - new SwXTextCursor(*GetDoc(), this, CURSOR_FOOTNOTE, aPos); - aRef = static_cast(pXCursor); - SwUnoCrsr *const pUnoCrsr = pXCursor->GetCursor(); - pUnoCrsr->Move(fnMoveForward, fnGoNode); - } - else - throw uno::RuntimeException(); - return aRef; + + SwFmtFtn const& rFmt( m_pImpl->GetFootnoteFormatOrThrow() ); + + SwTxtFtn const*const pTxtFtn = rFmt.GetTxtFtn(); + SwPosition aPos( *pTxtFtn->GetStartNode() ); + SwXTextCursor *const pXCursor = + new SwXTextCursor(*GetDoc(), this, CURSOR_FOOTNOTE, aPos); + SwUnoCrsr *const pUnoCrsr = pXCursor->GetCursor(); + pUnoCrsr->Move(fnMoveForward, fnGoNode); + const uno::Reference< text::XTextCursor > xRet = + static_cast(pXCursor); + return xRet; } + /*-- 10.12.98 15:31:51--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextCursor > SwXFootnote::createTextCursorByRange( - const uno::Reference< text::XTextRange > & aTextPosition) - throw( uno::RuntimeException ) +uno::Reference< text::XTextCursor > SAL_CALL +SwXFootnote::createTextCursorByRange( + const uno::Reference< text::XTextRange > & xTextPosition) +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - const SwFmtFtn* pFmt = FindFmt(); - if( !pFmt ) - throw uno::RuntimeException(); - uno::Reference< text::XTextCursor > aRef; + + SwFmtFtn const& rFmt( m_pImpl->GetFootnoteFormatOrThrow() ); + SwUnoInternalPaM aPam(*GetDoc()); - if (::sw::XTextRangeToSwPaM(aPam, aTextPosition)) + if (!::sw::XTextRangeToSwPaM(aPam, xTextPosition)) { - const SwTxtFtn* pTxtFtn = pFmt->GetTxtFtn(); - const SwNode* pFtnStartNode = &pTxtFtn->GetStartNode()->GetNode(); + throw uno::RuntimeException(); + } - const SwNode* pStart = aPam.GetNode()->FindFootnoteStartNode(); - if( pStart != pFtnStartNode ) - throw uno::RuntimeException(); + SwTxtFtn const*const pTxtFtn = rFmt.GetTxtFtn(); + SwNode const*const pFtnStartNode = &pTxtFtn->GetStartNode()->GetNode(); - aRef = static_cast( + const SwNode* pStart = aPam.GetNode()->FindFootnoteStartNode(); + if (pStart != pFtnStartNode) + { + throw uno::RuntimeException(); + } + + const uno::Reference< text::XTextCursor > xRet = + static_cast( new SwXTextCursor(*GetDoc(), this, CURSOR_FOOTNOTE, *aPam.GetPoint(), aPam.GetMark())); - } - else - throw uno::RuntimeException(); - return aRef; + return xRet; } + /*-- 13.06.00 14:28:23--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< container::XEnumeration > SwXFootnote::createEnumeration() throw( uno::RuntimeException ) +uno::Reference< container::XEnumeration > SAL_CALL +SwXFootnote::createEnumeration() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< container::XEnumeration > aRef; - const SwFmtFtn* pFmt = FindFmt(); - if(pFmt) - { - const SwTxtFtn* pTxtFtn = pFmt->GetTxtFtn(); - SwPosition aPos( *pTxtFtn->GetStartNode() ); - ::std::auto_ptr pUnoCursor( - GetDoc()->CreateUnoCrsr(aPos, sal_False)); - pUnoCursor->Move(fnMoveForward, fnGoNode); - aRef = new SwXParagraphEnumeration(this, pUnoCursor, CURSOR_FOOTNOTE); - } - return aRef; + + SwFmtFtn const& rFmt( m_pImpl->GetFootnoteFormatOrThrow() ); + + SwTxtFtn const*const pTxtFtn = rFmt.GetTxtFtn(); + SwPosition aPos( *pTxtFtn->GetStartNode() ); + ::std::auto_ptr pUnoCursor( + GetDoc()->CreateUnoCrsr(aPos, sal_False)); + pUnoCursor->Move(fnMoveForward, fnGoNode); + const uno::Reference< container::XEnumeration > xRet = + new SwXParagraphEnumeration(this, pUnoCursor, CURSOR_FOOTNOTE); + return xRet; } + /*-- 13.06.00 14:28:24--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Type SwXFootnote::getElementType( ) throw(uno::RuntimeException) +uno::Type SAL_CALL SwXFootnote::getElementType() throw (uno::RuntimeException) { - return ::getCppuType(static_cast*>(0)); + return text::XTextRange::static_type(); } /*-- 13.06.00 14:28:24--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXFootnote::hasElements( ) throw(uno::RuntimeException) +sal_Bool SAL_CALL SwXFootnote::hasElements() throw (uno::RuntimeException) { return sal_True; } -/* -----------------------------07.01.00 12:39-------------------------------- - ---------------------------------------------------------------------------*/ -void SwXFootnote::Invalidate() -{ - if(GetRegisteredIn()) - { - ((SwModify*)GetRegisteredIn())->Remove(this); - pFmtFtn = 0; - aLstnrCntnr.Disposing(); - SetDoc(0); - } -} -/* -----------------18.01.99 09:12------------------- - * - * --------------------------------------------------*/ -void SwXFootnote::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew) -{ - switch( pOld ? pOld->Which() : 0 ) - { - case RES_REMOVE_UNO_OBJECT: - case RES_OBJECTDYING: - if( (void*)GetRegisteredIn() == ((SwPtrMsgPoolItem *)pOld)->pObject ) - Invalidate(); - break; - case RES_FMT_CHG: - // wurden wir an das neue umgehaengt und wird das alte geloscht? - if( ((SwFmtChg*)pNew)->pChangedFmt == GetRegisteredIn() && - ((SwFmtChg*)pOld)->pChangedFmt->IsFmtInDTOR() ) - Invalidate(); - break; - case RES_FOOTNOTE_DELETED: - if( (void*)pFmtFtn == ((SwPtrMsgPoolItem *)pOld)->pObject ) - Invalidate(); - break; - } -} /*-- 11.09.00 13:12:03--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< beans::XPropertySetInfo > SwXFootnote::getPropertySetInfo( ) - throw(uno::RuntimeException) +uno::Reference< beans::XPropertySetInfo > SAL_CALL +SwXFootnote::getPropertySetInfo() +throw (uno::RuntimeException) { - static uno::Reference< beans::XPropertySetInfo > xRef = aSwMapProvider.GetPropertySet(PROPERTY_MAP_FOOTNOTE)->getPropertySetInfo(); - return xRef; + vos::OGuard g(Application::GetSolarMutex()); + static uno::Reference< beans::XPropertySetInfo > xRet = + aSwMapProvider.GetPropertySet(PROPERTY_MAP_FOOTNOTE) + ->getPropertySetInfo(); + return xRet; } + /*-- 11.09.00 13:12:04--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXFootnote::setPropertyValue( const ::rtl::OUString&, - const uno::Any& ) - throw(beans::UnknownPropertyException, beans::PropertyVetoException, - lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +void SAL_CALL +SwXFootnote::setPropertyValue(const ::rtl::OUString&, const uno::Any&) +throw (beans::UnknownPropertyException, beans::PropertyVetoException, + lang::IllegalArgumentException, lang::WrappedTargetException, + uno::RuntimeException) { //no values to be set throw lang::IllegalArgumentException(); @@ -525,28 +644,34 @@ void SwXFootnote::setPropertyValue( const ::rtl::OUString&, /*-- 11.09.00 13:12:04--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Any SwXFootnote::getPropertyValue( const OUString& rPropertyName ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +uno::Any SAL_CALL +SwXFootnote::getPropertyValue(const OUString& rPropertyName) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + uno::Any aRet; if (! ::sw::GetDefaultTextContentValue(aRet, rPropertyName)) { - if(rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_START_REDLINE))|| - rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_END_REDLINE))) + if (rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_START_REDLINE)) || + rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_END_REDLINE))) { //redline can only be returned if it's a living object - if(!m_bIsDescriptor) + if (!m_pImpl->m_bIsDescriptor) + { aRet = SwXText::getPropertyValue(rPropertyName); + } } - else if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_REFERENCE_ID))) + else if (rPropertyName.equalsAsciiL( + SW_PROP_NAME(UNO_NAME_REFERENCE_ID))) { - const SwFmtFtn* pFmt = FindFmt(); - if(pFmt) + SwFmtFtn const*const pFmt = m_pImpl->GetFootnoteFormat(); + if (pFmt) { - const SwTxtFtn* pTxtFtn = pFmt->GetTxtFtn(); + SwTxtFtn const*const pTxtFtn = pFmt->GetTxtFtn(); DBG_ASSERT(pTxtFtn, "no TextNode?"); - aRet <<= (sal_Int16)pTxtFtn->GetSeqRefNo(); + aRet <<= static_cast(pTxtFtn->GetSeqRefNo()); } } else @@ -558,37 +683,51 @@ uno::Any SwXFootnote::getPropertyValue( const OUString& rPropertyName ) } return aRet; } + /*-- 11.09.00 13:12:04--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXFootnote::addPropertyChangeListener( const OUString& /*aPropertyName*/, - const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/ ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +void SAL_CALL +SwXFootnote::addPropertyChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { + OSL_ENSURE(false, + "SwXFootnote::addPropertyChangeListener(): not implemented"); } -/*-- 11.09.00 13:12:04--------------------------------------------------- - -----------------------------------------------------------------------*/ -void SwXFootnote::removePropertyChangeListener( const OUString& /*aPropertyName*/, - const uno::Reference< beans::XPropertyChangeListener >& /*aListener*/ ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +void SAL_CALL +SwXFootnote::removePropertyChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { + OSL_ENSURE(false, + "SwXFootnote::removePropertyChangeListener(): not implemented"); } -/*-- 11.09.00 13:12:04--------------------------------------------------- - -----------------------------------------------------------------------*/ -void SwXFootnote::addVetoableChangeListener( const OUString& /*PropertyName*/, - const uno::Reference< beans::XVetoableChangeListener >& /*aListener*/ ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +void SAL_CALL +SwXFootnote::addVetoableChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { + OSL_ENSURE(false, + "SwXFootnote::addVetoableChangeListener(): not implemented"); } -/*-- 11.09.00 13:12:05--------------------------------------------------- - -----------------------------------------------------------------------*/ -void SwXFootnote::removeVetoableChangeListener( const OUString& /*PropertyName*/, - const uno::Reference< beans::XVetoableChangeListener >& /*aListener*/ ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +void SAL_CALL +SwXFootnote::removeVetoableChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { + OSL_ENSURE(false, + "SwXFootnote::removeVetoableChangeListener(): not implemented"); } - diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index 918ab49d45f0..53b0da94b12d 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -1344,13 +1344,7 @@ CreateParentXText(SwDoc & rDoc, const SwPosition& rPos) if (pSttNode == pTxtFtn->GetStartNode()->GetNode(). FindSttNodeByType(SwFootnoteStartNode)) { - xParentText = - static_cast(rDoc.GetUnoCallBack())-> - GetFootnote(rFtn); - if (!xParentText.is()) - { - xParentText = new SwXFootnote(&rDoc, rFtn); - } + xParentText = SwXFootnote::CreateXFootnote(rDoc, rFtn); break; } } -- cgit From 399fb822ef81bd2440da8ab48cc2028a6b44d5b7 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 8 Jan 2010 17:13:58 +0100 Subject: swunolocking1: #i105557#: fix locking for SwXDocumentIndex: add Impl struct, and use UnoImplPtr to lock destructor. move all implementation details out of header, into Impl struct. replace broken SwClient iteration with a WeakReference in SwFrmFmt. make constructor private, and add factory function CreateXDocumentIndex. use new XUnoTunnel helpers. clean up the implementation a little. remove SwXDocumentIndexes::GetObject(). --- sw/inc/unoidx.hxx | 197 ++-- sw/source/core/unocore/unocrsrhelper.cxx | 8 +- sw/source/core/unocore/unoidx.cxx | 1681 +++++++++++++++++------------- sw/source/core/unocore/unosect.cxx | 3 +- 4 files changed, 1082 insertions(+), 807 deletions(-) (limited to 'sw') diff --git a/sw/inc/unoidx.hxx b/sw/inc/unoidx.hxx index ef503926ad1f..f82e2c9984d2 100644 --- a/sw/inc/unoidx.hxx +++ b/sw/inc/unoidx.hxx @@ -53,101 +53,143 @@ class SwTOXType; /* -----------------07.12.98 10:08------------------- * * --------------------------------------------------*/ -class SwDocIdxProperties_Impl; class SwXIndexStyleAccess_Impl; class SwXIndexTokenAccess_Impl; -class SwXDocumentIndex : public cppu::WeakImplHelper5 -< - ::com::sun::star::text::XDocumentIndex, - ::com::sun::star::lang::XServiceInfo, - ::com::sun::star::beans::XPropertySet, - ::com::sun::star::container::XNamed, - ::com::sun::star::lang::XUnoTunnel ->, - public SwClient -{ - friend class SwXIndexStyleAccess_Impl; - friend class SwXIndexTokenAccess_Impl; +typedef ::cppu::WeakImplHelper5 +< ::com::sun::star::lang::XUnoTunnel +, ::com::sun::star::lang::XServiceInfo +, ::com::sun::star::beans::XPropertySet +, ::com::sun::star::container::XNamed +, ::com::sun::star::text::XDocumentIndex +> SwXDocumentIndex_Base; - SwEventListenerContainer aLstnrCntnr; - const SfxItemPropertySet* m_pPropSet; - SwDoc* m_pDoc; - const SwTOXBaseSection* pBase; - TOXTypes eTOXType; +class SwXDocumentIndex + : public SwXDocumentIndex_Base +{ - //Descriptor-Interface - sal_Bool bIsDescriptor; - SwDocIdxProperties_Impl* pProps; +private: - SwXIndexStyleAccess_Impl* pStyleAccess; - SwXIndexTokenAccess_Impl* pTokenAccess; + friend class SwXIndexStyleAccess_Impl; + friend class SwXIndexTokenAccess_Impl; - SwSectionFmt* GetFmt()const {return (SwSectionFmt*)GetRegisteredIn();} + class Impl; + ::sw::UnoImplPtr m_pImpl; - sal_Bool IsDescriptor() const {return bIsDescriptor;} - const SwDocIdxProperties_Impl* GetProperties_Impl() const { return pProps;} - SwDocIdxProperties_Impl* GetProperties_Impl() { return pProps;} - TOXTypes GetTOXType() const {return eTOXType;} + virtual ~SwXDocumentIndex(); - SwXIndexStyleAccess_Impl* GetStyleAccess() const {return pStyleAccess;} - void SetStyleAccess(SwXIndexStyleAccess_Impl* pSet) - {pStyleAccess = pSet;} + SwXDocumentIndex(SwTOXBaseSection const&, SwDoc &); - SwXIndexTokenAccess_Impl* GetTokenAccess() const {return pTokenAccess;} - void SetTokenAccess(SwXIndexTokenAccess_Impl* pSet) - {pTokenAccess = pSet;} -protected: - virtual ~SwXDocumentIndex(); public: - SwXDocumentIndex(const SwTOXBaseSection* = 0, SwDoc* = 0); - //Descriptor-Ctor - SwXDocumentIndex(TOXTypes eToxType, SwDoc& rDoc); + /// descriptor + SwXDocumentIndex(const TOXTypes eToxType, SwDoc& rDoc); - TYPEINFO(); + static ::com::sun::star::uno::Reference< + ::com::sun::star::text::XDocumentIndex> + CreateXDocumentIndex(SwDoc & rDoc, SwTOXBaseSection const& rSection); static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId(); - //XUnoTunnel - virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); - - //XDocumentIndex - virtual ::rtl::OUString SAL_CALL getServiceName( ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL update( ) throw(::com::sun::star::uno::RuntimeException); + // XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( + const ::com::sun::star::uno::Sequence< sal_Int8 >& rIdentifier) + throw (::com::sun::star::uno::RuntimeException); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( + const ::rtl::OUString& rServiceName) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL + getSupportedServiceNames() + throw (::com::sun::star::uno::RuntimeException); + + // XComponent + virtual void SAL_CALL dispose() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addEventListener( + const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XEventListener > & xListener) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeEventListener( + const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XEventListener > & xListener) + throw (::com::sun::star::uno::RuntimeException); + + // XPropertySet + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySetInfo > SAL_CALL + getPropertySetInfo() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertyValue( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Any& rValue) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::beans::PropertyVetoException, + ::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( + const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addPropertyChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertyChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removePropertyChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertyChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addVetoableChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XVetoableChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeVetoableChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XVetoableChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + + // XNamed + virtual ::rtl::OUString SAL_CALL getName() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setName(const ::rtl::OUString& rName) + throw (::com::sun::star::uno::RuntimeException); + + // XTextContent + virtual void SAL_CALL attach( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xTextRange) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > SAL_CALL getAnchor() + throw (::com::sun::star::uno::RuntimeException); + + + // XDocumentIndex + virtual ::rtl::OUString SAL_CALL getServiceName() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL update() + throw (::com::sun::star::uno::RuntimeException); - //XPropertySet - virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - - //XTextContent - virtual void SAL_CALL attach(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xTextRange) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getAnchor(void) throw( ::com::sun::star::uno::RuntimeException ); - - //XComponent - virtual void SAL_CALL dispose(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw( ::com::sun::star::uno::RuntimeException ); - - //XNamed - virtual rtl::OUString SAL_CALL getName(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL setName(const rtl::OUString& Name_) throw( ::com::sun::star::uno::RuntimeException ); - - //XServiceInfo - virtual rtl::OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual BOOL SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException ); - - //SwClient - virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew); - - void attachToRange(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xTextRange)throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); }; + /* -----------------07.12.98 10:08------------------- * * --------------------------------------------------*/ @@ -274,7 +316,6 @@ public: virtual BOOL SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException ); virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException ); - static SwXDocumentIndex* GetObject(const SwTOXBaseSection* pTOX); }; /* -----------------13.09.99 16:39------------------- diff --git a/sw/source/core/unocore/unocrsrhelper.cxx b/sw/source/core/unocore/unocrsrhelper.cxx index 29318ce49986..df34c675bfa0 100644 --- a/sw/source/core/unocore/unocrsrhelper.cxx +++ b/sw/source/core/unocore/unocrsrhelper.cxx @@ -69,6 +69,7 @@ #include #include #include +#include #include #include #include @@ -331,9 +332,10 @@ sal_Bool getCrsrPropertyValue(const SfxItemPropertySimpleEntry& rEntry { if( pAny ) { - uno::Reference< XDocumentIndex > aRef = - SwXDocumentIndexes::GetObject((SwTOXBaseSection*)pBase); - pAny->setValue(&aRef, ::getCppuType((uno::Reference*)0)); + const uno::Reference< text::XDocumentIndex > xRef = + SwXDocumentIndex::CreateXDocumentIndex(*rPam.GetDoc(), + *static_cast(pBase)); + (*pAny) <<= xRef; } } else diff --git a/sw/source/core/unocore/unoidx.cxx b/sw/source/core/unocore/unoidx.cxx index 8fad219d742e..d860cedd3fb7 100644 --- a/sw/source/core/unocore/unoidx.cxx +++ b/sw/source/core/unocore/unoidx.cxx @@ -31,19 +31,19 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" -#include - -#include -#include -#include -#include -#include #include #include #include #include #include #include + +#include +#include +#include +#include + +#include #include #include #include @@ -59,6 +59,7 @@ #include #include #include +#include #include #include #include @@ -74,36 +75,61 @@ using namespace ::com::sun::star; using ::rtl::OUString; //----------------------------------------------------------------------------- -String lcl_AnyToString(uno::Any rVal) throw(lang::IllegalArgumentException) +static String +lcl_AnyToString(uno::Any const& rVal) throw (lang::IllegalArgumentException) { OUString sRet; if(!(rVal >>= sRet)) + { throw lang::IllegalArgumentException(); + } return sRet; } //----------------------------------------------------------------------------- -sal_Int16 lcl_AnyToInt16(uno::Any rVal) throw(lang::IllegalArgumentException) +static sal_Int16 +lcl_AnyToInt16(uno::Any const& rVal) throw (lang::IllegalArgumentException) { sal_Int16 nRet = 0; if(!(rVal >>= nRet)) + { throw lang::IllegalArgumentException(); + } return nRet; } //----------------------------------------------------------------------------- -sal_Bool lcl_AnyToBool(uno::Any rVal) throw(lang::IllegalArgumentException) +static sal_Bool +lcl_AnyToBool(uno::Any const& rVal) throw (lang::IllegalArgumentException) { sal_Bool bRet = sal_False; if(!(rVal >>= bRet)) + { throw lang::IllegalArgumentException(); + } return bRet; } -/****************************************************************************** - * - ******************************************************************************/ + +static void +lcl_AnyToBitMask(uno::Any const& rValue, + sal_uInt16 & rBitMask, const sal_uInt16 nBit) +throw (lang::IllegalArgumentException) +{ + rBitMask = lcl_AnyToBool(rValue) + ? (rBitMask | nBit) + : (rBitMask & ~nBit); +} +static void +lcl_BitMaskToAny(uno::Any & o_rValue, + const sal_uInt16 nBitMask, const sal_uInt16 nBit) +{ + const sal_Bool bRet = 0 != (nBitMask & nBit); + o_rValue <<= bRet; +} + //----------------------------------------------------------------------------- -void lcl_ReAssignTOXType(SwDoc* pDoc, SwTOXBase& rTOXBase, const OUString& rNewName) +static void +lcl_ReAssignTOXType(SwDoc* pDoc, SwTOXBase& rTOXBase, const OUString& rNewName) { - sal_uInt16 nUserCount = pDoc->GetTOXTypeCount( TOX_USER ); + const sal_uInt16 nUserCount = pDoc->GetTOXTypeCount( TOX_USER ); const SwTOXType* pNewType = 0; for(sal_uInt16 nUser = 0; nUser < nUserCount; nUser++) { @@ -133,14 +159,19 @@ void lcl_ConvertTOUNameToProgrammaticName(OUString& rTmp) ShellResource* pShellRes = ViewShell::GetShellRes(); if(rTmp.equals(pShellRes->aTOXUserName)) + { rTmp = OUString(C2U(cUserDefined)); - //if the version is not English but the alternative index's name is "User-Defined" - //a " (user)" is appended + } + // if the version is not English but the alternative index's name is + // "User-Defined" a " (user)" is appended else if(rTmp.equalsAscii(cUserDefined)) + { rTmp += C2U(cUserSuffix); + } } //----------------------------------------------------------------------------- -void lcl_ConvertTOUNameToUserName(OUString& rTmp) +static void +lcl_ConvertTOUNameToUserName(OUString& rTmp) { ShellResource* pShellRes = ViewShell::GetShellRes(); if(rTmp.equalsAscii(cUserDefined)) @@ -150,43 +181,189 @@ void lcl_ConvertTOUNameToUserName(OUString& rTmp) else if(!pShellRes->aTOXUserName.EqualsAscii(cUserDefined) && USER_AND_SUFFIXLEN == rTmp.getLength()) { - String sToChange(rTmp); //make sure that in non-English versions the " (user)" suffix is removed - if(!sToChange.SearchAscii(cUserDefined) && USER_LEN == sToChange.SearchAscii(cUserSuffix)) + if (rTmp.matchAsciiL(cUserDefined, sizeof(cUserDefined)) && + rTmp.matchAsciiL(cUserSuffix, sizeof(cUserSuffix), USER_LEN)) + { rTmp = C2U(cUserDefined); + } } } /****************************************************************** * SwXDocumentIndex ******************************************************************/ + /* -----------------20.06.98 11:06------------------- * * --------------------------------------------------*/ -class SwDocIdxProperties_Impl +class SwDocIndexDescriptorProperties_Impl { - SwTOXBase* pTOXBase; - OUString sUserTOXTypeName; +private: + ::std::auto_ptr m_pTOXBase; + OUString m_sUserTOXTypeName; + public: - SwTOXBase& GetTOXBase() {return *pTOXBase;} - SwDocIdxProperties_Impl(const SwTOXType* pType); - ~SwDocIdxProperties_Impl(){delete pTOXBase;} + SwDocIndexDescriptorProperties_Impl(SwTOXType const*const pType); - const OUString& GetTypeName()const {return sUserTOXTypeName;} - void SetTypeName(const OUString& rSet) {sUserTOXTypeName = rSet;} + SwTOXBase & GetTOXBase() { return *m_pTOXBase; } + const OUString& GetTypeName() const { return m_sUserTOXTypeName; } + void SetTypeName(const OUString& rSet) { m_sUserTOXTypeName = rSet; } }; /* -----------------20.06.98 11:41------------------- * * --------------------------------------------------*/ -SwDocIdxProperties_Impl::SwDocIdxProperties_Impl(const SwTOXType* pType) +SwDocIndexDescriptorProperties_Impl::SwDocIndexDescriptorProperties_Impl( + SwTOXType const*const pType) { SwForm aForm(pType->GetType()); - pTOXBase = new SwTOXBase(pType, aForm, - nsSwTOXElement::TOX_MARK, pType->GetTypeName()); + m_pTOXBase.reset(new SwTOXBase(pType, aForm, + nsSwTOXElement::TOX_MARK, pType->GetTypeName())); if(pType->GetType() == TOX_CONTENT || pType->GetType() == TOX_USER) - pTOXBase->SetLevel(MAXLEVEL); - sUserTOXTypeName = pType->GetTypeName(); + { + m_pTOXBase->SetLevel(MAXLEVEL); + } + m_sUserTOXTypeName = pType->GetTypeName(); +} + +static sal_uInt16 +lcl_TypeToPropertyMap(const TOXTypes eType) +{ + switch (eType) + { + case TOX_INDEX: return PROPERTY_MAP_INDEX_IDX; + case TOX_CONTENT: return PROPERTY_MAP_INDEX_CNTNT; + case TOX_TABLES: return PROPERTY_MAP_INDEX_TABLES; + case TOX_ILLUSTRATIONS: return PROPERTY_MAP_INDEX_ILLUSTRATIONS; + case TOX_OBJECTS: return PROPERTY_MAP_INDEX_OBJECTS; + case TOX_AUTHORITIES: return PROPERTY_MAP_BIBLIOGRAPHY; + //case TOX_USER: + default: + return PROPERTY_MAP_INDEX_USER; + } +} + +class SwXDocumentIndex::Impl + : public SwClient +{ + +public: + + SfxItemPropertySet const& m_rPropSet; + const TOXTypes m_eTOXType; + SwEventListenerContainer m_ListenerContainer; + bool m_bIsDescriptor; + SwDoc * m_pDoc; + ::std::auto_ptr m_pProps; + uno::WeakReference m_wStyleAccess; + uno::WeakReference m_wTokenAccess; + + Impl( SwXDocumentIndex & rThis, + SwDoc & rDoc, + const TOXTypes eType, + SwTOXBaseSection const*const pBaseSection) + : SwClient((pBaseSection) ? pBaseSection->GetFmt() : 0) + , m_rPropSet( + *aSwMapProvider.GetPropertySet(lcl_TypeToPropertyMap(eType))) + , m_eTOXType(eType) + , m_ListenerContainer(static_cast< ::cppu::OWeakObject* >(&rThis)) + , m_bIsDescriptor(0 == pBaseSection) + , m_pDoc(&rDoc) + , m_pProps((m_bIsDescriptor) + ? new SwDocIndexDescriptorProperties_Impl(rDoc.GetTOXType(eType, 0)) + : 0) + { + } + + SwSectionFmt * GetSectionFmt() const { + return static_cast( + const_cast(GetRegisteredIn())); + } + + SwTOXBase & GetTOXSectionOrThrow() const + { + SwSectionFmt *const pSectionFmt(GetSectionFmt()); + SwTOXBase *const pTOXSection( (m_bIsDescriptor) + ? &m_pProps->GetTOXBase() + : ((pSectionFmt) + ? static_cast(pSectionFmt->GetSection()) + : 0)); + if (!pTOXSection) + { + throw uno::RuntimeException(OUString(RTL_CONSTASCII_USTRINGPARAM( + "SwXDocumentIndex: disposed or invalid")), 0); + } + return *pTOXSection; + } + + sal_Int32 GetFormMax() const + { + SwTOXBase & rSection( GetTOXSectionOrThrow() ); + return (m_bIsDescriptor) + ? SwForm::GetFormMaxLevel(m_eTOXType) + : rSection.GetTOXForm().GetFormMax(); + } + + // SwClient + virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + +}; + +/*-- 14.12.98 09:35:07--------------------------------------------------- + + -----------------------------------------------------------------------*/ +void SwXDocumentIndex::Impl::Modify(SfxPoolItem *pOld, SfxPoolItem *pNew) +{ + ClientModify(this, pOld, pNew); + + if (!GetRegisteredIn()) + { + m_ListenerContainer.Disposing(); + } +} + +/*-- 14.12.98 09:35:03--------------------------------------------------- + + -----------------------------------------------------------------------*/ +SwXDocumentIndex::SwXDocumentIndex( + SwTOXBaseSection const& rBaseSection, SwDoc & rDoc) + : m_pImpl( new SwXDocumentIndex::Impl( *this, + rDoc, rBaseSection.SwTOXBase::GetType(), & rBaseSection) ) +{ +} +/* -----------------15.01.99 14:59------------------- + * + * --------------------------------------------------*/ +SwXDocumentIndex::SwXDocumentIndex(const TOXTypes eType, SwDoc& rDoc) + : m_pImpl( new SwXDocumentIndex::Impl( *this, rDoc, eType, 0) ) +{ +} + +/*-- 14.12.98 09:35:04--------------------------------------------------- + + -----------------------------------------------------------------------*/ +SwXDocumentIndex::~SwXDocumentIndex() +{ } + +uno::Reference +SwXDocumentIndex::CreateXDocumentIndex( + SwDoc & rDoc, SwTOXBaseSection const& rSection) +{ + // re-use existing SwXDocumentIndex + // #i105557#: do not iterate over the registered clients: race condition + SwSectionFmt *const pFmt = rSection.GetFmt(); + uno::Reference xIndex(pFmt->GetXObject(), + uno::UNO_QUERY); + if (!xIndex.is()) + { + SwXDocumentIndex *const pIndex(new SwXDocumentIndex(rSection, rDoc)); + xIndex.set(pIndex); + pFmt->SetXObject(uno::Reference(xIndex)); + } + return xIndex; +} + /* -----------------------------10.03.00 18:02-------------------------------- ---------------------------------------------------------------------------*/ @@ -198,505 +375,530 @@ const uno::Sequence< sal_Int8 > & SwXDocumentIndex::getUnoTunnelId() /* -----------------------------10.03.00 18:04-------------------------------- ---------------------------------------------------------------------------*/ -sal_Int64 SAL_CALL SwXDocumentIndex::getSomething( const uno::Sequence< sal_Int8 >& rId ) - throw(uno::RuntimeException) +sal_Int64 SAL_CALL +SwXDocumentIndex::getSomething(const uno::Sequence< sal_Int8 >& rId) +throw (uno::RuntimeException) { - if( rId.getLength() == 16 - && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), - rId.getConstArray(), 16 ) ) - { - return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(this) ); - } - return 0; + return ::sw::UnoTunnelImpl(rId, this); } + /* -----------------------------06.04.00 15:01-------------------------------- ---------------------------------------------------------------------------*/ -OUString SwXDocumentIndex::getImplementationName(void) throw( uno::RuntimeException ) +OUString SAL_CALL +SwXDocumentIndex::getImplementationName() throw (uno::RuntimeException) { return C2U("SwXDocumentIndex"); } /* -----------------------------06.04.00 15:01-------------------------------- ---------------------------------------------------------------------------*/ -BOOL SwXDocumentIndex::supportsService(const OUString& rServiceName) throw( uno::RuntimeException ) -{ - return C2U("com.sun.star.text.BaseIndex") == rServiceName || - ( TOX_INDEX == eTOXType && C2U("com.sun.star.text.DocumentIndex") == rServiceName) || - ( TOX_CONTENT == eTOXType && C2U("com.sun.star.text.ContentIndex") == rServiceName) || - ( TOX_USER == eTOXType && C2U("com.sun.star.text.UserDefinedIndex") == rServiceName) || - ( TOX_ILLUSTRATIONS == eTOXType && C2U("com.sun.star.text.IllustrationsIndex") == rServiceName) || - ( TOX_TABLES == eTOXType && C2U("com.sun.star.text.TableIndex") == rServiceName) || - ( TOX_OBJECTS == eTOXType && C2U("com.sun.star.text.ObjectIndex") == rServiceName) || - ( TOX_AUTHORITIES == eTOXType && C2U("com.sun.star.text.Bibliography") == rServiceName); +sal_Bool SAL_CALL +SwXDocumentIndex::supportsService(const OUString& rServiceName) +throw (uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + + return C2U("com.sun.star.text.BaseIndex") == rServiceName + || ((TOX_INDEX == m_pImpl->m_eTOXType) && + rServiceName.equalsAscii("com.sun.star.text.DocumentIndex")) + || ((TOX_CONTENT == m_pImpl->m_eTOXType) && + rServiceName.equalsAscii("com.sun.star.text.ContentIndex")) + || ((TOX_USER == m_pImpl->m_eTOXType) && + rServiceName.equalsAscii("com.sun.star.text.UserDefinedIndex")) + || ((TOX_ILLUSTRATIONS == m_pImpl->m_eTOXType) && + rServiceName.equalsAscii("com.sun.star.text.IllustrationsIndex")) + || ((TOX_TABLES == m_pImpl->m_eTOXType) && + rServiceName.equalsAscii("com.sun.star.text.TableIndex")) + || ((TOX_OBJECTS == m_pImpl->m_eTOXType) && + rServiceName.equalsAscii("com.sun.star.text.ObjectIndex")) + || ((TOX_AUTHORITIES == m_pImpl->m_eTOXType) && + rServiceName.equalsAscii("com.sun.star.text.Bibliography")); } /* -----------------------------06.04.00 15:01-------------------------------- ---------------------------------------------------------------------------*/ -uno::Sequence< OUString > SwXDocumentIndex::getSupportedServiceNames(void) throw( uno::RuntimeException ) +uno::Sequence< OUString > SAL_CALL +SwXDocumentIndex::getSupportedServiceNames() throw (uno::RuntimeException) { + vos::OGuard g(Application::GetSolarMutex()); + uno::Sequence< OUString > aRet(2); OUString* pArray = aRet.getArray(); pArray[0] = C2U("com.sun.star.text.BaseIndex"); - switch( eTOXType ) - { - case TOX_INDEX: pArray[1] = C2U("com.sun.star.text.DocumentIndex");break; - case TOX_CONTENT: pArray[1] = C2U("com.sun.star.text.ContentIndex");break; - case TOX_TABLES: pArray[1] = C2U("com.sun.star.text.TableIndex");break; - case TOX_ILLUSTRATIONS: pArray[1] = C2U("com.sun.star.text.IllustrationsIndex");break; - case TOX_OBJECTS: pArray[1] = C2U("com.sun.star.text.ObjectIndex");break; - case TOX_AUTHORITIES : pArray[1] = C2U("com.sun.star.text.Bibliography");break; + switch (m_pImpl->m_eTOXType) + { + case TOX_INDEX: + pArray[1] = C2U("com.sun.star.text.DocumentIndex"); + break; + case TOX_CONTENT: + pArray[1] = C2U("com.sun.star.text.ContentIndex"); + break; + case TOX_TABLES: + pArray[1] = C2U("com.sun.star.text.TableIndex"); + break; + case TOX_ILLUSTRATIONS: + pArray[1] = C2U("com.sun.star.text.IllustrationsIndex"); + break; + case TOX_OBJECTS: + pArray[1] = C2U("com.sun.star.text.ObjectIndex"); + break; + case TOX_AUTHORITIES: + pArray[1] = C2U("com.sun.star.text.Bibliography"); + break; //case TOX_USER: default: pArray[1] = C2U("com.sun.star.text.UserDefinedIndex"); } return aRet; } -/*-- 14.12.98 09:35:03--------------------------------------------------- - - -----------------------------------------------------------------------*/ -TYPEINIT1(SwXDocumentIndex, SwClient) -SwXDocumentIndex::SwXDocumentIndex(const SwTOXBaseSection* pB, SwDoc* pDc) : - aLstnrCntnr( (text::XTextContent*)this), - m_pPropSet(0), - m_pDoc(pDc), - pBase(pB), - eTOXType(TOX_USER), - bIsDescriptor(sal_False), - pProps(0), - pStyleAccess(0), - pTokenAccess(0) -{ - if(pBase && m_pDoc) - { - pBase->GetFmt()->Add(this); - sal_uInt16 PropertyId; - eTOXType = pBase->SwTOXBase::GetType(); - switch( eTOXType ) - { - case TOX_INDEX: PropertyId = PROPERTY_MAP_INDEX_IDX; break; - case TOX_CONTENT: PropertyId = PROPERTY_MAP_INDEX_CNTNT; break; - case TOX_TABLES: PropertyId = PROPERTY_MAP_INDEX_TABLES; break; - case TOX_ILLUSTRATIONS: PropertyId = PROPERTY_MAP_INDEX_ILLUSTRATIONS; break; - case TOX_OBJECTS: PropertyId = PROPERTY_MAP_INDEX_OBJECTS; break; - case TOX_AUTHORITIES : PropertyId = PROPERTY_MAP_BIBLIOGRAPHY; break; - //case TOX_USER: - default: - PropertyId = PROPERTY_MAP_INDEX_USER; - } - m_pPropSet = aSwMapProvider.GetPropertySet(PropertyId); - } -} -/* -----------------15.01.99 14:59------------------- - * - * --------------------------------------------------*/ -SwXDocumentIndex::SwXDocumentIndex(TOXTypes eType, SwDoc& rDoc) : - aLstnrCntnr( (text::XTextContent*)this), - m_pDoc(0), - pBase(0), - eTOXType(eType), - bIsDescriptor(sal_True), - pProps(new SwDocIdxProperties_Impl(rDoc.GetTOXType(eType, 0))), - pStyleAccess(0), - pTokenAccess(0) -{ - sal_uInt16 PropertyId; - switch(eType) - { - case TOX_INDEX: PropertyId = PROPERTY_MAP_INDEX_IDX; break; - case TOX_CONTENT: PropertyId = PROPERTY_MAP_INDEX_CNTNT; break; - case TOX_TABLES: PropertyId = PROPERTY_MAP_INDEX_TABLES; break; - case TOX_ILLUSTRATIONS: PropertyId = PROPERTY_MAP_INDEX_ILLUSTRATIONS; break; - case TOX_OBJECTS: PropertyId = PROPERTY_MAP_INDEX_OBJECTS; break; - case TOX_AUTHORITIES : PropertyId = PROPERTY_MAP_BIBLIOGRAPHY; break; - //case TOX_USER: - default: - PropertyId = PROPERTY_MAP_INDEX_USER; - } - m_pPropSet = aSwMapProvider.GetPropertySet(PropertyId); -} - -/*-- 14.12.98 09:35:04--------------------------------------------------- - -----------------------------------------------------------------------*/ -SwXDocumentIndex::~SwXDocumentIndex() -{ - delete pProps; -} /*-- 14.12.98 09:35:05--------------------------------------------------- -----------------------------------------------------------------------*/ -OUString SwXDocumentIndex::getServiceName(void) throw( uno::RuntimeException ) +OUString SAL_CALL SwXDocumentIndex::getServiceName() +throw (uno::RuntimeException) { + vos::OGuard g(Application::GetSolarMutex()); + USHORT nObjectType = SW_SERVICE_TYPE_INDEX; - switch(eTOXType) + switch (m_pImpl->m_eTOXType) { // case TOX_INDEX: break; - case TOX_USER: nObjectType = SW_SERVICE_USER_INDEX;break; - case TOX_CONTENT: nObjectType = SW_SERVICE_CONTENT_INDEX;break; - case TOX_ILLUSTRATIONS: nObjectType = SW_SERVICE_INDEX_ILLUSTRATIONS;break; - case TOX_OBJECTS: nObjectType = SW_SERVICE_INDEX_OBJECTS;break; - case TOX_TABLES: nObjectType = SW_SERVICE_INDEX_TABLES;break; - case TOX_AUTHORITIES: nObjectType = SW_SERVICE_INDEX_BIBLIOGRAPHY;break; + case TOX_USER: nObjectType = SW_SERVICE_USER_INDEX; + break; + case TOX_CONTENT: nObjectType = SW_SERVICE_CONTENT_INDEX; + break; + case TOX_ILLUSTRATIONS: nObjectType = SW_SERVICE_INDEX_ILLUSTRATIONS; + break; + case TOX_OBJECTS: nObjectType = SW_SERVICE_INDEX_OBJECTS; + break; + case TOX_TABLES: nObjectType = SW_SERVICE_INDEX_TABLES; + break; + case TOX_AUTHORITIES: nObjectType = SW_SERVICE_INDEX_BIBLIOGRAPHY; + break; default: - ; + break; } return SwXServiceProvider::GetProviderName(nObjectType); } + /*-- 14.12.98 09:35:05--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXDocumentIndex::update(void) throw( uno::RuntimeException ) +void SAL_CALL SwXDocumentIndex::update() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwSectionFmt *pFmt = GetFmt(); - SwTOXBase* pTOXBase = pFmt ? (SwTOXBaseSection*)pFmt->GetSection() : 0; + + SwSectionFmt *const pFmt = m_pImpl->GetSectionFmt(); + SwTOXBaseSection *const pTOXBase = (pFmt) ? + static_cast(pFmt->GetSection()) : 0; if(!pTOXBase) + { throw uno::RuntimeException(); - ((SwTOXBaseSection*)pTOXBase)->Update(); - // Seitennummern eintragen - ((SwTOXBaseSection*)pTOXBase)->UpdatePageNum(); + } + pTOXBase->Update(); + // page numbers + pTOXBase->UpdatePageNum(); } + /*-- 14.12.98 09:35:05--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< beans::XPropertySetInfo > SwXDocumentIndex::getPropertySetInfo(void) throw( uno::RuntimeException ) +uno::Reference< beans::XPropertySetInfo > SAL_CALL +SwXDocumentIndex::getPropertySetInfo() throw (uno::RuntimeException) { - uno::Reference< beans::XPropertySetInfo > aRef = m_pPropSet->getPropertySetInfo(); - return aRef; + vos::OGuard g(Application::GetSolarMutex()); + + const uno::Reference< beans::XPropertySetInfo > xRef = + m_pImpl->m_rPropSet.getPropertySetInfo(); + return xRef; } + /*-- 14.12.98 09:35:05--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXDocumentIndex::setPropertyValue(const OUString& rPropertyName, - const uno::Any& aValue) - throw( beans::UnknownPropertyException, beans::PropertyVetoException, - lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +void SAL_CALL +SwXDocumentIndex::setPropertyValue( + const OUString& rPropertyName, const uno::Any& rValue) +throw (beans::UnknownPropertyException, beans::PropertyVetoException, + lang::IllegalArgumentException, lang::WrappedTargetException, + uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName(rPropertyName); + + SfxItemPropertySimpleEntry const*const pEntry = + m_pImpl->m_rPropSet.getPropertyMap()->getByName(rPropertyName); if (!pEntry) - throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); - if ( pEntry->nFlags & beans::PropertyAttribute::READONLY) - throw beans::PropertyVetoException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); + { + throw beans::UnknownPropertyException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) + + rPropertyName, + static_cast(this)); + } + if (pEntry->nFlags & beans::PropertyAttribute::READONLY) + { + throw beans::PropertyVetoException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Property is read-only: " )) + + rPropertyName, + static_cast(this)); + } - SwTOXBase* pTOXBase = 0; - if(GetFmt()) - pTOXBase = (SwTOXBaseSection*)GetFmt()->GetSection(); - else if(bIsDescriptor) - pTOXBase = &pProps->GetTOXBase(); - if(pTOXBase) + SwSectionFmt *const pSectionFmt(m_pImpl->GetSectionFmt()); + SwTOXBase & rTOXBase( m_pImpl->GetTOXSectionOrThrow() ); + + sal_uInt16 nCreate = rTOXBase.GetCreateType(); + sal_uInt16 nTOIOptions = 0; + sal_uInt16 nOLEOptions = rTOXBase.GetOLEOptions(); + const TOXTypes eTxBaseType = rTOXBase.GetTOXType()->GetType(); + if (eTxBaseType == TOX_INDEX) { - sal_uInt16 nCreate = pTOXBase->GetCreateType(); - sal_uInt16 nTOIOptions = 0; - sal_uInt16 nOLEOptions = pTOXBase->GetOLEOptions(); - TOXTypes eTxBaseType = pTOXBase->GetTOXType()->GetType(); - if( eTxBaseType == TOX_INDEX ) - nTOIOptions = pTOXBase->GetOptions(); - SwForm aForm(pTOXBase->GetTOXForm()); - sal_Bool bForm = sal_False; - SfxItemSet* pAttrSet = 0; - switch(pEntry->nWID) + nTOIOptions = rTOXBase.GetOptions(); + } + SwForm aForm(rTOXBase.GetTOXForm()); + sal_Bool bForm = sal_False; + switch (pEntry->nWID) + { + case WID_IDX_TITLE: { - case WID_IDX_TITLE : - { - OUString sNewName; - aValue >>= sNewName; - pTOXBase->SetTitle(sNewName); - } - break; - case WID_IDX_NAME: - { - OUString sNewName; - aValue >>= sNewName; - pTOXBase->SetTOXName(sNewName); - } - break; - case WID_USER_IDX_NAME: + OUString sNewName; + if (!(rValue >>= sNewName)) { - OUString sNewName; - aValue >>= sNewName; - lcl_ConvertTOUNameToUserName(sNewName); - DBG_ASSERT(TOX_USER == eTxBaseType, "tox type name can only be changed for user indexes"); - if(GetFmt()) - { - OUString sTmp = pTOXBase->GetTOXType()->GetTypeName(); - if(sTmp != sNewName) - { - lcl_ReAssignTOXType(GetFmt()->GetDoc(), *pTOXBase, sNewName); - } - } - else - pProps->SetTypeName(sNewName); + throw lang::IllegalArgumentException(); } - break; - case WID_IDX_LOCALE: + rTOXBase.SetTitle(sNewName); + } + break; + case WID_IDX_NAME: + { + OUString sNewName; + if (!(rValue >>= sNewName)) { - lang::Locale aLocale; - if(aValue>>= aLocale) - pTOXBase->SetLanguage(SvxLocaleToLanguage(aLocale)); - else - throw lang::IllegalArgumentException(); + throw lang::IllegalArgumentException(); } - break; - case WID_IDX_SORT_ALGORITHM: + rTOXBase.SetTOXName(sNewName); + } + break; + case WID_USER_IDX_NAME: + { + OUString sNewName; + if (!(rValue >>= sNewName)) { - OUString sTmp; - if(aValue >>= sTmp) - pTOXBase->SetSortAlgorithm(sTmp); - else - throw lang::IllegalArgumentException(); + throw lang::IllegalArgumentException(); } - break; - case WID_LEVEL : - pTOXBase->SetLevel(lcl_AnyToInt16(aValue)); - break; - case WID_CREATE_FROM_MARKS : - nCreate = lcl_AnyToBool(aValue) ? nCreate | nsSwTOXElement::TOX_MARK: nCreate & ~nsSwTOXElement::TOX_MARK; - break; - case WID_CREATE_FROM_OUTLINE : - nCreate = lcl_AnyToBool(aValue) ? nCreate | nsSwTOXElement::TOX_OUTLINELEVEL: nCreate & ~nsSwTOXElement::TOX_OUTLINELEVEL; - break; -// case WID_PARAGRAPH_STYLE_NAMES :DBG_ERROR("not implemented") -// break; - case WID_CREATE_FROM_CHAPTER : - pTOXBase->SetFromChapter(lcl_AnyToBool(aValue)); - break; - case WID_CREATE_FROM_LABELS : - pTOXBase->SetFromObjectNames(! lcl_AnyToBool(aValue)); - break; - case WID_PROTECTED : + lcl_ConvertTOUNameToUserName(sNewName); + DBG_ASSERT(TOX_USER == eTxBaseType, + "tox type name can only be changed for user indexes"); + if (pSectionFmt) { - sal_Bool bSet = lcl_AnyToBool(aValue); - pTOXBase->SetProtected(bSet); - if(GetFmt()) - ((SwTOXBaseSection*)pTOXBase)->SetProtect(bSet); + OUString sTmp = rTOXBase.GetTOXType()->GetTypeName(); + if (sTmp != sNewName) + { + lcl_ReAssignTOXType(pSectionFmt->GetDoc(), + rTOXBase, sNewName); + } } - break; - case WID_USE_ALPHABETICAL_SEPARATORS: - nTOIOptions = lcl_AnyToBool(aValue) ? - nTOIOptions | nsSwTOIOptions::TOI_ALPHA_DELIMITTER : nTOIOptions & ~nsSwTOIOptions::TOI_ALPHA_DELIMITTER; - break; - case WID_USE_KEY_AS_ENTRY : - nTOIOptions = lcl_AnyToBool(aValue) ? - nTOIOptions | nsSwTOIOptions::TOI_KEY_AS_ENTRY : nTOIOptions & ~nsSwTOIOptions::TOI_KEY_AS_ENTRY; - break; - case WID_USE_COMBINED_ENTRIES : - nTOIOptions = lcl_AnyToBool(aValue) ? - nTOIOptions | nsSwTOIOptions::TOI_SAME_ENTRY : nTOIOptions & ~nsSwTOIOptions::TOI_SAME_ENTRY; - break; - case WID_IS_CASE_SENSITIVE : - nTOIOptions = lcl_AnyToBool(aValue) ? - nTOIOptions | nsSwTOIOptions::TOI_CASE_SENSITIVE : nTOIOptions & ~nsSwTOIOptions::TOI_CASE_SENSITIVE; - break; - case WID_USE_P_P : - nTOIOptions = lcl_AnyToBool(aValue) ? - nTOIOptions | nsSwTOIOptions::TOI_FF : nTOIOptions & ~nsSwTOIOptions::TOI_FF; - break; - case WID_USE_DASH : - nTOIOptions = lcl_AnyToBool(aValue) ? - nTOIOptions | nsSwTOIOptions::TOI_DASH : nTOIOptions & ~nsSwTOIOptions::TOI_DASH; - break; - case WID_USE_UPPER_CASE : - nTOIOptions = lcl_AnyToBool(aValue) ? - nTOIOptions | nsSwTOIOptions::TOI_INITIAL_CAPS : nTOIOptions & ~nsSwTOIOptions::TOI_INITIAL_CAPS; - break; - case WID_IS_COMMA_SEPARATED : - bForm = sal_True; - aForm.SetCommaSeparated(lcl_AnyToBool(aValue)); - break; - case WID_LABEL_CATEGORY : + else { - // convert file-format/API/external programmatic english name - // to internal UI name before usage - String aName( SwStyleNameMapper::GetSpecialExtraUIName( - lcl_AnyToString(aValue) ) ); - pTOXBase->SetSequenceName( aName ); + m_pImpl->m_pProps->SetTypeName(sNewName); } - break; - case WID_LABEL_DISPLAY_TYPE : + } + break; + case WID_IDX_LOCALE: + { + lang::Locale aLocale; + if (!(rValue>>= aLocale)) { - sal_Int16 nVal = lcl_AnyToInt16(aValue); - sal_uInt16 nSet = CAPTION_COMPLETE; - switch (nVal) - { - case text::ReferenceFieldPart::TEXT: nSet = CAPTION_COMPLETE; - break; - case text::ReferenceFieldPart::CATEGORY_AND_NUMBER : nSet = CAPTION_NUMBER; - break; - case text::ReferenceFieldPart::ONLY_CAPTION : nSet = CAPTION_TEXT; - break; - default: - throw lang::IllegalArgumentException(); - } - pTOXBase->SetCaptionDisplay((SwCaptionDisplay)nSet); + throw lang::IllegalArgumentException(); } - break; - case WID_USE_LEVEL_FROM_SOURCE : - pTOXBase->SetLevelFromChapter(lcl_AnyToBool(aValue)); - break; - case WID_MAIN_ENTRY_CHARACTER_STYLE_NAME : + rTOXBase.SetLanguage(SvxLocaleToLanguage(aLocale)); + } + break; + case WID_IDX_SORT_ALGORITHM: + { + OUString sTmp; + if (!(rValue >>= sTmp)) { - String aString; - SwStyleNameMapper::FillUIName(lcl_AnyToString(aValue), aString, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, sal_True); - pTOXBase->SetMainEntryCharStyle( aString ); + throw lang::IllegalArgumentException(); } - break; - case WID_CREATE_FROM_TABLES : - nCreate = lcl_AnyToBool(aValue) ? nCreate | nsSwTOXElement::TOX_TABLE : nCreate & ~nsSwTOXElement::TOX_TABLE; - break; - case WID_CREATE_FROM_TEXT_FRAMES : - nCreate = lcl_AnyToBool(aValue) ? nCreate | nsSwTOXElement::TOX_FRAME : nCreate & ~nsSwTOXElement::TOX_FRAME; - break; - case WID_CREATE_FROM_GRAPHIC_OBJECTS : - nCreate = lcl_AnyToBool(aValue) ? nCreate | nsSwTOXElement::TOX_GRAPHIC : nCreate & ~nsSwTOXElement::TOX_GRAPHIC; - break; - case WID_CREATE_FROM_EMBEDDED_OBJECTS : - if(lcl_AnyToBool(aValue)) - nCreate |= nsSwTOXElement::TOX_OLE; - else - nCreate &= ~nsSwTOXElement::TOX_OLE; - break; - case WID_CREATE_FROM_STAR_MATH: - nOLEOptions = lcl_AnyToBool(aValue) ? nOLEOptions | nsSwTOOElements::TOO_MATH : nOLEOptions & ~nsSwTOOElements::TOO_MATH; - break; - case WID_CREATE_FROM_STAR_CHART : - nOLEOptions = lcl_AnyToBool(aValue) ? nOLEOptions | nsSwTOOElements::TOO_CHART : nOLEOptions & ~nsSwTOOElements::TOO_CHART; - break; - case WID_CREATE_FROM_STAR_CALC : - nOLEOptions = lcl_AnyToBool(aValue) ? nOLEOptions | nsSwTOOElements::TOO_CALC : nOLEOptions & ~nsSwTOOElements::TOO_CALC; - break; - case WID_CREATE_FROM_STAR_DRAW : - nOLEOptions = lcl_AnyToBool(aValue) ? nOLEOptions | nsSwTOOElements::TOO_DRAW_IMPRESS : nOLEOptions & ~nsSwTOOElements::TOO_DRAW_IMPRESS; - break; - case WID_CREATE_FROM_OTHER_EMBEDDED_OBJECTS: - nOLEOptions = lcl_AnyToBool(aValue) ? nOLEOptions | nsSwTOOElements::TOO_OTHER : nOLEOptions & ~nsSwTOOElements::TOO_OTHER; - break; - case WID_PARA_HEAD : + rTOXBase.SetSortAlgorithm(sTmp); + } + break; + case WID_LEVEL: + { + rTOXBase.SetLevel(lcl_AnyToInt16(rValue)); + } + break; + case WID_CREATE_FROM_MARKS: + lcl_AnyToBitMask(rValue, nCreate, nsSwTOXElement::TOX_MARK); + break; + case WID_CREATE_FROM_OUTLINE: + lcl_AnyToBitMask(rValue, nCreate, nsSwTOXElement::TOX_OUTLINELEVEL); + break; +// case WID_PARAGRAPH_STYLE_NAMES :DBG_ERROR("not implemented") +// break; + case WID_CREATE_FROM_CHAPTER: + rTOXBase.SetFromChapter(lcl_AnyToBool(rValue)); + break; + case WID_CREATE_FROM_LABELS: + rTOXBase.SetFromObjectNames(! lcl_AnyToBool(rValue)); + break; + case WID_PROTECTED: + { + sal_Bool bSet = lcl_AnyToBool(rValue); + rTOXBase.SetProtected(bSet); + if (pSectionFmt) { - String aString; - SwStyleNameMapper::FillUIName( lcl_AnyToString(aValue), aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True); - bForm = sal_True; - //Header steht an Pos 0 - aForm.SetTemplate( 0, aString ); + static_cast(rTOXBase).SetProtect(bSet); } - break; - case WID_IS_RELATIVE_TABSTOPS: - bForm = sal_True; - aForm.SetRelTabPos(lcl_AnyToBool(aValue)); - break; - case WID_PARA_SEP : + } + break; + case WID_USE_ALPHABETICAL_SEPARATORS: + lcl_AnyToBitMask(rValue, nTOIOptions, + nsSwTOIOptions::TOI_ALPHA_DELIMITTER); + break; + case WID_USE_KEY_AS_ENTRY: + lcl_AnyToBitMask(rValue, nTOIOptions, + nsSwTOIOptions::TOI_KEY_AS_ENTRY); + break; + case WID_USE_COMBINED_ENTRIES: + lcl_AnyToBitMask(rValue, nTOIOptions, + nsSwTOIOptions::TOI_SAME_ENTRY); + break; + case WID_IS_CASE_SENSITIVE: + lcl_AnyToBitMask(rValue, nTOIOptions, + nsSwTOIOptions::TOI_CASE_SENSITIVE); + break; + case WID_USE_P_P: + lcl_AnyToBitMask(rValue, nTOIOptions, nsSwTOIOptions::TOI_FF); + break; + case WID_USE_DASH: + lcl_AnyToBitMask(rValue, nTOIOptions, nsSwTOIOptions::TOI_DASH); + break; + case WID_USE_UPPER_CASE: + lcl_AnyToBitMask(rValue, nTOIOptions, + nsSwTOIOptions::TOI_INITIAL_CAPS); + break; + case WID_IS_COMMA_SEPARATED: + bForm = sal_True; + aForm.SetCommaSeparated(lcl_AnyToBool(rValue)); + break; + case WID_LABEL_CATEGORY: + { + // convert file-format/API/external programmatic english name + // to internal UI name before usage + String aName( SwStyleNameMapper::GetSpecialExtraUIName( + lcl_AnyToString(rValue) ) ); + rTOXBase.SetSequenceName( aName ); + } + break; + case WID_LABEL_DISPLAY_TYPE: + { + const sal_Int16 nVal = lcl_AnyToInt16(rValue); + sal_uInt16 nSet = CAPTION_COMPLETE; + switch (nVal) { - String aString; - bForm = sal_True; - SwStyleNameMapper::FillUIName( lcl_AnyToString(aValue), aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True); - aForm.SetTemplate( 1, aString ); + case text::ReferenceFieldPart::TEXT: + nSet = CAPTION_COMPLETE; + break; + case text::ReferenceFieldPart::CATEGORY_AND_NUMBER: + nSet = CAPTION_NUMBER; + break; + case text::ReferenceFieldPart::ONLY_CAPTION: + nSet = CAPTION_TEXT; + break; + default: + throw lang::IllegalArgumentException(); } - break; - case WID_CREATE_FROM_PARAGRAPH_STYLES: - nCreate = lcl_AnyToBool(aValue) ? - (nCreate | nsSwTOXElement::TOX_TEMPLATE) : (nCreate & ~nsSwTOXElement::TOX_TEMPLATE); - break; - - case WID_PARA_LEV1 : - case WID_PARA_LEV2 : - case WID_PARA_LEV3 : - case WID_PARA_LEV4 : - case WID_PARA_LEV5 : - case WID_PARA_LEV6 : - case WID_PARA_LEV7 : - case WID_PARA_LEV8 : - case WID_PARA_LEV9 : - case WID_PARA_LEV10 : + rTOXBase.SetCaptionDisplay(static_cast(nSet)); + } + break; + case WID_USE_LEVEL_FROM_SOURCE: + rTOXBase.SetLevelFromChapter(lcl_AnyToBool(rValue)); + break; + case WID_MAIN_ENTRY_CHARACTER_STYLE_NAME: + { + String aString; + SwStyleNameMapper::FillUIName(lcl_AnyToString(rValue), + aString, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, sal_True); + rTOXBase.SetMainEntryCharStyle( aString ); + } + break; + case WID_CREATE_FROM_TABLES: + lcl_AnyToBitMask(rValue, nCreate, nsSwTOXElement::TOX_TABLE); + break; + case WID_CREATE_FROM_TEXT_FRAMES: + lcl_AnyToBitMask(rValue, nCreate, nsSwTOXElement::TOX_FRAME); + break; + case WID_CREATE_FROM_GRAPHIC_OBJECTS: + lcl_AnyToBitMask(rValue, nCreate, nsSwTOXElement::TOX_GRAPHIC); + break; + case WID_CREATE_FROM_EMBEDDED_OBJECTS: + lcl_AnyToBitMask(rValue, nCreate, nsSwTOXElement::TOX_OLE); + break; + case WID_CREATE_FROM_STAR_MATH: + lcl_AnyToBitMask(rValue, nOLEOptions, nsSwTOOElements::TOO_MATH); + break; + case WID_CREATE_FROM_STAR_CHART: + lcl_AnyToBitMask(rValue, nOLEOptions, nsSwTOOElements::TOO_CHART); + break; + case WID_CREATE_FROM_STAR_CALC: + lcl_AnyToBitMask(rValue, nOLEOptions, nsSwTOOElements::TOO_CALC); + break; + case WID_CREATE_FROM_STAR_DRAW: + lcl_AnyToBitMask(rValue, nOLEOptions, + nsSwTOOElements::TOO_DRAW_IMPRESS); + break; + case WID_CREATE_FROM_OTHER_EMBEDDED_OBJECTS: + lcl_AnyToBitMask(rValue, nOLEOptions, nsSwTOOElements::TOO_OTHER); + break; + case WID_PARA_HEAD: + { + String aString; + SwStyleNameMapper::FillUIName( lcl_AnyToString(rValue), + aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True); + bForm = sal_True; + // Header is on Pos 0 + aForm.SetTemplate( 0, aString ); + } + break; + case WID_IS_RELATIVE_TABSTOPS: + bForm = sal_True; + aForm.SetRelTabPos(lcl_AnyToBool(rValue)); + break; + case WID_PARA_SEP: + { + String aString; + bForm = sal_True; + SwStyleNameMapper::FillUIName( lcl_AnyToString(rValue), + aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True); + aForm.SetTemplate( 1, aString ); + } + break; + case WID_CREATE_FROM_PARAGRAPH_STYLES: + lcl_AnyToBitMask(rValue, nCreate, nsSwTOXElement::TOX_TEMPLATE); + break; + + case WID_PARA_LEV1: + case WID_PARA_LEV2: + case WID_PARA_LEV3: + case WID_PARA_LEV4: + case WID_PARA_LEV5: + case WID_PARA_LEV6: + case WID_PARA_LEV7: + case WID_PARA_LEV8: + case WID_PARA_LEV9: + case WID_PARA_LEV10: + { + bForm = sal_True; + // in sdbcx::Index Label 1 begins at Pos 2 otherwise at Pos 1 + const sal_uInt16 nLPos = rTOXBase.GetType() == TOX_INDEX ? 2 : 1; + String aString; + SwStyleNameMapper::FillUIName( lcl_AnyToString(rValue), + aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True); + aForm.SetTemplate(nLPos + pEntry->nWID - WID_PARA_LEV1, aString ); + } + break; + default: + //this is for items only + if (WID_PRIMARY_KEY > pEntry->nWID) { - bForm = sal_True; - // im sdbcx::Index beginnt Lebel 1 bei Pos 2 sonst bei Pos 1 - sal_uInt16 nLPos = pTOXBase->GetType() == TOX_INDEX ? 2 : 1; - String aString; - SwStyleNameMapper::FillUIName( lcl_AnyToString(aValue), aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True); - aForm.SetTemplate(nLPos + pEntry->nWID - WID_PARA_LEV1, aString ); - } - break; - default: - //this is for items only - if(WID_PRIMARY_KEY > pEntry->nWID) + const SwAttrSet& rSet = + m_pImpl->m_pDoc->GetTOXBaseAttrSet(rTOXBase); + SfxItemSet aAttrSet(rSet); + m_pImpl->m_rPropSet.setPropertyValue( + rPropertyName, rValue, aAttrSet); + + const SwSectionFmts& rSects = m_pImpl->m_pDoc->GetSections(); + for (sal_uInt16 i = 0; i < rSects.Count(); i++) { - const SwAttrSet& rSet = m_pDoc->GetTOXBaseAttrSet(*pTOXBase); - pAttrSet = new SfxItemSet(rSet); - m_pPropSet->setPropertyValue(rPropertyName, aValue, *pAttrSet); - - const SwSectionFmts& rSects = m_pDoc->GetSections(); - const SwSectionFmt* pOwnFmt = GetFmt(); - for(sal_uInt16 i = 0; i < rSects.Count(); i++) + const SwSectionFmt* pTmpFmt = rSects[ i ]; + if (pTmpFmt == pSectionFmt) { - const SwSectionFmt* pTmpFmt = rSects[ i ]; - if(pTmpFmt == pOwnFmt) - { - m_pDoc->ChgSection( i, *(SwTOXBaseSection*)pTOXBase, pAttrSet ); - break; - } + m_pImpl->m_pDoc->ChgSection( i, + static_cast(rTOXBase), + & aAttrSet); + break; } } - } - pTOXBase->SetCreate(nCreate); - pTOXBase->SetOLEOptions(nOLEOptions); - if(pTOXBase->GetTOXType()->GetType() == TOX_INDEX) - pTOXBase->SetOptions(nTOIOptions); - if(bForm) - pTOXBase->SetTOXForm(aForm); - delete pAttrSet; + } + } + rTOXBase.SetCreate(nCreate); + rTOXBase.SetOLEOptions(nOLEOptions); + if (rTOXBase.GetTOXType()->GetType() == TOX_INDEX) + { + rTOXBase.SetOptions(nTOIOptions); + } + if (bForm) + { + rTOXBase.SetTOXForm(aForm); } - else - throw uno::RuntimeException(); - } + /*-- 14.12.98 09:35:05--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Any SwXDocumentIndex::getPropertyValue(const OUString& rPropertyName) - throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +uno::Any SAL_CALL +SwXDocumentIndex::getPropertyValue(const OUString& rPropertyName) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + uno::Any aRet; - const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName(rPropertyName); + SfxItemPropertySimpleEntry const*const pEntry = + m_pImpl->m_rPropSet.getPropertyMap()->getByName(rPropertyName); if (!pEntry) - throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); + { + throw beans::UnknownPropertyException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) + + rPropertyName, + static_cast< cppu::OWeakObject * >(this)); + } + + SwSectionFmt *const pSectionFmt( m_pImpl->GetSectionFmt() ); SwTOXBase* pTOXBase = 0; - if(GetFmt()) - pTOXBase = (SwTOXBaseSection*)GetFmt()->GetSection(); - else if(bIsDescriptor) - pTOXBase = &pProps->GetTOXBase(); + if (pSectionFmt) + { + pTOXBase = static_cast(pSectionFmt->GetSection()); + } + else if (m_pImpl->m_bIsDescriptor) + { + pTOXBase = &m_pImpl->m_pProps->GetTOXBase(); + } if(pTOXBase) { - sal_uInt16 nCreate = pTOXBase->GetCreateType(); - sal_uInt16 nTOIOptions = 0; - sal_uInt16 nOLEOptions = pTOXBase->GetOLEOptions(); - if(pTOXBase->GetTOXType()->GetType() == TOX_INDEX) - nTOIOptions = pTOXBase->GetOptions(); + const sal_uInt16 nCreate = pTOXBase->GetCreateType(); + const sal_uInt16 nOLEOptions = pTOXBase->GetOLEOptions(); + const sal_uInt16 nTOIOptions = + (pTOXBase->GetTOXType()->GetType() == TOX_INDEX) + ? pTOXBase->GetOptions() + : 0U; const SwForm& rForm = pTOXBase->GetTOXForm(); - sal_Bool bBOOL = sal_True; - sal_Bool bRet = sal_False; switch(pEntry->nWID) { case WID_IDX_CONTENT_SECTION: case WID_IDX_HEADER_SECTION : - bBOOL = sal_False; if(WID_IDX_CONTENT_SECTION == pEntry->nWID) { - uno::Reference xContentSect = SwXTextSections::GetObject( *GetFmt() ); + const uno::Reference xContentSect = + SwXTextSection::CreateXTextSection( pSectionFmt ); aRet <<= xContentSect; } else { SwSections aSectArr; - GetFmt()->GetChildSections( aSectArr, SORTSECT_NOT, FALSE); + pSectionFmt->GetChildSections(aSectArr, + SORTSECT_NOT, FALSE); for(USHORT i = 0; i < aSectArr.Count(); i++) { SwSection* pSect = aSectArr[i]; if(pSect->GetType() == TOX_HEADER_SECTION) { - uno::Reference xHeaderSect = SwXTextSections::GetObject( *pSect->GetFmt() ); - aRet <<= xHeaderSect; + const uno::Reference xHeader = + SwXTextSection::CreateXTextSection( + pSect->GetFmt() ); + aRet <<= xHeader; break; } } @@ -704,80 +906,96 @@ uno::Any SwXDocumentIndex::getPropertyValue(const OUString& rPropertyName) break; case WID_IDX_TITLE : { - bBOOL = sal_False; OUString uRet(pTOXBase->GetTitle()); aRet <<= uRet; break; } case WID_IDX_NAME: - bBOOL = sal_False; aRet <<= OUString(pTOXBase->GetTOXName()); break; case WID_USER_IDX_NAME: { - bBOOL = sal_False; OUString sTmp; - if(!IsDescriptor()) + if (!m_pImpl->m_bIsDescriptor) + { sTmp = pTOXBase->GetTOXType()->GetTypeName(); + } else - sTmp = pProps->GetTypeName(); + { + sTmp = m_pImpl->m_pProps->GetTypeName(); + } //I18N lcl_ConvertTOUNameToProgrammaticName(sTmp); aRet <<= sTmp; } break; case WID_IDX_LOCALE: - bBOOL = sal_False; aRet <<= SvxCreateLocale(pTOXBase->GetLanguage()); break; case WID_IDX_SORT_ALGORITHM: - bBOOL = sal_False; aRet <<= OUString(pTOXBase->GetSortAlgorithm()); break; case WID_LEVEL : - bBOOL = sal_False; - aRet <<= (sal_Int16)pTOXBase->GetLevel(); + aRet <<= static_cast(pTOXBase->GetLevel()); break; - case WID_CREATE_FROM_MARKS : - bRet = 0 != (nCreate & nsSwTOXElement::TOX_MARK); + case WID_CREATE_FROM_MARKS: + lcl_BitMaskToAny(aRet, nCreate, nsSwTOXElement::TOX_MARK); break; - case WID_CREATE_FROM_OUTLINE : - bRet = 0 != (nCreate & nsSwTOXElement::TOX_OUTLINELEVEL); + case WID_CREATE_FROM_OUTLINE: + lcl_BitMaskToAny(aRet, nCreate, + nsSwTOXElement::TOX_OUTLINELEVEL); break; - case WID_CREATE_FROM_CHAPTER : - bRet = pTOXBase->IsFromChapter(); + case WID_CREATE_FROM_CHAPTER: + { + const sal_Bool bRet = pTOXBase->IsFromChapter(); + aRet <<= bRet; + } break; - case WID_CREATE_FROM_LABELS : - bRet = ! pTOXBase->IsFromObjectNames(); + case WID_CREATE_FROM_LABELS: + { + const sal_Bool bRet = ! pTOXBase->IsFromObjectNames(); + aRet <<= bRet; + } break; - case WID_PROTECTED : - bRet = pTOXBase->IsProtected(); + case WID_PROTECTED: + { + const sal_Bool bRet = pTOXBase->IsProtected(); + aRet <<= bRet; + } break; case WID_USE_ALPHABETICAL_SEPARATORS: - bRet = 0 != (nTOIOptions & nsSwTOIOptions::TOI_ALPHA_DELIMITTER); + lcl_BitMaskToAny(aRet, nTOIOptions, + nsSwTOIOptions::TOI_ALPHA_DELIMITTER); break; - case WID_USE_KEY_AS_ENTRY : - bRet = 0 != (nTOIOptions & nsSwTOIOptions::TOI_KEY_AS_ENTRY); + case WID_USE_KEY_AS_ENTRY: + lcl_BitMaskToAny(aRet, nTOIOptions, + nsSwTOIOptions::TOI_KEY_AS_ENTRY); break; - case WID_USE_COMBINED_ENTRIES : - bRet = 0 != (nTOIOptions & nsSwTOIOptions::TOI_SAME_ENTRY); + case WID_USE_COMBINED_ENTRIES: + lcl_BitMaskToAny(aRet, nTOIOptions, + nsSwTOIOptions::TOI_SAME_ENTRY); break; - case WID_IS_CASE_SENSITIVE : - bRet = 0 != (nTOIOptions & nsSwTOIOptions::TOI_CASE_SENSITIVE); + case WID_IS_CASE_SENSITIVE: + lcl_BitMaskToAny(aRet, nTOIOptions, + nsSwTOIOptions::TOI_CASE_SENSITIVE); break; case WID_USE_P_P: - bRet = 0 != (nTOIOptions & nsSwTOIOptions::TOI_FF); + lcl_BitMaskToAny(aRet, nTOIOptions, nsSwTOIOptions::TOI_FF); break; - case WID_USE_DASH : - bRet = 0 != (nTOIOptions & nsSwTOIOptions::TOI_DASH); + case WID_USE_DASH: + lcl_BitMaskToAny(aRet, nTOIOptions, nsSwTOIOptions::TOI_DASH); break; - case WID_USE_UPPER_CASE : - bRet = 0 != (nTOIOptions & nsSwTOIOptions::TOI_INITIAL_CAPS); + case WID_USE_UPPER_CASE: + lcl_BitMaskToAny(aRet, nTOIOptions, + nsSwTOIOptions::TOI_INITIAL_CAPS); break; - case WID_IS_COMMA_SEPARATED : - bRet = rForm.IsCommaSeparated(); + case WID_IS_COMMA_SEPARATED: + { + const sal_Bool bRet = rForm.IsCommaSeparated(); + aRet <<= bRet; + } break; - case WID_LABEL_CATEGORY : + case WID_LABEL_CATEGORY: { // convert internal UI name to // file-format/API/external programmatic english name @@ -785,50 +1003,58 @@ uno::Any SwXDocumentIndex::getPropertyValue(const OUString& rPropertyName) String aName( SwStyleNameMapper::GetSpecialExtraProgName( pTOXBase->GetSequenceName() ) ); aRet <<= OUString( aName ); - bBOOL = sal_False; } break; - case WID_LABEL_DISPLAY_TYPE : + case WID_LABEL_DISPLAY_TYPE: { - bBOOL = sal_False; sal_Int16 nSet = text::ReferenceFieldPart::TEXT; switch (pTOXBase->GetCaptionDisplay()) { - case CAPTION_COMPLETE: nSet = text::ReferenceFieldPart::TEXT;break; - case CAPTION_NUMBER : nSet = text::ReferenceFieldPart::CATEGORY_AND_NUMBER; break; - case CAPTION_TEXT : nSet = text::ReferenceFieldPart::ONLY_CAPTION; break; + case CAPTION_COMPLETE: + nSet = text::ReferenceFieldPart::TEXT; + break; + case CAPTION_NUMBER: + nSet = text::ReferenceFieldPart::CATEGORY_AND_NUMBER; + break; + case CAPTION_TEXT: + nSet = text::ReferenceFieldPart::ONLY_CAPTION; + break; } aRet <<= nSet; } break; - case WID_USE_LEVEL_FROM_SOURCE : - bRet = pTOXBase->IsLevelFromChapter(); + case WID_USE_LEVEL_FROM_SOURCE: + { + const sal_Bool bRet = pTOXBase->IsLevelFromChapter(); + aRet <<= bRet; + } break; - case WID_LEVEL_FORMAT : + case WID_LEVEL_FORMAT: { - uno::Reference< container::XIndexReplace > xTokenAcc = - ((SwXDocumentIndex*)this)->GetTokenAccess(); - if(!xTokenAcc.is()) - xTokenAcc = new SwXIndexTokenAccess_Impl(* - (SwXDocumentIndex*)this); - aRet.setValue(&xTokenAcc, ::getCppuType((const uno::Reference*)0)); - bBOOL = sal_False; + uno::Reference< container::XIndexReplace > xTokenAccess( + m_pImpl->m_wTokenAccess); + if (!xTokenAccess.is()) + { + xTokenAccess = new SwXIndexTokenAccess_Impl(*this); + m_pImpl->m_wTokenAccess = xTokenAccess; + } + aRet <<= xTokenAccess; } break; - case WID_LEVEL_PARAGRAPH_STYLES : + case WID_LEVEL_PARAGRAPH_STYLES: { - uno::Reference< container::XIndexReplace > xStyleAcc = - ((SwXDocumentIndex*)this)->GetStyleAccess(); - if(!xStyleAcc.is()) - xStyleAcc = new SwXIndexStyleAccess_Impl(* - (SwXDocumentIndex*)this); - aRet.setValue(&xStyleAcc, ::getCppuType((const uno::Reference*)0)); - bBOOL = sal_False; + uno::Reference< container::XIndexReplace > xStyleAccess( + m_pImpl->m_wStyleAccess); + if (!xStyleAccess.is()) + { + xStyleAccess = new SwXIndexStyleAccess_Impl(*this); + m_pImpl->m_wStyleAccess = xStyleAccess; + } + aRet <<= xStyleAccess; } break; - case WID_MAIN_ENTRY_CHARACTER_STYLE_NAME : + case WID_MAIN_ENTRY_CHARACTER_STYLE_NAME: { - bBOOL = sal_False; String aString; SwStyleNameMapper::FillProgName( pTOXBase->GetMainEntryCharStyle(), @@ -838,47 +1064,47 @@ uno::Any SwXDocumentIndex::getPropertyValue(const OUString& rPropertyName) aRet <<= OUString( aString ); } break; - case WID_CREATE_FROM_TABLES : - bRet = 0 != (nCreate & nsSwTOXElement::TOX_TABLE); + case WID_CREATE_FROM_TABLES: + lcl_BitMaskToAny(aRet, nCreate, nsSwTOXElement::TOX_TABLE); break; - case WID_CREATE_FROM_TEXT_FRAMES : - bRet = 0 != (nCreate & nsSwTOXElement::TOX_FRAME); + case WID_CREATE_FROM_TEXT_FRAMES: + lcl_BitMaskToAny(aRet, nCreate, nsSwTOXElement::TOX_FRAME); break; - case WID_CREATE_FROM_GRAPHIC_OBJECTS : - bRet = 0 != (nCreate & nsSwTOXElement::TOX_GRAPHIC); + case WID_CREATE_FROM_GRAPHIC_OBJECTS: + lcl_BitMaskToAny(aRet, nCreate, nsSwTOXElement::TOX_GRAPHIC); break; - case WID_CREATE_FROM_EMBEDDED_OBJECTS : - bRet = 0 != (nCreate & nsSwTOXElement::TOX_OLE); + case WID_CREATE_FROM_EMBEDDED_OBJECTS: + lcl_BitMaskToAny(aRet, nCreate, nsSwTOXElement::TOX_OLE); break; case WID_CREATE_FROM_STAR_MATH: - bRet = 0 != (nOLEOptions & nsSwTOOElements::TOO_MATH); + lcl_BitMaskToAny(aRet, nOLEOptions, nsSwTOOElements::TOO_MATH); break; - case WID_CREATE_FROM_STAR_CHART : - bRet = 0 != (nOLEOptions & nsSwTOOElements::TOO_CHART); + case WID_CREATE_FROM_STAR_CHART: + lcl_BitMaskToAny(aRet, nOLEOptions, nsSwTOOElements::TOO_CHART); break; - case WID_CREATE_FROM_STAR_CALC : - bRet = 0 != (nOLEOptions & nsSwTOOElements::TOO_CALC); + case WID_CREATE_FROM_STAR_CALC: + lcl_BitMaskToAny(aRet, nOLEOptions, nsSwTOOElements::TOO_CALC); break; - case WID_CREATE_FROM_STAR_DRAW : - bRet = 0 != (nOLEOptions & nsSwTOOElements::TOO_DRAW_IMPRESS); + case WID_CREATE_FROM_STAR_DRAW: + lcl_BitMaskToAny(aRet, nOLEOptions, + nsSwTOOElements::TOO_DRAW_IMPRESS); break; case WID_CREATE_FROM_OTHER_EMBEDDED_OBJECTS: - bRet = 0 != (nOLEOptions & nsSwTOOElements::TOO_OTHER); + lcl_BitMaskToAny(aRet, nOLEOptions, nsSwTOOElements::TOO_OTHER); break; case WID_CREATE_FROM_PARAGRAPH_STYLES: - bRet = 0 != (nCreate & nsSwTOXElement::TOX_TEMPLATE); + lcl_BitMaskToAny(aRet, nCreate, nsSwTOXElement::TOX_TEMPLATE); break; - case WID_PARA_HEAD : + case WID_PARA_HEAD: { //Header steht an Pos 0 String aString; SwStyleNameMapper::FillProgName(rForm.GetTemplate( 0 ), aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True ); aRet <<= OUString( aString ); - bBOOL = sal_False; } break; - case WID_PARA_SEP : + case WID_PARA_SEP: { String aString; SwStyleNameMapper::FillProgName( @@ -887,21 +1113,20 @@ uno::Any SwXDocumentIndex::getPropertyValue(const OUString& rPropertyName) nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True); aRet <<= OUString( aString ); - bBOOL = sal_False; } break; - case WID_PARA_LEV1 : - case WID_PARA_LEV2 : - case WID_PARA_LEV3 : - case WID_PARA_LEV4 : - case WID_PARA_LEV5 : - case WID_PARA_LEV6 : - case WID_PARA_LEV7 : - case WID_PARA_LEV8 : - case WID_PARA_LEV9 : - case WID_PARA_LEV10 : + case WID_PARA_LEV1: + case WID_PARA_LEV2: + case WID_PARA_LEV3: + case WID_PARA_LEV4: + case WID_PARA_LEV5: + case WID_PARA_LEV6: + case WID_PARA_LEV7: + case WID_PARA_LEV8: + case WID_PARA_LEV9: + case WID_PARA_LEV10: { - // im sdbcx::Index beginnt Lebel 1 bei Pos 2 sonst bei Pos 1 + // in sdbcx::Index Label 1 begins at Pos 2 otherwise at Pos 1 sal_uInt16 nLPos = pTOXBase->GetType() == TOX_INDEX ? 2 : 1; String aString; SwStyleNameMapper::FillProgName( @@ -910,282 +1135,319 @@ uno::Any SwXDocumentIndex::getPropertyValue(const OUString& rPropertyName) nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True); aRet <<= OUString( aString ); - bBOOL = sal_False; } break; case WID_IS_RELATIVE_TABSTOPS: - bRet = rForm.IsRelTabPos(); + { + const sal_Bool bRet = rForm.IsRelTabPos(); + aRet <<= bRet; + } break; case WID_INDEX_MARKS: { SwTOXMarks aMarks; - const SwTOXType* pType = pTOXBase->GetTOXType(); - SwClientIter aIter(*(SwTOXType*)pType); - SwTOXMark* pMark = (SwTOXMark*)aIter.First(TYPE(SwTOXMark)); + SwTOXType const*const pType = pTOXBase->GetTOXType(); + SwClientIter aIter(*pType); + SwTOXMark * pMark = + static_cast(aIter.First(TYPE(SwTOXMark))); while( pMark ) { if(pMark->GetTxtTOXMark()) + { aMarks.C40_INSERT(SwTOXMark, pMark, aMarks.Count()); - pMark = (SwTOXMark*)aIter.Next(); + } + pMark = static_cast(aIter.Next()); } - uno::Sequence< uno::Reference < text::XDocumentIndexMark > > aXMarks(aMarks.Count()); - uno::Reference* pxMarks = aXMarks.getArray(); + uno::Sequence< uno::Reference > + aXMarks(aMarks.Count()); + uno::Reference* pxMarks = + aXMarks.getArray(); for(USHORT i = 0; i < aMarks.Count(); i++) { pMark = aMarks.GetObject(i); - pxMarks[i] = SwXDocumentIndexMark::GetObject((SwTOXType*)pType, pMark, m_pDoc); + pxMarks[i] = SwXDocumentIndexMark::GetObject( + const_cast(pType), pMark, m_pImpl->m_pDoc); } - aRet.setValue(&aXMarks, ::getCppuType((uno::Sequence< uno::Reference< text::XDocumentIndexMark > >*)0)); - bBOOL = sal_False; + aRet <<= aXMarks; } break; default: //this is for items only - bBOOL = sal_False; if(WID_PRIMARY_KEY > pEntry->nWID) { - const SwAttrSet& rSet = m_pDoc->GetTOXBaseAttrSet(*pTOXBase); - aRet = m_pPropSet->getPropertyValue(rPropertyName, rSet); + const SwAttrSet& rSet = + m_pImpl->m_pDoc->GetTOXBaseAttrSet(*pTOXBase); + aRet = m_pImpl->m_rPropSet.getPropertyValue( + rPropertyName, rSet); } } - if(bBOOL) - aRet.setValue(&bRet, ::getCppuBooleanType()); } return aRet; } -/*-- 14.12.98 09:35:06--------------------------------------------------- - -----------------------------------------------------------------------*/ -void SwXDocumentIndex::addPropertyChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) -{ - DBG_WARNING("not implemented"); -} /*-- 14.12.98 09:35:06--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXDocumentIndex::removePropertyChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +void SAL_CALL +SwXDocumentIndex::addPropertyChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - DBG_WARNING("not implemented"); + OSL_ENSURE(false, + "SwXDocumentIndex::addPropertyChangeListener(): not implemented"); } -/*-- 14.12.98 09:35:06--------------------------------------------------- - -----------------------------------------------------------------------*/ -void SwXDocumentIndex::addVetoableChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +void SAL_CALL +SwXDocumentIndex::removePropertyChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - DBG_WARNING("not implemented"); + OSL_ENSURE(false, + "SwXDocumentIndex::removePropertyChangeListener(): not implemented"); } -/*-- 14.12.98 09:35:07--------------------------------------------------- - -----------------------------------------------------------------------*/ -void SwXDocumentIndex::removeVetoableChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +void SAL_CALL +SwXDocumentIndex::addVetoableChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - DBG_WARNING("not implemented"); + OSL_ENSURE(false, + "SwXDocumentIndex::addVetoableChangeListener(): not implemented"); } -/*-- 14.12.98 09:35:07--------------------------------------------------- - -----------------------------------------------------------------------*/ -void SwXDocumentIndex::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew) +void SAL_CALL +SwXDocumentIndex::removeVetoableChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - BOOL bRemove = FALSE; - switch( pOld ? pOld->Which() : 0 ) - { - case RES_REMOVE_UNO_OBJECT: - case RES_OBJECTDYING: - bRemove = (void*)GetRegisteredIn() == ((SwPtrMsgPoolItem *)pOld)->pObject; - break; - case RES_FMT_CHG: - // wurden wir an das neue umgehaengt und wird das alte geloscht? - bRemove = ((SwFmtChg*)pNew)->pChangedFmt == GetRegisteredIn() && - ((SwFmtChg*)pOld)->pChangedFmt->IsFmtInDTOR(); - break; - } - if( bRemove ) - { - ((SwModify*)GetRegisteredIn())->Remove( this ); - aLstnrCntnr.Disposing(); - } + OSL_ENSURE(false, + "SwXDocumentIndex::removeVetoableChangeListener(): not implemented"); } + /* -----------------18.02.99 13:39------------------- * * --------------------------------------------------*/ -void SwXDocumentIndex::attachToRange(const uno::Reference< text::XTextRange > & xTextRange) - throw( lang::IllegalArgumentException, uno::RuntimeException ) +void SAL_CALL +SwXDocumentIndex::attach(const uno::Reference< text::XTextRange > & xTextRange) +throw (lang::IllegalArgumentException, uno::RuntimeException) { - if(!bIsDescriptor) + vos::OGuard aGuard(Application::GetSolarMutex()); + + if (!m_pImpl->m_bIsDescriptor) + { throw uno::RuntimeException(); - uno::Reference xRangeTunnel( xTextRange, uno::UNO_QUERY); - SwXTextRange* pRange = 0; - OTextCursorHelper* pCursor = 0; - if(xRangeTunnel.is()) + } + const uno::Reference xRangeTunnel( xTextRange, uno::UNO_QUERY); + SwXTextRange *const pRange = + ::sw::UnoTunnelGetImplementation(xRangeTunnel); + OTextCursorHelper *const pCursor = + ::sw::UnoTunnelGetImplementation(xRangeTunnel); + + SwDoc *const pDoc = + (pRange) ? pRange->GetDoc() : ((pCursor) ? pCursor->GetDoc() : 0); + if (!pDoc) { - pRange = reinterpret_cast< SwXTextRange * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXTextRange::getUnoTunnelId()) )); - pCursor = reinterpret_cast< OTextCursorHelper * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( OTextCursorHelper::getUnoTunnelId()) )); + throw lang::IllegalArgumentException(); } - SwDoc* pDoc = pRange ? (SwDoc*)pRange->GetDoc() : pCursor ? (SwDoc*)pCursor->GetDoc() : 0; - if(pDoc ) + SwUnoInternalPaM aPam(*pDoc); + //das muss jetzt sal_True liefern + ::sw::XTextRangeToSwPaM(aPam, xTextRange); + + const SwTOXBase* pOld = pDoc->GetCurTOX( *aPam.Start() ); + if (pOld) { - SwUnoInternalPaM aPam(*pDoc); - //das muss jetzt sal_True liefern - ::sw::XTextRangeToSwPaM(aPam, xTextRange); + throw lang::IllegalArgumentException(); + } - const SwTOXBase* pOld = pDoc->GetCurTOX( *aPam.Start() ); - if(!pOld) - { - UnoActionContext aAction(pDoc); - if(aPam.HasMark()) - pDoc->DeleteAndJoin(aPam); + UnoActionContext aAction(pDoc); + if (aPam.HasMark()) + { + pDoc->DeleteAndJoin(aPam); + } - SwTOXBase& rTOXBase = pProps->GetTOXBase(); - const SwTOXType* pTOXType = rTOXBase.GetTOXType(); - if(TOX_USER == pTOXType->GetType() && !pProps->GetTypeName().equals(pTOXType->GetTypeName())) - { - lcl_ReAssignTOXType(pDoc, rTOXBase, pProps->GetTypeName()); - } - //TODO: apply Section attributes (columns and background) - const SwTOXBaseSection* pTOX = pDoc->InsertTableOf( - *aPam.GetPoint(), rTOXBase, 0, sal_False ); + SwTOXBase & rTOXBase = m_pImpl->m_pProps->GetTOXBase(); + SwTOXType const*const pTOXType = rTOXBase.GetTOXType(); + if ((TOX_USER == pTOXType->GetType()) && + !m_pImpl->m_pProps->GetTypeName().equals(pTOXType->GetTypeName())) + { + lcl_ReAssignTOXType(pDoc, rTOXBase, m_pImpl->m_pProps->GetTypeName()); + } + //TODO: apply Section attributes (columns and background) + SwTOXBaseSection const*const pTOX = + pDoc->InsertTableOf( *aPam.GetPoint(), rTOXBase, 0, sal_False ); - pDoc->SetTOXBaseName( *pTOX, pProps->GetTOXBase().GetTOXName() ); + pDoc->SetTOXBaseName(*pTOX, m_pImpl->m_pProps->GetTOXBase().GetTOXName()); - // Seitennummern eintragen - pBase = (const SwTOXBaseSection*)pTOX; - pBase->GetFmt()->Add(this); - ((SwTOXBaseSection*)pTOX)->UpdatePageNum(); - } - else - throw lang::IllegalArgumentException(); + // update page numbers + pTOX->GetFmt()->Add(m_pImpl.get()); + pTOX->GetFmt()->SetXObject(static_cast< ::cppu::OWeakObject*>(this)); + const_cast(pTOX)->UpdatePageNum(); - DELETEZ(pProps); - m_pDoc = pDoc; - bIsDescriptor = sal_False; - } + m_pImpl->m_pProps.reset(); + m_pImpl->m_pDoc = pDoc; + m_pImpl->m_bIsDescriptor = sal_False; } -/*-- 15.01.99 14:23:51--------------------------------------------------- - -----------------------------------------------------------------------*/ -void SwXDocumentIndex::attach(const uno::Reference< text::XTextRange > & xTextRange) - throw( lang::IllegalArgumentException, uno::RuntimeException ) -{ - vos::OGuard aGuard(Application::GetSolarMutex()); - attachToRange( xTextRange ); -} /*-- 15.01.99 14:23:56--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextRange > SwXDocumentIndex::getAnchor(void) throw( uno::RuntimeException ) +uno::Reference< text::XTextRange > SAL_CALL +SwXDocumentIndex::getAnchor() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< text::XTextRange > xRet; - if(GetRegisteredIn()) + + SwSectionFmt *const pSectionFmt( m_pImpl->GetSectionFmt() ); + if (!pSectionFmt) { - SwSectionFmt* pSectFmt = GetFmt(); - const SwNodeIndex* pIdx; - if( 0 != ( pIdx = pSectFmt->GetCntnt().GetCntntIdx() ) && - pIdx->GetNode().GetNodes().IsDocNodes() ) - { - SwPaM aPaM(*pIdx); - aPaM.Move( fnMoveForward, fnGoCntnt ); - aPaM.SetMark(); - aPaM.GetPoint()->nNode = *pIdx->GetNode().EndOfSectionNode(); - aPaM.Move( fnMoveBackward, fnGoCntnt ); - xRet = SwXTextRange::CreateXTextRange(*pSectFmt->GetDoc(), - *aPaM.GetMark(), aPaM.GetPoint()); - } - } - else throw uno::RuntimeException(); + } + + uno::Reference< text::XTextRange > xRet; + SwNodeIndex const*const pIdx( pSectionFmt->GetCntnt().GetCntntIdx() ); + if (pIdx && pIdx->GetNode().GetNodes().IsDocNodes()) + { + SwPaM aPaM(*pIdx); + aPaM.Move( fnMoveForward, fnGoCntnt ); + aPaM.SetMark(); + aPaM.GetPoint()->nNode = *pIdx->GetNode().EndOfSectionNode(); + aPaM.Move( fnMoveBackward, fnGoCntnt ); + xRet = SwXTextRange::CreateXTextRange(*pSectionFmt->GetDoc(), + *aPaM.GetMark(), aPaM.GetPoint()); + } return xRet; } + /*-- 15.01.99 15:46:48--------------------------------------------------- -----------------------------------------------------------------------*/ void lcl_RemoveChildSections(SwSectionFmt& rParentFmt) { SwSections aTmpArr; - SwDoc* pDoc = rParentFmt.GetDoc(); - sal_uInt16 nCnt = rParentFmt.GetChildSections(aTmpArr,SORTSECT_POS); + SwDoc *const pDoc = rParentFmt.GetDoc(); + const sal_uInt16 nCnt = rParentFmt.GetChildSections(aTmpArr, SORTSECT_POS); if( nCnt ) { for( sal_uInt16 n = 0; n < nCnt; ++n ) + { if( aTmpArr[n]->GetFmt()->IsInNodesArr() ) { SwSectionFmt* pFmt = aTmpArr[n]->GetFmt(); lcl_RemoveChildSections(*pFmt); pDoc->DelSectionFmt( pFmt ); } + } } } -void SwXDocumentIndex::dispose(void) throw( uno::RuntimeException ) + +void SAL_CALL SwXDocumentIndex::dispose() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(GetRegisteredIn()) + + SwSectionFmt *const pSectionFmt( m_pImpl->GetSectionFmt() ); + if (pSectionFmt) { - SwSectionFmt* pSectFmt = GetFmt(); - pSectFmt->GetDoc()->DeleteTOX( *(SwTOXBaseSection*)pSectFmt->GetSection(), sal_True); + pSectionFmt->GetDoc()->DeleteTOX( + *static_cast(pSectionFmt->GetSection()), + sal_True); } - else - throw uno::RuntimeException(); } + /*-- 15.01.99 15:46:49--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXDocumentIndex::addEventListener(const uno::Reference< lang::XEventListener > & aListener) throw( uno::RuntimeException ) +void SAL_CALL +SwXDocumentIndex::addEventListener( + const uno::Reference< lang::XEventListener > & xListener) +throw (uno::RuntimeException) { - if(!GetRegisteredIn()) + vos::OGuard g(Application::GetSolarMutex()); + + if (!m_pImpl->GetRegisteredIn()) + { throw uno::RuntimeException(); - aLstnrCntnr.AddListener(aListener); + } + m_pImpl->m_ListenerContainer.AddListener(xListener); } /*-- 15.01.99 15:46:54--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXDocumentIndex::removeEventListener(const uno::Reference< lang::XEventListener > & aListener) throw( uno::RuntimeException ) +void SAL_CALL +SwXDocumentIndex::removeEventListener( + const uno::Reference< lang::XEventListener > & xListener) +throw (uno::RuntimeException) { - if(!GetRegisteredIn() || !aLstnrCntnr.RemoveListener(aListener)) + vos::OGuard g(Application::GetSolarMutex()); + + if (!m_pImpl->GetRegisteredIn() || + !m_pImpl->m_ListenerContainer.RemoveListener(xListener)) + { throw uno::RuntimeException(); + } } + /* -----------------30.07.99 11:28------------------- --------------------------------------------------*/ -OUString SwXDocumentIndex::getName(void) throw( uno::RuntimeException ) +OUString SAL_CALL SwXDocumentIndex::getName() throw (uno::RuntimeException) { - SwSectionFmt* pSectionFmt = GetFmt(); + vos::OGuard g(Application::GetSolarMutex()); + OUString uRet; - if(bIsDescriptor) + SwSectionFmt *const pSectionFmt( m_pImpl->GetSectionFmt() ); + if (m_pImpl->m_bIsDescriptor) { - uRet = OUString(pProps->GetTOXBase().GetTOXName()); + uRet = OUString(m_pImpl->m_pProps->GetTOXBase().GetTOXName()); } else if(pSectionFmt) { uRet = OUString(pSectionFmt->GetSection()->GetName()); } else + { throw uno::RuntimeException(); + } return uRet; } /* -----------------30.07.99 11:28------------------- --------------------------------------------------*/ -void SwXDocumentIndex::setName(const OUString& rName) throw( uno::RuntimeException ) +void SAL_CALL +SwXDocumentIndex::setName(const OUString& rName) throw (uno::RuntimeException) { - SwSectionFmt* pSectionFmt = GetFmt(); - String sNewName(rName); - sal_Bool bExcept = sal_False; - if(!sNewName.Len()) - bExcept = sal_True; - if(bIsDescriptor) + vos::OGuard g(Application::GetSolarMutex()); + + if (!rName.getLength()) { - pProps->GetTOXBase().SetTOXName(sNewName); + throw uno::RuntimeException(); } - else if(!pSectionFmt || - !pSectionFmt->GetDoc()->SetTOXBaseName( - *(SwTOXBaseSection*)pSectionFmt->GetSection(), sNewName)) - bExcept = sal_True; - if(bExcept) + SwSectionFmt *const pSectionFmt( m_pImpl->GetSectionFmt() ); + if (m_pImpl->m_bIsDescriptor) + { + m_pImpl->m_pProps->GetTOXBase().SetTOXName(rName); + } + else if (pSectionFmt) + { + const bool bSuccess = pSectionFmt->GetDoc()->SetTOXBaseName( + *static_cast(pSectionFmt->GetSection()), rName); + if (!bSuccess) + { + throw uno::RuntimeException(); + } + } + else + { throw uno::RuntimeException(); + } } /****************************************************************** @@ -2018,7 +2280,6 @@ uno::Any SwXDocumentIndexes::getByIndex(sal_Int32 nIndex) if(!IsValid()) throw uno::RuntimeException(); - uno::Any aRet; sal_Int32 nIdx = 0; const SwSectionFmts& rFmts = GetDoc()->GetSections(); @@ -2029,9 +2290,11 @@ uno::Any SwXDocumentIndexes::getByIndex(sal_Int32 nIndex) pSect->GetFmt()->GetSectionNode() && nIdx++ == nIndex ) { - uno::Reference< text::XDocumentIndex > xTmp = new SwXDocumentIndex( - (SwTOXBaseSection*)pSect, GetDoc() ); - aRet.setValue(&xTmp, ::getCppuType((uno::Reference*)0)); + const uno::Reference< text::XDocumentIndex > xTmp = + SwXDocumentIndex::CreateXDocumentIndex( + *GetDoc(), static_cast(*pSect)); + uno::Any aRet; + aRet <<= xTmp; return aRet; } } @@ -2049,7 +2312,6 @@ uno::Any SwXDocumentIndexes::getByName(const OUString& rName) if(!IsValid()) throw uno::RuntimeException(); - uno::Any aRet; String sToFind(rName); const SwSectionFmts& rFmts = GetDoc()->GetSections(); @@ -2060,9 +2322,11 @@ uno::Any SwXDocumentIndexes::getByName(const OUString& rName) pSect->GetFmt()->GetSectionNode() && ((SwTOXBaseSection*)pSect)->GetTOXName() == sToFind) { - uno::Reference< text::XDocumentIndex > xTmp = new SwXDocumentIndex( - (SwTOXBaseSection*)pSect, GetDoc() ); - aRet.setValue(&xTmp, ::getCppuType((uno::Reference*)0)); + const uno::Reference< text::XDocumentIndex > xTmp = + SwXDocumentIndex::CreateXDocumentIndex( + *GetDoc(), static_cast(*pSect)); + uno::Any aRet; + aRet <<= xTmp; return aRet; } } @@ -2145,17 +2409,6 @@ sal_Bool SwXDocumentIndexes::hasElements(void) throw( uno::RuntimeException ) return 0 != getCount(); } -SwXDocumentIndex* SwXDocumentIndexes::GetObject(const SwTOXBaseSection* pTOX) -{ - SwSectionFmt* pFmt = pTOX->GetFmt(); - SwClientIter aIter(*pFmt); - SwXDocumentIndex* pxIdx = (SwXDocumentIndex*)aIter.First(TYPE(SwXDocumentIndex)); - if(pxIdx) - return pxIdx; - else - return new SwXDocumentIndex(pTOX, pFmt->GetDoc()); -} - /* -----------------------------06.04.00 15:08-------------------------------- ---------------------------------------------------------------------------*/ @@ -2187,16 +2440,12 @@ SwXIndexStyleAccess_Impl::SwXIndexStyleAccess_Impl(SwXDocumentIndex& rParentIdx) rParent(rParentIdx), xParent(&rParentIdx) { - vos::OGuard aGuard(Application::GetSolarMutex()); - rParent.SetStyleAccess(this); } /*-- 13.09.99 16:52:29--------------------------------------------------- -----------------------------------------------------------------------*/ SwXIndexStyleAccess_Impl::~SwXIndexStyleAccess_Impl() { - vos::OGuard aGuard(Application::GetSolarMutex()); - rParent.SetStyleAccess(0); } /*-- 13.09.99 16:52:29--------------------------------------------------- @@ -2206,14 +2455,13 @@ void SwXIndexStyleAccess_Impl::replaceByIndex(sal_Int32 nIndex, const uno::Any& lang::WrappedTargetException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - const sal_Bool bDescriptor = rParent.IsDescriptor(); - SwSectionFmt* pSectFmt = rParent.GetFmt(); - if(!pSectFmt && !bDescriptor) - throw uno::RuntimeException(); + if(nIndex < 0 || nIndex > MAXLEVEL) + { throw lang::IndexOutOfBoundsException(); - SwTOXBase* pTOXBase = bDescriptor ? &rParent.GetProperties_Impl()->GetTOXBase() : - (SwTOXBaseSection*)pSectFmt->GetSection(); + } + + SwTOXBase * pTOXBase( &rParent.m_pImpl->GetTOXSectionOrThrow() ); uno::Sequence aSeq; if(!(rElement >>= aSeq)) @@ -2247,14 +2495,13 @@ uno::Any SwXIndexStyleAccess_Impl::getByIndex(sal_Int32 nIndex) uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - const sal_Bool bDescriptor = rParent.IsDescriptor(); - SwSectionFmt* pSectFmt = rParent.GetFmt(); - if(!pSectFmt && !bDescriptor) - throw uno::RuntimeException(); + if(nIndex < 0 || nIndex > MAXLEVEL) + { throw lang::IndexOutOfBoundsException(); - SwTOXBase* pTOXBase = bDescriptor ? &rParent.GetProperties_Impl()->GetTOXBase() : - (SwTOXBaseSection*)pSectFmt->GetSection(); + } + + SwTOXBase * pTOXBase( &rParent.m_pImpl->GetTOXSectionOrThrow() ); const String& rStyles = pTOXBase->GetStyleNames((sal_uInt16) nIndex); sal_uInt16 nStyles = rStyles.GetTokenCount(TOX_STYLE_DELIMITER); @@ -2322,18 +2569,14 @@ uno::Sequence< OUString > SwXIndexTokenAccess_Impl::getSupportedServiceNames(voi SwXIndexTokenAccess_Impl::SwXIndexTokenAccess_Impl(SwXDocumentIndex& rParentIdx) : rParent(rParentIdx), xParent(&rParentIdx), - nCount(SwForm::GetFormMaxLevel(rParent.GetTOXType())) + nCount(0) { - vos::OGuard aGuard(Application::GetSolarMutex()); - rParent.SetTokenAccess(this); } /*-- 13.09.99 16:52:29--------------------------------------------------- -----------------------------------------------------------------------*/ SwXIndexTokenAccess_Impl::~SwXIndexTokenAccess_Impl() { - vos::OGuard aGuard(Application::GetSolarMutex()); - rParent.SetTokenAccess(0); } /*-- 13.09.99 16:52:29--------------------------------------------------- @@ -2343,13 +2586,9 @@ void SwXIndexTokenAccess_Impl::replaceByIndex(sal_Int32 nIndex, const uno::Any& lang::WrappedTargetException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - const sal_Bool bDescriptor = rParent.IsDescriptor(); - SwSectionFmt* pSectFmt = rParent.GetFmt(); - if(!pSectFmt && !bDescriptor) - throw uno::RuntimeException(); - SwTOXBase* pTOXBase = bDescriptor ? &rParent.GetProperties_Impl()->GetTOXBase() : - (SwTOXBaseSection*)pSectFmt->GetSection(); + SwTOXBase * pTOXBase( &rParent.m_pImpl->GetTOXSectionOrThrow() ); + if(nIndex < 0 || (nIndex > pTOXBase->GetTOXForm().GetFormMax())) throw lang::IndexOutOfBoundsException(); @@ -2358,6 +2597,7 @@ void SwXIndexTokenAccess_Impl::replaceByIndex(sal_Int32 nIndex, const uno::Any& if(!(rElement >>= aSeq)) throw lang::IllegalArgumentException(); + String sPattern; sal_Int32 nTokens = aSeq.getLength(); const beans::PropertyValues* pTokens = aSeq.getConstArray(); @@ -2519,14 +2759,8 @@ void SwXIndexTokenAccess_Impl::replaceByIndex(sal_Int32 nIndex, const uno::Any& sal_Int32 SwXIndexTokenAccess_Impl::getCount(void) throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - const sal_Bool bDescriptor = rParent.IsDescriptor(); - SwSectionFmt* pSectFmt = rParent.GetFmt(); - if(!pSectFmt && !bDescriptor) - throw uno::RuntimeException(); - sal_Int32 nRet = bDescriptor ? - nCount : - ((SwTOXBaseSection*)pSectFmt->GetSection())-> - GetTOXForm().GetFormMax(); + + const sal_Int32 nRet = rParent.m_pImpl->GetFormMax(); return nRet; } /*-- 13.09.99 16:52:30--------------------------------------------------- @@ -2537,12 +2771,9 @@ uno::Any SwXIndexTokenAccess_Impl::getByIndex(sal_Int32 nIndex) uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - const sal_Bool bDescriptor = rParent.IsDescriptor(); - SwSectionFmt* pSectFmt = rParent.GetFmt(); - if(!pSectFmt && !bDescriptor) - throw uno::RuntimeException(); - SwTOXBase* pTOXBase = bDescriptor ? &rParent.GetProperties_Impl()->GetTOXBase() : - (SwTOXBaseSection*)pSectFmt->GetSection(); + + SwTOXBase * pTOXBase( &rParent.m_pImpl->GetTOXSectionOrThrow() ); + if(nIndex < 0 || (nIndex > pTOXBase->GetTOXForm().GetFormMax())) throw lang::IndexOutOfBoundsException(); diff --git a/sw/source/core/unocore/unosect.cxx b/sw/source/core/unocore/unosect.cxx index 907a2a617c9b..6eeb9757e47a 100644 --- a/sw/source/core/unocore/unosect.cxx +++ b/sw/source/core/unocore/unosect.cxx @@ -1169,7 +1169,8 @@ throw (beans::UnknownPropertyException, lang::WrappedTargetException, SwTOXBaseSection *const pTOXBaseSect = PTR_CAST(SwTOXBaseSection, pEnclosingSection); const uno::Reference xIndex = - SwXDocumentIndexes::GetObject(pTOXBaseSect); + SwXDocumentIndex::CreateXDocumentIndex( + *pTOXBaseSect->GetFmt()->GetDoc(), *pTOXBaseSect); pRet[nProperty] <<= xIndex; } // else: no enclosing index found -> empty return value -- cgit From 342e7b53a498adba704d9c177db58cdf3cf0733f Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 8 Jan 2010 17:13:58 +0100 Subject: swunolocking1: #i105557#: move SwXDocumentIndex helper classes out of header. use new XUnoTunnel and XServiceInfo helpers. clean up the implementation a little. --- sw/inc/unoidx.hxx | 80 +----- sw/source/core/unocore/unoidx.cxx | 549 ++++++++++++++++++++++++++------------ 2 files changed, 381 insertions(+), 248 deletions(-) (limited to 'sw') diff --git a/sw/inc/unoidx.hxx b/sw/inc/unoidx.hxx index f82e2c9984d2..f3462a17bebb 100644 --- a/sw/inc/unoidx.hxx +++ b/sw/inc/unoidx.hxx @@ -32,9 +32,7 @@ #include #include -#include #include -#include #include #include @@ -53,8 +51,6 @@ class SwTOXType; /* -----------------07.12.98 10:08------------------- * * --------------------------------------------------*/ -class SwXIndexStyleAccess_Impl; -class SwXIndexTokenAccess_Impl; typedef ::cppu::WeakImplHelper5 < ::com::sun::star::lang::XUnoTunnel @@ -70,8 +66,8 @@ class SwXDocumentIndex private: - friend class SwXIndexStyleAccess_Impl; - friend class SwXIndexTokenAccess_Impl; + class StyleAccess_Impl; + class TokenAccess_Impl; class Impl; ::sw::UnoImplPtr m_pImpl; @@ -316,79 +312,7 @@ public: virtual BOOL SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException ); virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException ); -}; -/* -----------------13.09.99 16:39------------------- - - --------------------------------------------------*/ -class SwXIndexStyleAccess_Impl : public cppu::WeakImplHelper2 -< - ::com::sun::star::container::XIndexReplace, - ::com::sun::star::lang::XServiceInfo -> -{ - SwXDocumentIndex& rParent; - ::com::sun::star::uno::Reference< ::com::sun::star::text::XDocumentIndex > xParent; -protected: - virtual ~SwXIndexStyleAccess_Impl(); -public: - SwXIndexStyleAccess_Impl(SwXDocumentIndex& rParentIdx); - - - //XIndexReplace - virtual void SAL_CALL replaceByIndex( sal_Int32 Index, const ::com::sun::star::uno::Any& Element ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - - //XIndexAccess - virtual sal_Int32 SAL_CALL getCount(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException ); - - //XElementAccess - virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw(::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL hasElements( ) throw(::com::sun::star::uno::RuntimeException); - - //XServiceInfo - virtual rtl::OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual BOOL SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException ); - -}; - -/* -----------------13.09.99 16:39------------------- - - --------------------------------------------------*/ -class SwXIndexTokenAccess_Impl : public cppu::WeakImplHelper2 -< - ::com::sun::star::container::XIndexReplace, - ::com::sun::star::lang::XServiceInfo -> -{ - SwXDocumentIndex& rParent; - ::com::sun::star::uno::Reference< ::com::sun::star::text::XDocumentIndex > xParent; - sal_Int32 nCount; -protected: - virtual ~SwXIndexTokenAccess_Impl(); -public: - SwXIndexTokenAccess_Impl(SwXDocumentIndex& rParentIdx); - - - - //XIndexReplace - virtual void SAL_CALL replaceByIndex( sal_Int32 Index, const ::com::sun::star::uno::Any& Element ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - - //XIndexAccess - virtual sal_Int32 SAL_CALL getCount(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException ); - - //XElementAccess - virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw(::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL hasElements( ) throw(::com::sun::star::uno::RuntimeException); - - //XServiceInfo - virtual rtl::OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual BOOL SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException ); - }; #endif - diff --git a/sw/source/core/unocore/unoidx.cxx b/sw/source/core/unocore/unoidx.cxx index d860cedd3fb7..4c55e3e1963f 100644 --- a/sw/source/core/unocore/unoidx.cxx +++ b/sw/source/core/unocore/unoidx.cxx @@ -31,12 +31,13 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" +#include +#include +#include #include #include #include -#include #include -#include #include #include @@ -75,7 +76,7 @@ using namespace ::com::sun::star; using ::rtl::OUString; //----------------------------------------------------------------------------- -static String +static OUString lcl_AnyToString(uno::Any const& rVal) throw (lang::IllegalArgumentException) { OUString sRet; @@ -190,6 +191,104 @@ lcl_ConvertTOUNameToUserName(OUString& rTmp) } } +/* -----------------13.09.99 16:39------------------- + + --------------------------------------------------*/ +typedef ::cppu::WeakImplHelper2 +< lang::XServiceInfo +, container::XIndexReplace +> SwXDocumentIndexStyleAccess_Base; + +class SwXDocumentIndex::StyleAccess_Impl + : public SwXDocumentIndexStyleAccess_Base +{ + +private: + /// can be destroyed threadsafely, so no UnoImplPtr here + ::rtl::Reference m_xParent; + + virtual ~StyleAccess_Impl(); + +public: + StyleAccess_Impl(SwXDocumentIndex& rParentIdx); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() + throw (uno::RuntimeException); + virtual sal_Bool SAL_CALL + supportsService(const ::rtl::OUString& rServiceName) + throw (uno::RuntimeException); + virtual uno::Sequence< ::rtl::OUString > SAL_CALL + getSupportedServiceNames() throw (uno::RuntimeException); + + // XElementAccess + virtual uno::Type SAL_CALL getElementType() throw (uno::RuntimeException); + virtual sal_Bool SAL_CALL hasElements() throw (uno::RuntimeException); + + // XIndexAccess + virtual sal_Int32 SAL_CALL getCount() throw (uno::RuntimeException); + virtual uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) + throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, + uno::RuntimeException); + + // XIndexReplace + virtual void SAL_CALL + replaceByIndex(sal_Int32 Index, const uno::Any& rElement) + throw (lang::IllegalArgumentException, lang::IndexOutOfBoundsException, + lang::WrappedTargetException, uno::RuntimeException); + +}; + +/* -----------------13.09.99 16:39------------------- + + --------------------------------------------------*/ +typedef ::cppu::WeakImplHelper2 +< lang::XServiceInfo +, container::XIndexReplace +> SwXDocumentIndexTokenAccess_Base; + +class SwXDocumentIndex::TokenAccess_Impl + : public SwXDocumentIndexTokenAccess_Base +{ + +private: + /// can be destroyed threadsafely, so no UnoImplPtr here + ::rtl::Reference m_xParent; + + virtual ~TokenAccess_Impl(); + +public: + + TokenAccess_Impl(SwXDocumentIndex& rParentIdx); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() + throw (uno::RuntimeException); + virtual sal_Bool SAL_CALL + supportsService(const ::rtl::OUString& rServiceName) + throw (uno::RuntimeException); + virtual uno::Sequence< ::rtl::OUString > SAL_CALL + getSupportedServiceNames() throw (uno::RuntimeException); + + // XElementAccess + virtual uno::Type SAL_CALL getElementType() throw (uno::RuntimeException); + virtual sal_Bool SAL_CALL hasElements() throw (uno::RuntimeException); + + // XIndexAccess + virtual sal_Int32 SAL_CALL getCount() throw (uno::RuntimeException); + virtual uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) + throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, + uno::RuntimeException); + + // XIndexReplace + virtual void SAL_CALL + replaceByIndex(sal_Int32 Index, const uno::Any& rElement) + throw (lang::IllegalArgumentException, lang::IndexOutOfBoundsException, + lang::WrappedTargetException, uno::RuntimeException); + +}; + + /****************************************************************** * SwXDocumentIndex ******************************************************************/ @@ -1035,7 +1134,7 @@ throw (beans::UnknownPropertyException, lang::WrappedTargetException, m_pImpl->m_wTokenAccess); if (!xTokenAccess.is()) { - xTokenAccess = new SwXIndexTokenAccess_Impl(*this); + xTokenAccess = new TokenAccess_Impl(*this); m_pImpl->m_wTokenAccess = xTokenAccess; } aRet <<= xTokenAccess; @@ -1047,7 +1146,7 @@ throw (beans::UnknownPropertyException, lang::WrappedTargetException, m_pImpl->m_wStyleAccess); if (!xStyleAccess.is()) { - xStyleAccess = new SwXIndexStyleAccess_Impl(*this); + xStyleAccess = new StyleAccess_Impl(*this); m_pImpl->m_wStyleAccess = xStyleAccess; } aRet <<= xStyleAccess; @@ -2409,49 +2508,66 @@ sal_Bool SwXDocumentIndexes::hasElements(void) throw( uno::RuntimeException ) return 0 != getCount(); } -/* -----------------------------06.04.00 15:08-------------------------------- +/****************************************************************** + * SwXDocumentIndex::StyleAccess_Impl + ******************************************************************/ - ---------------------------------------------------------------------------*/ -OUString SwXIndexStyleAccess_Impl::getImplementationName(void) throw( uno::RuntimeException ) +/*-- 13.09.99 16:52:28--------------------------------------------------- + + -----------------------------------------------------------------------*/ +SwXDocumentIndex::StyleAccess_Impl::StyleAccess_Impl( + SwXDocumentIndex& rParentIdx) + : m_xParent(&rParentIdx) { - return C2U("SwXIndexStyleAccess_Impl"); } -/* -----------------------------06.04.00 15:08-------------------------------- +/*-- 13.09.99 16:52:29--------------------------------------------------- - ---------------------------------------------------------------------------*/ -BOOL SwXIndexStyleAccess_Impl::supportsService(const OUString& rServiceName) throw( uno::RuntimeException ) + -----------------------------------------------------------------------*/ +SwXDocumentIndex::StyleAccess_Impl::~StyleAccess_Impl() { - return C2U("com.sun.star.text.DocumentIndexParagraphStyles") == rServiceName; } + /* -----------------------------06.04.00 15:08-------------------------------- ---------------------------------------------------------------------------*/ -uno::Sequence< OUString > SwXIndexStyleAccess_Impl::getSupportedServiceNames(void) throw( uno::RuntimeException ) +OUString SAL_CALL +SwXDocumentIndex::StyleAccess_Impl::getImplementationName() +throw (uno::RuntimeException) { - uno::Sequence< OUString > aRet(1); - OUString* pArray = aRet.getArray(); - pArray[0] = C2U("com.sun.star.text.DocumentIndexParagraphStyles"); - return aRet; + return C2U("SwXDocumentIndex::StyleAccess_Impl"); } -/*-- 13.09.99 16:52:28--------------------------------------------------- - -----------------------------------------------------------------------*/ -SwXIndexStyleAccess_Impl::SwXIndexStyleAccess_Impl(SwXDocumentIndex& rParentIdx) : - rParent(rParentIdx), - xParent(&rParentIdx) +static char const*const g_ServicesIndexStyleAccess[] = { + "com.sun.star.text.DocumentIndexParagraphStyles", +}; +static const size_t g_nServicesIndexStyleAccess( + sizeof(g_ServicesIndexStyleAccess)/sizeof(g_ServicesIndexStyleAccess[0])); + +sal_Bool SAL_CALL +SwXDocumentIndex::StyleAccess_Impl::supportsService( + const OUString& rServiceName) +throw (uno::RuntimeException) +{ + return ::sw::SupportsServiceImpl( + g_nServicesIndexStyleAccess, g_ServicesIndexStyleAccess, rServiceName); } -/*-- 13.09.99 16:52:29--------------------------------------------------- - -----------------------------------------------------------------------*/ -SwXIndexStyleAccess_Impl::~SwXIndexStyleAccess_Impl() +uno::Sequence< OUString > SAL_CALL +SwXDocumentIndex::StyleAccess_Impl::getSupportedServiceNames() +throw (uno::RuntimeException) { + return ::sw::GetSupportedServiceNamesImpl( + g_nServicesIndexStyleAccess, g_ServicesIndexStyleAccess); } + /*-- 13.09.99 16:52:29--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXIndexStyleAccess_Impl::replaceByIndex(sal_Int32 nIndex, const uno::Any& rElement) - throw( lang::IllegalArgumentException, lang::IndexOutOfBoundsException, +void SAL_CALL +SwXDocumentIndex::StyleAccess_Impl::replaceByIndex( + sal_Int32 nIndex, const uno::Any& rElement) +throw (lang::IllegalArgumentException, lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); @@ -2461,38 +2577,45 @@ void SwXIndexStyleAccess_Impl::replaceByIndex(sal_Int32 nIndex, const uno::Any& throw lang::IndexOutOfBoundsException(); } - SwTOXBase * pTOXBase( &rParent.m_pImpl->GetTOXSectionOrThrow() ); + SwTOXBase & rTOXBase( m_xParent->m_pImpl->GetTOXSectionOrThrow() ); uno::Sequence aSeq; if(!(rElement >>= aSeq)) + { throw lang::IllegalArgumentException(); + } - sal_Int32 nStyles = aSeq.getLength(); + const sal_Int32 nStyles = aSeq.getLength(); const OUString* pStyles = aSeq.getConstArray(); String sSetStyles; String aString; for(sal_Int32 i = 0; i < nStyles; i++) { if(i) + { sSetStyles += TOX_STYLE_DELIMITER; - SwStyleNameMapper::FillUIName(pStyles[i], aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True); + } + SwStyleNameMapper::FillUIName(pStyles[i], aString, + nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True); sSetStyles += aString; } - pTOXBase->SetStyleNames(sSetStyles, (sal_uInt16) nIndex); + rTOXBase.SetStyleNames(sSetStyles, static_cast(nIndex)); } /*-- 13.09.99 16:52:29--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Int32 SwXIndexStyleAccess_Impl::getCount(void) throw( uno::RuntimeException ) +sal_Int32 SAL_CALL +SwXDocumentIndex::StyleAccess_Impl::getCount() throw (uno::RuntimeException) { return MAXLEVEL; } /*-- 13.09.99 16:52:30--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Any SwXIndexStyleAccess_Impl::getByIndex(sal_Int32 nIndex) - throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, - uno::RuntimeException) +uno::Any SAL_CALL +SwXDocumentIndex::StyleAccess_Impl::getByIndex(sal_Int32 nIndex) +throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, + uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); @@ -2501,10 +2624,11 @@ uno::Any SwXIndexStyleAccess_Impl::getByIndex(sal_Int32 nIndex) throw lang::IndexOutOfBoundsException(); } - SwTOXBase * pTOXBase( &rParent.m_pImpl->GetTOXSectionOrThrow() ); + SwTOXBase & rTOXBase( m_xParent->m_pImpl->GetTOXSectionOrThrow() ); - const String& rStyles = pTOXBase->GetStyleNames((sal_uInt16) nIndex); - sal_uInt16 nStyles = rStyles.GetTokenCount(TOX_STYLE_DELIMITER); + const String& rStyles = + rTOXBase.GetStyleNames(static_cast(nIndex)); + const sal_uInt16 nStyles = rStyles.GetTokenCount(TOX_STYLE_DELIMITER); uno::Sequence aStyles(nStyles); OUString* pStyles = aStyles.getArray(); String aString; @@ -2523,116 +2647,143 @@ uno::Any SwXIndexStyleAccess_Impl::getByIndex(sal_Int32 nIndex) /*-- 13.09.99 16:52:30--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Type SwXIndexStyleAccess_Impl::getElementType(void) - throw( uno::RuntimeException ) +uno::Type SAL_CALL +SwXDocumentIndex::StyleAccess_Impl::getElementType() +throw (uno::RuntimeException) { return ::getCppuType((uno::Sequence*)0); } /*-- 13.09.99 16:52:30--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXIndexStyleAccess_Impl::hasElements(void) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXDocumentIndex::StyleAccess_Impl::hasElements() throw (uno::RuntimeException) { return sal_True; } -/* -----------------13.09.99 16:51------------------- - - --------------------------------------------------*/ -/* -----------------------------06.04.00 15:08-------------------------------- +/****************************************************************** + * SwXDocumentIndex::TokenAccess_Impl + ******************************************************************/ +/*-- 13.09.99 16:52:28--------------------------------------------------- - ---------------------------------------------------------------------------*/ -OUString SwXIndexTokenAccess_Impl::getImplementationName(void) throw( uno::RuntimeException ) + -----------------------------------------------------------------------*/ +SwXDocumentIndex::TokenAccess_Impl::TokenAccess_Impl( + SwXDocumentIndex& rParentIdx) + : m_xParent(&rParentIdx) { - return C2U("SwXIndexTokenAccess_Impl"); } -/* -----------------------------06.04.00 15:08-------------------------------- +/*-- 13.09.99 16:52:29--------------------------------------------------- - ---------------------------------------------------------------------------*/ -BOOL SwXIndexTokenAccess_Impl::supportsService(const OUString& rServiceName) throw( uno::RuntimeException ) + -----------------------------------------------------------------------*/ +SwXDocumentIndex::TokenAccess_Impl::~TokenAccess_Impl() { - return C2U("com.sun.star.text.DocumentIndexLevelFormat") == rServiceName; } + /* -----------------------------06.04.00 15:08-------------------------------- ---------------------------------------------------------------------------*/ -uno::Sequence< OUString > SwXIndexTokenAccess_Impl::getSupportedServiceNames(void) throw( uno::RuntimeException ) +OUString SAL_CALL +SwXDocumentIndex::TokenAccess_Impl::getImplementationName() +throw (uno::RuntimeException) { - uno::Sequence< OUString > aRet(1); - OUString* pArray = aRet.getArray(); - pArray[0] = C2U("com.sun.star.text.DocumentIndexLevelFormat"); - return aRet; + return C2U("SwXDocumentIndex::TokenAccess_Impl"); } -/*-- 13.09.99 16:52:28--------------------------------------------------- - -----------------------------------------------------------------------*/ -SwXIndexTokenAccess_Impl::SwXIndexTokenAccess_Impl(SwXDocumentIndex& rParentIdx) : - rParent(rParentIdx), - xParent(&rParentIdx), - nCount(0) +static char const*const g_ServicesIndexTokenAccess[] = +{ + "com.sun.star.text.DocumentIndexLevelFormat", +}; +static const size_t g_nServicesIndexTokenAccess( + sizeof(g_ServicesIndexTokenAccess)/sizeof(g_ServicesIndexTokenAccess[0])); + +sal_Bool SAL_CALL +SwXDocumentIndex::TokenAccess_Impl::supportsService( + const OUString& rServiceName) +throw (uno::RuntimeException) { + return ::sw::SupportsServiceImpl( + g_nServicesIndexTokenAccess, g_ServicesIndexTokenAccess, rServiceName); } -/*-- 13.09.99 16:52:29--------------------------------------------------- - -----------------------------------------------------------------------*/ -SwXIndexTokenAccess_Impl::~SwXIndexTokenAccess_Impl() +uno::Sequence< OUString > SAL_CALL +SwXDocumentIndex::TokenAccess_Impl::getSupportedServiceNames() +throw (uno::RuntimeException) { + return ::sw::GetSupportedServiceNamesImpl( + g_nServicesIndexTokenAccess, g_ServicesIndexTokenAccess); } + +struct TokenType { + const char *pName; + const enum FormTokenType eTokenType; +}; + +static const struct TokenType g_TokenTypes[] = +{ + { "TokenEntryNumber", TOKEN_ENTRY_NO }, + { "TokenEntryText", TOKEN_ENTRY_TEXT }, + { "TokenTabStop", TOKEN_TAB_STOP }, + { "TokenText", TOKEN_TEXT }, + { "TokenPageNumber", TOKEN_PAGE_NUMS }, + { "TokenChapterInfo", TOKEN_CHAPTER_INFO }, + { "TokenHyperlinkStart", TOKEN_LINK_START }, + { "TokenHyperlinkEnd", TOKEN_LINK_END }, + { "TokenBibliographyDataField", TOKEN_AUTHORITY }, + { 0, static_cast(0) } +}; + /*-- 13.09.99 16:52:29--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXIndexTokenAccess_Impl::replaceByIndex(sal_Int32 nIndex, const uno::Any& rElement) - throw( lang::IllegalArgumentException, lang::IndexOutOfBoundsException, - lang::WrappedTargetException, uno::RuntimeException) +void SAL_CALL +SwXDocumentIndex::TokenAccess_Impl::replaceByIndex( + sal_Int32 nIndex, const uno::Any& rElement) +throw (lang::IllegalArgumentException, lang::IndexOutOfBoundsException, + lang::WrappedTargetException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwTOXBase * pTOXBase( &rParent.m_pImpl->GetTOXSectionOrThrow() ); + SwTOXBase & rTOXBase( m_xParent->m_pImpl->GetTOXSectionOrThrow() ); - if(nIndex < 0 || - (nIndex > pTOXBase->GetTOXForm().GetFormMax())) - throw lang::IndexOutOfBoundsException(); + if ((nIndex < 0) || (nIndex > rTOXBase.GetTOXForm().GetFormMax())) + { + throw lang::IndexOutOfBoundsException(); + } uno::Sequence aSeq; if(!(rElement >>= aSeq)) + { throw lang::IllegalArgumentException(); - + } String sPattern; - sal_Int32 nTokens = aSeq.getLength(); + const sal_Int32 nTokens = aSeq.getLength(); const beans::PropertyValues* pTokens = aSeq.getConstArray(); for(sal_Int32 i = 0; i < nTokens; i++) { const beans::PropertyValue* pProperties = pTokens[i].getConstArray(); - sal_Int32 nProperties = pTokens[i].getLength(); + const sal_Int32 nProperties = pTokens[i].getLength(); //create an invalid token SwFormToken aToken(TOKEN_END); for(sal_Int32 j = 0; j < nProperties; j++) { - if( COMPARE_EQUAL == pProperties[j].Name.compareToAscii("TokenType")) + if (pProperties[j].Name.equalsAscii("TokenType")) { - const String sTokenType = + const OUString sTokenType = lcl_AnyToString(pProperties[j].Value); - if(sTokenType.EqualsAscii("TokenEntryNumber")) - aToken.eTokenType = TOKEN_ENTRY_NO; - else if(sTokenType.EqualsAscii("TokenEntryText" )) - aToken.eTokenType = TOKEN_ENTRY_TEXT; - else if(sTokenType.EqualsAscii("TokenTabStop" )) - aToken.eTokenType = TOKEN_TAB_STOP; - else if(sTokenType.EqualsAscii("TokenText" )) - aToken.eTokenType = TOKEN_TEXT; - else if(sTokenType.EqualsAscii("TokenPageNumber")) - aToken.eTokenType = TOKEN_PAGE_NUMS; - else if(sTokenType.EqualsAscii("TokenChapterInfo" )) - aToken.eTokenType = TOKEN_CHAPTER_INFO; - else if(sTokenType.EqualsAscii("TokenHyperlinkStart" )) - aToken.eTokenType = TOKEN_LINK_START; - else if(sTokenType.EqualsAscii("TokenHyperlinkEnd")) - aToken.eTokenType = TOKEN_LINK_END; - else if(sTokenType.EqualsAscii("TokenBibliographyDataField" )) - aToken.eTokenType = TOKEN_AUTHORITY; + for (TokenType const* pTokenType = g_TokenTypes; + pTokenType->pName; ++pTokenType) + { + if (sTokenType.equalsAscii(pTokenType->pName)) + { + aToken.eTokenType = pTokenType->eTokenType; + break; + } + } } - else if( pProperties[j].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("CharacterStyleName" ) )) + else if (pProperties[j].Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("CharacterStyleName"))) { String sCharStyleName; SwStyleNameMapper::FillUIName( @@ -2642,54 +2793,68 @@ void SwXIndexTokenAccess_Impl::replaceByIndex(sal_Int32 nIndex, const uno::Any& sal_True); aToken.sCharStyleName = sCharStyleName; aToken.nPoolId = SwStyleNameMapper::GetPoolIdFromUIName ( - sCharStyleName, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT ); + sCharStyleName, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT ); } - else if( pProperties[j].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("TabStopRightAligned") )) + else if (pProperties[j].Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("TabStopRightAligned"))) { - sal_Bool bRight = lcl_AnyToBool(pProperties[j].Value); + const sal_Bool bRight = lcl_AnyToBool(pProperties[j].Value); aToken.eTabAlign = bRight ? SVX_TAB_ADJUST_END : SVX_TAB_ADJUST_LEFT; } - else if( pProperties[j].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("TabStopPosition" ))) + else if (pProperties[j].Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("TabStopPosition"))) { sal_Int32 nPosition = 0; - if(pProperties[j].Value.getValueType() != ::getCppuType((sal_Int32*)0)) + if (!(pProperties[j].Value >>= nPosition)) + { throw lang::IllegalArgumentException(); - pProperties[j].Value >>= nPosition; + } nPosition = MM100_TO_TWIP(nPosition); if(nPosition < 0) + { throw lang::IllegalArgumentException(); + } aToken.nTabStopPosition = nPosition; } - else if( pProperties[j].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("TabStopFillCharacter" ))) + else if (pProperties[j].Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("TabStopFillCharacter"))) { - const String sFillChar = + const OUString sFillChar = lcl_AnyToString(pProperties[j].Value); - if(sFillChar.Len() > 1) + if (sFillChar.getLength() > 1) + { throw lang::IllegalArgumentException(); - aToken.cTabFillChar = sFillChar.Len() ? - sFillChar.GetChar(0) : ' '; + } + aToken.cTabFillChar = + (sFillChar.getLength()) ? sFillChar[0] : ' '; } - else if( pProperties[j].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("Text" ))) + else if (pProperties[j].Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("Text"))) { - const String sText = - lcl_AnyToString(pProperties[j].Value); + const OUString sText = lcl_AnyToString(pProperties[j].Value); aToken.sText = sText; } - else if( pProperties[j].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("ChapterFormat" ))) + else if (pProperties[j].Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("ChapterFormat"))) { sal_Int16 nFormat = lcl_AnyToInt16(pProperties[j].Value); switch(nFormat) { - case text::ChapterFormat::NUMBER: nFormat = CF_NUMBER; + case text::ChapterFormat::NUMBER: + nFormat = CF_NUMBER; break; - case text::ChapterFormat::NAME: nFormat = CF_TITLE; + case text::ChapterFormat::NAME: + nFormat = CF_TITLE; break; - case text::ChapterFormat::NAME_NUMBER: nFormat = CF_NUM_TITLE; + case text::ChapterFormat::NAME_NUMBER: + nFormat = CF_NUM_TITLE; break; - case text::ChapterFormat::NO_PREFIX_SUFFIX:nFormat = CF_NUMBER_NOPREPST; + case text::ChapterFormat::NO_PREFIX_SUFFIX: + nFormat = CF_NUMBER_NOPREPST; break; - case text::ChapterFormat::DIGIT: nFormat = CF_NUM_NOPREPST_TITLE; + case text::ChapterFormat::DIGIT: + nFormat = CF_NUM_NOPREPST_TITLE; break; default: throw lang::IllegalArgumentException(); @@ -2697,15 +2862,19 @@ void SwXIndexTokenAccess_Impl::replaceByIndex(sal_Int32 nIndex, const uno::Any& aToken.nChapterFormat = nFormat; } //--->i53420 - else if( pProperties[j].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("ChapterLevel")) ) + else if (pProperties[j].Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("ChapterLevel"))) { const sal_Int16 nLevel = lcl_AnyToInt16(pProperties[j].Value); if( nLevel < 1 || nLevel > MAXLEVEL ) + { throw lang::IllegalArgumentException(); + } aToken.nOutlineLevel = nLevel; } //<--- - else if( pProperties[j].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("BibliographyDataField"))) + else if (pProperties[j].Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("BibliographyDataField"))) { sal_Int16 nType = 0; pProperties[j].Value >>= nType; @@ -2719,7 +2888,8 @@ void SwXIndexTokenAccess_Impl::replaceByIndex(sal_Int32 nIndex, const uno::Any& aToken.nAuthorityField = nType; } // #i21237# - else if ( pProperties[j].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("WithTab"))) + else if (pProperties[j].Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("WithTab"))) { aToken.bWithTab = lcl_AnyToBool(pProperties[j].Value); } @@ -2727,17 +2897,22 @@ void SwXIndexTokenAccess_Impl::replaceByIndex(sal_Int32 nIndex, const uno::Any& } //exception if wrong TokenType if(TOKEN_END <= aToken.eTokenType ) + { throw lang::IllegalArgumentException(); + } // set TokenType from TOKEN_ENTRY_TEXT to TOKEN_ENTRY if it is // not a content index if(TOKEN_ENTRY_TEXT == aToken.eTokenType && - TOX_CONTENT != pTOXBase->GetType()) + (TOX_CONTENT != rTOXBase.GetType())) + { aToken.eTokenType = TOKEN_ENTRY; + } //---> i53420 // check for chapter format allowed values if it was TOKEN_ENTRY_NO type // only allowed value are CF_NUMBER and CF_NUM_NOPREPST_TITLE // reading from file if( TOKEN_ENTRY_NO == aToken.eTokenType ) + { switch(aToken.nChapterFormat) { case CF_NUMBER: @@ -2746,41 +2921,47 @@ void SwXIndexTokenAccess_Impl::replaceByIndex(sal_Int32 nIndex, const uno::Any& default: throw lang::IllegalArgumentException(); } + } //<--- sPattern += aToken.GetString(); } - SwForm aForm(pTOXBase->GetTOXForm()); - aForm.SetPattern((sal_uInt16) nIndex, sPattern); - pTOXBase->SetTOXForm(aForm); + SwForm aForm(rTOXBase.GetTOXForm()); + aForm.SetPattern(static_cast(nIndex), sPattern); + rTOXBase.SetTOXForm(aForm); } + /*-- 13.09.99 16:52:29--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Int32 SwXIndexTokenAccess_Impl::getCount(void) throw( uno::RuntimeException ) +sal_Int32 SAL_CALL +SwXDocumentIndex::TokenAccess_Impl::getCount() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - const sal_Int32 nRet = rParent.m_pImpl->GetFormMax(); + const sal_Int32 nRet = m_xParent->m_pImpl->GetFormMax(); return nRet; } + /*-- 13.09.99 16:52:30--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Any SwXIndexTokenAccess_Impl::getByIndex(sal_Int32 nIndex) - throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, - uno::RuntimeException) +uno::Any SAL_CALL +SwXDocumentIndex::TokenAccess_Impl::getByIndex(sal_Int32 nIndex) +throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, + uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwTOXBase * pTOXBase( &rParent.m_pImpl->GetTOXSectionOrThrow() ); + SwTOXBase & rTOXBase( m_xParent->m_pImpl->GetTOXSectionOrThrow() ); - if(nIndex < 0 || - (nIndex > pTOXBase->GetTOXForm().GetFormMax())) + if ((nIndex < 0) || (nIndex > rTOXBase.GetTOXForm().GetFormMax())) + { throw lang::IndexOutOfBoundsException(); + } // #i21237# - SwFormTokens aPattern = pTOXBase->GetTOXForm(). - GetPattern((sal_uInt16) nIndex); + SwFormTokens aPattern = rTOXBase.GetTOXForm(). + GetPattern(static_cast(nIndex)); SwFormTokens::iterator aIt = aPattern.begin(); sal_uInt16 nTokenCount = 0; @@ -2793,7 +2974,8 @@ uno::Any SwXIndexTokenAccess_Impl::getByIndex(sal_Int32 nIndex) beans::PropertyValues* pTokenProps = aRetSeq.getArray(); SwFormToken aToken = *aIt; // #i21237# - uno::Sequence< beans::PropertyValue >& rCurTokenSeq = pTokenProps[nTokenCount-1]; + uno::Sequence< beans::PropertyValue >& rCurTokenSeq = + pTokenProps[nTokenCount-1]; SwStyleNameMapper::FillProgName( aToken.sCharStyleName, aString, @@ -2802,25 +2984,30 @@ uno::Any SwXIndexTokenAccess_Impl::getByIndex(sal_Int32 nIndex) const OUString aProgCharStyle( aString ); switch(aToken.eTokenType) { - case TOKEN_ENTRY_NO : + case TOKEN_ENTRY_NO: { //--->i53420 // writing to file (from doc to properties) sal_Int32 nElements = 2; sal_Int32 nCurrentElement = 0; - if( aToken.nChapterFormat != CF_NUMBER )//check for default value + // check for default value + if (aToken.nChapterFormat != CF_NUMBER) + { nElements++;//we need the element + } if( aToken.nOutlineLevel != MAXLEVEL ) + { nElements++; + } rCurTokenSeq.realloc( nElements ); beans::PropertyValue* pArr = rCurTokenSeq.getArray(); pArr[nCurrentElement].Name = C2U("TokenType"); - pArr[nCurrentElement++].Value <<= OUString::createFromAscii("TokenEntryNumber"); -// pArr[0].Value <<= C2U("TokenEntryNumber"); + pArr[nCurrentElement++].Value <<= + OUString::createFromAscii("TokenEntryNumber"); pArr[nCurrentElement].Name = C2U("CharacterStyleName"); pArr[nCurrentElement++].Value <<= aProgCharStyle; @@ -2828,18 +3015,24 @@ uno::Any SwXIndexTokenAccess_Impl::getByIndex(sal_Int32 nIndex) { pArr[nCurrentElement].Name = C2U("ChapterFormat"); sal_Int16 nVal; -//! the allowed values for chapter format, when used as entry number, are CF_NUMBER and CF_NUM_NOPREPST_TITLE only, all else forced to +// the allowed values for chapter format, when used as entry number, +// are CF_NUMBER and CF_NUM_NOPREPST_TITLE only, all else forced to //CF_NUMBER switch(aToken.nChapterFormat) { default: - case CF_NUMBER: nVal = text::ChapterFormat::NUMBER; break; - case CF_NUM_NOPREPST_TITLE: nVal = text::ChapterFormat::DIGIT; break; + case CF_NUMBER: + nVal = text::ChapterFormat::NUMBER; + break; + case CF_NUM_NOPREPST_TITLE: + nVal = text::ChapterFormat::DIGIT; + break; } - pArr[nCurrentElement++].Value <<= (sal_Int16)nVal; + pArr[nCurrentElement++].Value <<= nVal; } - if( aToken.nOutlineLevel != MAXLEVEL ) //only a ChapterLevel != MAXLEVEL is registered + // only a ChapterLevel != MAXLEVEL is registered + if (aToken.nOutlineLevel != MAXLEVEL) { pArr[nCurrentElement].Name = C2U("ChapterLevel"); pArr[nCurrentElement].Value <<= aToken.nOutlineLevel; @@ -2847,8 +3040,8 @@ uno::Any SwXIndexTokenAccess_Impl::getByIndex(sal_Int32 nIndex) //<--- } break; - case TOKEN_ENTRY : // no difference between Entry and Entry Text - case TOKEN_ENTRY_TEXT : + case TOKEN_ENTRY: // no difference between Entry and Entry Text + case TOKEN_ENTRY_TEXT: { rCurTokenSeq.realloc( 2 ); beans::PropertyValue* pArr = rCurTokenSeq.getArray(); @@ -2860,7 +3053,7 @@ uno::Any SwXIndexTokenAccess_Impl::getByIndex(sal_Int32 nIndex) pArr[1].Value <<= aProgCharStyle; } break; - case TOKEN_TAB_STOP : + case TOKEN_TAB_STOP: { rCurTokenSeq.realloc(5); // #i21237# beans::PropertyValue* pArr = rCurTokenSeq.getArray(); @@ -2868,7 +3061,6 @@ uno::Any SwXIndexTokenAccess_Impl::getByIndex(sal_Int32 nIndex) pArr[0].Name = C2U("TokenType"); pArr[0].Value <<= OUString::createFromAscii("TokenTabStop"); - if(SVX_TAB_ADJUST_END == aToken.eTabAlign) { pArr[1].Name = C2U("TabStopRightAligned"); @@ -2889,10 +3081,10 @@ uno::Any SwXIndexTokenAccess_Impl::getByIndex(sal_Int32 nIndex) pArr[3].Value <<= aProgCharStyle; // #i21237# pArr[4].Name = C2U("WithTab"); - pArr[4].Value.setValue(&aToken.bWithTab, ::getCppuBooleanType()); + pArr[4].Value <<= static_cast(aToken.bWithTab); } break; - case TOKEN_TEXT : + case TOKEN_TEXT: { rCurTokenSeq.realloc( 3 ); beans::PropertyValue* pArr = rCurTokenSeq.getArray(); @@ -2907,7 +3099,7 @@ uno::Any SwXIndexTokenAccess_Impl::getByIndex(sal_Int32 nIndex) pArr[2].Value <<= OUString(aToken.sText); } break; - case TOKEN_PAGE_NUMS : + case TOKEN_PAGE_NUMS: { rCurTokenSeq.realloc( 2 ); beans::PropertyValue* pArr = rCurTokenSeq.getArray(); @@ -2919,7 +3111,7 @@ uno::Any SwXIndexTokenAccess_Impl::getByIndex(sal_Int32 nIndex) pArr[1].Value <<= aProgCharStyle; } break; - case TOKEN_CHAPTER_INFO : + case TOKEN_CHAPTER_INFO: { rCurTokenSeq.realloc( 4 ); beans::PropertyValue* pArr = rCurTokenSeq.getArray(); @@ -2934,13 +3126,23 @@ uno::Any SwXIndexTokenAccess_Impl::getByIndex(sal_Int32 nIndex) sal_Int16 nVal = text::ChapterFormat::NUMBER; switch(aToken.nChapterFormat) { - case CF_NUMBER: nVal = text::ChapterFormat::NUMBER; break; - case CF_TITLE: nVal = text::ChapterFormat::NAME; break; - case CF_NUM_TITLE: nVal = text::ChapterFormat::NAME_NUMBER; break; - case CF_NUMBER_NOPREPST: nVal = text::ChapterFormat::NO_PREFIX_SUFFIX; break; - case CF_NUM_NOPREPST_TITLE: nVal = text::ChapterFormat::DIGIT; break; + case CF_NUMBER: + nVal = text::ChapterFormat::NUMBER; + break; + case CF_TITLE: + nVal = text::ChapterFormat::NAME; + break; + case CF_NUM_TITLE: + nVal = text::ChapterFormat::NAME_NUMBER; + break; + case CF_NUMBER_NOPREPST: + nVal = text::ChapterFormat::NO_PREFIX_SUFFIX; + break; + case CF_NUM_NOPREPST_TITLE: + nVal = text::ChapterFormat::DIGIT; + break; } - pArr[2].Value <<= (sal_Int16)nVal; + pArr[2].Value <<= nVal; //--->i53420 pArr[3].Name = C2U("ChapterLevel"); // @@ -2948,33 +3150,36 @@ uno::Any SwXIndexTokenAccess_Impl::getByIndex(sal_Int32 nIndex) //<--- } break; - case TOKEN_LINK_START : + case TOKEN_LINK_START: { rCurTokenSeq.realloc( 2 ); beans::PropertyValue* pArr = rCurTokenSeq.getArray(); pArr[0].Name = C2U("TokenType"); - pArr[0].Value <<= OUString::createFromAscii("TokenHyperlinkStart"); + pArr[0].Value <<= + OUString::createFromAscii("TokenHyperlinkStart"); pArr[1].Name = C2U("CharacterStyleName"); pArr[1].Value <<= aProgCharStyle; } break; - case TOKEN_LINK_END : + case TOKEN_LINK_END: { rCurTokenSeq.realloc( 1 ); beans::PropertyValue* pArr = rCurTokenSeq.getArray(); pArr[0].Name = C2U("TokenType"); - pArr[0].Value <<= OUString::createFromAscii("TokenHyperlinkEnd"); + pArr[0].Value <<= + OUString::createFromAscii("TokenHyperlinkEnd"); } break; - case TOKEN_AUTHORITY : + case TOKEN_AUTHORITY: { rCurTokenSeq.realloc( 3 ); beans::PropertyValue* pArr = rCurTokenSeq.getArray(); pArr[0].Name = C2U("TokenType"); - pArr[0].Value <<= OUString::createFromAscii("TokenBibliographyDataField"); + pArr[0].Value <<= + OUString::createFromAscii("TokenBibliographyDataField"); pArr[1].Name = C2U("CharacterStyleName"); pArr[1].Value <<= aProgCharStyle; @@ -2991,22 +3196,26 @@ uno::Any SwXIndexTokenAccess_Impl::getByIndex(sal_Int32 nIndex) aIt++; // #i21237# } - uno::Any aRet(&aRetSeq, ::getCppuType((uno::Sequence< beans::PropertyValues >*)0)); - + uno::Any aRet; + aRet <<= aRetSeq; return aRet; } + /*-- 13.09.99 16:52:30--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Type SwXIndexTokenAccess_Impl::getElementType(void) - throw( uno::RuntimeException ) +uno::Type SAL_CALL +SwXDocumentIndex::TokenAccess_Impl::getElementType() +throw (uno::RuntimeException) { return ::getCppuType((uno::Sequence< beans::PropertyValues >*)0); } /*-- 13.09.99 16:52:30--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXIndexTokenAccess_Impl::hasElements(void) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXDocumentIndex::TokenAccess_Impl::hasElements() +throw (uno::RuntimeException) { return sal_True; } -- cgit From f3dca2c04f5bd6d30c33e06de2ef6f35636ddbe9 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 8 Jan 2010 17:13:59 +0100 Subject: swunolocking1: #i105557#: SwXDocumentIndexes: use new XServiceInfo helpers. clean up the implementation a little. --- sw/inc/unoidx.hxx | 67 ++++++++++------- sw/source/core/unocore/unoidx.cxx | 150 +++++++++++++++++++++++--------------- 2 files changed, 131 insertions(+), 86 deletions(-) (limited to 'sw') diff --git a/sw/inc/unoidx.hxx b/sw/inc/unoidx.hxx index f3462a17bebb..8d432f9fdcf3 100644 --- a/sw/inc/unoidx.hxx +++ b/sw/inc/unoidx.hxx @@ -271,46 +271,57 @@ public: SwDoc* pDoc); void Invalidate(); }; + /* -----------------05.05.99 12:27------------------- * * --------------------------------------------------*/ - -class SwXDocumentIndexes : public SwCollectionBaseClass, - public SwUnoCollection +class SwXDocumentIndexes + : public SwCollectionBaseClass + , public SwUnoCollection { -protected: - virtual ~SwXDocumentIndexes(); -public: - SwXDocumentIndexes(SwDoc* pDoc); - -// SMART_UNO_DECLARATION( SwXDocumentIndexes, UsrObject ); +private: -// automatisch auskommentiert - [getIdlClass or queryInterface] - Bitte XTypeProvider benutzen! -// virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::reflection::XIdlClass > > getIdlClasses(void) + virtual ~SwXDocumentIndexes(); -// throw( ::com::sun::star::uno::RuntimeException ); -// automatisch auskommentiert - [getIdlClass or queryInterface] - Bitte XTypeProvider benutzen! -// virtual sal_Bool queryInterface( ::com::sun::star::uno::Uik aUik, ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & rOut ); +public: + SwXDocumentIndexes(SwDoc *const pDoc); - //XNameAccess - virtual ::com::sun::star::uno::Any SAL_CALL getByName(const rtl::OUString& Name) throw( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getElementNames(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual sal_Bool SAL_CALL hasByName(const rtl::OUString& Name) throw( ::com::sun::star::uno::RuntimeException ); + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( + const ::rtl::OUString& rServiceName) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL + getSupportedServiceNames() + throw (::com::sun::star::uno::RuntimeException); - //XIndexAccess - virtual sal_Int32 SAL_CALL getCount(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException ); + // XElementAccess + virtual ::com::sun::star::uno::Type SAL_CALL getElementType() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL hasElements() + throw (::com::sun::star::uno::RuntimeException); - //XElementAccess - virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw(::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL hasElements( ) throw(::com::sun::star::uno::RuntimeException); + // XIndexAccess + virtual sal_Int32 SAL_CALL getCount() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) + throw (::com::sun::star::lang::IndexOutOfBoundsException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); - //XServiceInfo - virtual rtl::OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual BOOL SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException ); + // XNameAccess + virtual ::com::sun::star::uno::Any SAL_CALL getByName( + const ::rtl::OUString& rName) + throw (::com::sun::star::container::NoSuchElementException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL + getElementNames() throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL hasByName(const ::rtl::OUString& rName) + throw (::com::sun::star::uno::RuntimeException); }; diff --git a/sw/source/core/unocore/unoidx.cxx b/sw/source/core/unocore/unoidx.cxx index 4c55e3e1963f..0b6a3c8c93c2 100644 --- a/sw/source/core/unocore/unoidx.cxx +++ b/sw/source/core/unocore/unoidx.cxx @@ -2312,49 +2312,63 @@ void SwXDocumentIndexMark::Invalidate() m_pDoc = 0; } } -/* -----------------------------06.04.00 15:08-------------------------------- - ---------------------------------------------------------------------------*/ -OUString SwXDocumentIndexes::getImplementationName(void) throw( uno::RuntimeException ) +/****************************************************************** + * SwXDocumentIndexes + ******************************************************************/ +/*-- 05.05.99 13:14:59--------------------------------------------------- + + -----------------------------------------------------------------------*/ +SwXDocumentIndexes::SwXDocumentIndexes(SwDoc *const _pDoc) + : SwUnoCollection(_pDoc) { - return C2U("SwXDocumentIndexes"); } -/* -----------------------------06.04.00 15:08-------------------------------- +/*-- 05.05.99 13:15:00--------------------------------------------------- - ---------------------------------------------------------------------------*/ -BOOL SwXDocumentIndexes::supportsService(const OUString& rServiceName) throw( uno::RuntimeException ) + -----------------------------------------------------------------------*/ +SwXDocumentIndexes::~SwXDocumentIndexes() { - return C2U("com.sun.star.text.DocumentIndexes") == rServiceName; } + /* -----------------------------06.04.00 15:08-------------------------------- ---------------------------------------------------------------------------*/ -uno::Sequence< OUString > SwXDocumentIndexes::getSupportedServiceNames(void) throw( uno::RuntimeException ) +OUString SAL_CALL +SwXDocumentIndexes::getImplementationName() throw (uno::RuntimeException) { - uno::Sequence< OUString > aRet(1); - OUString* pArray = aRet.getArray(); - pArray[0] = C2U("com.sun.star.text.DocumentIndexes"); - return aRet; + return C2U("SwXDocumentIndexes"); } -/*-- 05.05.99 13:14:59--------------------------------------------------- - -----------------------------------------------------------------------*/ -SwXDocumentIndexes::SwXDocumentIndexes(SwDoc* _pDoc) : - SwUnoCollection(_pDoc) +static char const*const g_ServicesDocumentIndexes[] = +{ + "com.sun.star.text.DocumentIndexes", +}; +static const size_t g_nServicesDocumentIndexes( + sizeof(g_ServicesDocumentIndexes)/sizeof(g_ServicesDocumentIndexes[0])); + +sal_Bool SAL_CALL +SwXDocumentIndexes::supportsService(const OUString& rServiceName) +throw (uno::RuntimeException) { + return ::sw::SupportsServiceImpl( + g_nServicesDocumentIndexes, g_ServicesDocumentIndexes, rServiceName); } -/*-- 05.05.99 13:15:00--------------------------------------------------- - -----------------------------------------------------------------------*/ -SwXDocumentIndexes::~SwXDocumentIndexes() +uno::Sequence< OUString > SAL_CALL +SwXDocumentIndexes::getSupportedServiceNames() throw (uno::RuntimeException) { + return ::sw::GetSupportedServiceNamesImpl( + g_nServicesDocumentIndexes, g_ServicesDocumentIndexes); } + /*-- 05.05.99 13:15:01--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Int32 SwXDocumentIndexes::getCount(void) throw( uno::RuntimeException ) +sal_Int32 SAL_CALL +SwXDocumentIndexes::getCount() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + if(!IsValid()) throw uno::RuntimeException(); @@ -2365,17 +2379,23 @@ sal_Int32 SwXDocumentIndexes::getCount(void) throw( uno::RuntimeException ) const SwSection* pSect = rFmts[ n ]->GetSection(); if( TOX_CONTENT_SECTION == pSect->GetType() && pSect->GetFmt()->GetSectionNode() ) + { ++nRet; + } } return nRet; } + /*-- 05.05.99 13:15:01--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Any SwXDocumentIndexes::getByIndex(sal_Int32 nIndex) - throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException ) +uno::Any SAL_CALL +SwXDocumentIndexes::getByIndex(sal_Int32 nIndex) +throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, + uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + if(!IsValid()) throw uno::RuntimeException(); @@ -2388,14 +2408,14 @@ uno::Any SwXDocumentIndexes::getByIndex(sal_Int32 nIndex) if( TOX_CONTENT_SECTION == pSect->GetType() && pSect->GetFmt()->GetSectionNode() && nIdx++ == nIndex ) - { - const uno::Reference< text::XDocumentIndex > xTmp = - SwXDocumentIndex::CreateXDocumentIndex( - *GetDoc(), static_cast(*pSect)); - uno::Any aRet; - aRet <<= xTmp; - return aRet; - } + { + const uno::Reference< text::XDocumentIndex > xTmp = + SwXDocumentIndex::CreateXDocumentIndex( + *GetDoc(), static_cast(*pSect)); + uno::Any aRet; + aRet <<= xTmp; + return aRet; + } } throw lang::IndexOutOfBoundsException(); @@ -2404,14 +2424,16 @@ uno::Any SwXDocumentIndexes::getByIndex(sal_Int32 nIndex) /*-- 31.01.00 10:12:31--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Any SwXDocumentIndexes::getByName(const OUString& rName) - throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException ) +uno::Any SAL_CALL +SwXDocumentIndexes::getByName(const OUString& rName) +throw (container::NoSuchElementException, lang::WrappedTargetException, + uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + if(!IsValid()) throw uno::RuntimeException(); - String sToFind(rName); const SwSectionFmts& rFmts = GetDoc()->GetSections(); for( sal_uInt16 n = 0; n < rFmts.Count(); ++n ) @@ -2419,25 +2441,28 @@ uno::Any SwXDocumentIndexes::getByName(const OUString& rName) const SwSection* pSect = rFmts[ n ]->GetSection(); if( TOX_CONTENT_SECTION == pSect->GetType() && pSect->GetFmt()->GetSectionNode() && - ((SwTOXBaseSection*)pSect)->GetTOXName() == sToFind) - { - const uno::Reference< text::XDocumentIndex > xTmp = - SwXDocumentIndex::CreateXDocumentIndex( - *GetDoc(), static_cast(*pSect)); - uno::Any aRet; - aRet <<= xTmp; - return aRet; - } + (static_cast(pSect)->GetTOXName() + == sToFind)) + { + const uno::Reference< text::XDocumentIndex > xTmp = + SwXDocumentIndex::CreateXDocumentIndex( + *GetDoc(), static_cast(*pSect)); + uno::Any aRet; + aRet <<= xTmp; + return aRet; + } } throw container::NoSuchElementException(); } + /*-- 31.01.00 10:12:31--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Sequence< OUString > SwXDocumentIndexes::getElementNames(void) - throw( uno::RuntimeException ) +uno::Sequence< OUString > SAL_CALL +SwXDocumentIndexes::getElementNames() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + if(!IsValid()) throw uno::RuntimeException(); @@ -2446,10 +2471,12 @@ uno::Sequence< OUString > SwXDocumentIndexes::getElementNames(void) sal_uInt16 n; for( n = 0; n < rFmts.Count(); ++n ) { - const SwSection* pSect = rFmts[ n ]->GetSection(); + SwSection const*const pSect = rFmts[ n ]->GetSection(); if( TOX_CONTENT_SECTION == pSect->GetType() && pSect->GetFmt()->GetSectionNode() ) + { ++nCount; + } } uno::Sequence< OUString > aRet(nCount); @@ -2457,22 +2484,26 @@ uno::Sequence< OUString > SwXDocumentIndexes::getElementNames(void) sal_uInt16 nCnt; for( n = 0, nCnt = 0; n < rFmts.Count(); ++n ) { - const SwSection* pSect = rFmts[ n ]->GetSection(); + SwSection const*const pSect = rFmts[ n ]->GetSection(); if( TOX_CONTENT_SECTION == pSect->GetType() && pSect->GetFmt()->GetSectionNode()) { - pArray[nCnt++] = OUString(((SwTOXBaseSection*)pSect)->GetTOXName()); + pArray[nCnt++] = OUString( + static_cast(pSect)->GetTOXName()); } } return aRet; } + /*-- 31.01.00 10:12:31--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXDocumentIndexes::hasByName(const OUString& rName) - throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXDocumentIndexes::hasByName(const OUString& rName) +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + if(!IsValid()) throw uno::RuntimeException(); @@ -2480,31 +2511,34 @@ sal_Bool SwXDocumentIndexes::hasByName(const OUString& rName) const SwSectionFmts& rFmts = GetDoc()->GetSections(); for( sal_uInt16 n = 0; n < rFmts.Count(); ++n ) { - const SwSection* pSect = rFmts[ n ]->GetSection(); + SwSection const*const pSect = rFmts[ n ]->GetSection(); if( TOX_CONTENT_SECTION == pSect->GetType() && pSect->GetFmt()->GetSectionNode()) { - if(((SwTOXBaseSection*)pSect)->GetTOXName() == sToFind) + if (static_cast(pSect)->GetTOXName() + == sToFind) + { return sal_True; + } } } return sal_False; } + /*-- 05.05.99 13:15:01--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Type SwXDocumentIndexes::getElementType(void) throw( uno::RuntimeException ) +uno::Type SAL_CALL +SwXDocumentIndexes::getElementType() throw (uno::RuntimeException) { - return ::getCppuType((uno::Reference< text::XDocumentIndex> *)0); + return text::XDocumentIndex::static_type(); } /*-- 05.05.99 13:15:02--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXDocumentIndexes::hasElements(void) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXDocumentIndexes::hasElements() throw (uno::RuntimeException) { - vos::OGuard aGuard(Application::GetSolarMutex()); - if(!IsValid()) - throw uno::RuntimeException(); return 0 != getCount(); } -- cgit From fb0dd0d206e140a72291bff3e0225c938bb9de68 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 8 Jan 2010 17:13:59 +0100 Subject: swunolocking1: #i105557#: fix locking for SwXDocumentIndexMark: add Impl struct, and use UnoImplPtr to lock destructor. move all implementation details out of header, into Impl struct. disable broken SwClient iteration. make constructor private, and add factory function CreateXDocumentIndexMark. use new XUnoTunnel helpers. clean up the implementation a little. remove SwXDocumentIndexMark::GetObject(). --- sw/inc/unoidx.hxx | 179 +++--- sw/source/core/unocore/unoclbck.cxx | 12 +- sw/source/core/unocore/unocrsrhelper.cxx | 8 +- sw/source/core/unocore/unoidx.cxx | 992 ++++++++++++++++++------------- sw/source/core/unocore/unoportenum.cxx | 5 +- 5 files changed, 700 insertions(+), 496 deletions(-) (limited to 'sw') diff --git a/sw/inc/unoidx.hxx b/sw/inc/unoidx.hxx index 8d432f9fdcf3..dd1edce22d0d 100644 --- a/sw/inc/unoidx.hxx +++ b/sw/inc/unoidx.hxx @@ -36,14 +36,13 @@ #include #include +#include #include -#include #include #include -class SfxItemPropertySet; class SwTOXBaseSection; class SwTOXMark; class SwTOXType; @@ -189,87 +188,129 @@ public: /* -----------------07.12.98 10:08------------------- * * --------------------------------------------------*/ -class SwXDocumentIndexMark : public cppu::WeakImplHelper4 -< - ::com::sun::star::text::XDocumentIndexMark, - ::com::sun::star::lang::XServiceInfo, - ::com::sun::star::beans::XPropertySet, - ::com::sun::star::lang::XUnoTunnel ->, - public SwClient +typedef ::cppu::WeakImplHelper4 +< ::com::sun::star::lang::XUnoTunnel +, ::com::sun::star::lang::XServiceInfo +, ::com::sun::star::beans::XPropertySet +, ::com::sun::star::text::XDocumentIndexMark +> SwXDocumentIndexMark_Base; + +class SwXDocumentIndexMark + : public SwXDocumentIndexMark_Base { - SwEventListenerContainer aLstnrCntnr; - SwDepend aTypeDepend; - SwDoc* m_pDoc; - const SwTOXMark* m_pTOXMark; - const SfxItemPropertySet* m_pPropSet; - - sal_Bool bIsDescriptor; - sal_Bool bMainEntry; - TOXTypes eType; - sal_uInt16 nLevel; - String sAltText; - String sPrimaryKey; - String sSecondaryKey; - String sTextReading; - String sPrimaryKeyReading; - String sSecondaryKeyReading; - String sUserIndexName; - - void InitMap(TOXTypes eToxType); -protected: - virtual ~SwXDocumentIndexMark(); -public: - SwXDocumentIndexMark(TOXTypes eToxType); - SwXDocumentIndexMark(const SwTOXType* pType, - const SwTOXMark* pMark, - SwDoc* pDc); +private: - TYPEINFO(); + class Impl; + ::sw::UnoImplPtr m_pImpl; - static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId(); + virtual ~SwXDocumentIndexMark(); - //XUnoTunnel - virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); + SwXDocumentIndexMark(SwDoc & rDoc, + SwTOXType & rType, const SwTOXMark & rMark); - virtual rtl::OUString SAL_CALL getMarkEntry(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL setMarkEntry(const rtl::OUString& aIndexEntry) throw( ::com::sun::star::uno::RuntimeException ); +public: - //XTextContent - virtual void SAL_CALL attach(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xTextRange) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getAnchor(void) throw( ::com::sun::star::uno::RuntimeException ); + /// descriptor + SwXDocumentIndexMark(const TOXTypes eToxType); - //XComponent - virtual void SAL_CALL dispose(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw( ::com::sun::star::uno::RuntimeException ); + static ::com::sun::star::uno::Reference< + ::com::sun::star::text::XDocumentIndexMark> + CreateXDocumentIndexMark(SwDoc & rDoc, + SwTOXType & rType, const SwTOXMark & rMark); - //XPropertySet - virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId(); - //XServiceInfo - virtual rtl::OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual BOOL SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException ); + // XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( + const ::com::sun::star::uno::Sequence< sal_Int8 >& rIdentifier) + throw (::com::sun::star::uno::RuntimeException); - //SwClient - virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew); + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( + const ::rtl::OUString& rServiceName) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL + getSupportedServiceNames() + throw (::com::sun::star::uno::RuntimeException); + + // XComponent + virtual void SAL_CALL dispose() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addEventListener( + const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XEventListener > & xListener) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeEventListener( + const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XEventListener > & xListener) + throw (::com::sun::star::uno::RuntimeException); + + // XPropertySet + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySetInfo > SAL_CALL + getPropertySetInfo() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertyValue( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Any& rValue) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::beans::PropertyVetoException, + ::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( + const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addPropertyChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertyChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removePropertyChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertyChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addVetoableChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XVetoableChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeVetoableChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XVetoableChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); - void attachToRange(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xTextRange)throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); + // XTextContent + virtual void SAL_CALL attach( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xTextRange) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > SAL_CALL getAnchor() + throw (::com::sun::star::uno::RuntimeException); - SwTOXType* GetTOXType() const {return (SwTOXType*)aTypeDepend.GetRegisteredIn();} - const SwTOXMark* GetTOXMark() const {return m_pTOXMark;} + // XDocumentIndexMark + virtual rtl::OUString SAL_CALL getMarkEntry() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setMarkEntry(const rtl::OUString& rIndexEntry) + throw (::com::sun::star::uno::RuntimeException); - static SwXDocumentIndexMark* GetObject(SwTOXType* pType, const SwTOXMark* pMark, - SwDoc* pDoc); - void Invalidate(); }; /* -----------------05.05.99 12:27------------------- diff --git a/sw/source/core/unocore/unoclbck.cxx b/sw/source/core/unocore/unoclbck.cxx index 6cc9cc0ee910..6e5b08210147 100644 --- a/sw/source/core/unocore/unoclbck.cxx +++ b/sw/source/core/unocore/unoclbck.cxx @@ -78,18 +78,8 @@ SwXFootnote* SwUnoCallBack::GetFootnote(const SwFmtFtn& rMark) /* -----------------------------27.11.00 17:15-------------------------------- ---------------------------------------------------------------------------*/ -SwXDocumentIndexMark* SwUnoCallBack::GetTOXMark(const SwTOXMark& rMark) +SwXDocumentIndexMark* SwUnoCallBack::GetTOXMark(const SwTOXMark& /*rMark*/) { - SwClientIter aIter( *this ); - SwXDocumentIndexMark* pxIndexMark = (SwXDocumentIndexMark*)aIter.First( TYPE( SwXDocumentIndexMark )); - while(pxIndexMark) - { - const SwTOXMark* pMark = pxIndexMark->GetTOXMark(); - if(pMark == &rMark) - return pxIndexMark; - - pxIndexMark = (SwXDocumentIndexMark*)aIter.Next( ); - } return 0; } diff --git a/sw/source/core/unocore/unocrsrhelper.cxx b/sw/source/core/unocore/unocrsrhelper.cxx index df34c675bfa0..642b0b5030aa 100644 --- a/sw/source/core/unocore/unocrsrhelper.cxx +++ b/sw/source/core/unocore/unocrsrhelper.cxx @@ -314,9 +314,11 @@ sal_Bool getCrsrPropertyValue(const SfxItemPropertySimpleEntry& rEntry if( pAny ) { const SwTOXMark& rMark = pTxtAttr->GetTOXMark(); - uno::Reference< XDocumentIndexMark > xRef = SwXDocumentIndexMark::GetObject( - (SwTOXType*)rMark.GetTOXType(), &rMark, rPam.GetDoc()); - pAny->setValue(&xRef, ::getCppuType((uno::Reference*)0)); + const uno::Reference< text::XDocumentIndexMark > xRef = + SwXDocumentIndexMark::CreateXDocumentIndexMark( + *rPam.GetDoc(), + *const_cast(rMark.GetTOXType()), rMark); + (*pAny) <<= xRef; } } else diff --git a/sw/source/core/unocore/unoidx.cxx b/sw/source/core/unocore/unoidx.cxx index 0b6a3c8c93c2..807b230c5b6d 100644 --- a/sw/source/core/unocore/unoidx.cxx +++ b/sw/source/core/unocore/unoidx.cxx @@ -70,6 +70,7 @@ #include #include #include +#include using namespace ::com::sun::star; @@ -326,7 +327,7 @@ SwDocIndexDescriptorProperties_Impl::SwDocIndexDescriptorProperties_Impl( } static sal_uInt16 -lcl_TypeToPropertyMap(const TOXTypes eType) +lcl_TypeToPropertyMap_Index(const TOXTypes eType) { switch (eType) { @@ -363,7 +364,7 @@ public: SwTOXBaseSection const*const pBaseSection) : SwClient((pBaseSection) ? pBaseSection->GetFmt() : 0) , m_rPropSet( - *aSwMapProvider.GetPropertySet(lcl_TypeToPropertyMap(eType))) + *aSwMapProvider.GetPropertySet(lcl_TypeToPropertyMap_Index(eType))) , m_eTOXType(eType) , m_ListenerContainer(static_cast< ::cppu::OWeakObject* >(&rThis)) , m_bIsDescriptor(0 == pBaseSection) @@ -1264,8 +1265,9 @@ throw (beans::UnknownPropertyException, lang::WrappedTargetException, for(USHORT i = 0; i < aMarks.Count(); i++) { pMark = aMarks.GetObject(i); - pxMarks[i] = SwXDocumentIndexMark::GetObject( - const_cast(pType), pMark, m_pImpl->m_pDoc); + pxMarks[i] = SwXDocumentIndexMark::CreateXDocumentIndexMark( + *m_pImpl->m_pDoc, + *const_cast(pType), *pMark); } aRet <<= aXMarks; } @@ -1552,6 +1554,165 @@ SwXDocumentIndex::setName(const OUString& rName) throw (uno::RuntimeException) /****************************************************************** * SwXDocumentIndexMark ******************************************************************/ +/* -----------------21.04.99 09:36------------------- + * + * --------------------------------------------------*/ +static sal_uInt16 +lcl_TypeToPropertyMap_Mark(const TOXTypes eType) +{ + switch (eType) + { + case TOX_INDEX: return PROPERTY_MAP_INDEX_MARK; + case TOX_CONTENT: return PROPERTY_MAP_CNTIDX_MARK; + //case TOX_USER: + default: + return PROPERTY_MAP_USER_MARK; + } +} + +class SwXDocumentIndexMark::Impl + : public SwClient +{ + +public: + + SfxItemPropertySet const& m_rPropSet; + const TOXTypes m_eTOXType; + SwEventListenerContainer m_ListenerContainer; + bool m_bIsDescriptor; + SwDepend m_TypeDepend; + const SwTOXMark * m_pTOXMark; + SwDoc * m_pDoc; + + sal_Bool m_bMainEntry; + sal_uInt16 m_nLevel; + OUString m_sAltText; + OUString m_sPrimaryKey; + OUString m_sSecondaryKey; + OUString m_sTextReading; + OUString m_sPrimaryKeyReading; + OUString m_sSecondaryKeyReading; + OUString m_sUserIndexName; + + Impl( SwXDocumentIndexMark & rThis, + SwDoc *const pDoc, + const enum TOXTypes eType, + SwTOXType *const pType, SwTOXMark const*const pMark) + : SwClient((pDoc) ? pDoc->GetUnoCallBack() : 0) + , m_rPropSet( + *aSwMapProvider.GetPropertySet(lcl_TypeToPropertyMap_Mark(eType))) + , m_eTOXType(eType) + , m_ListenerContainer(static_cast< ::cppu::OWeakObject* >(&rThis)) + , m_bIsDescriptor(0 == pMark) + , m_TypeDepend(this, pType) + , m_pTOXMark(pMark) + , m_pDoc(pDoc) + , m_bMainEntry(sal_False) + , m_nLevel(0) + { + } + + SwTOXType * GetTOXType() const { + return static_cast( + const_cast(m_TypeDepend.GetRegisteredIn())); + } + + void Invalidate(); + + // SwClient + virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + +}; + +/* -----------------------------16.10.00 11:24-------------------------------- + + ---------------------------------------------------------------------------*/ +void SwXDocumentIndexMark::Impl::Invalidate() +{ + if (GetRegisteredIn()) + { + const_cast(GetRegisteredIn())->Remove(this); + if (m_TypeDepend.GetRegisteredIn()) + { + const_cast(m_TypeDepend.GetRegisteredIn())->Remove( + &m_TypeDepend); + } + } + m_ListenerContainer.Disposing(); + m_pDoc = 0; + m_pTOXMark = 0; +} + +/*-- 14.12.98 10:25:47--------------------------------------------------- + + -----------------------------------------------------------------------*/ +void SwXDocumentIndexMark::Impl::Modify(SfxPoolItem *pOld, SfxPoolItem *pNew) +{ + ClientModify(this, pOld, pNew); + + if (!GetRegisteredIn()) // removed => dispose + { + Invalidate(); + } + else if (pOld) + { + switch (pOld->Which()) + { + case RES_TOXMARK_DELETED: + if (static_cast(m_pTOXMark) == + static_cast(pOld)->pObject) + { + Invalidate(); + } + break; + } + } +} + +/*-- 14.12.98 10:25:43--------------------------------------------------- + + -----------------------------------------------------------------------*/ +SwXDocumentIndexMark::SwXDocumentIndexMark(const TOXTypes eToxType) + : m_pImpl( new SwXDocumentIndexMark::Impl(*this, 0, eToxType, 0, 0) ) +{ +} +/*-- 14.12.98 10:25:44--------------------------------------------------- + + -----------------------------------------------------------------------*/ +SwXDocumentIndexMark::SwXDocumentIndexMark(SwDoc & rDoc, + SwTOXType & rType, const SwTOXMark & rMark) + : m_pImpl( new SwXDocumentIndexMark::Impl(*this, &rDoc, rType.GetType(), + &rType, &rMark) ) +{ +} +/*-- 14.12.98 10:25:44--------------------------------------------------- + + -----------------------------------------------------------------------*/ +SwXDocumentIndexMark::~SwXDocumentIndexMark() +{ +} + +uno::Reference +SwXDocumentIndexMark::CreateXDocumentIndexMark( + SwDoc & rDoc, SwTOXType & rType, const SwTOXMark & rMark) +{ + // #i105557#: do not iterate over the registered clients: race condition + // to do this properly requires the SwXDocumentIndexMark to register at the + // format directly, not at the unocallback +#if 0 + SwClientIter aIter(*pType); + SwXDocumentIndexMark::Impl* pxMark = (SwXDocumentIndexMark::Impl*) + aIter.First(TYPE(SwXDocumentIndexMark::Impl)); + while( pxMark ) + { + if(pxMark->m_pTOXMark == pMark) + return pxMark->m_rThis; + pxMark = (SwXDocumentIndexMark::Impl*)aIter.Next(); + } +#endif + return new SwXDocumentIndexMark(rDoc, rType, rMark); +} + /* -----------------------------10.03.00 18:02-------------------------------- ---------------------------------------------------------------------------*/ @@ -1563,55 +1724,62 @@ const uno::Sequence< sal_Int8 > & SwXDocumentIndexMark::getUnoTunnelId() /* -----------------------------10.03.00 18:04-------------------------------- ---------------------------------------------------------------------------*/ -sal_Int64 SAL_CALL SwXDocumentIndexMark::getSomething( const uno::Sequence< sal_Int8 >& rId ) - throw(uno::RuntimeException) +sal_Int64 SAL_CALL +SwXDocumentIndexMark::getSomething(const uno::Sequence< sal_Int8 >& rId) +throw (uno::RuntimeException) { - if( rId.getLength() == 16 - && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), - rId.getConstArray(), 16 ) ) - { - return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(this) ); - } - return 0; + return ::sw::UnoTunnelImpl(rId, this); } -TYPEINIT1(SwXDocumentIndexMark, SwClient) -const sal_Char cBaseMark[] = "com.sun.star.text.BaseIndexMark"; -const sal_Char cContentMark[] = "com.sun.star.text.ContentIndexMark"; -const sal_Char cIdxMark[] = "com.sun.star.text.DocumentIndexMark"; -const sal_Char cIdxMarkAsian[] = "com.sun.star.text.DocumentIndexMarkAsian"; -const sal_Char cUserMark[] = "com.sun.star.text.UserIndexMark"; -const sal_Char cTextContent[] = "com.sun.star.text.TextContent"; +static const sal_Char cBaseMark[] = "com.sun.star.text.BaseIndexMark"; +static const sal_Char cContentMark[] = "com.sun.star.text.ContentIndexMark"; +static const sal_Char cIdxMark[] = "com.sun.star.text.DocumentIndexMark"; +static const sal_Char cIdxMarkAsian[] = "com.sun.star.text.DocumentIndexMarkAsian"; +static const sal_Char cUserMark[] = "com.sun.star.text.UserIndexMark"; +static const sal_Char cTextContent[] = "com.sun.star.text.TextContent"; + /* -----------------------------06.04.00 15:07-------------------------------- ---------------------------------------------------------------------------*/ -OUString SwXDocumentIndexMark::getImplementationName(void) throw( uno::RuntimeException ) +OUString SAL_CALL +SwXDocumentIndexMark::getImplementationName() throw (uno::RuntimeException) { return C2U("SwXDocumentIndexMark"); } /* -----------------------------06.04.00 15:07-------------------------------- ---------------------------------------------------------------------------*/ -BOOL SwXDocumentIndexMark::supportsService(const OUString& rServiceName) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXDocumentIndexMark::supportsService(const OUString& rServiceName) +throw (uno::RuntimeException) { - return !rServiceName.compareToAscii(cBaseMark)|| - !rServiceName.compareToAscii(cTextContent) || - (eType == TOX_USER && !rServiceName.compareToAscii(cUserMark)) || - (eType == TOX_CONTENT && !rServiceName.compareToAscii(cContentMark)) || - (eType == TOX_INDEX && !rServiceName.compareToAscii(cIdxMark)) || - (eType == TOX_INDEX && !rServiceName.compareToAscii(cIdxMarkAsian)); + vos::OGuard g(Application::GetSolarMutex()); + + return rServiceName.equalsAscii(cBaseMark) + || rServiceName.equalsAscii(cTextContent) + || ((m_pImpl->m_eTOXType == TOX_USER) + && rServiceName.equalsAscii(cUserMark)) + || ((m_pImpl->m_eTOXType == TOX_CONTENT) + && rServiceName.equalsAscii(cContentMark)) + || ((m_pImpl->m_eTOXType == TOX_INDEX) + && rServiceName.equalsAscii(cIdxMark)) + || ((m_pImpl->m_eTOXType == TOX_INDEX) + && rServiceName.equalsAscii(cIdxMarkAsian)); } /* -----------------------------06.04.00 15:07-------------------------------- ---------------------------------------------------------------------------*/ -uno::Sequence< OUString > SwXDocumentIndexMark::getSupportedServiceNames(void) throw( uno::RuntimeException ) +uno::Sequence< OUString > SAL_CALL +SwXDocumentIndexMark::getSupportedServiceNames() throw (uno::RuntimeException) { - INT32 nCnt = (eType == TOX_INDEX) ? 4 : 3; + vos::OGuard g(Application::GetSolarMutex()); + + const sal_Int32 nCnt = (m_pImpl->m_eTOXType == TOX_INDEX) ? 4 : 3; uno::Sequence< OUString > aRet(nCnt); OUString* pArray = aRet.getArray(); pArray[0] = C2U(cBaseMark); pArray[1] = C2U(cTextContent); - switch(eType) + switch (m_pImpl->m_eTOXType) { case TOX_USER: pArray[2] = C2U(cUserMark); @@ -1629,97 +1797,47 @@ uno::Sequence< OUString > SwXDocumentIndexMark::getSupportedServiceNames(void) t } return aRet; } -/*-- 14.12.98 10:25:43--------------------------------------------------- - - -----------------------------------------------------------------------*/ -SwXDocumentIndexMark::SwXDocumentIndexMark(TOXTypes eToxType) : - aLstnrCntnr( (text::XTextContent*)this), - aTypeDepend(this, 0), - m_pDoc(0), - m_pTOXMark(0), - bIsDescriptor(sal_True), - bMainEntry(sal_False), - eType(eToxType), - nLevel(0) -{ - InitMap(eToxType); -} -/*-- 14.12.98 10:25:44--------------------------------------------------- - - -----------------------------------------------------------------------*/ -SwXDocumentIndexMark::SwXDocumentIndexMark(const SwTOXType* pType, - const SwTOXMark* pMark, - SwDoc* pDc) : - aLstnrCntnr( (text::XTextContent*)this), - aTypeDepend(this, (SwTOXType*)pType), - m_pDoc(pDc), - m_pTOXMark(pMark), - bIsDescriptor(sal_False), - bMainEntry(sal_False), - eType(pType->GetType()), - nLevel(0) -{ - m_pDoc->GetUnoCallBack()->Add(this); - InitMap(eType); -} -/*-- 14.12.98 10:25:44--------------------------------------------------- - - -----------------------------------------------------------------------*/ -SwXDocumentIndexMark::~SwXDocumentIndexMark() -{ - -} -/* -----------------21.04.99 09:36------------------- - * - * --------------------------------------------------*/ -void SwXDocumentIndexMark::InitMap(TOXTypes eToxType) -{ - sal_uInt16 nMapId = PROPERTY_MAP_USER_MARK; //case TOX_USER: - switch( eToxType ) - { - case TOX_INDEX: - nMapId = PROPERTY_MAP_INDEX_MARK ; - break; - case TOX_CONTENT: - nMapId = PROPERTY_MAP_CNTIDX_MARK; - break; - //case TOX_USER: - default: - ; - } - m_pPropSet = aSwMapProvider.GetPropertySet(nMapId); -} /*-- 14.12.98 10:25:45--------------------------------------------------- -----------------------------------------------------------------------*/ -OUString SwXDocumentIndexMark::getMarkEntry(void) throw( uno::RuntimeException ) +OUString SAL_CALL +SwXDocumentIndexMark::getMarkEntry() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwTOXType* pType = ((SwXDocumentIndexMark*)this)->GetTOXType(); + OUString sRet; - if(pType && m_pTOXMark) + SwTOXType *const pType = m_pImpl->GetTOXType(); + if (pType && m_pImpl->m_pTOXMark) { - sRet = OUString(m_pTOXMark->GetAlternativeText()); + sRet = OUString(m_pImpl->m_pTOXMark->GetAlternativeText()); + } + else if (m_pImpl->m_bIsDescriptor) + { + sRet = m_pImpl->m_sAltText; } - else if(bIsDescriptor) - sRet = sAltText; else + { throw uno::RuntimeException(); + } return sRet; } /*-- 14.12.98 10:25:45--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXDocumentIndexMark::setMarkEntry(const OUString& rIndexEntry) throw( uno::RuntimeException ) +void SAL_CALL +SwXDocumentIndexMark::setMarkEntry(const OUString& rIndexEntry) +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwTOXType* pType = ((SwXDocumentIndexMark*)this)->GetTOXType(); - if(pType && m_pTOXMark) + + SwTOXType *const pType = m_pImpl->GetTOXType(); + if (pType && m_pImpl->m_pTOXMark) { - SwTOXMark aMark(*m_pTOXMark); + SwTOXMark aMark(*m_pImpl->m_pTOXMark); aMark.SetAlternativeText(rIndexEntry); - const SwTxtTOXMark* pTxtMark = m_pTOXMark->GetTxtTOXMark(); + SwTxtTOXMark const*const pTxtMark = + m_pImpl->m_pTOXMark->GetTxtTOXMark(); SwPaM aPam(pTxtMark->GetTxtNode(), *pTxtMark->GetStart()); aPam.SetMark(); if(pTxtMark->GetEnd()) @@ -1729,9 +1847,9 @@ void SwXDocumentIndexMark::setMarkEntry(const OUString& rIndexEntry) throw( uno: else aPam.GetPoint()->nContent++; - //die alte Marke loeschen - m_pDoc->DeleteTOXMark(m_pTOXMark); - m_pTOXMark = 0; + // delete old mark + m_pImpl->m_pDoc->DeleteTOXMark(m_pImpl->m_pTOXMark); + m_pImpl->m_pTOXMark = 0; SwTxtAttr* pTxtAttr = 0; sal_Bool bInsAtPos = aMark.IsAlternativeText(); @@ -1740,311 +1858,377 @@ void SwXDocumentIndexMark::setMarkEntry(const OUString& rIndexEntry) throw( uno: if( bInsAtPos ) { SwPaM aTmp( *pStt ); - m_pDoc->InsertPoolItem( aTmp, aMark, 0 ); + m_pImpl->m_pDoc->InsertPoolItem( aTmp, aMark, 0 ); pTxtAttr = pStt->nNode.GetNode().GetTxtNode()->GetTxtAttrForCharAt( pStt->nContent.GetIndex()-1, RES_TXTATR_TOXMARK); } else if( *pEnd != *pStt ) { - m_pDoc->InsertPoolItem( aPam, aMark, + m_pImpl->m_pDoc->InsertPoolItem( aPam, aMark, nsSetAttrMode::SETATTR_DONTEXPAND ); pTxtAttr = pStt->nNode.GetNode().GetTxtNode()->GetTxtAttr( pStt->nContent, RES_TXTATR_TOXMARK); } - //und sonst - Marke geloescht? if(pTxtAttr) - m_pTOXMark = &pTxtAttr->GetTOXMark(); + { + m_pImpl->m_pTOXMark = &pTxtAttr->GetTOXMark(); + } } - else if(bIsDescriptor) + else if (m_pImpl->m_bIsDescriptor) { - sAltText = rIndexEntry; + m_pImpl->m_sAltText = rIndexEntry; } else + { throw uno::RuntimeException(); + } } + /* -----------------18.02.99 13:40------------------- * * --------------------------------------------------*/ -void SwXDocumentIndexMark::attachToRange(const uno::Reference< text::XTextRange > & xTextRange) - throw( lang::IllegalArgumentException, uno::RuntimeException ) +void SAL_CALL +SwXDocumentIndexMark::attach( + const uno::Reference< text::XTextRange > & xTextRange) +throw (lang::IllegalArgumentException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(!bIsDescriptor) - throw uno::RuntimeException(); - uno::Reference xRangeTunnel( xTextRange, uno::UNO_QUERY); - SwXTextRange* pRange = 0; - OTextCursorHelper* pCursor = 0; - if(xRangeTunnel.is()) + if (!m_pImpl->m_bIsDescriptor) { - pRange = reinterpret_cast< SwXTextRange * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXTextRange::getUnoTunnelId()) )); - pCursor = reinterpret_cast< OTextCursorHelper * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( OTextCursorHelper::getUnoTunnelId()) )); + throw uno::RuntimeException(); } - SwDoc* pDoc = pRange ? (SwDoc*)pRange->GetDoc() : pCursor ? (SwDoc*)pCursor->GetDoc() : 0; + const uno::Reference xRangeTunnel(xTextRange, uno::UNO_QUERY); + SwXTextRange *const pRange = + ::sw::UnoTunnelGetImplementation(xRangeTunnel); + OTextCursorHelper *const pCursor = + ::sw::UnoTunnelGetImplementation(xRangeTunnel); + SwDoc *const pDoc = + (pRange) ? pRange->GetDoc() : ((pCursor) ? pCursor->GetDoc() : 0); + if (!pDoc) + { + throw lang::IllegalArgumentException(); + } - if(pDoc ) + const SwTOXType* pTOXType = 0; + switch (m_pImpl->m_eTOXType) { - const SwTOXType* pTOXType = 0; - switch(eType) + case TOX_INDEX: + case TOX_CONTENT: + pTOXType = pDoc->GetTOXType( m_pImpl->m_eTOXType, 0 ); + break; + case TOX_USER: { - case TOX_INDEX: - case TOX_CONTENT: - pTOXType = pDoc->GetTOXType( eType, 0 ); - break; - case TOX_USER: + if (!m_pImpl->m_sUserIndexName.getLength()) { - if(!sUserIndexName.Len()) - pTOXType = pDoc->GetTOXType( eType, 0 ); - else + pTOXType = pDoc->GetTOXType( m_pImpl->m_eTOXType, 0 ); + } + else + { + const sal_uInt16 nCount = + pDoc->GetTOXTypeCount(m_pImpl->m_eTOXType); + for (sal_uInt16 i = 0; i < nCount; i++) { - sal_uInt16 nCount = pDoc->GetTOXTypeCount( eType); - for(sal_uInt16 i = 0; i < nCount; i++) + SwTOXType const*const pTemp = + pDoc->GetTOXType( m_pImpl->m_eTOXType, i ); + if (m_pImpl->m_sUserIndexName == + OUString(pTemp->GetTypeName())) { - const SwTOXType* pTemp = pDoc->GetTOXType( eType, i ); - if(sUserIndexName == pTemp->GetTypeName()) - { - pTOXType = pTemp; - break; - } - } - if(!pTOXType) - { - SwTOXType aUserType(TOX_USER, sUserIndexName); - pTOXType = pDoc->InsertTOXType(aUserType); + pTOXType = pTemp; + break; } } + if (!pTOXType) + { + SwTOXType aUserType(TOX_USER, m_pImpl->m_sUserIndexName); + pTOXType = pDoc->InsertTOXType(aUserType); + } } - break; - - default: - ; } - if(!pTOXType) - throw lang::IllegalArgumentException(); - pDoc->GetUnoCallBack()->Add(this); - ((SwTOXType*)pTOXType)->Add(&aTypeDepend); - - SwUnoInternalPaM aPam(*pDoc); - //das muss jetzt sal_True liefern - ::sw::XTextRangeToSwPaM(aPam, xTextRange); - SwTOXMark aMark (pTOXType); - if(sAltText.Len()) - aMark.SetAlternativeText(sAltText); - switch(eType) - { - case TOX_INDEX: - if(sPrimaryKey.Len()) - aMark.SetPrimaryKey(sPrimaryKey); - if(sSecondaryKey.Len()) - aMark.SetSecondaryKey(sSecondaryKey); - if(sTextReading.Len()) - aMark.SetTextReading(sTextReading); - if(sPrimaryKeyReading.Len()) - aMark.SetPrimaryKeyReading(sPrimaryKeyReading); - if(sSecondaryKeyReading.Len()) - aMark.SetSecondaryKeyReading(sSecondaryKeyReading); - aMark.SetMainEntry(bMainEntry); - break; - case TOX_USER: - case TOX_CONTENT: - if(USHRT_MAX != nLevel) - aMark.SetLevel(nLevel+1); - break; + break; - default: - ; - } - UnoActionContext aAction(pDoc); - sal_Bool bMark = *aPam.GetPoint() != *aPam.GetMark(); - // Marks ohne Alternativtext ohne selektierten Text koennen nicht eingefuegt werden, - // deshalb hier ein Leerzeichen - ob das die ideale Loesung ist? - if(!bMark && !aMark.GetAlternativeText().Len()) - aMark.SetAlternativeText( String(' ') ); - - SwXTextCursor const*const pTextCursor( - dynamic_cast(pCursor)); - const bool bForceExpandHints( (!bMark && pTextCursor) - ? pTextCursor->IsAtEndOfMeta() : false ); - const SetAttrMode nInsertFlags = (bForceExpandHints) - ? ( nsSetAttrMode::SETATTR_FORCEHINTEXPAND - | nsSetAttrMode::SETATTR_DONTEXPAND) - : nsSetAttrMode::SETATTR_DONTEXPAND; - - pDoc->InsertPoolItem(aPam, aMark, nInsertFlags); - if( bMark && *aPam.GetPoint() > *aPam.GetMark()) - aPam.Exchange(); + default: + break; + } + if (!pTOXType) + { + throw lang::IllegalArgumentException(); + } + pDoc->GetUnoCallBack()->Add(m_pImpl.get()); + const_cast(pTOXType)->Add(&m_pImpl->m_TypeDepend); - SwTxtAttr* pTxtAttr = 0; - if( bMark ) - pTxtAttr = aPam.GetNode()->GetTxtNode()->GetTxtAttr( - aPam.GetPoint()->nContent, RES_TXTATR_TOXMARK ); - else - { - pTxtAttr = aPam.GetNode()->GetTxtNode()->GetTxtAttrForCharAt( - aPam.GetPoint()->nContent.GetIndex()-1, RES_TXTATR_TOXMARK ); - } + SwUnoInternalPaM aPam(*pDoc); + //das muss jetzt sal_True liefern + ::sw::XTextRangeToSwPaM(aPam, xTextRange); + SwTOXMark aMark (pTOXType); + if (m_pImpl->m_sAltText.getLength()) + { + aMark.SetAlternativeText(m_pImpl->m_sAltText); + } + switch (m_pImpl->m_eTOXType) + { + case TOX_INDEX: + if (m_pImpl->m_sPrimaryKey.getLength()) + { + aMark.SetPrimaryKey(m_pImpl->m_sPrimaryKey); + } + if (m_pImpl->m_sSecondaryKey.getLength()) + { + aMark.SetSecondaryKey(m_pImpl->m_sSecondaryKey); + } + if (m_pImpl->m_sTextReading.getLength()) + { + aMark.SetTextReading(m_pImpl->m_sTextReading); + } + if (m_pImpl->m_sPrimaryKeyReading.getLength()) + { + aMark.SetPrimaryKeyReading(m_pImpl->m_sPrimaryKeyReading); + } + if (m_pImpl->m_sSecondaryKeyReading.getLength()) + { + aMark.SetSecondaryKeyReading(m_pImpl->m_sSecondaryKeyReading); + } + aMark.SetMainEntry(m_pImpl->m_bMainEntry); + break; + case TOX_USER: + case TOX_CONTENT: + if (USHRT_MAX != m_pImpl->m_nLevel) + { + aMark.SetLevel(m_pImpl->m_nLevel+1); + } + break; - if(pTxtAttr) - { - m_pTOXMark = &pTxtAttr->GetTOXMark(); - m_pDoc = pDoc; - bIsDescriptor = sal_False; - } - else - throw uno::RuntimeException(); + default: + break; + } + UnoActionContext aAction(pDoc); + const sal_Bool bMark = *aPam.GetPoint() != *aPam.GetMark(); + // Marks ohne Alternativtext ohne selektierten Text koennen nicht eingefuegt werden, + // deshalb hier ein Leerzeichen - ob das die ideale Loesung ist? + if (!bMark && !aMark.GetAlternativeText().Len()) + { + aMark.SetAlternativeText( String(' ') ); } -} -/*-- 14.12.98 10:25:45--------------------------------------------------- - -----------------------------------------------------------------------*/ -void SwXDocumentIndexMark::attach(const uno::Reference< text::XTextRange > & xTextRange) - throw( lang::IllegalArgumentException, uno::RuntimeException ) -{ - vos::OGuard aGuard(Application::GetSolarMutex()); - attachToRange( xTextRange ); + SwXTextCursor const*const pTextCursor( + dynamic_cast(pCursor)); + const bool bForceExpandHints( (!bMark && pTextCursor) + ? pTextCursor->IsAtEndOfMeta() : false ); + const SetAttrMode nInsertFlags = (bForceExpandHints) + ? ( nsSetAttrMode::SETATTR_FORCEHINTEXPAND + | nsSetAttrMode::SETATTR_DONTEXPAND) + : nsSetAttrMode::SETATTR_DONTEXPAND; + + pDoc->InsertPoolItem(aPam, aMark, nInsertFlags); + if (bMark && *aPam.GetPoint() > *aPam.GetMark()) + { + aPam.Exchange(); + } + + SwTxtAttr* pTxtAttr = 0; + if (bMark) + { + pTxtAttr = aPam.GetNode()->GetTxtNode()->GetTxtAttr( + aPam.GetPoint()->nContent, RES_TXTATR_TOXMARK ); + } + else + { + pTxtAttr = aPam.GetNode()->GetTxtNode()->GetTxtAttrForCharAt( + aPam.GetPoint()->nContent.GetIndex()-1, RES_TXTATR_TOXMARK ); + } + + if (!pTxtAttr) + { + throw uno::RuntimeException(); + } + + m_pImpl->m_pTOXMark = &pTxtAttr->GetTOXMark(); + m_pImpl->m_pDoc = pDoc; + m_pImpl->m_bIsDescriptor = sal_False; } + /*-- 14.12.98 10:25:45--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextRange > SwXDocumentIndexMark::getAnchor(void) throw( uno::RuntimeException ) +uno::Reference< text::XTextRange > SAL_CALL +SwXDocumentIndexMark::getAnchor() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< text::XTextRange > aRet; - SwTOXType* pType = ((SwXDocumentIndexMark*)this)->GetTOXType(); - if(pType && m_pTOXMark) + + SwTOXType *const pType = m_pImpl->GetTOXType(); + if (!pType || !m_pImpl->m_pTOXMark) { - if( m_pTOXMark->GetTxtTOXMark() ) - { - const SwTxtTOXMark* pTxtMark = m_pTOXMark->GetTxtTOXMark(); - SwPaM aPam(pTxtMark->GetTxtNode(), *pTxtMark->GetStart()); - aPam.SetMark(); - if(pTxtMark->GetEnd()) - { - aPam.GetPoint()->nContent = *pTxtMark->GetEnd(); - } - else - aPam.GetPoint()->nContent++; - uno::Reference< frame::XModel > xModel = m_pDoc->GetDocShell()->GetBaseModel(); - uno::Reference< text::XTextDocument > xTDoc(xModel, uno::UNO_QUERY); - aRet = new SwXTextRange(aPam, xTDoc->getText()); - } + throw uno::RuntimeException(); } - if(!aRet.is()) + if (!m_pImpl->m_pTOXMark->GetTxtTOXMark()) + { throw uno::RuntimeException(); - return aRet; + } + const SwTxtTOXMark* pTxtMark = m_pImpl->m_pTOXMark->GetTxtTOXMark(); + SwPaM aPam(pTxtMark->GetTxtNode(), *pTxtMark->GetStart()); + aPam.SetMark(); + if(pTxtMark->GetEnd()) + { + aPam.GetPoint()->nContent = *pTxtMark->GetEnd(); + } + else + { + aPam.GetPoint()->nContent++; + } + const uno::Reference< frame::XModel > xModel = + m_pImpl->m_pDoc->GetDocShell()->GetBaseModel(); + const uno::Reference< text::XTextDocument > xTDoc(xModel, uno::UNO_QUERY); + const uno::Reference< text::XTextRange > xRet = + new SwXTextRange(aPam, xTDoc->getText()); + + return xRet; } + /*-- 14.12.98 10:25:45--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXDocumentIndexMark::dispose(void) throw( uno::RuntimeException ) +void SAL_CALL +SwXDocumentIndexMark::dispose() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwTOXType* pType = ((SwXDocumentIndexMark*)this)->GetTOXType(); - if(pType && m_pTOXMark) + + SwTOXType *const pType = m_pImpl->GetTOXType(); + if (pType && m_pImpl->m_pTOXMark) { - m_pDoc->DeleteTOXMark(m_pTOXMark); + m_pImpl->m_pDoc->DeleteTOXMark(m_pImpl->m_pTOXMark); } - else - throw uno::RuntimeException(); } /*-- 14.12.98 10:25:45--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXDocumentIndexMark::addEventListener(const uno::Reference< lang::XEventListener > & aListener) - throw( uno::RuntimeException ) +void SAL_CALL +SwXDocumentIndexMark::addEventListener( + const uno::Reference< lang::XEventListener > & xListener) +throw (uno::RuntimeException) { - if(!GetRegisteredIn()) + vos::OGuard g(Application::GetSolarMutex()); + + if (!m_pImpl->GetRegisteredIn()) + { throw uno::RuntimeException(); - aLstnrCntnr.AddListener(aListener); + } + m_pImpl->m_ListenerContainer.AddListener(xListener); } /*-- 14.12.98 10:25:46--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXDocumentIndexMark::removeEventListener(const uno::Reference< lang::XEventListener > & aListener) - throw( uno::RuntimeException ) +void SAL_CALL +SwXDocumentIndexMark::removeEventListener( + const uno::Reference< lang::XEventListener > & xListener) +throw (uno::RuntimeException) { - if(!GetRegisteredIn() || !aLstnrCntnr.RemoveListener(aListener)) + vos::OGuard g(Application::GetSolarMutex()); + + if (!m_pImpl->GetRegisteredIn() || + !m_pImpl->m_ListenerContainer.RemoveListener(xListener)) + { throw uno::RuntimeException(); + } } + /*-- 14.12.98 10:25:46--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< beans::XPropertySetInfo > SwXDocumentIndexMark::getPropertySetInfo(void) - throw( uno::RuntimeException ) +uno::Reference< beans::XPropertySetInfo > SAL_CALL +SwXDocumentIndexMark::getPropertySetInfo() throw (uno::RuntimeException) { + vos::OGuard g(Application::GetSolarMutex()); + static uno::Reference< beans::XPropertySetInfo > xInfos[3]; int nPos = 0; - switch(eType) + switch (m_pImpl->m_eTOXType) { - case TOX_INDEX: nPos = 0; break; - case TOX_CONTENT: nPos = 1; break; - case TOX_USER: nPos = 2; break; + case TOX_INDEX: nPos = 0; break; + case TOX_CONTENT: nPos = 1; break; + case TOX_USER: nPos = 2; break; default: ; } if(!xInfos[nPos].is()) { - uno::Reference< beans::XPropertySetInfo > xInfo = m_pPropSet->getPropertySetInfo(); + const uno::Reference< beans::XPropertySetInfo > xInfo = + m_pImpl->m_rPropSet.getPropertySetInfo(); // extend PropertySetInfo! const uno::Sequence aPropSeq = xInfo->getProperties(); xInfos[nPos] = new SfxExtItemPropertySetInfo( - aSwMapProvider.GetPropertyMapEntries(PROPERTY_MAP_PARAGRAPH_EXTENSIONS), + aSwMapProvider.GetPropertyMapEntries( + PROPERTY_MAP_PARAGRAPH_EXTENSIONS), aPropSeq ); } return xInfos[nPos]; } + /*-- 14.12.98 10:25:46--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXDocumentIndexMark::setPropertyValue(const OUString& rPropertyName, - const uno::Any& aValue) - throw( beans::UnknownPropertyException, beans::PropertyVetoException, - lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException ) +void SAL_CALL +SwXDocumentIndexMark::setPropertyValue( + const OUString& rPropertyName, const uno::Any& rValue) +throw (beans::UnknownPropertyException, beans::PropertyVetoException, + lang::IllegalArgumentException, lang::WrappedTargetException, + uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwTOXType* pType = ((SwXDocumentIndexMark*)this)->GetTOXType(); - const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName(rPropertyName); + + SfxItemPropertySimpleEntry const*const pEntry = + m_pImpl->m_rPropSet.getPropertyMap()->getByName(rPropertyName); if (!pEntry) - throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); - if ( pEntry->nFlags & beans::PropertyAttribute::READONLY) - throw beans::PropertyVetoException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); - if(pType && m_pTOXMark) { - SwDoc* pLocalDoc = m_pDoc; + throw beans::UnknownPropertyException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) + + rPropertyName, + static_cast(this)); + } + if (pEntry->nFlags & beans::PropertyAttribute::READONLY) + { + throw beans::PropertyVetoException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Property is read-only: ")) + + rPropertyName, + static_cast(this)); + } + + SwTOXType *const pType = m_pImpl->GetTOXType(); + if (pType && m_pImpl->m_pTOXMark) + { + SwDoc* pLocalDoc = m_pImpl->m_pDoc; - SwTOXMark aMark(*m_pTOXMark); + SwTOXMark aMark(*m_pImpl->m_pTOXMark); switch(pEntry->nWID) { case WID_ALT_TEXT: - aMark.SetAlternativeText(lcl_AnyToString(aValue)); + aMark.SetAlternativeText(lcl_AnyToString(rValue)); break; case WID_LEVEL: - aMark.SetLevel(Min( (sal_Int8) ( MAXLEVEL ), - (sal_Int8)(lcl_AnyToInt16(aValue)+1))); + aMark.SetLevel(Min( static_cast( MAXLEVEL ), + static_cast(lcl_AnyToInt16(rValue)+1))); break; case WID_PRIMARY_KEY : - aMark.SetPrimaryKey(lcl_AnyToString(aValue)); + aMark.SetPrimaryKey(lcl_AnyToString(rValue)); break; case WID_SECONDARY_KEY: - aMark.SetSecondaryKey(lcl_AnyToString(aValue)); + aMark.SetSecondaryKey(lcl_AnyToString(rValue)); break; case WID_MAIN_ENTRY: - aMark.SetMainEntry(lcl_AnyToBool(aValue)); + aMark.SetMainEntry(lcl_AnyToBool(rValue)); break; case WID_TEXT_READING: - aMark.SetTextReading(lcl_AnyToString(aValue)); + aMark.SetTextReading(lcl_AnyToString(rValue)); break; case WID_PRIMARY_KEY_READING: - aMark.SetPrimaryKeyReading(lcl_AnyToString(aValue)); + aMark.SetPrimaryKeyReading(lcl_AnyToString(rValue)); break; case WID_SECONDARY_KEY_READING: - aMark.SetSecondaryKeyReading(lcl_AnyToString(aValue)); + aMark.SetSecondaryKeyReading(lcl_AnyToString(rValue)); break; } - const SwTxtTOXMark* pTxtMark = m_pTOXMark->GetTxtTOXMark(); + SwTxtTOXMark const*const pTxtMark = + m_pImpl->m_pTOXMark->GetTxtTOXMark(); SwPaM aPam(pTxtMark->GetTxtNode(), *pTxtMark->GetStart()); aPam.SetMark(); if(pTxtMark->GetEnd()) @@ -2052,15 +2236,17 @@ void SwXDocumentIndexMark::setPropertyValue(const OUString& rPropertyName, aPam.GetPoint()->nContent = *pTxtMark->GetEnd(); } else + { aPam.GetPoint()->nContent++; + } //delete the old mark - pLocalDoc->DeleteTOXMark(m_pTOXMark); - m_pTOXMark = 0; + pLocalDoc->DeleteTOXMark(m_pImpl->m_pTOXMark); + m_pImpl->m_pTOXMark = 0; sal_Bool bInsAtPos = aMark.IsAlternativeText(); - const SwPosition *pStt = aPam.Start(), - *pEnd = aPam.End(); + const SwPosition *pStt = aPam.Start(); + const SwPosition *pEnd = aPam.End(); SwTxtAttr* pTxtAttr = 0; if( bInsAtPos ) @@ -2077,101 +2263,120 @@ void SwXDocumentIndexMark::setPropertyValue(const OUString& rPropertyName, pTxtAttr = pStt->nNode.GetNode().GetTxtNode()->GetTxtAttr( pStt->nContent, RES_TXTATR_TOXMARK ); } - m_pDoc = pLocalDoc; + m_pImpl->m_pDoc = pLocalDoc; if(pTxtAttr) { - m_pTOXMark = &pTxtAttr->GetTOXMark(); - m_pDoc->GetUnoCallBack()->Add(this); - pType->Add(&aTypeDepend); + m_pImpl->m_pTOXMark = &pTxtAttr->GetTOXMark(); + m_pImpl->m_pDoc->GetUnoCallBack()->Add(m_pImpl.get()); + pType->Add(&m_pImpl->m_TypeDepend); } } - else if(bIsDescriptor) + else if (m_pImpl->m_bIsDescriptor) { switch(pEntry->nWID) { case WID_ALT_TEXT: - sAltText = lcl_AnyToString(aValue); + m_pImpl->m_sAltText = lcl_AnyToString(rValue); break; case WID_LEVEL: { - sal_Int16 nVal = lcl_AnyToInt16(aValue); + const sal_Int16 nVal = lcl_AnyToInt16(rValue); if(nVal >= 0 && nVal < MAXLEVEL) - nLevel = nVal; + { + m_pImpl->m_nLevel = nVal; + } else + { throw lang::IllegalArgumentException(); + } } break; - case WID_PRIMARY_KEY : - sPrimaryKey = lcl_AnyToString(aValue); + case WID_PRIMARY_KEY: + m_pImpl->m_sPrimaryKey = lcl_AnyToString(rValue); break; case WID_SECONDARY_KEY: - sSecondaryKey = lcl_AnyToString(aValue); + m_pImpl->m_sSecondaryKey = lcl_AnyToString(rValue); break; case WID_TEXT_READING: - sTextReading = lcl_AnyToString(aValue); + m_pImpl->m_sTextReading = lcl_AnyToString(rValue); break; case WID_PRIMARY_KEY_READING: - sPrimaryKeyReading = lcl_AnyToString(aValue); + m_pImpl->m_sPrimaryKeyReading = lcl_AnyToString(rValue); break; case WID_SECONDARY_KEY_READING: - sSecondaryKeyReading = lcl_AnyToString(aValue); + m_pImpl->m_sSecondaryKeyReading = lcl_AnyToString(rValue); break; - case WID_USER_IDX_NAME : + case WID_USER_IDX_NAME: { - OUString sTmp(lcl_AnyToString(aValue)); + OUString sTmp(lcl_AnyToString(rValue)); lcl_ConvertTOUNameToUserName(sTmp); - sUserIndexName = sTmp; + m_pImpl->m_sUserIndexName = sTmp; } break; case WID_MAIN_ENTRY: - bMainEntry = lcl_AnyToBool(aValue); + m_pImpl->m_bMainEntry = lcl_AnyToBool(rValue); break; } } else + { throw uno::RuntimeException(); + } } + /*-- 14.12.98 10:25:46--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Any SwXDocumentIndexMark::getPropertyValue(const OUString& rPropertyName) - throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +uno::Any SAL_CALL +SwXDocumentIndexMark::getPropertyValue(const OUString& rPropertyName) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + uno::Any aRet; - SwTOXType* pType = ((SwXDocumentIndexMark*)this)->GetTOXType(); - const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName(rPropertyName); + SfxItemPropertySimpleEntry const*const pEntry = + m_pImpl->m_rPropSet.getPropertyMap()->getByName(rPropertyName); if (!pEntry) - throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); + { + throw beans::UnknownPropertyException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) + + rPropertyName, + static_cast(this)); + } if (::sw::GetDefaultTextContentValue(aRet, rPropertyName, pEntry->nWID)) { return aRet; } - if(pType && m_pTOXMark) + + SwTOXType *const pType = m_pImpl->GetTOXType(); + if (pType && m_pImpl->m_pTOXMark) { switch(pEntry->nWID) { case WID_ALT_TEXT: - aRet <<= OUString(m_pTOXMark->GetAlternativeText()); + aRet <<= OUString(m_pImpl->m_pTOXMark->GetAlternativeText()); break; case WID_LEVEL: - aRet <<= (sal_Int16)(m_pTOXMark->GetLevel() - 1); + aRet <<= static_cast( + m_pImpl->m_pTOXMark->GetLevel() - 1); break; case WID_PRIMARY_KEY : - aRet <<= OUString(m_pTOXMark->GetPrimaryKey()); + aRet <<= OUString(m_pImpl->m_pTOXMark->GetPrimaryKey()); break; case WID_SECONDARY_KEY: - aRet <<= OUString(m_pTOXMark->GetSecondaryKey()); + aRet <<= OUString(m_pImpl->m_pTOXMark->GetSecondaryKey()); break; case WID_TEXT_READING: - aRet <<= OUString(m_pTOXMark->GetTextReading()); + aRet <<= OUString(m_pImpl->m_pTOXMark->GetTextReading()); break; case WID_PRIMARY_KEY_READING: - aRet <<= OUString(m_pTOXMark->GetPrimaryKeyReading()); + aRet <<= OUString(m_pImpl->m_pTOXMark->GetPrimaryKeyReading()); break; case WID_SECONDARY_KEY_READING: - aRet <<= OUString(m_pTOXMark->GetSecondaryKeyReading()); + aRet <<= OUString( + m_pImpl->m_pTOXMark->GetSecondaryKeyReading()); break; case WID_USER_IDX_NAME : { @@ -2182,136 +2387,101 @@ uno::Any SwXDocumentIndexMark::getPropertyValue(const OUString& rPropertyName) break; case WID_MAIN_ENTRY: { - sal_Bool bTemp = m_pTOXMark->IsMainEntry(); - aRet.setValue(&bTemp, ::getBooleanCppuType()); + const sal_Bool bTemp = m_pImpl->m_pTOXMark->IsMainEntry(); + aRet <<= bTemp; } break; } } - else if(bIsDescriptor) + else if (m_pImpl->m_bIsDescriptor) { switch(pEntry->nWID) { case WID_ALT_TEXT: - aRet <<= OUString(sAltText); + aRet <<= m_pImpl->m_sAltText; break; case WID_LEVEL: - aRet <<= (sal_Int16)nLevel; + aRet <<= static_cast(m_pImpl->m_nLevel); break; - case WID_PRIMARY_KEY : - aRet <<= OUString(sPrimaryKey); + case WID_PRIMARY_KEY: + aRet <<= m_pImpl->m_sPrimaryKey; break; case WID_SECONDARY_KEY: - aRet <<= OUString(sSecondaryKey); + aRet <<= m_pImpl->m_sSecondaryKey; break; case WID_TEXT_READING: - aRet <<= OUString(sTextReading); + aRet <<= m_pImpl->m_sTextReading; break; case WID_PRIMARY_KEY_READING: - aRet <<= OUString(sPrimaryKeyReading); + aRet <<= m_pImpl->m_sPrimaryKeyReading; break; case WID_SECONDARY_KEY_READING: - aRet <<= OUString(sSecondaryKeyReading); + aRet <<= m_pImpl->m_sSecondaryKeyReading; break; case WID_USER_IDX_NAME : - aRet <<= OUString(sUserIndexName); + aRet <<= m_pImpl->m_sUserIndexName; break; case WID_MAIN_ENTRY: { - aRet.setValue(&bMainEntry, ::getBooleanCppuType()); + aRet <<= static_cast(m_pImpl->m_bMainEntry); } break; } } else + { throw uno::RuntimeException(); + } return aRet; } -/*-- 14.12.98 10:25:46--------------------------------------------------- - -----------------------------------------------------------------------*/ -void SwXDocumentIndexMark::addPropertyChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) -{ - DBG_WARNING("not implemented"); -} /*-- 14.12.98 10:25:46--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXDocumentIndexMark::removePropertyChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) -{ - DBG_WARNING("not implemented"); -} -/*-- 14.12.98 10:25:47--------------------------------------------------- - - -----------------------------------------------------------------------*/ -void SwXDocumentIndexMark::addVetoableChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +void SAL_CALL +SwXDocumentIndexMark::addPropertyChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - DBG_WARNING("not implemented"); + OSL_ENSURE(false, + "SwXDocumentIndexMark::addPropertyChangeListener(): not implemented"); } -/*-- 14.12.98 10:25:47--------------------------------------------------- - -----------------------------------------------------------------------*/ -void SwXDocumentIndexMark::removeVetoableChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +void SAL_CALL +SwXDocumentIndexMark::removePropertyChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - DBG_WARNING("not implemented"); + OSL_ENSURE(false, + "SwXDocumentIndexMark::removePropertyChangeListener(): not implemented"); } -/*-- 14.12.98 10:25:47--------------------------------------------------- - -----------------------------------------------------------------------*/ -SwXDocumentIndexMark* SwXDocumentIndexMark::GetObject(SwTOXType* pType, - const SwTOXMark* pMark, SwDoc* pDoc) +void SAL_CALL +SwXDocumentIndexMark::addVetoableChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - SwClientIter aIter(*pType); - SwXDocumentIndexMark* pxMark = (SwXDocumentIndexMark*) - aIter.First(TYPE(SwXDocumentIndexMark)); - while( pxMark ) - { - if(pxMark->m_pTOXMark == pMark) - return pxMark; - pxMark = (SwXDocumentIndexMark*)aIter.Next(); - } - return new SwXDocumentIndexMark(pType, pMark, pDoc); + OSL_ENSURE(false, + "SwXDocumentIndexMark::addVetoableChangeListener(): not implemented"); } -/*-- 14.12.98 10:25:47--------------------------------------------------- - -----------------------------------------------------------------------*/ -void SwXDocumentIndexMark::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew) +void SAL_CALL +SwXDocumentIndexMark::removeVetoableChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - switch( pOld ? pOld->Which() : 0 ) - { - case RES_REMOVE_UNO_OBJECT: - case RES_OBJECTDYING: - if( (void*)GetRegisteredIn() == ((SwPtrMsgPoolItem *)pOld)->pObject ) - Invalidate(); - break; - - case RES_FMT_CHG: - // wurden wir an das neue umgehaengt und wird das alte geloscht? - if( ((SwFmtChg*)pNew)->pChangedFmt == GetRegisteredIn() && - ((SwFmtChg*)pOld)->pChangedFmt->IsFmtInDTOR() ) - Invalidate(); - break; - case RES_TOXMARK_DELETED: - if( (void*)m_pTOXMark == ((SwPtrMsgPoolItem *)pOld)->pObject ) - Invalidate(); - break; - } + OSL_ENSURE(false, + "SwXDocumentIndexMark::removeVetoableChangeListener(): not implemented"); } -/* -----------------------------16.10.00 11:24-------------------------------- - ---------------------------------------------------------------------------*/ -void SwXDocumentIndexMark::Invalidate() -{ - if(GetRegisteredIn()) - { - ((SwModify*)GetRegisteredIn())->Remove(this); - if(aTypeDepend.GetRegisteredIn()) - ((SwModify*)aTypeDepend.GetRegisteredIn())->Remove(&aTypeDepend); - aLstnrCntnr.Disposing(); - m_pTOXMark = 0; - m_pDoc = 0; - } -} /****************************************************************** * SwXDocumentIndexes diff --git a/sw/source/core/unocore/unoportenum.cxx b/sw/source/core/unocore/unoportenum.cxx index e780e95c361e..6e29ff314cf8 100644 --- a/sw/source/core/unocore/unoportenum.cxx +++ b/sw/source/core/unocore/unoportenum.cxx @@ -481,8 +481,9 @@ lcl_CreateTOXMarkPortion( ->GetTOXMark(rTOXMark); if (!xContent.is()) { - xContent = new SwXDocumentIndexMark(rTOXMark.GetTOXType(), - &rTOXMark, pDoc); + xContent.set( SwXDocumentIndexMark::CreateXDocumentIndexMark(*pDoc, + *const_cast(rTOXMark.GetTOXType()), rTOXMark), + uno::UNO_QUERY); } SwXTextPortion* pPortion = 0; -- cgit From 82aba30102fe1cce3f6582bfbe29bacb7498363d Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 8 Jan 2010 17:13:59 +0100 Subject: swunolocking1: #i105557#: remove class SwUnoCallBack. everything SwUnoCallBack class does has unfixable race conditions. in SwDoc, the uno callback is now a plain SwModify. --- sw/inc/doc.hxx | 3 +- sw/source/core/doc/docnew.cxx | 3 +- sw/source/core/inc/unoclbck.hxx | 52 --------------------- sw/source/core/unocore/makefile.mk | 1 - sw/source/core/unocore/unoclbck.cxx | 85 ---------------------------------- sw/source/core/unocore/unocoll.cxx | 1 - sw/source/core/unocore/unoobj.cxx | 1 - sw/source/core/unocore/unoobj2.cxx | 1 - sw/source/core/unocore/unoportenum.cxx | 16 ++----- 9 files changed, 6 insertions(+), 157 deletions(-) delete mode 100644 sw/source/core/inc/unoclbck.hxx delete mode 100644 sw/source/core/unocore/unoclbck.cxx (limited to 'sw') diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index de82d9056ff9..0066b37b4575 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -199,7 +199,6 @@ class SwLayouter; class SdrView; class SdrMarkList; class SwAuthEntry; -class SwUnoCallBack; class SwLayoutCache; class IStyleAccess; struct SwCallMouseEvent; @@ -391,7 +390,7 @@ class SW_DLLPUBLIC SwDoc : SwLayoutCache *pLayoutCache; // Layout cache to read and save with the // document for a faster formatting - SwUnoCallBack *pUnoCallBack; + SwModify *pUnoCallBack; IGrammarContact *mpGrammarContact; // for grammar checking in paragraphs during editing mutable comphelper::ImplementationReference< SwChartDataProvider diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx index 71c42cf27176..7b333ad1f960 100644 --- a/sw/source/core/doc/docnew.cxx +++ b/sw/source/core/doc/docnew.cxx @@ -90,7 +90,6 @@ #include #include #include -#include #include #include #include @@ -259,7 +258,7 @@ SwDoc::SwDoc() : pStyleAccess( 0 ), // <-- pLayoutCache( 0 ), - pUnoCallBack(new SwUnoCallBack(0)), + pUnoCallBack(new SwModify(0)), mpGrammarContact( 0 ), aChartDataProviderImplRef(), pChartControllerHelper( 0 ), diff --git a/sw/source/core/inc/unoclbck.hxx b/sw/source/core/inc/unoclbck.hxx deleted file mode 100644 index 30a338f358f6..000000000000 --- a/sw/source/core/inc/unoclbck.hxx +++ /dev/null @@ -1,52 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: unoclbck.hxx,v $ - * $Revision: 1.6 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef _UNOCLBCK_HXX -#define _UNOCLBCK_HXX -#include - -class SwXReferenceMark; -class SwFmtRefMark; -class SwFmtFtn; -class SwXFootnote; -class SwTOXMark; -class SwXDocumentIndexMark; - -class SwUnoCallBack : public SwModify -{ -public: - SwUnoCallBack(SwModify *pToRegisterIn); - virtual ~SwUnoCallBack(); - - // returns the API object of a reference mark if available - SwXReferenceMark* GetRefMark(const SwFmtRefMark& rMark); - SwXFootnote* GetFootnote(const SwFmtFtn& rMark); - SwXDocumentIndexMark* GetTOXMark(const SwTOXMark& rMark); -}; -#endif diff --git a/sw/source/core/unocore/makefile.mk b/sw/source/core/unocore/makefile.mk index b364956a3d0c..31c6f4f72668 100644 --- a/sw/source/core/unocore/makefile.mk +++ b/sw/source/core/unocore/makefile.mk @@ -115,7 +115,6 @@ SLOFILES = \ $(SLO)$/unotextmarkup.obj\ $(SLO)$/TextCursorHelper.obj \ $(SLO)$/unotext.obj\ - $(SLO)$/unoclbck.obj\ $(SLO)$/unomap.obj\ $(SLO)$/unoprnms.obj\ $(SLO)$/XMLRangeHelper.obj diff --git a/sw/source/core/unocore/unoclbck.cxx b/sw/source/core/unocore/unoclbck.cxx deleted file mode 100644 index 6e5b08210147..000000000000 --- a/sw/source/core/unocore/unoclbck.cxx +++ /dev/null @@ -1,85 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: unoclbck.cxx,v $ - * $Revision: 1.10 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_sw.hxx" - - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* -----------------------------06.01.00 13:51-------------------------------- - - ---------------------------------------------------------------------------*/ -SwUnoCallBack::SwUnoCallBack(SwModify *pToRegisterIn) : - SwModify(pToRegisterIn) -{ -} -/* -----------------------------06.01.00 13:51-------------------------------- - - ---------------------------------------------------------------------------*/ -SwUnoCallBack::~SwUnoCallBack() -{ -} -/* -----------------------------01.09.00 12:03-------------------------------- - - ---------------------------------------------------------------------------*/ -SwXReferenceMark* SwUnoCallBack::GetRefMark(const SwFmtRefMark& rMark) -{ - return SwXReferenceMark::GetReferenceMark(*this, rMark); -} - -/* -----------------------------05.09.00 12:38-------------------------------- - - ---------------------------------------------------------------------------*/ -SwXFootnote* SwUnoCallBack::GetFootnote(const SwFmtFtn& rMark) -{ - return SwXFootnote::GetXFootnote(*this, rMark); -} - -/* -----------------------------27.11.00 17:15-------------------------------- - - ---------------------------------------------------------------------------*/ -SwXDocumentIndexMark* SwUnoCallBack::GetTOXMark(const SwTOXMark& /*rMark*/) -{ - return 0; -} - diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx index 57f9b05a9c01..daafeb65888b 100644 --- a/sw/source/core/unocore/unocoll.cxx +++ b/sw/source/core/unocore/unocoll.cxx @@ -43,7 +43,6 @@ #include #include #include -#include #include #include #include diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx index ba86f9c509b1..e1601dcbcad1 100644 --- a/sw/source/core/unocore/unoobj.cxx +++ b/sw/source/core/unocore/unoobj.cxx @@ -84,7 +84,6 @@ #include #include #include -#include #include #include #include diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index 53b0da94b12d..90d8c7538a0d 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -75,7 +75,6 @@ #include #include #include -#include #include #include #include diff --git a/sw/source/core/unocore/unoportenum.cxx b/sw/source/core/unocore/unoportenum.cxx index 6e29ff314cf8..fd9722db9616 100644 --- a/sw/source/core/unocore/unoportenum.cxx +++ b/sw/source/core/unocore/unoportenum.cxx @@ -45,7 +45,6 @@ #include #include #include -#include #include #include #include @@ -429,9 +428,7 @@ lcl_CreateRefMarkPortion( SwDoc* pDoc = pUnoCrsr->GetDoc(); const SwFmtRefMark& rRefMark = static_cast(rAttr.GetAttr()); - Reference xContent = - static_cast(pDoc->GetUnoCallBack()) - ->GetRefMark(rRefMark); + Reference xContent; if (!xContent.is()) { xContent = new SwXReferenceMark(pDoc, &rRefMark); @@ -476,15 +473,10 @@ lcl_CreateTOXMarkPortion( SwDoc* pDoc = pUnoCrsr->GetDoc(); const SwTOXMark& rTOXMark = static_cast(rAttr.GetAttr()); - Reference xContent = - static_cast(pDoc->GetUnoCallBack()) - ->GetTOXMark(rTOXMark); - if (!xContent.is()) - { - xContent.set( SwXDocumentIndexMark::CreateXDocumentIndexMark(*pDoc, + Reference xContent( + SwXDocumentIndexMark::CreateXDocumentIndexMark(*pDoc, *const_cast(rTOXMark.GetTOXType()), rTOXMark), - uno::UNO_QUERY); - } + uno::UNO_QUERY); SwXTextPortion* pPortion = 0; if (!bEnd) -- cgit From c93ddde38115731d4e5ca2dd41f0dced93625cd7 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 8 Jan 2010 17:14:00 +0100 Subject: swunolocking1: #i107771#: SwXDocumentIndexMark: register at SwTOXMark instead of UnoCallBack. implement instance caching with a WeakReference in SwTOXMark. [the ODF export depends on caching: see XMLIndexMarkExport::GetID()] --- sw/inc/tox.hxx | 32 ++++++++++++++++++--- sw/inc/unoidx.hxx | 4 +-- sw/source/core/docnode/nodes.cxx | 4 ++- sw/source/core/tox/tox.cxx | 34 +++++++++++++++++----- sw/source/core/txtnode/thints.cxx | 2 +- sw/source/core/unocore/unocrsrhelper.cxx | 3 +- sw/source/core/unocore/unoidx.cxx | 49 +++++++++++--------------------- sw/source/core/unocore/unoportenum.cxx | 8 +++--- 8 files changed, 84 insertions(+), 52 deletions(-) (limited to 'sw') diff --git a/sw/inc/tox.hxx b/sw/inc/tox.hxx index 9223ffa2d9df..b7384212a4e5 100644 --- a/sw/inc/tox.hxx +++ b/sw/inc/tox.hxx @@ -27,8 +27,10 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -#ifndef _TOX_HXX -#define _TOX_HXX +#ifndef SW_TOX_HXX +#define SW_TOX_HXX + +#include #include #include @@ -47,6 +49,11 @@ #define INCLUDED_VECTOR #endif + +namespace com { namespace sun { namespace star { + namespace text { class XDocumentIndexMark; } +} } } + class SwTOXType; class SwTOXMark; class SwTxtTOXMark; @@ -61,7 +68,9 @@ SV_DECL_PTRARR(SwTOXMarks, SwTOXMark*, 0, 10) #define IVER_TOXMARK_STRPOOL ((USHORT)1) #define IVER_TOXMARK_NEWTOX ((USHORT)2) -class SW_DLLPUBLIC SwTOXMark : public SfxPoolItem, public SwClient +class SW_DLLPUBLIC SwTOXMark + : public SfxPoolItem + , public SwModify { friend void _InitCore(); friend class SwTxtTOXMark; @@ -80,6 +89,8 @@ class SW_DLLPUBLIC SwTOXMark : public SfxPoolItem, public SwClient BOOL bAutoGenerated : 1; // generated using a concordance file BOOL bMainEntry : 1; // main entry emphasized by character style + ::com::sun::star::uno::WeakReference< + ::com::sun::star::text::XDocumentIndexMark> m_wXDocumentIndexMark; SwTOXMark(); // to create the dflt. atr. in _InitCore @@ -97,6 +108,11 @@ public: virtual int operator==( const SfxPoolItem& ) const; virtual SfxPoolItem* Clone( SfxItemPool* pPool = 0 ) const; + // SwClient + virtual void Modify( SfxPoolItem* pOld, SfxPoolItem* pNew ); + + void InvalidateTOXMark(); + String GetText() const; inline BOOL IsAlternativeText() const; @@ -131,6 +147,14 @@ public: const SwTxtTOXMark* GetTxtTOXMark() const { return pTxtAttr; } SwTxtTOXMark* GetTxtTOXMark() { return pTxtAttr; } + + SW_DLLPRIVATE ::com::sun::star::uno::WeakReference< + ::com::sun::star::text::XDocumentIndexMark> const& GetXTOXMark() const + { return m_wXDocumentIndexMark; } + SW_DLLPRIVATE void SetXTOXMark(::com::sun::star::uno::Reference< + ::com::sun::star::text::XDocumentIndexMark> const& xMark) + { m_wXDocumentIndexMark = xMark; } + }; /*-------------------------------------------------------------------- @@ -769,4 +793,4 @@ inline void SwTOXBase::SetOptions(USHORT nOpt) } -#endif // _TOX_HXX +#endif // SW_TOX_HXX diff --git a/sw/inc/unoidx.hxx b/sw/inc/unoidx.hxx index dd1edce22d0d..664b0c46a78b 100644 --- a/sw/inc/unoidx.hxx +++ b/sw/inc/unoidx.hxx @@ -207,7 +207,7 @@ private: virtual ~SwXDocumentIndexMark(); SwXDocumentIndexMark(SwDoc & rDoc, - SwTOXType & rType, const SwTOXMark & rMark); + SwTOXType & rType, SwTOXMark & rMark); public: @@ -217,7 +217,7 @@ public: static ::com::sun::star::uno::Reference< ::com::sun::star::text::XDocumentIndexMark> CreateXDocumentIndexMark(SwDoc & rDoc, - SwTOXType & rType, const SwTOXMark & rMark); + SwTOXType & rType, SwTOXMark & rMark); static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId(); diff --git a/sw/source/core/docnode/nodes.cxx b/sw/source/core/docnode/nodes.cxx index 29d9c61e1ad8..78008db5da00 100644 --- a/sw/source/core/docnode/nodes.cxx +++ b/sw/source/core/docnode/nodes.cxx @@ -48,6 +48,7 @@ #include #include #include +#include // InvalidateTOXMark #include #include @@ -341,7 +342,8 @@ void SwNodes::ChgNode( SwNodeIndex& rDelPos, ULONG nSz, break; case RES_TXTATR_TOXMARK: - nDelMsg = RES_TOXMARK_DELETED; + static_cast(pAttr->GetAttr()) + .InvalidateTOXMark(); break; case RES_TXTATR_REFMARK: diff --git a/sw/source/core/tox/tox.cxx b/sw/source/core/tox/tox.cxx index ddf9a2563a4b..5779b985346d 100644 --- a/sw/source/core/tox/tox.cxx +++ b/sw/source/core/tox/tox.cxx @@ -50,6 +50,7 @@ #include #include #include +#include // SwPtrMsgPoolItem // -> #i21237# #include @@ -176,10 +177,11 @@ SwFormTokens lcl_GetAuthPattern(USHORT nTypeId) --------------------------------------------------------------------*/ - // Konstruktor fuers Default vom Attribut-Pool +/// pool default constructor SwTOXMark::SwTOXMark() - : SfxPoolItem( RES_TXTATR_TOXMARK ), - SwClient( 0 ), + : SfxPoolItem( RES_TXTATR_TOXMARK ) + , SwModify( 0 ) + , pTxtAttr( 0 ), bAutoGenerated(FALSE), bMainEntry(FALSE) @@ -188,8 +190,9 @@ SwTOXMark::SwTOXMark() SwTOXMark::SwTOXMark( const SwTOXType* pTyp ) - : SfxPoolItem( RES_TXTATR_TOXMARK ), - SwClient( (SwModify*)pTyp ), + : SfxPoolItem( RES_TXTATR_TOXMARK ) + , SwModify( const_cast(pTyp) ) + , pTxtAttr( 0 ), nLevel( 0 ), bAutoGenerated(FALSE), bMainEntry(FALSE) @@ -198,8 +201,9 @@ SwTOXMark::SwTOXMark( const SwTOXType* pTyp ) SwTOXMark::SwTOXMark( const SwTOXMark& rCopy ) - : SfxPoolItem( RES_TXTATR_TOXMARK ), - SwClient((SwModify*)rCopy.GetRegisteredIn()), + : SfxPoolItem( RES_TXTATR_TOXMARK ) + , SwModify(rCopy.pRegisteredIn) + , aPrimaryKey( rCopy.aPrimaryKey ), aSecondaryKey( rCopy.aSecondaryKey ), aTextReading( rCopy.aTextReading ), aPrimaryKeyReading( rCopy.aPrimaryKeyReading ), @@ -230,6 +234,22 @@ SfxPoolItem* SwTOXMark::Clone( SfxItemPool* ) const return new SwTOXMark( *this ); } +void SwTOXMark::Modify(SfxPoolItem* pOld, SfxPoolItem* pNew) +{ + SwModify::Modify(pOld, pNew); + if (pOld && (RES_REMOVE_UNO_OBJECT == pOld->Which())) + { // invalidate cached uno object + SetXTOXMark(::com::sun::star::uno::Reference< + ::com::sun::star::text::XDocumentIndexMark>(0)); + } +} + +void SwTOXMark::InvalidateTOXMark() +{ + SwPtrMsgPoolItem aMsgHint( RES_REMOVE_UNO_OBJECT, + &static_cast(*this) ); // cast to base class! + Modify(&aMsgHint, &aMsgHint); +} String SwTOXMark::GetText() const { diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx index 3300294f9e4b..5fdbc0026353 100644 --- a/sw/source/core/txtnode/thints.cxx +++ b/sw/source/core/txtnode/thints.cxx @@ -1174,7 +1174,7 @@ void SwTxtNode::DestroyAttr( SwTxtAttr* pAttr ) break; case RES_TXTATR_TOXMARK: - nDelMsg = RES_TOXMARK_DELETED; + static_cast(pAttr->GetAttr()).InvalidateTOXMark(); break; case RES_TXTATR_REFMARK: diff --git a/sw/source/core/unocore/unocrsrhelper.cxx b/sw/source/core/unocore/unocrsrhelper.cxx index 642b0b5030aa..e5540bb9bc3b 100644 --- a/sw/source/core/unocore/unocrsrhelper.cxx +++ b/sw/source/core/unocore/unocrsrhelper.cxx @@ -313,7 +313,8 @@ sal_Bool getCrsrPropertyValue(const SfxItemPropertySimpleEntry& rEntry { if( pAny ) { - const SwTOXMark& rMark = pTxtAttr->GetTOXMark(); + SwTOXMark & rMark = + static_cast(pTxtAttr->GetAttr()); const uno::Reference< text::XDocumentIndexMark > xRef = SwXDocumentIndexMark::CreateXDocumentIndexMark( *rPam.GetDoc(), diff --git a/sw/source/core/unocore/unoidx.cxx b/sw/source/core/unocore/unoidx.cxx index 807b230c5b6d..db2ab16e5784 100644 --- a/sw/source/core/unocore/unoidx.cxx +++ b/sw/source/core/unocore/unoidx.cxx @@ -1598,7 +1598,7 @@ public: SwDoc *const pDoc, const enum TOXTypes eType, SwTOXType *const pType, SwTOXMark const*const pMark) - : SwClient((pDoc) ? pDoc->GetUnoCallBack() : 0) + : SwClient(const_cast(pMark)) , m_rPropSet( *aSwMapProvider.GetPropertySet(lcl_TypeToPropertyMap_Mark(eType))) , m_eTOXType(eType) @@ -1654,19 +1654,6 @@ void SwXDocumentIndexMark::Impl::Modify(SfxPoolItem *pOld, SfxPoolItem *pNew) { Invalidate(); } - else if (pOld) - { - switch (pOld->Which()) - { - case RES_TOXMARK_DELETED: - if (static_cast(m_pTOXMark) == - static_cast(pOld)->pObject) - { - Invalidate(); - } - break; - } - } } /*-- 14.12.98 10:25:43--------------------------------------------------- @@ -1680,7 +1667,7 @@ SwXDocumentIndexMark::SwXDocumentIndexMark(const TOXTypes eToxType) -----------------------------------------------------------------------*/ SwXDocumentIndexMark::SwXDocumentIndexMark(SwDoc & rDoc, - SwTOXType & rType, const SwTOXMark & rMark) + SwTOXType & rType, SwTOXMark & rMark) : m_pImpl( new SwXDocumentIndexMark::Impl(*this, &rDoc, rType.GetType(), &rType, &rMark) ) { @@ -1694,23 +1681,20 @@ SwXDocumentIndexMark::~SwXDocumentIndexMark() uno::Reference SwXDocumentIndexMark::CreateXDocumentIndexMark( - SwDoc & rDoc, SwTOXType & rType, const SwTOXMark & rMark) + SwDoc & rDoc, SwTOXType & rType, SwTOXMark & rMark) { + // re-use existing SwXDocumentIndexMark + // NB: xmloff depends on this caching to generate ID from the address! // #i105557#: do not iterate over the registered clients: race condition - // to do this properly requires the SwXDocumentIndexMark to register at the - // format directly, not at the unocallback -#if 0 - SwClientIter aIter(*pType); - SwXDocumentIndexMark::Impl* pxMark = (SwXDocumentIndexMark::Impl*) - aIter.First(TYPE(SwXDocumentIndexMark::Impl)); - while( pxMark ) - { - if(pxMark->m_pTOXMark == pMark) - return pxMark->m_rThis; - pxMark = (SwXDocumentIndexMark::Impl*)aIter.Next(); + uno::Reference< text::XDocumentIndexMark > xTOXMark(rMark.GetXTOXMark()); + if (!xTOXMark.is()) + { + SwXDocumentIndexMark *const pNew = + new SwXDocumentIndexMark(rDoc, rType, rMark); + xTOXMark.set(pNew); + rMark.SetXTOXMark(xTOXMark); } -#endif - return new SwXDocumentIndexMark(rDoc, rType, rMark); + return xTOXMark; } /* -----------------------------10.03.00 18:02-------------------------------- @@ -1955,8 +1939,6 @@ throw (lang::IllegalArgumentException, uno::RuntimeException) { throw lang::IllegalArgumentException(); } - pDoc->GetUnoCallBack()->Add(m_pImpl.get()); - const_cast(pTOXType)->Add(&m_pImpl->m_TypeDepend); SwUnoInternalPaM aPam(*pDoc); //das muss jetzt sal_True liefern @@ -2046,6 +2028,9 @@ throw (lang::IllegalArgumentException, uno::RuntimeException) m_pImpl->m_pTOXMark = &pTxtAttr->GetTOXMark(); m_pImpl->m_pDoc = pDoc; m_pImpl->m_bIsDescriptor = sal_False; + + const_cast(m_pImpl->m_pTOXMark)->Add(m_pImpl.get()); + const_cast(pTOXType)->Add(&m_pImpl->m_TypeDepend); } /*-- 14.12.98 10:25:45--------------------------------------------------- @@ -2268,7 +2253,7 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException, if(pTxtAttr) { m_pImpl->m_pTOXMark = &pTxtAttr->GetTOXMark(); - m_pImpl->m_pDoc->GetUnoCallBack()->Add(m_pImpl.get()); + const_cast(m_pImpl->m_pTOXMark)->Add(m_pImpl.get()); pType->Add(&m_pImpl->m_TypeDepend); } } diff --git a/sw/source/core/unocore/unoportenum.cxx b/sw/source/core/unocore/unoportenum.cxx index fd9722db9616..7996a5e13bcf 100644 --- a/sw/source/core/unocore/unoportenum.cxx +++ b/sw/source/core/unocore/unoportenum.cxx @@ -468,12 +468,12 @@ static Reference lcl_CreateTOXMarkPortion( Reference const& xParent, const SwUnoCrsr * const pUnoCrsr, - const SwTxtAttr & rAttr, const bool bEnd) + SwTxtAttr & rAttr, const bool bEnd) { SwDoc* pDoc = pUnoCrsr->GetDoc(); - const SwTOXMark& rTOXMark = static_cast(rAttr.GetAttr()); + SwTOXMark & rTOXMark = static_cast(rAttr.GetAttr()); - Reference xContent( + const Reference xContent( SwXDocumentIndexMark::CreateXDocumentIndexMark(*pDoc, *const_cast(rTOXMark.GetTOXType()), rTOXMark), uno::UNO_QUERY); @@ -742,7 +742,7 @@ lcl_ExportHints( while(nStartIndex < pHints->GetStartCount() && nCurrentIndex >= (nNextStart = (*pHints->GetStart(nStartIndex)->GetStart()))) { - const SwTxtAttr * const pAttr = pHints->GetStart(nStartIndex); + SwTxtAttr * const pAttr = pHints->GetStart(nStartIndex); USHORT nAttrWhich = pAttr->Which(); if (nNextStart == nCurrentIndex) { -- cgit From 680ebbec1520b6df42264a450932d779edc07c3c Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Wed, 13 Jan 2010 10:16:37 +0100 Subject: #i108219# SwWeb print options fixed --- sw/source/core/view/vprint.cxx | 23 +++++++++++++---------- sw/source/ui/config/optpage.cxx | 19 ++++++++++++++++--- sw/source/ui/config/prtopt.cxx | 18 ++++++++++++++++-- 3 files changed, 45 insertions(+), 15 deletions(-) mode change 100644 => 100755 sw/source/ui/config/optpage.cxx (limited to 'sw') diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index bab2428c0b67..864948046b75 100755 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -394,7 +394,7 @@ SwPrintUIOptions::SwPrintUIOptions( // create sequence of print UI options // (5 options are not available for Writer-Web) const int nCTLOpts = bCTL ? 1 : 0; - const int nNumProps = nCTLOpts + (bWeb ? 16 : 20); + const int nNumProps = nCTLOpts + (bWeb ? 14 : 20); m_aUIProperties.realloc( nNumProps ); int nIdx = 0; @@ -455,15 +455,18 @@ SwPrintUIOptions::SwPrintUIOptions( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintBlackFonts" ) ), bDefaultVal ); - // create subgroup for misc options - m_aUIProperties[ nIdx++ ].Value = getSubgroupControlOpt( rtl::OUString( aLocalizedStrings.GetString( 15 ) ), rtl::OUString() ); - - // create a bool option for printing automatically inserted blank pages - bDefaultVal = rDefaultPrintData.IsPrintEmptyPages(); - m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 16 ), - aLocalizedStrings.GetString( 17 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintEmptyPages" ) ), - bDefaultVal ); + if (!bWeb) + { + // create subgroup for misc options + m_aUIProperties[ nIdx++ ].Value = getSubgroupControlOpt( rtl::OUString( aLocalizedStrings.GetString( 15 ) ), rtl::OUString() ); + + // create a bool option for printing automatically inserted blank pages + bDefaultVal = rDefaultPrintData.IsPrintEmptyPages(); + m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 16 ), + aLocalizedStrings.GetString( 17 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintEmptyPages" ) ), + bDefaultVal ); + } // create a bool option for paper tray bDefaultVal = rDefaultPrintData.IsPaperFromSetup(); diff --git a/sw/source/ui/config/optpage.cxx b/sw/source/ui/config/optpage.cxx old mode 100644 new mode 100755 index d609f1ed28cc..0777ac3c3325 --- a/sw/source/ui/config/optpage.cxx +++ b/sw/source/ui/config/optpage.cxx @@ -416,13 +416,26 @@ SwAddPrinterTabPage::SwAddPrinterTabPage( Window* pParent, aPrintTextPlaceholderCB.Hide(); // aReverseCB.SetPosPixel(aLeftPageCB.GetPosPixel()); aProspectCB.SetPosPixel(aLeftPageCB.GetPosPixel()); - Point rPt( aRightPageCB.GetPosPixel() ); - rPt.setX(rPt.getX() + 15); // indent - aProspectCB_RTL.SetPosPixel(rPt); + Point aPt( aRightPageCB.GetPosPixel() ); + aPt.setX(aPt.getX() + 15); // indent + aProspectCB_RTL.SetPosPixel(aPt); // aBlackFontCB.SetPosPixel(aBackgroundCB.GetPosPixel()); // aPrintHiddenTextCB.SetPosPixel(aBlackFontCB.GetPosPixel()); // aBackgroundCB.SetPosPixel(aCtrlFldCB.GetPosPixel()); // aCtrlFldCB.SetPosPixel(aDrawCB.GetPosPixel()); + + // hide aPrintEmptyPagesCB and move everything below up accordingly + long nDeltaY = aPaperFromSetupCB.GetPosPixel().getY() - aPrintEmptyPagesCB.GetPosPixel().getY(); + aPrintEmptyPagesCB.Hide(); + aPt = aPaperFromSetupCB.GetPosPixel(); + aPt.setY( aPt.getY() - nDeltaY ); + aPaperFromSetupCB.SetPosPixel( aPt ); + aPt = aFaxFT.GetPosPixel(); + aPt.setY( aPt.getY() - nDeltaY ); + aFaxFT.SetPosPixel( aPt ); + aPt = aFaxLB.GetPosPixel(); + aPt.setY( aPt.getY() - nDeltaY ); + aFaxLB.SetPosPixel( aPt ); } aProspectCB_RTL.Disable(); SvtCTLOptions aCTLOptions; diff --git a/sw/source/ui/config/prtopt.cxx b/sw/source/ui/config/prtopt.cxx index ceb48b6adefe..1f8f04f54d65 100644 --- a/sw/source/ui/config/prtopt.cxx +++ b/sw/source/ui/config/prtopt.cxx @@ -69,8 +69,8 @@ Sequence SwPrintOptions::GetPropertyNames() "Page/LeftPage", // 13 not in SW/Web "Page/RightPage", // 14 not in SW/Web "EmptyPages", // 15 not in SW/Web - "Content/PrintPlaceholders", // 16 not in Sw/Web - "Content/PrintHiddenText" // 17 + "Content/PrintPlaceholders", // 16 not in Sw/Web + "Content/PrintHiddenText" // 17 not in Sw/Web }; const int nCount = bIsWeb ? 12 : 18; Sequence aNames(nCount); @@ -92,6 +92,8 @@ SwPrintOptions::SwPrintOptions(sal_Bool bWeb) : bPrintPageBackground = !bWeb; bPrintBlackFont = bWeb; bPrintTextPlaceholder = bPrintHiddenText = sal_False; + if (bWeb) + bPrintEmptyPages = sal_False; Sequence aNames = GetPropertyNames(); Sequence aValues = GetProperties(aNames); @@ -133,6 +135,12 @@ SwPrintOptions::SwPrintOptions(sal_Bool bWeb) : } } } + + // currently there is just one checkbox for print drawings and print graphics + // In the UI. (File/Print dialog and Tools/Options/.../Print) + // And since print graphics is the only available in Writer and WrtierWeb ... + + bPrintDraw = bPrintGraphic; } /* -----------------------------06.09.00 16:50-------------------------------- @@ -176,6 +184,12 @@ void SwPrintOptions::Commit() case 17: bVal = bPrintHiddenText; pValues[nProp].setValue(&bVal, rType); break; } } + + // currently there is just one checkbox for print drawings and print graphics + // In the UI. (File/Print dialog and Tools/Options/.../Print) + // And since print graphics is the only available in Writer and WrtierWeb ... + bPrintDraw = bPrintGraphic; + PutProperties(aNames, aValues); } -- cgit From b59c89d2ae495e0c42ae76042379960444269b19 Mon Sep 17 00:00:00 2001 From: "Philipp Lohmann [pl]" Date: Thu, 14 Jan 2010 22:27:44 +0100 Subject: undo previous erroneous change, solar.hrc belongs to svl instead vcl now --- sw/inc/helpid.h | 2 +- sw/inc/pch/precompiled_sw.hxx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'sw') diff --git a/sw/inc/helpid.h b/sw/inc/helpid.h index dca700fbb8b6..6bab531ad1c5 100644 --- a/sw/inc/helpid.h +++ b/sw/inc/helpid.h @@ -28,7 +28,7 @@ * ************************************************************************/ #ifndef _SOLAR_HRC -#include +#include #endif #define HID_BASE HID_APP_START diff --git a/sw/inc/pch/precompiled_sw.hxx b/sw/inc/pch/precompiled_sw.hxx index f43d09731f2f..e8aadd472aa6 100644 --- a/sw/inc/pch/precompiled_sw.hxx +++ b/sw/inc/pch/precompiled_sw.hxx @@ -677,7 +677,7 @@ #include "svl/slstitm.hxx" #include "svl/smplhint.hxx" #include "svtools/soerr.hxx" -#include "vcl/solar.hrc" +#include "svl/solar.hrc" #include "unotools/sourceviewconfig.hxx" #include "svtools/stdctrl.hxx" #include "svl/stritem.hxx" -- cgit From 5390c9fba7b59dda8f1a2a00e9535a52098d04e0 Mon Sep 17 00:00:00 2001 From: "Philipp Lohmann [pl]" Date: Fri, 15 Jan 2010 00:20:57 +0100 Subject: solve some merge problems --- sw/source/core/view/vprint.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sw') diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index 94169b0db2ab..10b62f92c68a 100755 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -54,8 +54,8 @@ #include #include -#include -#include +#include +#include #include #include -- cgit From df7c98db5ee7ed1e910d3e96461da37c005fa263 Mon Sep 17 00:00:00 2001 From: Kurt Zenker Date: Mon, 18 Jan 2010 18:37:54 +0100 Subject: masterfix: #i10000# bBoolVar does not exist, use rValue --- sw/source/ui/uno/unomod.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'sw') diff --git a/sw/source/ui/uno/unomod.cxx b/sw/source/ui/uno/unomod.cxx index 6a072b44af31..906402b8e365 100644 --- a/sw/source/ui/uno/unomod.cxx +++ b/sw/source/ui/uno/unomod.cxx @@ -572,17 +572,17 @@ void SwXPrintSettings::_getSingleValue( const comphelper::PropertyInfo & rInfo, break; case HANDLE_PRINTSET_PROSPECT_RTL: { - bBoolVal = mpPrtOpt->IsPrintProspectRTL(); + rValue <<= mpPrtOpt->IsPrintProspectRTL(); } break; case HANDLE_PRINTSET_PLACEHOLDER: { - bBoolVal = mpPrtOpt->IsPrintTextPlaceholder(); + rValue <<= mpPrtOpt->IsPrintTextPlaceholder(); } break; case HANDLE_PRINTSET_HIDDEN_TEXT: { - bBoolVal = mpPrtOpt->IsPrintHiddenText(); + rValue <<= mpPrtOpt->IsPrintHiddenText(); } break; default: -- cgit From fdde737ea0caf7450a6676f46651f78ee05321ab Mon Sep 17 00:00:00 2001 From: Kurt Zenker Date: Mon, 18 Jan 2010 19:01:17 +0100 Subject: masterfix: #i10000# syntax error fixed --- sw/source/core/view/vprint.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sw') diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index 10b62f92c68a..7a22698b87ca 100755 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -562,7 +562,7 @@ SwPrintUIOptions::SwPrintUIOptions( // 0 : all pages (left & right) // 1 : left pages // 2 : right pages - DBG_ASSERT( rDefaultPrintData.IsPrintLeftPage() || rDefaultPrintData.IsPrintRigthPage(), + DBG_ASSERT( rDefaultPrintData.IsPrintLeftPage() || rDefaultPrintData.IsPrintRightPage(), "unexpected value combination" ); sal_Int16 nPagesChoice = 0; if (rDefaultPrintData.IsPrintLeftPage() && !rDefaultPrintData.IsPrintRightPage()) -- cgit From 85bd4fb7e1db9d02ab9801afcd7e45381ae6a787 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Wed, 20 Jan 2010 16:59:56 +0100 Subject: swunolocking1: #i108489#: fix crash: XTextRangeToSwPaM(): do not prematurely release newly created text cursor. SwXTextViewCursor::gotoRange(): do not throw IllegalArgumentException. --- sw/source/core/unocore/unoobj2.cxx | 7 ++++--- sw/source/ui/uno/unotxvw.cxx | 4 +++- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'sw') diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index 90d8c7538a0d..8f6c3c3340d1 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -1160,10 +1160,11 @@ bool XTextRangeToSwPaM( SwUnoInternalPaM & rToFill, // if it's a text then create a temporary cursor there and re-use // the pCursor variable - if(pText) + // #i108489#: Reference in outside scope to keep cursor alive + uno::Reference< text::XTextCursor > xTextCursor; + if (pText) { - const uno::Reference< text::XTextCursor > xTextCursor = - pText->CreateCursor(); + xTextCursor.set( pText->CreateCursor() ); xTextCursor->gotoEnd(sal_True); const uno::Reference xCrsrTunnel( xTextCursor, uno::UNO_QUERY); diff --git a/sw/source/ui/uno/unotxvw.cxx b/sw/source/ui/uno/unotxvw.cxx index c83db6909045..4ce45761485b 100644 --- a/sw/source/ui/uno/unotxvw.cxx +++ b/sw/source/ui/uno/unotxvw.cxx @@ -1364,7 +1364,9 @@ void SwXTextViewCursor::gotoRange( SwUnoInternalPaM rDestPam(*m_pView->GetDocShell()->GetDoc()); if (!::sw::XTextRangeToSwPaM(rDestPam, xRange)) - throw IllegalArgumentException(); + { + throw uno::RuntimeException(); + } ShellModes eSelMode = m_pView->GetShellMode(); SwWrtShell& rSh = m_pView->GetWrtShell(); -- cgit From 35933081fda3551db61a81c9af5ac393fb5fc80e Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 22 Jan 2010 19:07:50 +0100 Subject: swunolocking1: fix regression: SwXParagraphEnumeration constructor really needs the start node as a parameter because determining it from the cursor cannot work in nested tables. --- sw/inc/unoparagraph.hxx | 6 ++++- sw/source/core/unocore/unoobj.cxx | 8 ++++++- sw/source/core/unocore/unoobj2.cxx | 45 ++++++++++---------------------------- sw/source/core/unocore/unotbl.cxx | 6 ++++- 4 files changed, 29 insertions(+), 36 deletions(-) (limited to 'sw') diff --git a/sw/inc/unoparagraph.hxx b/sw/inc/unoparagraph.hxx index add936e9c702..8743737c338e 100644 --- a/sw/inc/unoparagraph.hxx +++ b/sw/inc/unoparagraph.hxx @@ -55,7 +55,9 @@ struct SwPosition; class SwPaM; class SwUnoCrsr; +class SwStartNode; class SwTxtNode; +class SwTable; class SwXText; @@ -339,7 +341,9 @@ public: ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > const & xParent, ::std::auto_ptr pCursor, - const CursorType eType); + const CursorType eType, + SwStartNode const*const pStartNode = 0, + SwTable const*const pTable = 0); // XServiceInfo virtual ::rtl::OUString SAL_CALL getImplementationName() diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx index e1601dcbcad1..1e8eea9392f0 100644 --- a/sw/source/core/unocore/unoobj.cxx +++ b/sw/source/core/unocore/unoobj.cxx @@ -3157,8 +3157,14 @@ SwXTextCursor::createEnumeration() throw (uno::RuntimeException) } const CursorType eSetType = (CURSOR_TBLTEXT == m_pImpl->m_eType) ? CURSOR_SELECTION_IN_TABLE : CURSOR_SELECTION; + SwTableNode const*const pStartNode( (CURSOR_TBLTEXT == m_pImpl->m_eType) + ? rUnoCursor.GetPoint()->nNode.GetNode().FindTableNode() + : 0); + SwTable const*const pTable( + (pStartNode) ? & pStartNode->GetTable() : 0 ); const uno::Reference< container::XEnumeration > xRet = - new SwXParagraphEnumeration(pParentText, pNewCrsr, eSetType); + new SwXParagraphEnumeration( + pParentText, pNewCrsr, eSetType, pStartNode, pTable); return xRet; } diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index 8f6c3c3340d1..f4935586efaf 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -468,34 +468,6 @@ void SwUnoCursorHelper::GetCrsrAttr(SwPaM & rPam, * SwXParagraphEnumeration ******************************************************************/ -static SwStartNode * -lcl_InitStartNode(const CursorType eType, SwUnoCrsr *const pCursor) -{ - switch (eType) - { - case CURSOR_TBLTEXT: // table cell: pCursor points at first paragraph - return pCursor->Start()->nNode.GetNode().StartOfSectionNode(); - case CURSOR_SELECTION_IN_TABLE: // table - return pCursor->Start()->nNode.GetNode().FindTableNode(); - default: - return 0; - } -} - -static SwTable const* -lcl_InitTable(const CursorType eType, SwStartNode const*const pStartNode) -{ - switch (eType) - { - case CURSOR_TBLTEXT: // table cell - return & pStartNode->FindTableNode()->GetTable(); - case CURSOR_SELECTION_IN_TABLE: // table - return & static_cast(pStartNode)->GetTable(); - default: - return 0; - } -} - class SwXParagraphEnumeration::Impl : public SwClient { @@ -517,16 +489,17 @@ public: Impl( uno::Reference< text::XText > const& xParent, ::std::auto_ptr pCursor, - const CursorType eType) + const CursorType eType, + SwStartNode const*const pStartNode, SwTable const*const pTable) : SwClient( pCursor.release() ) , m_xParentText( xParent ) , m_eCursorType( eType ) // remember table and start node for later travelling // (used in export of tables in tables) - , m_pOwnStartNode( lcl_InitStartNode(eType, GetCursor()) ) + , m_pOwnStartNode( pStartNode ) // for import of tables in tables we have to remember the actual // table and start node of the current position in the enumeration. - , m_pOwnTable( lcl_InitTable(eType, m_pOwnStartNode) ) + , m_pOwnTable( pTable ) , m_nEndIndex( GetCursor()->End()->nNode.GetIndex() ) , m_nFirstParaStart( -1 ) , m_nLastParaEnd( -1 ) @@ -534,6 +507,10 @@ public: { OSL_ENSURE(m_xParentText.is(), "SwXParagraphEnumeration: no parent?"); OSL_ENSURE(GetRegisteredIn(), "SwXParagraphEnumeration: no cursor?"); + OSL_ENSURE( !((CURSOR_SELECTION_IN_TABLE == eType) || + (CURSOR_TBLTEXT == eType)) + || (m_pOwnTable && m_pOwnStartNode), + "SwXParagraphEnumeration: table type but no start node or table?"); if ((CURSOR_SELECTION == m_eCursorType) || (CURSOR_SELECTION_IN_TABLE == m_eCursorType)) @@ -576,8 +553,10 @@ void SwXParagraphEnumeration::Impl::Modify(SfxPoolItem *pOld, SfxPoolItem *pNew) SwXParagraphEnumeration::SwXParagraphEnumeration( uno::Reference< text::XText > const& xParent, ::std::auto_ptr pCursor, - const CursorType eType) - : m_pImpl( new SwXParagraphEnumeration::Impl(xParent, pCursor, eType) ) + const CursorType eType, + SwStartNode const*const pStartNode, SwTable const*const pTable) + : m_pImpl( new SwXParagraphEnumeration::Impl(xParent, pCursor, eType, + pStartNode, pTable) ) { } /*-- 10.12.98 11:52:12--------------------------------------------------- diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index e17ba707c1a8..a52f04e5a8c4 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -1227,8 +1227,12 @@ uno::Reference< container::XEnumeration > SwXCell::createEnumeration(void) thro GetDoc()->CreateUnoCrsr(aPos, sal_False)); pUnoCursor->Move(fnMoveForward, fnGoNode); + // remember table and start node for later travelling + // (used in export of tables in tables) + SwTable const*const pTable( & pSttNd->FindTableNode()->GetTable() ); SwXParagraphEnumeration *const pEnum = - new SwXParagraphEnumeration(this, pUnoCursor, CURSOR_TBLTEXT); + new SwXParagraphEnumeration(this, pUnoCursor, CURSOR_TBLTEXT, + pSttNd, pTable); aRef = pEnum; // // no Cursor in protected sections -- cgit