LibreOffice Module sfx2 (master) 1
SidebarController.hxx
Go to the documentation of this file.
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#pragma once
20
21#include <memory>
22#include <sal/config.h>
23
26#include <sfx2/sidebar/Deck.hxx>
30#include <sfx2/viewfrm.hxx>
31
32#include <com/sun/star/beans/XPropertySet.hpp>
33#include <com/sun/star/beans/XPropertyChangeListener.hpp>
34#include <com/sun/star/frame/XStatusListener.hpp>
35#include <com/sun/star/frame/XFrameActionListener.hpp>
36#include <com/sun/star/ui/XContextChangeEventListener.hpp>
37#include <com/sun/star/ui/XSidebar.hpp>
38
39#include <optional>
41
42namespace com::sun::star::awt { class XWindow; }
43namespace com::sun::star::frame { class XDispatch; }
44namespace com::sun::star::ui { class XUIElement; }
45
47 css::ui::XContextChangeEventListener,
48 css::beans::XPropertyChangeListener,
49 css::ui::XSidebar,
50 css::frame::XStatusListener,
51 css::frame::XFrameActionListener
53
54class SfxSplitWindow;
55class SfxViewShell;
56
57namespace sfx2::sidebar {
58
59class DeckDescriptor;
60class SidebarDockingWindow;
61
64{
65public:
67 const SfxViewFrame* pViewFrame);
68 virtual ~SidebarController() override;
71
78 static SidebarController* GetSidebarControllerForFrame (
79 const css::uno::Reference<css::frame::XFrame>& rxFrame);
80
81 void registerSidebarForFrame(const css::uno::Reference<css::frame::XController>& xFrame);
82
83 void unregisterSidebarForFrame(const css::uno::Reference<css::frame::XController>& xFrame);
84
85 // ui::XContextChangeEventListener
86 virtual void SAL_CALL notifyContextChangeEvent (const css::ui::ContextChangeEventObject& rEvent) override;
87
88 // XEventListener
89 virtual void SAL_CALL disposing (const css::lang::EventObject& rEventObject) override;
90
91 // beans::XPropertyChangeListener
92 virtual void SAL_CALL propertyChange (const css::beans::PropertyChangeEvent& rEvent) override;
93
94 // frame::XStatusListener
95 virtual void SAL_CALL statusChanged (const css::frame::FeatureStateEvent& rEvent) override;
96
97 // frame::XFrameActionListener
98 virtual void SAL_CALL frameAction (const css::frame::FrameActionEvent& rEvent) override;
99
100 // ui::XSidebar
101 virtual void SAL_CALL requestLayout() override;
102
103 void NotifyResize();
104
111 const static sal_Int32 SwitchFlag_NoForce = 0x00;
112 const static sal_Int32 SwitchFlag_ForceSwitch = 0x01;
113 const static sal_Int32 SwitchFlag_ForceNewDeck = 0x02;
114 const static sal_Int32 SwitchFlag_ForceNewPanels = 0x02;
115
116 void OpenThenSwitchToDeck(std::u16string_view rsDeckId);
117 void OpenThenToggleDeck(const OUString& rsDeckId);
118
121 void RequestCloseDeck();
122
125 void RequestOpenDeck();
126
129 bool IsDeckVisible(std::u16string_view rsDeckId);
130
131 bool IsDeckOpen(const sal_Int32 nIndex = -1);
132
133 FocusManager& GetFocusManager() { return maFocusManager;}
134
135 ResourceManager* GetResourceManager() { return mpResourceManager.get();}
136
137 // std::unique_ptr<ResourceManager> GetResourceManager() { return mpResourceManager;}
138
139 const Context& GetCurrentContext() const { return maCurrentContext;}
140 bool IsDocumentReadOnly (void) const { return mbIsDocumentReadOnly;}
141
142 void SwitchToDeck(std::u16string_view rsDeckId);
143 void SwitchToDefaultDeck();
144 bool WasFloatingDeckClosed() const { return mbFloatingDeckClosed; }
145 void SetFloatingDeckClosed(bool bWasClosed) { mbFloatingDeckClosed = bWasClosed; }
146
147 void CreateDeck(std::u16string_view rDeckId);
148 void CreateDeck(std::u16string_view rDeckId, const Context& rContext, bool bForceCreate = false);
149
151 ResourceManager::PanelContextDescriptorContainer GetMatchingPanels(std::u16string_view rDeckId);
152
153 void notifyDeckTitle(std::u16string_view targetDeckId);
154
155 void updateModel(const css::uno::Reference<css::frame::XModel>& xModel);
156
157 void disposeDecks();
158
159 void FadeIn();
160 void FadeOut();
161
162 tools::Rectangle GetDeckDragArea() const;
163
164 css::uno::Reference<css::frame::XFrame> const & getXFrame() const {return mxFrame;}
165
166 sal_Int32 getMaximumWidth() const { return mnMaximumSidebarWidth; }
167 void setMaximumWidth(sal_Int32 nMaximumWidth) { mnMaximumSidebarWidth = nMaximumWidth; }
168
169 void saveDeckState();
170
171 void SyncUpdate();
172
173 // Used to avoid wrong context update when an embedded object activation is in progress
174 bool hasChartOrMathContextCurrently() const;
175
176 static SidebarController* GetSidebarControllerForView(const SfxViewShell* pViewShell);
177
178private:
179 SidebarController(SidebarDockingWindow* pParentWindow, const SfxViewFrame* pViewFrame);
180
184 css::uno::Reference<css::frame::XFrame> mxFrame;
188 css::uno::Reference<css::frame::XController> mxCurrentController;
196 css::uno::Reference<css::beans::XPropertySet> mxThemePropertySet;
197
206 ::std::optional<bool> mbIsDeckRequestedOpen;
207 ::std::optional<bool> mbIsDeckOpen;
208
210
216 css::uno::Reference<css::frame::XDispatch> mxReadOnlyModeDispatch;
228
229 DECL_DLLPRIVATE_LINK(WindowEventHandler, VclWindowEvent&, void);
232 void UpdateConfigurations();
233
234 css::uno::Reference<css::ui::XUIElement> CreateUIElement (
235 const css::uno::Reference<css::awt::XWindow>& rxWindow,
236 const OUString& rsImplementationURL,
237 const bool bWantsCanvas,
238 const Context& rContext);
239
240 void CreatePanels(
241 std::u16string_view rDeckId,
242 const Context& rContext);
243 std::shared_ptr<Panel> CreatePanel (
244 std::u16string_view rsPanelId,
245 weld::Widget* pParentWindow,
246 const bool bIsInitiallyExpanded,
247 const Context& rContext,
248 const VclPtr<Deck>& pDeck);
249
250 void SwitchToDeck (
251 const DeckDescriptor& rDeckDescriptor,
252 const Context& rContext);
253
254 void ShowPopupMenu (
255 weld::Menu& rMainMenu,
256 weld::Menu& rSubMenu,
257 const ::std::vector<TabBar::DeckMenuData>& rMenuData) const;
258 void PopulatePopupMenus(
259 weld::Menu& rMainButton,
260 weld::Menu& rSubMenu,
261 const ::std::vector<TabBar::DeckMenuData>& rMenuData) const;
262 DECL_DLLPRIVATE_LINK(OnMenuItemSelected, const OUString&, void);
263 DECL_DLLPRIVATE_LINK(OnSubMenuItemSelected, const OUString&, void);
264 void BroadcastPropertyChange();
265
270 bool CanModifyChildWindowWidth();
271
275 sal_Int32 SetChildWindowWidth (const sal_Int32 nNewWidth);
276
281 void UpdateTitleBarIcons();
282
283 void UpdateDeckOpenState();
284 void RestrictWidth (sal_Int32 nWidth);
285 SfxSplitWindow* GetSplitWindow();
286 void ProcessNewWidth (const sal_Int32 nNewWidth);
287 void UpdateCloseIndicator (const bool bIsIndicatorVisible);
288
293 void ShowPanel (const Panel& rPanel);
294
295 virtual void disposing(std::unique_lock<std::mutex>&) override;
296
297 std::unique_ptr<ResourceManager> mpResourceManager;
298
299};
300
301} // end of namespace sfx2::sidebar
302
303/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
comphelper::WeakComponentImplHelper< css::ui::XContextChangeEventListener, css::beans::XPropertyChangeListener, css::ui::XSidebar, css::frame::XStatusListener, css::frame::XFrameActionListener > SidebarControllerInterfaceBase
One SfxViewShell more or less represents one edit window for a document, there can be multiple ones f...
Definition: viewsh.hxx:165
A simple asynchronous call via Application::PostUserCall.
Concentrate all focus handling in this class.
Multiple panels form a single deck.
Definition: Panel.hxx:54
Read the content of the Sidebar.xcu file and provide access methods so that the sidebar can easily de...
std::vector< PanelContextDescriptor > PanelContextDescriptorContainer
std::vector< DeckContextDescriptor > DeckContextDescriptorContainer
::std::optional< bool > mbIsDeckRequestedOpen
Two flags control whether the deck is displayed or if only the tab bar remains visible.
css::uno::Reference< css::beans::XPropertySet > mxThemePropertySet
css::uno::Reference< css::frame::XFrame > mxFrame
sal_Int32 mnRequestedForceFlags
Use a combination of SwitchFlag_* as value.
css::uno::Reference< css::frame::XFrame > const & getXFrame() const
SidebarController & operator=(const SidebarController &)=delete
::std::optional< bool > mbIsDeckOpen
sal_Int32 mnSavedSidebarWidth
Before the deck is closed the sidebar width is saved into this variable, so that it can be restored w...
void setMaximumWidth(sal_Int32 nMaximumWidth)
css::uno::Reference< css::frame::XDispatch > mxReadOnlyModeDispatch
const Context & GetCurrentContext() const
sal_Int32 mnWidthOnSplitterButtonDown
When the user moves the splitter then we remember the width at that time.
void SetFloatingDeckClosed(bool bWasClosed)
SidebarController(const SidebarController &)=delete
DECL_DLLPRIVATE_LINK(OnSubMenuItemSelected, const OUString &, void)
std::unique_ptr< ResourceManager > mpResourceManager
VclPtr< vcl::Window > mpCloseIndicator
Control that is temporarily used as replacement for the deck to indicate that when the current mouse ...
DECL_DLLPRIVATE_LINK(OnMenuItemSelected, const OUString &, void)
VclPtr< SidebarDockingWindow > mpParentWindow
DECL_DLLPRIVATE_LINK(WindowEventHandler, VclWindowEvent &, void)
css::uno::Reference< css::frame::XController > mxCurrentController
VclPtr< SfxSplitWindow > mpSplitWindow
#define SFX2_DLLPUBLIC
Definition: dllapi.h:29
css::uno::Reference< css::deployment::XPackageRegistry > create(css::uno::Reference< css::deployment::XPackageRegistry > const &xRootRegistry, OUString const &context, OUString const &cachePath, css::uno::Reference< css::uno::XComponentContext > const &xComponentContext)