[Libreoffice-commits] core.git: 2 commits - lotuswordpro/source
Noel Grandin
noel.grandin at collabora.co.uk
Mon Mar 5 06:33:30 UTC 2018
lotuswordpro/source/filter/lwpdrawobj.cxx | 8 ----
lotuswordpro/source/filter/lwpdrawobj.hxx | 2 -
lotuswordpro/source/filter/lwppara.cxx | 49 +++++++------------------
lotuswordpro/source/filter/lwppara.hxx | 12 ++----
lotuswordpro/source/filter/lwppara1.cxx | 14 ++-----
lotuswordpro/source/filter/lwpparaproperty.cxx | 3 -
lotuswordpro/source/filter/lwpparaproperty.hxx | 9 +---
7 files changed, 29 insertions(+), 68 deletions(-)
New commits:
commit 38667b4895b04fabcd9639d0154e55c23b743c7a
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Thu Mar 1 11:10:53 2018 +0200
loplugin:useuniqueptr in LwpDrawPolygon
Change-Id: Ia9a6b312a7e0ce189257395c84f65156546cb955
Reviewed-on: https://gerrit.libreoffice.org/50739
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/lotuswordpro/source/filter/lwpdrawobj.cxx b/lotuswordpro/source/filter/lwpdrawobj.cxx
index b1711065217d..60a7b9a5a306 100644
--- a/lotuswordpro/source/filter/lwpdrawobj.cxx
+++ b/lotuswordpro/source/filter/lwpdrawobj.cxx
@@ -565,17 +565,11 @@ XFFrame* LwpDrawPolyLine::CreateStandardDrawObj(const OUString& rStyleName)
LwpDrawPolygon::LwpDrawPolygon(SvStream * pStream, DrawingOffsetAndScale* pTransData)
: LwpDrawObj(pStream, pTransData)
, m_nNumPoints(0)
- , m_pVector(nullptr)
{
}
LwpDrawPolygon::~LwpDrawPolygon()
{
- if (m_pVector)
- {
- delete [] m_pVector;
- m_pVector = nullptr;
- }
}
/**
@@ -589,7 +583,7 @@ void LwpDrawPolygon::Read()
if (m_nNumPoints > m_pStream->remainingSize() / 4)
throw BadRead();
- m_pVector = new SdwPoint[m_nNumPoints];
+ m_pVector.reset( new SdwPoint[m_nNumPoints] );
for (sal_uInt16 nC = 0; nC < m_nNumPoints; nC++)
{
diff --git a/lotuswordpro/source/filter/lwpdrawobj.hxx b/lotuswordpro/source/filter/lwpdrawobj.hxx
index 647a715eb30e..01b946653b8b 100644
--- a/lotuswordpro/source/filter/lwpdrawobj.hxx
+++ b/lotuswordpro/source/filter/lwpdrawobj.hxx
@@ -208,7 +208,7 @@ class LwpDrawPolygon : public LwpDrawObj
{
private:
sal_uInt16 m_nNumPoints;
- SdwPoint* m_pVector;
+ std::unique_ptr<SdwPoint[]> m_pVector;
public:
LwpDrawPolygon(SvStream * pStream, DrawingOffsetAndScale* pTransData);
commit 23c6774691d6c745a21762765dc5036c7484e800
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Thu Mar 1 11:04:41 2018 +0200
loplugin:useuniqueptr in LwpPara
to simplify the management, use a std::vector instead of an embedded
linked list for LwpParaProperty
Change-Id: Ib09c6609967552a74d5cb2a43565104bf3f5c036
Reviewed-on: https://gerrit.libreoffice.org/50738
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/lotuswordpro/source/filter/lwppara.cxx b/lotuswordpro/source/filter/lwppara.cxx
index d84fbb59d8b8..0175e54ae08a 100644
--- a/lotuswordpro/source/filter/lwppara.cxx
+++ b/lotuswordpro/source/filter/lwppara.cxx
@@ -103,7 +103,6 @@ LwpPara::LwpPara(LwpObjectHeader const & objHdr, LwpSvStream* pStrm)
, m_nOrdinal(0)
, m_nFlags(0)
, m_nLevel(0)
- , m_pProps(nullptr)
, m_pBreaks(nullptr)
, m_pIndentOverride(nullptr)
, m_FontID(0)
@@ -122,21 +121,6 @@ LwpPara::LwpPara(LwpObjectHeader const & objHdr, LwpSvStream* pStrm)
LwpPara::~LwpPara()
{
- if (m_pBreaks)
- {
- delete m_pBreaks;
- m_pBreaks = nullptr;
- }
-
- delete m_pIndentOverride;
-
- LwpParaProperty* pNextProp;
- while(m_pProps)
- {
- pNextProp = m_pProps->GetNext();
- delete m_pProps;
- m_pProps = pNextProp;
- }
}
void LwpPara::Read()
@@ -323,31 +307,29 @@ void LwpPara::RegisterStyle()
if (pParaStyle && pParaStyle->GetIndent())
{
std::unique_ptr<LwpIndentOverride> pIndentOverride(GetParaStyle()->GetIndent()->clone());
- delete m_pIndentOverride;
- m_pIndentOverride = pIndentOverride.release();
+ m_pIndentOverride = std::move(pIndentOverride);
}
std::unique_ptr<XFParaStyle> xOverStyle;
bool noSpacing = true;
LwpParaProperty* pBulletProps = nullptr, *pNumberingProps = nullptr;
- if (m_pProps != nullptr)
+ if (!m_vProps.empty())
{
bool noIndent = true;
xOverStyle.reset(new XFParaStyle);
*xOverStyle = *pBaseStyle;
xOverStyle->SetStyleName("");
- LwpParaProperty* pProps = m_pProps;
sal_uInt32 PropType;
LwpParaStyle& rParaStyle = dynamic_cast<LwpParaStyle&>(*m_ParaStyle.obj());
- while (pProps)
+ for (auto & pProps : m_vProps)
{
PropType = pProps->GetType();
switch(PropType)
{
case PP_LOCAL_ALIGN:
{
- LwpAlignmentOverride *pAlignment = static_cast<LwpParaAlignProperty*>(pProps)->GetAlignment();
+ LwpAlignmentOverride *pAlignment = static_cast<LwpParaAlignProperty*>(pProps.get())->GetAlignment();
if (pAlignment)
{
if (!rParaStyle.GetAlignment())
@@ -366,20 +348,20 @@ void LwpPara::RegisterStyle()
case PP_LOCAL_INDENT:
{
noIndent = false;
- LwpIndentOverride *pIndent = static_cast<LwpParaIndentProperty*>(pProps)->GetIndent();
+ LwpIndentOverride *pIndent = static_cast<LwpParaIndentProperty*>(pProps.get())->GetIndent();
if (pIndent)
{
if (!rParaStyle.GetIndent())
OverrideIndent(nullptr, pIndent, xOverStyle.get());
else
- OverrideIndent(m_pIndentOverride, pIndent, xOverStyle.get());
+ OverrideIndent(m_pIndentOverride.get(), pIndent, xOverStyle.get());
}
break;
}
case PP_LOCAL_SPACING:
{
noSpacing = false;
- LwpSpacingOverride *pSpacing = static_cast<LwpParaSpacingProperty*>(pProps)->GetSpacing();
+ LwpSpacingOverride *pSpacing = static_cast<LwpParaSpacingProperty*>(pProps.get())->GetSpacing();
if (pSpacing)
{
if (!rParaStyle.GetSpacing())
@@ -395,22 +377,22 @@ void LwpPara::RegisterStyle()
}
case PP_LOCAL_BORDER:
{
- OverrideParaBorder(pProps, xOverStyle.get());
+ OverrideParaBorder(pProps.get(), xOverStyle.get());
break;
}
case PP_LOCAL_BREAKS:
{
- OverrideParaBreaks(pProps, xOverStyle.get());
+ OverrideParaBreaks(pProps.get(), xOverStyle.get());
break;
}
case PP_LOCAL_BULLET:
{
- pBulletProps = pProps;
+ pBulletProps = pProps.get();
break;
}
case PP_LOCAL_NUMBERING:
{
- pNumberingProps = pProps;
+ pNumberingProps = pProps.get();
break;
}
case PP_LOCAL_TABRACK:
@@ -419,7 +401,7 @@ void LwpPara::RegisterStyle()
}
case PP_LOCAL_BACKGROUND:
{
- LwpBackgroundOverride* pBGOver = static_cast<LwpParaBackGroundProperty*>(pProps)->GetBackground();
+ LwpBackgroundOverride* pBGOver = static_cast<LwpParaBackGroundProperty*>(pProps.get())->GetBackground();
if (pBGOver)
{
LwpBackgroundStuff& rBGStuff = pBGOver->GetBGStuff();
@@ -446,14 +428,13 @@ void LwpPara::RegisterStyle()
default:
break;
}
- pProps = pProps->GetNext();
}
if (noIndent && m_pIndentOverride)
{
if (m_pIndentOverride->IsUseRelative() && GetParent())
{
- OverrideIndent(nullptr,m_pIndentOverride,xOverStyle.get());
+ OverrideIndent(nullptr,m_pIndentOverride.get(),xOverStyle.get());
}
}
if (!m_ParentStyleName.isEmpty())
@@ -469,7 +450,7 @@ void LwpPara::RegisterStyle()
{
xOverStyle.reset(new XFParaStyle);
*xOverStyle = *pBaseStyle;
- OverrideIndent(nullptr,m_pIndentOverride,xOverStyle.get());
+ OverrideIndent(nullptr,m_pIndentOverride.get(),xOverStyle.get());
if (!m_ParentStyleName.isEmpty())
xOverStyle->SetParentStyleName(m_ParentStyleName);
m_StyleName = pXFStyleManager->AddStyle(xOverStyle.release()).m_pStyle->GetStyleName();
@@ -511,7 +492,7 @@ void LwpPara::RegisterStyle()
}
else if (!m_xBullOver->IsEditable())
{
- m_aBulletStyleName = pBulletStyleMgr->RegisterBulletStyle(this, m_xBullOver.get(), m_pIndentOverride);
+ m_aBulletStyleName = pBulletStyleMgr->RegisterBulletStyle(this, m_xBullOver.get(), m_pIndentOverride.get());
}
// test codes
diff --git a/lotuswordpro/source/filter/lwppara.hxx b/lotuswordpro/source/filter/lwppara.hxx
index ef44a214d1dd..1a688304937d 100644
--- a/lotuswordpro/source/filter/lwppara.hxx
+++ b/lotuswordpro/source/filter/lwppara.hxx
@@ -199,18 +199,18 @@ protected:
sal_uInt16 m_nFlags;
sal_uInt16 m_nLevel;
LwpFribPtr m_Fribs;
- LwpParaProperty* m_pProps;
+ std::vector< std::unique_ptr<LwpParaProperty> > m_vProps;
//LwpForked3NotifyList* m_NotifyList; //not saved
OUString m_StyleName;
OUString m_ParentStyleName;//Add to support toc
- LwpBreaksOverride* m_pBreaks;
+ std::unique_ptr<LwpBreaksOverride> m_pBreaks;
OUString m_AftPageBreakName;
OUString m_BefPageBreakName;
OUString m_AftColumnBreakName;
OUString m_BefColumnBreakName;
- LwpIndentOverride* m_pIndentOverride;
+ std::unique_ptr<LwpIndentOverride> m_pIndentOverride;
OUString m_Content;//for silver bullet,get text of first frib
sal_uInt32 m_FontID;//for silver bullet
OUString m_AllText;//get all text in this paragraph
@@ -327,13 +327,11 @@ inline void LwpPara::SetXFContainer(XFContentContainer* pCont)
}
inline LwpIndentOverride* LwpPara::GetIndent()
{
- return m_pIndentOverride;
+ return m_pIndentOverride.get();
}
inline void LwpPara::SetIndent(LwpIndentOverride* pIndentOverride)
{
- if (m_pIndentOverride)
- delete m_pIndentOverride;
- m_pIndentOverride = pIndentOverride;
+ m_pIndentOverride.reset( pIndentOverride );
}
inline LwpObjectID& LwpPara::GetStoryID()
{
diff --git a/lotuswordpro/source/filter/lwppara1.cxx b/lotuswordpro/source/filter/lwppara1.cxx
index 14c1e7244f14..d31decf5df73 100644
--- a/lotuswordpro/source/filter/lwppara1.cxx
+++ b/lotuswordpro/source/filter/lwppara1.cxx
@@ -400,8 +400,7 @@ void LwpPara::OverrideParaBreaks(LwpParaProperty* pProps, XFParaStyle* pOverStyl
}
// save the breaks
- delete m_pBreaks;
- m_pBreaks = pFinalBreaks.release();
+ m_pBreaks.reset( pFinalBreaks.release() );
XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
if (m_pBreaks->IsKeepWithNext())
@@ -554,16 +553,11 @@ void LwpPara::OverrideParaNumbering(LwpParaProperty const * pProps)
**************************************************************************/
LwpParaProperty* LwpPara::GetProperty(sal_uInt32 nPropType)
{
- LwpParaProperty* pProps = m_pProps;
- while(pProps)
- {
- if(pProps->GetType() == nPropType)
+ for (auto & i : m_vProps)
+ if(i->GetType() == nPropType)
{
- return pProps;
+ return i.get();
}
- pProps = pProps->GetNext();
-
- }
return nullptr;
}
diff --git a/lotuswordpro/source/filter/lwpparaproperty.cxx b/lotuswordpro/source/filter/lwpparaproperty.cxx
index 4df55a5bbec8..a60b291c1959 100644
--- a/lotuswordpro/source/filter/lwpparaproperty.cxx
+++ b/lotuswordpro/source/filter/lwpparaproperty.cxx
@@ -130,8 +130,7 @@ void LwpPara::ReadPropertyList(LwpObjectStream* pFile)
// Stick it at the beginning of the list
if (NewProp)
{
- NewProp->insert(m_pProps, nullptr);
- m_pProps = NewProp;
+ m_vProps.emplace(m_vProps.begin(), NewProp);
}
}
}
diff --git a/lotuswordpro/source/filter/lwpparaproperty.hxx b/lotuswordpro/source/filter/lwpparaproperty.hxx
index 89bd4cd52820..4c97f011c9ba 100644
--- a/lotuswordpro/source/filter/lwpparaproperty.hxx
+++ b/lotuswordpro/source/filter/lwpparaproperty.hxx
@@ -84,19 +84,14 @@
#define PP_LOCAL_KINSOKU 0x4b494e53UL /* "KINS" */
#define PP_PROPLIST 0x50524f50UL /* "PROP" */
-class LwpParaProperty : public LwpDLList
+class LwpParaProperty
{
public:
LwpParaProperty(){}
+ virtual ~LwpParaProperty() {}
virtual sal_uInt32 GetType() = 0;
- inline LwpParaProperty* GetNext();
};
-inline LwpParaProperty* LwpParaProperty::GetNext()
-{
- return static_cast<LwpParaProperty*>(LwpDLList::GetNext());
-}
-
//align/indent/spacing
//TO DO:border/background etc
More information about the Libreoffice-commits
mailing list