include/svx/dlgctrl.hxx | 3 +- include/svx/sidebar/LineWidthPopup.hxx | 3 +- svx/source/dialog/dlgctrl.cxx | 9 ++---- svx/source/sidebar/line/LineWidthPopup.cxx | 36 +++++++++++--------------- svx/source/sidebar/line/LineWidthValueSet.cxx | 13 ++------- svx/source/sidebar/line/LineWidthValueSet.hxx | 5 ++- 6 files changed, 31 insertions(+), 38 deletions(-)
New commits: commit 514d7d41ae867bedcdf3df7831a69e7a66e94a78 Author: Noel Grandin <noel.gran...@collabora.co.uk> Date: Thu May 31 10:49:18 2018 +0200 loplugin:useuniqueptr in SvxRectCtl Change-Id: I99b95cec1985ea5b89d705df1a22a95b2b072008 Reviewed-on: https://gerrit.libreoffice.org/55228 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/include/svx/dlgctrl.hxx b/include/svx/dlgctrl.hxx index d8be686c2bea..9001543a0013 100644 --- a/include/svx/dlgctrl.hxx +++ b/include/svx/dlgctrl.hxx @@ -29,6 +29,7 @@ #include <svx/xtable.hxx> #include <rtl/ref.hxx> #include <o3tl/typed_flags_set.hxx> +#include <memory> #include <array> class XOBitmap; @@ -97,7 +98,7 @@ protected: Point aPtLB, aPtMB, aPtRB; Point aPtNew; RectPoint eRP, eDefRP; - BitmapEx* pBitmap; + std::unique_ptr<BitmapEx> pBitmap; CTL_STATE m_nState; bool mbUpdateForeground : 1; diff --git a/svx/source/dialog/dlgctrl.cxx b/svx/source/dialog/dlgctrl.cxx index b6d9f52709ad..5330c2ad6841 100644 --- a/svx/source/dialog/dlgctrl.cxx +++ b/svx/source/dialog/dlgctrl.cxx @@ -96,7 +96,7 @@ SvxRectCtl::~SvxRectCtl() void SvxRectCtl::dispose() { - delete pBitmap; + pBitmap.reset(); pAccContext.clear(); Control::dispose(); @@ -133,12 +133,12 @@ void SvxRectCtl::Resize_Impl() void SvxRectCtl::InitRectBitmap() { - delete pBitmap; + pBitmap.reset(); const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings(); svtools::ColorConfig aColorConfig; - pBitmap = new BitmapEx(RID_SVXCTRL_RECTBTNS); + pBitmap.reset(new BitmapEx(RID_SVXCTRL_RECTBTNS)); // set bitmap-colors Color aColorAry1[7]; @@ -183,8 +183,7 @@ void SvxRectCtl::MarkToResetSettings(bool bUpdateForeground, bool bUpdateBackgro { mbUpdateForeground = bUpdateForeground; mbUpdateBackground = bUpdateBackground; - delete pBitmap; - pBitmap = nullptr; // forces new creating of bitmap + pBitmap.reset(); // forces new creating of bitmap } void SvxRectCtl::InitSettings(vcl::RenderContext& rRenderContext) commit 6798473388f9a4b9f2d1c64e89d540d7e15e3584 Author: Noel Grandin <noel.gran...@collabora.co.uk> Date: Thu May 31 13:15:18 2018 +0200 loplugin:useuniqueptr in LineWidthPopup and LineWidthValueSet Change-Id: Ia60c396fd4f9fda7c5a2fc6bef4a2a2be01d8bcf Reviewed-on: https://gerrit.libreoffice.org/55233 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/include/svx/sidebar/LineWidthPopup.hxx b/include/svx/sidebar/LineWidthPopup.hxx index 4f4823e0abe7..a6b5713ef6f7 100644 --- a/include/svx/sidebar/LineWidthPopup.hxx +++ b/include/svx/sidebar/LineWidthPopup.hxx @@ -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; 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; }; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits