From feb336a2a286ff1fc4f584c1ee4ab2148ac596ad Mon Sep 17 00:00:00 2001 From: Laurent Balland-Poirier Date: Sun, 3 May 2015 18:01:52 +0200 Subject: 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 Tested-by: Eike Rathke --- 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(+) create mode 100644 sc/source/ui/sidebar/NumberFormatPropertyPanel.hrc create mode 100644 sc/source/ui/sidebar/NumberFormatPropertyPanel.src diff --git a/include/sfx2/sfx.hrc b/include/sfx2/sfx.hrc index e184a3061303..4f63e5262607 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 d41a13fbee6d..e959dc058806 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 953c318d115e..f3c492f38855 100644 --- a/sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx +++ b/sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx @@ -21,6 +21,7 @@ #include #include #include "NumberFormatPropertyPanel.hxx" +#include #include "sc.hrc" #include "scresid.hxx" #include @@ -50,6 +51,8 @@ NumberFormatPropertyPanel::NumberFormatPropertyPanel( const css::uno::Reference& 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 000000000000..3c2a63217c59 --- /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 + +#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 64e1a8d14ede..5c61709899af 100644 --- a/sc/source/ui/sidebar/NumberFormatPropertyPanel.hxx +++ b/sc/source/ui/sidebar/NumberFormatPropertyPanel.hxx @@ -72,6 +72,9 @@ private: VclPtr mpBtnNegRed; VclPtr 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 000000000000..35f15e3d87d9 --- /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 a0fb39694450..b987c53e2684 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(bThousand)); -- cgit v1.2.3