use std::unique_ptr
Change-Id: I642486578190ed5e74a917c60153cac084f35fe8
This commit is contained in:
@@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
#include <rtl/ustring.hxx>
|
#include <rtl/ustring.hxx>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <memory>
|
||||||
#include <stack>
|
#include <stack>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@@ -37,7 +38,6 @@ class XMLTextListsHelper
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
XMLTextListsHelper();
|
XMLTextListsHelper();
|
||||||
~XMLTextListsHelper();
|
|
||||||
XMLTextListsHelper(const XMLTextListsHelper&) = delete;
|
XMLTextListsHelper(const XMLTextListsHelper&) = delete;
|
||||||
XMLTextListsHelper& operator=(const XMLTextListsHelper&) = delete;
|
XMLTextListsHelper& operator=(const XMLTextListsHelper&) = delete;
|
||||||
|
|
||||||
@@ -136,7 +136,7 @@ class XMLTextListsHelper
|
|||||||
// as value
|
// as value
|
||||||
typedef ::std::map< OUString,
|
typedef ::std::map< OUString,
|
||||||
::std::pair< OUString, OUString > > tMapForLists;
|
::std::pair< OUString, OUString > > tMapForLists;
|
||||||
tMapForLists* mpProcessedLists;
|
std::unique_ptr<tMapForLists> mpProcessedLists;
|
||||||
OUString msLastProcessedListId;
|
OUString msLastProcessedListId;
|
||||||
OUString msListStyleOfLastProcessedList;
|
OUString msListStyleOfLastProcessedList;
|
||||||
|
|
||||||
@@ -144,19 +144,19 @@ class XMLTextListsHelper
|
|||||||
map with <ListStyleName> as key and pair( <ListId, ListStyleDefaultListId> )
|
map with <ListStyleName> as key and pair( <ListId, ListStyleDefaultListId> )
|
||||||
as value. (#i92811#)
|
as value. (#i92811#)
|
||||||
*/
|
*/
|
||||||
tMapForLists* mpMapListIdToListStyleDefaultListId;
|
std::unique_ptr<tMapForLists> mpMapListIdToListStyleDefaultListId;
|
||||||
|
|
||||||
// container type to build up continue list chain:
|
// container type to build up continue list chain:
|
||||||
// map with <ListId> of master list as key and <ListId> of last list
|
// map with <ListId> of master list as key and <ListId> of last list
|
||||||
// continuing the master list as value
|
// continuing the master list as value
|
||||||
typedef ::std::map< OUString, OUString > tMapForContinuingLists;
|
typedef ::std::map< OUString, OUString > tMapForContinuingLists;
|
||||||
tMapForContinuingLists* mpContinuingLists;
|
std::unique_ptr<tMapForContinuingLists> mpContinuingLists;
|
||||||
|
|
||||||
// stack type for opened list elements and its list style:
|
// stack type for opened list elements and its list style:
|
||||||
// vector with pair( <ListId>, <ListStyleName> ) as value
|
// vector with pair( <ListId>, <ListStyleName> ) as value
|
||||||
typedef ::std::vector< ::std::pair< OUString, OUString > >
|
typedef ::std::vector< ::std::pair< OUString, OUString > >
|
||||||
tStackForLists;
|
tStackForLists;
|
||||||
tStackForLists* mpListStack;
|
std::unique_ptr<tStackForLists> mpListStack;
|
||||||
|
|
||||||
/// to connect numbered-paragraphs that have no list-id attribute:
|
/// to connect numbered-paragraphs that have no list-id attribute:
|
||||||
/// vector of pair of style-name and list-id (indexed by level)
|
/// vector of pair of style-name and list-id (indexed by level)
|
||||||
|
@@ -20,6 +20,9 @@
|
|||||||
|
|
||||||
#include <txtlists.hxx>
|
#include <txtlists.hxx>
|
||||||
#include <comphelper/random.hxx>
|
#include <comphelper/random.hxx>
|
||||||
|
|
||||||
|
#include <o3tl/make_unique.hxx>
|
||||||
|
|
||||||
#include <tools/date.hxx>
|
#include <tools/date.hxx>
|
||||||
#include <tools/time.hxx>
|
#include <tools/time.hxx>
|
||||||
|
|
||||||
@@ -38,41 +41,12 @@ using namespace ::com::sun::star;
|
|||||||
|
|
||||||
|
|
||||||
XMLTextListsHelper::XMLTextListsHelper()
|
XMLTextListsHelper::XMLTextListsHelper()
|
||||||
: mpProcessedLists( nullptr ),
|
: msLastProcessedListId(),
|
||||||
msLastProcessedListId(),
|
msListStyleOfLastProcessedList()
|
||||||
msListStyleOfLastProcessedList(),
|
|
||||||
// Inconsistent behavior regarding lists (#i92811#)
|
// 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(
|
void XMLTextListsHelper::PushListContext(
|
||||||
XMLTextListBlockContext *i_pListBlock)
|
XMLTextListBlockContext *i_pListBlock)
|
||||||
{
|
{
|
||||||
@@ -139,9 +113,9 @@ void XMLTextListsHelper::KeepListAsProcessed( const OUString& sListId,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( mpProcessedLists == nullptr )
|
if ( !mpProcessedLists )
|
||||||
{
|
{
|
||||||
mpProcessedLists = new tMapForLists();
|
mpProcessedLists = o3tl::make_unique<tMapForLists>();
|
||||||
}
|
}
|
||||||
|
|
||||||
::std::pair< OUString, OUString >
|
::std::pair< OUString, OUString >
|
||||||
@@ -154,9 +128,9 @@ void XMLTextListsHelper::KeepListAsProcessed( const OUString& sListId,
|
|||||||
// Inconsistent behavior regarding lists (#i92811#)
|
// Inconsistent behavior regarding lists (#i92811#)
|
||||||
if ( !sListStyleDefaultListId.isEmpty())
|
if ( !sListStyleDefaultListId.isEmpty())
|
||||||
{
|
{
|
||||||
if ( mpMapListIdToListStyleDefaultListId == nullptr )
|
if ( !mpMapListIdToListStyleDefaultListId )
|
||||||
{
|
{
|
||||||
mpMapListIdToListStyleDefaultListId = new tMapForLists();
|
mpMapListIdToListStyleDefaultListId = o3tl::make_unique<tMapForLists>();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( mpMapListIdToListStyleDefaultListId->find( sListStyleName ) ==
|
if ( mpMapListIdToListStyleDefaultListId->find( sListStyleName ) ==
|
||||||
@@ -172,7 +146,7 @@ void XMLTextListsHelper::KeepListAsProcessed( const OUString& sListId,
|
|||||||
|
|
||||||
bool XMLTextListsHelper::IsListProcessed( const OUString& sListId ) const
|
bool XMLTextListsHelper::IsListProcessed( const OUString& sListId ) const
|
||||||
{
|
{
|
||||||
if ( mpProcessedLists == nullptr )
|
if ( !mpProcessedLists )
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -183,7 +157,7 @@ bool XMLTextListsHelper::IsListProcessed( const OUString& sListId ) const
|
|||||||
OUString XMLTextListsHelper::GetListStyleOfProcessedList(
|
OUString XMLTextListsHelper::GetListStyleOfProcessedList(
|
||||||
const OUString& sListId ) const
|
const OUString& sListId ) const
|
||||||
{
|
{
|
||||||
if ( mpProcessedLists != nullptr )
|
if ( mpProcessedLists )
|
||||||
{
|
{
|
||||||
tMapForLists::const_iterator aIter = mpProcessedLists->find( sListId );
|
tMapForLists::const_iterator aIter = mpProcessedLists->find( sListId );
|
||||||
if ( aIter != mpProcessedLists->end() )
|
if ( aIter != mpProcessedLists->end() )
|
||||||
@@ -198,7 +172,7 @@ OUString XMLTextListsHelper::GetListStyleOfProcessedList(
|
|||||||
OUString XMLTextListsHelper::GetContinueListIdOfProcessedList(
|
OUString XMLTextListsHelper::GetContinueListIdOfProcessedList(
|
||||||
const OUString& sListId ) const
|
const OUString& sListId ) const
|
||||||
{
|
{
|
||||||
if ( mpProcessedLists != nullptr )
|
if ( mpProcessedLists )
|
||||||
{
|
{
|
||||||
tMapForLists::const_iterator aIter = mpProcessedLists->find( sListId );
|
tMapForLists::const_iterator aIter = mpProcessedLists->find( sListId );
|
||||||
if ( aIter != mpProcessedLists->end() )
|
if ( aIter != mpProcessedLists->end() )
|
||||||
@@ -232,7 +206,7 @@ OUString XMLTextListsHelper::GenerateNewListId() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
OUString sNewListId( sTmpStr );
|
OUString sNewListId( sTmpStr );
|
||||||
if ( mpProcessedLists != nullptr )
|
if ( mpProcessedLists )
|
||||||
{
|
{
|
||||||
long nHitCount = 0;
|
long nHitCount = 0;
|
||||||
while ( mpProcessedLists->find( sNewListId ) != mpProcessedLists->end() )
|
while ( mpProcessedLists->find( sNewListId ) != mpProcessedLists->end() )
|
||||||
@@ -255,7 +229,7 @@ OUString XMLTextListsHelper::GetListIdForListBlock( XMLTextListBlockContext& rLi
|
|||||||
sListBlockListId = rListBlock.GetListId();
|
sListBlockListId = rListBlock.GetListId();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( mpMapListIdToListStyleDefaultListId != nullptr )
|
if ( mpMapListIdToListStyleDefaultListId )
|
||||||
{
|
{
|
||||||
if ( !sListBlockListId.isEmpty() )
|
if ( !sListBlockListId.isEmpty() )
|
||||||
{
|
{
|
||||||
@@ -280,9 +254,9 @@ OUString XMLTextListsHelper::GetListIdForListBlock( XMLTextListBlockContext& rLi
|
|||||||
void XMLTextListsHelper::StoreLastContinuingList( const OUString& sListId,
|
void XMLTextListsHelper::StoreLastContinuingList( const OUString& sListId,
|
||||||
const OUString& sContinuingListId )
|
const OUString& sContinuingListId )
|
||||||
{
|
{
|
||||||
if ( mpContinuingLists == nullptr )
|
if ( !mpContinuingLists )
|
||||||
{
|
{
|
||||||
mpContinuingLists = new tMapForContinuingLists();
|
mpContinuingLists = o3tl::make_unique<tMapForContinuingLists>();
|
||||||
}
|
}
|
||||||
|
|
||||||
(*mpContinuingLists)[ sListId ] = sContinuingListId;
|
(*mpContinuingLists)[ sListId ] = sContinuingListId;
|
||||||
@@ -291,7 +265,7 @@ void XMLTextListsHelper::StoreLastContinuingList( const OUString& sListId,
|
|||||||
OUString XMLTextListsHelper::GetLastContinuingListId(
|
OUString XMLTextListsHelper::GetLastContinuingListId(
|
||||||
const OUString& sListId ) const
|
const OUString& sListId ) const
|
||||||
{
|
{
|
||||||
if ( mpContinuingLists != nullptr)
|
if ( mpContinuingLists )
|
||||||
{
|
{
|
||||||
tMapForContinuingLists::const_iterator aIter =
|
tMapForContinuingLists::const_iterator aIter =
|
||||||
mpContinuingLists->find( sListId );
|
mpContinuingLists->find( sListId );
|
||||||
@@ -307,9 +281,9 @@ OUString XMLTextListsHelper::GetLastContinuingListId(
|
|||||||
void XMLTextListsHelper::PushListOnStack( const OUString& sListId,
|
void XMLTextListsHelper::PushListOnStack( const OUString& sListId,
|
||||||
const OUString& sListStyleName )
|
const OUString& sListStyleName )
|
||||||
{
|
{
|
||||||
if ( mpListStack == nullptr )
|
if ( !mpListStack )
|
||||||
{
|
{
|
||||||
mpListStack = new tStackForLists();
|
mpListStack = o3tl::make_unique<tStackForLists>();
|
||||||
}
|
}
|
||||||
::std::pair< OUString, OUString >
|
::std::pair< OUString, OUString >
|
||||||
aListData( sListId, sListStyleName );
|
aListData( sListId, sListStyleName );
|
||||||
@@ -317,7 +291,7 @@ void XMLTextListsHelper::PushListOnStack( const OUString& sListId,
|
|||||||
}
|
}
|
||||||
void XMLTextListsHelper::PopListFromStack()
|
void XMLTextListsHelper::PopListFromStack()
|
||||||
{
|
{
|
||||||
if ( mpListStack != nullptr &&
|
if ( mpListStack &&
|
||||||
mpListStack->size() > 0 )
|
mpListStack->size() > 0 )
|
||||||
{
|
{
|
||||||
mpListStack->pop_back();
|
mpListStack->pop_back();
|
||||||
@@ -326,7 +300,7 @@ void XMLTextListsHelper::PopListFromStack()
|
|||||||
|
|
||||||
bool XMLTextListsHelper::EqualsToTopListStyleOnStack( const OUString& sListId ) const
|
bool XMLTextListsHelper::EqualsToTopListStyleOnStack( const OUString& sListId ) const
|
||||||
{
|
{
|
||||||
return mpListStack != nullptr && sListId == mpListStack->back().second;
|
return mpListStack && sListId == mpListStack->back().second;
|
||||||
}
|
}
|
||||||
|
|
||||||
OUString
|
OUString
|
||||||
|
Reference in New Issue
Block a user