summaryrefslogtreecommitdiff
path: root/cui
diff options
context:
space:
mode:
authorSerge Krot <Serge.Krot@cib.de>2020-10-27 11:26:55 +0100
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2020-11-13 21:29:45 +0100
commit63540cbef6484fa9dc017c93676d0b5e85075303 (patch)
tree575d181f80d7601cbc816249f95d9f65b8f10b75 /cui
parenta874f1e6d4b3195885f440e2aaf2c848db435985 (diff)
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.Behrens@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.Behrens@CIB.de> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105409 Tested-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Diffstat (limited to 'cui')
-rw-r--r--cui/source/tabpages/border.cxx120
1 files changed, 91 insertions, 29 deletions
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);