summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
authorDavid Tardon <dtardon@redhat.com>2016-09-09 14:13:49 +0200
committerDavid Tardon <dtardon@redhat.com>2016-09-09 16:16:45 +0200
commit8d458a24f79ed9ba321daa3db283eb22dbd7c27f (patch)
tree2383f349f332ad830b8ac5a4ce9740d9006bf14e /xmloff
parent97dbbf7282b48eccedf60696ad65cf4e9987c7a9 (diff)
use std::unique_ptr
Change-Id: I642486578190ed5e74a917c60153cac084f35fe8
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/inc/txtlists.hxx10
-rw-r--r--xmloff/source/text/txtlists.cxx68
2 files changed, 26 insertions, 52 deletions
diff --git a/xmloff/inc/txtlists.hxx b/xmloff/inc/txtlists.hxx
index 68b9a61dade1..f4696713908e 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 da1a1bc2b3d1..1c7b1389e9d4 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