LibreOffice Module sc (master) 1
cbnumberformat.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
20#include <cbnumberformat.hxx>
21#include <globstr.hrc>
22#include <scresid.hxx>
23#include <sfx2/dispatch.hxx>
24#include <sfx2/viewfrm.hxx>
25#include <sfx2/viewsh.hxx>
26#include <svl/intitem.hxx>
27#include <sc.hrc>
28
30 : InterimItemWindow(pParent, "modules/scalc/ui/numberbox.ui", "NumberBox", true,
31 reinterpret_cast<sal_uInt64>(SfxViewShell::Current()))
32 , m_xWidget(m_xBuilder->weld_combo_box("numbertype"))
33{
34 m_xWidget->append_text(ScResId(STR_GENERAL));
35 m_xWidget->append_text(ScResId(STR_NUMBER));
36 m_xWidget->append_text(ScResId(STR_PERCENT));
37 m_xWidget->append_text(ScResId(STR_CURRENCY));
38 m_xWidget->append_text(ScResId(STR_DATE));
39 m_xWidget->append_text(ScResId(STR_TIME));
40 m_xWidget->append_text(ScResId(STR_SCIENTIFIC));
41 m_xWidget->append_text(ScResId(STR_FRACTION));
42 m_xWidget->append_text(ScResId(STR_BOOLEAN_VALUE));
43 m_xWidget->append_text(ScResId(STR_TEXT));
44
45 m_xWidget->connect_changed(LINK(this, ScNumberFormat, NumFormatSelectHdl));
46 m_xWidget->connect_key_press(LINK(this, ScNumberFormat, KeyInputHdl));
47
48 SetSizePixel(m_xWidget->get_preferred_size());
49}
50
52{
53 m_xWidget.reset();
55}
56
58
60{
61 if (m_xWidget)
62 m_xWidget->grab_focus();
64}
65
66IMPL_STATIC_LINK(ScNumberFormat, NumFormatSelectHdl, weld::ComboBox&, rBox, void)
67{
68 auto* pCurSh = SfxViewFrame::Current();
69 if (!pCurSh)
70 return;
71
72 SfxDispatcher* pDisp = pCurSh->GetBindings().GetDispatcher();
73 if (pDisp)
74 {
75 const sal_Int32 nVal = rBox.get_active();
76 SfxUInt16Item aItem(SID_NUMBER_TYPE_FORMAT, nVal);
77 pDisp->ExecuteList(SID_NUMBER_TYPE_FORMAT, SfxCallMode::RECORD, { &aItem });
78
79 pCurSh->GetWindow().GrabFocus();
80 }
81}
82
83IMPL_LINK(ScNumberFormat, KeyInputHdl, const KeyEvent&, rKEvt, bool)
84{
85 return ChildKeyInput(rKEvt);
86}
87
88/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::unique_ptr< weld::Image > m_xWidget
IMPL_STATIC_LINK(ScNumberFormat, NumFormatSelectHdl, weld::ComboBox &, rBox, void)
IMPL_LINK(ScNumberFormat, KeyInputHdl, const KeyEvent &, rKEvt, bool)
virtual void dispose() override
virtual void GetFocus() override
virtual ~ScNumberFormat() override
std::unique_ptr< weld::ComboBox > m_xWidget
virtual void dispose() override
ScNumberFormat(vcl::Window *pParent)
virtual void GetFocus() override
SfxDispatcher * GetDispatcher() const
SfxBindings * GetBindings() const
const SfxPoolItem * ExecuteList(sal_uInt16 nSlot, SfxCallMode nCall, std::initializer_list< SfxPoolItem const * > args, std::initializer_list< SfxPoolItem const * > internalargs=std::initializer_list< SfxPoolItem const * >())
static SAL_WARN_UNUSED_RESULT SfxViewFrame * Current()
virtual void SetSizePixel(const Size &rNewSize)
OUString ScResId(TranslateId aId)
Definition: scdll.cxx:90