[Libreoffice-commits] core.git: 9 commits - editeng/source include/xmloff xmloff/inc xmloff/source
David Tardon
dtardon at redhat.com
Fri Sep 9 14:17:19 UTC 2016
editeng/source/items/xmlcnitm.cxx | 3
include/xmloff/XMLFontStylesContext.hxx | 12 -
include/xmloff/XMLTextListAutoStylePool.hxx | 3
include/xmloff/controlpropertyhdl.hxx | 20 +-
include/xmloff/unoatrcn.hxx | 11 -
xmloff/inc/txtlists.hxx | 10 -
xmloff/source/core/unoatrcn.cxx | 14 -
xmloff/source/forms/controlpropertyhdl.cxx | 48 +----
xmloff/source/forms/elementexport.cxx | 27 +--
xmloff/source/forms/elementexport.hxx | 6
xmloff/source/forms/propertyexport.cxx | 208 +++++++++++-------------
xmloff/source/style/XMLFontStylesContext.cxx | 9 -
xmloff/source/text/XMLTextFrameContext.cxx | 13 -
xmloff/source/text/XMLTextFrameContext.hxx | 5
xmloff/source/text/XMLTextListAutoStylePool.cxx | 11 -
xmloff/source/text/txtlists.cxx | 68 ++-----
16 files changed, 196 insertions(+), 272 deletions(-)
New commits:
commit 8e11d353665242fc90ef485ff8f67a44206b6393
Author: David Tardon <dtardon at redhat.com>
Date: Fri Sep 9 14:55:12 2016 +0200
use std::unique_ptr
Change-Id: I8ba37267e8a7058ade54783ea0e117a8f8816c45
diff --git a/editeng/source/items/xmlcnitm.cxx b/editeng/source/items/xmlcnitm.cxx
index c1e397f..520b3b1 100644
--- a/editeng/source/items/xmlcnitm.cxx
+++ b/editeng/source/items/xmlcnitm.cxx
@@ -20,6 +20,7 @@
#include <com/sun/star/xml/AttributeData.hpp>
#include <com/sun/star/lang/XUnoTunnel.hpp>
#include <o3tl/any.hxx>
+#include <o3tl/make_unique.hxx>
#include <xmloff/xmlcnimp.hxx>
#include <xmloff/unoatrcn.hxx>
#include <editeng/xmlcnitm.hxx>
@@ -73,7 +74,7 @@ sal_uInt16 SvXMLAttrContainerItem::GetVersion( sal_uInt16 /*nFileFormatVersion*/
bool SvXMLAttrContainerItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
{
Reference<XNameContainer> xContainer =
- new SvUnoAttributeContainer( new SvXMLAttrContainerData( *pImpl.get() ) );
+ new SvUnoAttributeContainer( o3tl::make_unique<SvXMLAttrContainerData>( *pImpl.get() ) );
rVal <<= xContainer;
return true;
diff --git a/include/xmloff/unoatrcn.hxx b/include/xmloff/unoatrcn.hxx
index 1f81e91..7ba70ad 100644
--- a/include/xmloff/unoatrcn.hxx
+++ b/include/xmloff/unoatrcn.hxx
@@ -21,6 +21,9 @@
#define INCLUDED_XMLOFF_UNOATRCN_HXX
#include <sal/config.h>
+
+#include <memory>
+
#include <xmloff/dllapi.h>
#include <sal/types.h>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
@@ -41,16 +44,14 @@ class XMLOFF_DLLPUBLIC SvUnoAttributeContainer:
css::container::XNameContainer >
{
private:
- SvXMLAttrContainerData* mpContainer;
+ std::unique_ptr<SvXMLAttrContainerData> mpContainer;
SAL_DLLPRIVATE sal_uInt16 getIndexByName(const OUString& aName )
const;
public:
- SvUnoAttributeContainer( SvXMLAttrContainerData* pContainer = nullptr );
- virtual ~SvUnoAttributeContainer();
-
- SvXMLAttrContainerData* GetContainerImpl() const { return mpContainer; }
+ SvUnoAttributeContainer( std::unique_ptr<SvXMLAttrContainerData> pContainer = nullptr );
+ SvXMLAttrContainerData* GetContainerImpl() const { return mpContainer.get(); }
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId() throw();
virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) throw(css::uno::RuntimeException, std::exception) override;
diff --git a/xmloff/source/core/unoatrcn.cxx b/xmloff/source/core/unoatrcn.cxx
index 1fae778..fec3e48 100644
--- a/xmloff/source/core/unoatrcn.cxx
+++ b/xmloff/source/core/unoatrcn.cxx
@@ -20,6 +20,7 @@
#include <string.h>
#include <com/sun/star/xml/AttributeData.hpp>
#include <o3tl/any.hxx>
+#include <o3tl/make_unique.hxx>
#include <rtl/ustrbuf.hxx>
#include <comphelper/servicehelper.hxx>
#include <cppuhelper/supportsservice.hxx>
@@ -38,16 +39,11 @@ uno::Reference< uno::XInterface > SvUnoAttributeContainer_CreateInstance()
return *(new SvUnoAttributeContainer);
}
-SvUnoAttributeContainer::SvUnoAttributeContainer( SvXMLAttrContainerData* pContainer)
-: mpContainer( pContainer )
+SvUnoAttributeContainer::SvUnoAttributeContainer( std::unique_ptr<SvXMLAttrContainerData> pContainer)
+: mpContainer( std::move( pContainer ) )
{
- if( mpContainer == nullptr )
- mpContainer = new SvXMLAttrContainerData;
-}
-
-SvUnoAttributeContainer::~SvUnoAttributeContainer()
-{
- delete mpContainer;
+ if( !mpContainer )
+ mpContainer = o3tl::make_unique<SvXMLAttrContainerData>();
}
// container::XElementAccess
commit 8d458a24f79ed9ba321daa3db283eb22dbd7c27f
Author: David Tardon <dtardon at redhat.com>
Date: Fri Sep 9 14:13:49 2016 +0200
use std::unique_ptr
Change-Id: I642486578190ed5e74a917c60153cac084f35fe8
diff --git a/xmloff/inc/txtlists.hxx b/xmloff/inc/txtlists.hxx
index 68b9a61..f469671 100644
--- a/xmloff/inc/txtlists.hxx
+++ b/xmloff/inc/txtlists.hxx
@@ -22,6 +22,7 @@
#include <rtl/ustring.hxx>
#include <map>
+#include <memory>
#include <stack>
#include <tuple>
#include <vector>
@@ -37,7 +38,6 @@ class XMLTextListsHelper
{
public:
XMLTextListsHelper();
- ~XMLTextListsHelper();
XMLTextListsHelper(const XMLTextListsHelper&) = delete;
XMLTextListsHelper& operator=(const XMLTextListsHelper&) = delete;
@@ -136,7 +136,7 @@ class XMLTextListsHelper
// as value
typedef ::std::map< OUString,
::std::pair< OUString, OUString > > tMapForLists;
- tMapForLists* mpProcessedLists;
+ std::unique_ptr<tMapForLists> mpProcessedLists;
OUString msLastProcessedListId;
OUString msListStyleOfLastProcessedList;
@@ -144,19 +144,19 @@ class XMLTextListsHelper
map with <ListStyleName> as key and pair( <ListId, ListStyleDefaultListId> )
as value. (#i92811#)
*/
- tMapForLists* mpMapListIdToListStyleDefaultListId;
+ std::unique_ptr<tMapForLists> mpMapListIdToListStyleDefaultListId;
// container type to build up continue list chain:
// map with <ListId> of master list as key and <ListId> of last list
// continuing the master list as value
typedef ::std::map< OUString, OUString > tMapForContinuingLists;
- tMapForContinuingLists* mpContinuingLists;
+ std::unique_ptr<tMapForContinuingLists> mpContinuingLists;
// stack type for opened list elements and its list style:
// vector with pair( <ListId>, <ListStyleName> ) as value
typedef ::std::vector< ::std::pair< OUString, OUString > >
tStackForLists;
- tStackForLists* mpListStack;
+ std::unique_ptr<tStackForLists> mpListStack;
/// to connect numbered-paragraphs that have no list-id attribute:
/// vector of pair of style-name and list-id (indexed by level)
diff --git a/xmloff/source/text/txtlists.cxx b/xmloff/source/text/txtlists.cxx
index da1a1bc..1c7b138 100644
--- a/xmloff/source/text/txtlists.cxx
+++ b/xmloff/source/text/txtlists.cxx
@@ -20,6 +20,9 @@
#include <txtlists.hxx>
#include <comphelper/random.hxx>
+
+#include <o3tl/make_unique.hxx>
+
#include <tools/date.hxx>
#include <tools/time.hxx>
@@ -38,41 +41,12 @@ using namespace ::com::sun::star;
XMLTextListsHelper::XMLTextListsHelper()
- : mpProcessedLists( nullptr ),
- msLastProcessedListId(),
- msListStyleOfLastProcessedList(),
+ : msLastProcessedListId(),
+ msListStyleOfLastProcessedList()
// Inconsistent behavior regarding lists (#i92811#)
- mpMapListIdToListStyleDefaultListId( nullptr ),
- mpContinuingLists( nullptr ),
- mpListStack( nullptr )
{
}
-XMLTextListsHelper::~XMLTextListsHelper()
-{
- if ( mpProcessedLists )
- {
- mpProcessedLists->clear();
- delete mpProcessedLists;
- }
- // Inconsistent behavior regarding lists (#i92811#)#
- if ( mpMapListIdToListStyleDefaultListId )
- {
- mpMapListIdToListStyleDefaultListId->clear();
- delete mpMapListIdToListStyleDefaultListId;
- }
- if ( mpContinuingLists )
- {
- mpContinuingLists->clear();
- delete mpContinuingLists;
- }
- if ( mpListStack )
- {
- mpListStack->clear();
- delete mpListStack;
- }
-}
-
void XMLTextListsHelper::PushListContext(
XMLTextListBlockContext *i_pListBlock)
{
@@ -139,9 +113,9 @@ void XMLTextListsHelper::KeepListAsProcessed( const OUString& sListId,
return;
}
- if ( mpProcessedLists == nullptr )
+ if ( !mpProcessedLists )
{
- mpProcessedLists = new tMapForLists();
+ mpProcessedLists = o3tl::make_unique<tMapForLists>();
}
::std::pair< OUString, OUString >
@@ -154,9 +128,9 @@ void XMLTextListsHelper::KeepListAsProcessed( const OUString& sListId,
// Inconsistent behavior regarding lists (#i92811#)
if ( !sListStyleDefaultListId.isEmpty())
{
- if ( mpMapListIdToListStyleDefaultListId == nullptr )
+ if ( !mpMapListIdToListStyleDefaultListId )
{
- mpMapListIdToListStyleDefaultListId = new tMapForLists();
+ mpMapListIdToListStyleDefaultListId = o3tl::make_unique<tMapForLists>();
}
if ( mpMapListIdToListStyleDefaultListId->find( sListStyleName ) ==
@@ -172,7 +146,7 @@ void XMLTextListsHelper::KeepListAsProcessed( const OUString& sListId,
bool XMLTextListsHelper::IsListProcessed( const OUString& sListId ) const
{
- if ( mpProcessedLists == nullptr )
+ if ( !mpProcessedLists )
{
return false;
}
@@ -183,7 +157,7 @@ bool XMLTextListsHelper::IsListProcessed( const OUString& sListId ) const
OUString XMLTextListsHelper::GetListStyleOfProcessedList(
const OUString& sListId ) const
{
- if ( mpProcessedLists != nullptr )
+ if ( mpProcessedLists )
{
tMapForLists::const_iterator aIter = mpProcessedLists->find( sListId );
if ( aIter != mpProcessedLists->end() )
@@ -198,7 +172,7 @@ OUString XMLTextListsHelper::GetListStyleOfProcessedList(
OUString XMLTextListsHelper::GetContinueListIdOfProcessedList(
const OUString& sListId ) const
{
- if ( mpProcessedLists != nullptr )
+ if ( mpProcessedLists )
{
tMapForLists::const_iterator aIter = mpProcessedLists->find( sListId );
if ( aIter != mpProcessedLists->end() )
@@ -232,7 +206,7 @@ OUString XMLTextListsHelper::GenerateNewListId() const
}
OUString sNewListId( sTmpStr );
- if ( mpProcessedLists != nullptr )
+ if ( mpProcessedLists )
{
long nHitCount = 0;
while ( mpProcessedLists->find( sNewListId ) != mpProcessedLists->end() )
@@ -255,7 +229,7 @@ OUString XMLTextListsHelper::GetListIdForListBlock( XMLTextListBlockContext& rLi
sListBlockListId = rListBlock.GetListId();
}
- if ( mpMapListIdToListStyleDefaultListId != nullptr )
+ if ( mpMapListIdToListStyleDefaultListId )
{
if ( !sListBlockListId.isEmpty() )
{
@@ -280,9 +254,9 @@ OUString XMLTextListsHelper::GetListIdForListBlock( XMLTextListBlockContext& rLi
void XMLTextListsHelper::StoreLastContinuingList( const OUString& sListId,
const OUString& sContinuingListId )
{
- if ( mpContinuingLists == nullptr )
+ if ( !mpContinuingLists )
{
- mpContinuingLists = new tMapForContinuingLists();
+ mpContinuingLists = o3tl::make_unique<tMapForContinuingLists>();
}
(*mpContinuingLists)[ sListId ] = sContinuingListId;
@@ -291,7 +265,7 @@ void XMLTextListsHelper::StoreLastContinuingList( const OUString& sListId,
OUString XMLTextListsHelper::GetLastContinuingListId(
const OUString& sListId ) const
{
- if ( mpContinuingLists != nullptr)
+ if ( mpContinuingLists )
{
tMapForContinuingLists::const_iterator aIter =
mpContinuingLists->find( sListId );
@@ -307,9 +281,9 @@ OUString XMLTextListsHelper::GetLastContinuingListId(
void XMLTextListsHelper::PushListOnStack( const OUString& sListId,
const OUString& sListStyleName )
{
- if ( mpListStack == nullptr )
+ if ( !mpListStack )
{
- mpListStack = new tStackForLists();
+ mpListStack = o3tl::make_unique<tStackForLists>();
}
::std::pair< OUString, OUString >
aListData( sListId, sListStyleName );
@@ -317,7 +291,7 @@ void XMLTextListsHelper::PushListOnStack( const OUString& sListId,
}
void XMLTextListsHelper::PopListFromStack()
{
- if ( mpListStack != nullptr &&
+ if ( mpListStack &&
mpListStack->size() > 0 )
{
mpListStack->pop_back();
@@ -326,7 +300,7 @@ void XMLTextListsHelper::PopListFromStack()
bool XMLTextListsHelper::EqualsToTopListStyleOnStack( const OUString& sListId ) const
{
- return mpListStack != nullptr && sListId == mpListStack->back().second;
+ return mpListStack && sListId == mpListStack->back().second;
}
OUString
commit 97dbbf7282b48eccedf60696ad65cf4e9987c7a9
Author: David Tardon <dtardon at redhat.com>
Date: Fri Sep 9 13:41:01 2016 +0200
avoid manual memory management
Change-Id: Ibc4e7191e5cbc5a14c32b32bab99116173070a87
diff --git a/xmloff/source/text/XMLTextListAutoStylePool.cxx b/xmloff/source/text/XMLTextListAutoStylePool.cxx
index bbdf2f7..f480cfd 100644
--- a/xmloff/source/text/XMLTextListAutoStylePool.cxx
+++ b/xmloff/source/text/XMLTextListAutoStylePool.cxx
@@ -17,6 +17,8 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <vector>
+
#include <tools/debug.hxx>
#include <tools/solar.h>
#include <o3tl/sorted_vector.hxx>
@@ -246,16 +248,11 @@ void XMLTextListAutoStylePool::exportXML() const
if( !nCount )
return;
- XMLTextListAutoStylePoolEntry_Impl **aExpEntries =
- new XMLTextListAutoStylePoolEntry_Impl*[nCount];
+ std::vector<XMLTextListAutoStylePoolEntry_Impl*> aExpEntries(nCount);
sal_uInt32 i;
for( i=0; i < nCount; i++ )
{
- aExpEntries[i] = nullptr;
- }
- for( i=0; i < nCount; i++ )
- {
XMLTextListAutoStylePoolEntry_Impl *pEntry = (*pPool)[i];
SAL_WARN_IF( pEntry->GetPos() >= nCount, "xmloff", "Illegal pos" );
aExpEntries[pEntry->GetPos()] = pEntry;
@@ -269,7 +266,6 @@ void XMLTextListAutoStylePool::exportXML() const
aNumRuleExp.exportNumberingRule( pEntry->GetName(), false,
pEntry->GetNumRules() );
}
- delete [] aExpEntries;
}
commit 7469d7556919a4ebb54e71fbdf3be9c7f88afa13
Author: David Tardon <dtardon at redhat.com>
Date: Fri Sep 9 13:36:58 2016 +0200
use std::unique_ptr
Change-Id: I39475538ed838e4210e256d85c6dd46232f8dc50
diff --git a/include/xmloff/XMLTextListAutoStylePool.hxx b/include/xmloff/XMLTextListAutoStylePool.hxx
index cb0b90c..3b6ba29 100644
--- a/include/xmloff/XMLTextListAutoStylePool.hxx
+++ b/include/xmloff/XMLTextListAutoStylePool.hxx
@@ -25,6 +25,7 @@
#include <sal/types.h>
#include <rtl/ustring.hxx>
#include <com/sun/star/ucb/XAnyCompare.hpp>
+#include <memory>
#include <set>
namespace com { namespace sun { namespace star { namespace container {
@@ -42,7 +43,7 @@ class XMLOFF_DLLPUBLIC XMLTextListAutoStylePool
OUString sPrefix;
- XMLTextListAutoStylePool_Impl *pPool;
+ std::unique_ptr<XMLTextListAutoStylePool_Impl> pPool;
XMLTextListAutoStylePoolNames_Impl m_aNames;
sal_uInt32 nName;
diff --git a/xmloff/source/text/XMLTextListAutoStylePool.cxx b/xmloff/source/text/XMLTextListAutoStylePool.cxx
index 10f5e6d..bbdf2f7 100644
--- a/xmloff/source/text/XMLTextListAutoStylePool.cxx
+++ b/xmloff/source/text/XMLTextListAutoStylePool.cxx
@@ -157,7 +157,6 @@ XMLTextListAutoStylePool::~XMLTextListAutoStylePool()
{
// The XMLTextListAutoStylePoolEntry_Impl object in the pool need delete explicitly in dtor.
pPool->DeleteAndDestroyAll();
- delete pPool;
}
void XMLTextListAutoStylePool::RegisterName( const OUString& rName )
commit bbb017f95ec70c8d10dc6e1473f14eeda9ff6144
Author: David Tardon <dtardon at redhat.com>
Date: Fri Sep 9 12:57:01 2016 +0200
use std::unique_ptr
Change-Id: I52713ea0015a5f0118c337279f37bc38b1121f1e
diff --git a/xmloff/source/text/XMLTextFrameContext.cxx b/xmloff/source/text/XMLTextFrameContext.cxx
index bb6ae18..d49df3c 100644
--- a/xmloff/source/text/XMLTextFrameContext.cxx
+++ b/xmloff/source/text/XMLTextFrameContext.cxx
@@ -17,6 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <o3tl/make_unique.hxx>
#include <tools/debug.hxx>
#include <osl/diagnose.h>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
@@ -1341,7 +1342,6 @@ XMLTextFrameContext::XMLTextFrameContext(
: SvXMLImportContext( rImport, nPrfx, rLName )
, MultiImageImportHelper()
, m_xAttrList( new SvXMLAttributeList( xAttrList ) )
-, m_pHyperlink( nullptr )
// Implement Title/Description Elements UI (#i73249#)
, m_sTitle()
, m_sDesc()
@@ -1391,11 +1391,6 @@ XMLTextFrameContext::XMLTextFrameContext(
}
}
-XMLTextFrameContext::~XMLTextFrameContext()
-{
- delete m_pHyperlink;
-}
-
void XMLTextFrameContext::EndElement()
{
/// solve if multiple image child contexts were imported
@@ -1429,8 +1424,7 @@ void XMLTextFrameContext::EndElement()
{
pImpl->SetHyperlink( m_pHyperlink->GetHRef(), m_pHyperlink->GetName(),
m_pHyperlink->GetTargetFrameName(), m_pHyperlink->GetMap() );
- delete m_pHyperlink;
- m_pHyperlink = nullptr;
+ m_pHyperlink.reset();
}
}
@@ -1651,8 +1645,7 @@ void XMLTextFrameContext::SetHyperlink( const OUString& rHRef,
bool bMap )
{
OSL_ENSURE( !m_pHyperlink, "recursive SetHyperlink call" );
- delete m_pHyperlink;
- m_pHyperlink = new XMLTextFrameContextHyperlink_Impl(
+ m_pHyperlink = o3tl::make_unique<XMLTextFrameContextHyperlink_Impl>(
rHRef, rName, rTargetFrameName, bMap );
}
diff --git a/xmloff/source/text/XMLTextFrameContext.hxx b/xmloff/source/text/XMLTextFrameContext.hxx
index 4e297ab..8f19eda 100644
--- a/xmloff/source/text/XMLTextFrameContext.hxx
+++ b/xmloff/source/text/XMLTextFrameContext.hxx
@@ -20,6 +20,8 @@
#ifndef INCLUDED_XMLOFF_SOURCE_TEXT_XMLTEXTFRAMECONTEXT_HXX
#define INCLUDED_XMLOFF_SOURCE_TEXT_XMLTEXTFRAMECONTEXT_HXX
+#include <memory>
+
#include <com/sun/star/text/TextContentAnchorType.hpp>
#include <xmloff/xmlictxt.hxx>
#include <xmloff/xmlmultiimagehelper.hxx>
@@ -37,7 +39,7 @@ class XMLTextFrameContext : public SvXMLImportContext, public MultiImageImportHe
SvXMLImportContextRef m_xImplContext;
SvXMLImportContextRef m_xReplImplContext;
- XMLTextFrameContextHyperlink_Impl *m_pHyperlink;
+ std::unique_ptr<XMLTextFrameContextHyperlink_Impl> m_pHyperlink;
// Implement Title/Description Elements UI (#i73249#)
OUString m_sTitle;
OUString m_sDesc;
@@ -69,7 +71,6 @@ public:
const css::uno::Reference<
css::xml::sax::XAttributeList > & xAttrList,
css::text::TextContentAnchorType eDfltAnchorType );
- virtual ~XMLTextFrameContext();
virtual void EndElement() override;
commit 66e6278e9ad0537843cfecbfee9bcf808702a141
Author: David Tardon <dtardon at redhat.com>
Date: Fri Sep 9 12:52:48 2016 +0200
use std::unique_ptr
Change-Id: I507b19dfd7445144258554b08bbf2fea0ed1698f
diff --git a/include/xmloff/XMLFontStylesContext.hxx b/include/xmloff/XMLFontStylesContext.hxx
index e00a3866d..d671e65 100644
--- a/include/xmloff/XMLFontStylesContext.hxx
+++ b/include/xmloff/XMLFontStylesContext.hxx
@@ -22,6 +22,7 @@
#include <sal/config.h>
#include <xmloff/dllapi.h>
+#include <memory>
#include <vector>
#include <xmloff/xmlstyle.hxx>
@@ -35,12 +36,12 @@ class XMLFontEncodingPropHdl;
class XMLOFF_DLLPUBLIC XMLFontStylesContext : public SvXMLStylesContext
{
- XMLFontFamilyNamePropHdl *pFamilyNameHdl;
- XMLFontFamilyPropHdl *pFamilyHdl;
- XMLFontPitchPropHdl *pPitchHdl;
- XMLFontEncodingPropHdl *pEncHdl;
+ std::unique_ptr<XMLFontFamilyNamePropHdl> pFamilyNameHdl;
+ std::unique_ptr<XMLFontFamilyPropHdl> pFamilyHdl;
+ std::unique_ptr<XMLFontPitchPropHdl> pPitchHdl;
+ std::unique_ptr<XMLFontEncodingPropHdl> pEncHdl;
- SvXMLTokenMap *pFontStyleAttrTokenMap;
+ std::unique_ptr<SvXMLTokenMap> pFontStyleAttrTokenMap;
rtl_TextEncoding eDfltEncoding;
@@ -57,7 +58,6 @@ public:
const OUString& rLName,
const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList,
rtl_TextEncoding eDfltEnc );
- virtual ~XMLFontStylesContext();
const SvXMLTokenMap& GetFontStyleAttrTokenMap() const
{
diff --git a/xmloff/source/style/XMLFontStylesContext.cxx b/xmloff/source/style/XMLFontStylesContext.cxx
index 2d5469d..28fb855 100644
--- a/xmloff/source/style/XMLFontStylesContext.cxx
+++ b/xmloff/source/style/XMLFontStylesContext.cxx
@@ -377,15 +377,6 @@ XMLFontStylesContext::XMLFontStylesContext( SvXMLImport& rImport,
{
}
-XMLFontStylesContext::~XMLFontStylesContext()
-{
- delete pFamilyNameHdl;
- delete pFamilyHdl;
- delete pPitchHdl;
- delete pEncHdl;
- delete pFontStyleAttrTokenMap;
-}
-
bool XMLFontStylesContext::FillProperties( const OUString& rName,
::std::vector< XMLPropertyState > &rProps,
sal_Int32 nFamilyNameIdx,
commit 064a33a3b8e194876a4e368f65d8df2ff86ce381
Author: David Tardon <dtardon at redhat.com>
Date: Fri Sep 9 12:48:00 2016 +0200
use std::unique_ptr
Change-Id: I3d7a8a8296e1d107b1f364b5c0785fc9f19cbed5
diff --git a/xmloff/source/forms/elementexport.cxx b/xmloff/source/forms/elementexport.cxx
index cd9d89b..f1d1a98 100644
--- a/xmloff/source/forms/elementexport.cxx
+++ b/xmloff/source/forms/elementexport.cxx
@@ -18,6 +18,9 @@
*/
#include "elementexport.hxx"
+
+#include <o3tl/make_unique.hxx>
+
#include "strings.hxx"
#include <xmloff/xmlnmspe.hxx>
#include "eventexport.hxx"
@@ -92,13 +95,11 @@ namespace xmloff
const Sequence< ScriptEventDescriptor >& _rEvents)
:OPropertyExport(_rContext, _rxProps)
,m_aEvents(_rEvents)
- ,m_pXMLElement(nullptr)
{
}
OElementExport::~OElementExport()
{
- delete m_pXMLElement;
}
void OElementExport::doExport()
@@ -142,13 +143,12 @@ namespace xmloff
void OElementExport::implStartElement(const sal_Char* _pName)
{
- m_pXMLElement = new SvXMLElementExport(m_rContext.getGlobalContext(), XML_NAMESPACE_FORM, _pName, true, true);
+ m_pXMLElement = o3tl::make_unique<SvXMLElementExport>(m_rContext.getGlobalContext(), XML_NAMESPACE_FORM, _pName, true, true);
}
void OElementExport::implEndElement()
{
- delete m_pXMLElement;
- m_pXMLElement = nullptr;
+ m_pXMLElement.reset();
}
void OElementExport::exportServiceNameAttribute()
@@ -239,17 +239,10 @@ namespace xmloff
,m_nIncludeSpecial(SCAFlags::NONE)
,m_nIncludeEvents(EAFlags::NONE)
,m_nIncludeBindings(BAFlags::NONE)
- ,m_pOuterElement(nullptr)
{
OSL_ENSURE(m_xProps.is(), "OControlExport::OControlExport: invalid arguments!");
}
- OControlExport::~OControlExport()
- {
- // end the outer element if it exists
- delete m_pOuterElement;
- }
-
void OControlExport::exportOuterAttributes()
{
// the control id
@@ -1407,13 +1400,12 @@ namespace xmloff
{
// before we let the base class start it's outer element, we add a wrapper element
const sal_Char *pOuterElementName = getOuterXMLElementName();
- m_pOuterElement = pOuterElementName
- ? new SvXMLElementExport(
+ if (pOuterElementName)
+ m_pOuterElement = o3tl::make_unique<SvXMLElementExport>(
m_rContext.getGlobalContext(),
XML_NAMESPACE_FORM,
pOuterElementName, true,
- true)
- : nullptr;
+ true);
// add the attributes for the inner element
exportInnerAttributes();
@@ -1428,8 +1420,7 @@ namespace xmloff
OElementExport::implEndElement();
// end the outer element if it exists
- delete m_pOuterElement;
- m_pOuterElement = nullptr;
+ m_pOuterElement.reset();
}
const sal_Char* OControlExport::getOuterXMLElementName() const
diff --git a/xmloff/source/forms/elementexport.hxx b/xmloff/source/forms/elementexport.hxx
index f3b2f0a..665c0d9 100644
--- a/xmloff/source/forms/elementexport.hxx
+++ b/xmloff/source/forms/elementexport.hxx
@@ -22,6 +22,7 @@
#include <sal/config.h>
+#include <memory>
#include <set>
#include <com/sun/star/beans/XPropertySet.hpp>
@@ -43,7 +44,7 @@ namespace xmloff
css::uno::Sequence< css::script::ScriptEventDescriptor >
m_aEvents;
- SvXMLElementExport* m_pXMLElement; // XML element doing the concrete startElement etc.
+ std::unique_ptr<SvXMLElementExport> m_pXMLElement; // XML element doing the concrete startElement etc.
public:
OElementExport(IFormsExportContext& _rContext,
@@ -100,7 +101,7 @@ namespace xmloff
EAFlags m_nIncludeEvents; // events to include
BAFlags m_nIncludeBindings; // binding attributes to include
- SvXMLElementExport* m_pOuterElement; // XML element doing the concrete startElement etc. for the outer element
+ std::unique_ptr<SvXMLElementExport> m_pOuterElement; // XML element doing the concrete startElement etc. for the outer element
public:
/** constructs an object capable of exporting controls
@@ -119,7 +120,6 @@ namespace xmloff
const OUString& _rControlId,
const OUString& _rReferringControls,
const css::uno::Sequence< css::script::ScriptEventDescriptor >& _rxEvents);
- virtual ~OControlExport();
protected:
/// start the XML element
commit ab028d991a4c9618c59fd71ddcc4c8f64428264c
Author: David Tardon <dtardon at redhat.com>
Date: Fri Sep 9 12:42:22 2016 +0200
use std::unique_ptr
Change-Id: I55c6282c7b60cceb702a5f2f0f24b8ad288ec716
diff --git a/xmloff/source/forms/propertyexport.cxx b/xmloff/source/forms/propertyexport.cxx
index b5db7bb..650bf60 100644
--- a/xmloff/source/forms/propertyexport.cxx
+++ b/xmloff/source/forms/propertyexport.cxx
@@ -18,6 +18,11 @@
*/
#include "propertyexport.hxx"
+
+#include <memory>
+
+#include <o3tl/make_unique.hxx>
+
#include <xmloff/xmlexp.hxx>
#include "strings.hxx"
#include <xmloff/xmlnmspe.hxx>
@@ -99,131 +104,122 @@ namespace xmloff
void OPropertyExport::exportRemainingProperties()
{
// the properties tag (will be created if we have at least one no-default property)
- SvXMLElementExport* pPropertiesTag = nullptr;
+ std::unique_ptr<SvXMLElementExport> pPropertiesTag;
- try
+ Any aValue;
+ OUString sValue;
+
+ // loop through all the properties which are yet to be exported
+ for ( StringSet::const_iterator aProperty = m_aRemainingProps.begin();
+ aProperty != m_aRemainingProps.end();
+ ++aProperty
+ )
{
- Any aValue;
- OUString sValue;
-
- // loop through all the properties which are yet to be exported
- for ( StringSet::const_iterator aProperty = m_aRemainingProps.begin();
- aProperty != m_aRemainingProps.end();
- ++aProperty
- )
- {
- DBG_CHECK_PROPERTY_NO_TYPE(*aProperty);
+ DBG_CHECK_PROPERTY_NO_TYPE(*aProperty);
- #if OSL_DEBUG_LEVEL > 0
- const OUString sPropertyName = *aProperty; (void)sPropertyName;
- #endif
- if ( !shouldExportProperty( *aProperty ) )
- continue;
+#if OSL_DEBUG_LEVEL > 0
+ const OUString sPropertyName = *aProperty; (void)sPropertyName;
+#endif
+ if ( !shouldExportProperty( *aProperty ) )
+ continue;
- // now that we have the first sub-tag we need the form:properties element
- if (!pPropertiesTag)
- pPropertiesTag = new SvXMLElementExport(m_rContext.getGlobalContext(), XML_NAMESPACE_FORM, token::XML_PROPERTIES, true, true);
+ // now that we have the first sub-tag we need the form:properties element
+ if (!pPropertiesTag)
+ pPropertiesTag = o3tl::make_unique<SvXMLElementExport>(m_rContext.getGlobalContext(), XML_NAMESPACE_FORM, token::XML_PROPERTIES, true, true);
- // add the name attribute
- AddAttribute(XML_NAMESPACE_FORM, token::XML_PROPERTY_NAME, *aProperty);
+ // add the name attribute
+ AddAttribute(XML_NAMESPACE_FORM, token::XML_PROPERTY_NAME, *aProperty);
- // get the value
- aValue = m_xProps->getPropertyValue(*aProperty);
+ // get the value
+ aValue = m_xProps->getPropertyValue(*aProperty);
- // the type to export
- Type aExportType;
+ // the type to export
+ Type aExportType;
- // is it a sequence
- bool bIsSequence = TypeClass_SEQUENCE == aValue.getValueTypeClass();
- // the type of the property, maybe reduced to the element type of a sequence
- if (bIsSequence)
- aExportType = getSequenceElementType( aValue.getValueType() );
- else
- aExportType = aValue.getValueType();
+ // is it a sequence
+ bool bIsSequence = TypeClass_SEQUENCE == aValue.getValueTypeClass();
+ // the type of the property, maybe reduced to the element type of a sequence
+ if (bIsSequence)
+ aExportType = getSequenceElementType( aValue.getValueType() );
+ else
+ aExportType = aValue.getValueType();
- // the type attribute
+ // the type attribute
- bool bIsEmptyValue = TypeClass_VOID == aValue.getValueType().getTypeClass();
- if ( bIsEmptyValue )
- {
- css::beans::Property aPropDesc;
- aPropDesc = m_xPropertyInfo->getPropertyByName( *aProperty );
- aExportType = aPropDesc.Type;
- }
- token::XMLTokenEnum eValueType = implGetPropertyXMLType( aExportType );
+ bool bIsEmptyValue = TypeClass_VOID == aValue.getValueType().getTypeClass();
+ if ( bIsEmptyValue )
+ {
+ css::beans::Property aPropDesc;
+ aPropDesc = m_xPropertyInfo->getPropertyByName( *aProperty );
+ aExportType = aPropDesc.Type;
+ }
+ token::XMLTokenEnum eValueType = implGetPropertyXMLType( aExportType );
- if ( bIsEmptyValue )
- AddAttribute( XML_NAMESPACE_OFFICE, token::XML_VALUE_TYPE, token::XML_VOID );
- else
- AddAttribute( XML_NAMESPACE_OFFICE, token::XML_VALUE_TYPE, eValueType );
+ if ( bIsEmptyValue )
+ AddAttribute( XML_NAMESPACE_OFFICE, token::XML_VALUE_TYPE, token::XML_VOID );
+ else
+ AddAttribute( XML_NAMESPACE_OFFICE, token::XML_VALUE_TYPE, eValueType );
- token::XMLTokenEnum eValueAttName( token::XML_VALUE );
- switch ( eValueType )
- {
- case token::XML_BOOLEAN: eValueAttName = token::XML_BOOLEAN_VALUE; break;
- case token::XML_STRING: eValueAttName = token::XML_STRING_VALUE; break;
- default: break;
- }
+ token::XMLTokenEnum eValueAttName( token::XML_VALUE );
+ switch ( eValueType )
+ {
+ case token::XML_BOOLEAN: eValueAttName = token::XML_BOOLEAN_VALUE; break;
+ case token::XML_STRING: eValueAttName = token::XML_STRING_VALUE; break;
+ default: break;
+ }
- if( !bIsSequence && !bIsEmptyValue )
- { // the simple case
+ if( !bIsSequence && !bIsEmptyValue )
+ { // the simple case
- sValue = implConvertAny(aValue);
- AddAttribute(XML_NAMESPACE_OFFICE, eValueAttName, sValue );
- }
+ sValue = implConvertAny(aValue);
+ AddAttribute(XML_NAMESPACE_OFFICE, eValueAttName, sValue );
+ }
- // start the property tag
- SvXMLElementExport aValueTag1(m_rContext.getGlobalContext(),
- XML_NAMESPACE_FORM,
- bIsSequence ? token::XML_LIST_PROPERTY
- : token::XML_PROPERTY, true, true);
+ // start the property tag
+ SvXMLElementExport aValueTag1(m_rContext.getGlobalContext(),
+ XML_NAMESPACE_FORM,
+ bIsSequence ? token::XML_LIST_PROPERTY
+ : token::XML_PROPERTY, true, true);
- if (!bIsSequence)
- continue;
+ if (!bIsSequence)
+ continue;
- // the not-that-simple case, we need to iterate through the sequence elements
- switch ( aExportType.getTypeClass() )
- {
- case TypeClass_STRING:
- exportRemainingPropertiesSequence< OUString >(
- aValue, eValueAttName);
- break;
- case TypeClass_DOUBLE:
- exportRemainingPropertiesSequence< double >(
- aValue, eValueAttName);
- break;
- case TypeClass_BOOLEAN:
- exportRemainingPropertiesSequence< sal_Bool >(
- aValue, eValueAttName);
- break;
- case TypeClass_BYTE:
- exportRemainingPropertiesSequence< sal_Int8 >(
- aValue, eValueAttName);
- break;
- case TypeClass_SHORT:
- exportRemainingPropertiesSequence< sal_Int16 >(
- aValue, eValueAttName);
- break;
- case TypeClass_LONG:
- exportRemainingPropertiesSequence< sal_Int32 >(
- aValue, eValueAttName);
- break;
- case TypeClass_HYPER:
- exportRemainingPropertiesSequence< sal_Int64 >(
- aValue, eValueAttName);
- break;
- default:
- OSL_FAIL("OPropertyExport::exportRemainingProperties: unsupported sequence tyoe !");
- break;
- }
+ // the not-that-simple case, we need to iterate through the sequence elements
+ switch ( aExportType.getTypeClass() )
+ {
+ case TypeClass_STRING:
+ exportRemainingPropertiesSequence< OUString >(
+ aValue, eValueAttName);
+ break;
+ case TypeClass_DOUBLE:
+ exportRemainingPropertiesSequence< double >(
+ aValue, eValueAttName);
+ break;
+ case TypeClass_BOOLEAN:
+ exportRemainingPropertiesSequence< sal_Bool >(
+ aValue, eValueAttName);
+ break;
+ case TypeClass_BYTE:
+ exportRemainingPropertiesSequence< sal_Int8 >(
+ aValue, eValueAttName);
+ break;
+ case TypeClass_SHORT:
+ exportRemainingPropertiesSequence< sal_Int16 >(
+ aValue, eValueAttName);
+ break;
+ case TypeClass_LONG:
+ exportRemainingPropertiesSequence< sal_Int32 >(
+ aValue, eValueAttName);
+ break;
+ case TypeClass_HYPER:
+ exportRemainingPropertiesSequence< sal_Int64 >(
+ aValue, eValueAttName);
+ break;
+ default:
+ OSL_FAIL("OPropertyExport::exportRemainingProperties: unsupported sequence tyoe !");
+ break;
}
}
- catch(...)
- {
- delete pPropertiesTag;
- throw;
- }
- delete pPropertiesTag;
}
void OPropertyExport::examinePersistence()
commit ecb2850003ed2e9d40da1c3d3ac3ee043ce2bf76
Author: David Tardon <dtardon at redhat.com>
Date: Fri Sep 9 12:35:41 2016 +0200
use std::unique_ptr
Change-Id: Ic0cb9399e5cfc7237a3cda666b1d4f926761a9ca
diff --git a/include/xmloff/controlpropertyhdl.hxx b/include/xmloff/controlpropertyhdl.hxx
index 685f407..e043b16 100644
--- a/include/xmloff/controlpropertyhdl.hxx
+++ b/include/xmloff/controlpropertyhdl.hxx
@@ -21,6 +21,9 @@
#define INCLUDED_XMLOFF_CONTROLPROPERTYHDL_HXX
#include <sal/config.h>
+
+#include <memory>
+
#include <xmloff/dllapi.h>
#include <xmloff/prhdlfac.hxx>
#include <rtl/ref.hxx>
@@ -110,16 +113,13 @@ namespace xmloff
class XMLOFF_DLLPUBLIC OControlPropertyHandlerFactory : public XMLPropertyHandlerFactory
{
protected:
- mutable XMLConstantsPropertyHandler* m_pTextAlignHandler;
- mutable OControlBorderHandler* m_pControlBorderStyleHandler;
- mutable OControlBorderHandler* m_pControlBorderColorHandler;
- mutable ORotationAngleHandler* m_pRotationAngleHandler;
- mutable OFontWidthHandler* m_pFontWidthHandler;
- mutable XMLConstantsPropertyHandler* m_pFontEmphasisHandler;
- mutable XMLConstantsPropertyHandler* m_pFontReliefHandler;
-
- protected:
- virtual ~OControlPropertyHandlerFactory();
+ mutable std::unique_ptr<XMLConstantsPropertyHandler> m_pTextAlignHandler;
+ mutable std::unique_ptr<OControlBorderHandler> m_pControlBorderStyleHandler;
+ mutable std::unique_ptr<OControlBorderHandler> m_pControlBorderColorHandler;
+ mutable std::unique_ptr<ORotationAngleHandler> m_pRotationAngleHandler;
+ mutable std::unique_ptr<OFontWidthHandler> m_pFontWidthHandler;
+ mutable std::unique_ptr<XMLConstantsPropertyHandler> m_pFontEmphasisHandler;
+ mutable std::unique_ptr<XMLConstantsPropertyHandler> m_pFontReliefHandler;
public:
OControlPropertyHandlerFactory();
diff --git a/xmloff/source/forms/controlpropertyhdl.cxx b/xmloff/source/forms/controlpropertyhdl.cxx
index 855df15..e313f98 100644
--- a/xmloff/source/forms/controlpropertyhdl.cxx
+++ b/xmloff/source/forms/controlpropertyhdl.cxx
@@ -19,6 +19,8 @@
#include <xmloff/controlpropertyhdl.hxx>
+#include <o3tl/make_unique.hxx>
+
#include <com/sun/star/util/MeasureUnit.hpp>
#include <com/sun/star/awt/TextAlign.hpp>
#include <com/sun/star/awt/FontWidth.hpp>
@@ -47,25 +49,7 @@ namespace xmloff
//= OControlPropertyHandlerFactory
OControlPropertyHandlerFactory::OControlPropertyHandlerFactory()
- :m_pTextAlignHandler(nullptr)
- ,m_pControlBorderStyleHandler(nullptr)
- ,m_pControlBorderColorHandler(nullptr)
- ,m_pRotationAngleHandler(nullptr)
- ,m_pFontWidthHandler(nullptr)
- ,m_pFontEmphasisHandler(nullptr)
- ,m_pFontReliefHandler(nullptr)
- {
- }
-
- OControlPropertyHandlerFactory::~OControlPropertyHandlerFactory()
{
- delete m_pTextAlignHandler;
- delete m_pControlBorderStyleHandler;
- delete m_pControlBorderColorHandler;
- delete m_pRotationAngleHandler;
- delete m_pFontWidthHandler;
- delete m_pFontEmphasisHandler;
- delete m_pFontReliefHandler;
}
const XMLPropertyHandler* OControlPropertyHandlerFactory::GetPropertyHandler(sal_Int32 _nType) const
@@ -76,44 +60,44 @@ namespace xmloff
{
case XML_TYPE_TEXT_ALIGN:
if (!m_pTextAlignHandler)
- m_pTextAlignHandler = new XMLConstantsPropertyHandler(OEnumMapper::getEnumMap(OEnumMapper::epTextAlign), XML_TOKEN_INVALID );
- pHandler = m_pTextAlignHandler;
+ m_pTextAlignHandler = o3tl::make_unique<XMLConstantsPropertyHandler>(OEnumMapper::getEnumMap(OEnumMapper::epTextAlign), XML_TOKEN_INVALID );
+ pHandler = m_pTextAlignHandler.get();
break;
case XML_TYPE_CONTROL_BORDER:
if (!m_pControlBorderStyleHandler)
- m_pControlBorderStyleHandler = new OControlBorderHandler( OControlBorderHandler::STYLE );
- pHandler = m_pControlBorderStyleHandler;
+ m_pControlBorderStyleHandler = o3tl::make_unique<OControlBorderHandler>( OControlBorderHandler::STYLE );
+ pHandler = m_pControlBorderStyleHandler.get();
break;
case XML_TYPE_CONTROL_BORDER_COLOR:
if ( !m_pControlBorderColorHandler )
- m_pControlBorderColorHandler = new OControlBorderHandler( OControlBorderHandler::COLOR );
- pHandler = m_pControlBorderColorHandler;
+ m_pControlBorderColorHandler = o3tl::make_unique<OControlBorderHandler>( OControlBorderHandler::COLOR );
+ pHandler = m_pControlBorderColorHandler.get();
break;
case XML_TYPE_ROTATION_ANGLE:
if (!m_pRotationAngleHandler)
- m_pRotationAngleHandler = new ORotationAngleHandler;
- pHandler = m_pRotationAngleHandler;
+ m_pRotationAngleHandler = o3tl::make_unique<ORotationAngleHandler>();
+ pHandler = m_pRotationAngleHandler.get();
break;
case XML_TYPE_FONT_WIDTH:
if (!m_pFontWidthHandler)
- m_pFontWidthHandler = new OFontWidthHandler;
- pHandler = m_pFontWidthHandler;
+ m_pFontWidthHandler = o3tl::make_unique<OFontWidthHandler>();
+ pHandler = m_pFontWidthHandler.get();
break;
case XML_TYPE_CONTROL_TEXT_EMPHASIZE:
if (!m_pFontEmphasisHandler)
- m_pFontEmphasisHandler = new XMLConstantsPropertyHandler( OEnumMapper::getEnumMap(OEnumMapper::epFontEmphasis), XML_NONE );
- pHandler = m_pFontEmphasisHandler;
+ m_pFontEmphasisHandler = o3tl::make_unique<XMLConstantsPropertyHandler>( OEnumMapper::getEnumMap(OEnumMapper::epFontEmphasis), XML_NONE );
+ pHandler = m_pFontEmphasisHandler.get();
break;
case XML_TYPE_TEXT_FONT_RELIEF:
if (!m_pFontReliefHandler)
- m_pFontReliefHandler = new XMLConstantsPropertyHandler( OEnumMapper::getEnumMap(OEnumMapper::epFontRelief), XML_NONE );
- pHandler = m_pFontReliefHandler;
+ m_pFontReliefHandler = o3tl::make_unique<XMLConstantsPropertyHandler>( OEnumMapper::getEnumMap(OEnumMapper::epFontRelief), XML_NONE );
+ pHandler = m_pFontReliefHandler.get();
break;
case XML_TYPE_TEXT_LINE_MODE:
pHandler = new XMLNamedBoolPropertyHdl(
More information about the Libreoffice-commits
mailing list