LibreOffice Module sc (master) 1
NumberFormatControl.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
21#include <cbnumberformat.hxx>
22#include <svl/intitem.hxx>
23#include <vcl/toolbox.hxx>
24
25using namespace sc;
26
28
29ScNumberFormatControl::ScNumberFormatControl(sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox& rTbx)
30 : SfxToolBoxControl(nSlotId, nId, rTbx)
31{
32}
33
35{
36}
37
39 const SfxPoolItem* pState)
40{
42 ToolBox& rTbx = GetToolBox();
43 ScNumberFormat* pComboBox = static_cast<ScNumberFormat*>(rTbx.GetItemWindow(nId));
44
45 DBG_ASSERT( pComboBox, "Control not found!" );
46
47 if(SfxItemState::DISABLED == eState)
48 pComboBox->Disable();
49 else
50 pComboBox->Enable();
51
52 rTbx.EnableItem(nId, SfxItemState::DISABLED != eState);
53
54 switch(eState)
55 {
56 case SfxItemState::DEFAULT:
57 {
58 const SfxUInt16Item* pItem = static_cast<const SfxUInt16Item*>(pState);
59 sal_uInt16 nVal = pItem->GetValue();
60 pComboBox->set_active(nVal);
61 break;
62 }
63
64 default:
65 break;
66 }
67}
68
70{
72 pControl->Show();
73
74 return pControl;
75}
76
77/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SFX_IMPL_TOOLBOX_CONTROL(ScNumberFormatControl, SfxUInt16Item)
sal_uInt16 GetValue() const
void set_active(int nPos)
ToolBoxItemId GetId() const
ToolBox & GetToolBox() const
void EnableItem(ToolBoxItemId nItemId, bool bEnable=true)
vcl::Window * GetItemWindow(ToolBoxItemId nItemId) const
static VclPtr< reference_type > Create(Arg &&... arg)
virtual void StateChangedAtToolBoxControl(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem *pState) override
virtual ~ScNumberFormatControl() override
virtual VclPtr< InterimItemWindow > CreateItemWindow(vcl::Window *pParent) override
void Disable(bool bChild=true)
void Enable(bool bEnable=true, bool bChild=true)
#define DBG_ASSERT(sCon, aError)
CAUTION! The following defines must be in the same namespace as the respective type.
sal_Int16 nId
SfxItemState