xref: /aoo41x/main/sfx2/inc/sfx2/viewfrm.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef _SFXVIEWFRM_HXX
28 #define _SFXVIEWFRM_HXX
29 
30 #include "sal/config.h"
31 #include "sfx2/dllapi.h"
32 #include "sal/types.h"
33 #include <svl/lstner.hxx>
34 #include <sfx2/module.hxx>
35 #include <sfx2/frame.hxx>
36 #include <sfx2/shell.hxx>
37 #include <sfx2/sfxsids.hrc>
38 #include <svl/poolitem.hxx>
39 #include <com/sun/star/frame/status/Verb.hpp>
40 #include <com/sun/star/frame/XModel.hpp>
41 #include <com/sun/star/frame/XController2.hpp>
42 
43 #include <tools/svborder.hxx>
44 
45 class SfxMacro;
46 class SvBorder;
47 class SfxDispatcher;
48 class SfxObjectShell;
49 class SfxBindings;
50 class SfxProgress;
51 class SvData;
52 class SfxViewShell;
53 class SvPseudoObject;
54 class SystemWindow;
55 class Fraction;
56 class Point;
57 class Size;
58 class SfxChildWindow;
59 
60 namespace sfx2
61 {
62 class SvLinkSource;
63 }
64 namespace svtools
65 {
66     class AsynchronLink;
67 }
68 
69 #ifndef SFX_DECL_OBJECTSHELL_DEFINED
70 #define SFX_DECL_OBJECTSHELL_DEFINED
71 SV_DECL_REF(SfxObjectShell)
72 #endif
73 
74 //========================================================================
75 DBG_NAMEEX(SfxViewFrame)
76 class SFX2_DLLPUBLIC SfxViewFrame: public SfxShell, public SfxListener
77 {
78 	struct SfxViewFrame_Impl*	pImp;
79 
80 	SfxObjectShellRef			xObjSh;
81 	SfxDispatcher*				pDispatcher;
82 	SfxBindings*				pBindings;
83 	sal_uInt16						nAdjustPosPixelLock;
84 
85 private:
86 #ifndef _SFX_HXX
87 	SAL_DLLPRIVATE void Construct_Impl( SfxObjectShell *pObjSh=NULL );
88 #endif
89 
90 protected:
91     virtual void            Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
92 
93 #ifndef _SFX_HXX
94 	SAL_DLLPRIVATE void KillDispatcher_Impl();
95 #endif
96 
97 	virtual                 ~SfxViewFrame();
98 
99 public:
100                             SfxViewFrame( SfxFrame& rFrame, SfxObjectShell *pDoc = NULL );
101 
102 							TYPEINFO();
103 							SFX_DECL_INTERFACE(SFX_INTERFACE_SFXVIEWFRM)
104 
105     static void             SetViewFrame( SfxViewFrame* );
106 
107     static SfxViewFrame*    LoadHiddenDocument( SfxObjectShell& i_rDoc, const sal_uInt16 i_nViewId );
108     static SfxViewFrame*    LoadDocument( SfxObjectShell& i_rDoc, const sal_uInt16 i_nViewId );
109     static SfxViewFrame*    LoadDocumentIntoFrame( SfxObjectShell& i_rDoc, const SfxFrameItem* i_pFrameItem, const sal_uInt16 i_nViewId = 0 );
110     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 );
111     static SfxViewFrame*    DisplayNewDocument( SfxObjectShell& i_rDoc, const SfxRequest& i_rCreateDocRequest, const sal_uInt16 i_nViewId = 0 );
112 
113     static SfxViewFrame*    Current();
114 	static SfxViewFrame*	GetFirst( const SfxObjectShell* pDoc = 0, sal_Bool bOnlyVisible = sal_True );
115 	static SfxViewFrame*    GetNext( const SfxViewFrame& rPrev, const SfxObjectShell* pDoc = 0, sal_Bool bOnlyVisible = sal_True );
116 	static sal_uInt16           Count();
117 
118     static SfxViewFrame*    Get( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController>& i_rController, const SfxObjectShell* i_pDoc = NULL );
119 
120 			void            DoActivate(sal_Bool bMDI, SfxViewFrame *pOld=NULL);
121 			void            DoDeactivate(sal_Bool bMDI, SfxViewFrame *pOld=NULL);
122 
123 	SfxViewFrame*			GetParentViewFrame() const;
124 
125 	using SfxShell::GetDispatcher;
126         SfxDispatcher*          GetDispatcher() { return pDispatcher; }
127 	SfxBindings&            GetBindings() { return *pBindings; }
128 	const SfxBindings&      GetBindings() const  { return *pBindings; }
129 	Window&         		GetWindow() const;
130 	virtual void            SetZoomFactor( const Fraction &rZoomX, const Fraction &rZoomY );
131 
132 	SfxProgress*            GetProgress() const;
133 #ifdef ENABLE_INIMANAGER//MUSTINI
134 	SfxIniManager*          GetIniManager() const;
135 #endif
136 
137 	SfxObjectShell* 		GetObjectShell() const
138 							{ return xObjSh; }
139 
140 	void					DoAdjustPosSize( SfxViewShell *pSh,
141 										const Point rPos, const Size &rSize );
142 	void                    LockAdjustPosSizePixel()
143 							{ nAdjustPosPixelLock++; }
144 	void                    UnlockAdjustPosSizePixel()
145 							{ nAdjustPosPixelLock--; }
146 	void                    DoAdjustPosSizePixel( SfxViewShell * pSh,
147 										const Point &rPos, const Size &rSize );
148 	void					Hide();
149 	void					Show();
150     sal_Bool                    IsVisible() const;
151 	void					ToTop();
152 	void					Enable( sal_Bool bEnable );
153 	virtual sal_Bool            Close();
154 	virtual void            Activate( sal_Bool bUI );
155 	virtual void            Deactivate( sal_Bool bUI );
156 
157 	// DDE-Interface
158 	virtual long			DdeExecute( const String& rCmd );
159 	virtual long			DdeGetData( const String& rItem,
160 										const String& rMimeType,
161 										::com::sun::star::uno::Any & rValue );
162 	virtual long			DdeSetData( const String& rItem,
163 										const String& rMimeType,
164 								const ::com::sun::star::uno::Any & rValue );
165 	virtual ::sfx2::SvLinkSource* 	DdeCreateLinkSource( const String& rItem );
166 
167 	void                    ShowStatusText( const String& rText );
168 	void                    HideStatusText();
169 
170 	String			        UpdateTitle();
171 
172     static void ActivateToolPanel( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& i_rFrame, const ::rtl::OUString& i_rPanelURL );
173 
174 	// interne Handler
175 	SAL_DLLPRIVATE virtual sal_Bool SetBorderPixelImpl( const SfxViewShell *pSh, const SvBorder &rBorder );
176 	SAL_DLLPRIVATE virtual const SvBorder& GetBorderPixelImpl( const SfxViewShell *pSh ) const;
177 	SAL_DLLPRIVATE virtual void InvalidateBorderImpl( const SfxViewShell *pSh );
178 
179 	virtual SfxObjectShell*	GetObjectShell();
180 	sal_uInt16					GetCurViewId() const;
181 	SfxFrame&				GetFrame() const;
182 	SfxViewFrame*			GetTopViewFrame() const;
183 
184 	sal_Bool					DoClose();
185 	sal_uIntPtr					GetFrameType() const
186 							{ return GetFrame().GetFrameType(); }
187 	SfxFrame&				GetTopFrame() const
188 							{ return GetFrame().GetTopFrame(); }
189 	void					GetTargetList( TargetList& rList ) const
190 							{ GetFrame().GetTargetList( rList ); }
191 	void                	CancelTransfers()
192 							{ GetFrame().CancelTransfers(); }
193 
194 	void					SetModalMode( sal_Bool );
195     sal_Bool                    IsInModalMode() const;
196     void                    Resize(sal_Bool bForce=sal_False);
197 
198     //void                        SetChildWindow(sal_uInt16 nId, sal_Bool bVisible );
199     void                        SetChildWindow(sal_uInt16 nId, sal_Bool bVisible, sal_Bool bSetFocus=sal_True);
200     void                        ToggleChildWindow(sal_uInt16);
201     sal_Bool                        HasChildWindow(sal_uInt16);
202     sal_Bool                        KnowsChildWindow(sal_uInt16);
203     void                        ShowChildWindow(sal_uInt16,sal_Bool bVisible=sal_True);
204     SfxChildWindow*             GetChildWindow(sal_uInt16);
205     void                        ChildWindowExecute(SfxRequest&);
206     void                        ChildWindowState(SfxItemSet&);
207 
208 //#if 0 // _SOLAR__PRIVATE
209 	SAL_DLLPRIVATE void SetDowning_Impl();
210 	SAL_DLLPRIVATE void GetDocNumber_Impl();
211 	SAL_DLLPRIVATE sal_Bool IsDowning_Impl() const;
212 	SAL_DLLPRIVATE void SetViewShell_Impl( SfxViewShell *pVSh );
213 	SAL_DLLPRIVATE void ReleaseObjectShell_Impl();
214 
215 	SAL_DLLPRIVATE void GetState_Impl( SfxItemSet &rSet );
216 	SAL_DLLPRIVATE void ExecReload_Impl( SfxRequest &rReq );
217 	SAL_DLLPRIVATE void ExecReload_Impl( SfxRequest &rReq, sal_Bool bAsync );
218 	SAL_DLLPRIVATE void StateReload_Impl( SfxItemSet &rSet );
219 	SAL_DLLPRIVATE void ExecView_Impl( SfxRequest &rReq );
220 	SAL_DLLPRIVATE void StateView_Impl( SfxItemSet &rSet );
221 	SAL_DLLPRIVATE void ExecHistory_Impl( SfxRequest &rReq );
222 	SAL_DLLPRIVATE void StateHistory_Impl( SfxItemSet &rSet );
223 	SAL_DLLPRIVATE SfxViewFrame* GetParentViewFrame_Impl() const;
224 	SAL_DLLPRIVATE void ForceOuterResize_Impl(sal_Bool bOn=sal_True);
225 	SAL_DLLPRIVATE sal_Bool IsResizeInToOut_Impl() const;
226 	SAL_DLLPRIVATE sal_Bool IsAdjustPosSizePixelLocked_Impl() const
227 							{ return nAdjustPosPixelLock != 0; }
228 	SAL_DLLPRIVATE void ForceInnerResize_Impl( sal_Bool bOn );
229 	SAL_DLLPRIVATE void UpdateDocument_Impl();
230 
231 	SAL_DLLPRIVATE void LockObjectShell_Impl(sal_Bool bLock=sal_True);
232 
233     SAL_DLLPRIVATE void MakeActive_Impl( sal_Bool bActivate );
234 	SAL_DLLPRIVATE void SetQuietMode_Impl( sal_Bool );
235 	SAL_DLLPRIVATE const Size& GetMargin_Impl() const;
236 	SAL_DLLPRIVATE void SetActiveChildFrame_Impl( SfxViewFrame* );
237 	SAL_DLLPRIVATE SfxViewFrame* GetActiveChildFrame_Impl() const;
238 	SAL_DLLPRIVATE String GetActualPresentationURL_Impl() const;
239 	SAL_DLLPRIVATE static void CloseHiddenFrames_Impl();
240     SAL_DLLPRIVATE void MiscExec_Impl(SfxRequest &);
241     SAL_DLLPRIVATE void MiscState_Impl(SfxItemSet &);
242     SAL_DLLPRIVATE SfxWorkWindow* GetWorkWindow_Impl( sal_uInt16 nId );
243     SAL_DLLPRIVATE void AddDispatchMacroToBasic_Impl(const ::rtl::OUString& sMacro);
244 
245 	SAL_DLLPRIVATE void Exec_Impl(SfxRequest &);
246 	SAL_DLLPRIVATE void INetExecute_Impl(SfxRequest &);
247 	SAL_DLLPRIVATE void INetState_Impl(SfxItemSet &);
248 
249     SAL_DLLPRIVATE void SetCurViewId_Impl( const sal_uInt16 i_nID );
250     SAL_DLLPRIVATE void ActivateToolPanel_Impl( const ::rtl::OUString& i_rPanelURL );
251 
252 //#endif
253 private:
254     SAL_DLLPRIVATE sal_Bool SwitchToViewShell_Impl( sal_uInt16 nNo, sal_Bool bIsIndex = sal_False );
255     SAL_DLLPRIVATE void PopShellAndSubShells_Impl( SfxViewShell& i_rViewShell );
256     SAL_DLLPRIVATE void SaveCurrentViewData_Impl( const sal_uInt16 i_nNewViewId );
257 
258     /** loads the given existing document into the given frame
259 
260         This is done using the XComponentLoader interface of the frame, so the SFX document loader is invoked.
261 
262         @param i_rDoc
263             the document to load
264         @param i_rFrame
265             the frame to load the document into
266         @param i_rLoadArgs
267             the arguments to pass to the component loader. If this sequence is empty, then the current arguments of the
268             model will be obtained, and passed to the loader. This ensures that any arguments in the model will be preserved,
269             instead of being reset.
270         @param i_nViewId
271             the ID of the view to create
272         @throws Exception
273             if something goes wrong. The caller is responsible for handling this.
274     */
275     SAL_DLLPRIVATE static SfxViewShell* LoadViewIntoFrame_Impl(
276                             const SfxObjectShell& i_rDoc,
277                             const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& i_rFrame,
278                             const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& i_rLoadArgs,
279                             const sal_uInt16 i_nViewId,
280                             const bool i_bHidden
281                         );
282 
283     /** loads the given existing document into the given frame
284 
285         This is done using the XComponentLoader interface of the frame, so the SFX document loader is invoked.
286 
287         If no frame is given, a blank top level frame is created.
288 
289         If anything fails during the process, as much as possible is cleaned up.
290 
291         @param i_rDoc
292             the document to load
293         @param i_rFrame
294             the frame to load the document into. Might be <NULL/>, in which case a new frame is created.
295         @param i_nViewId
296             the ID of the view to create
297     */
298     SAL_DLLPRIVATE static SfxViewFrame* LoadViewIntoFrame_Impl_NoThrow(
299                             const SfxObjectShell& i_rDoc,
300                             const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& i_rFrame,
301                             const sal_uInt16 i_nViewId,
302                             const bool i_bHidden
303                         );
304 };
305 
306 //--------------------------------------------------------------------
307 
308 class SFX2_DLLPUBLIC SfxViewFrameItem: public SfxPoolItem
309 {
310 	SfxViewFrame*			pFrame;
311 
312 public:
313 							TYPEINFO();
314 							SfxViewFrameItem( SfxViewFrame *pViewFrame ):
315 								SfxPoolItem( 0 ),
316 								pFrame( pViewFrame)
317 							{}
318 							SfxViewFrameItem( sal_uInt16 nWhichId, SfxViewFrame *pViewFrame ):
319 								SfxPoolItem( nWhichId ),
320 								pFrame( pViewFrame)
321 							{}
322 
323 	virtual int 			operator==( const SfxPoolItem& ) const;
324 	virtual String			GetValueText() const;
325 	virtual SfxPoolItem*	Clone( SfxItemPool *pPool = 0 ) const;
326 
327 	SfxViewFrame*			GetFrame() const
328 							{ return pFrame; }
329 };
330 
331 class SfxVerbListItem : public SfxPoolItem
332 {
333     com::sun::star::uno::Sequence < com::sun::star::embed::VerbDescriptor > aVerbs;
334 
335 public:
336                             TYPEINFO();
337                             SfxVerbListItem( sal_uInt16 nWhichId = SID_OBJECT ) :
338                                 SfxPoolItem( nWhichId )
339                             {}
340 
341                             SfxVerbListItem( sal_uInt16 nWhichId, const com::sun::star::uno::Sequence < com::sun::star::embed::VerbDescriptor >& );
342 
343 	virtual int 			operator==( const SfxPoolItem& ) const;
344 	virtual SfxPoolItem*	Clone( SfxItemPool *pPool = 0 ) const;
345 
346 	virtual	sal_Bool        QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const;
347     const com::sun::star::uno::Sequence < com::sun::star::embed::VerbDescriptor >& GetVerbList() const { return aVerbs; }
348 };
349 
350 #endif
351