/src/libreoffice/sc/source/ui/cctrl/SheetViewBox.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 | | |
10 | | #include <SheetViewBox.hxx> |
11 | | |
12 | | #include <sfx2/dispatch.hxx> |
13 | | #include <sfx2/viewfrm.hxx> |
14 | | #include <sfx2/viewsh.hxx> |
15 | | #include <svl/intitem.hxx> |
16 | | #include <svl/itemset.hxx> |
17 | | #include <vcl/weld/Builder.hxx> |
18 | | |
19 | | #include <globstr.hrc> |
20 | | #include <scresid.hxx> |
21 | | #include <sc.hrc> |
22 | | #include <docsh.hxx> |
23 | | #include <viewdata.hxx> |
24 | | |
25 | | #include <SheetViewManager.hxx> |
26 | | #include <SheetView.hxx> |
27 | | #include <SheetViewTypes.hxx> |
28 | | |
29 | | SheetViewBox::SheetViewBox(vcl::Window* pParent) |
30 | 0 | : InterimItemWindow(pParent, u"modules/scalc/ui/sheetviewbox.ui"_ustr, u"SheetViewBox"_ustr, |
31 | 0 | true) |
32 | 0 | , m_xWidget(m_xBuilder->weld_combo_box(u"sheetview_combobox"_ustr)) |
33 | 0 | { |
34 | 0 | m_xWidget->connect_changed(LINK(this, SheetViewBox, SelectHdl)); |
35 | 0 | m_xWidget->connect_key_press(LINK(this, SheetViewBox, KeyInputHdl)); |
36 | 0 | SetSizePixel(m_xWidget->get_preferred_size()); |
37 | 0 | } Unexecuted instantiation: SheetViewBox::SheetViewBox(vcl::Window*) Unexecuted instantiation: SheetViewBox::SheetViewBox(vcl::Window*) |
38 | | |
39 | | void SheetViewBox::dispose() |
40 | 0 | { |
41 | 0 | m_xWidget.reset(); |
42 | 0 | InterimItemWindow::dispose(); |
43 | 0 | } |
44 | | |
45 | 0 | SheetViewBox::~SheetViewBox() { disposeOnce(); } |
46 | | |
47 | | void SheetViewBox::GetFocus() |
48 | 0 | { |
49 | 0 | if (m_xWidget) |
50 | 0 | m_xWidget->grab_focus(); |
51 | 0 | InterimItemWindow::GetFocus(); |
52 | 0 | } |
53 | | |
54 | | void SheetViewBox::Update(ScViewData& rViewData) |
55 | 0 | { |
56 | 0 | m_xWidget->clear(); |
57 | 0 | m_xWidget->freeze(); |
58 | |
|
59 | 0 | OUString sActiveID = OUString::number(sc::DefaultSheetViewID); |
60 | 0 | m_xWidget->append(sActiveID, sc::SheetViewManager::defaultViewName()); |
61 | |
|
62 | 0 | auto pSheetManager = rViewData.GetCurrentSheetViewManager(); |
63 | |
|
64 | 0 | if (pSheetManager) |
65 | 0 | { |
66 | 0 | for (auto const& rSheetView : pSheetManager->iterateValidSheetViews()) |
67 | 0 | { |
68 | 0 | OUString sID = OUString::number(rSheetView.getID()); |
69 | 0 | if (rSheetView.getID() == rViewData.GetSheetViewID()) |
70 | 0 | sActiveID = sID; |
71 | 0 | m_xWidget->append(sID, rSheetView.GetName()); |
72 | 0 | } |
73 | 0 | } |
74 | 0 | m_xWidget->thaw(); |
75 | |
|
76 | 0 | m_xWidget->set_active_id(sActiveID); |
77 | 0 | } |
78 | | |
79 | | IMPL_STATIC_LINK(SheetViewBox, SelectHdl, weld::ComboBox&, rComboBox, void) |
80 | 0 | { |
81 | 0 | auto* pViewFrame = SfxViewFrame::Current(); |
82 | 0 | if (!pViewFrame) |
83 | 0 | return; |
84 | | |
85 | 0 | SfxDispatcher* pDispatcher = pViewFrame->GetBindings().GetDispatcher(); |
86 | 0 | if (!pDispatcher) |
87 | 0 | return; |
88 | | |
89 | 0 | const OUString sValue = rComboBox.get_active_id(); |
90 | 0 | SfxInt32Item aItem(FN_PARAM_1, sValue.toInt32()); |
91 | 0 | pDispatcher->ExecuteList(FID_SELECT_SHEET_VIEW, SfxCallMode::RECORD, { &aItem }); |
92 | |
|
93 | 0 | pViewFrame->GetWindow().GrabFocus(); |
94 | 0 | } |
95 | | |
96 | 0 | IMPL_LINK(SheetViewBox, KeyInputHdl, const KeyEvent&, rKEvt, bool) { return ChildKeyInput(rKEvt); } |
97 | | |
98 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |