cui/source/tabpages/border.cxx | 120 +++++++++++++++++++++++++-------- include/svx/frmsel.hxx | 2 sc/qa/uitest/calc_tests/formatCells.py | 53 ++++++++++++++ svx/source/dialog/frmsel.cxx | 5 + 4 files changed, 151 insertions(+), 29 deletions(-)
New commits: commit 63540cbef6484fa9dc017c93676d0b5e85075303 Author: Serge Krot <serge.k...@cib.de> AuthorDate: Tue Oct 27 11:26:55 2020 +0100 Commit: Thorsten Behrens <thorsten.behr...@cib.de> CommitDate: Fri Nov 13 21:29:45 2020 +0100 tdf#137790 calc: Minimal line width for different line styles Change-Id: I4d062f054a5ef6da7ef595190a7b3c6e2a0b191e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104865 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <thorsten.behr...@cib.de> tdf#137790 calc: set minimal line width: unit test Change-Id: Idac7c23e55b3c4ee94790458fca5e7a7a5522098 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105301 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <thorsten.behr...@cib.de> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105409 Tested-by: Thorsten Behrens <thorsten.behr...@cib.de> diff --git a/cui/source/tabpages/border.cxx b/cui/source/tabpages/border.cxx index 84bdcd8f92c1..5ded87ea6659 100644 --- a/cui/source/tabpages/border.cxx +++ b/cui/source/tabpages/border.cxx @@ -81,6 +81,43 @@ static void lcl_SetDecimalDigitsTo1(weld::MetricSpinButton& rField) rField.set_min(rField.normalize(nMin), FieldUnit::TWIP); } +// returns in pt +static sal_Int64 lcl_GetMinLineWidth(SvxBorderLineStyle aStyle) +{ + switch (aStyle) + { + case SvxBorderLineStyle::NONE: + return 0; + + case SvxBorderLineStyle::SOLID: + case SvxBorderLineStyle::DOTTED: + case SvxBorderLineStyle::DASHED: + case SvxBorderLineStyle::FINE_DASHED: + case SvxBorderLineStyle::DASH_DOT: + case SvxBorderLineStyle::DASH_DOT_DOT: + return 15; + + // Double lines + case SvxBorderLineStyle::DOUBLE: return 22; + case SvxBorderLineStyle::DOUBLE_THIN: return 22; + case SvxBorderLineStyle::THINTHICK_SMALLGAP: return 20; + case SvxBorderLineStyle::THINTHICK_MEDIUMGAP: return 15; + case SvxBorderLineStyle::THINTHICK_LARGEGAP: return 15; + case SvxBorderLineStyle::THICKTHIN_SMALLGAP: return 20; + case SvxBorderLineStyle::THICKTHIN_MEDIUMGAP: return 15; + case SvxBorderLineStyle::THICKTHIN_LARGEGAP: return 15; + + case SvxBorderLineStyle::EMBOSSED: return 15; + case SvxBorderLineStyle::ENGRAVED: return 15; + + case SvxBorderLineStyle::OUTSET: return 10; + case SvxBorderLineStyle::INSET: return 10; + + default: + return 15; + } +} + // number of preset images to show const sal_uInt16 SVX_BORDER_PRESET_COUNT = 5; @@ -1170,15 +1207,37 @@ IMPL_LINK_NOARG(SvxBorderTabPage, ModifyWidthHdl_Impl, weld::MetricSpinButton&, IMPL_LINK_NOARG(SvxBorderTabPage, SelStyleHdl_Impl, SvtLineListBox&, void) { - sal_Int64 nVal = m_xLineWidthMF->get_value(FieldUnit::NONE); - nVal = static_cast<sal_Int64>(MetricField::ConvertDoubleValue( - nVal, - m_xLineWidthMF->get_digits(), - FieldUnit::POINT, MapUnit::MapTwip )); - m_aFrameSel.SetStyleToSelection ( nVal, + sal_Int64 nOldWidth = m_xLineWidthMF->get_value(FieldUnit::NONE); + nOldWidth = static_cast<sal_Int64>(MetricField::ConvertDoubleValue( + nOldWidth, + m_xLineWidthMF->get_digits(), + FieldUnit::POINT, + MapUnit::MapTwip)); + + const sal_Int64 nOldMinWidth = lcl_GetMinLineWidth(m_aFrameSel.getCurrentStyleLineStyle()); + const sal_Int64 nNewMinWidth = lcl_GetMinLineWidth(m_xLbLineStyle->GetSelectEntryStyle()); + + // 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; + + // set value inside edit box + if (nOldWidth != nNewWidth) + { + const sal_Int64 nNewWidthPt = static_cast<sal_Int64>(MetricField::ConvertDoubleValue( + nNewWidth, + m_xLineWidthMF->get_digits(), + MapUnit::MapTwip, + FieldUnit::POINT)); + m_xLineWidthMF->set_value(nNewWidthPt, FieldUnit::POINT); + } + + // set value inside style box + m_aFrameSel.SetStyleToSelection( nNewWidth, m_xLbLineStyle->GetSelectEntryStyle() ); } + // ValueSet handling sal_uInt16 SvxBorderTabPage::GetPresetImageId( sal_uInt16 nValueSetIdx ) const { @@ -1309,34 +1368,33 @@ void SvxBorderTabPage::FillLineListBox_Impl() static struct { SvxBorderLineStyle mnStyle; - long mnMinWidth; SvtLineListBox::ColorFunc mpColor1Fn; SvtLineListBox::ColorFunc mpColor2Fn; SvtLineListBox::ColorDistFunc mpColorDistFn; } const aLines[] = { // Simple lines - { SvxBorderLineStyle::SOLID, 0, &sameColor, &sameColor, &sameDistColor }, - { SvxBorderLineStyle::DOTTED, 0, &sameColor, &sameColor, &sameDistColor }, - { SvxBorderLineStyle::DASHED, 0, &sameColor, &sameColor, &sameDistColor }, - { SvxBorderLineStyle::FINE_DASHED, 0, &sameColor, &sameColor, &sameDistColor }, - { SvxBorderLineStyle::DASH_DOT, 0, &sameColor, &sameColor, &sameDistColor }, - { SvxBorderLineStyle::DASH_DOT_DOT, 0, &sameColor, &sameColor, &sameDistColor }, + { SvxBorderLineStyle::SOLID, &sameColor, &sameColor, &sameDistColor }, + { SvxBorderLineStyle::DOTTED, &sameColor, &sameColor, &sameDistColor }, + { SvxBorderLineStyle::DASHED, &sameColor, &sameColor, &sameDistColor }, + { SvxBorderLineStyle::FINE_DASHED, &sameColor, &sameColor, &sameDistColor }, + { SvxBorderLineStyle::DASH_DOT, &sameColor, &sameColor, &sameDistColor }, + { SvxBorderLineStyle::DASH_DOT_DOT, &sameColor, &sameColor, &sameDistColor }, // Double lines - { SvxBorderLineStyle::DOUBLE, 10, &sameColor, &sameColor, &sameDistColor }, - { SvxBorderLineStyle::DOUBLE_THIN, 10, &sameColor, &sameColor, &sameDistColor }, - { SvxBorderLineStyle::THINTHICK_SMALLGAP, 20, &sameColor, &sameColor, &sameDistColor }, - { SvxBorderLineStyle::THINTHICK_MEDIUMGAP, 0, &sameColor, &sameColor, &sameDistColor }, - { SvxBorderLineStyle::THINTHICK_LARGEGAP, 0, &sameColor, &sameColor, &sameDistColor }, - { SvxBorderLineStyle::THICKTHIN_SMALLGAP, 20, &sameColor, &sameColor, &sameDistColor }, - { SvxBorderLineStyle::THICKTHIN_MEDIUMGAP, 0, &sameColor, &sameColor, &sameDistColor }, - { SvxBorderLineStyle::THICKTHIN_LARGEGAP, 0, &sameColor, &sameColor, &sameDistColor }, - - { SvxBorderLineStyle::EMBOSSED, 15, &SvxBorderLine::threeDLightColor, &SvxBorderLine::threeDDarkColor, &lcl_mediumColor }, - { SvxBorderLineStyle::ENGRAVED, 15, &SvxBorderLine::threeDDarkColor, &SvxBorderLine::threeDLightColor, &lcl_mediumColor }, - - { SvxBorderLineStyle::OUTSET, 10, &SvxBorderLine::lightColor, &SvxBorderLine::darkColor, &sameDistColor }, - { SvxBorderLineStyle::INSET, 10, &SvxBorderLine::darkColor, &SvxBorderLine::lightColor, &sameDistColor } + { SvxBorderLineStyle::DOUBLE, &sameColor, &sameColor, &sameDistColor }, + { SvxBorderLineStyle::DOUBLE_THIN, &sameColor, &sameColor, &sameDistColor }, + { SvxBorderLineStyle::THINTHICK_SMALLGAP, &sameColor, &sameColor, &sameDistColor }, + { SvxBorderLineStyle::THINTHICK_MEDIUMGAP, &sameColor, &sameColor, &sameDistColor }, + { SvxBorderLineStyle::THINTHICK_LARGEGAP, &sameColor, &sameColor, &sameDistColor }, + { SvxBorderLineStyle::THICKTHIN_SMALLGAP, &sameColor, &sameColor, &sameDistColor }, + { SvxBorderLineStyle::THICKTHIN_MEDIUMGAP, &sameColor, &sameColor, &sameDistColor }, + { SvxBorderLineStyle::THICKTHIN_LARGEGAP, &sameColor, &sameColor, &sameDistColor }, + + { SvxBorderLineStyle::EMBOSSED, &SvxBorderLine::threeDLightColor, &SvxBorderLine::threeDDarkColor, &lcl_mediumColor }, + { SvxBorderLineStyle::ENGRAVED, &SvxBorderLine::threeDDarkColor, &SvxBorderLine::threeDLightColor, &lcl_mediumColor }, + + { SvxBorderLineStyle::OUTSET, &SvxBorderLine::lightColor, &SvxBorderLine::darkColor, &sameDistColor }, + { SvxBorderLineStyle::INSET, &SvxBorderLine::darkColor, &SvxBorderLine::lightColor, &sameDistColor } }; m_xLbLineStyle->SetSourceUnit( FieldUnit::TWIP ); @@ -1347,8 +1405,12 @@ void SvxBorderTabPage::FillLineListBox_Impl() continue; m_xLbLineStyle->InsertEntry( - SvxBorderLine::getWidthImpl(aLines[i].mnStyle), aLines[i].mnStyle, - aLines[i].mnMinWidth, aLines[i].mpColor1Fn, aLines[i].mpColor2Fn, aLines[i].mpColorDistFn); + SvxBorderLine::getWidthImpl(aLines[i].mnStyle), + aLines[i].mnStyle, + lcl_GetMinLineWidth(aLines[i].mnStyle), + aLines[i].mpColor1Fn, + aLines[i].mpColor2Fn, + aLines[i].mpColorDistFn); } sal_Int64 nVal = m_xLineWidthMF->get_value(FieldUnit::NONE); diff --git a/include/svx/frmsel.hxx b/include/svx/frmsel.hxx index f9a6195258eb..d6fc1c65823e 100644 --- a/include/svx/frmsel.hxx +++ b/include/svx/frmsel.hxx @@ -153,6 +153,8 @@ public: /** Sets the passed color to all selected frame borders. */ void SetColorToSelection( const Color& rColor ); + SvxBorderLineStyle getCurrentStyleLineStyle() const; + // accessibility css::uno::Reference<css::accessibility::XAccessible> getAccessibleParent() const { return GetDrawingArea()->get_accessible_parent(); } diff --git a/sc/qa/uitest/calc_tests/formatCells.py b/sc/qa/uitest/calc_tests/formatCells.py index 4ebcfddddf4a..b930e7c751b4 100644 --- a/sc/qa/uitest/calc_tests/formatCells.py +++ b/sc/qa/uitest/calc_tests/formatCells.py @@ -293,6 +293,59 @@ class formatCell(UITestCase): self.ui_test.close_doc() + def test_minimal_border_width(self): + #borderpage.ui, tdf#137790 + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + #set points pt measurement + change_measurement_unit(self, "Point") + + #select cell A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #format - cell + self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "5") #tab Borders + + linewidthmf = xDialog.getChild("linewidthmf") + xLineSet = xDialog.getChild('lineset') + + # check line-width for default solid line + self.assertEqual('0', get_state_as_dict(xLineSet)['SelectedItemPos']) + widthVal = get_state_as_dict(linewidthmf)["Text"] + self.assertEqual(widthVal, '0.75 pt') + + # 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, '1.10 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') + + # 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') + + # 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') + + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + self.ui_test.close_doc() + def test_format_cell_borders_tab(self): #borderpage.ui calc_doc = self.ui_test.create_doc_in_start_center("calc") diff --git a/svx/source/dialog/frmsel.cxx b/svx/source/dialog/frmsel.cxx index 07cb2e0223bc..674b33a63bd2 100644 --- a/svx/source/dialog/frmsel.cxx +++ b/svx/source/dialog/frmsel.cxx @@ -1010,6 +1010,11 @@ void FrameSelector::SetColorToSelection( const Color& rColor ) mxImpl->SetBorderState( **aIt, FrameBorderState::Show ); } +SvxBorderLineStyle FrameSelector::getCurrentStyleLineStyle() const +{ + return mxImpl->maCurrStyle.GetBorderLineStyle(); +} + // accessibility Reference< XAccessible > FrameSelector::CreateAccessible() { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits