diff options
author | Michael Stahl <mstahl@redhat.com> | 2015-10-30 22:23:48 +0100 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2015-11-02 11:43:11 +0100 |
commit | 02b7f3d1a21d68611f2cd8405103c8546542960b (patch) | |
tree | 376c622c1449120b1368164e9ebf250a5fba9f20 /xmloff | |
parent | 253081247628923d53eccc2d027594add4e40b1f (diff) |
xmloff: replace boost::ptr_vector with std::vector<std::unique_ptr>
Change-Id: I3270237a8691a5f5f4495be8cf2e290cac0b2fcd
Diffstat (limited to 'xmloff')
-rw-r--r-- | xmloff/source/text/txtparai.cxx | 139 |
1 files changed, 72 insertions, 67 deletions
diff --git a/xmloff/source/text/txtparai.cxx b/xmloff/source/text/txtparai.cxx index 888b3ca04510..ca8f2461851b 100644 --- a/xmloff/source/text/txtparai.cxx +++ b/xmloff/source/text/txtparai.cxx @@ -18,9 +18,14 @@ */ #include <xmloff/unointerfacetouniqueidentifiermapper.hxx> + +#include <memory> +#include <vector> + #include <rtl/ustring.hxx> #include <rtl/ustrbuf.hxx> -#include <boost/ptr_container/ptr_vector.hpp> + +#include <o3tl/make_unique.hxx> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/text/XTextFrame.hpp> @@ -53,7 +58,6 @@ #include "txtlists.hxx" #include <txtparaimphint.hxx> -class XMLHints_Impl : public boost::ptr_vector<XMLHint_Impl> {}; using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -64,6 +68,8 @@ using namespace ::xmloff::token; using ::com::sun::star::container::XEnumerationAccess; using ::com::sun::star::container::XEnumeration; +class XMLHints_Impl : public std::vector<std::unique_ptr<XMLHint_Impl>> {}; + TYPEINIT1( XMLCharContext, SvXMLImportContext ); XMLCharContext::XMLCharContext( @@ -161,7 +167,7 @@ public: SvXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLocalName, - XMLHints_Impl& rHnts, + XMLHints_Impl& rHints, const Reference<xml::sax::XAttributeList> & xAttrList); static bool FindName( @@ -184,13 +190,13 @@ XMLStartReferenceContext_Impl::XMLStartReferenceContext_Impl( if (FindName(GetImport(), xAttrList, sName)) { - XMLHint_Impl* pHint = new XMLReferenceHint_Impl( - sName, rImport.GetTextImport()->GetCursor()->getStart() ); + std::unique_ptr<XMLHint_Impl> pHint(new XMLReferenceHint_Impl( + sName, rImport.GetTextImport()->GetCursor()->getStart())); // degenerates to point reference, if no end is found! pHint->SetEnd(rImport.GetTextImport()->GetCursor()->getStart() ); - rHints.push_back(pHint); + rHints.push_back(std::move(pHint)); } } @@ -232,7 +238,7 @@ public: SvXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLocalName, - XMLHints_Impl& rHnts, + XMLHints_Impl& rHints, const Reference<xml::sax::XAttributeList> & xAttrList); }; @@ -255,7 +261,7 @@ XMLEndReferenceContext_Impl::XMLEndReferenceContext_Impl( sal_uInt16 nCount = rHints.size(); for(sal_uInt16 nPos = 0; nPos < nCount; nPos++) { - XMLHint_Impl *pHint = &rHints[nPos]; + XMLHint_Impl *const pHint = rHints[nPos].get(); if ( pHint->IsReference() && sName.equals( static_cast<XMLReferenceHint_Impl *>(pHint)->GetRefName()) ) { @@ -271,7 +277,7 @@ XMLEndReferenceContext_Impl::XMLEndReferenceContext_Impl( class XMLImpSpanContext_Impl : public SvXMLImportContext { - XMLHints_Impl& rHints; + XMLHints_Impl& m_rHints; XMLStyleHint_Impl *pHint; bool& rIgnoreLeadingSpace; @@ -287,7 +293,7 @@ public: sal_uInt16 nPrfx, const OUString& rLName, const Reference< xml::sax::XAttributeList > & xAttrList, - XMLHints_Impl& rHnts, + XMLHints_Impl& rHints, bool& rIgnLeadSpace, sal_uInt8 nSFConvFlags ); @@ -298,7 +304,7 @@ public: SvXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLocalName, const Reference< xml::sax::XAttributeList > & xAttrList, - sal_uInt16 nToken, XMLHints_Impl& rHnts, + sal_uInt16 nToken, XMLHints_Impl& rHints, bool& rIgnLeadSpace, sal_uInt8 nStarFontsConvFlags = 0 ); @@ -311,7 +317,7 @@ public: class XMLImpHyperlinkContext_Impl : public SvXMLImportContext { - XMLHints_Impl& mrHints; + XMLHints_Impl& m_rHints; XMLHyperlinkHint_Impl *mpHint; bool& mrbIgnoreLeadingSpace; @@ -325,7 +331,7 @@ public: sal_uInt16 nPrfx, const OUString& rLName, const Reference< xml::sax::XAttributeList > & xAttrList, - XMLHints_Impl& rHnts, + XMLHints_Impl& rHints, bool& rIgnLeadSpace ); virtual ~XMLImpHyperlinkContext_Impl(); @@ -344,10 +350,10 @@ XMLImpHyperlinkContext_Impl::XMLImpHyperlinkContext_Impl( sal_uInt16 nPrfx, const OUString& rLName, const Reference< xml::sax::XAttributeList > & xAttrList, - XMLHints_Impl& rHnts, + XMLHints_Impl& rHints, bool& rIgnLeadSpace ) : SvXMLImportContext( rImport, nPrfx, rLName ) - , mrHints( rHnts ) + , m_rHints( rHints ) , mpHint( new XMLHyperlinkHint_Impl( GetImport().GetTextImport()->GetCursorAsRange()->getStart() ) ) , mrbIgnoreLeadingSpace( rIgnLeadSpace ) { @@ -403,7 +409,7 @@ XMLImpHyperlinkContext_Impl::XMLImpHyperlinkContext_Impl( } else { - mrHints.push_back( mpHint ); + m_rHints.push_back(std::unique_ptr<XMLHyperlinkHint_Impl>(mpHint)); } } @@ -434,7 +440,7 @@ SvXMLImportContext *XMLImpHyperlinkContext_Impl::CreateChildContext( return XMLImpSpanContext_Impl::CreateChildContext( GetImport(), nPrefix, rLocalName, xAttrList, - nToken, mrHints, mrbIgnoreLeadingSpace ); + nToken, m_rHints, mrbIgnoreLeadingSpace ); } } @@ -445,7 +451,7 @@ void XMLImpHyperlinkContext_Impl::Characters( const OUString& rChars ) class XMLImpRubyBaseContext_Impl : public SvXMLImportContext { - XMLHints_Impl& rHints; + XMLHints_Impl& m_rHints; bool& rIgnoreLeadingSpace; @@ -458,7 +464,7 @@ public: sal_uInt16 nPrfx, const OUString& rLName, const Reference< xml::sax::XAttributeList > & xAttrList, - XMLHints_Impl& rHnts, + XMLHints_Impl& rHints, bool& rIgnLeadSpace ); virtual ~XMLImpRubyBaseContext_Impl(); @@ -477,11 +483,11 @@ XMLImpRubyBaseContext_Impl::XMLImpRubyBaseContext_Impl( sal_uInt16 nPrfx, const OUString& rLName, const Reference< xml::sax::XAttributeList > &, - XMLHints_Impl& rHnts, - bool& rIgnLeadSpace ) : - SvXMLImportContext( rImport, nPrfx, rLName ), - rHints( rHnts ), - rIgnoreLeadingSpace( rIgnLeadSpace ) + XMLHints_Impl& rHints, + bool& rIgnLeadSpace ) + : SvXMLImportContext( rImport, nPrfx, rLName ) + , m_rHints( rHints ) + , rIgnoreLeadingSpace( rIgnLeadSpace ) { } @@ -499,7 +505,7 @@ SvXMLImportContext *XMLImpRubyBaseContext_Impl::CreateChildContext( return XMLImpSpanContext_Impl::CreateChildContext( GetImport(), nPrefix, rLocalName, xAttrList, - nToken, rHints, rIgnoreLeadingSpace ); + nToken, m_rHints, rIgnoreLeadingSpace ); } void XMLImpRubyBaseContext_Impl::Characters( const OUString& rChars ) @@ -509,7 +515,7 @@ void XMLImpRubyBaseContext_Impl::Characters( const OUString& rChars ) class XMLImpRubyContext_Impl : public SvXMLImportContext { - XMLHints_Impl& rHints; + XMLHints_Impl& m_rHints; bool& rIgnoreLeadingSpace; @@ -527,7 +533,7 @@ public: sal_uInt16 nPrfx, const OUString& rLName, const Reference< xml::sax::XAttributeList > & xAttrList, - XMLHints_Impl& rHnts, + XMLHints_Impl& rHints, bool& rIgnLeadSpace ); virtual ~XMLImpRubyContext_Impl(); @@ -606,11 +612,11 @@ XMLImpRubyContext_Impl::XMLImpRubyContext_Impl( sal_uInt16 nPrfx, const OUString& rLName, const Reference< xml::sax::XAttributeList > & xAttrList, - XMLHints_Impl& rHnts, - bool& rIgnLeadSpace ) : - SvXMLImportContext( rImport, nPrfx, rLName ), - rHints( rHnts ), - rIgnoreLeadingSpace( rIgnLeadSpace ) + XMLHints_Impl& rHints, + bool& rIgnLeadSpace ) + : SvXMLImportContext( rImport, nPrfx, rLName ) + , m_rHints( rHints ) + , rIgnoreLeadingSpace( rIgnLeadSpace ) , m_xStart( GetImport().GetTextImport()->GetCursorAsRange()->getStart() ) { sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; @@ -655,7 +661,7 @@ SvXMLImportContext *XMLImpRubyContext_Impl::CreateChildContext( pContext = new XMLImpRubyBaseContext_Impl( GetImport(), nPrefix, rLocalName, xAttrList, - rHints, + m_rHints, rIgnoreLeadingSpace ); else if( IsXMLToken( rLocalName, XML_RUBY_TEXT ) ) pContext = new XMLImpRubyTextContext_Impl( GetImport(), nPrefix, @@ -1002,7 +1008,7 @@ class XMLIndexMarkImportContext_Impl : public SvXMLImportContext { const OUString sAlternativeText; - XMLHints_Impl& rHints; + XMLHints_Impl& m_rHints; const enum XMLTextPElemTokens eToken; OUString sID; @@ -1014,7 +1020,7 @@ public: sal_uInt16 nPrefix, const OUString& rLocalName, enum XMLTextPElemTokens nTok, - XMLHints_Impl& rHnts); + XMLHints_Impl& rHints); void StartElement(const Reference<xml::sax::XAttributeList> & xAttrList) override; @@ -1051,11 +1057,11 @@ XMLIndexMarkImportContext_Impl::XMLIndexMarkImportContext_Impl( sal_uInt16 nPrefix, const OUString& rLocalName, enum XMLTextPElemTokens eTok, - XMLHints_Impl& rHnts) : - SvXMLImportContext(rImport, nPrefix, rLocalName), - sAlternativeText("AlternativeText"), - rHints(rHnts), - eToken(eTok) + XMLHints_Impl& rHints) + : SvXMLImportContext(rImport, nPrefix, rLocalName) + , sAlternativeText("AlternativeText") + , m_rHints(rHints) + , eToken(eTok) { } @@ -1079,8 +1085,8 @@ void XMLIndexMarkImportContext_Impl::StartElement( if (CreateMark(xMark, sService)) { ProcessAttributes(xAttrList, xMark); - XMLHint_Impl* pHint = new XMLIndexMarkHint_Impl(xMark, xPos); - rHints.push_back(pHint); + m_rHints.push_back( + o3tl::make_unique<XMLIndexMarkHint_Impl>(xMark, xPos)); } // else: can't create mark -> ignore break; @@ -1099,9 +1105,8 @@ void XMLIndexMarkImportContext_Impl::StartElement( if (!sID.isEmpty()) { // process only if we find an ID - XMLHint_Impl* pHint = - new XMLIndexMarkHint_Impl(xMark, xPos, sID); - rHints.push_back(pHint); + m_rHints.push_back( + o3tl::make_unique<XMLIndexMarkHint_Impl>(xMark, xPos, sID)); } // else: no ID -> we'll never find the end -> ignore } @@ -1120,10 +1125,10 @@ void XMLIndexMarkImportContext_Impl::StartElement( if (!sID.isEmpty()) { // if we have an ID, find the hint and set the end position - sal_uInt16 nCount = rHints.size(); + sal_uInt16 nCount = m_rHints.size(); for(sal_uInt16 nPos = 0; nPos < nCount; nPos++) { - XMLHint_Impl *pHint = &rHints[nPos]; + XMLHint_Impl *const pHint = m_rHints[nPos].get(); if ( pHint->IsIndexMark() && sID.equals( static_cast<XMLIndexMarkHint_Impl *>(pHint)->GetID()) ) @@ -1287,7 +1292,7 @@ public: sal_uInt16 nPrefix, const OUString& rLocalName, enum XMLTextPElemTokens nTok, - XMLHints_Impl& rHnts); + XMLHints_Impl& rHints); protected: @@ -1302,9 +1307,9 @@ TYPEINIT1( XMLTOCMarkImportContext_Impl, XMLIndexMarkImportContext_Impl ); XMLTOCMarkImportContext_Impl::XMLTOCMarkImportContext_Impl( SvXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLocalName, - enum XMLTextPElemTokens nTok, XMLHints_Impl& rHnts) : + enum XMLTextPElemTokens nTok, XMLHints_Impl& rHints) : XMLIndexMarkImportContext_Impl(rImport, nPrefix, rLocalName, - nTok, rHnts), + nTok, rHints), sLevel("Level") { } @@ -1352,7 +1357,7 @@ public: sal_uInt16 nPrefix, const OUString& rLocalName, enum XMLTextPElemTokens nTok, - XMLHints_Impl& rHnts); + XMLHints_Impl& rHints); protected: @@ -1367,9 +1372,9 @@ TYPEINIT1( XMLUserIndexMarkImportContext_Impl, XMLIndexMarkImportContext_Impl); XMLUserIndexMarkImportContext_Impl::XMLUserIndexMarkImportContext_Impl( SvXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLocalName, - enum XMLTextPElemTokens nTok, XMLHints_Impl& rHnts) : + enum XMLTextPElemTokens nTok, XMLHints_Impl& rHints) : XMLIndexMarkImportContext_Impl(rImport, nPrefix, rLocalName, - nTok, rHnts), + nTok, rHints), sUserIndexName("UserIndexName"), sLevel("Level") { @@ -1429,7 +1434,7 @@ public: sal_uInt16 nPrefix, const OUString& rLocalName, enum XMLTextPElemTokens nTok, - XMLHints_Impl& rHnts); + XMLHints_Impl& rHints); protected: @@ -1445,9 +1450,9 @@ TYPEINIT1( XMLAlphaIndexMarkImportContext_Impl, XMLAlphaIndexMarkImportContext_Impl::XMLAlphaIndexMarkImportContext_Impl( SvXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLocalName, - enum XMLTextPElemTokens nTok, XMLHints_Impl& rHnts) : + enum XMLTextPElemTokens nTok, XMLHints_Impl& rHints) : XMLIndexMarkImportContext_Impl(rImport, nPrefix, rLocalName, - nTok, rHnts), + nTok, rHints), sPrimaryKey("PrimaryKey"), sSecondaryKey("SecondaryKey"), sTextReading("TextReading"), @@ -1513,12 +1518,12 @@ XMLImpSpanContext_Impl::XMLImpSpanContext_Impl( sal_uInt16 nPrfx, const OUString& rLName, const Reference< xml::sax::XAttributeList > & xAttrList, - XMLHints_Impl& rHnts, + XMLHints_Impl& rHints, bool& rIgnLeadSpace, sal_uInt8 nSFConvFlags ) : SvXMLImportContext( rImport, nPrfx, rLName ) -, rHints( rHnts ) +, m_rHints( rHints ) , pHint( 0 ) , rIgnoreLeadingSpace( rIgnLeadSpace ) , nStarFontsConvFlags( nSFConvFlags & (CONV_FROM_STAR_BATS|CONV_FROM_STAR_MATH) ) @@ -1543,7 +1548,7 @@ XMLImpSpanContext_Impl::XMLImpSpanContext_Impl( { pHint = new XMLStyleHint_Impl( aStyleName, GetImport().GetTextImport()->GetCursorAsRange()->getStart() ); - rHints.push_back( pHint ); + m_rHints.push_back(std::unique_ptr<XMLStyleHint_Impl>(pHint)); } } @@ -1691,8 +1696,8 @@ SvXMLImportContext *XMLImpSpanContext_Impl::CreateChildContext( if( TextContentAnchorType_AT_CHARACTER == pTextFrameContext->GetAnchorType() ) { - rHints.push_back( new XMLTextFrameHint_Impl( - pTextFrameContext, xAnchorPos ) ); + rHints.push_back(o3tl::make_unique<XMLTextFrameHint_Impl>( + pTextFrameContext, xAnchorPos)); } pContext = pTextFrameContext; rIgnoreLeadingSpace = false; @@ -1705,9 +1710,8 @@ SvXMLImportContext *XMLImpSpanContext_Impl::CreateChildContext( new XMLTextFrameHyperlinkContext( rImport, nPrefix, rLocalName, xAttrList, TextContentAnchorType_AS_CHARACTER ); - XMLTextFrameHint_Impl *pHint = - new XMLTextFrameHint_Impl( pContext, xAnchorPos); - rHints.push_back( pHint ); + rHints.push_back( + o3tl::make_unique<XMLTextFrameHint_Impl>(pContext, xAnchorPos)); } break; @@ -1780,7 +1784,8 @@ SvXMLImportContext *XMLImpSpanContext_Impl::CreateChildContext( // adjust its anchor position, if its at-character anchored Reference < XTextRange > xAnchorPos = rImport.GetTextImport()->GetCursor()->getStart(); - rHints.push_back( new XMLDrawHint_Impl( pShapeContext, xAnchorPos ) ); + rHints.push_back( + o3tl::make_unique<XMLDrawHint_Impl>(pShapeContext, xAnchorPos)); } if( !pContext ) { @@ -1804,7 +1809,7 @@ SvXMLImportContext *XMLImpSpanContext_Impl::CreateChildContext( sal_uInt16 nToken = rTokenMap.Get( nPrefix, rLocalName ); return CreateChildContext( GetImport(), nPrefix, rLocalName, xAttrList, - nToken, rHints, rIgnoreLeadingSpace + nToken, m_rHints, rIgnoreLeadingSpace ,nStarFontsConvFlags ); } @@ -2076,7 +2081,7 @@ XMLParaContext::~XMLParaContext() { for( size_t i=0; i<pHints->size(); i++ ) { - XMLHint_Impl *pHint = &(*pHints)[i]; + XMLHint_Impl *const pHint = (*pHints)[i].get(); xAttrCursor->gotoRange( pHint->GetStart(), sal_False ); xAttrCursor->gotoRange( pHint->GetEnd(), sal_True ); switch( pHint->GetType() ) |