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 INCLUDED_SFX2_VIEWSH_HXX
20 #define INCLUDED_SFX2_VIEWSH_HXX
22 #include <sal/config.h>
23 #include <sfx2/dllapi.h>
24 #include <sal/types.h>
25 #include <com/sun/star/embed/XEmbeddedObject.hpp>
26 #include <com/sun/star/frame/XController.hpp>
27 #include <com/sun/star/view/XRenderable.hpp>
28 #include <com/sun/star/uno/Reference.h>
29 #include <svl/lstner.hxx>
30 #include <com/sun/star/ui/XContextMenuInterceptor.hpp>
31 #include <com/sun/star/datatransfer/clipboard/XClipboardListener.hpp>
32 #include <com/sun/star/datatransfer/clipboard/XClipboardNotifier.hpp>
33 #include <cppuhelper/interfacecontainer.hxx>
34 #include <sfx2/shell.hxx>
35 #include <tools/gen.hxx>
36 #include <tools/errcode.hxx>
37 #include <vcl/jobset.hxx>
40 class SfxBaseController
;
54 class SfxFrameSetDescriptor
;
63 #define SFX_PRINTER_PRINTER 1 // without JOB SETUP => Temporary
64 #define SFX_PRINTER_JOBSETUP 2
65 #define SFX_PRINTER_OPTIONS 4
66 #define SFX_PRINTER_CHG_ORIENTATION 8
67 #define SFX_PRINTER_CHG_SIZE 16
68 #define SFX_PRINTER_ALL 31
70 #define SFX_PRINTER_CHG_ORIENTATION_FLAG 3
71 #define SFX_PRINTER_CHG_SIZE_FLAG 4
73 #define SFX_PRINTERROR_NONE 0
74 #define SFX_PRINTERROR_BUSY 1
76 // "Verified" using www.apple.com and Netscape 3.01
77 #define DEFAULT_MARGIN_WIDTH 8
78 #define DEFAULT_MARGIN_HEIGHT 12
80 //========================================================================
82 // @[SfxViewShell-Flags]
84 #define SFX_VIEW_HAS_PRINTOPTIONS 0x0010 /* Options-Button and Options-
85 Dialog in PrintDialog */
86 #define SFX_VIEW_CAN_PRINT 0x0020 /* Printing enabled without having
87 to create a Printer */
88 #define SFX_VIEW_NO_SHOW 0x0040 /* Window of the ViewShell shall
89 not be showed automatically */
90 #define SFX_VIEW_NO_NEWWINDOW 0x0100 /* Allow N View */
94 The SfxViewShell flags control the behavior of SfxViewShell for the
95 duration of its lifetime. They are defined in the constructor of
99 //=========================================================================
101 #define SFX_DECL_VIEWFACTORY(Class) \
103 static SfxViewFactory *pFactory; \
105 static SfxViewShell *CreateInstance(SfxViewFrame *pFrame, SfxViewShell *pOldView); \
106 static void RegisterFactory( sal_uInt16 nPrio = USHRT_MAX ); \
107 static SfxViewFactory&Factory() { return *pFactory; } \
108 static void InitFactory()
110 #define SFX_IMPL_NAMED_VIEWFACTORY(Class, AsciiViewName) \
111 SfxViewFactory* Class::pFactory; \
112 SfxViewShell* Class::CreateInstance(SfxViewFrame *pFrame, SfxViewShell *pOldView) \
113 { return new Class(pFrame, pOldView); } \
114 void Class::RegisterFactory( sal_uInt16 nPrio ) \
116 pFactory = new SfxViewFactory(&CreateInstance,nPrio,AsciiViewName);\
119 void Class::InitFactory()
121 #define SFX_VIEW_REGISTRATION(DocClass) \
122 DocClass::Factory().RegisterViewFactory( Factory() )
124 class SfxInPlaceClient
;
125 typedef ::std::vector
< SfxInPlaceClient
* > SfxInPlaceClientList
;
127 // -----------------------------------------------------------------------
128 class SFX2_DLLPUBLIC SfxViewShell
: public SfxShell
, public SfxListener
130 #ifdef INCLUDED_SFX2_VIEWSH_HXX
131 friend class SfxViewFrame
;
132 friend class SfxBaseController
;
133 friend class SfxPrinterController
;
136 struct SfxViewShell_Impl
* pImp
;
137 SfxInPlaceClientList
* pIPClientList
;
138 SfxViewFrame
* pFrame
;
141 sal_Bool bNoNewWindow
;
144 virtual void Activate(sal_Bool IsMDIActivate
);
145 virtual void Deactivate(sal_Bool IsMDIActivate
);
147 virtual void InnerResizePixel( const Point
&rOfs
, const Size
&rSize
);
148 virtual void OuterResizePixel( const Point
&rOfs
, const Size
&rSize
);
149 virtual void SetZoomFactor( const Fraction
&rZoomX
, const Fraction
&rZoomY
);
153 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
);
157 static SfxViewShell
* GetFirst( const TypeId
* pType
= 0, sal_Bool bOnlyVisible
= sal_True
);
158 static SfxViewShell
* GetNext( const SfxViewShell
& rPrev
,
159 const TypeId
* pType
= 0, sal_Bool bOnlyVisible
= sal_True
);
160 static SfxViewShell
* Current();
162 static SfxViewShell
* Get( const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XController
>& i_rController
);
164 // Initialize Constructors/Destructors
166 SFX_DECL_INTERFACE(SFX_INTERFACE_SFXVIEWSH
)
168 SfxViewShell( SfxViewFrame
*pFrame
, sal_uInt16 nFlags
= 0 );
169 virtual ~SfxViewShell();
171 SfxInPlaceClient
* GetIPClient() const;
172 SfxInPlaceClient
* GetUIActiveClient() const;
173 SfxInPlaceClient
* FindIPClient( const ::com::sun::star::uno::Reference
< ::com::sun::star::embed::XEmbeddedObject
>& xObj
, Window
*pObjParentWin
) const;
175 virtual ErrCode
DoVerb(long nVerb
);
177 virtual void OutplaceActivated( sal_Bool bActive
, SfxInPlaceClient
* pClient
);
178 virtual void InplaceActivating( SfxInPlaceClient
* pClient
);
179 virtual void InplaceDeactivated( SfxInPlaceClient
* pClient
);
180 virtual void UIActivating( SfxInPlaceClient
* pClient
);
181 virtual void UIDeactivated( SfxInPlaceClient
* pClient
);
183 void JumpToMark( const OUString
& rMark
);
184 void VisAreaChanged(const Rectangle
& rRect
);
187 virtual sal_uInt16
PrepareClose( sal_Bool bUI
= sal_True
, sal_Bool bForBrowsing
= sal_False
);
188 virtual OUString
GetSelectionText( bool bCompleteWords
= false );
189 virtual sal_Bool
HasSelection( sal_Bool bText
= sal_True
) const;
190 virtual SdrView
* GetDrawView() const;
192 SfxShell
* GetSubShell() const { return pSubShell
; }
193 void AddSubShell( SfxShell
& rShell
);
194 void RemoveSubShell( SfxShell
*pShell
=NULL
);
195 SfxShell
* GetSubShell( sal_uInt16
);
197 // Focus, KeyInput, Cursor
198 void GotFocus() const;
199 inline void LostFocus() const;
200 virtual void ShowCursor( bool bOn
= true );
201 virtual bool KeyInput( const KeyEvent
&rKeyEvent
);
205 Window
* GetWindow() const { return pWindow
; }
206 void SetWindow( Window
*pViewPort
);
207 virtual void AdjustPosSizePixel( const Point
&rOfs
, const Size
&rSize
);
208 const SvBorder
& GetBorderPixel() const;
209 void SetBorderPixel( const SvBorder
&rBorder
);
210 void InvalidateBorder();
211 inline SfxViewFrame
* GetViewFrame() const;
213 // Printing Interface
214 virtual SfxPrinter
* GetPrinter( sal_Bool bCreate
= sal_False
);
215 virtual sal_uInt16
SetPrinter( SfxPrinter
*pNewPrinter
, sal_uInt16 nDiffFlags
= SFX_PRINTER_ALL
, bool bIsAPI
=sal_False
);
216 virtual bool HasPrintOptionsPage() const;
217 virtual SfxTabPage
* CreatePrintOptionsPage( Window
*pParent
, const SfxItemSet
&rOptions
);
218 virtual JobSetup
GetJobSetup() const;
219 Printer
* GetActivePrinter() const;
222 virtual void WriteUserData( OUString
&, bool bBrowse
= false );
223 virtual void ReadUserData( const OUString
&, bool bBrowse
= false );
224 virtual void WriteUserDataSequence ( ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>&, sal_Bool bBrowse
= sal_False
);
225 virtual void ReadUserDataSequence ( const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>&, sal_Bool bBrowse
= sal_False
);
226 virtual void QueryObjAreaPixel( Rectangle
& rRect
) const;
228 virtual SfxObjectShell
* GetObjectShell();
229 /** retrieves the document which shall be considered the "current document" when the frame is active
231 The default implementation simply returns the XModel of the associated SfxObjectShell. You will rarely
232 need to overwrite this behavior.
234 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XModel
>
235 GetCurrentDocument() const;
236 /** forwards the current document, as returned by ->GetCurrentDocument, to SfxObjectShell::SetWorkingDocument
238 void SetCurrentDocument() const;
240 /** get an XRenderable instance that can render this document
242 virtual com::sun::star::uno::Reference
< com::sun::star::view::XRenderable
> GetRenderable();
245 virtual void MarginChanged();
246 const Size
& GetMargin() const;
247 void SetMargin( const Size
& );
248 void DisconnectAllClients();
249 virtual SfxFrame
* GetSmartSelf( SfxFrame
* pSelf
, SfxMedium
& rMedium
);
250 sal_Bool
NewWindowAllowed() const { return !bNoNewWindow
; }
251 void SetNewWindowAllowed( sal_Bool bSet
) { bNoNewWindow
= !bSet
; }
253 void SetController( SfxBaseController
* pController
);
254 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XController
>
257 sal_Bool
TryContextMenuInterception( Menu
& rIn
, const OUString
& rMenuIdentifier
, Menu
*& rpOut
, ::com::sun::star::ui::ContextMenuExecuteEvent aEvent
);
259 void ExecPrint( const com::sun::star::uno::Sequence
< com::sun::star::beans::PropertyValue
>&, sal_Bool
, sal_Bool
);
261 void AddRemoveClipboardListener( const com::sun::star::uno::Reference
< com::sun::star::datatransfer::clipboard::XClipboardListener
>&, sal_Bool
);
262 ::com::sun::star::uno::Reference
< ::com::sun::star::datatransfer::clipboard::XClipboardNotifier
> GetClipboardNotifier();
264 SAL_DLLPRIVATE SfxInPlaceClient
* GetUIActiveIPClient_Impl() const;
265 SAL_DLLPRIVATE
void AddContextMenuInterceptor_Impl( const ::com::sun::star::uno::Reference
< ::com::sun::star::ui::XContextMenuInterceptor
>& xInterceptor
);
266 SAL_DLLPRIVATE
void RemoveContextMenuInterceptor_Impl( const ::com::sun::star::uno::Reference
< ::com::sun::star::ui::XContextMenuInterceptor
>& xInterceptor
);
267 SAL_DLLPRIVATE
bool GlobalKeyInput_Impl( const KeyEvent
&rKeyEvent
);
269 SAL_DLLPRIVATE
void NewIPClient_Impl( SfxInPlaceClient
*pIPClient
)
270 { GetIPClientList_Impl(sal_True
)->push_back(pIPClient
); }
271 SAL_DLLPRIVATE
void IPClientGone_Impl( SfxInPlaceClient
*pIPClient
);
272 SAL_DLLPRIVATE SfxInPlaceClientList
* GetIPClientList_Impl( sal_Bool bCreate
= sal_True
) const;
273 SAL_DLLPRIVATE
void ResetAllClients_Impl( SfxInPlaceClient
*pIP
);
274 SAL_DLLPRIVATE
void DiscardClients_Impl();
276 SAL_DLLPRIVATE SfxPrinter
* SetPrinter_Impl( SfxPrinter
*pNewPrinter
);
277 SAL_DLLPRIVATE sal_Bool
IsShowView_Impl() const;
279 SAL_DLLPRIVATE
long HandleNotifyEvent_Impl( NotifyEvent
& rEvent
);
280 SAL_DLLPRIVATE sal_Bool
HasKeyListeners_Impl();
281 SAL_DLLPRIVATE sal_Bool
HasMouseClickListeners_Impl();
283 SAL_DLLPRIVATE SfxBaseController
* GetBaseController_Impl() const;
286 SAL_DLLPRIVATE
void ExecPrint_Impl(SfxRequest
&);
287 SAL_DLLPRIVATE
void ExecMisc_Impl(SfxRequest
&);
288 SAL_DLLPRIVATE
void GetState_Impl(SfxItemSet
&);
289 SAL_DLLPRIVATE SfxFrameSetDescriptor
* GetFrameSet_Impl() const;
290 SAL_DLLPRIVATE
void SetFrameSet_Impl(SfxFrameSetDescriptor
*);
291 SAL_DLLPRIVATE
void CheckIPClient_Impl( SfxInPlaceClient
*, const Rectangle
& );
292 SAL_DLLPRIVATE
void PushSubShells_Impl( sal_Bool bPush
=sal_True
);
293 SAL_DLLPRIVATE
void PopSubShells_Impl() { PushSubShells_Impl( sal_False
); }
294 SAL_DLLPRIVATE
void TakeOwnership_Impl();
295 SAL_DLLPRIVATE
void TakeFrameOwnership_Impl();
296 SAL_DLLPRIVATE sal_Bool
ExecKey_Impl(const KeyEvent
& aKey
);
299 //========================================================================
301 inline void SfxViewShell::LostFocus() const
305 This method has to be called by the application developer, if the edit
306 window has lost the focus. The SFx has for example the ability to turn off
307 the accelerator, so that the cursor keys, the Delete button, etc. work in
308 certain Floating-Windows, even though they are redefined by the
313 <StarView> unfortunatly does not provide the possibility to define
314 such events 'from the side'.
320 //------------------------------------------------------------------------
322 inline SfxViewFrame
* SfxViewShell::GetViewFrame() const
326 This method returns a pointer to the <SfxViewFrame> Instance in which
327 this SfxViewShell is displayed. This is the instance that was passed
328 on in the constructor. It is guaranteed that the returned pointer
329 points on the valid SfxViewFrame instance.
333 <SfxShell::GetFrame()const>
340 #endif // INCLUDED_SFX2_VIEWSH_HXX
343 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */