[Libreoffice-commits] core.git: 2 commits - sw/inc sw/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Fri Jan 11 07:44:39 UTC 2019
sw/inc/ndarr.hxx | 2 -
sw/source/core/docnode/ndtbl.cxx | 7 ++---
sw/source/core/unocore/unosett.cxx | 44 ++++++++++++++-----------------------
sw/source/core/unocore/unotext.cxx | 6 ++---
4 files changed, 24 insertions(+), 35 deletions(-)
New commits:
commit a41b1d18ad26703f6a5b622f10e1126570bfd419
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Thu Jan 10 16:58:45 2019 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Jan 11 08:44:23 2019 +0100
use unique_ptr in SwNodes::ExpandRangeForTableBox
Change-Id: I31cc9d6b962c116c64789d886b82ea476f4e5144
Reviewed-on: https://gerrit.libreoffice.org/66124
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sw/inc/ndarr.hxx b/sw/inc/ndarr.hxx
index 598397c43cf6..6153af0ad012 100644
--- a/sw/inc/ndarr.hxx
+++ b/sw/inc/ndarr.hxx
@@ -258,7 +258,7 @@ public:
SwTextFormatColl* pTextColl,
SwUndoTextToTable* pUndo );
- SwNodeRange * ExpandRangeForTableBox(const SwNodeRange & rRange);
+ std::unique_ptr<SwNodeRange> ExpandRangeForTableBox(const SwNodeRange & rRange);
/// create a table from a vector of NodeRanges - API support
SwTableNode* TextToTable( const TableRanges_t& rTableNodes,
diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index 47246bd18a69..6a173ffab31d 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -1279,9 +1279,8 @@ const SwTable* SwDoc::TextToTable( const std::vector< std::vector<SwNodeRange> >
return &rNdTable;
}
-SwNodeRange * SwNodes::ExpandRangeForTableBox(const SwNodeRange & rRange)
+std::unique_ptr<SwNodeRange> SwNodes::ExpandRangeForTableBox(const SwNodeRange & rRange)
{
- SwNodeRange * pResult = nullptr;
bool bChanged = false;
SwNodeIndex aNewStart = rRange.aStart;
@@ -1335,9 +1334,9 @@ SwNodeRange * SwNodes::ExpandRangeForTableBox(const SwNodeRange & rRange)
pNode = &aIndex.GetNode();
}
+ std::unique_ptr<SwNodeRange> pResult;
if (bChanged)
- pResult = new SwNodeRange(aNewStart, aNewEnd);
-
+ pResult.reset(new SwNodeRange(aNewStart, aNewEnd));
return pResult;
}
diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx
index 68d78213fb48..944851a47f2d 100644
--- a/sw/source/core/unocore/unotext.cxx
+++ b/sw/source/core/unocore/unotext.cxx
@@ -1835,10 +1835,10 @@ void SwXText::Impl::ConvertCell(
SwNodeRange aTmpRange(aStartCellPam.Start()->nNode,
aEndCellPam.End()->nNode);
- SwNodeRange * pCorrectedRange =
+ std::unique_ptr<SwNodeRange> pCorrectedRange =
m_pDoc->GetNodes().ExpandRangeForTableBox(aTmpRange);
- if (pCorrectedRange != nullptr)
+ if (pCorrectedRange)
{
SwPaM aNewStartPaM(pCorrectedRange->aStart, 0);
aStartCellPam = aNewStartPaM;
@@ -1851,7 +1851,7 @@ void SwXText::Impl::ConvertCell(
SwPaM aNewEndPaM(pCorrectedRange->aEnd, nEndLen);
aEndCellPam = aNewEndPaM;
- delete pCorrectedRange;
+ pCorrectedRange.reset();
}
/** check the nodes between start and end
commit c7d5ad9dbfc7ada52a3ec8c38fa8420a08b126c3
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Thu Jan 10 16:52:25 2019 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Jan 11 08:44:15 2019 +0100
use unique_ptr in SwXNumberingRules
Change-Id: I7daa1fbd11c62d712b2ff70714b5e5bda63d54d8
Reviewed-on: https://gerrit.libreoffice.org/66123
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sw/source/core/unocore/unosett.cxx b/sw/source/core/unocore/unosett.cxx
index 4a82db8bd944..d3b949b2a973 100644
--- a/sw/source/core/unocore/unosett.cxx
+++ b/sw/source/core/unocore/unosett.cxx
@@ -1610,9 +1610,9 @@ void SwXNumberingRules::SetPropertiesToNumFormat(
bool bWrongArg = false;
if(!bExcept)
- {
- SvxBrushItem* pSetBrush = nullptr;
- Size* pSetSize = nullptr;
+ {
+ std::unique_ptr<SvxBrushItem> pSetBrush;
+ std::unique_ptr<Size> pSetSize;
std::unique_ptr<SwFormatVertOrient> pSetVOrient;
bool bCharStyleNameSet = false;
@@ -1922,11 +1922,9 @@ void SwXNumberingRules::SetPropertiesToNumFormat(
{
const SvxBrushItem* pOrigBrush = aFormat.GetBrush();
if(pOrigBrush)
- {
- pSetBrush = new SvxBrushItem(*pOrigBrush);
- }
+ pSetBrush.reset(new SvxBrushItem(*pOrigBrush));
else
- pSetBrush = new SvxBrushItem(OUString(), OUString(), GPOS_AREA, RES_BACKGROUND);
+ pSetBrush.reset(new SvxBrushItem(OUString(), OUString(), GPOS_AREA, RES_BACKGROUND));
}
Graphic aGraphic(xGraphic);
pSetBrush->SetGraphic(aGraphic);
@@ -1945,11 +1943,9 @@ void SwXNumberingRules::SetPropertiesToNumFormat(
{
const SvxBrushItem* pOrigBrush = aFormat.GetBrush();
if(pOrigBrush)
- {
- pSetBrush = new SvxBrushItem(*pOrigBrush);
- }
+ pSetBrush.reset(new SvxBrushItem(*pOrigBrush));
else
- pSetBrush = new SvxBrushItem(OUString(), OUString(), GPOS_AREA, RES_BACKGROUND);
+ pSetBrush.reset(new SvxBrushItem(OUString(), OUString(), GPOS_AREA, RES_BACKGROUND));
}
uno::Reference<graphic::XGraphic> xGraphic(xBitmap, uno::UNO_QUERY);
@@ -1964,7 +1960,7 @@ void SwXNumberingRules::SetPropertiesToNumFormat(
{
assert( !pDocShell );
if(!pSetSize)
- pSetSize = new Size;
+ pSetSize.reset(new Size);
awt::Size size;
if (pProp->Value >>= size)
{
@@ -2016,11 +2012,9 @@ void SwXNumberingRules::SetPropertiesToNumFormat(
{
const SvxBrushItem* pOrigBrush = aFormat.GetBrush();
if(pOrigBrush)
- {
- pSetBrush = new SvxBrushItem(*pOrigBrush);
- }
+ pSetBrush.reset(new SvxBrushItem(*pOrigBrush));
else
- pSetBrush = new SvxBrushItem(OUString(), OUString(), GPOS_AREA, RES_BACKGROUND);
+ pSetBrush.reset(new SvxBrushItem(OUString(), OUString(), GPOS_AREA, RES_BACKGROUND));
}
Graphic aGraphic = vcl::graphic::loadFromURL(aURL);
@@ -2036,7 +2030,7 @@ void SwXNumberingRules::SetPropertiesToNumFormat(
if(!bExcept && !bWrongArg && (pSetBrush || pSetSize || pSetVOrient))
{
if(!pSetBrush && aFormat.GetBrush())
- pSetBrush = new SvxBrushItem(*aFormat.GetBrush());
+ pSetBrush.reset(new SvxBrushItem(*aFormat.GetBrush()));
if(pSetBrush)
{
@@ -2045,7 +2039,7 @@ void SwXNumberingRules::SetPropertiesToNumFormat(
if(!pSetSize)
{
- pSetSize = new Size(aFormat.GetGraphicSize());
+ pSetSize.reset(new Size(aFormat.GetGraphicSize()));
if(!pSetSize->Width() || !pSetSize->Height())
{
const Graphic* pGraphic = pSetBrush->GetGraphic();
@@ -2055,7 +2049,7 @@ void SwXNumberingRules::SetPropertiesToNumFormat(
}
sal_Int16 eOrient = pSetVOrient ?
pSetVOrient->GetVertOrient() : text::VertOrientation::NONE;
- aFormat.SetGraphicBrush( pSetBrush, pSetSize, text::VertOrientation::NONE == eOrient ? nullptr : &eOrient );
+ aFormat.SetGraphicBrush( pSetBrush.get(), pSetSize.get(), text::VertOrientation::NONE == eOrient ? nullptr : &eOrient );
}
}
if ((!bCharStyleNameSet || rCharStyleName.isEmpty())
@@ -2067,9 +2061,7 @@ void SwXNumberingRules::SetPropertiesToNumFormat(
SwStyleNameMapper::FillProgName(RES_POOLCHR_BUL_LEVEL, tmp);
rCharStyleName = tmp;
}
- delete pSetBrush;
- delete pSetSize;
- }
+ }
if(bWrongArg)
throw lang::IllegalArgumentException();
@@ -2086,13 +2078,13 @@ uno::Reference< XPropertySetInfo > SwXNumberingRules::getPropertySetInfo()
void SwXNumberingRules::setPropertyValue( const OUString& rPropertyName, const Any& rValue )
{
SolarMutexGuard aGuard;
- SwNumRule* pDocRule = nullptr;
+ std::unique_ptr<SwNumRule> pDocRule;
SwNumRule* pCreatedRule = nullptr;
if(!m_pNumRule)
{
if(m_pDocShell)
{
- pDocRule = new SwNumRule(*m_pDocShell->GetDoc()->GetOutlineNumRule());
+ pDocRule.reset(new SwNumRule(*m_pDocShell->GetDoc()->GetOutlineNumRule()));
}
else if(m_pDoc && !m_sCreatedNumRuleName.isEmpty())
{
@@ -2117,7 +2109,6 @@ void SwXNumberingRules::setPropertyValue( const OUString& rPropertyName, const A
}
else if(rPropertyName == UNO_NAME_NAME)
{
- delete pDocRule;
throw IllegalArgumentException();
}
else if(rPropertyName == UNO_NAME_IS_ABSOLUTE_MARGINS)
@@ -2135,7 +2126,6 @@ void SwXNumberingRules::setPropertyValue( const OUString& rPropertyName, const A
}
else if(rPropertyName == UNO_NAME_DEFAULT_LIST_ID)
{
- delete pDocRule;
throw IllegalArgumentException();
}
else
@@ -2144,7 +2134,7 @@ void SwXNumberingRules::setPropertyValue( const OUString& rPropertyName, const A
if(pDocRule)
{
m_pDocShell->GetDoc()->SetOutlineNumRule(*pDocRule);
- delete pDocRule;
+ pDocRule.reset();
}
else if(pCreatedRule)
{
More information about the Libreoffice-commits
mailing list