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