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

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

Change-Id: Ia6fce8eceb364d83cbbf5abcf734be262614e792
üst 144d8243
...@@ -114,7 +114,7 @@ SvParserState SvxRTFParser::CallParser() ...@@ -114,7 +114,7 @@ SvParserState SvxRTFParser::CallParser()
if( !aColorTbl.empty() ) if( !aColorTbl.empty() )
ClearColorTbl(); ClearColorTbl();
if( !aFontTbl.empty() ) if (!m_FontTable.empty())
ClearFontTbl(); ClearFontTbl();
if (!m_StyleTable.empty()) if (!m_StyleTable.empty())
ClearStyleTbl(); ClearStyleTbl();
...@@ -159,7 +159,7 @@ void SvxRTFParser::NextToken( int nToken ) ...@@ -159,7 +159,7 @@ void SvxRTFParser::NextToken( int nToken )
case RTF_DEFF: case RTF_DEFF:
if( bNewDoc ) if( bNewDoc )
{ {
if( !aFontTbl.empty() ) if (!m_FontTable.empty())
// Can immediately be set // Can immediately be set
SetDefault( nToken, nTokenValue ); SetDefault( nToken, nTokenValue );
else else
...@@ -442,7 +442,7 @@ void SvxRTFParser::ReadFontTable() ...@@ -442,7 +442,7 @@ void SvxRTFParser::ReadFontTable()
{ {
int nToken = 0; int nToken = 0;
int _nOpenBrakets = 1; // the first was already detected earlier!! 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); short nFontNo(0), nInsFontNo (0);
OUString sAltNm, sFntNm; OUString sAltNm, sFntNm;
bool bIsAltFntNm = false; bool bIsAltFntNm = false;
...@@ -558,15 +558,15 @@ void SvxRTFParser::ReadFontTable() ...@@ -558,15 +558,15 @@ void SvxRTFParser::ReadFontTable()
sFntNm = sFntNm + ";" + sAltNm; sFntNm = sFntNm + ";" + sAltNm;
pFont->SetName( sFntNm ); pFont->SetName( sFntNm );
aFontTbl.insert( nInsFontNo, pFont ); m_FontTable.insert(std::make_pair(nInsFontNo, std::move(pFont)));
pFont = new vcl::Font(); pFont.reset(new vcl::Font);
pFont->SetCharSet( nSystemChar ); pFont->SetCharSet( nSystemChar );
sAltNm.clear(); sAltNm.clear();
sFntNm.clear(); sFntNm.clear();
} }
} }
// the last one we have to delete manually // the last one we have to delete manually
delete pFont; pFont.reset();
SkipToken( -1 ); // the closing brace is evaluated "above" SkipToken( -1 ); // the closing brace is evaluated "above"
// set the default font in the Document // set the default font in the Document
...@@ -760,7 +760,7 @@ void SvxRTFParser::ClearColorTbl() ...@@ -760,7 +760,7 @@ void SvxRTFParser::ClearColorTbl()
void SvxRTFParser::ClearFontTbl() void SvxRTFParser::ClearFontTbl()
{ {
aFontTbl.clear(); m_FontTable.clear();
} }
void SvxRTFParser::ClearStyleTbl() void SvxRTFParser::ClearStyleTbl()
...@@ -793,19 +793,16 @@ OUString& SvxRTFParser::DelCharAtEnd( OUString& rStr, const sal_Unicode cDel ) ...@@ -793,19 +793,16 @@ OUString& SvxRTFParser::DelCharAtEnd( OUString& rStr, const sal_Unicode cDel )
const vcl::Font& SvxRTFParser::GetFont( sal_uInt16 nId ) const vcl::Font& SvxRTFParser::GetFont( sal_uInt16 nId )
{ {
SvxRTFFontTbl::const_iterator it = aFontTbl.find( nId ); SvxRTFFontTbl::const_iterator it = m_FontTable.find( nId );
const vcl::Font* pFont; if (it != m_FontTable.end())
if( it == aFontTbl.end() )
{ {
const SvxFontItem& rDfltFont = static_cast<const SvxFontItem&>( return *it->second;
pAttrPool->GetDefaultItem( aPlainMap.nFont ));
pDfltFont->SetName( rDfltFont.GetStyleName() );
pDfltFont->SetFamily( rDfltFont.GetFamily() );
pFont = pDfltFont;
} }
else const SvxFontItem& rDfltFont = static_cast<const SvxFontItem&>(
pFont = it->second; pAttrPool->GetDefaultItem( aPlainMap.nFont ));
return *pFont; pDfltFont->SetName( rDfltFont.GetStyleName() );
pDfltFont->SetFamily( rDfltFont.GetFamily() );
return *pDfltFont;
} }
SvxRTFItemStackType* SvxRTFParser::_GetAttrSet( bool const bCopyAttr ) SvxRTFItemStackType* SvxRTFParser::_GetAttrSet( bool const bCopyAttr )
......
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
#include <map> #include <map>
#include <utility> #include <utility>
#include <memory> #include <memory>
#include <boost/ptr_container/ptr_map.hpp>
#include <boost/ptr_container/ptr_vector.hpp> #include <boost/ptr_container/ptr_vector.hpp>
namespace vcl { class Font; } namespace vcl { class Font; }
...@@ -79,7 +78,7 @@ public: ...@@ -79,7 +78,7 @@ public:
typedef std::deque< Color* > SvxRTFColorTbl; 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; 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
...@@ -170,15 +169,11 @@ struct RTFPardAttrMapIds ...@@ -170,15 +169,11 @@ struct RTFPardAttrMapIds
}; };
class EDITENG_DLLPUBLIC SvxRTFParser : public SvRTFParser class EDITENG_DLLPUBLIC SvxRTFParser : public SvRTFParser
{ {
SvStream &rStrm; SvStream &rStrm;
SvxRTFColorTbl aColorTbl; SvxRTFColorTbl aColorTbl;
SvxRTFFontTbl aFontTbl; SvxRTFFontTbl m_FontTable;
SvxRTFStyleTbl m_StyleTable; SvxRTFStyleTbl m_StyleTable;
SvxRTFItemStack aAttrStack; SvxRTFItemStack aAttrStack;
SvxRTFItemStackList aAttrSetList; SvxRTFItemStackList aAttrSetList;
...@@ -389,7 +384,6 @@ inline SfxItemSet& SvxRTFParser::GetAttrSet() ...@@ -389,7 +384,6 @@ inline SfxItemSet& SvxRTFParser::GetAttrSet()
} }
#endif #endif // INCLUDED_EDITENG_SVXRTF_HXX
// INCLUDED_EDITENG_SVXRTF_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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