summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVasily Melenchuk <vasily.melenchuk@cib.de>2021-04-27 13:34:23 +0300
committerThorsten Behrens <thorsten.behrens@allotropia.de>2021-12-05 12:02:58 +0100
commit823c717cdc9b6f7af4f21d1cd4b3939429b64427 (patch)
tree03086e6d8d75d409f5b6ece6fe8d89f0b57ba2fc
parenttdf#145062 sw: deal with failing insertion of field in SwWrtShell (diff)
downloadcore-823c717cdc9b6f7af4f21d1cd4b3939429b64427.tar.gz
core-823c717cdc9b6f7af4f21d1cd4b3939429b64427.zip
tdf#48622 add border line thickness predefined values in UI
According to multiple reports border line width selection will be more intuitive with some predefined values. Here is an implementation of this proposal: line width can be selected from combobox from predefined values (thin, medium, thick and custom). Classical spinner is right now hidden unless custom line width is selected. Change-Id: I87a6237335b79a5f5b63e109360e1ea8f12ae071 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114709 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt <samuel.mehrbrodt@allotropia.de> (cherry picked from commit 089c7d05fde13251eb8cd8daaf7627b6bb0072f9) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126055 Tested-by: Thorsten Behrens <thorsten.behrens@allotropia.de> Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de>
-rw-r--r--cui/source/inc/border.hxx6
-rw-r--r--cui/source/tabpages/border.cxx48
-rw-r--r--cui/uiconfig/ui/borderpage.ui43
3 files changed, 84 insertions, 13 deletions
diff --git a/cui/source/inc/border.hxx b/cui/source/inc/border.hxx
index a138620017e1..6a56f02a1296 100644
--- a/cui/source/inc/border.hxx
+++ b/cui/source/inc/border.hxx
@@ -77,6 +77,7 @@ private:
class SvxBorderTabPage : public SfxTabPage
{
static const sal_uInt16 pRanges[];
+ static const std::vector<int> m_aLineWidths;
public:
SvxBorderTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rCoreAttrs);
@@ -128,6 +129,7 @@ private:
std::unique_ptr<SvtLineListBox> m_xLbLineStyle;
std::unique_ptr<ColorListBox> m_xLbLineColor;
+ std::unique_ptr<weld::ComboBox> m_xLineWidthLB;
std::unique_ptr<weld::MetricSpinButton> m_xLineWidthMF;
std::unique_ptr<weld::Container> m_xSpacingFrame;
@@ -165,9 +167,10 @@ private:
DECL_LINK(SelSdwHdl_Impl, SvtValueSet*, void);
DECL_LINK(LinesChanged_Impl, LinkParamNone*, void);
DECL_LINK(ModifyDistanceHdl_Impl, weld::MetricSpinButton&, void);
- DECL_LINK(ModifyWidthHdl_Impl, weld::MetricSpinButton&, void);
DECL_LINK(SyncHdl_Impl, weld::ToggleButton&, void);
DECL_LINK(RemoveAdjacentCellBorderHdl_Impl, weld::ToggleButton&, void);
+ DECL_LINK(ModifyWidthLBHdl_Impl, weld::ComboBox&, void);
+ DECL_LINK(ModifyWidthMFHdl_Impl, weld::MetricSpinButton&, void);
sal_uInt16 GetPresetImageId(sal_uInt16 nValueSetIdx) const;
const char* GetPresetStringId(sal_uInt16 nValueSetIdx) const;
@@ -175,6 +178,7 @@ private:
void FillPresetVS();
void FillShadowVS();
void FillValueSets();
+ void SetLineWidth(sal_Int64 nWidth);
// Filler
void FillLineListBox_Impl();
diff --git a/cui/source/tabpages/border.cxx b/cui/source/tabpages/border.cxx
index 5ded87ea6659..f00bcac95b82 100644
--- a/cui/source/tabpages/border.cxx
+++ b/cui/source/tabpages/border.cxx
@@ -74,6 +74,8 @@ const sal_uInt16 SvxBorderTabPage::pRanges[] =
0
};
+const std::vector<int> SvxBorderTabPage::m_aLineWidths = { 75, 200, 400, -1 };
+
static void lcl_SetDecimalDigitsTo1(weld::MetricSpinButton& rField)
{
auto nMin = rField.denormalize(rField.get_min(FieldUnit::TWIP));
@@ -288,6 +290,7 @@ SvxBorderTabPage::SvxBorderTabPage(weld::Container* pPage, weld::DialogControlle
, m_xFrameSelWin(new weld::CustomWeld(*m_xBuilder, "framesel", m_aFrameSel))
, m_xLbLineStyle(new SvtLineListBox(m_xBuilder->weld_menu_button("linestylelb")))
, m_xLbLineColor(new ColorListBox(m_xBuilder->weld_menu_button("linecolorlb"), pController->getDialog()))
+ , m_xLineWidthLB(m_xBuilder->weld_combo_box("linewidthlb"))
, m_xLineWidthMF(m_xBuilder->weld_metric_spin_button("linewidthmf", FieldUnit::POINT))
, m_xSpacingFrame(m_xBuilder->weld_container("spacing"))
, m_xLeftFT(m_xBuilder->weld_label("leftft"))
@@ -411,7 +414,7 @@ SvxBorderTabPage::SvxBorderTabPage(weld::Container* pPage, weld::DialogControlle
{
// The caller specifies default line width. Honor it.
const SfxInt64Item* p = static_cast<const SfxInt64Item*>(pItem);
- m_xLineWidthMF->set_value(p->GetValue(), FieldUnit::POINT);
+ SetLineWidth(p->GetValue());
}
// set metric
@@ -511,13 +514,17 @@ SvxBorderTabPage::SvxBorderTabPage(weld::Container* pPage, weld::DialogControlle
m_aFrameSel.SetSelectHdl(LINK(this, SvxBorderTabPage, LinesChanged_Impl));
m_xLbLineStyle->SetSelectHdl( LINK( this, SvxBorderTabPage, SelStyleHdl_Impl ) );
m_xLbLineColor->SetSelectHdl( LINK( this, SvxBorderTabPage, SelColHdl_Impl ) );
- m_xLineWidthMF->connect_value_changed( LINK( this, SvxBorderTabPage, ModifyWidthHdl_Impl ) );
+ m_xLineWidthLB->connect_changed(LINK(this, SvxBorderTabPage, ModifyWidthLBHdl_Impl));
+ m_xLineWidthMF->connect_value_changed(LINK(this, SvxBorderTabPage, ModifyWidthMFHdl_Impl));
m_xWndPresets->SetSelectHdl( LINK( this, SvxBorderTabPage, SelPreHdl_Impl ) );
m_xWndShadows->SetSelectHdl( LINK( this, SvxBorderTabPage, SelSdwHdl_Impl ) );
FillValueSets();
FillLineListBox_Impl();
+ // Reapply line width: probably one of prefefined values should be selected
+ SetLineWidth(m_xLineWidthMF->get_value(FieldUnit::NONE));
+
// connections
if (rCoreAttrs.HasItem(GetWhich(SID_ATTR_PARA_GRABBAG), &pItem))
{
@@ -774,7 +781,7 @@ void SvxBorderTabPage::Reset( const SfxItemSet* rSet )
sal_Int64 nWidthPt = static_cast<sal_Int64>(MetricField::ConvertDoubleValue(
sal_Int64( nWidth ), m_xLineWidthMF->get_digits(),
MapUnit::MapTwip, FieldUnit::POINT ));
- m_xLineWidthMF->set_value(nWidthPt, FieldUnit::POINT);
+ SetLineWidth(nWidthPt);
m_xLbLineStyle->SetWidth(nWidth);
// then set the style
@@ -1192,7 +1199,17 @@ IMPL_LINK(SvxBorderTabPage, SelColHdl_Impl, ColorListBox&, rColorBox, void)
m_aFrameSel.SetColorToSelection(aColor);
}
-IMPL_LINK_NOARG(SvxBorderTabPage, ModifyWidthHdl_Impl, weld::MetricSpinButton&, void)
+IMPL_LINK_NOARG(SvxBorderTabPage, ModifyWidthLBHdl_Impl, weld::ComboBox&, void)
+{
+ sal_Int32 nPos = m_xLineWidthLB->get_active();
+
+ SetLineWidth(m_aLineWidths[nPos]);
+
+ // Call the spinner handler to trigger all related modifications
+ ModifyWidthMFHdl_Impl(*m_xLineWidthMF);
+}
+
+IMPL_LINK_NOARG(SvxBorderTabPage, ModifyWidthMFHdl_Impl, weld::MetricSpinButton&, void)
{
sal_Int64 nVal = m_xLineWidthMF->get_value(FieldUnit::NONE);
nVal = static_cast<sal_Int64>(MetricField::ConvertDoubleValue(
@@ -1229,7 +1246,7 @@ IMPL_LINK_NOARG(SvxBorderTabPage, SelStyleHdl_Impl, SvtLineListBox&, void)
m_xLineWidthMF->get_digits(),
MapUnit::MapTwip,
FieldUnit::POINT));
- m_xLineWidthMF->set_value(nNewWidthPt, FieldUnit::POINT);
+ SetLineWidth(nNewWidthPt);
}
// set value inside style box
@@ -1356,6 +1373,27 @@ void SvxBorderTabPage::FillValueSets()
FillShadowVS();
}
+void SvxBorderTabPage::SetLineWidth( sal_Int64 nWidth )
+{
+ if ( nWidth >= 0 )
+ m_xLineWidthMF->set_value( nWidth, FieldUnit::POINT );
+
+ auto it = std::find_if( m_aLineWidths.begin(), m_aLineWidths.end(),
+ [nWidth](const int val) -> bool { return val == nWidth; } );
+
+ if ( it != m_aLineWidths.end() && *it >= 0 )
+ {
+ // Select predefined value in combobox
+ m_xLineWidthMF->hide();
+ m_xLineWidthLB->set_active(std::distance(m_aLineWidths.begin(), it));
+ }
+ else
+ {
+ // This is not one of predefined values. Show spinner
+ m_xLineWidthLB->set_active(m_aLineWidths.size()-1);
+ m_xLineWidthMF->show();
+ }
+}
static Color lcl_mediumColor( Color aMain, Color /*aDefault*/ )
{
diff --git a/cui/uiconfig/ui/borderpage.ui b/cui/uiconfig/ui/borderpage.ui
index 0f7c6f625985..d26ecdd339e7 100644
--- a/cui/uiconfig/ui/borderpage.ui
+++ b/cui/uiconfig/ui/borderpage.ui
@@ -258,14 +258,43 @@
</packing>
</child>
<child>
- <object class="GtkSpinButton" id="linewidthmf">
+ <object class="GtkGrid" id="gridlinewidth">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="halign">start</property>
- <property name="activates_default">True</property>
- <property name="adjustment">adjustment1</property>
- <property name="digits">2</property>
- <property name="value">0.05</property>
+ <property name="can_focus">False</property>
+ <property name="row_spacing">0</property>
+ <property name="column_spacing">6</property>
+ <property name="margin-start">0</property>
+ <property name="margin-top">0</property>
+ <child>
+ <object class="GtkComboBoxText" id="linewidthlb">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <items>
+ <item translatable="yes" context="borderpage|linewidthlb">Thin</item>
+ <item translatable="yes" context="borderpage|linewidthlb">Medium</item>
+ <item translatable="yes" context="borderpage|linewidthlb">Thick</item>
+ <item translatable="yes" context="borderpage|linewidthlb">Custom</item>
+ </items>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSpinButton" id="linewidthmf">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="halign">start</property>
+ <property name="activates_default">True</property>
+ <property name="adjustment">adjustment1</property>
+ <property name="digits">2</property>
+ <property name="truncate-multiline">True</property>
+ <property name="value">0.05</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="left_attach">1</property>