[Libreoffice-commits] core.git: include/sfx2 sc/AllLangResTarget_sc.mk sc/source

Laurent Balland-Poirier laurent.balland-poirier at laposte.net
Wed May 6 10:54:31 PDT 2015


 include/sfx2/sfx.hrc                               |    1 
 sc/AllLangResTarget_sc.mk                          |    1 
 sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx |    7 ++++
 sc/source/ui/sidebar/NumberFormatPropertyPanel.hrc |   25 ++++++++++++++++
 sc/source/ui/sidebar/NumberFormatPropertyPanel.hxx |    3 +
 sc/source/ui/sidebar/NumberFormatPropertyPanel.src |   32 +++++++++++++++++++++
 sc/source/ui/view/formatsh.cxx                     |   11 +++++++
 7 files changed, 80 insertions(+)

New commits:
commit feb336a2a286ff1fc4f584c1ee4ab2148ac596ad
Author: Laurent Balland-Poirier <laurent.balland-poirier at laposte.net>
Date:   Sun May 3 18:01:52 2015 +0200

    tdf#90258 Sidebar: toggle Thousand/Engineering
    
    Continue https://gerrit.libreoffice.org/15606/
    5a8c7fd551522bdfe935f4138bde0df376464608
    
    Rebase of https://gerrit.libreoffice.org/15233/
    Update with more robust tests.
    Update create NumberFormatPropertyPanel.[hs]rc
    
    Change-Id: I36bd95cbaee160f96e7e7369096b5c8fb0aa8a4d
    Reviewed-on: https://gerrit.libreoffice.org/15609
    Reviewed-by: Eike Rathke <erack at redhat.com>
    Tested-by: Eike Rathke <erack at redhat.com>

diff --git a/include/sfx2/sfx.hrc b/include/sfx2/sfx.hrc
index e184a30..4f63e526 100644
--- a/include/sfx2/sfx.hrc
+++ b/include/sfx2/sfx.hrc
@@ -88,6 +88,7 @@
 #define RID_SFX_SFXLOCAL_START              (RID_SFX_START + 3082)
 #define RID_SFX_VIEW_START                  (RID_SFX_START + 4096)
 #define RID_SFX_SIDEBAR_START               (RID_SFX_START + 4150)
+#define RID_SFX_PROPERTYPANEL_START         (RID_SFX_START + 4400)
 //      RID_CNT_START2                      (RID_SFX_START + 4500)
 //      RID_SFX_CHAOSDOC_START              (RID_SFX_START + 5120)
 //      RID_SFX_TPLCOMPONENT_START          (RID_SFX_START + 6800)
diff --git a/sc/AllLangResTarget_sc.mk b/sc/AllLangResTarget_sc.mk
index d41a13f..e959dc0 100644
--- a/sc/AllLangResTarget_sc.mk
+++ b/sc/AllLangResTarget_sc.mk
@@ -54,6 +54,7 @@ $(eval $(call gb_SrsTarget_add_files,sc/res,\
     sc/source/ui/miscdlgs/acredlin.src \
     sc/source/ui/formdlg/dwfunctr.src \
     sc/source/ui/sidebar/CellAppearancePropertyPanel.src \
+    sc/source/ui/sidebar/NumberFormatPropertyPanel.src \
     sc/source/ui/StatisticsDialogs/StatisticsDialogs.src \
     sc/source/core/src/compiler.src \
 ))
diff --git a/sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx b/sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx
index 953c318..f3c492f 100644
--- a/sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx
+++ b/sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx
@@ -21,6 +21,7 @@
 #include <sfx2/sidebar/Theme.hxx>
 #include <sfx2/sidebar/ControlFactory.hxx>
 #include "NumberFormatPropertyPanel.hxx"
+#include <NumberFormatPropertyPanel.hrc>
 #include "sc.hrc"
 #include "scresid.hxx"
 #include <sfx2/bindings.hxx>
@@ -50,6 +51,8 @@ NumberFormatPropertyPanel::NumberFormatPropertyPanel(
     const css::uno::Reference<css::frame::XFrame>& rxFrame,
     SfxBindings* pBindings)
   : PanelLayout(pParent,"NumberFormatPropertyPanel", "modules/scalc/ui/sidebarnumberformat.ui", rxFrame),
