diff options
author | Noel Grandin <noel@peralex.com> | 2015-10-27 12:52:16 +0200 |
---|---|---|
committer | Noel Grandin <noelgrandin@gmail.com> | 2015-10-27 12:48:50 +0000 |
commit | e25669fcedcb7231254d3ba0e0224b2e3eb901d8 (patch) | |
tree | 05ce242744c88d9efcd5b685720b2178008c2c8c /sw/source | |
parent | 96d03636a5f932151c7842ae34631258891fe807 (diff) |
don't allocate uno::Reference on the heap
There is no point, since it's the size of a pointer anyway
(found by temporarily making the new operator in uno::Reference
deleted).
Change-Id: I62a8b957fef9184f65d705600acfdab4116dcb34
Reviewed-on: https://gerrit.libreoffice.org/19603
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/core/unocore/unostyle.cxx | 50 | ||||
-rw-r--r-- | sw/source/filter/html/htmlforw.cxx | 26 | ||||
-rw-r--r-- | sw/source/filter/html/htmltabw.cxx | 2 | ||||
-rw-r--r-- | sw/source/filter/html/wrthtml.cxx | 11 | ||||
-rw-r--r-- | sw/source/filter/html/wrthtml.hxx | 2 | ||||
-rw-r--r-- | sw/source/uibase/inc/uivwimp.hxx | 2 | ||||
-rw-r--r-- | sw/source/uibase/inc/unomod.hxx | 4 | ||||
-rw-r--r-- | sw/source/uibase/inc/unotxvw.hxx | 6 | ||||
-rw-r--r-- | sw/source/uibase/uiview/uivwimp.cxx | 14 | ||||
-rw-r--r-- | sw/source/uibase/uno/unomod.cxx | 20 | ||||
-rw-r--r-- | sw/source/uibase/uno/unotxdoc.cxx | 355 | ||||
-rw-r--r-- | sw/source/uibase/uno/unotxvw.cxx | 30 |
12 files changed, 230 insertions, 292 deletions
diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index d2039b21d878..2372c75a1053 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -167,22 +167,17 @@ uno::Sequence< OUString > SwXStyleFamilies::getSupportedServiceNames() throw( un SwXStyleFamilies::SwXStyleFamilies(SwDocShell& rDocShell) : SwUnoCollection(rDocShell.GetDoc()), m_pDocShell(&rDocShell), - m_pxCharStyles(0), - m_pxParaStyles(0), - m_pxFrameStyles(0), - m_pxPageStyles(0), - m_pxNumberingStyles(0) + m_xCharStyles(), + m_xParaStyles(), + m_xFrameStyles(), + m_xPageStyles(), + m_xNumberingStyles() { } SwXStyleFamilies::~SwXStyleFamilies() { - delete m_pxCharStyles; - delete m_pxParaStyles; - delete m_pxFrameStyles; - delete m_pxPageStyles; - delete m_pxNumberingStyles; } uno::Any SAL_CALL SwXStyleFamilies::getByName(const OUString& Name) @@ -255,52 +250,47 @@ uno::Any SwXStyleFamilies::getByIndex(sal_Int32 nIndex) { case SFX_STYLE_FAMILY_CHAR: { - if(!m_pxCharStyles) + if(!m_xCharStyles.is()) { - static_cast<SwXStyleFamilies*>(this)->m_pxCharStyles = new uno::Reference< container::XNameContainer > (); - *m_pxCharStyles = new SwXStyleFamily(m_pDocShell, nType); + m_xCharStyles = new SwXStyleFamily(m_pDocShell, nType); } - aRef = *m_pxCharStyles; + aRef = m_xCharStyles; } break; case SFX_STYLE_FAMILY_PARA: { - if(!m_pxParaStyles) + if(!m_xParaStyles.is()) { - static_cast<SwXStyleFamilies*>(this)->m_pxParaStyles = new uno::Reference< container::XNameContainer > (); - *m_pxParaStyles = new SwXStyleFamily(m_pDocShell, nType); + m_xParaStyles = new SwXStyleFamily(m_pDocShell, nType); } - aRef = *m_pxParaStyles; + aRef = m_xParaStyles; } break; case SFX_STYLE_FAMILY_PAGE : { - if(!m_pxPageStyles) + if(!m_xPageStyles.is()) { - static_cast<SwXStyleFamilies*>(this)->m_pxPageStyles = new uno::Reference< container::XNameContainer > (); - *m_pxPageStyles = new SwXStyleFamily(m_pDocShell, nType); + m_xPageStyles = new SwXStyleFamily(m_pDocShell, nType); } - aRef = *m_pxPageStyles; + aRef = m_xPageStyles; } break; case SFX_STYLE_FAMILY_FRAME : { - if(!m_pxFrameStyles) + if(!m_xFrameStyles.is()) { - static_cast<SwXStyleFamilies*>(this)->m_pxFrameStyles = new uno::Reference< container::XNameContainer > (); - *m_pxFrameStyles = new SwXStyleFamily(m_pDocShell, nType); + m_xFrameStyles = new SwXStyleFamily(m_pDocShell, nType); } - aRef = *m_pxFrameStyles; + aRef = m_xFrameStyles; } break; case SFX_STYLE_FAMILY_PSEUDO: { - if(!m_pxNumberingStyles) + if(!m_xNumberingStyles.is()) { - static_cast<SwXStyleFamilies*>(this)->m_pxNumberingStyles = new uno::Reference< container::XNameContainer > (); - *m_pxNumberingStyles = new SwXStyleFamily(m_pDocShell, nType); + m_xNumberingStyles = new SwXStyleFamily(m_pDocShell, nType); } - aRef = *m_pxNumberingStyles; + aRef = m_xNumberingStyles; } break; } diff --git a/sw/source/filter/html/htmlforw.cxx b/sw/source/filter/html/htmlforw.cxx index 0efb13096355..e4ff1a58eab6 100644 --- a/sw/source/filter/html/htmlforw.cxx +++ b/sw/source/filter/html/htmlforw.cxx @@ -232,11 +232,11 @@ void SwHTMLWriter::OutForm( bool bTag_On, const SwStartNode *pStartNd ) if( !bTag_On ) { // die Form beenden wenn alle Controls ausgegeben wurden - if( pxFormComps && pxFormComps->is() && - (*pxFormComps)->getCount() == nFormCntrlCnt ) + if( mxFormComps.is() && + mxFormComps->getCount() == nFormCntrlCnt ) { - OutForm( false, *pxFormComps ); - (*pxFormComps) = 0; + OutForm( false, mxFormComps ); + mxFormComps.clear(); } return; } @@ -321,26 +321,24 @@ void SwHTMLWriter::OutForm( bool bTag_On, const SwStartNode *pStartNd ) } if( xNewFormComps.is() && - (!pxFormComps || !(xNewFormComps == *pxFormComps)) ) + (!mxFormComps.is() || !(xNewFormComps == mxFormComps)) ) { // Es soll eine Form aufgemacht werden ... - if( pxFormComps && pxFormComps->is() ) + if( mxFormComps.is() ) { // .. es ist aber noch eine Form offen: Das ist in // jedem Fall eine Fehler, aber wir schliessen die alte // Form trotzdem - OutForm( false, *pxFormComps ); + OutForm( false, mxFormComps ); //!!!nWarn = 1; // Control wird falscher Form zugeordnet } - if( !pxFormComps ) - pxFormComps = new uno::Reference< container::XIndexContainer > ; - *pxFormComps = xNewFormComps; + mxFormComps = xNewFormComps; - OutForm( true, *pxFormComps ); + OutForm( true, mxFormComps ); uno::Reference< beans::XPropertySet > xTmp; - OutHiddenControls( *pxFormComps, xTmp ); + OutHiddenControls( mxFormComps, xTmp ); } } @@ -1270,8 +1268,8 @@ Writer& OutHTML_DrawFrameFormatAsControl( Writer& rWrt, // Controls sind nicht absatz-gebunden, deshalb kein LF mehr ausgeben! rHTMLWrt.bLFPossible = false; - if( rHTMLWrt.pxFormComps && rHTMLWrt.pxFormComps->is() ) - rHTMLWrt.OutHiddenControls( *rHTMLWrt.pxFormComps, xPropSet ); + if( rHTMLWrt.mxFormComps.is() ) + rHTMLWrt.OutHiddenControls( rHTMLWrt.mxFormComps, xPropSet ); return rWrt; } diff --git a/sw/source/filter/html/htmltabw.cxx b/sw/source/filter/html/htmltabw.cxx index 9a1a3c447260..5926b067f0c4 100644 --- a/sw/source/filter/html/htmltabw.cxx +++ b/sw/source/filter/html/htmltabw.cxx @@ -920,7 +920,7 @@ Writer& OutHTML_SwTableNode( Writer& rWrt, SwTableNode & rNode, if( !rHTMLWrt.bPreserveForm ) { rHTMLWrt.OutForm( true, &rNode ); - bPreserveForm = (rHTMLWrt.pxFormComps && rHTMLWrt.pxFormComps->is() ); + bPreserveForm = rHTMLWrt.mxFormComps.is(); rHTMLWrt.bPreserveForm = bPreserveForm; } diff --git a/sw/source/filter/html/wrthtml.cxx b/sw/source/filter/html/wrthtml.cxx index 6a6782cd5342..ee9c2ef1a873 100644 --- a/sw/source/filter/html/wrthtml.cxx +++ b/sw/source/filter/html/wrthtml.cxx @@ -97,7 +97,7 @@ SwHTMLWriter::SwHTMLWriter( const OUString& rBaseURL ) , nHTMLMode(0) , eCSS1Unit(FUNIT_NONE) , pFootEndNotes(NULL) - , pxFormComps(NULL) + , mxFormComps() , pTemplate(NULL) , pDfltColor(NULL) , pStartNdIdx(NULL) @@ -285,7 +285,7 @@ sal_uLong SwHTMLWriter::WriteStream() pFootEndNotes = 0; pFormatFootnote = 0; bOutTable = bOutHeader = bOutFooter = bOutFlyFrame = false; - pxFormComps = 0; + mxFormComps.clear(); nFormCntrlCnt = 0; bPreserveForm = false; bClearLeft = bClearRight = false; @@ -412,8 +412,8 @@ sal_uLong SwHTMLWriter::WriteStream() Out_SwDoc( pOrigPam ); nTextAttrsToIgnore = 0; - if( pxFormComps && pxFormComps->is() ) - OutForm( false, *pxFormComps ); + if( mxFormComps.is() ) + OutForm( false, mxFormComps ); if( pFootEndNotes ) OutFootEndNotes(); @@ -474,8 +474,7 @@ sal_uLong SwHTMLWriter::WriteStream() delete pStartNdIdx; pStartNdIdx = 0; - delete pxFormComps; - pxFormComps = 0; + mxFormComps.clear(); OSL_ENSURE( !pFootEndNotes, "SwHTMLWriter::Write: Footnotes nicht durch OutFootEndNotes geloescht" ); diff --git a/sw/source/filter/html/wrthtml.hxx b/sw/source/filter/html/wrthtml.hxx index 30ea6cca7711..2f8fe1bedee9 100644 --- a/sw/source/filter/html/wrthtml.hxx +++ b/sw/source/filter/html/wrthtml.hxx @@ -300,7 +300,7 @@ public: OUString aNonConvertableCharacters; OUString aBulletGrfs[MAXLEVEL]; // die Grafiken fuer Listen - css::uno::Reference<css::container::XIndexContainer>* pxFormComps; // die aktuelle Form + css::uno::Reference<css::container::XIndexContainer> mxFormComps; // die aktuelle Form SwDoc *pTemplate; // die HTML-Vorlage Color *pDfltColor; // default Farbe diff --git a/sw/source/uibase/inc/uivwimp.hxx b/sw/source/uibase/inc/uivwimp.hxx index a1558fd82298..94c1401a44e2 100644 --- a/sw/source/uibase/inc/uivwimp.hxx +++ b/sw/source/uibase/inc/uivwimp.hxx @@ -93,7 +93,7 @@ class SwView_Impl ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > xScanEvtLstnr; ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > xClipEvtLstnr; ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterceptor > xDisProvInterceptor; - ::com::sun::star::uno::Reference< ::com::sun::star::view::XSelectionSupplier > *pxXTextView; // UNO object + ::com::sun::star::uno::Reference< ::com::sun::star::view::XSelectionSupplier > mxXTextView; // UNO object com::sun::star::uno::WeakReference< com::sun::star::lang::XUnoTunnel > xTransferable; // temporary document for printing text of selection / multi selection diff --git a/sw/source/uibase/inc/unomod.hxx b/sw/source/uibase/inc/unomod.hxx index b629a16b242a..70877da36abb 100644 --- a/sw/source/uibase/inc/unomod.hxx +++ b/sw/source/uibase/inc/unomod.hxx @@ -44,8 +44,8 @@ class SwXModule : public cppu::WeakImplHelper > { - ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > * pxViewSettings; - ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > * pxPrintSettings; + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > mxViewSettings; + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > mxPrintSettings; protected: virtual ~SwXModule(); diff --git a/sw/source/uibase/inc/unotxvw.hxx b/sw/source/uibase/inc/unotxvw.hxx index 806d11da27b9..dfa6721a7796 100644 --- a/sw/source/uibase/inc/unotxvw.hxx +++ b/sw/source/uibase/inc/unotxvw.hxx @@ -62,10 +62,10 @@ class SwXTextView : SwView* m_pView; const SfxItemPropertySet* m_pPropSet; // property map for SwXTextView properties - // (not related to pxViewSettings!) + // (not related to mxViewSettings!) - ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > * pxViewSettings; - ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextViewCursor > * pxTextViewCursor; + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > mxViewSettings; + ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextViewCursor > mxTextViewCursor; SdrObject* GetControl( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > & Model, diff --git a/sw/source/uibase/uiview/uivwimp.cxx b/sw/source/uibase/uiview/uivwimp.cxx index 7bb139335027..23ec3205ab97 100644 --- a/sw/source/uibase/uiview/uivwimp.cxx +++ b/sw/source/uibase/uiview/uivwimp.cxx @@ -55,7 +55,7 @@ using namespace ::com::sun::star::lang; using namespace ::com::sun::star::datatransfer::clipboard; SwView_Impl::SwView_Impl(SwView* pShell) - : pxXTextView(new uno::Reference<view::XSelectionSupplier>) + : mxXTextView() , pView(pShell) , pScanEvtLstnr(0) , pClipEvtLstnr(0) @@ -71,7 +71,7 @@ SwView_Impl::SwView_Impl(SwView* pShell) , m_bSelectObject(false) , m_bEditingPositionSet(false) { - *pxXTextView = new SwXTextView(pView); + mxXTextView = new SwXTextView(pView); xDisProvInterceptor = new SwXDispatchProviderInterceptor(*pView); } @@ -86,9 +86,9 @@ SwView_Impl::~SwView_Impl() { pInterceptor->Invalidate(); } - view::XSelectionSupplier* pTextView = pxXTextView->get(); + view::XSelectionSupplier* pTextView = mxXTextView.get(); static_cast<SwXTextView*>(pTextView)->Invalidate(); - delete pxXTextView; + mxXTextView.clear(); if( xScanEvtLstnr.is() ) pScanEvtLstnr->ViewDestroyed(); if( xClipEvtLstnr.is() ) @@ -110,13 +110,13 @@ void SwView_Impl::SetShellMode(ShellModes eSet) view::XSelectionSupplier* SwView_Impl::GetUNOObject() { - return pxXTextView->get(); + return mxXTextView.get(); } SwXTextView* SwView_Impl::GetUNOObject_Impl() { - view::XSelectionSupplier* pTextView = pxXTextView->get(); - return static_cast<SwXTextView*>(pTextView); + view::XSelectionSupplier* pTextView = mxXTextView.get(); + return static_cast<SwXTextView*>(pTextView); } void SwView_Impl::ExecuteScan( SfxRequest& rReq ) diff --git a/sw/source/uibase/uno/unomod.cxx b/sw/source/uibase/uno/unomod.cxx index 88374824f15f..57fba72ea608 100644 --- a/sw/source/uibase/uno/unomod.cxx +++ b/sw/source/uibase/uno/unomod.cxx @@ -194,39 +194,35 @@ static ChainablePropertySetInfo * lcl_createPrintSettingsInfo() } SwXModule::SwXModule() : - pxViewSettings(0), - pxPrintSettings(0) + mxViewSettings(), + mxPrintSettings() { } SwXModule::~SwXModule() { - delete pxViewSettings; - delete pxPrintSettings; } Reference< XPropertySet > SwXModule::getViewSettings() throw( uno::RuntimeException, std::exception ) { SolarMutexGuard aGuard; - if(!pxViewSettings) + if(!mxViewSettings.is()) { - static_cast<SwXModule*>(this)->pxViewSettings = new Reference< XPropertySet > ; OSL_FAIL("Web or Text?"); - *pxViewSettings = static_cast < HelperBaseNoState * > ( new SwXViewSettings( false, 0 ) ); + mxViewSettings = static_cast < HelperBaseNoState * > ( new SwXViewSettings( false, 0 ) ); } - return *pxViewSettings; + return mxViewSettings; } Reference< XPropertySet > SwXModule::getPrintSettings() throw( uno::RuntimeException, std::exception ) { SolarMutexGuard aGuard; - if(!pxPrintSettings) + if(!mxPrintSettings.is()) { - static_cast<SwXModule*>(this)->pxPrintSettings = new Reference< XPropertySet > ; OSL_FAIL("Web or Text?"); - *pxPrintSettings = static_cast < HelperBaseNoState * > ( new SwXPrintSettings ( PRINT_SETTINGS_MODULE ) ); + mxPrintSettings = static_cast < HelperBaseNoState * > ( new SwXPrintSettings ( PRINT_SETTINGS_MODULE ) ); } - return *pxPrintSettings; + return mxPrintSettings; } OUString SwXModule::getImplementationName() throw( RuntimeException, std::exception ) diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx index 52dfcc7fcc80..683119886911 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -378,30 +378,30 @@ SwXTextDocument::SwXTextDocument(SwDocShell* pShell) bObjectValid(pShell != 0), pDrawPage(0), - pxXDrawPage(0), + mxXDrawPage(), pBodyText(0), - pxXNumberingRules(0), - pxXFootnotes(0), - pxXFootnoteSettings(0), - pxXEndnotes(0), - pxXEndnoteSettings(0), - pxXReferenceMarks(0), - pxXTextFieldTypes(0), - pxXTextFieldMasters(0), - pxXTextSections(0), - pxXBookmarks(0), - pxXTextTables(0), - pxXTextFrames(0), - pxXGraphicObjects(0), - pxXEmbeddedObjects(0), - pxXStyleFamilies(0), - pxXAutoStyles(0), - pxXChapterNumbering(0), - pxXDocumentIndexes(0), - - pxXLineNumberingProperties(0), - pxLinkTargetSupplier(0), - pxXRedlines(0), + mxXNumberingRules(), + mxXFootnotes(), + mxXFootnoteSettings(), + mxXEndnotes(), + mxXEndnoteSettings(), + mxXReferenceMarks(), + mxXTextFieldTypes(), + mxXTextFieldMasters(), + mxXTextSections(), + mxXBookmarks(), + mxXTextTables(), + mxXTextFrames(), + mxXGraphicObjects(), + mxXEmbeddedObjects(), + mxXStyleFamilies(), + mxXAutoStyles(), + mxXChapterNumbering(), + mxXDocumentIndexes(), + + mxXLineNumberingProperties(), + mxLinkTargetSupplier(), + mxXRedlines(), m_pHiddenViewFrame(0), pPropertyHelper(0), m_pPrintUIOptions( NULL ), @@ -613,15 +613,14 @@ Reference< XPropertySet > SwXTextDocument::getLineNumberingProperties() SolarMutexGuard aGuard; if(IsValid()) { - if(!pxXLineNumberingProperties) + if(!mxXLineNumberingProperties.is()) { - pxXLineNumberingProperties = new Reference<XPropertySet>; - (*pxXLineNumberingProperties) = new SwXLineNumberingProperties(pDocShell->GetDoc()); + mxXLineNumberingProperties = new SwXLineNumberingProperties(pDocShell->GetDoc()); } } else throw RuntimeException(); - return *pxXLineNumberingProperties; + return mxXLineNumberingProperties; } Reference< XIndexReplace > SwXTextDocument::getChapterNumberingRules() @@ -630,12 +629,11 @@ Reference< XIndexReplace > SwXTextDocument::getChapterNumberingRules() SolarMutexGuard aGuard; if(!IsValid()) throw RuntimeException(); - if(!pxXChapterNumbering) + if(!mxXChapterNumbering.is()) { - pxXChapterNumbering = new Reference< XIndexReplace > ; - *pxXChapterNumbering = new SwXChapterNumbering(*pDocShell); + mxXChapterNumbering = new SwXChapterNumbering(*pDocShell); } - return *pxXChapterNumbering; + return mxXChapterNumbering; } Reference< XIndexAccess > SwXTextDocument::getNumberingRules() throw( RuntimeException, std::exception ) @@ -643,12 +641,11 @@ Reference< XIndexAccess > SwXTextDocument::getNumberingRules() throw( RuntimeEx SolarMutexGuard aGuard; if(!IsValid()) throw RuntimeException(); - if(!pxXNumberingRules ) + if(!mxXNumberingRules.is() ) { - static_cast<SwXTextDocument*>(this)->pxXNumberingRules = new Reference< XIndexAccess > ; - *pxXNumberingRules = new SwXNumberingRulesCollection( pDocShell->GetDoc() ); + mxXNumberingRules = new SwXNumberingRulesCollection( pDocShell->GetDoc() ); } - return *pxXNumberingRules; + return mxXNumberingRules; } Reference< XIndexAccess > SwXTextDocument::getFootnotes() throw( RuntimeException, std::exception ) @@ -656,12 +653,11 @@ Reference< XIndexAccess > SwXTextDocument::getFootnotes() throw( RuntimeExcepti SolarMutexGuard aGuard; if(!IsValid()) throw RuntimeException(); - if(!pxXFootnotes) + if(!mxXFootnotes.is()) { - static_cast<SwXTextDocument*>(this)->pxXFootnotes = new Reference< XIndexAccess > ; - *pxXFootnotes = new SwXFootnotes(false, pDocShell->GetDoc()); + mxXFootnotes = new SwXFootnotes(false, pDocShell->GetDoc()); } - return *pxXFootnotes; + return mxXFootnotes; } Reference< XPropertySet > SAL_CALL @@ -670,12 +666,11 @@ Reference< XPropertySet > SAL_CALL SolarMutexGuard aGuard; if(!IsValid()) throw RuntimeException(); - if(!pxXFootnoteSettings) + if(!mxXFootnoteSettings.is()) { - static_cast<SwXTextDocument*>(this)->pxXFootnoteSettings = new Reference< XPropertySet > ; - *pxXFootnoteSettings = new SwXFootnoteProperties(pDocShell->GetDoc()); + mxXFootnoteSettings = new SwXFootnoteProperties(pDocShell->GetDoc()); } - return *pxXFootnoteSettings; + return mxXFootnoteSettings; } Reference< XIndexAccess > SwXTextDocument::getEndnotes() throw( RuntimeException, std::exception ) @@ -683,12 +678,11 @@ Reference< XIndexAccess > SwXTextDocument::getEndnotes() throw( RuntimeExceptio SolarMutexGuard aGuard; if(!IsValid()) throw RuntimeException(); - if(!pxXEndnotes) + if(!mxXEndnotes.is()) { - static_cast<SwXTextDocument*>(this)->pxXEndnotes = new Reference< XIndexAccess > ; - *pxXEndnotes = new SwXFootnotes(true, pDocShell->GetDoc()); + mxXEndnotes = new SwXFootnotes(true, pDocShell->GetDoc()); } - return *pxXEndnotes; + return mxXEndnotes; } Reference< XPropertySet > SwXTextDocument::getEndnoteSettings() throw( RuntimeException, std::exception ) @@ -696,12 +690,11 @@ Reference< XPropertySet > SwXTextDocument::getEndnoteSettings() throw( RuntimeE SolarMutexGuard aGuard; if(!IsValid()) throw RuntimeException(); - if(!pxXEndnoteSettings) + if(!mxXEndnoteSettings.is()) { - static_cast<SwXTextDocument*>(this)->pxXEndnoteSettings = new Reference< XPropertySet > ; - *pxXEndnoteSettings = new SwXEndnoteProperties(pDocShell->GetDoc()); + mxXEndnoteSettings = new SwXEndnoteProperties(pDocShell->GetDoc()); } - return *pxXEndnoteSettings; + return mxXEndnoteSettings; } Reference< util::XReplaceDescriptor > SwXTextDocument::createReplaceDescriptor() @@ -1227,12 +1220,11 @@ Reference< XNameAccess > SwXTextDocument::getReferenceMarks() SolarMutexGuard aGuard; if(!IsValid()) throw RuntimeException(); - if(!pxXReferenceMarks) + if(!mxXReferenceMarks.is()) { - static_cast<SwXTextDocument*>(this)->pxXReferenceMarks = new Reference< XNameAccess > ; - *pxXReferenceMarks = new SwXReferenceMarks(pDocShell->GetDoc()); + mxXReferenceMarks = new SwXReferenceMarks(pDocShell->GetDoc()); } - return *pxXReferenceMarks; + return mxXReferenceMarks; } Reference< XEnumerationAccess > SwXTextDocument::getTextFields() throw( RuntimeException, std::exception ) @@ -1240,12 +1232,11 @@ Reference< XEnumerationAccess > SwXTextDocument::getTextFields() throw( Runtime SolarMutexGuard aGuard; if(!IsValid()) throw RuntimeException(); - if(!pxXTextFieldTypes) + if(!mxXTextFieldTypes.is()) { - static_cast<SwXTextDocument*>(this)->pxXTextFieldTypes = new Reference< XEnumerationAccess > ; - *pxXTextFieldTypes = new SwXTextFieldTypes(pDocShell->GetDoc()); + mxXTextFieldTypes = new SwXTextFieldTypes(pDocShell->GetDoc()); } - return *pxXTextFieldTypes; + return mxXTextFieldTypes; } Reference< XNameAccess > SwXTextDocument::getTextFieldMasters() @@ -1254,12 +1245,11 @@ Reference< XNameAccess > SwXTextDocument::getTextFieldMasters() SolarMutexGuard aGuard; if(!IsValid()) throw RuntimeException(); - if(!pxXTextFieldMasters) + if(!mxXTextFieldMasters.is()) { - static_cast<SwXTextDocument*>(this)->pxXTextFieldMasters = new Reference< XNameAccess > ; - *pxXTextFieldMasters = new SwXTextFieldMasters(pDocShell->GetDoc()); + mxXTextFieldMasters = new SwXTextFieldMasters(pDocShell->GetDoc()); } - return *pxXTextFieldMasters; + return mxXTextFieldMasters; } Reference< XNameAccess > SwXTextDocument::getEmbeddedObjects() throw( RuntimeException, std::exception ) @@ -1267,12 +1257,11 @@ Reference< XNameAccess > SwXTextDocument::getEmbeddedObjects() throw( RuntimeEx SolarMutexGuard aGuard; if(!IsValid()) throw RuntimeException(); - if(!pxXEmbeddedObjects) + if(!mxXEmbeddedObjects.is()) { - static_cast<SwXTextDocument*>(this)->pxXEmbeddedObjects = new Reference< XNameAccess > ; - *pxXEmbeddedObjects = new SwXTextEmbeddedObjects(pDocShell->GetDoc()); + mxXEmbeddedObjects = new SwXTextEmbeddedObjects(pDocShell->GetDoc()); } - return *pxXEmbeddedObjects; + return mxXEmbeddedObjects; } Reference< XNameAccess > SwXTextDocument::getBookmarks() throw( RuntimeException, std::exception ) @@ -1280,12 +1269,11 @@ Reference< XNameAccess > SwXTextDocument::getBookmarks() throw( RuntimeExceptio SolarMutexGuard aGuard; if(!IsValid()) throw RuntimeException(); - if(!pxXBookmarks) + if(!mxXBookmarks.is()) { - static_cast<SwXTextDocument*>(this)->pxXBookmarks = new Reference< XNameAccess > ; - *pxXBookmarks = new SwXBookmarks(pDocShell->GetDoc()); + mxXBookmarks = new SwXBookmarks(pDocShell->GetDoc()); } - return *pxXBookmarks; + return mxXBookmarks; } Reference< XNameAccess > SwXTextDocument::getTextSections() throw( RuntimeException, std::exception ) @@ -1293,12 +1281,11 @@ Reference< XNameAccess > SwXTextDocument::getTextSections() throw( RuntimeExcep SolarMutexGuard aGuard; if(!IsValid()) throw RuntimeException(); - if(!pxXTextSections) + if(!mxXTextSections.is()) { - static_cast<SwXTextDocument*>(this)->pxXTextSections = new Reference< XNameAccess > ; - *pxXTextSections = new SwXTextSections(pDocShell->GetDoc()); + mxXTextSections = new SwXTextSections(pDocShell->GetDoc()); } - return *pxXTextSections; + return mxXTextSections; } Reference< XNameAccess > SwXTextDocument::getTextTables() throw( RuntimeException, std::exception ) @@ -1306,12 +1293,11 @@ Reference< XNameAccess > SwXTextDocument::getTextTables() throw( RuntimeExcepti SolarMutexGuard aGuard; if(!IsValid()) throw RuntimeException(); - if(!pxXTextTables) + if(!mxXTextTables.is()) { - static_cast<SwXTextDocument*>(this)->pxXTextTables = new Reference< XNameAccess > ; - *pxXTextTables = new SwXTextTables(pDocShell->GetDoc()); + mxXTextTables = new SwXTextTables(pDocShell->GetDoc()); } - return *pxXTextTables; + return mxXTextTables; } Reference< XNameAccess > SwXTextDocument::getGraphicObjects() throw( RuntimeException, std::exception ) @@ -1319,12 +1305,11 @@ Reference< XNameAccess > SwXTextDocument::getGraphicObjects() throw( RuntimeExc SolarMutexGuard aGuard; if(!IsValid()) throw RuntimeException(); - if(!pxXGraphicObjects) + if(!mxXGraphicObjects.is()) { - static_cast<SwXTextDocument*>(this)->pxXGraphicObjects = new Reference< XNameAccess > ; - *pxXGraphicObjects = new SwXTextGraphicObjects(pDocShell->GetDoc()); + mxXGraphicObjects = new SwXTextGraphicObjects(pDocShell->GetDoc()); } - return *pxXGraphicObjects; + return mxXGraphicObjects; } Reference< XNameAccess > SwXTextDocument::getTextFrames() throw( RuntimeException, std::exception ) @@ -1332,12 +1317,11 @@ Reference< XNameAccess > SwXTextDocument::getTextFrames() throw( RuntimeExcepti SolarMutexGuard aGuard; if(!IsValid()) throw RuntimeException(); - if(!pxXTextFrames) + if(!mxXTextFrames.is()) { - static_cast<SwXTextDocument*>(this)->pxXTextFrames = new Reference< XNameAccess > ; - *pxXTextFrames = new SwXTextFrames(pDocShell->GetDoc()); + mxXTextFrames = new SwXTextFrames(pDocShell->GetDoc()); } - return *pxXTextFrames; + return mxXTextFrames; } Reference< XNameAccess > SwXTextDocument::getStyleFamilies() throw( RuntimeException, std::exception ) @@ -1345,12 +1329,11 @@ Reference< XNameAccess > SwXTextDocument::getStyleFamilies() throw( RuntimeExce SolarMutexGuard aGuard; if(!IsValid()) throw RuntimeException(); - if(!pxXStyleFamilies) + if(!mxXStyleFamilies.is()) { - static_cast<SwXTextDocument*>(this)->pxXStyleFamilies = new Reference< XNameAccess > ; - *pxXStyleFamilies = new SwXStyleFamilies(*pDocShell); + mxXStyleFamilies = new SwXStyleFamilies(*pDocShell); } - return *pxXStyleFamilies; + return mxXStyleFamilies; } uno::Reference< style::XAutoStyles > SwXTextDocument::getAutoStyles( ) @@ -1359,12 +1342,11 @@ uno::Reference< style::XAutoStyles > SwXTextDocument::getAutoStyles( ) SolarMutexGuard aGuard; if(!IsValid()) throw RuntimeException(); - if(!pxXAutoStyles) + if(!mxXAutoStyles.is()) { - pxXAutoStyles = new Reference< style::XAutoStyles > ; - *pxXAutoStyles = new SwXAutoStyles(*pDocShell); + mxXAutoStyles = new SwXAutoStyles(*pDocShell); } - return *pxXAutoStyles; + return mxXAutoStyles; } @@ -1373,17 +1355,17 @@ Reference< drawing::XDrawPage > SwXTextDocument::getDrawPage() throw( RuntimeEx SolarMutexGuard aGuard; if(!IsValid()) throw RuntimeException(); - if(!pxXDrawPage) + if(!mxXDrawPage.is()) { static_cast<SwXTextDocument*>(this)->pDrawPage = new SwXDrawPage(pDocShell->GetDoc()); - static_cast<SwXTextDocument*>(this)->pxXDrawPage = new Reference< drawing::XDrawPage >(pDrawPage); + static_cast<SwXTextDocument*>(this)->mxXDrawPage = pDrawPage; // Create a Reference to trigger the complete initialization of the // object. Otherwise in some corner cases it would get initialized // at ::InitNewDoc -> which would get called during // close() or dispose() -> n#681746 - uno::Reference<lang::XComponent> xComp( *pxXDrawPage, uno::UNO_QUERY ); + uno::Reference<lang::XComponent> xComp( mxXDrawPage, uno::UNO_QUERY ); } - return *pxXDrawPage; + return mxXDrawPage; } void SwXTextDocument::Invalidate() @@ -1420,36 +1402,32 @@ void SwXTextDocument::Reactivate(SwDocShell* pNewDocShell) void SwXTextDocument::InitNewDoc() { // first invalidate all collections, then delete references and Set to zero - if(pxXTextTables) + if(mxXTextTables.is()) { - XNameAccess* pTables = pxXTextTables->get(); + XNameAccess* pTables = mxXTextTables.get(); static_cast<SwXTextTables*>(pTables)->Invalidate(); - delete pxXTextTables; - pxXTextTables = 0; + mxXTextTables.clear(); } - if(pxXTextFrames) + if(mxXTextFrames.is()) { - XNameAccess* pFrms = pxXTextFrames->get(); + XNameAccess* pFrms = mxXTextFrames.get(); static_cast<SwXTextFrames*>(pFrms)->Invalidate(); - delete pxXTextFrames; - pxXTextFrames = 0; + mxXTextFrames.clear(); } - if(pxXGraphicObjects) + if(mxXGraphicObjects.is()) { - XNameAccess* pFrms = pxXGraphicObjects->get(); + XNameAccess* pFrms = mxXGraphicObjects.get(); static_cast<SwXTextGraphicObjects*>(pFrms)->Invalidate(); - delete pxXGraphicObjects; - pxXGraphicObjects = 0; + mxXGraphicObjects.clear(); } - if(pxXEmbeddedObjects) + if(mxXEmbeddedObjects.is()) { - XNameAccess* pOLE = pxXEmbeddedObjects->get(); + XNameAccess* pOLE = mxXEmbeddedObjects.get(); static_cast<SwXTextEmbeddedObjects*>(pOLE)->Invalidate(); - delete pxXEmbeddedObjects; - pxXEmbeddedObjects = 0; + mxXEmbeddedObjects.clear(); } if(xBodyText.is()) @@ -1475,147 +1453,129 @@ void SwXTextDocument::InitNewDoc() pNumFormat->SetNumberFormatter(0); } - if(pxXTextFieldTypes) + if(mxXTextFieldTypes.is()) { - XEnumerationAccess* pT = pxXTextFieldTypes->get(); + XEnumerationAccess* pT = mxXTextFieldTypes.get(); static_cast<SwXTextFieldTypes*>(pT)->Invalidate(); - delete pxXTextFieldTypes; - pxXTextFieldTypes = 0; + mxXTextFieldTypes.clear(); } - if(pxXTextFieldMasters) + if(mxXTextFieldMasters.is()) { - XNameAccess* pT = pxXTextFieldMasters->get(); + XNameAccess* pT = mxXTextFieldMasters.get(); static_cast<SwXTextFieldMasters*>(pT)->Invalidate(); - delete pxXTextFieldMasters; - pxXTextFieldMasters = 0; + mxXTextFieldMasters.clear(); } - if(pxXTextSections) + if(mxXTextSections.is()) { - XNameAccess* pSect = pxXTextSections->get(); + XNameAccess* pSect = mxXTextSections.get(); static_cast<SwXTextSections*>(pSect)->Invalidate(); - delete pxXTextSections; - pxXTextSections = 0; + mxXTextSections.clear(); } - if(pxXDrawPage) + if(mxXDrawPage.is()) { // #i91798#, #i91895# // dispose XDrawPage here. We are the owner and know that it is no longer in a valid condition. - uno::Reference<lang::XComponent> xComp( *pxXDrawPage, uno::UNO_QUERY ); + uno::Reference<lang::XComponent> xComp( mxXDrawPage, uno::UNO_QUERY ); xComp->dispose(); pDrawPage->InvalidateSwDoc(); - delete pxXDrawPage; - pxXDrawPage = 0; + mxXDrawPage.clear(); } - if ( pxXNumberingRules ) + if ( mxXNumberingRules.is() ) { - XIndexAccess* pNum = pxXNumberingRules->get(); + XIndexAccess* pNum = mxXNumberingRules.get(); static_cast<SwXNumberingRulesCollection*>(pNum)->Invalidate(); - delete pxXNumberingRules; - pxXNumberingRules = 0; + mxXNumberingRules.clear(); } - if(pxXFootnotes) + if(mxXFootnotes.is()) { - XIndexAccess* pFootnote = pxXFootnotes->get(); + XIndexAccess* pFootnote = mxXFootnotes.get(); static_cast<SwXFootnotes*>(pFootnote)->Invalidate(); - delete pxXFootnotes; - pxXFootnotes = 0; + mxXFootnotes.clear(); } - if(pxXEndnotes) + if(mxXEndnotes.is()) { - XIndexAccess* pFootnote = pxXEndnotes->get(); + XIndexAccess* pFootnote = mxXEndnotes.get(); static_cast<SwXFootnotes*>(pFootnote)->Invalidate(); - delete pxXEndnotes; - pxXEndnotes = 0; + mxXEndnotes.clear(); } - if(pxXDocumentIndexes) + if(mxXDocumentIndexes.is()) { - XIndexAccess* pIdxs = pxXDocumentIndexes->get(); + XIndexAccess* pIdxs = mxXDocumentIndexes.get(); static_cast<SwXDocumentIndexes*>(pIdxs)->Invalidate(); - delete pxXDocumentIndexes; - pxXDocumentIndexes = 0; + mxXDocumentIndexes.clear(); } - if(pxXStyleFamilies) + if(mxXStyleFamilies.is()) { - XNameAccess* pStyles = pxXStyleFamilies->get(); + XNameAccess* pStyles = mxXStyleFamilies.get(); static_cast<SwXStyleFamilies*>(pStyles)->Invalidate(); - delete pxXStyleFamilies; - pxXStyleFamilies = 0; + mxXStyleFamilies.clear(); } - if(pxXAutoStyles) + if(mxXAutoStyles.is()) { - XNameAccess* pStyles = pxXAutoStyles->get(); + XNameAccess* pStyles = mxXAutoStyles.get(); static_cast<SwXAutoStyles*>(pStyles)->Invalidate(); - delete pxXAutoStyles; - pxXAutoStyles = 0; + mxXAutoStyles.clear(); } - if(pxXBookmarks) + if(mxXBookmarks.is()) { - XNameAccess* pBm = pxXBookmarks->get(); + XNameAccess* pBm = mxXBookmarks.get(); static_cast<SwXBookmarks*>(pBm)->Invalidate(); - delete pxXBookmarks; - pxXBookmarks = 0; + mxXBookmarks.clear(); } - if(pxXChapterNumbering) + if(mxXChapterNumbering.is()) { - XIndexReplace* pCh = pxXChapterNumbering->get(); + XIndexReplace* pCh = mxXChapterNumbering.get(); static_cast<SwXChapterNumbering*>(pCh)->Invalidate(); - delete pxXChapterNumbering; - pxXChapterNumbering = 0; + mxXChapterNumbering.clear(); } - if(pxXFootnoteSettings) + if(mxXFootnoteSettings.is()) { - XPropertySet* pFntSet = pxXFootnoteSettings->get(); + XPropertySet* pFntSet = mxXFootnoteSettings.get(); static_cast<SwXFootnoteProperties*>(pFntSet)->Invalidate(); - delete pxXFootnoteSettings; - pxXFootnoteSettings = 0; + mxXFootnoteSettings.clear(); } - if(pxXEndnoteSettings) + if(mxXEndnoteSettings.is()) { - XPropertySet* pEndSet = pxXEndnoteSettings->get(); + XPropertySet* pEndSet = mxXEndnoteSettings.get(); static_cast<SwXEndnoteProperties*>(pEndSet)->Invalidate(); - delete pxXEndnoteSettings; - pxXEndnoteSettings = 0; + mxXEndnoteSettings.clear(); } - if(pxXLineNumberingProperties) + if(mxXLineNumberingProperties.is()) { - XPropertySet* pLine = pxXLineNumberingProperties->get(); + XPropertySet* pLine = mxXLineNumberingProperties.get(); static_cast<SwXLineNumberingProperties*>(pLine)->Invalidate(); - delete pxXLineNumberingProperties; - pxXLineNumberingProperties = 0; + mxXLineNumberingProperties.clear(); } - if(pxXReferenceMarks) + if(mxXReferenceMarks.is()) { - XNameAccess* pMarks = pxXReferenceMarks->get(); + XNameAccess* pMarks = mxXReferenceMarks.get(); static_cast<SwXReferenceMarks*>(pMarks)->Invalidate(); - delete pxXReferenceMarks; - pxXReferenceMarks = 0; + mxXReferenceMarks.clear(); } - if(pxLinkTargetSupplier) + if(mxLinkTargetSupplier.is()) { - XNameAccess* pAccess = (*pxLinkTargetSupplier).get(); + XNameAccess* pAccess = mxLinkTargetSupplier.get(); static_cast<SwXLinkTargetSupplier*>(pAccess)->Invalidate(); - delete pxLinkTargetSupplier; - pxLinkTargetSupplier = 0; + mxLinkTargetSupplier.clear(); } - if(pxXRedlines) + if(mxXRedlines.is()) { - XEnumerationAccess* pMarks = pxXRedlines->get(); + XEnumerationAccess* pMarks = mxXRedlines.get(); static_cast<SwXRedlines*>(pMarks)->Invalidate(); - delete pxXRedlines; - pxXRedlines = 0; + mxXRedlines.clear(); } if(xPropertyHelper.is()) { @@ -1805,12 +1765,11 @@ Reference< XIndexAccess > SwXTextDocument::getDocumentIndexes() throw( RuntimeE SolarMutexGuard aGuard; if(!IsValid()) throw RuntimeException(); - if(!pxXDocumentIndexes) + if(!mxXDocumentIndexes.is()) { - static_cast<SwXTextDocument*>(this)->pxXDocumentIndexes = new Reference< XIndexAccess > ; - *pxXDocumentIndexes = new SwXDocumentIndexes(pDocShell->GetDoc()); + mxXDocumentIndexes = new SwXDocumentIndexes(pDocShell->GetDoc()); } - return *pxXDocumentIndexes; + return mxXDocumentIndexes; } Reference< XPropertySetInfo > SwXTextDocument::getPropertySetInfo() throw( RuntimeException, std::exception ) @@ -2186,22 +2145,20 @@ void SwXTextDocument::removeVetoableChangeListener(const OUString& /*PropertyNam Reference< XNameAccess > SwXTextDocument::getLinks() throw( RuntimeException, std::exception ) { - if(!pxLinkTargetSupplier) + if(!mxLinkTargetSupplier.is()) { - pxLinkTargetSupplier = new Reference< XNameAccess > ; - (*pxLinkTargetSupplier) = new SwXLinkTargetSupplier(*this); + mxLinkTargetSupplier = new SwXLinkTargetSupplier(*this); } - return (*pxLinkTargetSupplier); + return mxLinkTargetSupplier; } Reference< XEnumerationAccess > SwXTextDocument::getRedlines( ) throw(RuntimeException, std::exception) { - if(!pxXRedlines) + if(!mxXRedlines.is()) { - pxXRedlines = new Reference< XEnumerationAccess > ; - (*pxXRedlines) = new SwXRedlines(pDocShell->GetDoc()); + mxXRedlines = new SwXRedlines(pDocShell->GetDoc()); } - return *pxXRedlines; + return mxXRedlines; } void SwXTextDocument::NotifyRefreshListeners() diff --git a/sw/source/uibase/uno/unotxvw.cxx b/sw/source/uibase/uno/unotxvw.cxx index 9b8a22effcf2..2871760addac 100644 --- a/sw/source/uibase/uno/unotxvw.cxx +++ b/sw/source/uibase/uno/unotxvw.cxx @@ -92,8 +92,8 @@ SwXTextView::SwXTextView(SwView* pSwView) : m_SelChangedListeners(m_aMutex), m_pView(pSwView), m_pPropSet( aSwMapProvider.GetPropertySet( PROPERTY_MAP_TEXT_VIEW ) ), - pxViewSettings(0), - pxTextViewCursor(0) + mxViewSettings(), + mxTextViewCursor() { } @@ -105,17 +105,17 @@ SwXTextView::~SwXTextView() void SwXTextView::Invalidate() { - if(pxViewSettings) + if(mxViewSettings.is()) { - HelperBaseNoState *pSettings = static_cast < HelperBaseNoState * > ( pxViewSettings->get() ); + HelperBaseNoState *pSettings = static_cast < HelperBaseNoState * > ( mxViewSettings.get() ); static_cast < SwXViewSettings* > ( pSettings )->Invalidate(); - DELETEZ(pxViewSettings); + mxViewSettings.clear(); } - if(pxTextViewCursor) + if(mxTextViewCursor.is()) { - text::XTextViewCursor* pCrsr = pxTextViewCursor->get(); + text::XTextViewCursor* pCrsr = mxTextViewCursor.get(); static_cast<SwXTextViewCursor*>(pCrsr)->Invalidate(); - DELETEZ(pxTextViewCursor); + mxTextViewCursor.clear(); } m_refCount++; //prevent second d'tor call @@ -497,12 +497,11 @@ uno::Reference< text::XTextViewCursor > SwXTextView::getViewCursor() throw( uno SolarMutexGuard aGuard; if(GetView()) { - if(!pxTextViewCursor) + if(!mxTextViewCursor.is()) { - static_cast<SwXTextView*>(this)->pxTextViewCursor = new uno::Reference< text::XTextViewCursor > ; - *pxTextViewCursor = new SwXTextViewCursor(GetView()); + mxTextViewCursor = new SwXTextViewCursor(GetView()); } - return *pxTextViewCursor; + return mxTextViewCursor; } else throw uno::RuntimeException(); @@ -513,15 +512,14 @@ uno::Reference< beans::XPropertySet > SwXTextView::getViewSettings() throw( uno SolarMutexGuard aGuard; if(m_pView) { - if(!pxViewSettings) + if(!mxViewSettings.is()) { - static_cast<SwXTextView*>(this)->pxViewSettings = new uno::Reference< beans::XPropertySet > ; - *pxViewSettings = static_cast < HelperBaseNoState * > ( new SwXViewSettings( false, m_pView ) ); + mxViewSettings = static_cast < HelperBaseNoState * > ( new SwXViewSettings( false, m_pView ) ); } } else throw uno::RuntimeException(); - return *pxViewSettings; + return mxViewSettings; } Sequence< Sequence< PropertyValue > > SwXTextView::getRubyList( sal_Bool /*bAutomatic*/ ) |