summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Balland-Poirier <laurent.balland-poirier@laposte.net>2016-07-17 18:20:24 +0200
committerLaurent BP <laurent.balland-poirier@laposte.net>2016-08-16 19:20:57 +0000
commit6e44bb1b67f41dc7dbf15fe4502578a38ac59738 (patch)
tree089b78269a39bbe36d4bb38955ebdea65ba335f0
parente8ac831bd6d5f2524bab826bfbedf23f8952bbce (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>
-rw-r--r--cui/source/inc/numfmt.hxx3
-rw-r--r--cui/source/tabpages/numfmt.cxx72
-rw-r--r--cui/uiconfig/ui/numberingformatpage.ui80
-rw-r--r--sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx84
-rw-r--r--sc/source/ui/sidebar/NumberFormatPropertyPanel.hxx4
-rw-r--r--sc/source/ui/view/formatsh.cxx4
-rw-r--r--sc/uiconfig/scalc/ui/sidebarnumberformat.ui47
-rw-r--r--svl/source/numbers/zforlist.cxx20
-rw-r--r--svl/source/numbers/zformat.cxx11
-rw-r--r--svl/source/numbers/zforscan.cxx5
10 files changed, 263 insertions, 67 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>
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>
diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx
index 5ca78ed0b370..0eaab97f467a 100644
--- a/svl/source/numbers/zforlist.cxx
+++ b/svl/source/numbers/zforlist.cxx
@@ -2858,7 +2858,7 @@ OUString SvNumberFormatter::GenerateFormat(sal_uInt32 nIndex,
}
}
}
- if (nPrecision > 0)
+ if (nPrecision > 0 && eType != css::util::NumberFormat::FRACTION )
{
sString.append(GetNumDecimalSep());
padToLength(sString, sString.getLength() + nPrecision, '0');
@@ -2931,6 +2931,24 @@ OUString SvNumberFormatter::GenerateFormat(sal_uInt32 nIndex,
}
sString.append(sNegStr.makeStringAndClear());
}
+ else if (eType == css::util::NumberFormat::FRACTION)
+ {
+ OUString aIntegerFractionDelimiterString = pFormat->GetIntegerFractionDelimiterString( 0 );
+ if ( aIntegerFractionDelimiterString == " " )
+ sString.append( aIntegerFractionDelimiterString );
+ else
+ {
+ sString.append( '"' );
+ sString.append( aIntegerFractionDelimiterString );
+ sString.append( '"' );
+ }
+ sString.append( pFormat->GetNumeratorString( 0 ) );
+ sString.append( '/' );
+ if ( nPrecision > 0 )
+ padToLength(sString, sString.getLength() + nPrecision, '?');
+ else
+ sString.append( '#' );
+ }
if (eType != css::util::NumberFormat::CURRENCY)
{
bool insertBrackets = false;
diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx
index a31754778b21..2cd92827f420 100644
--- a/svl/source/numbers/zformat.cxx
+++ b/svl/source/numbers/zformat.cxx
@@ -2004,7 +2004,8 @@ OUString lcl_GetFractionIntegerString(const ImpSvNumberformatInfo &rInfo, sal_uI
{
if( rInfo.nTypeArray[i] == NF_SYMBOLTYPE_FRACBLANK )
{
- for( i--; i >= 0 && rInfo.nTypeArray[i] == NF_SYMBOLTYPE_DIGIT ; i-- )
+ for( i--; i >= 0 && ( rInfo.nTypeArray[i] == NF_SYMBOLTYPE_DIGIT
+ || rInfo.nTypeArray[i] == NF_SYMBOLTYPE_THSEP ); i-- )
{
aIntegerString.insert( 0, rInfo.sStrArray[i] );
}
@@ -4350,7 +4351,13 @@ void SvNumberformat::GetNumForInfo( sal_uInt16 nNumFor, short& rScannedType,
const ImpSvNumberformatInfo& rInfo = NumFor[nNumFor].Info();
rScannedType = rInfo.eScannedType;
bThousand = rInfo.bThousand;
- nPrecision = rInfo.nCntPost;
+ nPrecision = (rInfo.eScannedType == css::util::NumberFormat::FRACTION)
+ ? rInfo.nCntExp // number of denominator digits for fraction
+ : rInfo.nCntPost;
+ sal_Int32 nPosHash = 1;
+ if ( rInfo.eScannedType == css::util::NumberFormat::FRACTION &&
+ ( (nPosHash += GetDenominatorString(nNumFor).indexOf('#')) > 0 ) )
+ nPrecision -= nPosHash;
if (bStandard && rInfo.eScannedType == css::util::NumberFormat::NUMBER)
{
// StandardFormat
diff --git a/svl/source/numbers/zforscan.cxx b/svl/source/numbers/zforscan.cxx
index 3642e91b0a56..82971a5fe0da 100644
--- a/svl/source/numbers/zforscan.cxx
+++ b/svl/source/numbers/zforscan.cxx
@@ -1047,8 +1047,9 @@ bool ImpSvNumberformatScan::IsLastBlankBeforeFrac(sal_uInt16 i)
{
bStop = true;
}
- else if ( nTypeArray[i] == NF_SYMBOLTYPE_DEL &&
- sStrArray[i][0] == ' ')
+ else if ( ( nTypeArray[i] == NF_SYMBOLTYPE_DEL &&
+ sStrArray[i][0] == ' ') ||
+ nTypeArray[i] == NF_SYMBOLTYPE_STRING ) // integer/fraction delimiter can also be a string
{
res = false;
}