1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef _SFXVIEWFRM_HXX
20 #define _SFXVIEWFRM_HXX
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>
36 #include <tools/svborder.hxx>
60 #ifndef SFX_DECL_OBJECTSHELL_DEFINED
61 #define SFX_DECL_OBJECTSHELL_DEFINED
62 SV_DECL_REF(SfxObjectShell
)
65 //========================================================================
66 DBG_NAMEEX(SfxViewFrame
)
67 class SFX2_DLLPUBLIC SfxViewFrame
: public SfxShell
, public SfxListener
69 struct SfxViewFrame_Impl
* pImp
;
71 SfxObjectShellRef xObjSh
;
72 SfxDispatcher
* pDispatcher
;
73 SfxBindings
* pBindings
;
74 sal_uInt16 nAdjustPosPixelLock
;
78 SAL_DLLPRIVATE
void Construct_Impl( SfxObjectShell
*pObjSh
=NULL
);
82 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
);
85 SAL_DLLPRIVATE
void KillDispatcher_Impl();
88 virtual ~SfxViewFrame();
91 SfxViewFrame( SfxFrame
& rFrame
, SfxObjectShell
*pDoc
= NULL
);
94 SFX_DECL_INTERFACE(SFX_INTERFACE_SFXVIEWFRM
)
96 static void SetViewFrame( SfxViewFrame
* );
98 static SfxViewFrame
* LoadHiddenDocument( SfxObjectShell
& i_rDoc
, const sal_uInt16 i_nViewId
);
99 static SfxViewFrame
* LoadDocument( SfxObjectShell
& i_rDoc
, const sal_uInt16 i_nViewId
);
100 static SfxViewFrame
* LoadDocumentIntoFrame( SfxObjectShell
& i_rDoc
, const SfxFrameItem
* i_pFrameItem
, const sal_uInt16 i_nViewId
= 0 );
101 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 );
102 static SfxViewFrame
* DisplayNewDocument( SfxObjectShell
& i_rDoc
, const SfxRequest
& i_rCreateDocRequest
, const sal_uInt16 i_nViewId
= 0 );
104 static SfxViewFrame
* Current();
105 static SfxViewFrame
* GetFirst( const SfxObjectShell
* pDoc
= 0, sal_Bool bOnlyVisible
= sal_True
);
106 static SfxViewFrame
* GetNext( const SfxViewFrame
& rPrev
, const SfxObjectShell
* pDoc
= 0, sal_Bool bOnlyVisible
= sal_True
);
108 static SfxViewFrame
* Get( const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XController
>& i_rController
, const SfxObjectShell
* i_pDoc
= NULL
);
110 void DoActivate(sal_Bool bMDI
, SfxViewFrame
*pOld
=NULL
);
111 void DoDeactivate(sal_Bool bMDI
, SfxViewFrame
*pOld
=NULL
);
113 SfxViewFrame
* GetParentViewFrame() const;
115 using SfxShell::GetDispatcher
;
116 SfxDispatcher
* GetDispatcher() { return pDispatcher
; }
117 SfxBindings
& GetBindings() { return *pBindings
; }
118 const SfxBindings
& GetBindings() const { return *pBindings
; }
119 Window
& GetWindow() const;
120 virtual void SetZoomFactor( const Fraction
&rZoomX
, const Fraction
&rZoomY
);
122 SfxProgress
* GetProgress() const;
124 SfxObjectShell
* GetObjectShell() const
127 void LockAdjustPosSizePixel()
128 { nAdjustPosPixelLock
++; }
129 void UnlockAdjustPosSizePixel()
130 { nAdjustPosPixelLock
--; }
131 void DoAdjustPosSizePixel( SfxViewShell
* pSh
,
132 const Point
&rPos
, const Size
&rSize
);
134 sal_Bool
IsVisible() const;
136 void Enable( sal_Bool bEnable
);
137 virtual sal_Bool
Close();
138 virtual void Activate( sal_Bool bUI
);
139 virtual void Deactivate( sal_Bool bUI
);
142 virtual long DdeExecute( const String
& rCmd
);
143 virtual long DdeGetData( const String
& rItem
,
144 const String
& rMimeType
,
145 ::com::sun::star::uno::Any
& rValue
);
146 virtual long DdeSetData( const String
& rItem
,
147 const String
& rMimeType
,
148 const ::com::sun::star::uno::Any
& rValue
);
149 virtual ::sfx2::SvLinkSource
* DdeCreateLinkSource( const String
& rItem
);
153 static void ActivateToolPanel( const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
>& i_rFrame
, const OUString
& i_rPanelURL
);
155 /// is the new sidebar enabled for the app as a whole ?
156 static bool IsSidebarEnabled();
159 SAL_DLLPRIVATE
virtual sal_Bool
SetBorderPixelImpl( const SfxViewShell
*pSh
, const SvBorder
&rBorder
);
160 SAL_DLLPRIVATE
virtual const SvBorder
& GetBorderPixelImpl( const SfxViewShell
*pSh
) const;
161 SAL_DLLPRIVATE
virtual void InvalidateBorderImpl( const SfxViewShell
*pSh
);
163 virtual SfxObjectShell
* GetObjectShell();
164 sal_uInt16
GetCurViewId() const;
165 SfxFrame
& GetFrame() const;
166 SfxViewFrame
* GetTopViewFrame() const;
169 sal_uIntPtr
GetFrameType() const
170 { return GetFrame().GetFrameType(); }
171 SfxFrame
& GetTopFrame() const
172 { return GetFrame().GetTopFrame(); }
173 void GetTargetList( TargetList
& rList
) const
174 { GetFrame().GetTargetList( rList
); }
175 void CancelTransfers()
176 { GetFrame().CancelTransfers(); }
178 void SetModalMode( sal_Bool
);
179 sal_Bool
IsInModalMode() const;
180 void Resize(sal_Bool bForce
=sal_False
);
182 void SetChildWindow(sal_uInt16 nId
, sal_Bool bVisible
, sal_Bool bSetFocus
=sal_True
);
183 void ToggleChildWindow(sal_uInt16
);
184 sal_Bool
HasChildWindow(sal_uInt16
);
185 sal_Bool
KnowsChildWindow(sal_uInt16
);
186 void ShowChildWindow(sal_uInt16
,sal_Bool bVisible
=sal_True
);
187 SfxChildWindow
* GetChildWindow(sal_uInt16
);
188 void ChildWindowExecute(SfxRequest
&);
189 void ChildWindowState(SfxItemSet
&);
191 /** Append a new InfoBar (see https://wiki.documentfoundation.org/Design/Whiteboards/Infobar).
193 The buttons will be added from Right to Left at the right of the info bar. The parent, size
194 and position of each button will be changed: only the width will remain unchanged.
196 void AppendInfoBar( const OUString
& sId
, const OUString
& sMessage
, std::vector
< PushButton
* > aButtons
);
197 void RemoveInfoBar( const OUString
& sId
);
199 SAL_DLLPRIVATE
void SetDowning_Impl();
200 SAL_DLLPRIVATE
void GetDocNumber_Impl();
201 SAL_DLLPRIVATE sal_Bool
IsDowning_Impl() const;
202 SAL_DLLPRIVATE
void SetViewShell_Impl( SfxViewShell
*pVSh
);
203 SAL_DLLPRIVATE
void ReleaseObjectShell_Impl();
205 SAL_DLLPRIVATE
void GetState_Impl( SfxItemSet
&rSet
);
206 SAL_DLLPRIVATE
void ExecReload_Impl( SfxRequest
&rReq
);
207 SAL_DLLPRIVATE
void StateReload_Impl( SfxItemSet
&rSet
);
208 SAL_DLLPRIVATE
void ExecView_Impl( SfxRequest
&rReq
);
209 SAL_DLLPRIVATE
void StateView_Impl( SfxItemSet
&rSet
);
210 SAL_DLLPRIVATE
void ExecHistory_Impl( SfxRequest
&rReq
);
211 SAL_DLLPRIVATE
void StateHistory_Impl( SfxItemSet
&rSet
);
212 SAL_DLLPRIVATE SfxViewFrame
* GetParentViewFrame_Impl() const;
213 SAL_DLLPRIVATE
void ForceOuterResize_Impl(sal_Bool bOn
=sal_True
);
214 SAL_DLLPRIVATE sal_Bool
IsResizeInToOut_Impl() const;
215 SAL_DLLPRIVATE sal_Bool
IsAdjustPosSizePixelLocked_Impl() const
216 { return nAdjustPosPixelLock
!= 0; }
217 SAL_DLLPRIVATE
void UpdateDocument_Impl();
219 SAL_DLLPRIVATE
void LockObjectShell_Impl(sal_Bool bLock
=sal_True
);
221 SAL_DLLPRIVATE
void MakeActive_Impl( sal_Bool bActivate
);
222 SAL_DLLPRIVATE
void SetQuietMode_Impl( sal_Bool
);
223 SAL_DLLPRIVATE
const Size
& GetMargin_Impl() const;
224 SAL_DLLPRIVATE
void SetActiveChildFrame_Impl( SfxViewFrame
* );
225 SAL_DLLPRIVATE SfxViewFrame
* GetActiveChildFrame_Impl() const;
226 SAL_DLLPRIVATE String
GetActualPresentationURL_Impl() const;
227 SAL_DLLPRIVATE
void MiscExec_Impl(SfxRequest
&);
228 SAL_DLLPRIVATE
void MiscState_Impl(SfxItemSet
&);
229 SAL_DLLPRIVATE SfxWorkWindow
* GetWorkWindow_Impl( sal_uInt16 nId
);
230 SAL_DLLPRIVATE
void AddDispatchMacroToBasic_Impl(const OUString
& sMacro
);
232 SAL_DLLPRIVATE
void Exec_Impl(SfxRequest
&);
233 SAL_DLLPRIVATE
void INetExecute_Impl(SfxRequest
&);
234 SAL_DLLPRIVATE
void INetState_Impl(SfxItemSet
&);
236 SAL_DLLPRIVATE
void SetCurViewId_Impl( const sal_uInt16 i_nID
);
237 SAL_DLLPRIVATE
void ActivateToolPanel_Impl( const OUString
& i_rPanelURL
);
240 SAL_DLLPRIVATE sal_Bool
SwitchToViewShell_Impl( sal_uInt16 nNo
, sal_Bool bIsIndex
= sal_False
);
241 SAL_DLLPRIVATE
void PopShellAndSubShells_Impl( SfxViewShell
& i_rViewShell
);
242 SAL_DLLPRIVATE
void SaveCurrentViewData_Impl( const sal_uInt16 i_nNewViewId
);
244 /** loads the given existing document into the given frame
246 This is done using the XComponentLoader interface of the frame, so the SFX document loader is invoked.
251 the frame to load the document into
253 the arguments to pass to the component loader. If this sequence is empty, then the current arguments of the
254 model will be obtained, and passed to the loader. This ensures that any arguments in the model will be preserved,
255 instead of being reset.
257 the ID of the view to create
259 if something goes wrong. The caller is responsible for handling this.
261 SAL_DLLPRIVATE
static SfxViewShell
* LoadViewIntoFrame_Impl(
262 const SfxObjectShell
& i_rDoc
,
263 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
>& i_rFrame
,
264 const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>& i_rLoadArgs
,
265 const sal_uInt16 i_nViewId
,
269 /** loads the given existing document into the given frame
271 This is done using the XComponentLoader interface of the frame, so the SFX document loader is invoked.
273 If no frame is given, a blank top level frame is created.
275 If anything fails during the process, as much as possible is cleaned up.
280 the frame to load the document into. Might be <NULL/>, in which case a new frame is created.
282 the ID of the view to create
284 SAL_DLLPRIVATE
static SfxViewFrame
* LoadViewIntoFrame_Impl_NoThrow(
285 const SfxObjectShell
& i_rDoc
,
286 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
>& i_rFrame
,
287 const sal_uInt16 i_nViewId
,
292 //--------------------------------------------------------------------
294 class SFX2_DLLPUBLIC SfxViewFrameItem
: public SfxPoolItem
296 SfxViewFrame
* pFrame
;
300 SfxViewFrameItem( SfxViewFrame
*pViewFrame
):
304 SfxViewFrameItem( sal_uInt16 nWhichId
, SfxViewFrame
*pViewFrame
):
305 SfxPoolItem( nWhichId
),
309 virtual int operator==( const SfxPoolItem
& ) const;
310 virtual String
GetValueText() const;
311 virtual SfxPoolItem
* Clone( SfxItemPool
*pPool
= 0 ) const;
313 SfxViewFrame
* GetFrame() const
317 class SfxVerbListItem
: public SfxPoolItem
319 com::sun::star::uno::Sequence
< com::sun::star::embed::VerbDescriptor
> aVerbs
;
323 SfxVerbListItem( sal_uInt16 nWhichId
= SID_OBJECT
) :
324 SfxPoolItem( nWhichId
)
327 SfxVerbListItem( sal_uInt16 nWhichId
, const com::sun::star::uno::Sequence
< com::sun::star::embed::VerbDescriptor
>& );
329 virtual int operator==( const SfxPoolItem
& ) const;
330 virtual SfxPoolItem
* Clone( SfxItemPool
*pPool
= 0 ) const;
332 virtual bool QueryValue( com::sun::star::uno::Any
& rVal
, sal_uInt8 nMemberId
= 0 ) const;
333 const com::sun::star::uno::Sequence
< com::sun::star::embed::VerbDescriptor
>& GetVerbList() const { return aVerbs
; }
338 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */