[Libreoffice-commits] core.git: 2 commits - sc/source sw/inc sw/source
Noel Grandin
noel.grandin at collabora.co.uk
Wed Jun 27 06:35:59 UTC 2018
sc/source/filter/xml/xmlannoi.cxx | 7 ++---
sc/source/filter/xml/xmlannoi.hxx | 2 -
sw/inc/viscrs.hxx | 10 ++++----
sw/source/core/crsr/viscrs.cxx | 46 +++++++++-----------------------------
4 files changed, 21 insertions(+), 44 deletions(-)
New commits:
commit 0541b41705946a8086f3ad2c5366765c389e5480
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Tue Jun 26 15:34:32 2018 +0200
loplugin:useuniqueptr in SwSelPaintRects
Change-Id: I34411e00d67ab29eb0796207d17f77a4f767c0b0
Reviewed-on: https://gerrit.libreoffice.org/56500
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sw/inc/viscrs.hxx b/sw/inc/viscrs.hxx
index 902a25314a00..258fc8d3f105 100644
--- a/sw/inc/viscrs.hxx
+++ b/sw/inc/viscrs.hxx
@@ -21,6 +21,7 @@
#include <config_features.h>
+#include <svx/sdr/overlay/overlayobject.hxx>
#include <vcl/cursor.hxx>
#include "swcrsr.hxx"
#include "swrect.hxx"
@@ -59,7 +60,6 @@ public:
// From here classes/methods for selections.
-namespace sdr { namespace overlay { class OverlayObject; }}
namespace sw { namespace overlay { class OverlayRangesOutline; }}
class MapMode;
@@ -74,15 +74,15 @@ class SwSelPaintRects : public SwRects
const SwCursorShell* m_pCursorShell;
#if HAVE_FEATURE_DESKTOP || defined(ANDROID)
- sdr::overlay::OverlayObject* m_pCursorOverlay;
+ std::unique_ptr<sdr::overlay::OverlayObject> m_pCursorOverlay;
// access to m_pCursorOverlay for swapContent
- sdr::overlay::OverlayObject* getCursorOverlay() const { return m_pCursorOverlay; }
- void setCursorOverlay(sdr::overlay::OverlayObject* pNew) { m_pCursorOverlay = pNew; }
+ sdr::overlay::OverlayObject* getCursorOverlay() const { return m_pCursorOverlay.get(); }
+ void setCursorOverlay(std::unique_ptr<sdr::overlay::OverlayObject> pNew) { m_pCursorOverlay = std::move(pNew); }
#endif
bool m_bShowTextInputFieldOverlay;
- sw::overlay::OverlayRangesOutline* m_pTextInputFieldOverlay;
+ std::unique_ptr<sw::overlay::OverlayRangesOutline> m_pTextInputFieldOverlay;
void HighlightInputField();
diff --git a/sw/source/core/crsr/viscrs.cxx b/sw/source/core/crsr/viscrs.cxx
index f52f96e017ad..6e588b0dfd14 100644
--- a/sw/source/core/crsr/viscrs.cxx
+++ b/sw/source/core/crsr/viscrs.cxx
@@ -265,34 +265,17 @@ void SwSelPaintRects::swapContent(SwSelPaintRects& rSwap)
#if HAVE_FEATURE_DESKTOP
// #i75172# also swap m_pCursorOverlay
- sdr::overlay::OverlayObject* pTempOverlay = getCursorOverlay();
- setCursorOverlay(rSwap.getCursorOverlay());
- rSwap.setCursorOverlay(pTempOverlay);
-
- const bool bTempShowTextInputFieldOverlay = m_bShowTextInputFieldOverlay;
- m_bShowTextInputFieldOverlay = rSwap.m_bShowTextInputFieldOverlay;
- rSwap.m_bShowTextInputFieldOverlay = bTempShowTextInputFieldOverlay;
-
- sw::overlay::OverlayRangesOutline* pTempTextInputFieldOverlay = m_pTextInputFieldOverlay;
- m_pTextInputFieldOverlay = rSwap.m_pTextInputFieldOverlay;
- rSwap.m_pTextInputFieldOverlay = pTempTextInputFieldOverlay;
+ std::swap(m_pCursorOverlay, rSwap.m_pCursorOverlay);
+ std::swap(m_bShowTextInputFieldOverlay, rSwap.m_bShowTextInputFieldOverlay);
+ std::swap(m_pTextInputFieldOverlay, rSwap.m_pTextInputFieldOverlay);
#endif
}
void SwSelPaintRects::Hide()
{
#if HAVE_FEATURE_DESKTOP
- if (m_pCursorOverlay)
- {
- delete m_pCursorOverlay;
- m_pCursorOverlay = nullptr;
- }
-
- if (m_pTextInputFieldOverlay != nullptr)
- {
- delete m_pTextInputFieldOverlay;
- m_pTextInputFieldOverlay = nullptr;
- }
+ m_pCursorOverlay.reset();
+ m_pTextInputFieldOverlay.reset();
#endif
SwRects::clear();
@@ -350,12 +333,11 @@ void SwSelPaintRects::Show(std::vector<OString>* pSelectionRectangles)
{
if(!aNewRanges.empty())
{
- static_cast<sdr::overlay::OverlaySelection*>(m_pCursorOverlay)->setRanges(aNewRanges);
+ static_cast<sdr::overlay::OverlaySelection*>(m_pCursorOverlay.get())->setRanges(aNewRanges);
}
else
{
- delete m_pCursorOverlay;
- m_pCursorOverlay = nullptr;
+ m_pCursorOverlay.reset();
}
}
else if(!empty())
@@ -370,11 +352,11 @@ void SwSelPaintRects::Show(std::vector<OString>* pSelectionRectangles)
const Color aHighlight(aSvtOptionsDrawinglayer.getHilightColor());
// create correct selection
- m_pCursorOverlay = new sdr::overlay::OverlaySelection(
+ m_pCursorOverlay.reset( new sdr::overlay::OverlaySelection(
sdr::overlay::OverlayType::Transparent,
aHighlight,
aNewRanges,
- true);
+ true) );
xTargetOverlay->add(*m_pCursorOverlay);
}
@@ -481,19 +463,15 @@ void SwSelPaintRects::HighlightInputField()
Color aHighlight(aSvtOptionsDrawinglayer.getHilightColor());
aHighlight.DecreaseLuminance( 128 );
- m_pTextInputFieldOverlay = new sw::overlay::OverlayRangesOutline(
- aHighlight, aInputFieldRanges );
+ m_pTextInputFieldOverlay.reset( new sw::overlay::OverlayRangesOutline(
+ aHighlight, aInputFieldRanges ) );
xTargetOverlay->add( *m_pTextInputFieldOverlay );
}
}
}
else
{
- if (m_pTextInputFieldOverlay != nullptr)
- {
- delete m_pTextInputFieldOverlay;
- m_pTextInputFieldOverlay = nullptr;
- }
+ m_pTextInputFieldOverlay.reset();
}
}
commit 510050dea2ce0a6476f0adb0f603a3e9fbe87405
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Tue Jun 26 15:05:19 2018 +0200
loplugin:useuniqueptr in ScXMLAnnotationContext
Change-Id: I0f26159f8af09a68c819c400abd09454a6d827b2
Reviewed-on: https://gerrit.libreoffice.org/56499
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sc/source/filter/xml/xmlannoi.cxx b/sc/source/filter/xml/xmlannoi.cxx
index 5f5216cf09d6..f7e87a940206 100644
--- a/sc/source/filter/xml/xmlannoi.cxx
+++ b/sc/source/filter/xml/xmlannoi.cxx
@@ -54,8 +54,8 @@ ScXMLAnnotationContext::ScXMLAnnotationContext( ScXMLImport& rImport,
{
XMLTableShapeImportHelper* pTableShapeImport = static_cast<XMLTableShapeImportHelper*>(GetScImport().GetShapeImport().get());
pTableShapeImport->SetAnnotation(this);
- pShapeContext = GetScImport().GetShapeImport()->CreateGroupChildContext(
- GetScImport(), nPrfx, rLName, xAttrList, xLocalShapes, true);
+ pShapeContext.reset( GetScImport().GetShapeImport()->CreateGroupChildContext(
+ GetScImport(), nPrfx, rLName, xAttrList, xLocalShapes, true) );
}
sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
@@ -155,8 +155,7 @@ void ScXMLAnnotationContext::EndElement()
if (pShapeContext)
{
pShapeContext->EndElement();
- delete pShapeContext;
- pShapeContext = nullptr;
+ pShapeContext.reset();
}
mrAnnotationData.maAuthor = maAuthorBuffer.makeStringAndClear();
diff --git a/sc/source/filter/xml/xmlannoi.hxx b/sc/source/filter/xml/xmlannoi.hxx
index 0e62d99f7e90..21b78e94cb34 100644
--- a/sc/source/filter/xml/xmlannoi.hxx
+++ b/sc/source/filter/xml/xmlannoi.hxx
@@ -97,7 +97,7 @@ private:
OUStringBuffer maAuthorBuffer;
OUStringBuffer maCreateDateBuffer;
OUStringBuffer maCreateDateStringBuffer;
- SvXMLImportContext* pShapeContext;
+ std::unique_ptr<SvXMLImportContext> pShapeContext;
};
#endif
More information about the Libreoffice-commits
mailing list