[Libreoffice-commits] core.git: 3 commits - editeng/source include/editeng
Michael Stahl
mstahl at redhat.com
Mon Jul 20 04:55:15 PDT 2015
editeng/source/editeng/eertfpar.cxx | 13 +-
editeng/source/rtf/rtfitem.cxx | 4
editeng/source/rtf/svxrtf.cxx | 162 ++++++++++++++++++------------------
include/editeng/svxrtf.hxx | 31 ++----
4 files changed, 103 insertions(+), 107 deletions(-)
New commits:
commit a0021a7fbf3b9799829f4a27efe20e992e8709f6
Author: Michael Stahl <mstahl at redhat.com>
Date: Mon Jul 20 13:32:03 2015 +0200
editeng: replace boost::ptr_vector with std::vector<std::unique_ptr>>
Change-Id: I29923bc78100d4b196d285dd78f664f7bcf3df19
diff --git a/editeng/source/rtf/rtfitem.cxx b/editeng/source/rtf/rtfitem.cxx
index ca864e1..5e1f233 100644
--- a/editeng/source/rtf/rtfitem.cxx
+++ b/editeng/source/rtf/rtfitem.cxx
@@ -244,7 +244,7 @@ void SvxRTFParser::ReadAttr( int nToken, SfxItemSet* pSet )
if( RTF_PARD == nLastToken || RTF_PLAIN == nLastToken )
break;
- if( pAkt->aAttrSet.Count() || pAkt->pChildList ||
+ if (pAkt->aAttrSet.Count() || pAkt->m_pChildList ||
pAkt->nStyleNo )
{
// Open a new Group
@@ -1715,7 +1715,7 @@ void SvxRTFParser::RTFPardPlain( bool const bPard, SfxItemSet** ppSet )
RTF_PLAIN != nLastToken &&
BRACELEFT != nLastToken )
{
- if( pAkt->aAttrSet.Count() || pAkt->pChildList || pAkt->nStyleNo )
+ if (pAkt->aAttrSet.Count() || pAkt->m_pChildList || pAkt->nStyleNo)
{
// open a new group
SvxRTFItemStackType* pNew = new SvxRTFItemStackType( *pAkt, *pInsPos, true );
diff --git a/editeng/source/rtf/svxrtf.cxx b/editeng/source/rtf/svxrtf.cxx
index 2656e44..6fb3283 100644
--- a/editeng/source/rtf/svxrtf.cxx
+++ b/editeng/source/rtf/svxrtf.cxx
@@ -195,11 +195,11 @@ INSINGLECHAR:
{
InsertText();
// all collected Attributes are set
- for( sal_uInt16 n = aAttrSetList.size(); n; )
+ for (size_t n = m_AttrSetList.size(); n; )
{
- SvxRTFItemStackType* pStkSet = &aAttrSetList[--n];
+ auto const& pStkSet = m_AttrSetList[--n];
SetAttrSet( *pStkSet );
- aAttrSetList.pop_back();
+ m_AttrSetList.pop_back();
}
}
break;
@@ -876,7 +876,7 @@ void SvxRTFParser::AttrGroupEnd() // process the current, delete from Stack
do { // middle check loop
sal_Int32 nOldSttNdIdx = pOld->pSttNd->GetIdx();
- if( !pOld->pChildList &&
+ if (!pOld->m_pChildList &&
((!pOld->aAttrSet.Count() && !pOld->nStyleNo ) ||
(nOldSttNdIdx == pInsPos->GetNodeIdx() &&
pOld->nSttCnt == pInsPos->GetCntIdx() )))
@@ -899,7 +899,7 @@ void SvxRTFParser::AttrGroupEnd() // process the current, delete from Stack
pItem = aIter.NextItem();
}
- if( !pOld->aAttrSet.Count() && !pOld->pChildList &&
+ if (!pOld->aAttrSet.Count() && !pOld->m_pChildList &&
!pOld->nStyleNo )
break;
}
@@ -933,8 +933,8 @@ void SvxRTFParser::AttrGroupEnd() // process the current, delete from Stack
// - all character attributes sre keep the area
// - all paragraph attributes to get the area
// up to the previous paragraph
- SvxRTFItemStackType* pNew = new SvxRTFItemStackType(
- *pOld, *pInsPos, true );
+ ::std::unique_ptr<SvxRTFItemStackType> pNew(
+ new SvxRTFItemStackType(*pOld, *pInsPos, true));
pNew->aAttrSet.SetParent( pOld->aAttrSet.GetParent() );
// Delete all paragraph attributes from pNew
@@ -946,7 +946,9 @@ void SvxRTFParser::AttrGroupEnd() // process the current, delete from Stack
// Were there any?
if( pNew->aAttrSet.Count() == pOld->aAttrSet.Count() )
- delete pNew;
+ {
+ pNew.reset();
+ }
else
{
pNew->nStyleNo = 0;
@@ -963,16 +965,16 @@ void SvxRTFParser::AttrGroupEnd() // process the current, delete from Stack
if( pAkt )
{
- pAkt->Add( pOld );
- pAkt->Add( pNew );
+ pAkt->Add(std::unique_ptr<SvxRTFItemStackType>(pOld));
+ pAkt->Add(std::move(pNew));
}
else
{
// Last off the stack, thus cache it until the next text was
// read. (Span no attributes!)
- aAttrSetList.push_back( pOld );
- aAttrSetList.push_back( pNew );
+ m_AttrSetList.push_back(std::unique_ptr<SvxRTFItemStackType>(pOld));
+ m_AttrSetList.push_back(std::move(pNew));
}
pOld = 0; // Do not delete pOld
break;
@@ -998,10 +1000,10 @@ void SvxRTFParser::AttrGroupEnd() // process the current, delete from Stack
if( pAkt )
{
- pAkt->Add( pOld );
+ pAkt->Add(std::unique_ptr<SvxRTFItemStackType>(pOld));
// split up and create new entry, because it make no sense
// to create a "so long" depend list. Bug 95010
- if( bCrsrBack && 50 < pAkt->pChildList->size() )
+ if (bCrsrBack && 50 < pAkt->m_pChildList->size())
{
// at the beginning of a paragraph? Move back one position
MovePos(true);
@@ -1023,7 +1025,7 @@ void SvxRTFParser::AttrGroupEnd() // process the current, delete from Stack
else
// Last off the stack, thus cache it until the next text was
// read. (Span no attributes!)
- aAttrSetList.push_back( pOld );
+ m_AttrSetList.push_back(std::unique_ptr<SvxRTFItemStackType>(pOld));
pOld = 0;
}
@@ -1046,11 +1048,11 @@ void SvxRTFParser::SetAllAttrOfStk() // end all Attr. and set it into doc
while( !aAttrStack.empty() )
AttrGroupEnd();
- for( sal_uInt16 n = aAttrSetList.size(); n; )
+ for (size_t n = m_AttrSetList.size(); n; )
{
- SvxRTFItemStackType* pStkSet = &aAttrSetList[--n];
+ auto const& pStkSet = m_AttrSetList[--n];
SetAttrSet( *pStkSet );
- aAttrSetList.pop_back();
+ m_AttrSetList.pop_back();
}
}
@@ -1061,15 +1063,15 @@ void SvxRTFParser::SetAttrSet( SvxRTFItemStackType &rSet )
if( !bIsSetDfltTab )
SetDefault( RTF_DEFTAB, 720 );
- if( rSet.pChildList )
+ if (rSet.m_pChildList)
rSet.Compress( *this );
if( rSet.aAttrSet.Count() || rSet.nStyleNo )
SetAttrInDoc( rSet );
// then process all the children
- if( rSet.pChildList )
- for( size_t n = 0; n < rSet.pChildList->size(); ++n )
- SetAttrSet( (*rSet.pChildList)[ n ] );
+ if (rSet.m_pChildList)
+ for (size_t n = 0; n < rSet.m_pChildList->size(); ++n)
+ SetAttrSet( *(*rSet.m_pChildList)[ n ] );
}
// Has no text been inserted yet? (SttPos from the top Stack entry!)
@@ -1130,9 +1132,9 @@ SvxRTFStyleType::SvxRTFStyleType( SfxItemPool& rPool, const sal_uInt16* pWhichRa
SvxRTFItemStackType::SvxRTFItemStackType(
SfxItemPool& rPool, const sal_uInt16* pWhichRange,
const SvxPosition& rPos )
- : aAttrSet( rPool, pWhichRange ),
- pChildList( 0 ),
- nStyleNo( 0 )
+ : aAttrSet( rPool, pWhichRange )
+ , m_pChildList( nullptr )
+ , nStyleNo( 0 )
{
pSttNd = rPos.MakeNodeIdx();
nSttCnt = rPos.GetCntIdx();
@@ -1144,9 +1146,9 @@ SvxRTFItemStackType::SvxRTFItemStackType(
const SvxRTFItemStackType& rCpy,
const SvxPosition& rPos,
bool const bCopyAttr )
- : aAttrSet( *rCpy.aAttrSet.GetPool(), rCpy.aAttrSet.GetRanges() ),
- pChildList( 0 ),
- nStyleNo( rCpy.nStyleNo )
+ : aAttrSet( *rCpy.aAttrSet.GetPool(), rCpy.aAttrSet.GetRanges() )
+ , m_pChildList( nullptr )
+ , nStyleNo( rCpy.nStyleNo )
{
pSttNd = rPos.MakeNodeIdx();
nSttCnt = rPos.GetCntIdx();
@@ -1160,18 +1162,18 @@ SvxRTFItemStackType::SvxRTFItemStackType(
SvxRTFItemStackType::~SvxRTFItemStackType()
{
- if( pChildList )
- delete pChildList;
+ if (m_pChildList)
+ delete m_pChildList;
if( pSttNd != pEndNd )
delete pEndNd;
delete pSttNd;
}
-void SvxRTFItemStackType::Add( SvxRTFItemStackType* pIns )
+void SvxRTFItemStackType::Add(std::unique_ptr<SvxRTFItemStackType> pIns)
{
- if( !pChildList )
- pChildList = new SvxRTFItemStackList();
- pChildList->push_back( pIns );
+ if (!m_pChildList)
+ m_pChildList = new SvxRTFItemStackList();
+ m_pChildList->push_back(std::move(pIns));
}
void SvxRTFItemStackType::SetStartPos( const SvxPosition& rPos )
@@ -1204,21 +1206,20 @@ void SvxRTFItemStackType::MoveFullNode(const SvxNodeIdx &rOldNode,
}
//And the same for all the children
- sal_Int32 nCount = pChildList ? pChildList->size() : 0;
+ sal_Int32 nCount = m_pChildList ? m_pChildList->size() : 0;
for (sal_Int32 i = 0; i < nCount; ++i)
{
- SvxRTFItemStackType* pStk = &(*pChildList)[i];
+ auto const& pStk = (*m_pChildList)[i];
pStk->MoveFullNode(rOldNode, rNewNode);
}
}
void SvxRTFItemStackType::Compress( const SvxRTFParser& rParser )
{
- ENSURE_OR_RETURN_VOID(pChildList, "Compress: no ChildList" );
- ENSURE_OR_RETURN_VOID(!pChildList->empty(), "Compress: ChildList empty");
+ ENSURE_OR_RETURN_VOID(m_pChildList, "Compress: no ChildList" );
+ ENSURE_OR_RETURN_VOID(!m_pChildList->empty(), "Compress: ChildList empty");
- sal_uInt16 n;
- SvxRTFItemStackType* pTmp = &(*pChildList)[0];
+ SvxRTFItemStackType* pTmp = (*m_pChildList)[0].get();
if( !pTmp->aAttrSet.Count() ||
pSttNd->GetIdx() != pTmp->pSttNd->GetIdx() ||
@@ -1229,10 +1230,10 @@ void SvxRTFItemStackType::Compress( const SvxRTFParser& rParser )
sal_Int32 nLastCnt = pTmp->nEndCnt;
SfxItemSet aMrgSet( pTmp->aAttrSet );
- for( n = 1; n < pChildList->size(); ++n )
+ for (size_t n = 1; n < m_pChildList->size(); ++n)
{
- pTmp = &(*pChildList)[n];
- if( pTmp->pChildList )
+ pTmp = (*m_pChildList)[n].get();
+ if (pTmp->m_pChildList)
pTmp->Compress( rParser );
if( !pTmp->nSttCnt
@@ -1241,9 +1242,12 @@ void SvxRTFItemStackType::Compress( const SvxRTFParser& rParser )
: ( pTmp->nSttCnt != nLastCnt ||
pLastNd->GetIdx() != pTmp->pSttNd->GetIdx() ))
{
- while( ++n < pChildList->size() )
- if( (pTmp = &(*pChildList)[n])->pChildList )
+ while (++n < m_pChildList->size())
+ {
+ pTmp = (*m_pChildList)[n].get();
+ if (pTmp->m_pChildList)
pTmp->Compress( rParser );
+ }
return;
}
@@ -1277,21 +1281,21 @@ void SvxRTFItemStackType::Compress( const SvxRTFParser& rParser )
// It can be merged
aAttrSet.Put( aMrgSet );
- for( n = 0; n < pChildList->size(); ++n )
+ for (size_t n = 0; n < m_pChildList->size(); ++n)
{
- pTmp = &(*pChildList)[n];
+ pTmp = (*m_pChildList)[n].get();
pTmp->aAttrSet.Differentiate( aMrgSet );
- if( !pTmp->pChildList && !pTmp->aAttrSet.Count() && !pTmp->nStyleNo )
+ if (!pTmp->m_pChildList && !pTmp->aAttrSet.Count() && !pTmp->nStyleNo)
{
- pChildList->erase( pChildList->begin() + n );
+ m_pChildList->erase( m_pChildList->begin() + n );
--n;
}
}
- if( pChildList->empty() )
+ if (m_pChildList->empty())
{
- delete pChildList;
- pChildList = 0;
+ delete m_pChildList;
+ m_pChildList = nullptr;
}
}
void SvxRTFItemStackType::SetRTFDefaults( const SfxItemSet& rDefaults )
diff --git a/include/editeng/svxrtf.hxx b/include/editeng/svxrtf.hxx
index c4b1ef7..19a3f84 100644
--- a/include/editeng/svxrtf.hxx
+++ b/include/editeng/svxrtf.hxx
@@ -31,7 +31,6 @@
#include <map>
#include <utility>
#include <memory>
-#include <boost/ptr_container/ptr_vector.hpp>
namespace vcl { class Font; }
class Color;
@@ -39,7 +38,7 @@ class Graphic;
class DateTime;
struct SvxRTFStyleType;
class SvxRTFItemStackType;
-class SvxRTFItemStackList : public boost::ptr_vector<SvxRTFItemStackType> {};
+class SvxRTFItemStackList : public std::vector<std::unique_ptr<SvxRTFItemStackType>> {};
namespace com { namespace sun { namespace star {
namespace document {
@@ -176,7 +175,7 @@ class EDITENG_DLLPUBLIC SvxRTFParser : public SvRTFParser
SvxRTFFontTbl m_FontTable;
SvxRTFStyleTbl m_StyleTable;
SvxRTFItemStack aAttrStack;
- SvxRTFItemStackList aAttrSetList;
+ SvxRTFItemStackList m_AttrSetList;
RTFPlainAttrMapIds aPlainMap;
RTFPardAttrMapIds aPardMap;
@@ -326,13 +325,13 @@ class EDITENG_DLLPUBLIC SvxRTFItemStackType
SfxItemSet aAttrSet;
SvxNodeIdx *pSttNd, *pEndNd;
sal_Int32 nSttCnt, nEndCnt;
- SvxRTFItemStackList* pChildList;
+ SvxRTFItemStackList* m_pChildList;
sal_uInt16 nStyleNo;
SvxRTFItemStackType( SfxItemPool&, const sal_uInt16* pWhichRange,
const SvxPosition& );
- void Add( SvxRTFItemStackType* );
+ void Add(std::unique_ptr<SvxRTFItemStackType>);
void Compress( const SvxRTFParser& );
public:
commit d2726959ff54f1c0b19dc4e605bd3ebadbdc0283
Author: Michael Stahl <mstahl at redhat.com>
Date: Mon Jul 20 13:00:22 2015 +0200
editeng: replace boost::ptr_map with std::map<std::unique_ptr>>
Change-Id: Ia6fce8eceb364d83cbbf5abcf734be262614e792
diff --git a/editeng/source/rtf/svxrtf.cxx b/editeng/source/rtf/svxrtf.cxx
index c0f8bed..2656e44 100644
--- a/editeng/source/rtf/svxrtf.cxx
+++ b/editeng/source/rtf/svxrtf.cxx
@@ -114,7 +114,7 @@ SvParserState SvxRTFParser::CallParser()
if( !aColorTbl.empty() )
ClearColorTbl();
- if( !aFontTbl.empty() )
+ if (!m_FontTable.empty())
ClearFontTbl();
if (!m_StyleTable.empty())
ClearStyleTbl();
@@ -159,7 +159,7 @@ void SvxRTFParser::NextToken( int nToken )
case RTF_DEFF:
if( bNewDoc )
{
- if( !aFontTbl.empty() )
+ if (!m_FontTable.empty())
// Can immediately be set
SetDefault( nToken, nTokenValue );
else
@@ -442,7 +442,7 @@ void SvxRTFParser::ReadFontTable()
{
int nToken = 0;
int _nOpenBrakets = 1; // the first was already detected earlier!!
- vcl::Font* pFont = new vcl::Font();
+ std::unique_ptr<vcl::Font> pFont(new vcl::Font);
short nFontNo(0), nInsFontNo (0);
OUString sAltNm, sFntNm;
bool bIsAltFntNm = false;
@@ -558,15 +558,15 @@ void SvxRTFParser::ReadFontTable()
sFntNm = sFntNm + ";" + sAltNm;
pFont->SetName( sFntNm );
- aFontTbl.insert( nInsFontNo, pFont );
- pFont = new vcl::Font();
+ m_FontTable.insert(std::make_pair(nInsFontNo, std::move(pFont)));
+ pFont.reset(new vcl::Font);
pFont->SetCharSet( nSystemChar );
sAltNm.clear();
sFntNm.clear();
}
}
// the last one we have to delete manually
- delete pFont;
+ pFont.reset();
SkipToken( -1 ); // the closing brace is evaluated "above"
// set the default font in the Document
@@ -760,7 +760,7 @@ void SvxRTFParser::ClearColorTbl()
void SvxRTFParser::ClearFontTbl()
{
- aFontTbl.clear();
+ m_FontTable.clear();
}
void SvxRTFParser::ClearStyleTbl()
@@ -793,19 +793,16 @@ OUString& SvxRTFParser::DelCharAtEnd( OUString& rStr, const sal_Unicode cDel )
const vcl::Font& SvxRTFParser::GetFont( sal_uInt16 nId )
{
- SvxRTFFontTbl::const_iterator it = aFontTbl.find( nId );
- const vcl::Font* pFont;
- if( it == aFontTbl.end() )
+ SvxRTFFontTbl::const_iterator it = m_FontTable.find( nId );
+ if (it != m_FontTable.end())
{
- const SvxFontItem& rDfltFont = static_cast<const SvxFontItem&>(
- pAttrPool->GetDefaultItem( aPlainMap.nFont ));
- pDfltFont->SetName( rDfltFont.GetStyleName() );
- pDfltFont->SetFamily( rDfltFont.GetFamily() );
- pFont = pDfltFont;
+ return *it->second;
}
- else
- pFont = it->second;
- return *pFont;
+ const SvxFontItem& rDfltFont = static_cast<const SvxFontItem&>(
+ pAttrPool->GetDefaultItem( aPlainMap.nFont ));
+ pDfltFont->SetName( rDfltFont.GetStyleName() );
+ pDfltFont->SetFamily( rDfltFont.GetFamily() );
+ return *pDfltFont;
}
SvxRTFItemStackType* SvxRTFParser::_GetAttrSet( bool const bCopyAttr )
diff --git a/include/editeng/svxrtf.hxx b/include/editeng/svxrtf.hxx
index f96eea6..c4b1ef7 100644
--- a/include/editeng/svxrtf.hxx
+++ b/include/editeng/svxrtf.hxx
@@ -31,7 +31,6 @@
#include <map>
#include <utility>
#include <memory>
-#include <boost/ptr_container/ptr_map.hpp>
#include <boost/ptr_container/ptr_vector.hpp>
namespace vcl { class Font; }
@@ -79,7 +78,7 @@ public:
typedef std::deque< Color* > SvxRTFColorTbl;
-typedef boost::ptr_map<short, vcl::Font> SvxRTFFontTbl;
+typedef std::map<short, std::unique_ptr<vcl::Font>> SvxRTFFontTbl;
typedef std::map<sal_uInt16, std::unique_ptr<SvxRTFStyleType>> SvxRTFStyleTbl;
// SvxRTFItemStack can't be "std::stack< SvxRTFItemStackType* >" type, because
@@ -170,15 +169,11 @@ struct RTFPardAttrMapIds
};
-
-
-
-
class EDITENG_DLLPUBLIC SvxRTFParser : public SvRTFParser
{
SvStream &rStrm;
SvxRTFColorTbl aColorTbl;
- SvxRTFFontTbl aFontTbl;
+ SvxRTFFontTbl m_FontTable;
SvxRTFStyleTbl m_StyleTable;
SvxRTFItemStack aAttrStack;
SvxRTFItemStackList aAttrSetList;
@@ -389,7 +384,6 @@ inline SfxItemSet& SvxRTFParser::GetAttrSet()
}
-#endif
- // INCLUDED_EDITENG_SVXRTF_HXX
+#endif // INCLUDED_EDITENG_SVXRTF_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 144d82434ddbb77bb3cd722bc7b636a612bb9db7
Author: Michael Stahl <mstahl at redhat.com>
Date: Mon Jul 20 12:54:57 2015 +0200
editeng: replace boost::ptr_map with std::map<std::unique_ptr>>
Change-Id: Id59fb4ee59872e60094bde85746416c83f058b00
diff --git a/editeng/source/editeng/eertfpar.cxx b/editeng/source/editeng/eertfpar.cxx
index 2c7e970..ebda620 100644
--- a/editeng/source/editeng/eertfpar.cxx
+++ b/editeng/source/editeng/eertfpar.cxx
@@ -368,7 +368,7 @@ void EditRTFParser::SetAttrInDoc( SvxRTFItemStackType &rSet )
DBG_ASSERT( it != GetStyleTbl().end(), "Template not defined in RTF!" );
if ( it != GetStyleTbl().end() )
{
- SvxRTFStyleType* pS = it->second;
+ auto const& pS = it->second;
mpEditEngine->SetStyleSheet(
EditSelection(aStartPaM, aEndPaM),
static_cast<SfxStyleSheet*>(mpEditEngine->GetStyleSheetPool()->Find(pS->sName, SFX_STYLE_FAMILY_ALL)));
@@ -433,11 +433,10 @@ void EditRTFParser::SetAttrInDoc( SvxRTFItemStackType &rSet )
SvxRTFStyleType* EditRTFParser::FindStyleSheet( const OUString& rName )
{
SvxRTFStyleTbl& rTable = GetStyleTbl();
- for ( SvxRTFStyleTbl::iterator it = rTable.begin(); it != rTable.end(); ++it )
+ for (auto const& iter : rTable)
{
- SvxRTFStyleType* pS = it->second;
- if ( pS->sName == rName )
- return pS;
+ if (iter.second->sName == rName)
+ return iter.second.get();
}
return NULL;
}
@@ -456,7 +455,7 @@ SfxStyleSheet* EditRTFParser::CreateStyleSheet( SvxRTFStyleType* pRTFStyle )
SvxRTFStyleTbl::iterator it = GetStyleTbl().find( pRTFStyle->nBasedOn );
if ( it != GetStyleTbl().end())
{
- SvxRTFStyleType* pS = it->second;
+ SvxRTFStyleType *const pS = it->second.get();
if ( pS && ( pS !=pRTFStyle ) )
aParent = pS->sName;
}
@@ -492,7 +491,7 @@ void EditRTFParser::CreateStyleSheets()
{
for (SvxRTFStyleTbl::iterator it = GetStyleTbl().begin(); it != GetStyleTbl().end(); ++it)
{
- SvxRTFStyleType* pRTFStyle = it->second;
+ SvxRTFStyleType* pRTFStyle = it->second.get();
CreateStyleSheet( pRTFStyle );
}
}
diff --git a/editeng/source/rtf/svxrtf.cxx b/editeng/source/rtf/svxrtf.cxx
index c4a8221..c0f8bed 100644
--- a/editeng/source/rtf/svxrtf.cxx
+++ b/editeng/source/rtf/svxrtf.cxx
@@ -116,7 +116,7 @@ SvParserState SvxRTFParser::CallParser()
ClearColorTbl();
if( !aFontTbl.empty() )
ClearFontTbl();
- if( !aStyleTbl.empty() )
+ if (!m_StyleTable.empty())
ClearStyleTbl();
if( !aAttrStack.empty() )
ClearAttrStack();
@@ -300,7 +300,8 @@ void SvxRTFParser::ReadStyleTable()
int nToken, bSaveChkStyleAttr = bChkStyleAttr ? 1 : 0;
sal_uInt16 nStyleNo = 0;
int _nOpenBrakets = 1; // the first was already detected earlier!!
- SvxRTFStyleType* pStyle = new SvxRTFStyleType( *pAttrPool, &aWhichMap[0] );
+ ::std::unique_ptr<SvxRTFStyleType> pStyle(
+ new SvxRTFStyleType( *pAttrPool, &aWhichMap[0] ));
pStyle->aAttrSet.Put( GetRTFDefaults() );
bIsInReadStyleTab = true;
@@ -348,13 +349,13 @@ void SvxRTFParser::ReadStyleTable()
{
pStyle->sName = DelCharAtEnd( aToken, ';' );
- if( !aStyleTbl.empty() )
+ if (!m_StyleTable.empty())
{
- aStyleTbl.erase(nStyleNo);
+ m_StyleTable.erase(nStyleNo);
}
// All data from the font is available, so off to the table
- aStyleTbl.insert( nStyleNo , pStyle);
- pStyle = new SvxRTFStyleType( *pAttrPool, &aWhichMap[0] );
+ m_StyleTable.insert(std::make_pair(nStyleNo, std::move(pStyle)));
+ pStyle.reset(new SvxRTFStyleType( *pAttrPool, &aWhichMap[0] ));
pStyle->aAttrSet.Put( GetRTFDefaults() );
nStyleNo = 0;
}
@@ -386,7 +387,7 @@ void SvxRTFParser::ReadStyleTable()
break;
}
}
- delete pStyle; // Delete the Last Style
+ pStyle.reset(); // Delete the Last Style
SkipToken( -1 ); // the closing brace is evaluated "above"
// Flag back to old state
@@ -764,7 +765,7 @@ void SvxRTFParser::ClearFontTbl()
void SvxRTFParser::ClearStyleTbl()
{
- aStyleTbl.clear();
+ m_StyleTable.clear();
}
void SvxRTFParser::ClearAttrStack()
@@ -835,7 +836,7 @@ void SvxRTFParser::_ClearStyleAttr( SvxRTFItemStackType& rStkType )
if( !IsChkStyleAttr() ||
!rStkType.GetAttrSet().Count() ||
- aStyleTbl.count( rStkType.nStyleNo ) == 0 )
+ m_StyleTable.count( rStkType.nStyleNo ) == 0 )
{
for( sal_uInt16 nWhich = aIter.GetCurWhich(); nWhich; nWhich = aIter.NextWhich() )
{
@@ -849,7 +850,7 @@ void SvxRTFParser::_ClearStyleAttr( SvxRTFItemStackType& rStkType )
{
// Delete all Attributes, which are already defined in the Style,
// from the current AttrSet.
- SvxRTFStyleType* pStyle = aStyleTbl.find( rStkType.nStyleNo )->second;
+ auto const& pStyle = m_StyleTable.find(rStkType.nStyleNo)->second;
SfxItemSet &rStyleSet = pStyle->aAttrSet;
const SfxPoolItem* pSItem;
for( sal_uInt16 nWhich = aIter.GetCurWhich(); nWhich; nWhich = aIter.NextWhich() )
diff --git a/include/editeng/svxrtf.hxx b/include/editeng/svxrtf.hxx
index fe93c33..f96eea6 100644
--- a/include/editeng/svxrtf.hxx
+++ b/include/editeng/svxrtf.hxx
@@ -27,8 +27,10 @@
#include <editeng/editengdllapi.h>
#include <deque>
-#include <utility>
#include <vector>
+#include <map>
+#include <utility>
+#include <memory>
#include <boost/ptr_container/ptr_map.hpp>
#include <boost/ptr_container/ptr_vector.hpp>
@@ -78,7 +80,7 @@ public:
typedef std::deque< Color* > SvxRTFColorTbl;
typedef boost::ptr_map<short, vcl::Font> SvxRTFFontTbl;
-typedef boost::ptr_map<sal_uInt16, SvxRTFStyleType> SvxRTFStyleTbl;
+typedef std::map<sal_uInt16, std::unique_ptr<SvxRTFStyleType>> SvxRTFStyleTbl;
// SvxRTFItemStack can't be "std::stack< SvxRTFItemStackType* >" type, because
// the methods are using operator[] in sw/source/filter/rtf/rtftbl.cxx file
@@ -177,7 +179,7 @@ class EDITENG_DLLPUBLIC SvxRTFParser : public SvRTFParser
SvStream &rStrm;
SvxRTFColorTbl aColorTbl;
SvxRTFFontTbl aFontTbl;
- SvxRTFStyleTbl aStyleTbl;
+ SvxRTFStyleTbl m_StyleTable;
SvxRTFItemStack aAttrStack;
SvxRTFItemStackList aAttrSetList;
@@ -292,7 +294,7 @@ protected:
// Query/Set the current insert position
void SetInsPos( const SvxPosition& rNew );
- SvxRTFStyleTbl& GetStyleTbl() { return aStyleTbl; }
+ SvxRTFStyleTbl& GetStyleTbl() { return m_StyleTable; }
public:
More information about the Libreoffice-commits
mailing list