tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / sc / source / ui / cctrl / cbnumberformat.cxx
blobe340f3bf63f40db63015802768af5ce822103f81
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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 <sc.hrc>
30 ScNumberFormat::ScNumberFormat(vcl::Window* pParent)
31 : InterimItemWindow(pParent, u"modules/scalc/ui/numberbox.ui"_ustr, u"NumberBox"_ustr, true,
32 reinterpret_cast<sal_uInt64>(SfxViewShell::Current()))
33 , m_xWidget(m_xBuilder->weld_combo_box(u"numbertype"_ustr))
35 m_xWidget->append_text(ScResId(STR_GENERAL));
36 m_xWidget->append_text(ScResId(STR_NUMBER));
37 m_xWidget->append_text(ScResId(STR_PERCENT));
38 m_xWidget->append_text(ScResId(STR_CURRENCY));
39 m_xWidget->append_text(ScResId(STR_DATE));
40 m_xWidget->append_text(ScResId(STR_TIME));
41 m_xWidget->append_text(ScResId(STR_SCIENTIFIC));
42 m_xWidget->append_text(ScResId(STR_FRACTION));
43 m_xWidget->append_text(ScResId(STR_BOOLEAN_VALUE));
44 m_xWidget->append_text(ScResId(STR_TEXT));
46 m_xWidget->connect_changed(LINK(this, ScNumberFormat, NumFormatSelectHdl));
47 m_xWidget->connect_key_press(LINK(this, ScNumberFormat, KeyInputHdl));
49 SetSizePixel(m_xWidget->get_preferred_size());
52 void ScNumberFormat::dispose()
54 m_xWidget.reset();
55 InterimItemWindow::dispose();
58 ScNumberFormat::~ScNumberFormat() { disposeOnce(); }
60 void ScNumberFormat::GetFocus()
62 if (m_xWidget)
63 m_xWidget->grab_focus();
64 InterimItemWindow::GetFocus();
67 IMPL_STATIC_LINK(ScNumberFormat, NumFormatSelectHdl, weld::ComboBox&, rBox, void)
69 auto* pCurSh = SfxViewFrame::Current();
70 if (!pCurSh)
71 return;
73 SfxDispatcher* pDisp = pCurSh->GetBindings().GetDispatcher();
74 if (pDisp)
76 const sal_Int32 nVal = rBox.get_active();
77 SfxUInt16Item aItem(SID_NUMBER_TYPE_FORMAT, nVal);
78 pDisp->ExecuteList(SID_NUMBER_TYPE_FORMAT, SfxCallMode::RECORD, { &aItem });
80 pCurSh->GetWindow().GrabFocus();
84 IMPL_LINK(ScNumberFormat, KeyInputHdl, const KeyEvent&, rKEvt, bool)
86 return ChildKeyInput(rKEvt);
89 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */