[Libreoffice-commits] core.git: sw/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Sun Feb 3 13:46:54 UTC 2019
sw/source/filter/ww8/wrtw8num.cxx | 15 ++++++++-------
sw/source/filter/ww8/wrtw8sty.cxx | 2 +-
sw/source/filter/ww8/wrtww8.cxx | 14 ++++++--------
sw/source/filter/ww8/wrtww8.hxx | 4 ++--
sw/source/filter/ww8/ww8atr.cxx | 21 +++++++++++----------
5 files changed, 28 insertions(+), 28 deletions(-)
New commits:
commit 3a5e05ebdd2da36c6a3d28d486bd114e491a951b
Author: Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Fri Feb 1 17:17:38 2019 +0100
Commit: Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Sun Feb 3 14:46:31 2019 +0100
sw: convert WW8Export::pO to unique_ptr
Change-Id: I2cb029574a3f44105a847debaef2caea16e5b66d
Reviewed-on: https://gerrit.libreoffice.org/67288
Tested-by: Jenkins
Reviewed-by: Michael Stahl <Michael.Stahl at cib.de>
diff --git a/sw/source/filter/ww8/wrtw8num.cxx b/sw/source/filter/ww8/wrtw8num.cxx
index 3fdd90134014..508ea7d0aad6 100644
--- a/sw/source/filter/ww8/wrtw8num.cxx
+++ b/sw/source/filter/ww8/wrtw8num.cxx
@@ -281,11 +281,11 @@ void WW8AttributeOutput::NumberingLevel( sal_uInt8 /*nLevel*/,
SwWW8Writer::WriteLong( *m_rWW8Export.pTableStrm, 0 );
// cbGrpprlChpx
- ww::bytes aCharAtrs;
+ std::unique_ptr<ww::bytes> pCharAtrs;
if ( pOutSet )
{
- ww::bytes* pOldpO = m_rWW8Export.pO;
- m_rWW8Export.pO = &aCharAtrs;
+ std::unique_ptr<ww::bytes> pOldpO = std::move(m_rWW8Export.pO);
+ m_rWW8Export.pO.reset(new ww::bytes);
if ( pFont )
{
sal_uInt16 nFontID = m_rWW8Export.m_aFontHelper.GetId( *pFont );
@@ -310,9 +310,10 @@ void WW8AttributeOutput::NumberingLevel( sal_uInt8 /*nLevel*/,
}
}
- m_rWW8Export.pO = pOldpO;
+ pCharAtrs = std::move(m_rWW8Export.pO);
+ m_rWW8Export.pO = std::move(pOldpO);
}
- m_rWW8Export.pTableStrm->WriteUChar( sal_uInt8( aCharAtrs.size() ) );
+ m_rWW8Export.pTableStrm->WriteUChar(sal_uInt8(pCharAtrs ? pCharAtrs->size() : 0));
// cbGrpprlPapx
sal_uInt8 aPapSprms [] = {
@@ -336,8 +337,8 @@ void WW8AttributeOutput::NumberingLevel( sal_uInt8 /*nLevel*/,
m_rWW8Export.pTableStrm->WriteBytes(aPapSprms, sizeof(aPapSprms));
// write Chpx
- if( !aCharAtrs.empty() )
- m_rWW8Export.pTableStrm->WriteBytes(aCharAtrs.data(), aCharAtrs.size());
+ if (pCharAtrs && !pCharAtrs->empty())
+ m_rWW8Export.pTableStrm->WriteBytes(pCharAtrs->data(), pCharAtrs->size());
// write the num string
SwWW8Writer::WriteShort( *m_rWW8Export.pTableStrm, rNumberingString.getLength() );
diff --git a/sw/source/filter/ww8/wrtw8sty.cxx b/sw/source/filter/ww8/wrtw8sty.cxx
index b3b2edb700fa..e41b5fa51ed9 100644
--- a/sw/source/filter/ww8/wrtw8sty.cxx
+++ b/sw/source/filter/ww8/wrtw8sty.cxx
@@ -376,7 +376,7 @@ OString const & MSWordStyles::GetStyleId(sal_uInt16 nId) const
}
/// For WW8 only - extend pO so that the size of pTableStrm is even.
-static void impl_SkipOdd( ww::bytes* pO, std::size_t nTableStrmTell )
+static void impl_SkipOdd(std::unique_ptr<ww::bytes> const& pO, std::size_t nTableStrmTell)
{
if ( ( nTableStrmTell + pO->size() ) & 1 ) // start on even
pO->push_back( sal_uInt8(0) ); // Address
diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx
index 6cfc0f019e54..00ef5bc377c4 100644
--- a/sw/source/filter/ww8/wrtww8.cxx
+++ b/sw/source/filter/ww8/wrtww8.cxx
@@ -1946,7 +1946,7 @@ void MSWordExportBase::SaveData( sal_uLong nStt, sal_uLong nEnd )
m_bStartTOX = false;
m_bInWriteTOX = false;
- m_aSaveData.push( aData );
+ m_aSaveData.push( std::move(aData) );
}
void MSWordExportBase::RestoreData()
@@ -1981,8 +1981,8 @@ void WW8Export::SaveData( sal_uLong nStt, sal_uLong nEnd )
if ( !pO->empty() )
{
- rData.pOOld = pO;
- pO = new ww::bytes;
+ rData.pOOld = std::move(pO);
+ pO.reset(new ww::bytes);
}
else
rData.pOOld = nullptr; // reuse pO
@@ -2000,8 +2000,7 @@ void WW8Export::RestoreData()
OSL_ENSURE( pO->empty(), "pO is not empty in WW8Export::RestoreData()" );
if ( rData.pOOld )
{
- delete pO;
- pO = rData.pOOld;
+ pO = std::move(rData.pOOld);
}
MSWordExportBase::RestoreData();
@@ -3340,7 +3339,7 @@ ErrCode WW8Export::ExportDocument_Impl()
m_pPapPlc.reset(new WW8_WrPlcPn( *this, PAP, pFib->m_fcMin ));
m_pChpPlc.reset(new WW8_WrPlcPn( *this, CHP, pFib->m_fcMin ));
- pO = new ww::bytes;
+ pO.reset(new ww::bytes);
m_pStyles.reset(new MSWordStyles( *this ));
m_pFieldMain.reset(new WW8_WrPlcField( 2, TXT_MAINTEXT ));
m_pFieldHdFt.reset(new WW8_WrPlcField( 2, TXT_HDFT ));
@@ -3435,7 +3434,7 @@ ErrCode WW8Export::ExportDocument_Impl()
m_pFieldHdFt.reset();;
m_pFieldMain.reset();;
m_pStyles.reset();;
- DELETEZ( pO );
+ pO.reset();
m_pChpPlc.reset();;
m_pPapPlc.reset();;
pSepx.reset();
@@ -3650,7 +3649,6 @@ WW8Export::WW8Export( SwWW8Writer *pWriter,
SwDoc *pDocument, SwPaM *pCurrentPam, SwPaM *pOriginalPam,
bool bDot )
: MSWordExportBase( pDocument, pCurrentPam, pOriginalPam )
- , pO(nullptr)
, pTableStrm(nullptr)
, pDataStrm(nullptr)
, m_bDot(bDot)
diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx
index 9102b6ab7627..3fdd698a51d6 100644
--- a/sw/source/filter/ww8/wrtww8.hxx
+++ b/sw/source/filter/ww8/wrtww8.hxx
@@ -432,7 +432,7 @@ struct MSWordSaveData
{
Point* pOldFlyOffset;
RndStdIds eOldAnchorType;
- ww::bytes* pOOld; ///< WW8Export only
+ std::unique_ptr<ww::bytes> pOOld; ///< WW8Export only
SwPaM* pOldPam, *pOldEnd;
sal_uLong nOldStart, nOldEnd;
const ww8::Frame* pOldFlyFormat;
@@ -961,7 +961,7 @@ private:
class WW8Export : public MSWordExportBase
{
public:
- ww::bytes *pO; ///< Buffer
+ std::unique_ptr<ww::bytes> pO; ///< Buffer
SvStream *pTableStrm, *pDataStrm; ///< Streams for WW97 Export
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index 44b3321fe3a2..26d85550a66b 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -1022,7 +1022,7 @@ void WW8AttributeOutput::StartRun( const SwRedlineData* pRedlineData, sal_Int32
if (m_rWW8Export.m_pAtn->IsNewRedlineComment(pRedlineData))
{
m_rWW8Export.m_pAtn->Append( m_rWW8Export.Fc2Cp( m_rWW8Export.Strm().Tell() ), pRedlineData );
- m_rWW8Export.WritePostItBegin( m_rWW8Export.pO );
+ m_rWW8Export.WritePostItBegin( m_rWW8Export.pO.get() );
}
}
}
@@ -2659,7 +2659,7 @@ void WW8AttributeOutput::PostitField( const SwField* pField )
{
const SwPostItField *pPField = static_cast<const SwPostItField*>(pField);
m_rWW8Export.m_pAtn->Append( m_rWW8Export.Fc2Cp( m_rWW8Export.Strm().Tell() ), pPField );
- m_rWW8Export.WritePostItBegin( m_rWW8Export.pO );
+ m_rWW8Export.WritePostItBegin( m_rWW8Export.pO.get() );
}
bool WW8AttributeOutput::DropdownField( const SwField* pField )
@@ -3396,18 +3396,18 @@ void WW8Export::WriteFootnoteBegin( const SwFormatFootnote& rFootnote, ww::bytes
}
else
{
- ww::bytes aOutArr;
+ std::unique_ptr<ww::bytes> pOwnOutArr(new ww::bytes);
// insert at start of array, so the "hard" attribute overrule the
// attributes of the character template
- aOutArr.insert( aOutArr.begin(), aAttrArr.begin(), aAttrArr.end() );
+ pOwnOutArr->insert(pOwnOutArr->begin(), aAttrArr.begin(), aAttrArr.end());
// write for the ftn number in the content, the font of the anchor
const SwTextFootnote* pTextFootnote = rFootnote.GetTextFootnote();
if( pTextFootnote )
{
- ww::bytes* pOld = pO;
- pO = &aOutArr;
+ std::unique_ptr<ww::bytes> pOld = std::move(pO);
+ pO = std::move(pOwnOutArr);
SfxItemSet aSet( m_pDoc->GetAttrPool(), svl::Items<RES_CHRATR_FONT,
RES_CHRATR_FONT>{} );
@@ -3423,10 +3423,11 @@ void WW8Export::WriteFootnoteBegin( const SwFormatFootnote& rFootnote, ww::bytes
{
m_pAttrOutput->OutputItem( pCFormat->GetAttrSet().Get(RES_CHRATR_FONT) );
}
- pO = pOld;
+ pOwnOutArr = std::move(pO);
+ pO = std::move(pOld);
}
- m_pChpPlc->AppendFkpEntry( Strm().Tell(), aOutArr.size(),
- aOutArr.data() );
+ m_pChpPlc->AppendFkpEntry( Strm().Tell(), pOwnOutArr->size(),
+ pOwnOutArr->data() );
}
}
@@ -3491,7 +3492,7 @@ void WW8AttributeOutput::TextFootnote_Impl( const SwFormatFootnote& rFootnote )
pFootnoteEnd = m_rWW8Export.pFootnote.get();
pFootnoteEnd->Append( m_rWW8Export.Fc2Cp( m_rWW8Export.Strm().Tell() ), rFootnote );
- m_rWW8Export.WriteFootnoteBegin( rFootnote, m_rWW8Export.pO );
+ m_rWW8Export.WriteFootnoteBegin( rFootnote, m_rWW8Export.pO.get() );
}
void WW8AttributeOutput::TextCharFormat( const SwFormatCharFormat& rCharFormat )
More information about the Libreoffice-commits
mailing list