+    maThousandSeparator(ScResId(RID_SFX_STR_THOUSAND_SEP)),
+    maEngineeringNotation(ScResId(RID_SFX_STR_ENGINEERING)),
     maNumFormatControl(SID_NUMBER_TYPE_FORMAT, *pBindings, *this),
     maFormatControl(SID_NUMBER_FORMAT, *pBindings, *this),
 
@@ -247,6 +250,10 @@ void NumberFormatPropertyPanel::NotifyItemUpdate(
                     mpEdDecimals->Disable();
                     mpEdLeadZeroes->Disable();
                 }
+                if( nVal == 6 ) // For scientific, Thousand separator is replaced by Engineering notation
+                    mpBtnThousand->SetText( maEngineeringNotation );
+                else
+                    mpBtnThousand->SetText( maThousandSeparator );
             }
             else
             {
diff --git a/sc/source/ui/sidebar/NumberFormatPropertyPanel.hrc b/sc/source/ui/sidebar/NumberFormatPropertyPanel.hrc
new file mode 100644
index 0000000..3c2a632
--- /dev/null
+++ b/sc/source/ui/sidebar/NumberFormatPropertyPanel.hrc
@@ -0,0 +1,25 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <sfx2/sfx.hrc>
+
+#define RID_SFX_STR_THOUSAND_SEP            ( RID_SFX_PROPERTYPANEL_START + 1 )
+#define RID_SFX_STR_ENGINEERING             ( RID_SFX_PROPERTYPANEL_START + 2 )
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/sidebar/NumberFormatPropertyPanel.hxx b/sc/source/ui/sidebar/NumberFormatPropertyPanel.hxx
index 64e1a8d..5c61709 100644
--- a/sc/source/ui/sidebar/NumberFormatPropertyPanel.hxx
+++ b/sc/source/ui/sidebar/NumberFormatPropertyPanel.hxx
@@ -72,6 +72,9 @@ private:
     VclPtr<CheckBox>                               mpBtnNegRed;
     VclPtr<CheckBox>                               mpBtnThousand;
 
+    OUString                                maThousandSeparator;
+    OUString                                maEngineeringNotation;
+
     ::sfx2::sidebar::ControllerItem         maNumFormatControl;
     ::sfx2::sidebar::ControllerItem         maFormatControl;
 
diff --git a/sc/source/ui/sidebar/NumberFormatPropertyPanel.src b/sc/source/ui/sidebar/NumberFormatPropertyPanel.src
new file mode 100644
index 0000000..35f15e3
--- /dev/null
+++ b/sc/source/ui/sidebar/NumberFormatPropertyPanel.src
@@ -0,0 +1,32 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#include "NumberFormatPropertyPanel.hrc"
+
+
+String RID_SFX_STR_THOUSAND_SEP
+{
+    Text [ en-US ] = "Thousands separator";
+};
+
+String RID_SFX_STR_ENGINEERING
+{
+    Text [ en-US ] = "Engineering notation";
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/formatsh.cxx b/sc/source/ui/view/formatsh.cxx
index a0fb396..b987c53 100644
--- a/sc/source/ui/view/formatsh.cxx
+++ b/sc/source/ui/view/formatsh.cxx
@@ -2422,6 +2422,17 @@ void ScFormatShell::GetNumFormatState( SfxItemSet& rSet )
                         sal_uInt16 nLeadZeroes(0);
 
                         pFormatter->GetFormatSpecialInfo(nNumberFormat,bThousand, bNegRed, nPrecision, nLeadZeroes);
+
+                        const SvNumberformat* pFormatEntry = pFormatter->GetEntry( nNumberFormat );
+                        if (pFormatEntry && (pFormatEntry->GetType() & css::util::NumberFormat::SCIENTIFIC))
+                        {
+                            // if scientific, bThousand is used for engineering notation
+                            const sal_uInt16 nIntegerDigits = pFormatEntry->GetFormatIntegerDigits();
+                            if (nIntegerDigits > 0 && ((nIntegerDigits % 3) == 0))
+                                bThousand = true;
+                            else
+                                bThousand = false;
+                        }
                         OUString aFormat;
                         static OUString sBreak = ",";
                         const OUString sThousand = OUString::number(static_cast<sal_Int32>(bThousand));


More information about the Libreoffice-commits mailing list