[Libreoffice-commits] core.git: 15 commits - include/xmloff writerperfect/inc writerperfect/qa writerperfect/source xmloff/inc xmloff/source
David Tardon
dtardon at redhat.com
Fri Sep 9 10:14:54 UTC 2016
include/xmloff/SchXMLImportHelper.hxx | 25 +-
include/xmloff/shapeimport.hxx | 2
include/xmloff/xmlnumfi.hxx | 4
writerperfect/inc/WPXSvInputStream.hxx | 2
writerperfect/qa/unit/DirectoryStreamTest.cxx | 13 -
writerperfect/source/calc/StarOfficeCalcImportFilter.cxx | 2
writerperfect/source/common/WPXSvInputStream.cxx | 10
writerperfect/source/draw/StarOfficeDrawImportFilter.cxx | 2
writerperfect/source/draw/ZMFImportFilter.cxx | 2
writerperfect/source/writer/StarOfficeWriterImportFilter.cxx | 11
xmloff/inc/animationimport.hxx | 7
xmloff/inc/animimp.hxx | 5
xmloff/inc/xexptran.hxx | 11
xmloff/source/chart/MultiPropertySetHandler.hxx | 30 --
xmloff/source/chart/SchXMLImport.cxx | 54 +---
xmloff/source/draw/animationimport.cxx | 34 --
xmloff/source/draw/animimp.cxx | 13 -
xmloff/source/draw/shapeimport.cxx | 29 --
xmloff/source/draw/xexptran.cxx | 135 ++---------
xmloff/source/draw/ximpcustomshape.cxx | 23 -
xmloff/source/draw/ximpshap.cxx | 26 --
xmloff/source/draw/ximpshap.hxx | 3
xmloff/source/draw/ximpstyl.cxx | 11
xmloff/source/draw/ximpstyl.hxx | 6
xmloff/source/style/xmlnumfi.cxx | 46 +--
25 files changed, 173 insertions(+), 333 deletions(-)
New commits:
commit 43c6b20b9fef7b6d331ae15cfcc9fd2632799584
Author: David Tardon <dtardon at redhat.com>
Date: Fri Sep 9 11:44:18 2016 +0200
use std::unique_ptr
Change-Id: I46dd045b2648f711b3e29ffea0c2e264c141293c
diff --git a/xmloff/source/style/xmlnumfi.cxx b/xmloff/source/style/xmlnumfi.cxx
index 9d035e4..e2b0f8d 100644
--- a/xmloff/source/style/xmlnumfi.cxx
+++ b/xmloff/source/style/xmlnumfi.cxx
@@ -65,11 +65,11 @@ struct SvXMLNumFmtEntry
class SvXMLNumImpData
{
SvNumberFormatter* pFormatter;
- SvXMLTokenMap* pStylesElemTokenMap;
- SvXMLTokenMap* pStyleElemTokenMap;
- SvXMLTokenMap* pStyleAttrTokenMap;
- SvXMLTokenMap* pStyleElemAttrTokenMap;
- LocaleDataWrapper* pLocaleData;
+ std::unique_ptr<SvXMLTokenMap> pStylesElemTokenMap;
+ std::unique_ptr<SvXMLTokenMap> pStyleElemTokenMap;
+ std::unique_ptr<SvXMLTokenMap> pStyleAttrTokenMap;
+ std::unique_ptr<SvXMLTokenMap> pStyleElemAttrTokenMap;
+ std::unique_ptr<LocaleDataWrapper> pLocaleData;
std::vector<SvXMLNumFmtEntry> m_NameEntries;
uno::Reference< uno::XComponentContext > m_xContext;
@@ -78,7 +78,6 @@ public:
SvXMLNumImpData(
SvNumberFormatter* pFmt,
const uno::Reference<uno::XComponentContext>& rxContext );
- ~SvXMLNumImpData();
SvNumberFormatter* GetNumberFormatter() const { return pFormatter; }
const SvXMLTokenMap& GetStylesElemTokenMap();
@@ -365,25 +364,11 @@ SvXMLNumImpData::SvXMLNumImpData(
SvNumberFormatter* pFmt,
const uno::Reference<uno::XComponentContext>& rxContext )
: pFormatter(pFmt),
- pStylesElemTokenMap(nullptr),
- pStyleElemTokenMap(nullptr),
- pStyleAttrTokenMap(nullptr),
- pStyleElemAttrTokenMap(nullptr),
- pLocaleData(nullptr),
m_xContext(rxContext)
{
SAL_WARN_IF( !rxContext.is(), "xmloff", "got no service manager" );
}
-SvXMLNumImpData::~SvXMLNumImpData()
-{
- delete pStylesElemTokenMap;
- delete pStyleElemTokenMap;
- delete pStyleAttrTokenMap;
- delete pStyleElemAttrTokenMap;
- delete pLocaleData;
-}
-
sal_uInt32 SvXMLNumImpData::GetKeyForName( const OUString& rName )
{
sal_uInt16 nCount = m_NameEntries.size();
@@ -479,7 +464,7 @@ const SvXMLTokenMap& SvXMLNumImpData::GetStylesElemTokenMap()
XML_TOKEN_MAP_END
};
- pStylesElemTokenMap = new SvXMLTokenMap( aStylesElemMap );
+ pStylesElemTokenMap = o3tl::make_unique<SvXMLTokenMap>( aStylesElemMap );
}
return *pStylesElemTokenMap;
}
@@ -517,7 +502,7 @@ const SvXMLTokenMap& SvXMLNumImpData::GetStyleElemTokenMap()
XML_TOKEN_MAP_END
};
- pStyleElemTokenMap = new SvXMLTokenMap( aStyleElemMap );
+ pStyleElemTokenMap = o3tl::make_unique<SvXMLTokenMap>( aStyleElemMap );
}
return *pStyleElemTokenMap;
}
@@ -548,7 +533,7 @@ const SvXMLTokenMap& SvXMLNumImpData::GetStyleAttrTokenMap()
XML_TOKEN_MAP_END
};
- pStyleAttrTokenMap = new SvXMLTokenMap( aStyleAttrMap );
+ pStyleAttrTokenMap = o3tl::make_unique<SvXMLTokenMap>( aStyleAttrMap );
}
return *pStyleAttrTokenMap;
}
@@ -594,7 +579,7 @@ const SvXMLTokenMap& SvXMLNumImpData::GetStyleElemAttrTokenMap()
XML_TOKEN_MAP_END
};
- pStyleElemAttrTokenMap = new SvXMLTokenMap( aStyleElemAttrMap );
+ pStyleElemAttrTokenMap = o3tl::make_unique<SvXMLTokenMap>( aStyleElemAttrMap );
}
return *pStyleElemAttrTokenMap;
}
@@ -602,7 +587,7 @@ const SvXMLTokenMap& SvXMLNumImpData::GetStyleElemAttrTokenMap()
const LocaleDataWrapper& SvXMLNumImpData::GetLocaleData( LanguageType nLang )
{
if ( !pLocaleData )
- pLocaleData = new LocaleDataWrapper(
+ pLocaleData = o3tl::make_unique<LocaleDataWrapper>(
pFormatter ? pFormatter->GetComponentContext() : m_xContext,
LanguageTag( nLang ) );
else
commit 87bc9685c250b403d4c002b54d5c49a6a81222fb
Author: David Tardon <dtardon at redhat.com>
Date: Fri Sep 9 11:42:20 2016 +0200
use std::unique_ptr
Change-Id: I33d75ede0031da63c00c35af7b42867fea0b8d80
diff --git a/include/xmloff/xmlnumfi.hxx b/include/xmloff/xmlnumfi.hxx
index e124917..a2ea8b4 100644
--- a/include/xmloff/xmlnumfi.hxx
+++ b/include/xmloff/xmlnumfi.hxx
@@ -72,7 +72,7 @@ namespace com { namespace sun { namespace star { namespace lang {
class SvXMLNumFmtHelper
{
- SvXMLNumImpData* pData;
+ std::unique_ptr<SvXMLNumImpData> pData;
public:
SvXMLNumFmtHelper(
@@ -91,7 +91,7 @@ public:
const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList,
SvXMLStylesContext& rStyles);
- SvXMLNumImpData* getData() { return pData; }
+ SvXMLNumImpData* getData() { return pData.get(); }
const SvXMLTokenMap& GetStylesElemTokenMap();
diff --git a/xmloff/source/style/xmlnumfi.cxx b/xmloff/source/style/xmlnumfi.cxx
index 1d94ea3..9d035e4 100644
--- a/xmloff/source/style/xmlnumfi.cxx
+++ b/xmloff/source/style/xmlnumfi.cxx
@@ -18,6 +18,9 @@
*/
#include <comphelper/string.hxx>
+
+#include <o3tl/make_unique.hxx>
+
#include <unotools/syslocale.hxx>
#include <svl/zforlist.hxx>
@@ -2307,7 +2310,7 @@ SvXMLNumFmtHelper::SvXMLNumFmtHelper(
if (pObj)
pFormatter = pObj->GetNumberFormatter();
- pData = new SvXMLNumImpData( pFormatter, rxContext );
+ pData = o3tl::make_unique<SvXMLNumImpData>( pFormatter, rxContext );
}
SvXMLNumFmtHelper::SvXMLNumFmtHelper(
@@ -2316,15 +2319,13 @@ SvXMLNumFmtHelper::SvXMLNumFmtHelper(
{
SAL_WARN_IF( !rxContext.is(), "xmloff", "got no service manager" );
- pData = new SvXMLNumImpData( pNumberFormatter, rxContext );
+ pData = o3tl::make_unique<SvXMLNumImpData>( pNumberFormatter, rxContext );
}
SvXMLNumFmtHelper::~SvXMLNumFmtHelper()
{
// remove temporary (volatile) formats from NumberFormatter
pData->RemoveVolatileFormats();
-
- delete pData;
}
SvXMLStyleContext* SvXMLNumFmtHelper::CreateChildContext( SvXMLImport& rImport,
@@ -2346,7 +2347,7 @@ SvXMLStyleContext* SvXMLNumFmtHelper::CreateChildContext( SvXMLImport& rImport,
case XML_TOK_STYLES_BOOLEAN_STYLE:
case XML_TOK_STYLES_TEXT_STYLE:
pContext = new SvXMLNumFormatContext( rImport, nPrefix, rLocalName,
- pData, nToken, xAttrList, rStyles );
+ pData.get(), nToken, xAttrList, rStyles );
break;
}
commit a13b6bd7317e39c3b54d4792aeea99fda0922a9d
Author: David Tardon <dtardon at redhat.com>
Date: Fri Sep 9 11:39:20 2016 +0200
use std::unique_ptr
Change-Id: I71627aa2a524a59180e8934df9561cf67a1c6126
diff --git a/xmloff/source/draw/ximpstyl.cxx b/xmloff/source/draw/ximpstyl.cxx
index dadbdaa..2533f27 100644
--- a/xmloff/source/draw/ximpstyl.cxx
+++ b/xmloff/source/draw/ximpstyl.cxx
@@ -24,6 +24,7 @@
#include <xmloff/xmluconv.hxx>
#include "ximpnote.hxx"
#include <tools/debug.hxx>
+#include <o3tl/make_unique.hxx>
#include <osl/diagnose.h>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
@@ -923,14 +924,8 @@ SdXMLStylesContext::SdXMLStylesContext(
mbIsAutoStyle(bIsAutoStyle)
{
Reference< uno::XComponentContext > xContext = rImport.GetComponentContext();
- mpNumFormatter = new SvNumberFormatter( xContext, LANGUAGE_SYSTEM );
- mpNumFmtHelper = new SvXMLNumFmtHelper( mpNumFormatter, xContext );
-}
-
-SdXMLStylesContext::~SdXMLStylesContext()
-{
- delete mpNumFmtHelper;
- delete mpNumFormatter;
+ mpNumFormatter = o3tl::make_unique<SvNumberFormatter>( xContext, LANGUAGE_SYSTEM );
+ mpNumFmtHelper = o3tl::make_unique<SvXMLNumFmtHelper>( mpNumFormatter.get(), xContext );
}
SvXMLStyleContext* SdXMLStylesContext::CreateStyleChildContext(
diff --git a/xmloff/source/draw/ximpstyl.hxx b/xmloff/source/draw/ximpstyl.hxx
index 8344554..867f5b3 100644
--- a/xmloff/source/draw/ximpstyl.hxx
+++ b/xmloff/source/draw/ximpstyl.hxx
@@ -25,6 +25,7 @@
#include "ximppage.hxx"
#include <xmloff/xmlstyle.hxx>
#include <com/sun/star/view/PaperOrientation.hpp>
+#include <memory>
#include <vector>
class SvNumberFormatter;
@@ -176,8 +177,8 @@ class SdXMLStylesContext : public SvXMLStylesContext
{
rtl::Reference< SvXMLImportPropertyMapper > xPresImpPropMapper;
bool mbIsAutoStyle;
- SvXMLNumFmtHelper* mpNumFmtHelper;
- SvNumberFormatter* mpNumFormatter;
+ std::unique_ptr<SvXMLNumFmtHelper> mpNumFmtHelper;
+ std::unique_ptr<SvNumberFormatter> mpNumFormatter;
const SdXMLImport& GetSdImport() const { return static_cast<const SdXMLImport&>(GetImport()); }
SdXMLImport& GetSdImport() { return static_cast<SdXMLImport&>(GetImport()); }
@@ -211,7 +212,6 @@ public:
const OUString& rLName,
const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList,
bool bIsAutoStyle);
- virtual ~SdXMLStylesContext();
virtual sal_uInt16 GetFamily( const OUString& rFamily ) const override;
virtual void EndElement() override;
commit 44c7366d5b58116c14d1dfd41ab6d2c8daec223a
Author: David Tardon <dtardon at redhat.com>
Date: Fri Sep 9 11:24:22 2016 +0200
avoid manual memory handling
Change-Id: I8b8d1126f20ee29fb3ac80e539da5e340226c304
diff --git a/xmloff/source/draw/ximpshap.cxx b/xmloff/source/draw/ximpshap.cxx
index ffd7077..15facfc 100644
--- a/xmloff/source/draw/ximpshap.cxx
+++ b/xmloff/source/draw/ximpshap.cxx
@@ -2583,14 +2583,8 @@ SdXMLChartShapeContext::SdXMLChartShapeContext(
const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList,
uno::Reference< drawing::XShapes >& rShapes,
bool bTemporaryShape)
-: SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ),
- mpChartContext( nullptr )
-{
-}
-
-SdXMLChartShapeContext::~SdXMLChartShapeContext()
+: SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape )
{
- delete mpChartContext;
}
void SdXMLChartShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList)
@@ -2626,7 +2620,7 @@ void SdXMLChartShapeContext::StartElement(const uno::Reference< xml::sax::XAttri
uno::Reference< frame::XModel > xChartModel;
if( aAny >>= xChartModel )
{
- mpChartContext = GetImport().GetChartImport()->CreateChartContext( GetImport(), XML_NAMESPACE_SVG, GetXMLToken(XML_CHART), xChartModel, xAttrList );
+ mxChartContext.set( GetImport().GetChartImport()->CreateChartContext( GetImport(), XML_NAMESPACE_SVG, GetXMLToken(XML_CHART), xChartModel, xAttrList ) );
}
}
}
@@ -2650,30 +2644,30 @@ void SdXMLChartShapeContext::StartElement(const uno::Reference< xml::sax::XAttri
SdXMLShapeContext::StartElement(xAttrList);
- if( mpChartContext )
- mpChartContext->StartElement( xAttrList );
+ if( mxChartContext.is() )
+ mxChartContext->StartElement( xAttrList );
}
}
void SdXMLChartShapeContext::EndElement()
{
- if( mpChartContext )
- mpChartContext->EndElement();
+ if( mxChartContext.is() )
+ mxChartContext->EndElement();
SdXMLShapeContext::EndElement();
}
void SdXMLChartShapeContext::Characters( const OUString& rChars )
{
- if( mpChartContext )
- mpChartContext->Characters( rChars );
+ if( mxChartContext.is() )
+ mxChartContext->Characters( rChars );
}
SvXMLImportContext * SdXMLChartShapeContext::CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName,
const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList )
{
- if( mpChartContext )
- return mpChartContext->CreateChildContext( nPrefix, rLocalName, xAttrList );
+ if( mxChartContext.is() )
+ return mxChartContext->CreateChildContext( nPrefix, rLocalName, xAttrList );
return nullptr;
}
diff --git a/xmloff/source/draw/ximpshap.hxx b/xmloff/source/draw/ximpshap.hxx
index dcf6233..a6ce95d 100644
--- a/xmloff/source/draw/ximpshap.hxx
+++ b/xmloff/source/draw/ximpshap.hxx
@@ -404,7 +404,7 @@ public:
class SdXMLChartShapeContext : public SdXMLShapeContext
{
- SvXMLImportContext* mpChartContext;
+ SvXMLImportContextRef mxChartContext;
public:
@@ -413,7 +413,6 @@ public:
const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList,
css::uno::Reference< css::drawing::XShapes >& rShapes,
bool bTemporaryShape);
- virtual ~SdXMLChartShapeContext();
virtual void StartElement( const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList ) override;
virtual void EndElement() override;
commit fccf28b5795b18907337bbb22a85d23a52280add
Author: David Tardon <dtardon at redhat.com>
Date: Fri Sep 9 11:21:00 2016 +0200
use std::unique_ptr
Change-Id: Ic03888e22949c6c3fc529f9a557f58620fc76f20
diff --git a/xmloff/source/draw/ximpcustomshape.cxx b/xmloff/source/draw/ximpcustomshape.cxx
index 167376b..029a1ba 100644
--- a/xmloff/source/draw/ximpcustomshape.cxx
+++ b/xmloff/source/draw/ximpcustomshape.cxx
@@ -20,6 +20,7 @@
#include "ximpcustomshape.hxx"
#include "ximpshap.hxx"
#include <o3tl/any.hxx>
+#include <o3tl/make_unique.hxx>
#include <rtl/math.hxx>
#include <rtl/ustrbuf.hxx>
#include <rtl/ustring.hxx>
@@ -47,6 +48,7 @@
#include <com/sun/star/drawing/ProjectionMode.hpp>
#include <sax/tools/converter.hxx>
#include <comphelper/sequence.hxx>
+#include <memory>
#include <unordered_map>
using namespace ::com::sun::star;
@@ -1168,7 +1170,7 @@ void XMLEnhancedCustomShapeContext::EndElement()
if ( !maEquations.empty() )
{
// creating hash map containing the name and index of each equation
- EquationHashMap* pH = new EquationHashMap;
+ std::unique_ptr<EquationHashMap> pH = o3tl::make_unique<EquationHashMap>();
std::vector< OUString >::iterator aEquationNameIter = maEquationNames.begin();
std::vector< OUString >::iterator aEquationNameEnd = maEquationNames.end();
while( aEquationNameIter != aEquationNameEnd )
@@ -1224,8 +1226,8 @@ void XMLEnhancedCustomShapeContext::EndElement()
aPathIter->Value);
for ( i = 0; i < rSeq.getLength(); i++ )
{
- CheckAndResolveEquationParameter( const_cast<css::drawing::EnhancedCustomShapeParameter &>(rSeq[ i ].First), pH );
- CheckAndResolveEquationParameter( const_cast<css::drawing::EnhancedCustomShapeParameter &>(rSeq[ i ].Second), pH );
+ CheckAndResolveEquationParameter( const_cast<css::drawing::EnhancedCustomShapeParameter &>(rSeq[ i ].First), pH.get() );
+ CheckAndResolveEquationParameter( const_cast<css::drawing::EnhancedCustomShapeParameter &>(rSeq[ i ].Second), pH.get() );
}
}
break;
@@ -1236,10 +1238,10 @@ void XMLEnhancedCustomShapeContext::EndElement()
aPathIter->Value);
for ( i = 0; i < rSeq.getLength(); i++ )
{
- CheckAndResolveEquationParameter( const_cast<css::drawing::EnhancedCustomShapeParameter &>(rSeq[ i ].TopLeft.First), pH );
- CheckAndResolveEquationParameter( const_cast<css::drawing::EnhancedCustomShapeParameter &>(rSeq[ i ].TopLeft.Second), pH );
- CheckAndResolveEquationParameter( const_cast<css::drawing::EnhancedCustomShapeParameter &>(rSeq[ i ].BottomRight.First), pH );
- CheckAndResolveEquationParameter( const_cast<css::drawing::EnhancedCustomShapeParameter &>(rSeq[ i ].BottomRight.Second), pH );
+ CheckAndResolveEquationParameter( const_cast<css::drawing::EnhancedCustomShapeParameter &>(rSeq[ i ].TopLeft.First), pH.get() );
+ CheckAndResolveEquationParameter( const_cast<css::drawing::EnhancedCustomShapeParameter &>(rSeq[ i ].TopLeft.Second), pH.get() );
+ CheckAndResolveEquationParameter( const_cast<css::drawing::EnhancedCustomShapeParameter &>(rSeq[ i ].BottomRight.First), pH.get() );
+ CheckAndResolveEquationParameter( const_cast<css::drawing::EnhancedCustomShapeParameter &>(rSeq[ i ].BottomRight.Second), pH.get() );
}
}
break;
@@ -1265,7 +1267,7 @@ void XMLEnhancedCustomShapeContext::EndElement()
case EAS_RadiusRangeMaximum :
{
CheckAndResolveEquationParameter( const_cast<css::drawing::EnhancedCustomShapeParameter &>(*o3tl::doAccess<css::drawing::EnhancedCustomShapeParameter>(
- pValues->Value)), pH );
+ pValues->Value)), pH.get() );
}
break;
@@ -1273,9 +1275,9 @@ void XMLEnhancedCustomShapeContext::EndElement()
case EAS_Polar :
{
CheckAndResolveEquationParameter( const_cast<css::drawing::EnhancedCustomShapeParameter &>((*o3tl::doAccess<css::drawing::EnhancedCustomShapeParameterPair>(
- pValues->Value)).First), pH );
+ pValues->Value)).First), pH.get() );
CheckAndResolveEquationParameter( const_cast<css::drawing::EnhancedCustomShapeParameter &>((*o3tl::doAccess<css::drawing::EnhancedCustomShapeParameterPair>(
- pValues->Value)).Second), pH );
+ pValues->Value)).Second), pH.get() );
}
break;
default:
@@ -1285,7 +1287,6 @@ void XMLEnhancedCustomShapeContext::EndElement()
}
++aHandleIter;
}
- delete pH;
}
SdXMLCustomShapePropertyMerge( mrCustomShapeGeometry, maExtrusion, EASGet( EAS_Extrusion ) );
commit df19c3c8006174e452cea455328ebb25e81a444b
Author: David Tardon <dtardon at redhat.com>
Date: Fri Sep 9 11:08:31 2016 +0200
reduce the insanity level of the codebase a bit
Change-Id: I4e0ee3cb87dd8f2bf8e35909e1b93d311c17a8c6
diff --git a/xmloff/inc/xexptran.hxx b/xmloff/inc/xexptran.hxx
index 230fd5b5..184158d 100644
--- a/xmloff/inc/xexptran.hxx
+++ b/xmloff/inc/xexptran.hxx
@@ -28,6 +28,7 @@
#include <com/sun/star/drawing/HomogenMatrix.hpp>
#include <tools/mapunit.hxx>
+#include <memory>
#include <vector>
struct ImpSdXMLExpTransObj2DBase;
@@ -45,14 +46,15 @@ namespace basegfx
class SdXMLImExTransform2D
{
- std::vector< ImpSdXMLExpTransObj2DBase* > maList;
+ // NOTE: This uses shared_ptr, because with unique_ptr the code
+ // fails to compile because of incomplete type.
+ std::vector< std::shared_ptr< ImpSdXMLExpTransObj2DBase > > maList;
OUString msString;
void EmptyList();
public:
SdXMLImExTransform2D() {}
- ~SdXMLImExTransform2D() { EmptyList(); }
void AddRotate(double fNew);
void AddTranslate(const ::basegfx::B2DTuple& rNew);
@@ -66,7 +68,9 @@ public:
class SdXMLImExTransform3D
{
- std::vector< ImpSdXMLExpTransObj3DBase* > maList;
+ // NOTE: This uses shared_ptr, because with unique_ptr the code
+ // fails to compile because of incomplete type.
+ std::vector< std::shared_ptr< ImpSdXMLExpTransObj3DBase > > maList;
OUString msString;
void EmptyList();
@@ -74,7 +78,6 @@ class SdXMLImExTransform3D
public:
SdXMLImExTransform3D() {}
SdXMLImExTransform3D(const OUString& rNew, const SvXMLUnitConverter& rConv);
- ~SdXMLImExTransform3D() { EmptyList(); }
void AddMatrix(const ::basegfx::B3DHomMatrix& rNew);
diff --git a/xmloff/source/draw/xexptran.cxx b/xmloff/source/draw/xexptran.cxx
index 7c4debc..f87f33d 100644
--- a/xmloff/source/draw/xexptran.cxx
+++ b/xmloff/source/draw/xexptran.cxx
@@ -18,6 +18,7 @@
*/
#include "xexptran.hxx"
+#include <o3tl/make_unique.hxx>
#include <rtl/ustrbuf.hxx>
#include <sax/tools/converter.hxx>
#include <xmloff/xmluconv.hxx>
@@ -35,6 +36,8 @@
using namespace ::com::sun::star;
+using o3tl::make_unique;
+
// parsing help functions for simple chars
void Imp_SkipSpaces(const OUString& rStr, sal_Int32& rPos, const sal_Int32 nLen)
{
@@ -170,6 +173,7 @@ struct ImpSdXMLExpTransObj2DBase
sal_uInt16 mnType;
explicit ImpSdXMLExpTransObj2DBase(sal_uInt16 nType)
: mnType(nType) {}
+ virtual ~ImpSdXMLExpTransObj2DBase() {}
};
// possible object types for 2D
@@ -224,51 +228,6 @@ struct ImpSdXMLExpTransObj2DMatrix : public ImpSdXMLExpTransObj2DBase
void SdXMLImExTransform2D::EmptyList()
{
- const sal_uInt32 nCount = maList.size();
- for(sal_uInt32 a(0L); a < nCount; a++)
- {
- ImpSdXMLExpTransObj2DBase* pObj = maList[a];
-
- switch(pObj->mnType)
- {
- case IMP_SDXMLEXP_TRANSOBJ2D_ROTATE :
- {
- delete static_cast<ImpSdXMLExpTransObj2DRotate*>(pObj);
- break;
- }
- case IMP_SDXMLEXP_TRANSOBJ2D_SCALE :
- {
- delete static_cast<ImpSdXMLExpTransObj2DScale*>(pObj);
- break;
- }
- case IMP_SDXMLEXP_TRANSOBJ2D_TRANSLATE :
- {
- delete static_cast<ImpSdXMLExpTransObj2DTranslate*>(pObj);
- break;
- }
- case IMP_SDXMLEXP_TRANSOBJ2D_SKEWX :
- {
- delete static_cast<ImpSdXMLExpTransObj2DSkewX*>(pObj);
- break;
- }
- case IMP_SDXMLEXP_TRANSOBJ2D_SKEWY :
- {
- delete static_cast<ImpSdXMLExpTransObj2DSkewY*>(pObj);
- break;
- }
- case IMP_SDXMLEXP_TRANSOBJ2D_MATRIX :
- {
- delete static_cast<ImpSdXMLExpTransObj2DMatrix*>(pObj);
- break;
- }
- default :
- {
- OSL_FAIL("SdXMLImExTransform2D: impossible entry!");
- break;
- }
- }
- }
-
maList.clear();
}
@@ -277,19 +236,19 @@ void SdXMLImExTransform2D::EmptyList()
void SdXMLImExTransform2D::AddRotate(double fNew)
{
if(fNew != 0.0)
- maList.push_back(new ImpSdXMLExpTransObj2DRotate(fNew));
+ maList.push_back(make_unique<ImpSdXMLExpTransObj2DRotate>(fNew));
}
void SdXMLImExTransform2D::AddTranslate(const ::basegfx::B2DTuple& rNew)
{
if(!rNew.equalZero())
- maList.push_back(new ImpSdXMLExpTransObj2DTranslate(rNew));
+ maList.push_back(make_unique<ImpSdXMLExpTransObj2DTranslate>(rNew));
}
void SdXMLImExTransform2D::AddSkewX(double fNew)
{
if(fNew != 0.0)
- maList.push_back(new ImpSdXMLExpTransObj2DSkewX(fNew));
+ maList.push_back(make_unique<ImpSdXMLExpTransObj2DSkewX>(fNew));
}
// gen string for export
@@ -302,7 +261,7 @@ const OUString& SdXMLImExTransform2D::GetExportString(const SvXMLUnitConverter&
const sal_uInt32 nCount = maList.size();
for(sal_uInt32 a(0L); a < nCount; a++)
{
- ImpSdXMLExpTransObj2DBase* pObj = maList[a];
+ ImpSdXMLExpTransObj2DBase* pObj = maList[a].get();
switch(pObj->mnType)
{
case IMP_SDXMLEXP_TRANSOBJ2D_ROTATE :
@@ -429,7 +388,7 @@ void SdXMLImExTransform2D::SetString(const OUString& rNew, const SvXMLUnitConver
Imp_SkipSpacesAndOpeningBraces(aStr, nPos, nLen);
fValue = Imp_GetDoubleChar(aStr, nPos, nLen, rConv, fValue);
if(fValue != 0.0)
- maList.push_back(new ImpSdXMLExpTransObj2DRotate(fValue));
+ maList.push_back(make_unique<ImpSdXMLExpTransObj2DRotate>(fValue));
Imp_SkipSpacesAndClosingBraces(aStr, nPos, nLen);
}
@@ -443,7 +402,7 @@ void SdXMLImExTransform2D::SetString(const OUString& rNew, const SvXMLUnitConver
aValue.setY(Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.getY()));
if(aValue.getX() != 1.0 || aValue.getY() != 1.0)
- maList.push_back(new ImpSdXMLExpTransObj2DScale(aValue));
+ maList.push_back(make_unique<ImpSdXMLExpTransObj2DScale>(aValue));
Imp_SkipSpacesAndClosingBraces(aStr, nPos, nLen);
}
@@ -457,7 +416,7 @@ void SdXMLImExTransform2D::SetString(const OUString& rNew, const SvXMLUnitConver
aValue.setY(Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.getY(), true));
if(!aValue.equalZero())
- maList.push_back(new ImpSdXMLExpTransObj2DTranslate(aValue));
+ maList.push_back(make_unique<ImpSdXMLExpTransObj2DTranslate>(aValue));
Imp_SkipSpacesAndClosingBraces(aStr, nPos, nLen);
}
@@ -468,7 +427,7 @@ void SdXMLImExTransform2D::SetString(const OUString& rNew, const SvXMLUnitConver
Imp_SkipSpacesAndOpeningBraces(aStr, nPos, nLen);
fValue = Imp_GetDoubleChar(aStr, nPos, nLen, rConv, fValue);
if(fValue != 0.0)
- maList.push_back(new ImpSdXMLExpTransObj2DSkewX(fValue));
+ maList.push_back(make_unique<ImpSdXMLExpTransObj2DSkewX>(fValue));
Imp_SkipSpacesAndClosingBraces(aStr, nPos, nLen);
}
@@ -479,7 +438,7 @@ void SdXMLImExTransform2D::SetString(const OUString& rNew, const SvXMLUnitConver
Imp_SkipSpacesAndOpeningBraces(aStr, nPos, nLen);
fValue = Imp_GetDoubleChar(aStr, nPos, nLen, rConv, fValue);
if(fValue != 0.0)
- maList.push_back(new ImpSdXMLExpTransObj2DSkewY(fValue));
+ maList.push_back(make_unique<ImpSdXMLExpTransObj2DSkewY>(fValue));
Imp_SkipSpacesAndClosingBraces(aStr, nPos, nLen);
}
@@ -515,7 +474,7 @@ void SdXMLImExTransform2D::SetString(const OUString& rNew, const SvXMLUnitConver
Imp_SkipSpacesAndCommas(aStr, nPos, nLen);
if(!aValue.isIdentity())
- maList.push_back(new ImpSdXMLExpTransObj2DMatrix(aValue));
+ maList.push_back(make_unique<ImpSdXMLExpTransObj2DMatrix>(aValue));
Imp_SkipSpacesAndClosingBraces(aStr, nPos, nLen);
}
@@ -535,7 +494,7 @@ void SdXMLImExTransform2D::GetFullTransform(::basegfx::B2DHomMatrix& rFullTrans)
const sal_uInt32 nCount = maList.size();
for(sal_uInt32 a(0L); a < nCount; a++)
{
- ImpSdXMLExpTransObj2DBase* pObj = maList[a];
+ ImpSdXMLExpTransObj2DBase* pObj = maList[a].get();
switch(pObj->mnType)
{
case IMP_SDXMLEXP_TRANSOBJ2D_ROTATE :
@@ -592,6 +551,7 @@ struct ImpSdXMLExpTransObj3DBase
sal_uInt16 mnType;
explicit ImpSdXMLExpTransObj3DBase(sal_uInt16 nType)
: mnType(nType) {}
+ virtual ~ImpSdXMLExpTransObj3DBase() {}
};
// possible object types for 3D
@@ -646,51 +606,6 @@ struct ImpSdXMLExpTransObj3DMatrix : public ImpSdXMLExpTransObj3DBase
void SdXMLImExTransform3D::EmptyList()
{
- const sal_uInt32 nCount = maList.size();
- for(sal_uInt32 a(0L); a < nCount; a++)
- {
- ImpSdXMLExpTransObj3DBase* pObj = maList[a];
-
- switch(pObj->mnType)
- {
- case IMP_SDXMLEXP_TRANSOBJ3D_ROTATE_X :
- {
- delete static_cast<ImpSdXMLExpTransObj3DRotateX*>(pObj);
- break;
- }
- case IMP_SDXMLEXP_TRANSOBJ3D_ROTATE_Y :
- {
- delete static_cast<ImpSdXMLExpTransObj3DRotateY*>(pObj);
- break;
- }
- case IMP_SDXMLEXP_TRANSOBJ3D_ROTATE_Z :
- {
- delete static_cast<ImpSdXMLExpTransObj3DRotateZ*>(pObj);
- break;
- }
- case IMP_SDXMLEXP_TRANSOBJ3D_SCALE :
- {
- delete static_cast<ImpSdXMLExpTransObj3DScale*>(pObj);
- break;
- }
- case IMP_SDXMLEXP_TRANSOBJ3D_TRANSLATE :
- {
- delete static_cast<ImpSdXMLExpTransObj3DTranslate*>(pObj);
- break;
- }
- case IMP_SDXMLEXP_TRANSOBJ3D_MATRIX :
- {
- delete static_cast<ImpSdXMLExpTransObj3DMatrix*>(pObj);
- break;
- }
- default :
- {
- OSL_FAIL("SdXMLImExTransform3D: impossible entry!");
- break;
- }
- }
- }
-
maList.clear();
}
@@ -699,7 +614,7 @@ void SdXMLImExTransform3D::EmptyList()
void SdXMLImExTransform3D::AddMatrix(const ::basegfx::B3DHomMatrix& rNew)
{
if(!rNew.isIdentity())
- maList.push_back(new ImpSdXMLExpTransObj3DMatrix(rNew));
+ maList.push_back(make_unique<ImpSdXMLExpTransObj3DMatrix>(rNew));
}
void SdXMLImExTransform3D::AddHomogenMatrix(const drawing::HomogenMatrix& xHomMat)
@@ -732,7 +647,7 @@ const OUString& SdXMLImExTransform3D::GetExportString(const SvXMLUnitConverter&
const sal_uInt32 nCount = maList.size();
for(sal_uInt32 a(0L); a < nCount; a++)
{
- ImpSdXMLExpTransObj3DBase* pObj = maList[a];
+ ImpSdXMLExpTransObj3DBase* pObj = maList[a].get();
switch(pObj->mnType)
{
case IMP_SDXMLEXP_TRANSOBJ3D_ROTATE_X :
@@ -894,7 +809,7 @@ void SdXMLImExTransform3D::SetString(const OUString& rNew, const SvXMLUnitConver
Imp_SkipSpacesAndOpeningBraces(aStr, nPos, nLen);
fValue = Imp_GetDoubleChar(aStr, nPos, nLen, rConv, fValue);
if(fValue != 0.0)
- maList.push_back(new ImpSdXMLExpTransObj3DRotateX(basegfx::deg2rad(fValue)));
+ maList.push_back(make_unique<ImpSdXMLExpTransObj3DRotateX>(basegfx::deg2rad(fValue)));
Imp_SkipSpacesAndClosingBraces(aStr, nPos, nLen);
}
@@ -906,7 +821,7 @@ void SdXMLImExTransform3D::SetString(const OUString& rNew, const SvXMLUnitConver
Imp_SkipSpacesAndOpeningBraces(aStr, nPos, nLen);
fValue = Imp_GetDoubleChar(aStr, nPos, nLen, rConv, fValue);
if(fValue != 0.0)
- maList.push_back(new ImpSdXMLExpTransObj3DRotateY(basegfx::deg2rad(fValue)));
+ maList.push_back(make_unique<ImpSdXMLExpTransObj3DRotateY>(basegfx::deg2rad(fValue)));
Imp_SkipSpacesAndClosingBraces(aStr, nPos, nLen);
}
@@ -918,7 +833,7 @@ void SdXMLImExTransform3D::SetString(const OUString& rNew, const SvXMLUnitConver
Imp_SkipSpacesAndOpeningBraces(aStr, nPos, nLen);
fValue = Imp_GetDoubleChar(aStr, nPos, nLen, rConv, fValue);
if(fValue != 0.0)
- maList.push_back(new ImpSdXMLExpTransObj3DRotateZ(basegfx::deg2rad(fValue)));
+ maList.push_back(make_unique<ImpSdXMLExpTransObj3DRotateZ>(basegfx::deg2rad(fValue)));
Imp_SkipSpacesAndClosingBraces(aStr, nPos, nLen);
}
@@ -935,7 +850,7 @@ void SdXMLImExTransform3D::SetString(const OUString& rNew, const SvXMLUnitConver
aValue.setZ(Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.getZ()));
if(1.0 != aValue.getX() || 1.0 != aValue.getY() || 1.0 != aValue.getZ())
- maList.push_back(new ImpSdXMLExpTransObj3DScale(aValue));
+ maList.push_back(make_unique<ImpSdXMLExpTransObj3DScale>(aValue));
Imp_SkipSpacesAndClosingBraces(aStr, nPos, nLen);
}
@@ -952,7 +867,7 @@ void SdXMLImExTransform3D::SetString(const OUString& rNew, const SvXMLUnitConver
aValue.setZ(Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.getZ(), true));
if(!aValue.equalZero())
- maList.push_back(new ImpSdXMLExpTransObj3DTranslate(aValue));
+ maList.push_back(make_unique<ImpSdXMLExpTransObj3DTranslate>(aValue));
Imp_SkipSpacesAndClosingBraces(aStr, nPos, nLen);
}
@@ -1012,7 +927,7 @@ void SdXMLImExTransform3D::SetString(const OUString& rNew, const SvXMLUnitConver
Imp_SkipSpacesAndCommas(aStr, nPos, nLen);
if(!aValue.isIdentity())
- maList.push_back(new ImpSdXMLExpTransObj3DMatrix(aValue));
+ maList.push_back(make_unique<ImpSdXMLExpTransObj3DMatrix>(aValue));
Imp_SkipSpacesAndClosingBraces(aStr, nPos, nLen);
}
@@ -1065,7 +980,7 @@ void SdXMLImExTransform3D::GetFullTransform(::basegfx::B3DHomMatrix& rFullTrans)
const sal_uInt32 nCount = maList.size();
for(sal_uInt32 a(0L); a < nCount; a++)
{
- ImpSdXMLExpTransObj3DBase* pObj = maList[a];
+ ImpSdXMLExpTransObj3DBase* pObj = maList[a].get();
switch(pObj->mnType)
{
case IMP_SDXMLEXP_TRANSOBJ3D_ROTATE_X :
commit 22547c51cf9484b0d7e1a7ed317fe5f70aaab694
Author: David Tardon <dtardon at redhat.com>
Date: Fri Sep 9 10:43:53 2016 +0200
use std::shared_ptr
Change-Id: Ie3f89c611f06be3c2fd5f43a4fa691f719078307
diff --git a/include/xmloff/shapeimport.hxx b/include/xmloff/shapeimport.hxx
index a1263c8..4402d58 100644
--- a/include/xmloff/shapeimport.hxx
+++ b/include/xmloff/shapeimport.hxx
@@ -266,7 +266,7 @@ class XMLOFF_DLLPUBLIC XMLShapeImportHelper : public salhelper::SimpleReferenceO
{
std::unique_ptr<XMLShapeImportHelperImpl> mpImpl;
- XMLShapeImportPageContextImpl* mpPageContext;
+ std::shared_ptr<XMLShapeImportPageContextImpl> mpPageContext;
// PropertySetMappers and factory
rtl::Reference<XMLSdPropHdlFactory> mpSdPropHdlFactory;
diff --git a/xmloff/source/draw/shapeimport.cxx b/xmloff/source/draw/shapeimport.cxx
index 08c184c..5738e70 100644
--- a/xmloff/source/draw/shapeimport.cxx
+++ b/xmloff/source/draw/shapeimport.cxx
@@ -88,7 +88,7 @@ struct XMLShapeImportPageContextImpl
uno::Reference < drawing::XShapes > mxShapes;
- struct XMLShapeImportPageContextImpl* mpNext;
+ std::shared_ptr<XMLShapeImportPageContextImpl> mpNext;
};
/** this class is to enable adding members to the XMLShapeImportHelper without getting incompatible */
@@ -111,7 +111,6 @@ XMLShapeImportHelper::XMLShapeImportHelper(
const uno::Reference< frame::XModel>& rModel,
SvXMLImportPropertyMapper *pExtMapper )
: mpImpl( new XMLShapeImportHelperImpl() ),
- mpPageContext(nullptr),
mpPropertySetMapper(nullptr),
mpPresPagePropsMapper(nullptr),
@@ -1021,8 +1020,8 @@ sal_Int32 XMLShapeImportHelper::getGluePointId( const css::uno::Reference< css::
/** this method must be calling before the first shape is imported for the given page */
void XMLShapeImportHelper::startPage( css::uno::Reference< css::drawing::XShapes >& rShapes )
{
- XMLShapeImportPageContextImpl* pOldContext = mpPageContext;
- mpPageContext = new XMLShapeImportPageContextImpl();
+ const std::shared_ptr<XMLShapeImportPageContextImpl> pOldContext = mpPageContext;
+ mpPageContext = std::make_shared<XMLShapeImportPageContextImpl>();
mpPageContext->mpNext = pOldContext;
mpPageContext->mxShapes = rShapes;
}
@@ -1036,9 +1035,7 @@ void XMLShapeImportHelper::endPage( css::uno::Reference< css::drawing::XShapes >
restoreConnections();
- XMLShapeImportPageContextImpl* pNextContext = mpPageContext->mpNext;
- delete mpPageContext;
- mpPageContext = pNextContext;
+ mpPageContext = mpPageContext->mpNext;
}
/** defines if the import should increment the progress bar or not */
commit 8304c237c3d3538cdb597e668aa43df54d4b43c3
Author: David Tardon <dtardon at redhat.com>
Date: Fri Sep 9 10:39:22 2016 +0200
use std::shared_ptr
Change-Id: I057b3f2ac6ec57b1a586bf450145a9690d891752
diff --git a/xmloff/source/draw/shapeimport.cxx b/xmloff/source/draw/shapeimport.cxx
index 016195f..08c184c 100644
--- a/xmloff/source/draw/shapeimport.cxx
+++ b/xmloff/source/draw/shapeimport.cxx
@@ -95,7 +95,7 @@ struct XMLShapeImportPageContextImpl
struct XMLShapeImportHelperImpl
{
// context for sorting shapes
- ShapeSortContext* mpSortContext;
+ std::shared_ptr<ShapeSortContext> mpSortContext;
std::vector<ConnectionHint> maConnections;
@@ -720,16 +720,16 @@ public:
vector<ZOrderHint> maUnsortedList;
sal_Int32 mnCurrentZ;
- ShapeSortContext* mpParentContext;
+ std::shared_ptr<ShapeSortContext> mpParentContext;
- ShapeSortContext( uno::Reference< drawing::XShapes >& rShapes, ShapeSortContext* pParentContext = nullptr );
+ ShapeSortContext( uno::Reference< drawing::XShapes >& rShapes, std::shared_ptr<ShapeSortContext> pParentContext = nullptr );
void popGroupAndSort();
private:
void moveShape( sal_Int32 nSourcePos, sal_Int32 nDestPos );
};
-ShapeSortContext::ShapeSortContext( uno::Reference< drawing::XShapes >& rShapes, ShapeSortContext* pParentContext )
+ShapeSortContext::ShapeSortContext( uno::Reference< drawing::XShapes >& rShapes, std::shared_ptr<ShapeSortContext> pParentContext )
: mxShapes( rShapes ), mnCurrentZ( 0 ), mpParentContext( pParentContext )
{
}
@@ -829,13 +829,13 @@ void ShapeSortContext::popGroupAndSort()
void XMLShapeImportHelper::pushGroupForSorting( uno::Reference< drawing::XShapes >& rShapes )
{
- mpImpl->mpSortContext = new ShapeSortContext( rShapes, mpImpl->mpSortContext );
+ mpImpl->mpSortContext = std::make_shared<ShapeSortContext>( rShapes, mpImpl->mpSortContext );
}
void XMLShapeImportHelper::popGroupAndSort()
{
SAL_WARN_IF( !mpImpl->mpSortContext, "xmloff", "No context to sort!" );
- if( mpImpl->mpSortContext == nullptr )
+ if( !mpImpl->mpSortContext )
return;
try
@@ -847,10 +847,8 @@ void XMLShapeImportHelper::popGroupAndSort()
OSL_FAIL("exception while sorting shapes, sorting failed!");
}
- // put parent on top and delete current context, we are done
- ShapeSortContext* pContext = mpImpl->mpSortContext;
- mpImpl->mpSortContext = pContext->mpParentContext;
- delete pContext;
+ // put parent on top and drop current context, we are done
+ mpImpl->mpSortContext = mpImpl->mpSortContext->mpParentContext;
}
void XMLShapeImportHelper::shapeWithZIndexAdded( css::uno::Reference< css::drawing::XShape >&, sal_Int32 nZIndex )
commit 7afc5ab572d4584f005a04cd57188a7c646b164b
Author: David Tardon <dtardon at redhat.com>
Date: Fri Sep 9 10:32:04 2016 +0200
use std::shared_ptr to manage memory
Change-Id: I3fcf285a75a1bf8252e0784c9ff4aceee64f4b5b
diff --git a/xmloff/inc/animimp.hxx b/xmloff/inc/animimp.hxx
index 19b9bbe..0a07b3f 100644
--- a/xmloff/inc/animimp.hxx
+++ b/xmloff/inc/animimp.hxx
@@ -20,6 +20,8 @@
#ifndef INCLUDED_XMLOFF_INC_ANIMIMP_HXX
#define INCLUDED_XMLOFF_INC_ANIMIMP_HXX
+#include <memory>
+
#include <xmloff/xmlictxt.hxx>
#include <com/sun/star/drawing/XShapes.hpp>
@@ -29,7 +31,7 @@ class AnimImpImpl;
class XMLAnimationsContext : public SvXMLImportContext
{
- AnimImpImpl* mpImpl;
+ std::shared_ptr<AnimImpImpl> mpImpl;
public:
@@ -37,7 +39,6 @@ public:
sal_uInt16 nPrfx,
const OUString& rLocalName,
const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList);
- virtual ~XMLAnimationsContext();
virtual SvXMLImportContext * CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName,
const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList ) override;
diff --git a/xmloff/source/draw/animimp.cxx b/xmloff/source/draw/animimp.cxx
index 0378122..6ba0a22 100644
--- a/xmloff/source/draw/animimp.cxx
+++ b/xmloff/source/draw/animimp.cxx
@@ -361,7 +361,7 @@ enum XMLActionKind
class XMLAnimationsEffectContext : public SvXMLImportContext
{
public:
- AnimImpImpl* mpImpl;
+ std::shared_ptr<AnimImpImpl> mpImpl;
XMLActionKind meKind;
bool mbTextEffect;
@@ -383,7 +383,7 @@ public:
sal_uInt16 nPrfx,
const OUString& rLocalName,
const Reference< XAttributeList >& xAttrList,
- AnimImpImpl* pImpl);
+ const std::shared_ptr<AnimImpImpl>& pImpl);
virtual ~XMLAnimationsEffectContext();
virtual void EndElement() override;
@@ -439,7 +439,7 @@ XMLAnimationsSoundContext::~XMLAnimationsSoundContext()
}
-XMLAnimationsEffectContext::XMLAnimationsEffectContext( SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLocalName, const Reference< XAttributeList >& xAttrList, AnimImpImpl* pImpl )
+XMLAnimationsEffectContext::XMLAnimationsEffectContext( SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLocalName, const Reference< XAttributeList >& xAttrList, const std::shared_ptr<AnimImpImpl>& pImpl )
: SvXMLImportContext(rImport, nPrfx, rLocalName),
mpImpl( pImpl ),
meKind( XMLE_SHOW ), mbTextEffect( false ),
@@ -638,13 +638,8 @@ void XMLAnimationsEffectContext::EndElement()
XMLAnimationsContext::XMLAnimationsContext( SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLocalName,
const css::uno::Reference< css::xml::sax::XAttributeList>& )
: SvXMLImportContext(rImport, nPrfx, rLocalName)
+, mpImpl(std::make_shared<AnimImpImpl>())
{
- mpImpl = new AnimImpImpl();
-}
-
-XMLAnimationsContext::~XMLAnimationsContext()
-{
- delete mpImpl;
}
SvXMLImportContext * XMLAnimationsContext::CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName,
commit 2e0cea44050e931bf7b290980a6b8c23de6526d5
Author: David Tardon <dtardon at redhat.com>
Date: Fri Sep 9 10:26:03 2016 +0200
use std::unique_ptr
Change-Id: I8ebbb94ae5f77fa44f46fb771f7d8ad5fc89a5bc
diff --git a/xmloff/source/draw/animationimport.cxx b/xmloff/source/draw/animationimport.cxx
index 85e635f..102457a 100644
--- a/xmloff/source/draw/animationimport.cxx
+++ b/xmloff/source/draw/animationimport.cxx
@@ -53,6 +53,9 @@
#include <sax/tools/converter.hxx>
#include <list>
+
+#include <o3tl/make_unique.hxx>
+
#include <xmloff/xmltypes.hxx>
#include "sdpropls.hxx"
#include <xmloff/xmltoken.hxx>
@@ -106,12 +109,11 @@ class AnimationsImportHelperImpl
private:
SvXMLImport& mrImport;
- SvXMLTokenMap* mpAnimationNodeTokenMap;
- SvXMLTokenMap* mpAnimationNodeAttributeTokenMap;
+ std::unique_ptr<SvXMLTokenMap> mpAnimationNodeTokenMap;
+ std::unique_ptr<SvXMLTokenMap> mpAnimationNodeAttributeTokenMap;
public:
explicit AnimationsImportHelperImpl( SvXMLImport& rImport );
- ~AnimationsImportHelperImpl();
const SvXMLTokenMap& getAnimationNodeTokenMap();
const SvXMLTokenMap& getAnimationNodeAttributeTokenMap();
@@ -127,16 +129,8 @@ public:
};
AnimationsImportHelperImpl::AnimationsImportHelperImpl( SvXMLImport& rImport )
-: mrImport( rImport ),
- mpAnimationNodeTokenMap( nullptr ),
- mpAnimationNodeAttributeTokenMap( nullptr )
-{
-}
-
-AnimationsImportHelperImpl::~AnimationsImportHelperImpl()
+: mrImport( rImport )
{
- delete mpAnimationNodeTokenMap;
- delete mpAnimationNodeAttributeTokenMap;
}
const SvXMLTokenMap& AnimationsImportHelperImpl::getAnimationNodeTokenMap()
@@ -159,7 +153,7 @@ const SvXMLTokenMap& AnimationsImportHelperImpl::getAnimationNodeTokenMap()
XML_TOKEN_MAP_END
};
- mpAnimationNodeTokenMap = new SvXMLTokenMap( aAnimationNodeTokenMap );
+ mpAnimationNodeTokenMap = o3tl::make_unique<SvXMLTokenMap>( aAnimationNodeTokenMap );
}
return *mpAnimationNodeTokenMap;
@@ -278,7 +272,7 @@ const SvXMLTokenMap& AnimationsImportHelperImpl::getAnimationNodeAttributeTokenM
XML_TOKEN_MAP_END
};
- mpAnimationNodeAttributeTokenMap = new SvXMLTokenMap( aAnimationNodeAttributeTokenMap );
+ mpAnimationNodeAttributeTokenMap = o3tl::make_unique<SvXMLTokenMap>( aAnimationNodeAttributeTokenMap );
}
return *mpAnimationNodeAttributeTokenMap;
commit 109ea4752b734683483aef5154d8debca2d300a3
Author: David Tardon <dtardon at redhat.com>
Date: Fri Sep 9 10:25:31 2016 +0200
use std::shared_ptr
Change-Id: Ib285d2445077a0263a09b36bf1a6fa1fe7f59496
diff --git a/xmloff/inc/animationimport.hxx b/xmloff/inc/animationimport.hxx
index afe509c..cea9782 100644
--- a/xmloff/inc/animationimport.hxx
+++ b/xmloff/inc/animationimport.hxx
@@ -20,6 +20,8 @@
#ifndef INCLUDED_XMLOFF_INC_ANIMATIONIMPORT_HXX
#define INCLUDED_XMLOFF_INC_ANIMATIONIMPORT_HXX
+#include <memory>
+
#include <xmloff/xmlictxt.hxx>
#include <com/sun/star/animations/XAnimationNode.hpp>
@@ -31,7 +33,7 @@ class AnimationsImportHelperImpl;
class AnimationNodeContext : public SvXMLImportContext
{
- AnimationsImportHelperImpl* mpHelper;
+ std::shared_ptr<AnimationsImportHelperImpl> mpHelper;
bool mbRootContext;
css::uno::Reference< css::animations::XAnimationNode > mxNode;
@@ -45,8 +47,7 @@ public:
sal_uInt16 nPrfx,
const OUString& rLocalName,
const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList,
- AnimationsImportHelperImpl* mpImpl = nullptr );
- virtual ~AnimationNodeContext();
+ std::shared_ptr<AnimationsImportHelperImpl> pImpl = nullptr );
virtual void StartElement( const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList ) override;
diff --git a/xmloff/source/draw/animationimport.cxx b/xmloff/source/draw/animationimport.cxx
index a9dd0f7..85e635f 100644
--- a/xmloff/source/draw/animationimport.cxx
+++ b/xmloff/source/draw/animationimport.cxx
@@ -625,16 +625,16 @@ AnimationNodeContext::AnimationNodeContext(
const Reference< XAnimationNode >& xParentNode,
SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLocalName,
const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList,
- AnimationsImportHelperImpl* pHelper /* = NULL */ )
+ std::shared_ptr<AnimationsImportHelperImpl> pHelper )
: SvXMLImportContext(rImport, nPrfx, rLocalName),
mpHelper( pHelper ),
- mbRootContext( pHelper == nullptr )
+ mbRootContext( !pHelper )
{
try
{
if( mbRootContext )
{
- mpHelper = new AnimationsImportHelperImpl( rImport );
+ mpHelper = std::make_shared<AnimationsImportHelperImpl>( rImport );
mxNode = xParentNode;
}
else
@@ -720,12 +720,6 @@ AnimationNodeContext::AnimationNodeContext(
}
}
-AnimationNodeContext::~AnimationNodeContext()
-{
- if( mbRootContext )
- delete mpHelper;
-}
-
void AnimationNodeContext::StartElement( const css::uno::Reference< css::xml::sax::XAttributeList >& )
{
// code of StartElement is moved to init_node that is now called
commit b42af6cee1d2c8a2bdb37d1a6e7e53704b839ee2
Author: David Tardon <dtardon at redhat.com>
Date: Fri Sep 9 10:15:43 2016 +0200
astyle
Change-Id: Ib237a5f02b64b93bd2994cd98f29938c3a0904ae
diff --git a/writerperfect/inc/WPXSvInputStream.hxx b/writerperfect/inc/WPXSvInputStream.hxx
index 06eddfd..9bbefbb 100644
--- a/writerperfect/inc/WPXSvInputStream.hxx
+++ b/writerperfect/inc/WPXSvInputStream.hxx
@@ -38,7 +38,7 @@ class WPXSvInputStreamImpl;
class WRITERPERFECT_DLLPUBLIC WPXSvInputStream : public librevenge::RVNGInputStream
{
public:
- WPXSvInputStream(css::uno::Reference< css::io::XInputStream > const & xStream);
+ WPXSvInputStream(css::uno::Reference< css::io::XInputStream > const &xStream);
virtual ~WPXSvInputStream();
virtual bool isStructured() override;
diff --git a/writerperfect/source/calc/StarOfficeCalcImportFilter.cxx b/writerperfect/source/calc/StarOfficeCalcImportFilter.cxx
index 5accde1..5ed92db 100644
--- a/writerperfect/source/calc/StarOfficeCalcImportFilter.cxx
+++ b/writerperfect/source/calc/StarOfficeCalcImportFilter.cxx
@@ -81,7 +81,7 @@ throw (RuntimeException, std::exception)
Sequence< OUString > SAL_CALL StarOfficeCalcImportFilter::getSupportedServiceNames()
throw (RuntimeException, std::exception)
{
- return Sequence< OUString >{"com.sun.star.document.ImportFilter", "com.sun.star.document.ExtendedTypeDetection"};
+ return Sequence< OUString > {"com.sun.star.document.ImportFilter", "com.sun.star.document.ExtendedTypeDetection"};
}
extern "C"
diff --git a/writerperfect/source/common/WPXSvInputStream.cxx b/writerperfect/source/common/WPXSvInputStream.cxx
index d23fc6c..f6bf586 100644
--- a/writerperfect/source/common/WPXSvInputStream.cxx
+++ b/writerperfect/source/common/WPXSvInputStream.cxx
@@ -143,7 +143,7 @@ struct OLEStorageImpl
void initialize(SvStream *pStream);
tools::SvRef<SotStorageStream> getStream(const rtl::OUString &rPath);
- tools::SvRef<SotStorageStream> const & getStream(std::size_t nId);
+ tools::SvRef<SotStorageStream> const &getStream(std::size_t nId);
private:
void traverse(const tools::SvRef<SotStorage> &rStorage, const rtl::OUString &rPath);
@@ -202,7 +202,7 @@ tools::SvRef<SotStorageStream> OLEStorageImpl::getStream(const rtl::OUString &rP
return maStreams[aIt->second].stream.ref;
}
-tools::SvRef<SotStorageStream> const & OLEStorageImpl::getStream(const std::size_t nId)
+tools::SvRef<SotStorageStream> const &OLEStorageImpl::getStream(const std::size_t nId)
{
if (!maStreams[nId].stream.ref.Is())
maStreams[nId].stream.ref = createStream(rtl::OStringToOUString(maStreams[nId].name, RTL_TEXTENCODING_UTF8));
@@ -400,7 +400,7 @@ class WPXSvInputStreamImpl
{
public:
explicit WPXSvInputStreamImpl(css::uno::Reference<
- css::io::XInputStream > const & xStream);
+ css::io::XInputStream > const &xStream);
~WPXSvInputStreamImpl();
bool isStructured();
@@ -442,7 +442,7 @@ public:
unsigned long mnReadBufferPos;
};
-WPXSvInputStreamImpl::WPXSvInputStreamImpl(Reference< XInputStream > const & xStream) :
+WPXSvInputStreamImpl::WPXSvInputStreamImpl(Reference< XInputStream > const &xStream) :
mxStream(xStream),
mxSeekable(xStream, UNO_QUERY),
maData(0),
@@ -809,7 +809,7 @@ void WPXSvInputStreamImpl::ensureZipIsInitialized()
mpZipStorage->initialize();
}
-WPXSvInputStream::WPXSvInputStream(Reference< XInputStream > const & xStream) :
+WPXSvInputStream::WPXSvInputStream(Reference< XInputStream > const &xStream) :
mpImpl(new WPXSvInputStreamImpl(xStream))
{
}
diff --git a/writerperfect/source/draw/StarOfficeDrawImportFilter.cxx b/writerperfect/source/draw/StarOfficeDrawImportFilter.cxx
index 57dfb7f..bded190 100644
--- a/writerperfect/source/draw/StarOfficeDrawImportFilter.cxx
+++ b/writerperfect/source/draw/StarOfficeDrawImportFilter.cxx
@@ -83,7 +83,7 @@ throw (RuntimeException, std::exception)
Sequence< OUString > SAL_CALL StarOfficeDrawImportFilter::getSupportedServiceNames()
throw (RuntimeException, std::exception)
{
- return Sequence< OUString >{"com.sun.star.document.ImportFilter", "com.sun.star.document.ExtendedTypeDetection"};
+ return Sequence< OUString > {"com.sun.star.document.ImportFilter", "com.sun.star.document.ExtendedTypeDetection"};
}
extern "C"
diff --git a/writerperfect/source/draw/ZMFImportFilter.cxx b/writerperfect/source/draw/ZMFImportFilter.cxx
index 0eabfc1..8c6e029 100644
--- a/writerperfect/source/draw/ZMFImportFilter.cxx
+++ b/writerperfect/source/draw/ZMFImportFilter.cxx
@@ -54,7 +54,7 @@ throw (RuntimeException, std::exception)
Sequence< OUString > SAL_CALL ZMFImportFilter::getSupportedServiceNames()
throw (RuntimeException, std::exception)
{
- return Sequence< OUString >{"com.sun.star.document.ImportFilter", "com.sun.star.document.ExtendedTypeDetection"};
+ return Sequence< OUString > {"com.sun.star.document.ImportFilter", "com.sun.star.document.ExtendedTypeDetection"};
}
extern "C"
diff --git a/writerperfect/source/writer/StarOfficeWriterImportFilter.cxx b/writerperfect/source/writer/StarOfficeWriterImportFilter.cxx
index e0580dc..9ee289e 100644
--- a/writerperfect/source/writer/StarOfficeWriterImportFilter.cxx
+++ b/writerperfect/source/writer/StarOfficeWriterImportFilter.cxx
@@ -40,9 +40,11 @@ bool StarOfficeWriterImportFilter::doImportDocument(librevenge::RVNGInputStream
STOFFDocument::Kind docKind = STOFFDocument::STOFF_K_UNKNOWN;
const STOFFDocument::Confidence confidence = STOFFDocument::isFileFormatSupported(&rInput, docKind);
OString aUtf8Passwd;
- if (confidence==STOFFDocument::STOFF_C_SUPPORTED_ENCRYPTION) {
+ if (confidence==STOFFDocument::STOFF_C_SUPPORTED_ENCRYPTION)
+ {
// try to ask for a password
- try {
+ try
+ {
ScopedVclPtrInstance< SfxPasswordDialog > aPasswdDlg(nullptr);
aPasswdDlg->SetMinLen(0);
if (!aPasswdDlg->Execute())
@@ -50,7 +52,8 @@ bool StarOfficeWriterImportFilter::doImportDocument(librevenge::RVNGInputStream
OUString aPasswd = aPasswdDlg->GetPassword();
aUtf8Passwd = OUStringToOString(aPasswd, RTL_TEXTENCODING_UTF8);
}
- catch (...) {
+ catch (...)
+ {
// ok, we will probably guess it
}
}
@@ -101,7 +104,7 @@ throw (RuntimeException, std::exception)
Sequence< OUString > SAL_CALL StarOfficeWriterImportFilter::getSupportedServiceNames()
throw (RuntimeException, std::exception)
{
- return Sequence< OUString >{"com.sun.star.document.ImportFilter", "com.sun.star.document.ExtendedTypeDetection"};
+ return Sequence< OUString > {"com.sun.star.document.ImportFilter", "com.sun.star.document.ExtendedTypeDetection"};
}
extern "C"
commit 05adc066ec8cbc0609e26ba0ddb2d8e766549309
Author: David Tardon <dtardon at redhat.com>
Date: Fri Sep 9 10:12:44 2016 +0200
use std::unique_ptr
Change-Id: Idd19671bb2eab12cac2011160c617bf3f43659d7
diff --git a/writerperfect/qa/unit/DirectoryStreamTest.cxx b/writerperfect/qa/unit/DirectoryStreamTest.cxx
index 9201cdd..79646ed 100644
--- a/writerperfect/qa/unit/DirectoryStreamTest.cxx
+++ b/writerperfect/qa/unit/DirectoryStreamTest.cxx
@@ -13,6 +13,8 @@
#include <comphelper/processfactory.hxx>
+#include <o3tl/make_unique.hxx>
+
#include <ucbhelper/content.hxx>
#include <test/bootstrapfixture.hxx>
@@ -62,14 +64,14 @@ static const char g_aDirPath[] = "/writerperfect/qa/unit/data/stream/test.dir";
static const char g_aNondirPath[] = "/writerperfect/qa/unit/data/stream/test.dir/mimetype";
static const char g_aNonexistentPath[] = "/writerperfect/qa/unit/data/stream/foo/bar";
-DirectoryStream *createForParent(const css::uno::Reference<css::ucb::XContent> &xContent)
+std::unique_ptr<DirectoryStream> createForParent(const css::uno::Reference<css::ucb::XContent> &xContent)
{
try
{
if (!xContent.is())
return nullptr;
- DirectoryStream *pDir(nullptr);
+ unique_ptr<DirectoryStream> pDir;
const uno::Reference<css::container::XChild> xChild(xContent, uno::UNO_QUERY);
if (xChild.is())
@@ -77,12 +79,9 @@ DirectoryStream *createForParent(const css::uno::Reference<css::ucb::XContent> &
const uno::Reference<ucb::XContent> xDirContent(xChild->getParent(), uno::UNO_QUERY);
if (xDirContent.is())
{
- pDir = new writerperfect::DirectoryStream(xDirContent);
+ pDir = o3tl::make_unique<DirectoryStream>(xDirContent);
if (!pDir->isStructured())
- {
- delete pDir;
- pDir = nullptr;
- }
+ pDir.reset();
}
}
commit 1eb1ff0faa395ae51696662c85df5e654331b94c
Author: David Tardon <dtardon at redhat.com>
Date: Fri Sep 9 10:07:47 2016 +0200
use std::unique_ptr
Change-Id: I94aafd665116d01d2f6134c4b41ab70c34e23ab6
diff --git a/include/xmloff/SchXMLImportHelper.hxx b/include/xmloff/SchXMLImportHelper.hxx
index 0e513e0..a842fd4 100644
--- a/include/xmloff/SchXMLImportHelper.hxx
+++ b/include/xmloff/SchXMLImportHelper.hxx
@@ -19,6 +19,8 @@
#ifndef INCLUDED_XMLOFF_SCHXMLIMPORTHELPER_HXX
#define INCLUDED_XMLOFF_SCHXMLIMPORTHELPER_HXX
+#include <memory>
+
#include <salhelper/simplereferenceobject.hxx>
#include <xmloff/families.hxx>
#include <com/sun/star/util/XStringMapping.hpp>
@@ -66,23 +68,22 @@ private:
css::uno::Reference< css::chart::XChartDocument > mxChartDoc;
SvXMLStylesContext* mpAutoStyles;
- SvXMLTokenMap* mpChartDocElemTokenMap;
- SvXMLTokenMap* mpTableElemTokenMap;
- SvXMLTokenMap* mpChartElemTokenMap;
- SvXMLTokenMap* mpPlotAreaElemTokenMap;
- SvXMLTokenMap* mpSeriesElemTokenMap;
+ std::unique_ptr<SvXMLTokenMap> mpChartDocElemTokenMap;
+ std::unique_ptr<SvXMLTokenMap> mpTableElemTokenMap;
+ std::unique_ptr<SvXMLTokenMap> mpChartElemTokenMap;
+ std::unique_ptr<SvXMLTokenMap> mpPlotAreaElemTokenMap;
+ std::unique_ptr<SvXMLTokenMap> mpSeriesElemTokenMap;
- SvXMLTokenMap* mpChartAttrTokenMap;
- SvXMLTokenMap* mpPlotAreaAttrTokenMap;
- SvXMLTokenMap* mpCellAttrTokenMap;
- SvXMLTokenMap* mpSeriesAttrTokenMap;
- SvXMLTokenMap* mpPropMappingAttrTokenMap;
- SvXMLTokenMap* mpRegEquationAttrTokenMap;
+ std::unique_ptr<SvXMLTokenMap> mpChartAttrTokenMap;
+ std::unique_ptr<SvXMLTokenMap> mpPlotAreaAttrTokenMap;
+ std::unique_ptr<SvXMLTokenMap> mpCellAttrTokenMap;
+ std::unique_ptr<SvXMLTokenMap> mpSeriesAttrTokenMap;
+ std::unique_ptr<SvXMLTokenMap> mpPropMappingAttrTokenMap;
+ std::unique_ptr<SvXMLTokenMap> mpRegEquationAttrTokenMap;
public:
SchXMLImportHelper();
- virtual ~SchXMLImportHelper();
/** get the context for reading the <chart:chart> element with subelements.
The result is stored in the XModel given if it also implements
diff --git a/xmloff/source/chart/SchXMLImport.cxx b/xmloff/source/chart/SchXMLImport.cxx
index 17645c9..373efbe 100644
--- a/xmloff/source/chart/SchXMLImport.cxx
+++ b/xmloff/source/chart/SchXMLImport.cxx
@@ -24,6 +24,7 @@
#include "SchXMLTools.hxx"
#include "facreg.hxx"
+#include <o3tl/make_unique.hxx>
#include <rtl/ustrbuf.hxx>
#include <comphelper/processfactory.hxx>
#include <xmloff/nmspmap.hxx>
@@ -85,37 +86,8 @@ private:
// attribute maps
SchXMLImportHelper::SchXMLImportHelper() :
- mpAutoStyles( nullptr ),
-
- mpChartDocElemTokenMap( nullptr ),
- mpTableElemTokenMap( nullptr ),
- mpChartElemTokenMap( nullptr ),
- mpPlotAreaElemTokenMap( nullptr ),
- mpSeriesElemTokenMap( nullptr ),
-
- mpChartAttrTokenMap( nullptr ),
- mpPlotAreaAttrTokenMap( nullptr ),
- mpCellAttrTokenMap( nullptr ),
- mpSeriesAttrTokenMap( nullptr ),
- mpPropMappingAttrTokenMap( nullptr ),
- mpRegEquationAttrTokenMap( nullptr )
-{
-}
-
-SchXMLImportHelper::~SchXMLImportHelper()
+ mpAutoStyles( nullptr )
{
- // delete token maps
- delete mpChartDocElemTokenMap;
- delete mpTableElemTokenMap;
- delete mpChartElemTokenMap;
- delete mpPlotAreaElemTokenMap;
- delete mpSeriesElemTokenMap;
-
- delete mpChartAttrTokenMap;
- delete mpPlotAreaAttrTokenMap;
- delete mpCellAttrTokenMap;
- delete mpSeriesAttrTokenMap;
- delete mpPropMappingAttrTokenMap;
}
SvXMLImportContext* SchXMLImportHelper::CreateChartContext(
@@ -171,7 +143,7 @@ const SvXMLTokenMap& SchXMLImportHelper::GetDocElemTokenMap()
XML_TOKEN_MAP_END
};
- mpChartDocElemTokenMap = new SvXMLTokenMap( aDocElemTokenMap );
+ mpChartDocElemTokenMap = o3tl::make_unique<SvXMLTokenMap>( aDocElemTokenMap );
} // if( ! mpChartDocElemTokenMap )
return *mpChartDocElemTokenMap;
@@ -192,7 +164,7 @@ const SvXMLTokenMap& SchXMLImportHelper::GetTableElemTokenMap()
XML_TOKEN_MAP_END
};
- mpTableElemTokenMap = new SvXMLTokenMap( aTableElemTokenMap );
+ mpTableElemTokenMap = o3tl::make_unique<SvXMLTokenMap>( aTableElemTokenMap );
} // if( ! mpTableElemTokenMap )
return *mpTableElemTokenMap;
@@ -212,7 +184,7 @@ const SvXMLTokenMap& SchXMLImportHelper::GetChartElemTokenMap()
XML_TOKEN_MAP_END
};
- mpChartElemTokenMap = new SvXMLTokenMap( aChartElemTokenMap );
+ mpChartElemTokenMap = o3tl::make_unique<SvXMLTokenMap>( aChartElemTokenMap );
} // if( ! mpChartElemTokenMap )
return *mpChartElemTokenMap;
@@ -237,7 +209,7 @@ const SvXMLTokenMap& SchXMLImportHelper::GetPlotAreaElemTokenMap()
XML_TOKEN_MAP_END
};
- mpPlotAreaElemTokenMap = new SvXMLTokenMap( aPlotAreaElemTokenMap );
+ mpPlotAreaElemTokenMap = o3tl::make_unique<SvXMLTokenMap>( aPlotAreaElemTokenMap );
} // if( ! mpPlotAreaElemTokenMap )
return *mpPlotAreaElemTokenMap;
@@ -258,7 +230,7 @@ const SvXMLTokenMap& SchXMLImportHelper::GetSeriesElemTokenMap()
XML_TOKEN_MAP_END
};
- mpSeriesElemTokenMap = new SvXMLTokenMap( aSeriesElemTokenMap );
+ mpSeriesElemTokenMap = o3tl::make_unique<SvXMLTokenMap>( aSeriesElemTokenMap );
} // if( ! mpSeriesElemTokenMap )
return *mpSeriesElemTokenMap;
@@ -280,7 +252,7 @@ const SvXMLTokenMap& SchXMLImportHelper::GetChartAttrTokenMap()
XML_TOKEN_MAP_END
};
- mpChartAttrTokenMap = new SvXMLTokenMap( aChartAttrTokenMap );
+ mpChartAttrTokenMap = o3tl::make_unique<SvXMLTokenMap>( aChartAttrTokenMap );
} // if( ! mpChartAttrTokenMap )
return *mpChartAttrTokenMap;
@@ -313,7 +285,7 @@ const SvXMLTokenMap& SchXMLImportHelper::GetPlotAreaAttrTokenMap()
XML_TOKEN_MAP_END
};
- mpPlotAreaAttrTokenMap = new SvXMLTokenMap( aPlotAreaAttrTokenMap );
+ mpPlotAreaAttrTokenMap = o3tl::make_unique<SvXMLTokenMap>( aPlotAreaAttrTokenMap );
} // if( ! mpPlotAreaAttrTokenMap )
return *mpPlotAreaAttrTokenMap;
@@ -330,7 +302,7 @@ const SvXMLTokenMap& SchXMLImportHelper::GetCellAttrTokenMap()
XML_TOKEN_MAP_END
};
- mpCellAttrTokenMap = new SvXMLTokenMap( aCellAttrTokenMap );
+ mpCellAttrTokenMap = o3tl::make_unique<SvXMLTokenMap>( aCellAttrTokenMap );
} // if( ! mpCellAttrTokenMap )
return *mpCellAttrTokenMap;
@@ -351,7 +323,7 @@ const SvXMLTokenMap& SchXMLImportHelper::GetSeriesAttrTokenMap()
XML_TOKEN_MAP_END
};
- mpSeriesAttrTokenMap = new SvXMLTokenMap( aSeriesAttrTokenMap );
+ mpSeriesAttrTokenMap = o3tl::make_unique<SvXMLTokenMap>( aSeriesAttrTokenMap );
} // if( ! mpSeriesAttrTokenMap )
return *mpSeriesAttrTokenMap;
@@ -368,7 +340,7 @@ const SvXMLTokenMap& SchXMLImportHelper::GetPropMappingAttrTokenMap()
XML_TOKEN_MAP_END
};
- mpPropMappingAttrTokenMap = new SvXMLTokenMap( aPropMappingAttrTokenMap );
+ mpPropMappingAttrTokenMap = o3tl::make_unique<SvXMLTokenMap>( aPropMappingAttrTokenMap );
}
return *mpPropMappingAttrTokenMap;
@@ -388,7 +360,7 @@ const SvXMLTokenMap& SchXMLImportHelper::GetRegEquationAttrTokenMap()
XML_TOKEN_MAP_END
};
- mpRegEquationAttrTokenMap = new SvXMLTokenMap( aRegressionEquationAttrTokenMap );
+ mpRegEquationAttrTokenMap = o3tl::make_unique<SvXMLTokenMap>( aRegressionEquationAttrTokenMap );
} // if( ! mpRegEquationAttrTokenMap )
return *mpRegEquationAttrTokenMap;
commit 260cbd3d3c86cd306129f3db290fed8b993b2909
Author: David Tardon <dtardon at redhat.com>
Date: Fri Sep 9 10:02:22 2016 +0200
use std::unique_ptr
Change-Id: I21572ac8afb1c514ff78b1e23c7fb9259f0b01fb
diff --git a/xmloff/source/chart/MultiPropertySetHandler.hxx b/xmloff/source/chart/MultiPropertySetHandler.hxx
index e263790..7996bfa 100644
--- a/xmloff/source/chart/MultiPropertySetHandler.hxx
+++ b/xmloff/source/chart/MultiPropertySetHandler.hxx
@@ -20,6 +20,9 @@
#ifndef INCLUDED_XMLOFF_SOURCE_CHART_MULTIPROPERTYSETHANDLER_HXX
#define INCLUDED_XMLOFF_SOURCE_CHART_MULTIPROPERTYSETHANDLER_HXX
+#include <memory>
+
+#include <o3tl/make_unique.hxx>
#include <rtl/ustring.hxx>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/beans/XMultiPropertySet.hpp>
@@ -123,7 +126,6 @@ public:
*/
explicit MultiPropertySetHandler (css::uno::Reference<
css::uno::XInterface> const & xObject);
- ~MultiPropertySetHandler();
/** @descr Add a property to handle. The type given implicitly by the
reference to a variable is used to create an instance of
the PropertyWrapper template class.
@@ -133,7 +135,7 @@ public:
*/
template<class T> void Add (const OUString & sName, T& rValue)
{
- aPropertyList[sName] = new PropertyWrapper<T> (sName, rValue);
+ aPropertyList[sName] = o3tl::make_unique<PropertyWrapper<T>>(sName, rValue);
}
/** @descr Try to get the values for all properties added with the Add
@@ -168,7 +170,7 @@ private:
PropertyWrapper. It uses OUStringComparison for sorting
the property names.
*/
- ::std::map< OUString, PropertyWrapperBase*, OUStringComparison> aPropertyList;
+ ::std::map< OUString, std::unique_ptr<PropertyWrapperBase>, OUStringComparison> aPropertyList;
/// The object from which to get the property values.
css::uno::Reference< css::uno::XInterface> mxObject;
@@ -180,19 +182,11 @@ MultiPropertySetHandler::MultiPropertySetHandler (css::uno::Reference<
{
}
-MultiPropertySetHandler::~MultiPropertySetHandler()
-{
- ::std::map< OUString, PropertyWrapperBase*, OUStringComparison>::iterator I;
- for (I=aPropertyList.begin(); I!=aPropertyList.end(); ++I)
- delete I->second;
-}
-
bool MultiPropertySetHandler::GetProperties()
{
- ::std::map< OUString, PropertyWrapperBase*, OUStringComparison>::iterator I;
css::uno::Sequence< OUString> aNameList (aPropertyList.size());
- int i;
- for (I=aPropertyList.begin(),i=0; I!=aPropertyList.end(); ++I)
+ int i = 0;
+ for (auto I=aPropertyList.begin(); I!=aPropertyList.end(); ++I)
aNameList[i++] = I->second->msName;
if ( ! MultiGet(aNameList))
if ( ! SingleGet(aNameList))
@@ -208,11 +202,10 @@ bool MultiPropertySetHandler::MultiGet (const css::uno::Sequence<
if (xMultiSet.is())
try
{
- ::std::map< OUString, PropertyWrapperBase*, OUStringComparison>::iterator I;
- int i;
+ int i = 0;
css::uno::Sequence< css::uno::Any> aValueList =
xMultiSet->getPropertyValues (rNameList);
- for (I=aPropertyList.begin(),i=0; I!=aPropertyList.end(); ++I)
+ for (auto I=aPropertyList.begin(); I!=aPropertyList.end(); ++I)
I->second->SetValue (aValueList[i++]);
}
catch (const css::beans::UnknownPropertyException&)
@@ -233,9 +226,8 @@ bool MultiPropertySetHandler::SingleGet (const css::uno::Sequence<
if (xSingleSet.is())
try
{
- ::std::map< OUString, PropertyWrapperBase*, OUStringComparison>::iterator I;
- int i;
- for (I=aPropertyList.begin(),i=0; I!=aPropertyList.end(); ++I)
+ int i = 0;
+ for (auto I=aPropertyList.begin(); I!=aPropertyList.end(); ++I)
I->second->SetValue (xSingleSet->getPropertyValue (rNameList[i++]));
}
catch (const css::beans::UnknownPropertyException&)
More information about the Libreoffice-commits
mailing list