/src/libreoffice/sd/source/ui/dlg/NavigatorChildWindow.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 <NavigatorChildWindow.hxx> |
21 | | #include <navigatr.hxx> |
22 | | #include <app.hrc> |
23 | | #include <sfx2/bindings.hxx> |
24 | | #include <sfx2/dispatch.hxx> |
25 | | #include <sfx2/sfxsids.hrc> |
26 | | #include <svl/eitem.hxx> |
27 | | #include <svl/itemset.hxx> |
28 | | #include <drawdoc.hxx> |
29 | | #include <ViewShellBase.hxx> |
30 | | #include <DrawController.hxx> |
31 | | |
32 | | namespace sd { |
33 | | |
34 | | static void RequestNavigatorUpdate (SfxBindings const * pBindings) |
35 | 0 | { |
36 | 0 | if (pBindings != nullptr |
37 | 0 | && pBindings->GetDispatcher() != nullptr) |
38 | 0 | { |
39 | 0 | SfxBoolItem aItem (SID_NAVIGATOR_INIT, true); |
40 | 0 | pBindings->GetDispatcher()->ExecuteList( |
41 | 0 | SID_NAVIGATOR_INIT, |
42 | 0 | SfxCallMode::ASYNCHRON | SfxCallMode::RECORD, |
43 | 0 | { &aItem }); |
44 | 0 | } |
45 | 0 | } |
46 | | |
47 | | SdNavigatorFloat::SdNavigatorFloat(SfxBindings* _pBindings, SfxChildWindow* _pMgr, |
48 | | vcl::Window* _pParent, SfxChildWinInfo* pInfo) |
49 | 0 | : SfxNavigator(_pBindings, _pMgr, _pParent, pInfo) |
50 | 0 | , m_xNavWin(std::make_unique<SdNavigatorWin>(m_xContainer.get(), _pBindings, this)) |
51 | 0 | , m_bSetInitialFocusOnActivate(true) |
52 | 0 | { |
53 | 0 | m_xNavWin->SetUpdateRequestFunctor( |
54 | 0 | [_pBindings] () { return RequestNavigatorUpdate(_pBindings); }); |
55 | |
|
56 | 0 | SetMinOutputSizePixel(GetOptimalSize()); |
57 | | |
58 | | // Set the toolbox navigation button tooltips |
59 | | // Tunnel through the controller to obtain a ViewShellBase. |
60 | 0 | css::uno::Reference<css::frame::XFrame> xFrame = _pBindings->GetActiveFrame(); |
61 | 0 | ViewShellBase* pViewShellBase = nullptr; |
62 | 0 | rtl::Reference<sd::DrawController> pController |
63 | 0 | = dynamic_cast<sd::DrawController*>(xFrame->getController().get()); |
64 | 0 | if (pController != nullptr) |
65 | 0 | pViewShellBase = pController->GetViewShellBase(); |
66 | 0 | if (pViewShellBase == nullptr) |
67 | 0 | throw css::uno::RuntimeException(u"can not get ViewShellBase for frame"_ustr); |
68 | 0 | m_xNavWin->SetToolBoxToolTips(pViewShellBase->GetDocument()); |
69 | 0 | } Unexecuted instantiation: sd::SdNavigatorFloat::SdNavigatorFloat(SfxBindings*, SfxChildWindow*, vcl::Window*, SfxChildWinInfo*) Unexecuted instantiation: sd::SdNavigatorFloat::SdNavigatorFloat(SfxBindings*, SfxChildWindow*, vcl::Window*, SfxChildWinInfo*) |
70 | | |
71 | | void SdNavigatorFloat::Activate() |
72 | 0 | { |
73 | 0 | SfxNavigator::Activate(); |
74 | | // tdf#141708 defer grabbing focus to preferred widget until the float is |
75 | | // first activated |
76 | 0 | if (m_bSetInitialFocusOnActivate) |
77 | 0 | { |
78 | 0 | m_xNavWin->FirstFocus(); |
79 | 0 | m_bSetInitialFocusOnActivate = false; |
80 | 0 | } |
81 | 0 | } |
82 | | |
83 | | void SdNavigatorFloat::InitTreeLB(const SdDrawDocument* pDoc) |
84 | 0 | { |
85 | 0 | m_xNavWin->InitTreeLB(pDoc); |
86 | 0 | } |
87 | | |
88 | | void SdNavigatorFloat::dispose() |
89 | 0 | { |
90 | 0 | m_xNavWin.reset(); |
91 | 0 | SfxNavigator::dispose(); |
92 | 0 | } |
93 | | |
94 | | SdNavigatorFloat::~SdNavigatorFloat() |
95 | 0 | { |
96 | 0 | disposeOnce(); |
97 | 0 | } |
98 | | |
99 | | SFX_IMPL_DOCKINGWINDOW(SdNavigatorWrapper, SID_NAVIGATOR); |
100 | | |
101 | | SdNavigatorWrapper::SdNavigatorWrapper(vcl::Window *_pParent, sal_uInt16 nId, |
102 | | SfxBindings* pBindings, SfxChildWinInfo* pInfo) |
103 | 0 | : SfxNavigatorWrapper(_pParent, nId) |
104 | 0 | { |
105 | 0 | SetWindow(VclPtr<SdNavigatorFloat>::Create(pBindings, this, _pParent, pInfo)); |
106 | 0 | Initialize(); |
107 | 0 | } |
108 | | |
109 | | } // end of namespace sd |
110 | | |
111 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |