Kaydet (Commit) 144d8243 authored tarafından Michael Stahl's avatar Michael Stahl

editeng: replace boost::ptr_map with std::map<std::unique_ptr>>

Change-Id: Id59fb4ee59872e60094bde85746416c83f058b00
üst 97a0e755
...@@ -368,7 +368,7 @@ void EditRTFParser::SetAttrInDoc( SvxRTFItemStackType &rSet ) ...@@ -368,7 +368,7 @@ void EditRTFParser::SetAttrInDoc( SvxRTFItemStackType &rSet )
DBG_ASSERT( it != GetStyleTbl().end(), "Template not defined in RTF!" ); DBG_ASSERT( it != GetStyleTbl().end(), "Template not defined in RTF!" );
if ( it != GetStyleTbl().end() ) if ( it != GetStyleTbl().end() )
{ {
SvxRTFStyleType* pS = it->second; auto const& pS = it->second;
mpEditEngine->SetStyleSheet( mpEditEngine->SetStyleSheet(
EditSelection(aStartPaM, aEndPaM), EditSelection(aStartPaM, aEndPaM),
static_cast<SfxStyleSheet*>(mpEditEngine->GetStyleSheetPool()->Find(pS->sName, SFX_STYLE_FAMILY_ALL))); static_cast<SfxStyleSheet*>(mpEditEngine->GetStyleSheetPool()->Find(pS->sName, SFX_STYLE_FAMILY_ALL)));
...@@ -433,11 +433,10 @@ void EditRTFParser::SetAttrInDoc( SvxRTFItemStackType &rSet ) ...@@ -433,11 +433,10 @@ void EditRTFParser::SetAttrInDoc( SvxRTFItemStackType &rSet )
SvxRTFStyleType* EditRTFParser::FindStyleSheet( const OUString& rName ) SvxRTFStyleType* EditRTFParser::FindStyleSheet( const OUString& rName )
{ {
SvxRTFStyleTbl& rTable = GetStyleTbl(); SvxRTFStyleTbl& rTable = GetStyleTbl();
for ( SvxRTFStyleTbl::iterator it = rTable.begin(); it != rTable.end(); ++it ) for (auto const& iter : rTable)
{ {
SvxRTFStyleType* pS = it->second; if (iter.second->sName == rName)
if ( pS->sName == rName ) return iter.second.get();
return pS;
} }
return NULL; return NULL;
} }
...@@ -456,7 +455,7 @@ SfxStyleSheet* EditRTFParser::CreateStyleSheet( SvxRTFStyleType* pRTFStyle ) ...@@ -456,7 +455,7 @@ SfxStyleSheet* EditRTFParser::CreateStyleSheet( SvxRTFStyleType* pRTFStyle )
SvxRTFStyleTbl::iterator it = GetStyleTbl().find( pRTFStyle->nBasedOn ); SvxRTFStyleTbl::iterator it = GetStyleTbl().find( pRTFStyle->nBasedOn );
if ( it != GetStyleTbl().end()) if ( it != GetStyleTbl().end())
{ {
SvxRTFStyleType* pS = it->second; SvxRTFStyleType *const pS = it->second.get();
if ( pS && ( pS !=pRTFStyle ) ) if ( pS && ( pS !=pRTFStyle ) )
aParent = pS->sName; aParent = pS->sName;
} }
...@@ -492,7 +491,7 @@ void EditRTFParser::CreateStyleSheets() ...@@ -492,7 +491,7 @@ void EditRTFParser::CreateStyleSheets()
{ {
for (SvxRTFStyleTbl::iterator it = GetStyleTbl().begin(); it != GetStyleTbl().end(); ++it) for (SvxRTFStyleTbl::iterator it = GetStyleTbl().begin(); it != GetStyleTbl().end(); ++it)
{ {
SvxRTFStyleType* pRTFStyle = it->second; SvxRTFStyleType* pRTFStyle = it->second.get();
CreateStyleSheet( pRTFStyle ); CreateStyleSheet( pRTFStyle );
} }
} }
......
...@@ -116,7 +116,7 @@ SvParserState SvxRTFParser::CallParser() ...@@ -116,7 +116,7 @@ SvParserState SvxRTFParser::CallParser()
ClearColorTbl(); ClearColorTbl();
if( !aFontTbl.empty() ) if( !aFontTbl.empty() )
ClearFontTbl(); ClearFontTbl();
if( !aStyleTbl.empty() ) if (!m_StyleTable.empty())
ClearStyleTbl(); ClearStyleTbl();
if( !aAttrStack.empty() ) if( !aAttrStack.empty() )
ClearAttrStack(); ClearAttrStack();
...@@ -300,7 +300,8 @@ void SvxRTFParser::ReadStyleTable() ...@@ -300,7 +300,8 @@ void SvxRTFParser::ReadStyleTable()
int nToken, bSaveChkStyleAttr = bChkStyleAttr ? 1 : 0; int nToken, bSaveChkStyleAttr = bChkStyleAttr ? 1 : 0;
sal_uInt16 nStyleNo = 0; sal_uInt16 nStyleNo = 0;
int _nOpenBrakets = 1; // the first was already detected earlier!! 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() ); pStyle->aAttrSet.Put( GetRTFDefaults() );
bIsInReadStyleTab = true; bIsInReadStyleTab = true;
...@@ -348,13 +349,13 @@ void SvxRTFParser::ReadStyleTable() ...@@ -348,13 +349,13 @@ void SvxRTFParser::ReadStyleTable()
{ {
pStyle->sName = DelCharAtEnd( aToken, ';' ); 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 // All data from the font is available, so off to the table
aStyleTbl.insert( nStyleNo , pStyle); m_StyleTable.insert(std::make_pair(nStyleNo, std::move(pStyle)));
pStyle = new SvxRTFStyleType( *pAttrPool, &aWhichMap[0] ); pStyle.reset(new SvxRTFStyleType( *pAttrPool, &aWhichMap[0] ));
pStyle->aAttrSet.Put( GetRTFDefaults() ); pStyle->aAttrSet.Put( GetRTFDefaults() );
nStyleNo = 0; nStyleNo = 0;
} }
...@@ -386,7 +387,7 @@ void SvxRTFParser::ReadStyleTable() ...@@ -386,7 +387,7 @@ void SvxRTFParser::ReadStyleTable()
break; break;
} }
} }
delete pStyle; // Delete the Last Style pStyle.reset(); // Delete the Last Style
SkipToken( -1 ); // the closing brace is evaluated "above" SkipToken( -1 ); // the closing brace is evaluated "above"
// Flag back to old state // Flag back to old state
...@@ -764,7 +765,7 @@ void SvxRTFParser::ClearFontTbl() ...@@ -764,7 +765,7 @@ void SvxRTFParser::ClearFontTbl()
void SvxRTFParser::ClearStyleTbl() void SvxRTFParser::ClearStyleTbl()
{ {
aStyleTbl.clear(); m_StyleTable.clear();
} }
void SvxRTFParser::ClearAttrStack() void SvxRTFParser::ClearAttrStack()
...@@ -835,7 +836,7 @@ void SvxRTFParser::_ClearStyleAttr( SvxRTFItemStackType& rStkType ) ...@@ -835,7 +836,7 @@ void SvxRTFParser::_ClearStyleAttr( SvxRTFItemStackType& rStkType )
if( !IsChkStyleAttr() || if( !IsChkStyleAttr() ||
!rStkType.GetAttrSet().Count() || !rStkType.GetAttrSet().Count() ||
aStyleTbl.count( rStkType.nStyleNo ) == 0 ) m_StyleTable.count( rStkType.nStyleNo ) == 0 )
{ {
for( sal_uInt16 nWhich = aIter.GetCurWhich(); nWhich; nWhich = aIter.NextWhich() ) for( sal_uInt16 nWhich = aIter.GetCurWhich(); nWhich; nWhich = aIter.NextWhich() )
{ {
...@@ -849,7 +850,7 @@ void SvxRTFParser::_ClearStyleAttr( SvxRTFItemStackType& rStkType ) ...@@ -849,7 +850,7 @@ void SvxRTFParser::_ClearStyleAttr( SvxRTFItemStackType& rStkType )
{ {
// Delete all Attributes, which are already defined in the Style, // Delete all Attributes, which are already defined in the Style,
// from the current AttrSet. // from the current AttrSet.
SvxRTFStyleType* pStyle = aStyleTbl.find( rStkType.nStyleNo )->second; auto const& pStyle = m_StyleTable.find(rStkType.nStyleNo)->second;
SfxItemSet &rStyleSet = pStyle->aAttrSet; SfxItemSet &rStyleSet = pStyle->aAttrSet;
const SfxPoolItem* pSItem; const SfxPoolItem* pSItem;
for( sal_uInt16 nWhich = aIter.GetCurWhich(); nWhich; nWhich = aIter.NextWhich() ) for( sal_uInt16 nWhich = aIter.GetCurWhich(); nWhich; nWhich = aIter.NextWhich() )
......
...@@ -27,8 +27,10 @@ ...@@ -27,8 +27,10 @@
#include <editeng/editengdllapi.h> #include <editeng/editengdllapi.h>
#include <deque> #include <deque>
#include <utility>
#include <vector> #include <vector>
#include <map>
#include <utility>
#include <memory>
#include <boost/ptr_container/ptr_map.hpp> #include <boost/ptr_container/ptr_map.hpp>
#include <boost/ptr_container/ptr_vector.hpp> #include <boost/ptr_container/ptr_vector.hpp>
...@@ -78,7 +80,7 @@ public: ...@@ -78,7 +80,7 @@ public:
typedef std::deque< Color* > SvxRTFColorTbl; typedef std::deque< Color* > SvxRTFColorTbl;
typedef boost::ptr_map<short, vcl::Font> SvxRTFFontTbl; 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 // SvxRTFItemStack can't be "std::stack< SvxRTFItemStackType* >" type, because
// the methods are using operator[] in sw/source/filter/rtf/rtftbl.cxx file // the methods are using operator[] in sw/source/filter/rtf/rtftbl.cxx file
...@@ -177,7 +179,7 @@ class EDITENG_DLLPUBLIC SvxRTFParser : public SvRTFParser ...@@ -177,7 +179,7 @@ class EDITENG_DLLPUBLIC SvxRTFParser : public SvRTFParser
SvStream &rStrm; SvStream &rStrm;
SvxRTFColorTbl aColorTbl; SvxRTFColorTbl aColorTbl;
SvxRTFFontTbl aFontTbl; SvxRTFFontTbl aFontTbl;
SvxRTFStyleTbl aStyleTbl; SvxRTFStyleTbl m_StyleTable;
SvxRTFItemStack aAttrStack; SvxRTFItemStack aAttrStack;
SvxRTFItemStackList aAttrSetList; SvxRTFItemStackList aAttrSetList;
...@@ -292,7 +294,7 @@ protected: ...@@ -292,7 +294,7 @@ protected:
// Query/Set the current insert position // Query/Set the current insert position
void SetInsPos( const SvxPosition& rNew ); void SetInsPos( const SvxPosition& rNew );
SvxRTFStyleTbl& GetStyleTbl() { return aStyleTbl; } SvxRTFStyleTbl& GetStyleTbl() { return m_StyleTable; }
public: public:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment