summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-06-26 15:34:32 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-06-27 08:35:49 +0200
commit0541b41705946a8086f3ad2c5366765c389e5480 (patch)
tree07f88305f96939155bc9eb88d97d00cce4fa660c /sw
parent510050dea2ce0a6476f0adb0f603a3e9fbe87405 (diff)
loplugin:useuniqueptr in SwSelPaintRects
Change-Id: I34411e00d67ab29eb0796207d17f77a4f767c0b0 Reviewed-on: https://gerrit.libreoffice.org/56500 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/viscrs.hxx10
-rw-r--r--sw/source/core/crsr/viscrs.cxx46
2 files changed, 17 insertions, 39 deletions
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();
}
}