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