diff options
-rw-r--r-- | editeng/source/editeng/eertfpar.cxx | 13 | ||||
-rw-r--r-- | editeng/source/rtf/svxrtf.cxx | 21 | ||||
-rw-r--r-- | include/editeng/svxrtf.hxx | 10 |
3 files changed, 23 insertions, 21 deletions
diff --git a/editeng/source/editeng/eertfpar.cxx b/editeng/source/editeng/eertfpar.cxx index 2c7e970480dd..ebda6204709b 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 c4a82217735f..c0f8bedce89f 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 fe93c33ae15a..f96eea6e8d16 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: |