diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2023-10-08 13:14:11 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2023-10-08 15:46:02 +0200 |
commit | c78861094f57198f4cd7117a85a5915358742209 (patch) | |
tree | 2b9abe1f78aa89524308ede35549a86574763a3c /cui | |
parent | 70c46e0e03a758fda4e94b561fdcae722414719f (diff) |
Simplify a bit
Change-Id: Icfa6d5bdc3c1a9e13f7e29d36a4a873a5c6bb05c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157684
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'cui')
-rw-r--r-- | cui/source/inc/border.hxx | 1 | ||||
-rw-r--r-- | cui/source/tabpages/border.cxx | 34 |
2 files changed, 15 insertions, 20 deletions
diff --git a/cui/source/inc/border.hxx b/cui/source/inc/border.hxx index 586b05f9410b..accb555930dc 100644 --- a/cui/source/inc/border.hxx +++ b/cui/source/inc/border.hxx @@ -77,7 +77,6 @@ private: class SvxBorderTabPage : public SfxTabPage { static const WhichRangesContainer pRanges; - static const std::vector<int> m_aLineWidths; public: SvxBorderTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rCoreAttrs); diff --git a/cui/source/tabpages/border.cxx b/cui/source/tabpages/border.cxx index 549ab533410a..ca2b7d61e2ef 100644 --- a/cui/source/tabpages/border.cxx +++ b/cui/source/tabpages/border.cxx @@ -78,22 +78,19 @@ const WhichRangesContainer SvxBorderTabPage::pRanges( namespace { -int lcl_twipsToPt(sal_Int64 nTwips) +constexpr int twipsToPt100(sal_Int64 nTwips) { - return vcl::ConvertDoubleValue(nTwips, 0, FieldUnit::TWIP, MapUnit::MapPoint) * 100; + return o3tl::convert(nTwips * 100, o3tl::Length::twip, o3tl::Length::pt); } +constexpr int s_LineWidths[] = { twipsToPt100(SvxBorderLineWidth::Hairline), + twipsToPt100(SvxBorderLineWidth::VeryThin), + twipsToPt100(SvxBorderLineWidth::Thin), + twipsToPt100(SvxBorderLineWidth::Medium), + twipsToPt100(SvxBorderLineWidth::Thick), + twipsToPt100(SvxBorderLineWidth::ExtraThick), + -1 }; } -const std::vector<int> SvxBorderTabPage::m_aLineWidths = { - lcl_twipsToPt(SvxBorderLineWidth::Hairline), - lcl_twipsToPt(SvxBorderLineWidth::VeryThin), - lcl_twipsToPt(SvxBorderLineWidth::Thin), - lcl_twipsToPt(SvxBorderLineWidth::Medium), - lcl_twipsToPt(SvxBorderLineWidth::Thick), - lcl_twipsToPt(SvxBorderLineWidth::ExtraThick), - -1 -}; - static void lcl_SetDecimalDigitsTo1(weld::MetricSpinButton& rField) { auto nMin = rField.denormalize(rField.get_min(FieldUnit::TWIP)); @@ -1243,10 +1240,10 @@ 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(); + nRemovedType = std::size(s_LineWidths) - m_xLineWidthLB->get_count(); } - SetLineWidth(m_aLineWidths[nPos + nRemovedType], nRemovedType); + SetLineWidth(s_LineWidths[nPos + nRemovedType], nRemovedType); // Call the spinner handler to trigger all related modifications ModifyWidthMFHdl_Impl(*m_xLineWidthMF); @@ -1462,19 +1459,18 @@ void SvxBorderTabPage::SetLineWidth( sal_Int64 nWidth, sal_Int32 nRemovedType ) 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; } ); + auto it = std::find( std::begin(s_LineWidths), std::end(s_LineWidths), nWidth ); - if ( it != m_aLineWidths.end() && *it >= 0 ) + if ( it != std::end(s_LineWidths) && *it >= 0 ) { // Select predefined value in combobox m_xLineWidthMF->hide(); - m_xLineWidthLB->set_active(std::distance(m_aLineWidths.begin(), it) - nRemovedType); + m_xLineWidthLB->set_active(std::distance(std::begin(s_LineWidths), it) - nRemovedType); } else { // This is not one of predefined values. Show spinner - m_xLineWidthLB->set_active(m_aLineWidths.size() - nRemovedType -1); + m_xLineWidthLB->set_active(std::size(s_LineWidths) - nRemovedType -1); m_xLineWidthMF->show(); } } |