/src/libreoffice/sc/source/ui/cctrl/cbnumberformat.cxx
Line | Count | Source |
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 <svl/itemset.hxx> |
28 | | #include <vcl/weld/Builder.hxx> |
29 | | #include <sc.hrc> |
30 | | |
31 | | ScNumberFormat::ScNumberFormat(vcl::Window* pParent) |
32 | 0 | : InterimItemWindow(pParent, u"modules/scalc/ui/numberbox.ui"_ustr, u"NumberBox"_ustr, true) |
33 | 0 | , m_xWidget(m_xBuilder->weld_combo_box(u"numbertype"_ustr)) |
34 | 0 | { |
35 | 0 | m_xWidget->append_text(ScResId(STR_GENERAL)); |
36 | 0 | m_xWidget->append_text(ScResId(STR_NUMBER)); |
37 | 0 | m_xWidget->append_text(ScResId(STR_PERCENT)); |
38 | 0 | m_xWidget->append_text(ScResId(STR_CURRENCY)); |
39 | 0 | m_xWidget->append_text(ScResId(STR_DATE)); |
40 | 0 | m_xWidget->append_text(ScResId(STR_TIME)); |
41 | 0 | m_xWidget->append_text(ScResId(STR_SCIENTIFIC)); |
42 | 0 | m_xWidget->append_text(ScResId(STR_FRACTION)); |
43 | 0 | m_xWidget->append_text(ScResId(STR_BOOLEAN_VALUE)); |
44 | 0 | m_xWidget->append_text(ScResId(STR_TEXT)); |
45 | |
|
46 | 0 | m_xWidget->connect_changed(LINK(this, ScNumberFormat, NumFormatSelectHdl)); |
47 | 0 | m_xWidget->connect_key_press(LINK(this, ScNumberFormat, KeyInputHdl)); |
48 | |
|
49 | 0 | SetSizePixel(m_xWidget->get_preferred_size()); |
50 | 0 | } Unexecuted instantiation: ScNumberFormat::ScNumberFormat(vcl::Window*) Unexecuted instantiation: ScNumberFormat::ScNumberFormat(vcl::Window*) |
51 | | |
52 | | void ScNumberFormat::dispose() |
53 | 0 | { |
54 | 0 | m_xWidget.reset(); |
55 | 0 | InterimItemWindow::dispose(); |
56 | 0 | } |
57 | | |
58 | 0 | ScNumberFormat::~ScNumberFormat() { disposeOnce(); } |
59 | | |
60 | | void ScNumberFormat::GetFocus() |
61 | 0 | { |
62 | 0 | if (m_xWidget) |
63 | 0 | m_xWidget->grab_focus(); |
64 | 0 | InterimItemWindow::GetFocus(); |
65 | 0 | } |
66 | | |
67 | | IMPL_STATIC_LINK(ScNumberFormat, NumFormatSelectHdl, weld::ComboBox&, rBox, void) |
68 | 0 | { |
69 | 0 | auto* pCurSh = SfxViewFrame::Current(); |
70 | 0 | if (!pCurSh) |
71 | 0 | return; |
72 | | |
73 | 0 | SfxDispatcher* pDisp = pCurSh->GetBindings().GetDispatcher(); |
74 | 0 | if (pDisp) |
75 | 0 | { |
76 | 0 | const sal_Int32 nVal = rBox.get_active(); |
77 | 0 | SfxUInt16Item aItem(SID_NUMBER_TYPE_FORMAT, nVal); |
78 | 0 | pDisp->ExecuteList(SID_NUMBER_TYPE_FORMAT, SfxCallMode::RECORD, { &aItem }); |
79 | |
|
80 | 0 | pCurSh->GetWindow().GrabFocus(); |
81 | 0 | } |
82 | 0 | } |
83 | | |
84 | | IMPL_LINK(ScNumberFormat, KeyInputHdl, const KeyEvent&, rKEvt, bool) |
85 | 0 | { |
86 | 0 | return ChildKeyInput(rKEvt); |
87 | 0 | } |
88 | | |
89 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |