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