From 6e44bb1b67f41dc7dbf15fe4502578a38ac59738 Mon Sep 17 00:00:00 2001 From: Laurent Balland-Poirier Date: Sun, 17 Jul 2016 18:20:24 +0200 Subject: 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 Reviewed-by: Laurent BP --- cui/source/inc/numfmt.hxx | 3 ++ cui/source/tabpages/numfmt.cxx | 72 ++++++++++++++++++++++-------- cui/uiconfig/ui/numberingformatpage.ui | 80 ++++++++++++++++++++++++++++++---- 3 files changed, 128 insertions(+), 27 deletions(-) (limited to 'cui') 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 m_pFtOptions; VclPtr m_pFtDecimals; VclPtr m_pEdDecimals; + VclPtr m_pFtDenominator; + VclPtr m_pEdDenominator; VclPtr m_pBtnNegRed; VclPtr m_pFtLeadZeroes; VclPtr 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 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 @@ 1 10 + + 8 + 1 + 1 + True False @@ -225,11 +230,38 @@ 6 12 - + True - True - - adjustment1 + False + 0 + vertical + 6 + + + True + True + + adjustment1 + + + False + True + 0 + + + + + True + True + + adjustment2 + + + False + True + 0 + + 1 @@ -249,13 +281,43 @@ - + True False - 1 - _Decimal places: - True - decimalsed + center + 0 + vertical + 6 + + + True + False + 1 + _Decimal places: + True + decimalsed + + + False + True + 0 + + + + + False + False + 1 + Den_ominator places: + True + denominatored + + + False + True + 0 + + 0 -- cgit