Line data Source code
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 <sal/config.h>
23 : #include <sfx2/dllapi.h>
24 : #include <sal/types.h>
25 : #include <svl/lstner.hxx>
26 : #include <sfx2/module.hxx>
27 : #include <sfx2/frame.hxx>
28 : #include <sfx2/shell.hxx>
29 : #include <sfx2/sfxsids.hrc>
30 : #include <svl/poolitem.hxx>
31 : #include <vcl/button.hxx>
32 : #include <com/sun/star/frame/status/Verb.hpp>
33 : #include <com/sun/star/frame/XModel.hpp>
34 : #include <com/sun/star/frame/XController2.hpp>
35 :
36 : #include <tools/svborder.hxx>
37 :
38 : class SvBorder;
39 : class SfxDispatcher;
40 : class SfxObjectShell;
41 : class SfxBindings;
42 : class SfxProgress;
43 : class SvData;
44 : class SfxViewShell;
45 : class SystemWindow;
46 : class Fraction;
47 : class Point;
48 : class Size;
49 : class SfxChildWindow;
50 : class SfxInfoBarWindow;
51 :
52 : namespace sfx2
53 : {
54 : class SvLinkSource;
55 : }
56 : namespace svtools
57 : {
58 : class AsynchronLink;
59 : }
60 :
61 : #ifndef SFX_DECL_OBJECTSHELL_DEFINED
62 : #define SFX_DECL_OBJECTSHELL_DEFINED
63 : typedef tools::SvRef<SfxObjectShell> SfxObjectShellRef;
64 : #endif
65 :
66 : class SFX2_DLLPUBLIC SfxViewFrame: public SfxShell, public SfxListener
67 : {
68 : struct SfxViewFrame_Impl* pImp;
69 :
70 : SfxObjectShellRef xObjSh;
71 : SfxDispatcher* pDispatcher;
72 : SfxBindings* pBindings;
73 : sal_uInt16 nAdjustPosPixelLock;
74 :
75 : private:
76 : SAL_DLLPRIVATE void Construct_Impl( SfxObjectShell *pObjSh=NULL );
77 :
78 : protected:
79 : virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) SAL_OVERRIDE;
80 :
81 : DECL_LINK( SwitchReadOnlyHandler, void * );
82 : SAL_DLLPRIVATE void KillDispatcher_Impl();
83 :
84 : virtual ~SfxViewFrame();
85 :
86 : public:
87 : SfxViewFrame( SfxFrame& rFrame, SfxObjectShell *pDoc = NULL );
88 :
89 : TYPEINFO_OVERRIDE();
90 208 : SFX_DECL_INTERFACE(SFX_INTERFACE_SFXVIEWFRM)
91 :
92 : private:
93 : /// SfxInterface initializer.
94 : static void InitInterface_Impl();
95 :
96 : public:
97 :
98 : static void SetViewFrame( SfxViewFrame* );
99 :
100 : static SfxViewFrame* LoadHiddenDocument( SfxObjectShell& i_rDoc, const sal_uInt16 i_nViewId );
101 : static SfxViewFrame* LoadDocument( SfxObjectShell& i_rDoc, const sal_uInt16 i_nViewId );
102 : static SfxViewFrame* LoadDocumentIntoFrame( SfxObjectShell& i_rDoc, const SfxFrameItem* i_pFrameItem, const sal_uInt16 i_nViewId = 0 );
103 : static SfxViewFrame* LoadDocumentIntoFrame( SfxObjectShell& i_rDoc, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& i_rFrameItem, const sal_uInt16 i_nViewId = 0 );
104 : static SfxViewFrame* DisplayNewDocument( SfxObjectShell& i_rDoc, const SfxRequest& i_rCreateDocRequest, const sal_uInt16 i_nViewId = 0 );
105 :
106 : static SfxViewFrame* Current();
107 : static SfxViewFrame* GetFirst( const SfxObjectShell* pDoc = 0, bool bOnlyVisible = true );
108 : static SfxViewFrame* GetNext( const SfxViewFrame& rPrev, const SfxObjectShell* pDoc = 0, bool bOnlyVisible = true );
109 :
110 : static SfxViewFrame* Get( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController>& i_rController, const SfxObjectShell* i_pDoc = NULL );
111 :
112 : void DoActivate(bool bMDI, SfxViewFrame *pOld=NULL);
113 : void DoDeactivate(bool bMDI, SfxViewFrame *pOld=NULL);
114 :
115 : SfxViewFrame* GetParentViewFrame() const;
116 :
117 : using SfxShell::GetDispatcher;
118 91592 : SfxDispatcher* GetDispatcher() { return pDispatcher; }
119 617662 : SfxBindings& GetBindings() { return *pBindings; }
120 : const SfxBindings& GetBindings() const { return *pBindings; }
121 : vcl::Window& GetWindow() const;
122 :
123 : SfxProgress* GetProgress() const;
124 :
125 20855 : SfxObjectShell* GetObjectShell() const
126 20855 : { return xObjSh; }
127 :
128 15 : void LockAdjustPosSizePixel()
129 15 : { nAdjustPosPixelLock++; }
130 15 : void UnlockAdjustPosSizePixel()
131 15 : { nAdjustPosPixelLock--; }
132 : void DoAdjustPosSizePixel( SfxViewShell * pSh,
133 : const Point &rPos, const Size &rSize );
134 : void Show();
135 : bool IsVisible() const;
136 : void ToTop();
137 : void Enable( bool bEnable );
138 : bool Close();
139 : virtual void Activate( bool bUI ) SAL_OVERRIDE;
140 : virtual void Deactivate( bool bUI ) SAL_OVERRIDE;
141 :
142 : void UpdateTitle();
143 :
144 : static void ActivateToolPanel( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& i_rFrame, const OUString& i_rPanelURL );
145 :
146 : // interne Handler
147 : SAL_DLLPRIVATE virtual bool SetBorderPixelImpl( const SfxViewShell *pSh, const SvBorder &rBorder );
148 : SAL_DLLPRIVATE virtual const SvBorder& GetBorderPixelImpl( const SfxViewShell *pSh ) const;
149 : SAL_DLLPRIVATE virtual void InvalidateBorderImpl( const SfxViewShell *pSh );
150 :
151 : virtual SfxObjectShell* GetObjectShell() SAL_OVERRIDE;
152 : sal_uInt16 GetCurViewId() const;
153 : SfxFrame& GetFrame() const;
154 : SfxViewFrame* GetTopViewFrame() const;
155 :
156 : bool DoClose();
157 6493 : sal_uIntPtr GetFrameType() const
158 6493 : { return GetFrame().GetFrameType(); }
159 7010 : SfxFrame& GetTopFrame() const
160 7010 : { return GetFrame().GetTopFrame(); }
161 0 : void GetTargetList( TargetList& rList ) const
162 0 : { GetFrame().GetTargetList( rList ); }
163 : void CancelTransfers()
164 : { GetFrame().CancelTransfers(); }
165 :
166 : void SetModalMode( bool );
167 : bool IsInModalMode() const;
168 : void Resize(bool bForce=false);
169 :
170 : void SetChildWindow(sal_uInt16 nId, bool bVisible, bool bSetFocus=true);
171 : void ToggleChildWindow(sal_uInt16);
172 : bool HasChildWindow(sal_uInt16);
173 : bool KnowsChildWindow(sal_uInt16);
174 : void ShowChildWindow(sal_uInt16,bool bVisible=true);
175 : SfxChildWindow* GetChildWindow(sal_uInt16);
176 : void ChildWindowExecute(SfxRequest&);
177 : void ChildWindowState(SfxItemSet&);
178 :
179 : /** Append a new InfoBar (see https://wiki.documentfoundation.org/Design/Whiteboards/Infobar).
180 :
181 : The buttons will be added from Right to Left at the right of the info bar. The parent, size
182 : and position of each button will be changed: only the width will remain unchanged.
183 : */
184 : SfxInfoBarWindow* AppendInfoBar(const OUString& sId, const OUString& sMessage);
185 : void RemoveInfoBar(const OUString& sId);
186 :
187 : SAL_DLLPRIVATE void SetDowning_Impl();
188 : SAL_DLLPRIVATE void GetDocNumber_Impl();
189 : SAL_DLLPRIVATE bool IsDowning_Impl() const;
190 : SAL_DLLPRIVATE void SetViewShell_Impl( SfxViewShell *pVSh );
191 : SAL_DLLPRIVATE void ReleaseObjectShell_Impl();
192 :
193 : SAL_DLLPRIVATE void GetState_Impl( SfxItemSet &rSet );
194 : SAL_DLLPRIVATE void ExecReload_Impl( SfxRequest &rReq );
195 : SAL_DLLPRIVATE void StateReload_Impl( SfxItemSet &rSet );
196 : SAL_DLLPRIVATE void ExecView_Impl( SfxRequest &rReq );
197 : SAL_DLLPRIVATE void StateView_Impl( SfxItemSet &rSet );
198 : SAL_DLLPRIVATE void ExecHistory_Impl( SfxRequest &rReq );
199 : SAL_DLLPRIVATE void StateHistory_Impl( SfxItemSet &rSet );
200 : SAL_DLLPRIVATE SfxViewFrame* GetParentViewFrame_Impl() const;
201 : SAL_DLLPRIVATE void ForceOuterResize_Impl(bool bOn=true);
202 : SAL_DLLPRIVATE bool IsResizeInToOut_Impl() const;
203 : SAL_DLLPRIVATE bool IsAdjustPosSizePixelLocked_Impl() const
204 : { return nAdjustPosPixelLock != 0; }
205 : SAL_DLLPRIVATE void UpdateDocument_Impl();
206 :
207 : SAL_DLLPRIVATE void LockObjectShell_Impl(bool bLock=true);
208 :
209 : SAL_DLLPRIVATE void MakeActive_Impl( bool bActivate );
210 : SAL_DLLPRIVATE void SetQuietMode_Impl( bool );
211 : SAL_DLLPRIVATE const Size& GetMargin_Impl() const;
212 : SAL_DLLPRIVATE void SetActiveChildFrame_Impl( SfxViewFrame* );
213 : SAL_DLLPRIVATE SfxViewFrame* GetActiveChildFrame_Impl() const;
214 : SAL_DLLPRIVATE OUString GetActualPresentationURL_Impl() const;
215 : SAL_DLLPRIVATE void MiscExec_Impl(SfxRequest &);
216 : SAL_DLLPRIVATE void MiscState_Impl(SfxItemSet &);
217 : SAL_DLLPRIVATE SfxWorkWindow* GetWorkWindow_Impl( sal_uInt16 nId );
218 : SAL_DLLPRIVATE void AddDispatchMacroToBasic_Impl(const OUString& sMacro);
219 :
220 : SAL_DLLPRIVATE void Exec_Impl(SfxRequest &);
221 : SAL_DLLPRIVATE void INetExecute_Impl(SfxRequest &);
222 : SAL_DLLPRIVATE void INetState_Impl(SfxItemSet &);
223 :
224 : SAL_DLLPRIVATE void SetCurViewId_Impl( const sal_uInt16 i_nID );
225 : SAL_DLLPRIVATE void ActivateToolPanel_Impl( const OUString& i_rPanelURL );
226 :
227 : private:
228 : SAL_DLLPRIVATE bool SwitchToViewShell_Impl( sal_uInt16 nNo, bool bIsIndex = false );
229 : SAL_DLLPRIVATE void PopShellAndSubShells_Impl( SfxViewShell& i_rViewShell );
230 : SAL_DLLPRIVATE void SaveCurrentViewData_Impl( const sal_uInt16 i_nNewViewId );
231 :
232 : /** loads the given existing document into the given frame
233 :
234 : This is done using the XComponentLoader interface of the frame, so the SFX document loader is invoked.
235 :
236 : @param i_rDoc
237 : the document to load
238 : @param i_rFrame
239 : the frame to load the document into
240 : @param i_rLoadArgs
241 : the arguments to pass to the component loader. If this sequence is empty, then the current arguments of the
242 : model will be obtained, and passed to the loader. This ensures that any arguments in the model will be preserved,
243 : instead of being reset.
244 : @param i_nViewId
245 : the ID of the view to create
246 : @throws Exception
247 : if something goes wrong. The caller is responsible for handling this.
248 : */
249 : SAL_DLLPRIVATE static SfxViewShell* LoadViewIntoFrame_Impl(
250 : const SfxObjectShell& i_rDoc,
251 : const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& i_rFrame,
252 : const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& i_rLoadArgs,
253 : const sal_uInt16 i_nViewId,
254 : const bool i_bHidden
255 : );
256 :
257 : /** loads the given existing document into the given frame
258 :
259 : This is done using the XComponentLoader interface of the frame, so the SFX document loader is invoked.
260 :
261 : If no frame is given, a blank top level frame is created.
262 :
263 : If anything fails during the process, as much as possible is cleaned up.
264 :
265 : @param i_rDoc
266 : the document to load
267 : @param i_rFrame
268 : the frame to load the document into. Might be <NULL/>, in which case a new frame is created.
269 : @param i_nViewId
270 : the ID of the view to create
271 : */
272 : SAL_DLLPRIVATE static SfxViewFrame* LoadViewIntoFrame_Impl_NoThrow(
273 : const SfxObjectShell& i_rDoc,
274 : const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& i_rFrame,
275 : const sal_uInt16 i_nViewId,
276 : const bool i_bHidden
277 : );
278 : };
279 :
280 :
281 :
282 0 : class SFX2_DLLPUBLIC SfxViewFrameItem: public SfxPoolItem
283 : {
284 : SfxViewFrame* pFrame;
285 :
286 : public:
287 : TYPEINFO_OVERRIDE();
288 0 : SfxViewFrameItem( SfxViewFrame *pViewFrame ):
289 : SfxPoolItem( 0 ),
290 0 : pFrame( pViewFrame)
291 0 : {}
292 0 : SfxViewFrameItem( sal_uInt16 nWhichId, SfxViewFrame *pViewFrame ):
293 : SfxPoolItem( nWhichId ),
294 0 : pFrame( pViewFrame)
295 0 : {}
296 :
297 : virtual bool operator==( const SfxPoolItem& ) const SAL_OVERRIDE;
298 : virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const SAL_OVERRIDE;
299 :
300 0 : SfxViewFrame* GetFrame() const
301 0 : { return pFrame; }
302 : };
303 :
304 : class SfxVerbListItem : public SfxPoolItem
305 : {
306 : com::sun::star::uno::Sequence < com::sun::star::embed::VerbDescriptor > aVerbs;
307 :
308 : public:
309 : TYPEINFO_OVERRIDE();
310 : SfxVerbListItem( sal_uInt16 nWhichId = SID_OBJECT ) :
311 : SfxPoolItem( nWhichId )
312 : {}
313 :
314 : SfxVerbListItem( sal_uInt16 nWhichId, const com::sun::star::uno::Sequence < com::sun::star::embed::VerbDescriptor >& );
315 :
316 : virtual bool operator==( const SfxPoolItem& ) const SAL_OVERRIDE;
317 : virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const SAL_OVERRIDE;
318 :
319 : virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const SAL_OVERRIDE;
320 : const com::sun::star::uno::Sequence < com::sun::star::embed::VerbDescriptor >& GetVerbList() const { return aVerbs; }
321 : };
322 :
323 : #endif
324 :
325 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|