calc: on editing invalidation of view with different zoom is wrong
[LibreOffice.git] / sc / source / ui / cctrl / cbnumberformat.cxx
blob29ab64e84e756a5bf8cb7302ca2f674de4caf15b
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 <sc.hrc>
29 ScNumberFormat::ScNumberFormat(vcl::Window* pParent)
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"))
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));
45 m_xWidget->connect_changed(LINK(this, ScNumberFormat, NumFormatSelectHdl));
46 m_xWidget->connect_key_press(LINK(this, ScNumberFormat, KeyInputHdl));
48 SetSizePixel(m_xWidget->get_preferred_size());
51 void ScNumberFormat::dispose()
53 m_xWidget.reset();
54 InterimItemWindow::dispose();
57 ScNumberFormat::~ScNumberFormat() { disposeOnce(); }
59 void ScNumberFormat::GetFocus()
61 if (m_xWidget)
62 m_xWidget->grab_focus();
63 InterimItemWindow::GetFocus();
66 IMPL_STATIC_LINK(ScNumberFormat, NumFormatSelectHdl, weld::ComboBox&, rBox, void)
68 auto* pCurSh = SfxViewFrame::Current();
69 if (!pCurSh)
70 return;
72 SfxDispatcher* pDisp = pCurSh->GetBindings().GetDispatcher();
73 if (pDisp)
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 });
79 pCurSh->GetWindow().GrabFocus();
83 IMPL_LINK(ScNumberFormat, KeyInputHdl, const KeyEvent&, rKEvt, bool)
85 return ChildKeyInput(rKEvt);
88 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */