Kaydet (Commit) 67984733 authored tarafından Noel Grandin's avatar Noel Grandin

loplugin:useuniqueptr in LineWidthPopup and LineWidthValueSet

Change-Id: Ia60c396fd4f9fda7c5a2fc6bef4a2a2be01d8bcf
Reviewed-on: https://gerrit.libreoffice.org/55233Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 100b6a22
......@@ -22,6 +22,7 @@
#include <svl/poolitem.hxx>
#include <vcl/floatwin.hxx>
#include <vcl/layout.hxx>
#include <array>
class Edit;
class MetricField;
......@@ -43,7 +44,7 @@ public:
private:
LinePropertyPanelBase& m_rParent;
OUString* m_pStr;
std::array<OUString,9> maStrUnits;
OUString m_sPt;
MapUnit m_eMapUnit;
bool m_bVSFocus;
......
......@@ -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;
......
......@@ -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 )
......
......@@ -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;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment