Resolves: tdf#152593 reuse Line Style preview code for Line Width preview
Change-Id: I842b3bfaeb63978377ebb3edaef4dfd94ec296a9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144651
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/include/svx/sidebar/LinePropertyPanelBase.hxx b/include/svx/sidebar/LinePropertyPanelBase.hxx
index e94612f..f5eef67 100644
--- a/include/svx/sidebar/LinePropertyPanelBase.hxx
+++ b/include/svx/sidebar/LinePropertyPanelBase.hxx
@@ -119,7 +119,7 @@ private:
OUString maIMGNone;
// multi-images
OUString maIMGWidthIcon[8];
BitmapEx maIMGWidthIcon[8];
bool mbWidthValuable : 1;
bool mbArrowSupported;
diff --git a/include/svx/xtable.hxx b/include/svx/xtable.hxx
index 96ad6ed..695064d 100644
--- a/include/svx/xtable.hxx
+++ b/include/svx/xtable.hxx
@@ -273,7 +273,7 @@ private:
OUString maStringSolidLine;
OUString maStringNoLine;
static BitmapEx ImpCreateBitmapForXDash(const XDash* pDash);
static double ImpGetDefaultLineThickness();
virtual BitmapEx CreateBitmapForUI(tools::Long nIndex) override;
public:
@@ -291,6 +291,8 @@ public:
// using GetUiBitmap for existing entries.
BitmapEx const & GetBitmapForUISolidLine() const;
static BitmapEx CreateBitmapForXDash(const XDash* pDash, double fLineThickness);
// Special calls to get the translated strings for the UI entry for no
// line style (XLINE_NONE) and solid line style (XLINE_SOLID) for dialogs
OUString const & GetStringForUiSolidLine() const;
diff --git a/svx/inc/bitmaps.hlst b/svx/inc/bitmaps.hlst
index 4b2fcf0..1dd65b8 100644
--- a/svx/inc/bitmaps.hlst
+++ b/svx/inc/bitmaps.hlst
@@ -125,14 +125,6 @@ inline constexpr OUStringLiteral RID_SVXBMP_GALLERY_SOUND_6 = u"svx/res/galsnd6.
inline constexpr OUStringLiteral RID_SVXBMP_GALLERY_SOUND_7 = u"svx/res/galsnd7.png";
inline constexpr OUStringLiteral BMP_NONE_ICON = u"svx/res/symphony/blank.png";
inline constexpr OUStringLiteral BMP_WIDTH1_ICON = u"svx/res/symphony/width1.png";
inline constexpr OUStringLiteral BMP_WIDTH2_ICON = u"svx/res/symphony/width2.png";
inline constexpr OUStringLiteral BMP_WIDTH3_ICON = u"svx/res/symphony/width3.png";
inline constexpr OUStringLiteral BMP_WIDTH4_ICON = u"svx/res/symphony/width4.png";
inline constexpr OUStringLiteral BMP_WIDTH5_ICON = u"svx/res/symphony/width5.png";
inline constexpr OUStringLiteral BMP_WIDTH6_ICON = u"svx/res/symphony/width6.png";
inline constexpr OUStringLiteral BMP_WIDTH7_ICON = u"svx/res/symphony/width7.png";
inline constexpr OUStringLiteral BMP_WIDTH8_ICON = u"svx/res/symphony/width8.png";
inline constexpr OUStringLiteral RID_SVXBMP_WIDTH_CUSTOM = u"svx/res/symphony/last_custom_common.png";
inline constexpr OUStringLiteral RID_SVXBMP_WIDTH_CUSTOM_GRAY = u"svx/res/symphony/last_custom_common_grey.png";
diff --git a/svx/source/sidebar/line/LinePropertyPanelBase.cxx b/svx/source/sidebar/line/LinePropertyPanelBase.cxx
index d04b161..67135a4 100644
--- a/svx/source/sidebar/line/LinePropertyPanelBase.cxx
+++ b/svx/source/sidebar/line/LinePropertyPanelBase.cxx
@@ -26,6 +26,7 @@
#include <svx/xlntrit.hxx>
#include <svx/xlncapit.hxx>
#include <svx/xlinjoit.hxx>
#include <svx/xtable.hxx>
#include <bitmaps.hlst>
using namespace css;
@@ -118,16 +119,17 @@ void LinePropertyPanelBase::Initialize()
{
mxTBWidth->set_item_popover(SELECTWIDTH, mxLineWidthPopup->getTopLevel());
maIMGWidthIcon[0] = BMP_WIDTH1_ICON;
maIMGWidthIcon[1] = BMP_WIDTH2_ICON;
maIMGWidthIcon[2] = BMP_WIDTH3_ICON;
maIMGWidthIcon[3] = BMP_WIDTH4_ICON;
maIMGWidthIcon[4] = BMP_WIDTH5_ICON;
maIMGWidthIcon[5] = BMP_WIDTH6_ICON;
maIMGWidthIcon[6] = BMP_WIDTH7_ICON;
maIMGWidthIcon[7] = BMP_WIDTH8_ICON;
maIMGWidthIcon[0] = XDashList::CreateBitmapForXDash(nullptr, 1);
maIMGWidthIcon[1] = XDashList::CreateBitmapForXDash(nullptr, 2);
maIMGWidthIcon[2] = XDashList::CreateBitmapForXDash(nullptr, 3);
maIMGWidthIcon[3] = XDashList::CreateBitmapForXDash(nullptr, 4);
maIMGWidthIcon[4] = XDashList::CreateBitmapForXDash(nullptr, 5);
maIMGWidthIcon[5] = XDashList::CreateBitmapForXDash(nullptr, 6);
maIMGWidthIcon[6] = XDashList::CreateBitmapForXDash(nullptr, 7);
maIMGWidthIcon[7] = XDashList::CreateBitmapForXDash(nullptr, 8);
mxTBWidth->set_item_icon_name(SELECTWIDTH, maIMGWidthIcon[0]);
Graphic aGraf(maIMGWidthIcon[0]);
mxTBWidth->set_item_image(SELECTWIDTH, aGraf.GetXGraphic());
mxTBWidth->connect_clicked(LINK(this, LinePropertyPanelBase, ToolboxWidthSelectHdl));
mxMFTransparent->connect_value_changed(LINK(this, LinePropertyPanelBase, ChangeTransparentHdl));
@@ -399,7 +401,10 @@ void LinePropertyPanelBase::SetWidthIcon(int n)
if (n == 0)
mxTBWidth->set_item_icon_name(SELECTWIDTH, maIMGNone);
else
mxTBWidth->set_item_icon_name(SELECTWIDTH, maIMGWidthIcon[n-1]);
{
Graphic aGraf(maIMGWidthIcon[n-1]);
mxTBWidth->set_item_image(SELECTWIDTH, aGraf.GetXGraphic());
}
}
void LinePropertyPanelBase::SetWidthIcon()
@@ -412,23 +417,24 @@ void LinePropertyPanelBase::SetWidthIcon()
tools::Long nVal = OutputDevice::LogicToLogic(mnWidthCoreValue * 10, meMapUnit, MapUnit::MapPoint);
Graphic aGraf;
if(nVal <= 6)
mxTBWidth->set_item_icon_name(SELECTWIDTH, maIMGWidthIcon[0]);
aGraf = Graphic(maIMGWidthIcon[0]);
else if (nVal <= 9)
mxTBWidth->set_item_icon_name(SELECTWIDTH, maIMGWidthIcon[1]);
aGraf = Graphic(maIMGWidthIcon[1]);
else if (nVal <= 12)
mxTBWidth->set_item_icon_name(SELECTWIDTH, maIMGWidthIcon[2]);
aGraf = Graphic(maIMGWidthIcon[2]);
else if (nVal <= 19)
mxTBWidth->set_item_icon_name(SELECTWIDTH, maIMGWidthIcon[3]);
aGraf = Graphic(maIMGWidthIcon[3]);
else if (nVal <= 26)
mxTBWidth->set_item_icon_name(SELECTWIDTH, maIMGWidthIcon[4]);
aGraf = Graphic(maIMGWidthIcon[4]);
else if (nVal <= 37)
mxTBWidth->set_item_icon_name(SELECTWIDTH, maIMGWidthIcon[5]);
aGraf = Graphic(maIMGWidthIcon[5]);
else if (nVal <= 52)
mxTBWidth->set_item_icon_name(SELECTWIDTH, maIMGWidthIcon[6]);
aGraf = Graphic(maIMGWidthIcon[6]);
else
mxTBWidth->set_item_icon_name(SELECTWIDTH, maIMGWidthIcon[7]);
aGraf = Graphic(maIMGWidthIcon[7]);
mxTBWidth->set_item_image(SELECTWIDTH, aGraf.GetXGraphic());
}
void LinePropertyPanelBase::SetWidth(tools::Long nWidth)
diff --git a/svx/source/xoutdev/xtabdash.cxx b/svx/source/xoutdev/xtabdash.cxx
index 93543d2..ad6480c 100644
--- a/svx/source/xoutdev/xtabdash.cxx
+++ b/svx/source/xoutdev/xtabdash.cxx
@@ -74,7 +74,12 @@ bool XDashList::Create()
return true;
}
BitmapEx XDashList::ImpCreateBitmapForXDash(const XDash* pDash)
double XDashList::ImpGetDefaultLineThickness()
{
return StyleSettings::GetListBoxPreviewDefaultLineWidth() * 1.1;
}
BitmapEx XDashList::CreateBitmapForXDash(const XDash* pDash, double fLineThickness)
{
const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
const Size& rSize = rStyleSettings.GetListBoxPreviewDefaultPixelSize();
@@ -89,7 +94,7 @@ BitmapEx XDashList::ImpCreateBitmapForXDash(const XDash* pDash)
// prepare LineAttribute
const basegfx::BColor aLineColor(rStyleSettings.GetFieldTextColor().getBColor());
const double fLineWidth(StyleSettings::GetListBoxPreviewDefaultLineWidth() * (nFactor * 1.1));
const double fLineWidth(fLineThickness * nFactor);
const drawinglayer::attribute::LineAttribute aLineAttribute(
aLineColor,
fLineWidth);
@@ -181,14 +186,14 @@ BitmapEx XDashList::CreateBitmapForUI( tools::Long nIndex )
{
const XDash& rDash = GetDash(nIndex)->GetDash();
return ImpCreateBitmapForXDash(&rDash);
return CreateBitmapForXDash(&rDash, ImpGetDefaultLineThickness());
}
BitmapEx const & XDashList::GetBitmapForUISolidLine() const
{
if(maBitmapSolidLine.IsEmpty())
{
const_cast< XDashList* >(this)->maBitmapSolidLine = XDashList::ImpCreateBitmapForXDash(nullptr);
const_cast< XDashList* >(this)->maBitmapSolidLine = XDashList::CreateBitmapForXDash(nullptr, ImpGetDefaultLineThickness());
}
return maBitmapSolidLine;