summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBalazs Varga <balazs.varga.extern@allotropia.de>2022-07-25 18:03:49 +0200
committerBalazs Varga <balazs.varga.extern@allotropia.de>2022-07-29 08:53:49 +0200
commitfe2d59a0730e60c0196baa46af12440afd343878 (patch)
treee627745273cc638e5f855b650067f485dcaddef7
parent4f61276dae10fdaf2ed33ab23d98adbe311cb7ee (diff)
tdf#150100 sc import and UI: fix double cell border dialog
Hide "Hairline (0.05pt)", "Very thin (0.5pt)" and "Thin (0.75pt)" predefined border types for Double cell borders, because it has a minimum thickness 1.1pt, which means, we cannot allow to select them. Also setting the Medium (1.5pt) predefined thickness to the border width for Double borders as the thinnest possible predefined value. TODO: tdf#146466: Inconsistent choices of borders between toolbar and sidebar Change-Id: I46ccb206835a34a6dfaa39e63e614bb01bc6b02e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137441 Tested-by: Jenkins Reviewed-by: Balazs Varga <balazs.varga.extern@allotropia.de>
-rw-r--r--cui/source/inc/border.hxx2
-rw-r--r--cui/source/tabpages/border.cxx55
-rw-r--r--cui/uiconfig/ui/borderpage.ui14
-rw-r--r--include/vcl/weld.hxx20
-rw-r--r--sc/qa/uitest/calc_tests/formatCells.py9
5 files changed, 83 insertions, 17 deletions
diff --git a/cui/source/inc/border.hxx b/cui/source/inc/border.hxx
index 2a3d14ed5062..586b05f9410b 100644
--- a/cui/source/inc/border.hxx
+++ b/cui/source/inc/border.hxx
@@ -178,7 +178,7 @@ private:
void FillPresetVS();
void FillShadowVS();
void FillValueSets();
- void SetLineWidth(sal_Int64 nWidth);
+ void SetLineWidth(sal_Int64 nWidth, sal_Int32 nRemovedType = 0);
// Filler
void FillLineListBox_Impl();
diff --git a/cui/source/tabpages/border.cxx b/cui/source/tabpages/border.cxx
index 683dd7713c37..38099a4599c8 100644
--- a/cui/source/tabpages/border.cxx
+++ b/cui/source/tabpages/border.cxx
@@ -1242,8 +1242,12 @@ IMPL_LINK(SvxBorderTabPage, SelColHdl_Impl, ColorListBox&, rColorBox, void)
IMPL_LINK_NOARG(SvxBorderTabPage, ModifyWidthLBHdl_Impl, weld::ComboBox&, void)
{
sal_Int32 nPos = m_xLineWidthLB->get_active();
+ sal_Int32 nRemovedType = 0;
+ if (m_xLineWidthLB->get_values_changed_from_saved()) {
+ nRemovedType = m_aLineWidths.size() - m_xLineWidthLB->get_count();
+ }
- SetLineWidth(m_aLineWidths[nPos]);
+ SetLineWidth(m_aLineWidths[nPos + nRemovedType], nRemovedType);
// Call the spinner handler to trigger all related modifications
ModifyWidthMFHdl_Impl(*m_xLineWidthMF);
@@ -1252,6 +1256,13 @@ IMPL_LINK_NOARG(SvxBorderTabPage, ModifyWidthLBHdl_Impl, weld::ComboBox&, void)
IMPL_LINK_NOARG(SvxBorderTabPage, ModifyWidthMFHdl_Impl, weld::MetricSpinButton&, void)
{
sal_Int64 nVal = m_xLineWidthMF->get_value(FieldUnit::NONE);
+
+ // for DOUBLE_THIN line style we cannot allow thinner line width then 1.10pt
+ if (m_xLbLineStyle->GetSelectEntryStyle() == SvxBorderLineStyle::DOUBLE_THIN)
+ m_xLineWidthMF->set_min(110, FieldUnit::NONE);
+ else
+ m_xLineWidthMF->set_min(5, FieldUnit::NONE);
+
nVal = static_cast<sal_Int64>(vcl::ConvertDoubleValue(
nVal,
m_xLineWidthMF->get_digits(),
@@ -1265,6 +1276,13 @@ IMPL_LINK_NOARG(SvxBorderTabPage, ModifyWidthMFHdl_Impl, weld::MetricSpinButton&
IMPL_LINK_NOARG(SvxBorderTabPage, SelStyleHdl_Impl, SvtLineListBox&, void)
{
sal_Int64 nOldWidth = m_xLineWidthMF->get_value(FieldUnit::NONE);
+
+ // for DOUBLE_THIN line style we cannot allow thinner line width then 1.10pt
+ if (m_xLbLineStyle->GetSelectEntryStyle() == SvxBorderLineStyle::DOUBLE_THIN)
+ m_xLineWidthMF->set_min(110, FieldUnit::NONE);
+ else
+ m_xLineWidthMF->set_min(5, FieldUnit::NONE);
+
nOldWidth = static_cast<sal_Int64>(vcl::ConvertDoubleValue(
nOldWidth,
m_xLineWidthMF->get_digits(),
@@ -1276,7 +1294,14 @@ IMPL_LINK_NOARG(SvxBorderTabPage, SelStyleHdl_Impl, SvtLineListBox&, void)
// auto change line-width if it doesn't correspond to minimal value
// let's change only in case when user has not changed the line-width into some custom value
- const sal_Int64 nNewWidth = (nOldMinWidth == nOldWidth)? nNewMinWidth : nOldWidth;
+ sal_Int64 nNewWidth = (nOldMinWidth == nOldWidth) ? nNewMinWidth : nOldWidth;
+
+ // if we had selected a predefined border width under SvxBorderLineWidth::Medium set the Medium as default
+ // otherwise if we had a cusom border width under 1.10pt then set the spinner to the maximum allowed value for double border styles
+ bool bNewDoubleHairline = m_xLbLineStyle->GetSelectEntryStyle() == SvxBorderLineStyle::DOUBLE_THIN && !m_xLineWidthMF->get_visible() &&
+ (nOldWidth == SvxBorderLineWidth::Hairline || nOldWidth == SvxBorderLineWidth::VeryThin || nOldWidth == SvxBorderLineWidth::Thin);
+ if (bNewDoubleHairline && nNewWidth < SvxBorderLineWidth::Medium)
+ nNewWidth = SvxBorderLineWidth::Medium;
// set value inside edit box
if (nOldWidth != nNewWidth)
@@ -1289,6 +1314,26 @@ IMPL_LINK_NOARG(SvxBorderTabPage, SelStyleHdl_Impl, SvtLineListBox&, void)
SetLineWidth(nNewWidthPt);
}
+ if (m_xLbLineStyle->GetSelectEntryStyle() == SvxBorderLineStyle::DOUBLE_THIN)
+ {
+ for (size_t i = 0; i < 3; i++)
+ {
+ m_xLineWidthLB->save_values_by_id(OUString::number(i));
+ m_xLineWidthLB->remove_id(OUString::number(i));
+ }
+ if (m_xLineWidthLB->get_active_id().isEmpty())
+ m_xLineWidthLB->set_active_id("3");
+ }
+ else
+ {
+ if (m_xLineWidthLB->get_values_changed_from_saved())
+ {
+ for (size_t i = 0; i < 3; i++)
+ m_xLineWidthLB->append(i, OUString::number(i), m_xLineWidthLB->get_saved_values(i));
+ m_xLineWidthLB->removeSavedValues();
+ }
+ }
+
// set value inside style box
m_aFrameSel.SetStyleToSelection( nNewWidth,
m_xLbLineStyle->GetSelectEntryStyle() );
@@ -1413,7 +1458,7 @@ void SvxBorderTabPage::FillValueSets()
FillShadowVS();
}
-void SvxBorderTabPage::SetLineWidth( sal_Int64 nWidth )
+void SvxBorderTabPage::SetLineWidth( sal_Int64 nWidth, sal_Int32 nRemovedType )
{
if ( nWidth >= 0 )
m_xLineWidthMF->set_value( nWidth, FieldUnit::POINT );
@@ -1425,12 +1470,12 @@ void SvxBorderTabPage::SetLineWidth( sal_Int64 nWidth )
{
// Select predefined value in combobox
m_xLineWidthMF->hide();
- m_xLineWidthLB->set_active(std::distance(m_aLineWidths.begin(), it));
+ m_xLineWidthLB->set_active(std::distance(m_aLineWidths.begin(), it) - nRemovedType);
}
else
{
// This is not one of predefined values. Show spinner
- m_xLineWidthLB->set_active(m_aLineWidths.size()-1);
+ m_xLineWidthLB->set_active(m_aLineWidths.size() - nRemovedType -1);
m_xLineWidthMF->show();
}
}
diff --git a/cui/uiconfig/ui/borderpage.ui b/cui/uiconfig/ui/borderpage.ui
index 58d86f023745..af57dbcb09a0 100644
--- a/cui/uiconfig/ui/borderpage.ui
+++ b/cui/uiconfig/ui/borderpage.ui
@@ -280,13 +280,13 @@
<property name="can-focus">False</property>
<property name="hexpand">False</property>
<items>
- <item translatable="yes" context="borderpage|linewidthlb">Hairline (0.05pt)</item>
- <item translatable="yes" context="borderpage|linewidthlb">Very thin (0.5pt)</item>
- <item translatable="yes" context="borderpage|linewidthlb">Thin (0.75pt)</item>
- <item translatable="yes" context="borderpage|linewidthlb">Medium (1.5pt)</item>
- <item translatable="yes" context="borderpage|linewidthlb">Thick (2.25pt)</item>
- <item translatable="yes" context="borderpage|linewidthlb">Extra thick (4.5pt)</item>
- <item translatable="yes" context="borderpage|linewidthlb">Custom</item>
+ <item id="0" translatable="yes" context="borderpage|linewidthlb">Hairline (0.05pt)</item>
+ <item id="1" translatable="yes" context="borderpage|linewidthlb">Very thin (0.5pt)</item>
+ <item id="2" translatable="yes" context="borderpage|linewidthlb">Thin (0.75pt)</item>
+ <item id="3" translatable="yes" context="borderpage|linewidthlb">Medium (1.5pt)</item>
+ <item id="4" translatable="yes" context="borderpage|linewidthlb">Thick (2.25pt)</item>
+ <item id="5" translatable="yes" context="borderpage|linewidthlb">Extra thick (4.5pt)</item>
+ <item id="6" translatable="yes" context="borderpage|linewidthlb">Custom</item>
</items>
<accessibility>
<relation type="labelled-by" target="label16"/>
diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx
index 3d275fe75967..37d65d83cb4e 100644
--- a/include/vcl/weld.hxx
+++ b/include/vcl/weld.hxx
@@ -698,6 +698,7 @@ class VCL_DLLPUBLIC ComboBox : virtual public Widget
{
private:
OUString m_sSavedValue;
+ std::vector<OUString> m_aSavedValues;
public:
// OUString is the id of the row, it may be null to measure the height of a generic line
@@ -749,6 +750,10 @@ public:
{
insert(-1, rStr, &rId, nullptr, &rImage);
}
+ void append(int pos, const OUString& rId, const OUString& rStr)
+ {
+ insert(pos, rStr, &rId, nullptr, nullptr);
+ }
virtual void insert_separator(int pos, const OUString& rId) = 0;
void append_separator(const OUString& rId) { insert_separator(-1, rId); }
@@ -825,8 +830,23 @@ public:
void connect_entry_activate(const Link<ComboBox&, bool>& rLink) { m_aEntryActivateHdl = rLink; }
void save_value() { m_sSavedValue = get_active_text(); }
+
+ void save_values_by_id(const OUString& rId)
+ {
+ m_aSavedValues.push_back(get_text(find_id(rId)));
+ }
+
OUString const& get_saved_value() const { return m_sSavedValue; }
+ OUString const& get_saved_values(int pos) const { return m_aSavedValues[pos]; }
bool get_value_changed_from_saved() const { return m_sSavedValue != get_active_text(); }
+ bool get_values_changed_from_saved() const
+ {
+ return !m_aSavedValues.empty()
+ && std::find(m_aSavedValues.begin(), m_aSavedValues.end(), get_active_text())
+ == m_aSavedValues.end();
+ }
+
+ void removeSavedValues() { m_aSavedValues.clear(); }
// for custom rendering a row
void connect_custom_get_size(const Link<vcl::RenderContext&, Size>& rLink)
diff --git a/sc/qa/uitest/calc_tests/formatCells.py b/sc/qa/uitest/calc_tests/formatCells.py
index e258721fbb5c..7397a9b9c76d 100644
--- a/sc/qa/uitest/calc_tests/formatCells.py
+++ b/sc/qa/uitest/calc_tests/formatCells.py
@@ -270,24 +270,25 @@ class formatCell(UITestCase):
# set line style to "double" (minimal width is taken)
xLineSet.executeAction("CHOOSE", mkPropertyValues({"POS": '16'}))
widthVal = get_state_as_dict(linewidthmf)["Text"]
- self.assertEqual(widthVal, '0.75 pt')
+ # minimim predefined width is Medium (1.50 pt)
+ self.assertEqual(widthVal, '1.50 pt')
# set line style to "solid"
xLineSet.executeAction("CHOOSE", mkPropertyValues({"POS": "1"}))
widthVal = get_state_as_dict(linewidthmf)["Text"]
- self.assertEqual(widthVal, '0.75 pt')
+ self.assertEqual(widthVal, '1.50 pt')
# make custom line width
linewidthmf.executeAction("UP", tuple())
linewidthmf.executeAction("UP", tuple())
linewidthmf.executeAction("UP", tuple())
widthVal = get_state_as_dict(linewidthmf)["Text"]
- self.assertEqual(widthVal, '1.50 pt')
+ self.assertEqual(widthVal, '2.25 pt')
# set line style to "double" (minimal width is not taken)
xLineSet.executeAction("CHOOSE", mkPropertyValues({"POS": "8"}))
widthVal = get_state_as_dict(linewidthmf)["Text"]
- self.assertEqual(widthVal, '1.50 pt')
+ self.assertEqual(widthVal, '2.25 pt')