diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-07-17 13:36:41 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-07-17 14:29:55 -0400 |
commit | 1409c9b703530beaa2bf4118f1501d675f8a535e (patch) | |
tree | c5b4616d53d9d46e102564dc040ef390919fb343 /sc | |
parent | 226fcd045455d49fa88f19117b83a9953274ff04 (diff) |
We can use ptr_vector for this.
Change-Id: I3972fb23557f61ce3dbe0e671ed4c3f434a98f8b
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/filter/inc/XclExpChangeTrack.hxx | 6 | ||||
-rw-r--r-- | sc/source/filter/xcl97/XclExpChangeTrack.cxx | 50 |
2 files changed, 27 insertions, 29 deletions
diff --git a/sc/source/filter/inc/XclExpChangeTrack.hxx b/sc/source/filter/inc/XclExpChangeTrack.hxx index 2bfa1bb7eded..c650d3642adb 100644 --- a/sc/source/filter/inc/XclExpChangeTrack.hxx +++ b/sc/source/filter/inc/XclExpChangeTrack.hxx @@ -29,6 +29,8 @@ #include "ftools.hxx" #include "excrecds.hxx" +#include <boost/ptr_container/ptr_vector.hpp> + // XclExpUserBView - one UserBView record for each user class XclExpUserBView : public ExcRecord @@ -567,8 +569,8 @@ public: class XclExpChangeTrack : protected XclExpRoot { -private: - std::vector<ExcRecord*> aRecList; // list of "Revision Log" stream records + typedef boost::ptr_vector<ExcRecord> RecListType; + RecListType maRecList; // list of "Revision Log" stream records std::stack<XclExpChTrAction*> aActionStack; XclExpChTrTabIdBuffer* pTabIdBuffer; std::vector<XclExpChTrTabIdBuffer*> maBuffers; diff --git a/sc/source/filter/xcl97/XclExpChangeTrack.cxx b/sc/source/filter/xcl97/XclExpChangeTrack.cxx index 8cc504fd97bd..c96169afdeb7 100644 --- a/sc/source/filter/xcl97/XclExpChangeTrack.cxx +++ b/sc/source/filter/xcl97/XclExpChangeTrack.cxx @@ -1408,10 +1408,10 @@ XclExpChangeTrack::XclExpChangeTrack( const XclExpRoot& rRoot ) : // build record list pHeader = new XclExpChTrHeader; - aRecList.push_back( new StartXmlElement( XML_headers, StartXmlElement::WRITE_NAMESPACES ) ); - aRecList.push_back( pHeader ); - aRecList.push_back( new XclExpChTr0x0195 ); - aRecList.push_back( new XclExpChTr0x0194( *pTempChangeTrack ) ); + maRecList.push_back( new StartXmlElement( XML_headers, StartXmlElement::WRITE_NAMESPACES ) ); + maRecList.push_back( pHeader ); + maRecList.push_back( new XclExpChTr0x0195 ); + maRecList.push_back( new XclExpChTr0x0194( *pTempChangeTrack ) ); OUString sLastUsername; DateTime aLastDateTime( DateTime::EMPTY ); @@ -1428,41 +1428,37 @@ XclExpChangeTrack::XclExpChangeTrack( const XclExpRoot& rRoot ) : { if( nIndex != 1 ) { - aRecList.push_back( new EndXmlElement( XML_revisions ) ); - aRecList.push_back( new EndHeaderElement() ); + maRecList.push_back( new EndXmlElement( XML_revisions ) ); + maRecList.push_back( new EndHeaderElement() ); } lcl_GenerateGUID( aGUID, bValidGUID ); sLastUsername = pAction->GetUsername(); aLastDateTime = pAction->GetDateTime(); - aRecList.push_back( new StartXmlElement( XML_header, 0 ) ); - aRecList.push_back( new XclExpChTrInfo( sLastUsername, aLastDateTime, aGUID, nLogNumber++ ) ); - aRecList.push_back( new XclExpChTrTabId( pAction->GetTabIdBuffer(), true ) ); - aRecList.push_back( new StartXmlElement( XML_revisions, StartXmlElement::WRITE_NAMESPACES | StartXmlElement::CLOSE_ELEMENT ) ); + maRecList.push_back( new StartXmlElement( XML_header, 0 ) ); + maRecList.push_back( new XclExpChTrInfo( sLastUsername, aLastDateTime, aGUID, nLogNumber++ ) ); + maRecList.push_back( new XclExpChTrTabId( pAction->GetTabIdBuffer(), true ) ); + maRecList.push_back( new StartXmlElement( XML_revisions, StartXmlElement::WRITE_NAMESPACES | StartXmlElement::CLOSE_ELEMENT ) ); pHeader->SetGUID( aGUID ); } pAction->SetIndex( nIndex ); - aRecList.push_back( pAction ); + maRecList.push_back( pAction ); } pHeader->SetGUID( aGUID ); pHeader->SetCount( nIndex - 1 ); if( nLogNumber > 1 ) { - aRecList.push_back( new EndXmlElement( XML_revisions ) ); - aRecList.push_back( new EndHeaderElement() ); + maRecList.push_back( new EndXmlElement( XML_revisions ) ); + maRecList.push_back( new EndHeaderElement() ); } - aRecList.push_back( new EndXmlElement( XML_headers ) ); - aRecList.push_back( new ExcEof ); + maRecList.push_back( new EndXmlElement( XML_headers ) ); + maRecList.push_back( new ExcEof ); } XclExpChangeTrack::~XclExpChangeTrack() { - std::vector<ExcRecord*>::iterator prIter; - for ( prIter = aRecList.begin(); prIter != aRecList.end(); ++prIter ) - delete *prIter; - std::vector<XclExpChTrTabIdBuffer*>::iterator pIter; for ( pIter = maBuffers.begin(); pIter != maBuffers.end(); ++pIter ) delete *pIter; @@ -1561,7 +1557,7 @@ bool XclExpChangeTrack::WriteUserNamesStream() void XclExpChangeTrack::Write() { - if( aRecList.empty() ) + if (maRecList.empty()) return; if( WriteUserNamesStream() ) @@ -1572,9 +1568,9 @@ void XclExpChangeTrack::Write() { XclExpStream aXclStrm( *xSvStrm, GetRoot(), EXC_MAXRECSIZE_BIFF8 + 8 ); - std::vector<ExcRecord*>::iterator pIter; - for ( pIter = aRecList.begin(); pIter != aRecList.end(); ++pIter ) - (*pIter)->Save(aXclStrm); + RecListType::iterator pIter; + for (pIter = maRecList.begin(); pIter != maRecList.end(); ++pIter) + pIter->Save(aXclStrm); xSvStrm->Commit(); } @@ -1602,7 +1598,7 @@ static void lcl_WriteUserNamesXml( XclExpXmlStream& rWorkbookStrm ) void XclExpChangeTrack::WriteXml( XclExpXmlStream& rWorkbookStrm ) { - if( aRecList.empty() ) + if (maRecList.empty()) return; lcl_WriteUserNamesXml( rWorkbookStrm ); @@ -1618,9 +1614,9 @@ void XclExpChangeTrack::WriteXml( XclExpXmlStream& rWorkbookStrm ) // contents of XclExpChangeTrack::WriteUserNamesStream()). rWorkbookStrm.PushStream( pRevisionHeaders ); - std::vector<ExcRecord*>::iterator pIter; - for ( pIter = aRecList.begin(); pIter != aRecList.end(); ++pIter ) - (*pIter)->SaveXml(rWorkbookStrm); + RecListType::iterator pIter; + for (pIter = maRecList.begin(); pIter != maRecList.end(); ++pIter) + pIter->SaveXml(rWorkbookStrm); rWorkbookStrm.PopStream(); } |