diff options
author | Laurent Balland <laurent.balland@mailo.fr> | 2023-01-14 15:48:12 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2023-02-03 17:57:01 +0000 |
commit | bbd487dc26c7e37982f64f6e6159c65ac77a89f1 (patch) | |
tree | 4b4ebdd38543910807e13e6bbf14390ff87ac81b /sc/source/ui/sidebar | |
parent | fb42b73d50eb3856a96c8c6f269e37d9da2181f2 (diff) |
tdf#153023 Disable Thousand separator for NatNum12
Add some helper to get NatNum12 state
Modify both Number format dialog and Sidebar
Transform CAT_ defines in enum
Change-Id: Iaa3127bf07223caac60e409306a1bee2edc37428
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145513
Tested-by: Jenkins
Reviewed-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'sc/source/ui/sidebar')
-rw-r--r-- | sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx b/sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx index c9910cc1db82..b2530df9838f 100644 --- a/sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx +++ b/sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx @@ -23,6 +23,7 @@ #include <sfx2/dispatch.hxx> #include <svl/intitem.hxx> #include <svl/stritem.hxx> +#include <svx/numfmtsh.hxx> #include <o3tl/string_view.hxx> #include <com/sun/star/lang/IllegalArgumentException.hpp> @@ -185,12 +186,17 @@ void NumberFormatPropertyPanel::NotifyItemUpdate( sal_uInt16 nVal = pItem->GetValue(); mnCategorySelected = nVal; mxLbCategory->set_active(nVal); - if (nVal < 8 && // General, Number, Percent, Currency, Time, Scientific, Fraction - nVal != 4 ) // not Date + // There is an offset between category list enum and listbox in side panel + SvxNumberFormatCategory nCategory = static_cast< SvxNumberFormatCategory >( nVal + 1 ); + if (nCategory <= CAT_FRACTION && // General, Number, Percent, Currency, Time, Scientific, Fraction + nCategory != CAT_DATE ) // not Date { - bool bIsScientific ( nVal == 6 );// For scientific, Thousand separator is replaced by Engineering notation - bool bIsFraction ( nVal == 7 ); // For fraction, Decimal places is replaced by Denominator places - bool bIsTime ( nVal == 5 ); // For Time, Decimal places and NegRed available + // For scientific, Thousand separator is replaced by Engineering notation + bool bIsScientific ( nCategory == CAT_SCIENTIFIC ); + // For fraction, Decimal places is replaced by Denominator places + bool bIsFraction ( nCategory == CAT_FRACTION ); + // For Time, Decimal places and NegRed available + bool bIsTime ( nCategory == CAT_TIME ); mxBtnThousand->set_visible( !bIsScientific ); mxBtnThousand->set_sensitive( !bIsScientific && !bIsTime ); mxBtnThousand->set_active(false); @@ -226,12 +232,14 @@ void NumberFormatPropertyPanel::NotifyItemUpdate( bool bNegRed = false; sal_uInt16 nPrecision = 0; sal_uInt16 nLeadZeroes = 0; + bool bNatNum12 = false; + SvxNumberFormatCategory nCategory = static_cast< SvxNumberFormatCategory >( mnCategorySelected + 1 ); if( eState >= SfxItemState::DEFAULT) { const SfxStringItem* pItem = static_cast<const SfxStringItem*>(pState); const OUString& aCode = pItem->GetValue(); sal_Int32 nIndex = 0; - sal_Int32 aFormat[4] = {0}; + sal_Int32 aFormat[5] = {0}; for (sal_Int32 & rn : aFormat) { rn = o3tl::toInt32(o3tl::getToken(aCode, 0, ',', nIndex)); @@ -242,6 +250,7 @@ void NumberFormatPropertyPanel::NotifyItemUpdate( bNegRed = static_cast<bool>(aFormat[1]); nPrecision = static_cast<sal_uInt16>(aFormat[2]); nLeadZeroes = static_cast<sal_uInt16>(aFormat[3]); + bNatNum12 = static_cast< bool >( aFormat[4] ); } else { @@ -250,6 +259,11 @@ void NumberFormatPropertyPanel::NotifyItemUpdate( nPrecision = 0; nLeadZeroes = 1; } + if ( nCategory == CAT_NUMBER || + nCategory == CAT_PERCENT || + nCategory == CAT_CURRENCY || + nCategory == CAT_FRACTION ) + mxBtnThousand->set_sensitive( !bNatNum12 ); if ( mxBtnThousand->get_visible() ) mxBtnThousand->set_active(bThousand); else if ( mxBtnEngineering->get_visible() ) |