Related tdf#140762 Add texts for "Border style" toolbar item
Make 'GetLineStyleName' a static method of 'SvtLineListBox'
and use it to retrieve and set the names for the items used
in the "Border Style" dropdown button in Calc's formatting
toolbar.
This ensures that the corresponding names are available as
tooltips and for screen readers.
Change-Id: I6b775e1bcd62deefd8a8a6a778dcee426bf3a1f3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111905
Tested-by: Michael Weghorn <m.weghorn@posteo.de>
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
diff --git a/include/svtools/ctrlbox.hxx b/include/svtools/ctrlbox.hxx
index 43347a1..0aff598 100644
--- a/include/svtools/ctrlbox.hxx
+++ b/include/svtools/ctrlbox.hxx
@@ -207,6 +207,8 @@
SvtLineListBox(std::unique_ptr<weld::MenuButton> pControl);
~SvtLineListBox();
static OUString GetLineStyleName(SvxBorderLineStyle eStyle);
/** Set the width in Twips */
void SetWidth(tools::Long nWidth)
{
diff --git a/svtools/source/control/ctrlbox.cxx b/svtools/source/control/ctrlbox.cxx
index 2f7c3eb..393c743 100644
--- a/svtools/source/control/ctrlbox.cxx
+++ b/svtools/source/control/ctrlbox.cxx
@@ -1403,23 +1403,6 @@
rBmp = aVirDev->GetBitmapEx( Point(), Size( aSize.Width(), n1+nDist+n2 ) );
}
namespace
{
OUString GetLineStyleName(SvxBorderLineStyle eStyle)
{
OUString sRet;
for (sal_uInt32 i = 0; i < SAL_N_ELEMENTS(RID_SVXSTR_BORDERLINE); ++i)
{
if (eStyle == RID_SVXSTR_BORDERLINE[i].second)
{
sRet = SvtResId(RID_SVXSTR_BORDERLINE[i].first);
break;
}
}
return sRet;
}
}
SvtLineListBox::SvtLineListBox(std::unique_ptr<weld::MenuButton> pControl)
: m_xControl(std::move(pControl))
, m_xBuilder(Application::CreateBuilder(m_xControl.get(), "svt/ui/linewindow.ui"))
@@ -1486,6 +1469,20 @@
{
}
OUString SvtLineListBox::GetLineStyleName(SvxBorderLineStyle eStyle)
{
OUString sRet;
for (sal_uInt32 i = 0; i < SAL_N_ELEMENTS(RID_SVXSTR_BORDERLINE); ++i)
{
if (eStyle == RID_SVXSTR_BORDERLINE[i].second)
{
sRet = SvtResId(RID_SVXSTR_BORDERLINE[i].first);
break;
}
}
return sRet;
}
sal_Int32 SvtLineListBox::GetStylePos( sal_Int32 nListPos )
{
sal_Int32 nPos = -1;
diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index e9cb9b1..ab4a7d1 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -738,7 +738,7 @@
GetColorLine2( GetItemCount( ) ),
GetColorDist( GetItemCount( ) ),
pData->GetStyle(), aBmp );
InsertItem(nId, Image(aBmp));
InsertItem(nId, Image(aBmp), SvtLineListBox::GetLineStyleName(pData->GetStyle()));
Size aBmpSize = aBmp.GetSizePixel();
if (aBmpSize.Width() > aSize.Width())
aSize.setWidth(aBmpSize.getWidth());