summaryrefslogtreecommitdiff
path: root/sc/source/ui
diff options
context:
space:
mode:
authorSzymon Kłos <eszkadev@gmail.com>2016-05-27 22:36:43 +0200
committerSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2016-06-01 06:06:55 +0000
commitbf3f3a6bfb08c2d1a2c95f1c1cf62117e0002235 (patch)
tree43927ef5c4048e9c39abf81722fab2ec9ccc47c8 /sc/source/ui
parentcbf36dd473fdc9e8d8b78c9e9317836a7cbbc6c7 (diff)
notebookbar: working number format listbox
Change-Id: I1555934646148b9cd4164cbaaf09dcb9affe861e Reviewed-on: https://gerrit.libreoffice.org/25579 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'sc/source/ui')
-rw-r--r--sc/source/ui/app/scdll.cxx2
-rw-r--r--sc/source/ui/cctrl/cbnumberformat.cxx60
-rw-r--r--sc/source/ui/inc/cbnumberformat.hxx36
-rw-r--r--sc/source/ui/sidebar/NumberFormatControl.cxx77
-rw-r--r--sc/source/ui/src/globstr.src40
5 files changed, 215 insertions, 0 deletions
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 <svx/ParaLineSpacingPopup.hxx>
#include <svx/TextCharacterSpacingPopup.hxx>
#include <svx/TextUnderlinePopup.hxx>
+#include <NumberFormatControl.hxx>
#include <svtools/parhtml.hxx>
#include <sot/formats.hxx>
@@ -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 <cbnumberformat.hxx>
+#include "global.hxx"
+#include <globstr.hrc>
+#include <sfx2/dispatch.hxx>
+#include <svl/intitem.hxx>
+#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 <vcl/lstbox.hxx>
+
+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 <NumberFormatControl.hxx>
+#include <cbnumberformat.hxx>
+#include <svl/intitem.hxx>
+#include <svl/stritem.hxx>
+#include <vcl/toolbox.hxx>
+
+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<ScNumberFormat*>(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<const SfxInt16Item*>(pState);
+ sal_uInt16 nVal = pItem->GetValue();
+ pComboBox->SelectEntryPos(nVal);
+ break;
+ }
+
+ default:
+ break;
+ }
+}
+
+VclPtr<vcl::Window> ScNumberFormatControl::CreateItemWindow( vcl::Window *pParent )
+{
+ VclPtr<ScNumberFormat> pControl = VclPtr<ScNumberFormat>::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: */