summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Tardon <dtardon@redhat.com>2016-09-08 11:28:31 +0200
committerDavid Tardon <dtardon@redhat.com>2016-09-09 07:30:30 +0200
commit7977914ae7614657575f7d1ae2cf86f7ad69a580 (patch)
tree37d044a939849e10860362da390e7c93eaac2c7a
parent3ef084c9bd7a7952a0e69efb9dbda81473c7856b (diff)
remove direct memory management
Change-Id: I9ab3fccd5b8a0cc64bfe7b70ed7a3e36d0e58a33
-rw-r--r--xmloff/source/draw/ximpstyl.cxx67
-rw-r--r--xmloff/source/draw/ximpstyl.hxx11
2 files changed, 24 insertions, 54 deletions
diff --git a/xmloff/source/draw/ximpstyl.cxx b/xmloff/source/draw/ximpstyl.cxx
index aee1d7b5debf..5a4266850089 100644
--- a/xmloff/source/draw/ximpstyl.cxx
+++ b/xmloff/source/draw/ximpstyl.cxx
@@ -379,8 +379,7 @@ SdXMLPageMasterContext::SdXMLPageMasterContext(
sal_uInt16 nPrfx,
const OUString& rLName,
const uno::Reference< xml::sax::XAttributeList>& xAttrList)
-: SvXMLStyleContext(rImport, nPrfx, rLName, xAttrList, XML_STYLE_FAMILY_SD_PAGEMASTERCONEXT_ID),
- mpPageMasterStyle( nullptr )
+: SvXMLStyleContext(rImport, nPrfx, rLName, xAttrList, XML_STYLE_FAMILY_SD_PAGEMASTERCONEXT_ID)
{
// set family to something special at SvXMLStyleContext
// for differences in search-methods
@@ -405,16 +404,6 @@ SdXMLPageMasterContext::SdXMLPageMasterContext(
}
}
-SdXMLPageMasterContext::~SdXMLPageMasterContext()
-{
- // release remembered contexts, they are no longer needed
- if(mpPageMasterStyle)
- {
- mpPageMasterStyle->ReleaseRef();
- mpPageMasterStyle = nullptr;
- }
-}
-
SvXMLImportContext *SdXMLPageMasterContext::CreateChildContext(
sal_uInt16 nPrefix,
const OUString& rLocalName,
@@ -424,12 +413,9 @@ SvXMLImportContext *SdXMLPageMasterContext::CreateChildContext(
if(nPrefix == XML_NAMESPACE_STYLE && IsXMLToken( rLocalName, XML_PAGE_LAYOUT_PROPERTIES) )
{
- pContext = new SdXMLPageMasterStyleContext(GetSdImport(), nPrefix, rLocalName, xAttrList);
-
- // remember SdXMLPresentationPlaceholderContext for later evaluation
- pContext->AddFirstRef();
- DBG_ASSERT(!mpPageMasterStyle, "PageMasterStyle is set, there seem to be two of them (!)");
- mpPageMasterStyle = static_cast<SdXMLPageMasterStyleContext*>(pContext);
+ DBG_ASSERT(!mxPageMasterStyle.is(), "PageMasterStyle is set, there seem to be two of them (!)");
+ mxPageMasterStyle.set(new SdXMLPageMasterStyleContext(GetSdImport(), nPrefix, rLocalName, xAttrList));
+ pContext = mxPageMasterStyle.get();
}
// call base class
@@ -465,10 +451,6 @@ SdXMLPresentationPageLayoutContext::SdXMLPresentationPageLayoutContext(
}
}
-SdXMLPresentationPageLayoutContext::~SdXMLPresentationPageLayoutContext()
-{
-}
-
SvXMLImportContext *SdXMLPresentationPageLayoutContext::CreateChildContext(
sal_uInt16 nPrefix,
const OUString& rLocalName,
@@ -478,13 +460,13 @@ SvXMLImportContext *SdXMLPresentationPageLayoutContext::CreateChildContext(
if(nPrefix == XML_NAMESPACE_PRESENTATION && IsXMLToken( rLocalName, XML_PLACEHOLDER ) )
{
+ const uno::Reference< SdXMLPresentationPlaceholderContext > xContext{
+ new SdXMLPresentationPlaceholderContext(GetSdImport(), nPrefix, rLocalName, xAttrList)};
// presentation:placeholder inside style:presentation-page-layout context
- pContext = new SdXMLPresentationPlaceholderContext(
- GetSdImport(), nPrefix, rLocalName, xAttrList);
+ pContext = xContext.get();
// remember SdXMLPresentationPlaceholderContext for later evaluation
- pContext->AddFirstRef();
- maList.push_back( static_cast<SdXMLPresentationPlaceholderContext*>(pContext) );
+ maList.push_back( xContext );
}
// call base class
@@ -501,7 +483,7 @@ void SdXMLPresentationPageLayoutContext::EndElement()
// at the moment only use number of types used there
if( !maList.empty() )
{
- SdXMLPresentationPlaceholderContext* pObj0 = maList[ 0 ];
+ SdXMLPresentationPlaceholderContext* pObj0 = maList[ 0 ].get();
if( pObj0->GetName() == "handout" )
{
switch( maList.size() )
@@ -543,7 +525,7 @@ void SdXMLPresentationPageLayoutContext::EndElement()
}
case 2:
{
- SdXMLPresentationPlaceholderContext* pObj1 = maList[ 1 ];
+ SdXMLPresentationPlaceholderContext* pObj1 = maList[ 1 ].get();
if( pObj1->GetName() == "subtitle" )
{
@@ -586,8 +568,8 @@ void SdXMLPresentationPageLayoutContext::EndElement()
}
case 3:
{
- SdXMLPresentationPlaceholderContext* pObj1 = maList[ 1 ];
- SdXMLPresentationPlaceholderContext* pObj2 = maList[ 2 ];
+ SdXMLPresentationPlaceholderContext* pObj1 = maList[ 1 ].get();
+ SdXMLPresentationPlaceholderContext* pObj2 = maList[ 2 ].get();
if( pObj1->GetName() == "outline" )
{
@@ -651,8 +633,8 @@ void SdXMLPresentationPageLayoutContext::EndElement()
}
case 4:
{
- SdXMLPresentationPlaceholderContext* pObj1 = maList[ 1 ];
- SdXMLPresentationPlaceholderContext* pObj2 = maList[ 2 ];
+ SdXMLPresentationPlaceholderContext* pObj1 = maList[ 1 ].get();
+ SdXMLPresentationPlaceholderContext* pObj2 = maList[ 2 ].get();
if( pObj1->GetName() == "object" )
{
@@ -673,7 +655,7 @@ void SdXMLPresentationPageLayoutContext::EndElement()
}
case 5:
{
- SdXMLPresentationPlaceholderContext* pObj1 = maList[ 1 ];
+ SdXMLPresentationPlaceholderContext* pObj1 = maList[ 1 ].get();
if( pObj1->GetName() == "object" )
{
@@ -700,8 +682,6 @@ void SdXMLPresentationPageLayoutContext::EndElement()
}
// release remembered contexts, they are no longer needed
- for ( size_t i = maList.size(); i > 0; )
- maList[ --i ]->ReleaseRef();
maList.clear();
}
}
@@ -1459,13 +1439,6 @@ SdXMLMasterStylesContext::SdXMLMasterStylesContext(
{
}
-SdXMLMasterStylesContext::~SdXMLMasterStylesContext()
-{
- for ( size_t i = maMasterPageList.size(); i > 0; )
- maMasterPageList[ --i ]->ReleaseRef();
- maMasterPageList.clear();
-}
-
SvXMLImportContext* SdXMLMasterStylesContext::CreateChildContext(
sal_uInt16 nPrefix,
const OUString& rLocalName,
@@ -1501,11 +1474,11 @@ SvXMLImportContext* SdXMLMasterStylesContext::CreateChildContext(
uno::Reference< drawing::XShapes > xNewShapes(xNewMasterPage, uno::UNO_QUERY);
if(xNewShapes.is() && GetSdImport().GetShapeImport()->GetStylesContext())
{
- pContext = new SdXMLMasterPageContext(GetSdImport(),
- nPrefix, rLocalName, xAttrList, xNewShapes);
-
- pContext->AddFirstRef();
- maMasterPageList.push_back( static_cast<SdXMLMasterPageContext*>(pContext) );
+ const uno::Reference<SdXMLMasterPageContext> xContext{
+ new SdXMLMasterPageContext(GetSdImport(),
+ nPrefix, rLocalName, xAttrList, xNewShapes)};
+ pContext = xContext.get();
+ maMasterPageList.push_back(xContext);
}
}
}
diff --git a/xmloff/source/draw/ximpstyl.hxx b/xmloff/source/draw/ximpstyl.hxx
index 6e1c5c08f2ad..788e3e48a7d8 100644
--- a/xmloff/source/draw/ximpstyl.hxx
+++ b/xmloff/source/draw/ximpstyl.hxx
@@ -68,7 +68,7 @@ public:
class SdXMLPageMasterContext: public SvXMLStyleContext
{
OUString msName;
- SdXMLPageMasterStyleContext*mpPageMasterStyle;
+ css::uno::Reference<SdXMLPageMasterStyleContext> mxPageMasterStyle;
const SdXMLImport& GetSdImport() const { return static_cast<const SdXMLImport&>(GetImport()); }
SdXMLImport& GetSdImport() { return static_cast<SdXMLImport&>(GetImport()); }
@@ -80,13 +80,12 @@ public:
sal_uInt16 nPrfx,
const OUString& rLName,
const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList);
- virtual ~SdXMLPageMasterContext();
virtual SvXMLImportContext *CreateChildContext(
sal_uInt16 nPrefix, const OUString& rLocalName,
const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList ) override;
- const SdXMLPageMasterStyleContext* GetPageMasterStyle() const { return mpPageMasterStyle; }
+ const SdXMLPageMasterStyleContext* GetPageMasterStyle() const { return mxPageMasterStyle.get(); }
};
// style:masterpage context
@@ -148,7 +147,7 @@ public:
class SdXMLPresentationPageLayoutContext: public SvXMLStyleContext
{
OUString msName;
- std::vector< SdXMLPresentationPlaceholderContext* >
+ std::vector< css::uno::Reference< SdXMLPresentationPlaceholderContext > >
maList;
sal_uInt16 mnTypeId;
@@ -162,7 +161,6 @@ public:
sal_uInt16 nPrfx,
const OUString& rLName,
const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList);
- virtual ~SdXMLPresentationPageLayoutContext();
virtual SvXMLImportContext *CreateChildContext(
sal_uInt16 nPrefix, const OUString& rLocalName,
@@ -228,7 +226,7 @@ public:
class SdXMLMasterStylesContext : public SvXMLImportContext
{
- std::vector< SdXMLMasterPageContext* > maMasterPageList;
+ std::vector< css::uno::Reference< SdXMLMasterPageContext > > maMasterPageList;
const SdXMLImport& GetSdImport() const { return static_cast<const SdXMLImport&>(GetImport()); }
SdXMLImport& GetSdImport() { return static_cast<SdXMLImport&>(GetImport()); }
@@ -238,7 +236,6 @@ public:
SdXMLMasterStylesContext(
SdXMLImport& rImport,
const OUString& rLName);
- virtual ~SdXMLMasterStylesContext();
virtual SvXMLImportContext* CreateChildContext(
sal_uInt16 nPrefix,