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

sw: replace boost::ptr_vector with std::vector<std::unique_ptr>

Change-Id: I9adb9a445844ead91eefec8c57b879b0cc11c686
üst 384d9e41
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <hintids.hxx> #include <hintids.hxx>
#include <string.h> #include <string.h>
#include <osl/endian.h> #include <osl/endian.h>
#include <o3tl/make_unique.hxx>
#include <docsh.hxx> #include <docsh.hxx>
#include <drawdoc.hxx> #include <drawdoc.hxx>
...@@ -1235,10 +1236,10 @@ void WW8_WrPct::AppendPc(WW8_FC nStartFc) ...@@ -1235,10 +1236,10 @@ void WW8_WrPct::AppendPc(WW8_FC nStartFc)
WW8_CP nStartCp = nStartFc - nOldFc; // subtract the beginning of the text WW8_CP nStartCp = nStartFc - nOldFc; // subtract the beginning of the text
if ( !nStartCp ) if ( !nStartCp )
{ {
if ( !aPcts.empty() ) if (!m_Pcts.empty())
{ {
OSL_ENSURE( 1 == aPcts.size(), "Leeres Piece !!"); OSL_ENSURE(1 == m_Pcts.size(), "empty Piece!");
aPcts.pop_back( ); m_Pcts.pop_back();
} }
} }
...@@ -1246,39 +1247,40 @@ void WW8_WrPct::AppendPc(WW8_FC nStartFc) ...@@ -1246,39 +1247,40 @@ void WW8_WrPct::AppendPc(WW8_FC nStartFc)
nStartCp >>= 1; // for Unicode: number of characters / 2 nStartCp >>= 1; // for Unicode: number of characters / 2
if( !aPcts.empty() ) if (!m_Pcts.empty())
nStartCp += aPcts.back().GetStartCp(); {
nStartCp += m_Pcts.back()->GetStartCp();
}
WW8_WrPc* pPc = new WW8_WrPc( nStartFc, nStartCp ); m_Pcts.push_back(o3tl::make_unique<WW8_WrPc>(nStartFc, nStartCp));
aPcts.push_back( pPc );
} }
void WW8_WrPct::WritePc( WW8Export& rWrt ) void WW8_WrPct::WritePc( WW8Export& rWrt )
{ {
sal_uLong nPctStart; sal_uLong nPctStart;
sal_uLong nOldPos, nEndPos; sal_uLong nOldPos, nEndPos;
boost::ptr_vector<WW8_WrPc>::iterator aIter;
nPctStart = rWrt.pTableStrm->Tell(); // Start piece table nPctStart = rWrt.pTableStrm->Tell(); // Start piece table
rWrt.pTableStrm->WriteChar( ( char )0x02 ); // Status byte PCT rWrt.pTableStrm->WriteChar( ( char )0x02 ); // Status byte PCT
nOldPos = nPctStart + 1; // remember Position nOldPos = nPctStart + 1; // remember Position
SwWW8Writer::WriteLong( *rWrt.pTableStrm, 0 ); // then the length SwWW8Writer::WriteLong( *rWrt.pTableStrm, 0 ); // then the length
for( aIter = aPcts.begin(); aIter != aPcts.end(); ++aIter ) // ranges for (auto const& it : m_Pcts) // ranges
SwWW8Writer::WriteLong( *rWrt.pTableStrm, {
aIter->GetStartCp() ); SwWW8Writer::WriteLong( *rWrt.pTableStrm, it->GetStartCp() );
}
// calculate the last Pos // calculate the last Pos
sal_uLong nStartCp = rWrt.pFib->fcMac - nOldFc; sal_uLong nStartCp = rWrt.pFib->fcMac - nOldFc;
nStartCp >>= 1; // For Unicode: number of characters / 2 nStartCp >>= 1; // For Unicode: number of characters / 2
nStartCp += aPcts.back().GetStartCp(); nStartCp += m_Pcts.back()->GetStartCp();
SwWW8Writer::WriteLong( *rWrt.pTableStrm, nStartCp ); SwWW8Writer::WriteLong( *rWrt.pTableStrm, nStartCp );
// piece references // piece references
for ( aIter = aPcts.begin(); aIter != aPcts.end(); ++aIter ) for (auto const& it : m_Pcts)
{ {
SwWW8Writer::WriteShort( *rWrt.pTableStrm, aIter->GetStatus()); SwWW8Writer::WriteShort(*rWrt.pTableStrm, it->GetStatus());
SwWW8Writer::WriteLong( *rWrt.pTableStrm, aIter->GetStartFc()); SwWW8Writer::WriteLong(*rWrt.pTableStrm, it->GetStartFc());
SwWW8Writer::WriteShort( *rWrt.pTableStrm, 0); // PRM=0 SwWW8Writer::WriteShort( *rWrt.pTableStrm, 0); // PRM=0
} }
...@@ -1295,18 +1297,18 @@ void WW8_WrPct::WritePc( WW8Export& rWrt ) ...@@ -1295,18 +1297,18 @@ void WW8_WrPct::WritePc( WW8Export& rWrt )
void WW8_WrPct::SetParaBreak() void WW8_WrPct::SetParaBreak()
{ {
OSL_ENSURE( !aPcts.empty(),"SetParaBreak : aPcts.empty()" ); OSL_ENSURE( !m_Pcts.empty(), "SetParaBreak : m_Pcts.empty()" );
aPcts.back().SetStatus(); m_Pcts.back()->SetStatus();
} }
WW8_CP WW8_WrPct::Fc2Cp( sal_uLong nFc ) const WW8_CP WW8_WrPct::Fc2Cp( sal_uLong nFc ) const
{ {
OSL_ENSURE( nFc >= (sal_uLong)nOldFc, "FilePos lies in front of last piece" ); OSL_ENSURE( nFc >= (sal_uLong)nOldFc, "FilePos lies in front of last piece" );
OSL_ENSURE( ! aPcts.empty(), "Fc2Cp no piece available" ); OSL_ENSURE( ! m_Pcts.empty(), "Fc2Cp no piece available" );
nFc -= nOldFc; nFc -= nOldFc;
nFc /= 2; // Unicode nFc /= 2; // Unicode
return nFc + aPcts.back().GetStartCp(); return nFc + m_Pcts.back()->GetStartCp();
} }
void WW8Export::AppendBookmarks( const SwTextNode& rNd, sal_Int32 nAktPos, sal_Int32 nLen ) void WW8Export::AppendBookmarks( const SwTextNode& rNd, sal_Int32 nAktPos, sal_Int32 nLen )
......
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include <boost/optional.hpp> #include <boost/optional.hpp>
#include <boost/ptr_container/ptr_vector.hpp> #include <boost/ptr_container/ptr_vector.hpp>
#include <memory>
#include <map> #include <map>
#include <vector> #include <vector>
...@@ -276,7 +277,7 @@ public: ...@@ -276,7 +277,7 @@ public:
// class WW8_WrPct to construct the piece table // class WW8_WrPct to construct the piece table
class WW8_WrPct class WW8_WrPct
{ {
boost::ptr_vector<WW8_WrPc > aPcts; std::vector<std::unique_ptr<WW8_WrPc>> m_Pcts;
WW8_FC nOldFc; WW8_FC nOldFc;
public: public:
explicit WW8_WrPct(WW8_FC nStartFc); explicit WW8_WrPct(WW8_FC nStartFc);
......
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