From bf3f3a6bfb08c2d1a2c95f1c1cf62117e0002235 Mon Sep 17 00:00:00 2001 From: Szymon Kłos Date: Fri, 27 May 2016 22:36:43 +0200 Subject: notebookbar: working number format listbox Change-Id: I1555934646148b9cd4164cbaaf09dcb9affe861e Reviewed-on: https://gerrit.libreoffice.org/25579 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt --- sc/Library_sc.mk | 2 + sc/inc/NumberFormatControl.hxx | 46 ++++++++++ sc/inc/globstr.hrc | 13 ++- sc/sdi/scalc.sdi | 2 +- sc/source/ui/app/scdll.cxx | 2 + sc/source/ui/cctrl/cbnumberformat.cxx | 60 +++++++++++++ sc/source/ui/inc/cbnumberformat.hxx | 36 ++++++++ sc/source/ui/sidebar/NumberFormatControl.cxx | 77 +++++++++++++++++ sc/source/ui/src/globstr.src | 40 +++++++++ sc/uiconfig/scalc/ui/notebookbar.ui | 124 +++++++++++++-------------- 10 files changed, 337 insertions(+), 65 deletions(-) create mode 100644 sc/inc/NumberFormatControl.hxx create mode 100644 sc/source/ui/cctrl/cbnumberformat.cxx create mode 100644 sc/source/ui/inc/cbnumberformat.hxx create mode 100644 sc/source/ui/sidebar/NumberFormatControl.cxx diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk index bd767cb31c30..892995fa0a80 100644 --- a/sc/Library_sc.mk +++ b/sc/Library_sc.mk @@ -380,6 +380,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\ sc/source/ui/app/typemap \ sc/source/ui/app/uiitems \ sc/source/ui/attrdlg/scabstdlg \ + sc/source/ui/cctrl/cbnumberformat \ sc/source/ui/cctrl/cbuttonw \ sc/source/ui/cctrl/checklistmenu \ sc/source/ui/cctrl/dpcontrol \ @@ -500,6 +501,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\ sc/source/ui/sidebar/CellAppearancePropertyPanel \ sc/source/ui/sidebar/CellBorderStyleControl \ sc/source/ui/sidebar/CellBorderStylePopup \ + sc/source/ui/sidebar/NumberFormatControl \ sc/source/ui/sidebar/NumberFormatPropertyPanel \ sc/source/ui/sidebar/ScPanelFactory \ sc/source/ui/StatisticsDialogs/AnalysisOfVarianceDialog \ diff --git a/sc/inc/NumberFormatControl.hxx b/sc/inc/NumberFormatControl.hxx new file mode 100644 index 000000000000..b7ecb4606399 --- /dev/null +++ b/sc/inc/NumberFormatControl.hxx @@ -0,0 +1,46 @@ +/* -*- 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 . + */ +#ifndef INCLUDED_SC_NUMBERFORMATCONTROL_HXX +#define INCLUDED_SC_NUMBERFORMATCONTROL_HXX + +#include +#include + +#include + +namespace sc { + +class SC_DLLPUBLIC ScNumberFormatControl : public SfxToolBoxControl +{ +public: + SFX_DECL_TOOLBOX_CONTROL(); + + ScNumberFormatControl(sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx); + virtual ~ScNumberFormatControl(); + + virtual void StateChanged(sal_uInt16 nSID, SfxItemState eState, + const SfxPoolItem* pState) override; + virtual VclPtr CreateItemWindow( vcl::Window *pParent ) override; +}; + +} // end of namespace sc + +#endif // INCLUDED_SC_NUMBERFORMATCONTROL_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/globstr.hrc b/sc/inc/globstr.hrc index 81e44932d49b..df4369f21838 100644 --- a/sc/inc/globstr.hrc +++ b/sc/inc/globstr.hrc @@ -708,7 +708,18 @@ #define STR_FILTER_SELCOUNT 533 -#define SC_GLOBSTR_STR_COUNT 534 /**< the count of permanently resident strings */ +#define STR_GENERAL 534 +#define STR_NUMBER 535 +#define STR_PERCENT 536 +#define STR_CURRENCY 537 +#define STR_DATE 538 +#define STR_TIME 539 +#define STR_SCIENTIFIC 540 +#define STR_FRACTION 541 +#define STR_BOOLEAN_VALUE 542 +#define STR_TEXT 543 + +#define SC_GLOBSTR_STR_COUNT 544 /**< the count of permanently resident strings */ #endif diff --git a/sc/sdi/scalc.sdi b/sc/sdi/scalc.sdi index 14169f0757a5..028e703cb054 100644 --- a/sc/sdi/scalc.sdi +++ b/sc/sdi/scalc.sdi @@ -6600,6 +6600,6 @@ SfxUInt16Item NumberFormatType SID_NUMBER_TYPE_FORMAT AccelConfig = FALSE, MenuConfig = FALSE, - ToolBoxConfig = FALSE, + ToolBoxConfig = TRUE, GroupId = GID_FORMAT; ] diff --git a/sc/source/ui/app/scdll.cxx b/sc/source/ui/app/scdll.cxx index 087477f69c6f..9a14c78ee23f 100644 --- a/sc/source/ui/app/scdll.cxx +++ b/sc/source/ui/app/scdll.cxx @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -174,6 +175,7 @@ void ScDLL::Init() svx::TextCharacterSpacingPopup ::RegisterControl(SID_ATTR_CHAR_KERNING, pMod ); svx::TextUnderlinePopup ::RegisterControl(SID_ATTR_CHAR_UNDERLINE, pMod ); svx::FormatPaintBrushToolBoxControl::RegisterControl(SID_FORMATPAINTBRUSH, pMod ); + sc::ScNumberFormatControl ::RegisterControl(SID_NUMBER_TYPE_FORMAT, pMod ); SvxGrafModeToolBoxControl ::RegisterControl(SID_ATTR_GRAF_MODE, pMod); SvxGrafRedToolBoxControl ::RegisterControl(SID_ATTR_GRAF_RED, pMod); diff --git a/sc/source/ui/cctrl/cbnumberformat.cxx b/sc/source/ui/cctrl/cbnumberformat.cxx new file mode 100644 index 000000000000..8e4e7c91b674 --- /dev/null +++ b/sc/source/ui/cctrl/cbnumberformat.cxx @@ -0,0 +1,60 @@ +/* -*- 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 +#include "global.hxx" +#include +#include +#include +#include "sc.hrc" + +ScNumberFormat::ScNumberFormat(vcl::Window* pParent, WinBits nStyle) : + ListBox(pParent, nStyle | WB_DROPDOWN|WB_LEFT|WB_VCENTER|WB_BORDER|WB_3DLOOK) +{ + SetSelectHdl(LINK(this, ScNumberFormat, NumFormatSelectHdl)); + AdaptDropDownLineCountToMaximum(); + + InsertEntry(ScGlobal::GetRscString(STR_GENERAL)); + InsertEntry(ScGlobal::GetRscString(STR_NUMBER)); + InsertEntry(ScGlobal::GetRscString(STR_PERCENT)); + InsertEntry(ScGlobal::GetRscString(STR_CURRENCY)); + InsertEntry(ScGlobal::GetRscString(STR_DATE)); + InsertEntry(ScGlobal::GetRscString(STR_TIME)); + InsertEntry(ScGlobal::GetRscString(STR_SCIENTIFIC)); + InsertEntry(ScGlobal::GetRscString(STR_FRACTION)); + InsertEntry(ScGlobal::GetRscString(STR_BOOLEAN_VALUE)); + InsertEntry(ScGlobal::GetRscString(STR_TEXT)); +} + +IMPL_LINK_TYPED(ScNumberFormat, NumFormatSelectHdl, ListBox&, rBox, void) +{ + if(SfxViewFrame::Current()) + { + SfxDispatcher* pDisp = SfxViewFrame::Current()->GetBindings().GetDispatcher(); + if(pDisp) + { + const sal_Int32 nVal = rBox.GetSelectEntryPos(); + SfxUInt16Item aItem(SID_NUMBER_TYPE_FORMAT, nVal); + pDisp->ExecuteList(SID_NUMBER_TYPE_FORMAT, + SfxCallMode::RECORD, {&aItem}); + } + } +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/cbnumberformat.hxx b/sc/source/ui/inc/cbnumberformat.hxx new file mode 100644 index 000000000000..b52cc94a9d47 --- /dev/null +++ b/sc/source/ui/inc/cbnumberformat.hxx @@ -0,0 +1,36 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_SC_SOURCE_UI_INC_CBNUMBERFORMAT_HXX +#define INCLUDED_SC_SOURCE_UI_INC_CBNUMBERFORMAT_HXX + +#include + +class ScNumberFormat : public ListBox +{ +public: + explicit ScNumberFormat(vcl::Window* pParent, WinBits nStyle); + +private: + DECL_LINK_TYPED(NumFormatSelectHdl, ListBox&, void); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/sidebar/NumberFormatControl.cxx b/sc/source/ui/sidebar/NumberFormatControl.cxx new file mode 100644 index 000000000000..d5cec76da326 --- /dev/null +++ b/sc/source/ui/sidebar/NumberFormatControl.cxx @@ -0,0 +1,77 @@ +/* -*- 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 +#include +#include +#include +#include + +using namespace sc; + +SFX_IMPL_TOOLBOX_CONTROL(ScNumberFormatControl, SfxUInt16Item); + +ScNumberFormatControl::ScNumberFormatControl(sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx) + : SfxToolBoxControl(nSlotId, nId, rTbx) +{ +} + +ScNumberFormatControl::~ScNumberFormatControl() +{ +} + +void ScNumberFormatControl::StateChanged(sal_uInt16, SfxItemState eState, + const SfxPoolItem* pState) +{ + sal_uInt16 nId = GetId(); + ToolBox& rTbx = GetToolBox(); + ScNumberFormat* pComboBox = static_cast(rTbx.GetItemWindow(nId)); + + DBG_ASSERT( pComboBox, "Control not found!" ); + + if(SfxItemState::DISABLED == eState) + pComboBox->Disable(); + else + pComboBox->Enable(); + + rTbx.EnableItem(nId, SfxItemState::DISABLED != eState); + + switch(eState) + { + case SfxItemState::DEFAULT: + { + const SfxInt16Item* pItem = static_cast(pState); + sal_uInt16 nVal = pItem->GetValue(); + pComboBox->SelectEntryPos(nVal); + break; + } + + default: + break; + } +} + +VclPtr ScNumberFormatControl::CreateItemWindow( vcl::Window *pParent ) +{ + VclPtr pControl = VclPtr::Create(pParent, WB_DROPDOWN); + pControl->SetSizePixel(pControl->GetOptimalSize()); + return pControl; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/src/globstr.src b/sc/source/ui/src/globstr.src index c74373f662b3..08e84c99f2e6 100644 --- a/sc/source/ui/src/globstr.src +++ b/sc/source/ui/src/globstr.src @@ -2109,6 +2109,46 @@ Resource RID_GLOBSTR { Text [ en-US ] = "%1 and %2 more"; }; + String STR_GENERAL + { + Text [ en-US ] = "General"; + }; + String STR_NUMBER + { + Text [ en-US ] = "Number"; + }; + String STR_PERCENT + { + Text [ en-US ] = "Percent"; + }; + String STR_CURRENCY + { + Text [ en-US ] = "Currency"; + }; + String STR_DATE + { + Text [ en-US ] = "Date"; + }; + String STR_TIME + { + Text [ en-US ] = "Time"; + }; + String STR_SCIENTIFIC + { + Text [ en-US ] = "Scientific"; + }; + String STR_FRACTION + { + Text [ en-US ] = "Fraction"; + }; + String STR_BOOLEAN_VALUE + { + Text [ en-US ] = "Boolean Value"; + }; + String STR_TEXT + { + Text [ en-US ] = "Text"; + }; }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/uiconfig/scalc/ui/notebookbar.ui b/sc/uiconfig/scalc/ui/notebookbar.ui index fb2dbae1eb1e..7c6d70d6f14d 100644 --- a/sc/uiconfig/scalc/ui/notebookbar.ui +++ b/sc/uiconfig/scalc/ui/notebookbar.ui @@ -103,6 +103,51 @@ False cmd/lc_paste.png + + True + False + cmd/lc_protect.png + + + True + False + cmd/lc_sendtoback.png + + + True + False + cmd/lc_spelldialog.png + + + True + False + cmd/lc_spellonline.png + + + True + False + cmd/lc_splitwindow.png + + + True + False + cmd/lc_thesaurus.png + + + True + False + cmd/lc_togglesheetgrid.png + + + True + False + cmd/lc_protect.png + + + True + False + cmd/lc_zoom.png + True False @@ -960,25 +1005,23 @@ False vertical - + True False - True - Select a category of contents. - Select a category of contents. - True - - General - Number - Percent - Currency - Date - Time - Scientific - Fraction - Boolean Value - Text - + False + + + False + True + False + .uno:NumberFormatType + True + + + False + True + + False @@ -987,7 +1030,7 @@ - + True False False @@ -2775,49 +2818,4 @@ - - True - False - cmd/lc_protect.png - - - True - False - cmd/lc_sendtoback.png - - - True - False - cmd/lc_spelldialog.png - - - True - False - cmd/lc_spellonline.png - - - True - False - cmd/lc_splitwindow.png - - - True - False - cmd/lc_thesaurus.png - - - True - False - cmd/lc_togglesheetgrid.png - - - True - False - cmd/lc_protect.png - - - True - False - cmd/lc_zoom.png - -- cgit