summaryrefslogtreecommitdiff
path: root/svx/source/sidebar/line
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-05-31 13:15:18 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-06-04 11:27:16 +0200
commit6798473388f9a4b9f2d1c64e89d540d7e15e3584 (patch)
treef3cf72773900aa58dbc50059e241cc11175e0027 /svx/source/sidebar/line
parent100b6a229e0ab9888578c138cd38424d16dec608 (diff)
loplugin:useuniqueptr in LineWidthPopup and LineWidthValueSet
Change-Id: Ia60c396fd4f9fda7c5a2fc6bef4a2a2be01d8bcf Reviewed-on: https://gerrit.libreoffice.org/55233 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svx/source/sidebar/line')
-rw-r--r--svx/source/sidebar/line/LineWidthPopup.cxx36
-rw-r--r--svx/source/sidebar/line/LineWidthValueSet.cxx13
-rw-r--r--svx/source/sidebar/line/LineWidthValueSet.hxx5
3 files changed, 23 insertions, 31 deletions
diff --git a/svx/source/sidebar/line/LineWidthPopup.cxx b/svx/source/sidebar/line/LineWidthPopup.cxx
index b3f4e3cbdb2e..d4a446a0e07c 100644
--- a/svx/source/sidebar/line/LineWidthPopup.cxx
+++ b/svx/source/sidebar/line/LineWidthPopup.cxx
@@ -31,7 +31,6 @@ namespace svx { namespace sidebar {
LineWidthPopup::LineWidthPopup(LinePropertyPanelBase& rParent)
: FloatingWindow(&rParent, "FloatingLineProperty", "svx/ui/floatinglineproperty.ui")
, m_rParent(rParent)
- , m_pStr(nullptr)
, m_sPt(SvxResId(RID_SVXSTR_PT))
, m_eMapUnit(MapUnit::MapTwip)
, m_bVSFocus(true)
@@ -48,35 +47,33 @@ LineWidthPopup::LineWidthPopup(LinePropertyPanelBase& rParent)
m_xVSWidth->SetStyle(m_xVSWidth->GetStyle()| WB_3DLOOK | WB_NO_DIRECTSELECT);
- m_pStr = new OUString[9];
-
- m_pStr[0] = "0.5";
- m_pStr[1] = "0.8";
- m_pStr[2] = "1.0";
- m_pStr[3] = "1.5";
- m_pStr[4] = "2.3";
- m_pStr[5] = "3.0";
- m_pStr[6] = "4.5";
- m_pStr[7] = "6.0";
- m_pStr[8] = SvxResId(RID_SVXSTR_WIDTH_LAST_CUSTOM);
+ maStrUnits[0] = "0.5";
+ maStrUnits[1] = "0.8";
+ maStrUnits[2] = "1.0";
+ maStrUnits[3] = "1.5";
+ maStrUnits[4] = "2.3";
+ maStrUnits[5] = "3.0";
+ maStrUnits[6] = "4.5";
+ maStrUnits[7] = "6.0";
+ maStrUnits[8] = SvxResId(RID_SVXSTR_WIDTH_LAST_CUSTOM);
const LocaleDataWrapper& rLocaleWrapper( Application::GetSettings().GetLocaleDataWrapper() );
const sal_Unicode cSep = rLocaleWrapper.getNumDecimalSep()[0];
for(int i = 0; i <= 7 ; i++)
{
- m_pStr[i] = m_pStr[i].replace('.', cSep);//Modify
- m_pStr[i] += " ";
- m_pStr[i] += m_sPt;
+ maStrUnits[i] = maStrUnits[i].replace('.', cSep);//Modify
+ maStrUnits[i] += " ";
+ maStrUnits[i] += m_sPt;
}
for (sal_uInt16 i = 1 ; i <= 9; ++i)
{
m_xVSWidth->InsertItem(i);
- m_xVSWidth->SetItemText(i, m_pStr[i-1]);
+ m_xVSWidth->SetItemText(i, maStrUnits[i-1]);
}
- m_xVSWidth->SetUnit(m_pStr);
+ m_xVSWidth->SetUnit(maStrUnits);
m_xVSWidth->SetItemData(1, reinterpret_cast<void*>(5));
m_xVSWidth->SetItemData(2, reinterpret_cast<void*>(8));
m_xVSWidth->SetItemData(3, reinterpret_cast<void*>(10));
@@ -98,7 +95,6 @@ LineWidthPopup::LineWidthPopup(LinePropertyPanelBase& rParent)
void LineWidthPopup::dispose()
{
- delete[] m_pStr;
m_xVSWidth.disposeAndClear();
m_xBox.clear();
m_xMFWidth.clear();
@@ -194,7 +190,7 @@ void LineWidthPopup::SetWidthSelect(long lValue, bool bValuable, MapUnit eMapUni
m_bCustom = false;
m_xVSWidth->SetImage(m_aIMGCusGray);
m_xVSWidth->SetCusEnable(false);
- m_xVSWidth->SetItemText(9, m_pStr[8]);
+ m_xVSWidth->SetItemText(9, maStrUnits[8]);
}
if (bValuable)
@@ -212,7 +208,7 @@ void LineWidthPopup::SetWidthSelect(long lValue, bool bValuable, MapUnit eMapUni
sal_uInt16 i = 0;
for(; i < 8; i++)
{
- if (strCurrValue == m_pStr[i])
+ if (strCurrValue == maStrUnits[i])
{
m_xVSWidth->SetSelItem(i+1);
break;
diff --git a/svx/source/sidebar/line/LineWidthValueSet.cxx b/svx/source/sidebar/line/LineWidthValueSet.cxx
index 9e497c6ca1d4..f08d3462e24b 100644
--- a/svx/source/sidebar/line/LineWidthValueSet.cxx
+++ b/svx/source/sidebar/line/LineWidthValueSet.cxx
@@ -29,7 +29,6 @@ LineWidthValueSet::LineWidthValueSet(vcl::Window* pParent)
, nSelItem(0)
, bCusEnable(false)
{
- strUnit = new OUString[9];
}
void LineWidthValueSet::Resize()
@@ -47,16 +46,12 @@ LineWidthValueSet::~LineWidthValueSet()
void LineWidthValueSet::dispose()
{
pVDev.disposeAndClear();
- delete[] strUnit;
ValueSet::dispose();
}
-void LineWidthValueSet::SetUnit(OUString const * str)
+void LineWidthValueSet::SetUnit(std::array<OUString,9> const & strUnits)
{
- for(int i = 0; i < 9; i++)
- {
- strUnit[i] = str[i];
- }
+ maStrUnits = strUnits;
}
void LineWidthValueSet::SetSelItem(sal_uInt16 nSel)
@@ -123,7 +118,7 @@ void LineWidthValueSet::UserDraw( const UserDrawEvent& rUDEvt )
aFont.SetColor(GetSettings().GetStyleSettings().GetDisableColor());
pDev->SetFont(aFont);
- pDev->DrawText(aStrRect, strUnit[ nItemId - 1 ], DrawTextFlags::EndEllipsis);
+ pDev->DrawText(aStrRect, maStrUnits[ nItemId - 1 ], DrawTextFlags::EndEllipsis);
}
else
{
@@ -148,7 +143,7 @@ void LineWidthValueSet::UserDraw( const UserDrawEvent& rUDEvt )
aFont.SetColor(GetSettings().GetStyleSettings().GetFieldTextColor());
pDev->SetFont(aFont);
Point aStart(aBLPos.X() + nRectWidth * 7 / 9 , aBLPos.Y() + nRectHeight/6);
- pDev->DrawText(aStart, strUnit[ nItemId - 1 ]); //can't set DrawTextFlags::EndEllipsis here ,or the text will disappear
+ pDev->DrawText(aStart, maStrUnits[ nItemId - 1 ]); //can't set DrawTextFlags::EndEllipsis here ,or the text will disappear
//draw line
if( nSelItem == nItemId )
diff --git a/svx/source/sidebar/line/LineWidthValueSet.hxx b/svx/source/sidebar/line/LineWidthValueSet.hxx
index 0738627d8bfa..abc200b64e3a 100644
--- a/svx/source/sidebar/line/LineWidthValueSet.hxx
+++ b/svx/source/sidebar/line/LineWidthValueSet.hxx
@@ -21,6 +21,7 @@
#include <svtools/valueset.hxx>
#include <vcl/image.hxx>
+#include <array>
namespace svx { namespace sidebar {
@@ -31,7 +32,7 @@ public:
virtual ~LineWidthValueSet() override;
virtual void dispose() override;
- void SetUnit(OUString const * str);
+ void SetUnit(std::array<OUString,9> const & strUnits);
void SetSelItem(sal_uInt16 nSel);
sal_uInt16 GetSelItem() { return nSelItem;}
void SetImage(const Image& img);
@@ -44,7 +45,7 @@ public:
private:
VclPtr<VirtualDevice> pVDev;
sal_uInt16 nSelItem;
- OUString* strUnit;
+ std::array<OUString,9> maStrUnits;
Image imgCus;
bool bCusEnable;
};