diff options
author | Szymon Kłos <eszkadev@gmail.com> | 2016-05-27 22:36:43 +0200 |
---|---|---|
committer | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2016-06-01 06:06:55 +0000 |
commit | bf3f3a6bfb08c2d1a2c95f1c1cf62117e0002235 (patch) | |
tree | 43927ef5c4048e9c39abf81722fab2ec9ccc47c8 /sc/source/ui/sidebar | |
parent | cbf36dd473fdc9e8d8b78c9e9317836a7cbbc6c7 (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/sidebar')
-rw-r--r-- | sc/source/ui/sidebar/NumberFormatControl.cxx | 77 |
1 files changed, 77 insertions, 0 deletions
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: */ |