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 /cui | |
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 'cui')
-rw-r--r-- | cui/source/inc/numfmt.hxx | 3 | ||||
-rw-r--r-- | cui/source/tabpages/numfmt.cxx | 72 | ||||
-rw-r--r-- | cui/uiconfig/ui/numberingformatpage.ui | 80 |
3 files changed, 128 insertions, 27 deletions
diff --git a/cui/source/inc/numfmt.hxx b/cui/source/inc/numfmt.hxx index 0fee236e258a..e89806895c3c 100644 --- a/cui/source/inc/numfmt.hxx +++ b/cui/source/inc/numfmt.hxx @@ -101,6 +101,8 @@ private: VclPtr<FixedText> m_pFtOptions; VclPtr<FixedText> m_pFtDecimals; VclPtr<NumericField> m_pEdDecimals; + VclPtr<FixedText> m_pFtDenominator; + VclPtr<NumericField> m_pEdDenominator; VclPtr<CheckBox> m_pBtnNegRed; VclPtr<FixedText> m_pFtLeadZeroes; VclPtr<NumericField> m_pEdLeadZeroes; @@ -137,6 +139,7 @@ private: void UpdateOptions_Impl( bool bCheckCatChange ); void UpdateFormatListBox_Impl( bool bCat, bool bUpdateEdit ); void UpdateThousandEngineeringCheckBox(); + void UpdateDecimalsDenominatorEditBox(); void Obstructing(); void EnableBySourceFormat_Impl(); void SetCategory( sal_uInt16 nPos ); diff --git a/cui/source/tabpages/numfmt.cxx b/cui/source/tabpages/numfmt.cxx index 415c4a45b078..51b918742d6d 100644 --- a/cui/source/tabpages/numfmt.cxx +++ b/cui/source/tabpages/numfmt.cxx @@ -255,6 +255,8 @@ SvxNumberFormatTabPage::SvxNumberFormatTabPage(vcl::Window* pParent, get(m_pFtOptions, "optionsft"); get(m_pFtDecimals, "decimalsft"); get(m_pEdDecimals, "decimalsed"); + get(m_pFtDenominator, "denominatorft"); + get(m_pEdDenominator, "denominatored"); get(m_pBtnNegRed, "negnumred"); get(m_pFtLeadZeroes, "leadzerosft"); get(m_pEdLeadZeroes, "leadzerosed"); @@ -300,6 +302,8 @@ void SvxNumberFormatTabPage::dispose() m_pFtOptions.clear(); m_pFtDecimals.clear(); m_pEdDecimals.clear(); + m_pFtDenominator.clear(); + m_pEdDenominator.clear(); m_pBtnNegRed.clear(); m_pFtLeadZeroes.clear(); m_pEdLeadZeroes.clear(); @@ -344,6 +348,7 @@ void SvxNumberFormatTabPage::Init_Impl() Link<Edit&,void> aLink = LINK( this, SvxNumberFormatTabPage, OptEditHdl_Impl ); m_pEdDecimals->SetModifyHdl( aLink ); + m_pEdDenominator->SetModifyHdl( aLink ); m_pEdLeadZeroes->SetModifyHdl( aLink ); m_pBtnNegRed->SetClickHdl( LINK( this, SvxNumberFormatTabPage, OptClickHdl_Impl ) ); @@ -355,6 +360,7 @@ void SvxNumberFormatTabPage::Init_Impl() m_pIbRemove->SetClickHdl( HDL( ClickHdl_Impl ) ); m_pIbInfo->SetClickHdl( HDL( ClickHdl_Impl ) ); UpdateThousandEngineeringCheckBox(); + UpdateDecimalsDenominatorEditBox(); m_pEdComment->SetLoseFocusHdl( LINK( this, SvxNumberFormatTabPage, LostFocusHdl_Impl) ); aResetWinTimer.SetTimeoutHdl(LINK( this, SvxNumberFormatTabPage, TimeHdl_Impl)); @@ -636,8 +642,10 @@ void SvxNumberFormatTabPage::Obstructing() m_pBtnEngineering->Disable(); m_pFtLeadZeroes->Disable(); m_pFtDecimals->Disable(); + m_pFtDenominator->Disable(); m_pEdLeadZeroes->Disable(); m_pEdDecimals->Disable(); + m_pEdDenominator->Disable(); m_pFtOptions->Disable(); m_pEdDecimals->SetText( OUString() ); m_pEdLeadZeroes->SetText( OUString() ); @@ -673,6 +681,8 @@ void SvxNumberFormatTabPage::EnableBySourceFormat_Impl() m_pLbLanguage->Enable( bEnable ); m_pFtDecimals->Enable( bEnable ); m_pEdDecimals->Enable( bEnable ); + m_pFtDenominator->Enable( bEnable ); + m_pEdDenominator->Enable( bEnable ); m_pFtLeadZeroes->Enable( bEnable ); m_pEdLeadZeroes->Enable( bEnable ); m_pBtnNegRed->Enable( bEnable ); @@ -962,6 +972,7 @@ void SvxNumberFormatTabPage::UpdateOptions_Impl( bool bCheckCatChange /*= sal_Fa } UpdateThousandEngineeringCheckBox(); + UpdateDecimalsDenominatorEditBox(); switch ( nCategory ) { case CAT_SCIENTIFIC: // bThousand is for Engineering notation @@ -978,16 +989,28 @@ void SvxNumberFormatTabPage::UpdateOptions_Impl( bool bCheckCatChange /*= sal_Fa case CAT_NUMBER: case CAT_PERCENT: case CAT_CURRENCY: + case CAT_FRACTION: m_pFtOptions->Enable(); - m_pFtDecimals->Enable(); - m_pEdDecimals->Enable(); + if ( nCategory == CAT_FRACTION ) + { + m_pFtDenominator->Enable(); + m_pEdDenominator->Enable(); + } + else + { + m_pFtDecimals->Enable(); + m_pEdDecimals->Enable(); + } m_pFtLeadZeroes->Enable(); m_pEdLeadZeroes->Enable(); m_pBtnNegRed->Enable(); if ( nCategory == CAT_NUMBER && m_pLbFormat->GetSelectEntryPos() == 0 ) m_pEdDecimals->SetText( "" ); //General format tdf#44399 else - m_pEdDecimals->SetText( OUString::number( nDecimals ) ); + if ( nCategory == CAT_FRACTION ) + m_pEdDenominator->SetText( OUString::number( nDecimals ) ); + else + m_pEdDecimals->SetText( OUString::number( nDecimals ) ); m_pEdLeadZeroes->SetText( OUString::number( nZeroes ) ); m_pBtnNegRed->Check( bNegRed ); if ( nCategory != CAT_SCIENTIFIC ) @@ -1003,11 +1026,12 @@ void SvxNumberFormatTabPage::UpdateOptions_Impl( bool bCheckCatChange /*= sal_Fa case CAT_DATE: case CAT_TIME: case CAT_BOOLEAN: - case CAT_FRACTION: default: m_pFtOptions->Disable(); m_pFtDecimals->Disable(); m_pEdDecimals->Disable(); + m_pFtDenominator->Disable(); + m_pEdDenominator->Disable(); m_pFtLeadZeroes->Disable(); m_pEdLeadZeroes->Disable(); m_pBtnNegRed->Disable(); @@ -1129,18 +1153,11 @@ void SvxNumberFormatTabPage::UpdateFormatListBox_Impl } -/************************************************************************* -#* Method: UpdateThousandEngineeringCheckBox -#*------------------------------------------------------------------------ -#* -#* Class: SvxNumberFormatTabPage -#* Function: Change visible checkbox according to category format -#* if scientific format "Engineering notation" -#* else "Thousands separator" -#* Input: --- -#* Output: --- -#* -#************************************************************************/ +/** + * Change visible checkbox according to category format + * if scientific format "Engineering notation" + * else "Thousands separator" + */ void SvxNumberFormatTabPage::UpdateThousandEngineeringCheckBox() { @@ -1150,6 +1167,22 @@ void SvxNumberFormatTabPage::UpdateThousandEngineeringCheckBox() } +/** + * Change visible Edit box and Fixed text according to category format + * if fraction format "Denominator places" + * else "Decimal places" + */ + +void SvxNumberFormatTabPage::UpdateDecimalsDenominatorEditBox() +{ + bool bIsFraction = m_pLbCategory->GetSelectEntryPos() == CAT_FRACTION; + m_pFtDecimals->Show( !bIsFraction ); + m_pEdDecimals->Show( !bIsFraction ); + m_pFtDenominator->Show( bIsFraction ); + m_pEdDenominator->Show( bIsFraction ); +} + + /************************************************************************* #* Handle: DoubleClickHdl_Impl #*------------------------------------------------------------------------ @@ -1589,6 +1622,7 @@ void SvxNumberFormatTabPage::OptHdl_Impl( void* pOptCtrl ) { if ( (pOptCtrl == m_pEdLeadZeroes) || (pOptCtrl == m_pEdDecimals) + || (pOptCtrl == m_pEdDenominator) || (pOptCtrl == m_pBtnNegRed) || (pOptCtrl == m_pBtnThousand) || (pOptCtrl == m_pBtnEngineering) ) @@ -1597,9 +1631,11 @@ void SvxNumberFormatTabPage::OptHdl_Impl( void* pOptCtrl ) bool bThousand = ( m_pBtnThousand->IsVisible() && m_pBtnThousand->IsEnabled() && m_pBtnThousand->IsChecked() ) || ( m_pBtnEngineering->IsVisible() && m_pBtnEngineering->IsEnabled() && m_pBtnEngineering->IsChecked() ); bool bNegRed = m_pBtnNegRed->IsEnabled() && m_pBtnNegRed->IsChecked(); - sal_uInt16 nPrecision = (m_pEdDecimals->IsEnabled()) + sal_uInt16 nPrecision = (m_pEdDecimals->IsEnabled() && m_pEdDecimals->IsVisible()) ? (sal_uInt16)m_pEdDecimals->GetValue() - : (sal_uInt16)0; + : ( (m_pEdDenominator->IsEnabled() && m_pEdDenominator->IsVisible()) + ? (sal_uInt16)m_pEdDenominator->GetValue() + : (sal_uInt16)0 ); sal_uInt16 nLeadZeroes = (m_pEdLeadZeroes->IsEnabled()) ? (sal_uInt16)m_pEdLeadZeroes->GetValue() : (sal_uInt16)0; diff --git a/cui/uiconfig/ui/numberingformatpage.ui b/cui/uiconfig/ui/numberingformatpage.ui index 87039b262656..9308246eb3f0 100644 --- a/cui/uiconfig/ui/numberingformatpage.ui +++ b/cui/uiconfig/ui/numberingformatpage.ui @@ -8,6 +8,11 @@ <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="GtkImage" id="image1"> <property name="visible">True</property> <property name="can_focus">False</property> @@ -225,11 +230,38 @@ <property name="row_spacing">6</property> <property name="column_spacing">12</property> <child> - <object class="GtkSpinButton" id="decimalsed"> + <object class="GtkBox" id="box2"> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="invisible_char">•</property> - <property name="adjustment">adjustment1</property> + <property name="can_focus">False</property> + <property name="border_width">0</property> + <property name="orientation">vertical</property> + <property name="spacing">6</property> + <child> + <object class="GtkSpinButton" id="decimalsed"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="invisible_char">•</property> + <property name="adjustment">adjustment1</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="denominatored"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="invisible_char">•</property> + <property name="adjustment">adjustment2</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> </object> <packing> <property name="left_attach">1</property> @@ -249,13 +281,43 @@ </packing> </child> <child> - <object class="GtkLabel" id="decimalsft"> + <object class="GtkBox" id="box3"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">1</property> - <property name="label" translatable="yes">_Decimal places:</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">decimalsed</property> + <property name="valign">center</property> + <property name="border_width">0</property> + <property name="orientation">vertical</property> + <property name="spacing">6</property> + <child> + <object class="GtkLabel" id="decimalsft"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="xalign">1</property> + <property name="label" translatable="yes">_Decimal places:</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">decimalsed</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="denominatorft"> + <property name="visible">False</property> + <property name="can_focus">False</property> + <property name="xalign">1</property> + <property name="label" translatable="yes">Den_ominator places:</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">denominatored</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> </object> <packing> <property name="left_attach">0</property> |