diff options
author | Laurent Balland-Poirier <laurent.balland-poirier@laposte.net> | 2016-07-17 18:20:24 +0200 |
---|---|---|
committer | Laurent BP <laurent.balland-poirier@laposte.net> | 2016-08-16 19:20:57 +0000 |
commit | 6e44bb1b67f41dc7dbf15fe4502578a38ac59738 (patch) | |
tree | 089b78269a39bbe36d4bb38955ebdea65ba335f0 /sc | |
parent | e8ac831bd6d5f2524bab826bfbedf23f8952bbce (diff) |
Fraction Number Format: add UI/Sidebar options
Enable modification of fraction number format through dialog UI:
- negative in red
- "Decimal places" is replaced with "Denominator places"
- leading zeros for integer part
- thousand separator for integer part
Update: options in Sidebar
Thousand separator works, also for ' ' as thousand separator
Change-Id: I0ed2952ed9cd8afb5444b44997526e5019a5858d
Reviewed-on: https://gerrit.libreoffice.org/27268
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Laurent BP <laurent.balland-poirier@laposte.net>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx | 84 | ||||
-rw-r--r-- | sc/source/ui/sidebar/NumberFormatPropertyPanel.hxx | 4 | ||||
-rw-r--r-- | sc/source/ui/view/formatsh.cxx | 4 | ||||
-rw-r--r-- | sc/uiconfig/scalc/ui/sidebarnumberformat.ui | 47 |
4 files changed, 104 insertions, 35 deletions
diff --git a/sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx b/sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx index 1a70f32fa54b..550ba6f34754 100644 --- a/sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx +++ b/sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx @@ -51,7 +51,10 @@ NumberFormatPropertyPanel::NumberFormatPropertyPanel( { get(mpLbCategory, "category"); get(mpTBCategory, "numberformat"); + get(mpFtDecimals, "decimalplaceslabel"); get(mpEdDecimals, "decimalplaces"); + get(mpFtDenominator, "denominatorplaceslabel"); + get(mpEdDenominator, "denominatorplaces"); get(mpEdLeadZeroes, "leadingzeroes"); get(mpBtnNegRed, "negativenumbersred"); get(mpBtnThousand, "thousandseparator"); @@ -69,7 +72,10 @@ void NumberFormatPropertyPanel::dispose() { mpLbCategory.clear(); mpTBCategory.clear(); + mpFtDecimals.clear(); mpEdDecimals.clear(); + mpFtDenominator.clear(); + mpEdDenominator.clear(); mpEdLeadZeroes.clear(); mpBtnNegRed.clear(); mpBtnThousand.clear(); @@ -90,6 +96,7 @@ void NumberFormatPropertyPanel::Initialize() Link<Edit&,void> aLink = LINK(this, NumberFormatPropertyPanel, NumFormatValueHdl); mpEdDecimals->SetModifyHdl( aLink ); + mpEdDenominator->SetModifyHdl( aLink ); mpEdLeadZeroes->SetModifyHdl( aLink ); mpBtnNegRed->SetClickHdl( LINK(this, NumberFormatPropertyPanel, NumFormatValueClickHdl) ); @@ -120,12 +127,14 @@ IMPL_LINK_NOARG_TYPED( NumberFormatPropertyPanel, NumFormatValueHdl, Edit&, void bool bThousand = ( mpBtnThousand->IsVisible() && mpBtnThousand->IsEnabled() && mpBtnThousand->IsChecked() ) || ( mpBtnEngineering->IsVisible() && mpBtnEngineering->IsEnabled() && mpBtnEngineering->IsChecked() ); bool bNegRed = mpBtnNegRed->IsEnabled() && mpBtnNegRed->IsChecked(); - sal_uInt16 nPrecision = (mpEdDecimals->IsEnabled()) - ? (sal_uInt16)mpEdDecimals->GetValue() - : (sal_uInt16)0; + sal_uInt16 nPrecision = (mpEdDecimals->IsEnabled() && mpEdDecimals->IsVisible()) + ? (sal_uInt16)mpEdDecimals->GetValue() + : (mpEdDenominator->IsEnabled() && mpEdDenominator->IsVisible()) + ? (sal_uInt16)mpEdDenominator->GetValue() + : (sal_uInt16)0; sal_uInt16 nLeadZeroes = (mpEdLeadZeroes->IsEnabled()) - ? (sal_uInt16)mpEdLeadZeroes->GetValue() - : (sal_uInt16)0; + ? (sal_uInt16)mpEdLeadZeroes->GetValue() + : (sal_uInt16)0; OUString sThousand = OUString::number(static_cast<sal_Int32>(bThousand)); OUString sNegRed = OUString::number(static_cast<sal_Int32>(bNegRed)); @@ -199,44 +208,34 @@ void NumberFormatPropertyPanel::NotifyItemUpdate( mnCategorySelected = nVal; mpLbCategory->SelectEntryPos(nVal); if( nVal < 4 || // General, Number, Percent and Currency - nVal == 6 ) // scientific also + nVal == 6 || // scientific also + nVal == 7 ) // fraction { - if ( nVal == 6 ) // scientific - { // For scientific, Thousand separator is replaced by Engineering notation - mpBtnThousand->Hide(); - mpBtnEngineering->Show(); - mpBtnEngineering->Enable(); - } - else - { - mpBtnEngineering->Hide(); - mpBtnThousand->Show(); - mpBtnThousand->Enable(); - } + 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 + mpBtnThousand->Show(!bIsScientific); + mpBtnThousand->Enable(!bIsScientific); + mpBtnEngineering->Show(bIsScientific); + mpBtnEngineering->Enable(bIsScientific); mpBtnNegRed->Enable(); - mpEdDecimals->Enable(); + mpFtDenominator->Show(bIsFraction); + mpEdDenominator->Show(bIsFraction); + mpFtDenominator->Enable(bIsFraction); + mpEdDenominator->Enable(bIsFraction); + mpFtDecimals->Show(!bIsFraction); + mpEdDecimals->Show(!bIsFraction); + mpFtDecimals->Enable(!bIsFraction); + mpEdDecimals->Enable(!bIsFraction); mpEdLeadZeroes->Enable(); } else - { - mpBtnEngineering->Hide(); - mpBtnThousand->Show(); - mpBtnThousand->Disable(); - mpBtnNegRed->Disable(); - mpEdDecimals->Disable(); - mpEdLeadZeroes->Disable(); - } + DisableControls(); } else { - mpBtnEngineering->Hide(); - mpBtnThousand->Show(); + DisableControls(); mpLbCategory->SetNoSelection(); mnCategorySelected = 0; - mpBtnThousand->Disable(); - mpBtnNegRed->Disable(); - mpEdDecimals->Disable(); - mpEdLeadZeroes->Disable(); } } break; @@ -277,8 +276,10 @@ void NumberFormatPropertyPanel::NotifyItemUpdate( mpBtnNegRed->Check(bNegRed); if ( mpLbCategory->GetSelectEntryPos() == 0 ) mpEdDecimals->SetText(""); // tdf#44399 - else + else if ( mpEdDecimals->IsVisible() ) mpEdDecimals->SetValue(nPrecision); + else if ( mpEdDenominator->IsVisible() ) + mpEdDenominator->SetValue(nPrecision); mpEdLeadZeroes->SetValue(nLeadZeroes); } break; @@ -287,6 +288,21 @@ void NumberFormatPropertyPanel::NotifyItemUpdate( } } +void NumberFormatPropertyPanel::DisableControls() +{ + mpBtnEngineering->Hide(); + mpBtnThousand->Show(); + mpBtnThousand->Disable(); + mpBtnNegRed->Disable(); + mpFtDenominator->Hide(); + mpEdDenominator->Hide(); + mpFtDecimals->Show(); + mpEdDecimals->Show(); + mpFtDecimals->Disable(); + mpEdDecimals->Disable(); + mpEdLeadZeroes->Disable(); +} + }} // end of namespace ::sc::sidebar /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/sidebar/NumberFormatPropertyPanel.hxx b/sc/source/ui/sidebar/NumberFormatPropertyPanel.hxx index 7947cb7b0436..1f9540e046cd 100644 --- a/sc/source/ui/sidebar/NumberFormatPropertyPanel.hxx +++ b/sc/source/ui/sidebar/NumberFormatPropertyPanel.hxx @@ -67,7 +67,10 @@ private: //ui controls VclPtr<ListBox> mpLbCategory; VclPtr<ToolBox> mpTBCategory; + VclPtr<FixedText> mpFtDecimals; VclPtr<NumericField> mpEdDecimals; + VclPtr<FixedText> mpFtDenominator; + VclPtr<NumericField> mpEdDenominator; VclPtr<NumericField> mpEdLeadZeroes; VclPtr<CheckBox> mpBtnNegRed; VclPtr<CheckBox> mpBtnThousand; @@ -86,6 +89,7 @@ private: DECL_LINK_TYPED(NumFormatValueClickHdl, Button*, void); void Initialize(); + void DisableControls(); }; } } // end of namespace ::sc::sidebar diff --git a/sc/source/ui/view/formatsh.cxx b/sc/source/ui/view/formatsh.cxx index 3383b1de5325..d399687a0095 100644 --- a/sc/source/ui/view/formatsh.cxx +++ b/sc/source/ui/view/formatsh.cxx @@ -1149,7 +1149,7 @@ void ScFormatShell::ExecuteNumFormat( SfxRequest& rReq ) eType = pEntry->GetType(); } - //Just use eType to judge whether the command is fired for NUMBER/PERCENT/CURRENCY/SCIENTIFIC + //Just use eType to judge whether the command is fired for NUMBER/PERCENT/CURRENCY/SCIENTIFIC/FRACTION //In sidebar, users can fire SID_NUMBER_FORMAT command by operating the related UI controls before they are disable switch(eType) { @@ -1162,6 +1162,8 @@ void ScFormatShell::ExecuteNumFormat( SfxRequest& rReq ) case css::util::NumberFormat::CURRENCY|css::util::NumberFormat::DEFINED: case css::util::NumberFormat::SCIENTIFIC: case css::util::NumberFormat::SCIENTIFIC|css::util::NumberFormat::DEFINED: + case css::util::NumberFormat::FRACTION: + case css::util::NumberFormat::FRACTION|css::util::NumberFormat::DEFINED: eType = 0; break; default: diff --git a/sc/uiconfig/scalc/ui/sidebarnumberformat.ui b/sc/uiconfig/scalc/ui/sidebarnumberformat.ui index 6572ad23369f..a8875e5ca22d 100644 --- a/sc/uiconfig/scalc/ui/sidebarnumberformat.ui +++ b/sc/uiconfig/scalc/ui/sidebarnumberformat.ui @@ -3,6 +3,16 @@ <interface> <requires lib="gtk+" version="3.0"/> <requires lib="LibreOffice" version="1.0"/> + <object class="GtkAdjustment" id="adjustment1"> + <property name="upper">20</property> + <property name="step_increment">1</property> + <property name="page_increment">10</property> + </object> + <object class="GtkAdjustment" id="adjustment2"> + <property name="upper">8</property> + <property name="step_increment">1</property> + <property name="page_increment">1</property> + </object> <object class="GtkGrid" id="NumberFormatPropertyPanel"> <property name="visible">True</property> <property name="can_focus">False</property> @@ -141,6 +151,7 @@ <property name="tooltip_markup" translatable="yes">Enter the number of decimal places that you want to display.</property> <property name="tooltip_text" translatable="yes">Enter the number of decimal places that you want to display.</property> <property name="invisible_char">•</property> + <property name="adjustment">adjustment1</property> <child internal-child="accessible"> <object class="AtkObject" id="decimalplaces-atkobject"> <property name="AtkObject::accessible-name" translatable="yes">Decimal Places</property> @@ -153,6 +164,41 @@ <property name="position">1</property> </packing> </child> + <child> + <object class="GtkLabel" id="denominatorplaceslabel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Den_ominator places:</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">denominatorplaces</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkSpinButton" id="denominatorplaces"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="has_tooltip">True</property> + <property name="tooltip_markup" translatable="yes">Enter the number of places for the denominator that you want to display.</property> + <property name="tooltip_text" translatable="yes">Enter the number of places for the denominator that you want to display.</property> + <property name="invisible_char">•</property> + <property name="adjustment">adjustment2</property> + <child internal-child="accessible"> + <object class="AtkObject" id="denominatorplaces-atkobject"> + <property name="AtkObject::accessible-name" translatable="yes">Denominator Places</property> + </object> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> </object> <packing> <property name="expand">False</property> @@ -189,6 +235,7 @@ <property name="tooltip_markup" translatable="yes">Enter the maximum number of zeroes to display before the decimal point.</property> <property name="tooltip_text" translatable="yes">Enter the maximum number of zeroes to display before the decimal point.</property> <property name="invisible_char">•</property> + <property name="adjustment">adjustment1</property> <child internal-child="accessible"> <object class="AtkObject" id="leadingzeroes-atkobject"> <property name="AtkObject::accessible-name" translatable="yes">Leading Zeroes</property> |