/src/libreoffice/include/sfx2/viewfrm.hxx
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 | | #ifndef INCLUDED_SFX2_VIEWFRM_HXX |
20 | | #define INCLUDED_SFX2_VIEWFRM_HXX |
21 | | |
22 | | #include <memory> |
23 | | #include <sal/config.h> |
24 | | #include <sfx2/dllapi.h> |
25 | | #include <sal/types.h> |
26 | | #include <svl/lstner.hxx> |
27 | | #include <sfx2/frame.hxx> |
28 | | #include <sfx2/objsh.hxx> |
29 | | #include <sfx2/shell.hxx> |
30 | | #include <svl/poolitem.hxx> |
31 | | #include <vcl/svapp.hxx> |
32 | | |
33 | | namespace weld { |
34 | | class Button; |
35 | | class Window; |
36 | | } |
37 | | class SvBorder; |
38 | | class SfxDispatcher; |
39 | | class SfxBindings; |
40 | | class SfxProgress; |
41 | | class SfxViewShell; |
42 | | class Point; |
43 | | class Size; |
44 | | class SfxChildWindow; |
45 | | class SfxInfoBarWindow; |
46 | | enum class InfobarType; |
47 | | class CommandPopupHandler; |
48 | | |
49 | | class SFX2_DLLPUBLIC SfxViewFrame final : public SfxShell, public SfxListener |
50 | | { |
51 | | std::unique_ptr<struct SfxViewFrame_Impl> m_pImpl; |
52 | | |
53 | | SfxObjectShellRef m_xObjSh; |
54 | | std::unique_ptr<SfxDispatcher> m_pDispatcher; |
55 | | SfxBindings* m_pBindings; |
56 | | ImplSVHelpData* m_pHelpData; |
57 | | ImplSVWinData* m_pWinData; |
58 | | sal_uInt16 m_nAdjustPosPixelLock; |
59 | | |
60 | | std::unique_ptr<CommandPopupHandler> m_pCommandPopupHandler; |
61 | | |
62 | | SAL_DLLPRIVATE void Construct_Impl( SfxObjectShell *pObjSh ); |
63 | | SAL_DLLPRIVATE virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; |
64 | | DECL_DLLPRIVATE_LINK(GetInvolvedHandler, weld::Button&, void); |
65 | | DECL_DLLPRIVATE_LINK(DonationHandler, weld::Button&, void); |
66 | | DECL_DLLPRIVATE_LINK(WhatsNewHandler, weld::Button&, void); |
67 | | DECL_DLLPRIVATE_LINK(MacroButtonHandler, weld::Button&, void); |
68 | | DECL_DLLPRIVATE_LINK(SecurityButtonHandler, weld::Button&, void); |
69 | | DECL_DLLPRIVATE_LINK(EventButtonHandler, weld::Button&, void); |
70 | | DECL_DLLPRIVATE_LINK(ViewSignaturesButtonHandler, weld::Button&, void); |
71 | | DECL_DLLPRIVATE_LINK(SwitchReadOnlyHandler, weld::Button&, void); |
72 | | DECL_DLLPRIVATE_LINK(SignDocumentHandler, weld::Button&, void); |
73 | | DECL_DLLPRIVATE_LINK(HiddenTrackChangesHandler, weld::Button&, void); |
74 | | DECL_DLLPRIVATE_LINK(HyphenationMissingHandler, weld::Button&, void); |
75 | | DECL_DLLPRIVATE_LINK(RefreshMasterPasswordHdl, weld::Button&, void); |
76 | | DECL_DLLPRIVATE_STATIC_LINK(SfxViewFrame, HelpMasterPasswordHdl, weld::Button&, void); |
77 | | SAL_DLLPRIVATE void KillDispatcher_Impl(); |
78 | | |
79 | | SAL_DLLPRIVATE virtual ~SfxViewFrame() override; |
80 | | |
81 | | public: |
82 | | SAL_DLLPRIVATE SfxViewFrame( SfxFrame& rFrame, SfxObjectShell *pDoc ); |
83 | | |
84 | | SFX_DECL_INTERFACE(SFX_INTERFACE_SFXVIEWFRM) |
85 | | |
86 | | private: |
87 | | /// SfxInterface initializer. |
88 | | SAL_DLLPRIVATE static void InitInterface_Impl(); |
89 | | |
90 | | SAL_DLLPRIVATE void AppendContainsMacrosInfobar(); |
91 | | public: |
92 | | |
93 | | SAL_DLLPRIVATE static void SetViewFrame( SfxViewFrame* ); |
94 | | |
95 | | static SfxViewFrame* LoadHiddenDocument( SfxObjectShell const & i_rDoc, SfxInterfaceId i_nViewId ); |
96 | | static SfxViewFrame* LoadDocument( SfxObjectShell const & i_rDoc, SfxInterfaceId i_nViewId ); |
97 | | static SfxViewFrame* LoadDocumentIntoFrame( SfxObjectShell const & i_rDoc, const SfxFrameItem* i_pFrameItem, SfxInterfaceId i_nViewId ); |
98 | | static SfxViewFrame* LoadDocumentIntoFrame( SfxObjectShell const & i_rDoc, const css::uno::Reference< css::frame::XFrame >& i_rFrameItem ); |
99 | | static SfxViewFrame* DisplayNewDocument( SfxObjectShell const & i_rDoc, const SfxRequest& i_rCreateDocRequest ); |
100 | | |
101 | | SAL_RET_MAYBENULL static SfxViewFrame* Current(); |
102 | | SAL_RET_MAYBENULL static SfxViewFrame* GetFirst( const SfxObjectShell* pDoc = nullptr, bool bOnlyVisible = true ); |
103 | | SAL_RET_MAYBENULL static SfxViewFrame* GetNext( const SfxViewFrame& rPrev, const SfxObjectShell* pDoc = nullptr, bool bOnlyVisible = true ); |
104 | | |
105 | | SAL_RET_MAYBENULL SAL_DLLPRIVATE static SfxViewFrame* Get( const css::uno::Reference< css::frame::XController>& i_rController, const SfxObjectShell* i_pDoc ); |
106 | | |
107 | | SAL_DLLPRIVATE void DoActivate(bool bMDI); |
108 | | SAL_DLLPRIVATE void DoDeactivate(bool bMDI, SfxViewFrame const *pOld); |
109 | | |
110 | | using SfxShell::GetDispatcher; |
111 | 100k | SfxDispatcher* GetDispatcher() { return m_pDispatcher.get(); } |
112 | 341k | SfxBindings& GetBindings() { return *m_pBindings; } |
113 | 0 | const SfxBindings& GetBindings() const { return *m_pBindings; } |
114 | | vcl::Window& GetWindow() const; |
115 | | SAL_RET_MAYBENULL weld::Window* GetFrameWeld() const; |
116 | | |
117 | | SAL_DLLPRIVATE SfxProgress* GetProgress() const; |
118 | | |
119 | | void LockAdjustPosSizePixel() |
120 | 0 | { m_nAdjustPosPixelLock++; } |
121 | | void UnlockAdjustPosSizePixel() |
122 | 0 | { m_nAdjustPosPixelLock--; } |
123 | | SAL_DLLPRIVATE void DoAdjustPosSizePixel( SfxViewShell * pSh, |
124 | | const Point &rPos, const Size &rSize, |
125 | | bool inplaceEditModeChange ); |
126 | | void Show(); |
127 | | bool IsVisible() const; |
128 | | void ToTop(); |
129 | | void Enable( bool bEnable ); |
130 | | SAL_DLLPRIVATE void Close(); |
131 | | SAL_DLLPRIVATE virtual void Activate( bool bUI ) override; |
132 | | SAL_DLLPRIVATE virtual void Deactivate( bool bUI ) override; |
133 | | |
134 | | SAL_DLLPRIVATE void UpdateTitle(); |
135 | | |
136 | | // interne Handler |
137 | | SAL_DLLPRIVATE void SetBorderPixelImpl( const SfxViewShell *pSh, const SvBorder &rBorder ); |
138 | | SAL_DLLPRIVATE const SvBorder& GetBorderPixelImpl() const; |
139 | | SAL_DLLPRIVATE void InvalidateBorderImpl( const SfxViewShell *pSh ); |
140 | | |
141 | | virtual SfxObjectShell* GetObjectShell() override; |
142 | | SfxInterfaceId GetCurViewId() const; |
143 | | SfxFrame& GetFrame() const; |
144 | | SfxViewFrame* GetTopViewFrame() const; |
145 | | |
146 | | bool DoClose(); |
147 | | static void GetTargetList( TargetList& rList ) |
148 | 0 | { SfxFrame::GetDefaultTargetList( rList ); } |
149 | | |
150 | | SAL_DLLPRIVATE void SetModalMode( bool ); |
151 | | bool IsInModalMode() const; |
152 | | void Resize(bool bForce=false); |
153 | | |
154 | | void SetChildWindow(sal_uInt16 nId, bool bVisible, bool bSetFocus=true); |
155 | | void ToggleChildWindow(sal_uInt16); |
156 | | bool HasChildWindow(sal_uInt16); |
157 | | bool KnowsChildWindow(sal_uInt16); |
158 | | void ShowChildWindow(sal_uInt16,bool bVisible=true); |
159 | | SfxChildWindow* GetChildWindow(sal_uInt16); |
160 | | void ChildWindowExecute(SfxRequest&); |
161 | | SAL_DLLPRIVATE void ChildWindowState(SfxItemSet&); |
162 | | |
163 | | /** Append a new InfoBar (see https://wiki.documentfoundation.org/Design/Whiteboards/Infobar). |
164 | | |
165 | | The buttons will be added from Right to Left at the right of the info bar. The parent, size |
166 | | and position of each button will be changed: only the width will remain unchanged. |
167 | | */ |
168 | | VclPtr<SfxInfoBarWindow> AppendInfoBar(const OUString& sId, |
169 | | const OUString& sPrimaryMessage, |
170 | | const OUString& sSecondaryMessage, |
171 | | InfobarType aInfobarType, |
172 | | bool bShowCloseButton=true); |
173 | | void RemoveInfoBar(std::u16string_view sId); |
174 | | SAL_DLLPRIVATE void UpdateInfoBar(std::u16string_view sId, const OUString& sPrimaryMessage, |
175 | | const OUString& sSecondaryMessage, |
176 | | InfobarType eType); |
177 | | bool HasInfoBarWithID(std::u16string_view sId); |
178 | | void AppendReadOnlyInfobar(); |
179 | | SAL_DLLPRIVATE void HandleSecurityInfobar(const OUString& sSecondaryMessage); |
180 | | |
181 | | SAL_DLLPRIVATE void GetDocNumber_Impl(); |
182 | | SAL_DLLPRIVATE void SetViewShell_Impl( SfxViewShell *pVSh ); |
183 | | SAL_DLLPRIVATE void ReleaseObjectShell_Impl(); |
184 | | |
185 | | SAL_DLLPRIVATE void GetState_Impl( SfxItemSet &rSet ); |
186 | | void ExecReload_Impl(SfxRequest& rReq); |
187 | | SAL_DLLPRIVATE void StateReload_Impl( SfxItemSet &rSet ); |
188 | | SAL_DLLPRIVATE void ExecView_Impl( SfxRequest &rReq ); |
189 | | SAL_DLLPRIVATE void StateView_Impl( SfxItemSet &rSet ); |
190 | | SAL_DLLPRIVATE void ExecHistory_Impl( SfxRequest &rReq ); |
191 | | SAL_DLLPRIVATE void StateHistory_Impl( SfxItemSet &rSet ); |
192 | | SAL_DLLPRIVATE void ForceOuterResize_Impl(); |
193 | | SAL_DLLPRIVATE void UpdateDocument_Impl(); |
194 | | |
195 | | SAL_DLLPRIVATE void LockObjectShell_Impl(); |
196 | | |
197 | | SAL_DLLPRIVATE void MakeActive_Impl( bool bActivate ); |
198 | | SAL_DLLPRIVATE const Size& GetMargin_Impl() const; |
199 | | SAL_DLLPRIVATE const OUString & GetActualPresentationURL_Impl() const; |
200 | | SAL_DLLPRIVATE void MiscExec_Impl(SfxRequest &); |
201 | | SAL_DLLPRIVATE void MiscState_Impl(SfxItemSet &); |
202 | | SAL_DLLPRIVATE SfxWorkWindow* GetWorkWindow_Impl(); |
203 | | SAL_DLLPRIVATE void AddDispatchMacroToBasic_Impl(const OUString& sMacro); |
204 | | |
205 | | SAL_DLLPRIVATE void Exec_Impl(SfxRequest &); |
206 | | SAL_DLLPRIVATE void INetExecute_Impl(SfxRequest &); |
207 | | SAL_DLLPRIVATE void INetState_Impl(SfxItemSet &); |
208 | | |
209 | | SAL_DLLPRIVATE void SetCurViewId_Impl( const SfxInterfaceId i_nID ); |
210 | | |
211 | | private: |
212 | | SAL_DLLPRIVATE bool SwitchToViewShell_Impl( sal_uInt16 nNo, bool bIsIndex = false ); |
213 | | SAL_DLLPRIVATE void PopShellAndSubShells_Impl( SfxViewShell& i_rViewShell ); |
214 | | SAL_DLLPRIVATE void SaveCurrentViewData_Impl( const SfxInterfaceId i_nNewViewId ); |
215 | | |
216 | | /** loads the given existing document into the given frame |
217 | | |
218 | | This is done using the XComponentLoader interface of the frame, so the SFX document loader is invoked. |
219 | | |
220 | | @param i_rDoc |
221 | | the document to load |
222 | | @param i_rFrame |
223 | | the frame to load the document into |
224 | | @param i_rLoadArgs |
225 | | the arguments to pass to the component loader. If this sequence is empty, then the current arguments of the |
226 | | model will be obtained, and passed to the loader. This ensures that any arguments in the model will be preserved, |
227 | | instead of being reset. |
228 | | @param i_nViewId |
229 | | the ID of the view to create |
230 | | @throws Exception |
231 | | if something goes wrong. The caller is responsible for handling this. |
232 | | */ |
233 | | SAL_DLLPRIVATE static SfxViewShell* LoadViewIntoFrame_Impl( |
234 | | const SfxObjectShell& i_rDoc, |
235 | | const css::uno::Reference< css::frame::XFrame >& i_rFrame, |
236 | | const css::uno::Sequence< css::beans::PropertyValue >& i_rLoadArgs, |
237 | | const SfxInterfaceId i_nViewId, |
238 | | const bool i_bHidden |
239 | | ); |
240 | | |
241 | | /** loads the given existing document into the given frame |
242 | | |
243 | | This is done using the XComponentLoader interface of the frame, so the SFX document loader is invoked. |
244 | | |
245 | | If no frame is given, a blank top level frame is created. |
246 | | |
247 | | If anything fails during the process, as much as possible is cleaned up. |
248 | | |
249 | | @param i_rDoc |
250 | | the document to load |
251 | | @param i_rFrame |
252 | | the frame to load the document into. Might be <NULL/>, in which case a new frame is created. |
253 | | @param i_nViewId |
254 | | the ID of the view to create |
255 | | */ |
256 | | SAL_DLLPRIVATE static SfxViewFrame* LoadViewIntoFrame_Impl_NoThrow( |
257 | | const SfxObjectShell& i_rDoc, |
258 | | const css::uno::Reference< css::frame::XFrame >& i_rFrame, |
259 | | const SfxInterfaceId i_nViewId, |
260 | | const bool i_bHidden |
261 | | ); |
262 | | }; |
263 | | |
264 | | |
265 | | class SFX2_DLLPUBLIC SfxViewFrameItem final : public SfxPoolItem |
266 | | { |
267 | | SfxViewFrame* pFrame; |
268 | | |
269 | | public: |
270 | | DECLARE_ITEM_TYPE_FUNCTION(SfxViewFrameItem) |
271 | | SfxViewFrameItem( SfxViewFrame *pViewFrame ): |
272 | 0 | SfxPoolItem( 0 ), |
273 | 0 | pFrame( pViewFrame) |
274 | 0 | {} |
275 | | |
276 | | virtual bool operator==( const SfxPoolItem& ) const override; |
277 | | virtual SfxViewFrameItem* Clone( SfxItemPool *pPool = nullptr ) const override; |
278 | | |
279 | | SfxViewFrame* GetFrame() const |
280 | 0 | { return pFrame; } |
281 | | }; |
282 | | |
283 | | #endif |
284 | | |
285 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |