summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-12-04 14:46:06 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-12-05 07:49:56 +0100
commitc77a81224da71aaee6ca4351c49274293241f88c (patch)
treebc144609cc3614e2481a9bbc2b15c70b8eed2dd3
parentc85f872b1cb8e733b556c03584080d06022f287d (diff)
use unique_ptr in ww8 export code
Change-Id: I505c8005aebec40b8e812aea10deaf79eb7223ab Reviewed-on: https://gerrit.libreoffice.org/64523 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--sw/source/filter/ww8/docxexport.cxx5
-rw-r--r--sw/source/filter/ww8/rtfexport.cxx2
-rw-r--r--sw/source/filter/ww8/wrtww8.cxx64
-rw-r--r--sw/source/filter/ww8/wrtww8.hxx26
-rw-r--r--sw/source/filter/ww8/ww8atr.cxx16
5 files changed, 50 insertions, 63 deletions
diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx
index 91e485eaa980..e311e7855ae3 100644
--- a/sw/source/filter/ww8/docxexport.cxx
+++ b/sw/source/filter/ww8/docxexport.cxx
@@ -534,8 +534,7 @@ ErrCode DocxExport::ExportDocument_Impl()
WriteVBA();
m_aLinkedTextboxesHelper.clear(); //final cleanup
- delete m_pStyles;
- m_pStyles = nullptr;
+ m_pStyles.reset();
m_pSections.reset();
return ERRCODE_NONE;
@@ -639,7 +638,7 @@ void DocxExport::PrepareNewPageDesc( const SfxItemSet* pSet,
void DocxExport::InitStyles()
{
- m_pStyles = new MSWordStyles( *this, /*bListStyles =*/ true );
+ m_pStyles.reset(new MSWordStyles( *this, /*bListStyles =*/ true ));
// setup word/styles.xml and the relations + content type
m_pFilter->addRelation( m_pDocumentFS->getOutputStream(),
diff --git a/sw/source/filter/ww8/rtfexport.cxx b/sw/source/filter/ww8/rtfexport.cxx
index 89a80960da6f..fdfd30e89de3 100644
--- a/sw/source/filter/ww8/rtfexport.cxx
+++ b/sw/source/filter/ww8/rtfexport.cxx
@@ -692,7 +692,7 @@ ErrCode RtfExport::ExportDocument_Impl()
// Font table
WriteFonts();
- m_pStyles = new MSWordStyles(*this);
+ m_pStyles.reset(new MSWordStyles(*this));
// Color and stylesheet table
WriteStyles();
diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx
index a6dcefce8a89..371912fba436 100644
--- a/sw/source/filter/ww8/wrtww8.cxx
+++ b/sw/source/filter/ww8/wrtww8.cxx
@@ -3333,21 +3333,21 @@ ErrCode WW8Export::ExportDocument_Impl()
m_pBkmks = new WW8_WrtBookmarks; // Bookmarks
GetWriter().CreateBookmarkTable();
- m_pPapPlc = new WW8_WrPlcPn( *this, PAP, pFib->m_fcMin );
- m_pChpPlc = new WW8_WrPlcPn( *this, CHP, pFib->m_fcMin );
+ 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;
- m_pStyles = new MSWordStyles( *this );
- m_pFieldMain = new WW8_WrPlcField( 2, TXT_MAINTEXT );
- m_pFieldHdFt = new WW8_WrPlcField( 2, TXT_HDFT );
- m_pFieldFootnote = new WW8_WrPlcField( 2, TXT_FTN );
- m_pFieldEdn = new WW8_WrPlcField( 2, TXT_EDN );
- m_pFieldAtn = new WW8_WrPlcField( 2, TXT_ATN );
- m_pFieldTextBxs = new WW8_WrPlcField( 2, TXT_TXTBOX );
- m_pFieldHFTextBxs = new WW8_WrPlcField( 2, TXT_HFTXTBOX );
-
- m_pMagicTable = new WW8_WrMagicTable;
-
- m_pGrf = new SwWW8WrGrf( *this );
+ m_pStyles.reset(new MSWordStyles( *this ));
+ m_pFieldMain.reset(new WW8_WrPlcField( 2, TXT_MAINTEXT ));
+ m_pFieldHdFt.reset(new WW8_WrPlcField( 2, TXT_HDFT ));
+ m_pFieldFootnote.reset(new WW8_WrPlcField( 2, TXT_FTN ));
+ m_pFieldEdn.reset(new WW8_WrPlcField( 2, TXT_EDN ));
+ m_pFieldAtn.reset(new WW8_WrPlcField( 2, TXT_ATN ));
+ m_pFieldTextBxs.reset(new WW8_WrPlcField( 2, TXT_TXTBOX ));
+ m_pFieldHFTextBxs.reset(new WW8_WrPlcField( 2, TXT_HFTXTBOX ));
+
+ m_pMagicTable.reset(new WW8_WrMagicTable);
+
+ m_pGrf.reset(new SwWW8WrGrf( *this ));
m_pPiece = new WW8_WrPct( pFib->m_fcMin );
pDop.reset(new WW8Dop);
@@ -3419,19 +3419,19 @@ ErrCode WW8Export::ExportDocument_Impl()
done:;
}
- DELETEZ( m_pGrf );
- DELETEZ( m_pMagicTable );
- DELETEZ( m_pFieldFootnote );
- DELETEZ( m_pFieldTextBxs );
- DELETEZ( m_pFieldHFTextBxs );
- DELETEZ( m_pFieldAtn );
- DELETEZ( m_pFieldEdn );
- DELETEZ( m_pFieldHdFt );
- DELETEZ( m_pFieldMain );
- DELETEZ( m_pStyles );
+ m_pGrf.reset();
+ m_pMagicTable.reset();;
+ m_pFieldFootnote.reset();;
+ m_pFieldTextBxs.reset();;
+ m_pFieldHFTextBxs.reset();;
+ m_pFieldAtn.reset();;
+ m_pFieldEdn.reset();;
+ m_pFieldHdFt.reset();;
+ m_pFieldMain.reset();;
+ m_pStyles.reset();;
DELETEZ( pO );
- DELETEZ( m_pChpPlc );
- DELETEZ( m_pPapPlc );
+ m_pChpPlc.reset();;
+ m_pPapPlc.reset();;
pSepx.reset();
delete m_pRedlAuthors;
@@ -3583,25 +3583,13 @@ MSWordExportBase::MSWordExportBase( SwDoc *pDocument, SwPaM *pCurrentPam, SwPaM
, m_pCurrentPageDesc(nullptr)
, m_bPrevTextNodeIsEmpty(false)
, m_bFirstTOCNodeWithSection(false)
- , m_pPapPlc(nullptr)
- , m_pChpPlc(nullptr)
, m_pChpIter(nullptr)
- , m_pStyles(nullptr)
, m_pAtn(nullptr)
, m_pTextBxs(nullptr)
, m_pHFTextBxs(nullptr)
, m_pParentFrame(nullptr)
, m_pFlyOffset(nullptr)
, m_eNewAnchorType(RndStdIds::FLY_AS_CHAR)
- , m_pFieldMain(nullptr)
- , m_pFieldHdFt(nullptr)
- , m_pFieldFootnote(nullptr)
- , m_pFieldEdn(nullptr)
- , m_pFieldAtn(nullptr)
- , m_pFieldTextBxs(nullptr)
- , m_pFieldHFTextBxs(nullptr)
- , m_pMagicTable(nullptr)
- , m_pGrf(nullptr)
, m_pStyAttr(nullptr)
, m_pOutFormatNode(nullptr)
, m_pCurrentStyle(nullptr)
diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx
index 0766d4df2c39..90e1a815a140 100644
--- a/sw/source/filter/ww8/wrtww8.hxx
+++ b/sw/source/filter/ww8/wrtww8.hxx
@@ -486,10 +486,10 @@ public:
const SwPageDesc *m_pCurrentPageDesc;
bool m_bPrevTextNodeIsEmpty;
bool m_bFirstTOCNodeWithSection;
- WW8_WrPlcPn* m_pPapPlc;
- WW8_WrPlcPn* m_pChpPlc;
+ std::unique_ptr<WW8_WrPlcPn> m_pPapPlc;
+ std::unique_ptr<WW8_WrPlcPn> m_pChpPlc;
MSWordAttrIter* m_pChpIter;
- MSWordStyles* m_pStyles;
+ std::unique_ptr<MSWordStyles> m_pStyles;
WW8_WrPlcAnnotations* m_pAtn;
std::unique_ptr<WW8_WrtFactoids> m_pFactoids;
WW8_WrPlcTextBoxes *m_pTextBxs, *m_pHFTextBxs;
@@ -512,18 +512,18 @@ public:
Point* m_pFlyOffset; // for adjusting of character-bound Fly in the Writer,
RndStdIds m_eNewAnchorType; // that is paragraph-bound in the WW.
- WW8_WrPlcField* m_pFieldMain; // fields in MainText
- WW8_WrPlcField* m_pFieldHdFt; // fields in Header/Footer
- WW8_WrPlcField* m_pFieldFootnote; // fields in FootNotes
- WW8_WrPlcField* m_pFieldEdn; // fields in EndNotes
- WW8_WrPlcField* m_pFieldAtn; // fields in Annotations
- WW8_WrPlcField* m_pFieldTextBxs; // fields in textboxes
- WW8_WrPlcField* m_pFieldHFTextBxs; // fields in header/footer textboxes
- WW8_WrMagicTable *m_pMagicTable; // keeps track of table cell positions, and
+ std::unique_ptr<WW8_WrPlcField> m_pFieldMain; // fields in MainText
+ std::unique_ptr<WW8_WrPlcField> m_pFieldHdFt; // fields in Header/Footer
+ std::unique_ptr<WW8_WrPlcField> m_pFieldFootnote; // fields in FootNotes
+ std::unique_ptr<WW8_WrPlcField> m_pFieldEdn; // fields in EndNotes
+ std::unique_ptr<WW8_WrPlcField> m_pFieldAtn; // fields in Annotations
+ std::unique_ptr<WW8_WrPlcField> m_pFieldTextBxs; // fields in textboxes
+ std::unique_ptr<WW8_WrPlcField> m_pFieldHFTextBxs; // fields in header/footer textboxes
+ std::unique_ptr<WW8_WrMagicTable> m_pMagicTable; // keeps track of table cell positions, and
// marks those that contain graphics,
// which is required to make word display
// graphics inside tables
- SwWW8WrGrf* m_pGrf;
+ std::unique_ptr<SwWW8WrGrf> m_pGrf;
const SwAttrSet* m_pStyAttr; // StyleAttr for Tabs
const SwModify* m_pOutFormatNode; // write Format or Node
const SwFormat *m_pCurrentStyle; // iff bStyDef=true, then this store the current style
@@ -960,7 +960,7 @@ private:
class WW8Export : public MSWordExportBase
{
public:
- ww::bytes* pO; ///< Buffer
+ 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 f48554658ec8..76de5be7b2ec 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -1711,25 +1711,25 @@ WW8_WrPlcField* WW8Export::CurrentFieldPlc() const
switch (m_nTextTyp)
{
case TXT_MAINTEXT:
- pFieldP = m_pFieldMain;
+ pFieldP = m_pFieldMain.get();
break;
case TXT_HDFT:
- pFieldP = m_pFieldHdFt;
+ pFieldP = m_pFieldHdFt.get();
break;
case TXT_FTN:
- pFieldP = m_pFieldFootnote;
+ pFieldP = m_pFieldFootnote.get();
break;
case TXT_EDN:
- pFieldP = m_pFieldEdn;
+ pFieldP = m_pFieldEdn.get();
break;
case TXT_ATN:
- pFieldP = m_pFieldAtn;
+ pFieldP = m_pFieldAtn.get();
break;
case TXT_TXTBOX:
- pFieldP = m_pFieldTextBxs;
+ pFieldP = m_pFieldTextBxs.get();
break;
case TXT_HFTXTBOX:
- pFieldP = m_pFieldHFTextBxs;
+ pFieldP = m_pFieldHFTextBxs.get();
break;
default:
OSL_ENSURE( false, "what type of SubDoc is that?" );
@@ -3884,7 +3884,7 @@ void WW8AttributeOutput::SectionBreak( sal_uInt8 nC, const WW8_SepInfo* /*pSecti
sal_uInt32 AttributeOutputBase::GridCharacterPitch( const SwTextGridItem& rGrid ) const
{
- MSWordStyles * pStyles = GetExport().m_pStyles;
+ MSWordStyles * pStyles = GetExport().m_pStyles.get();
const SwFormat * pSwFormat = pStyles->GetSwFormat(0);
sal_uInt32 nPageCharSize = 0;