xref: /aoo4110/main/sfx2/inc/sfx2/viewsh.hxx (revision b1cdbd2c)
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 _SFXVIEWSH_HXX
24 #define _SFXVIEWSH_HXX
25 
26 #include "sal/config.h"
27 #include "sfx2/dllapi.h"
28 #include "sal/types.h"
29 #include <com/sun/star/embed/XEmbeddedObject.hpp>
30 #include <com/sun/star/frame/XController.hpp>
31 #include <com/sun/star/view/XRenderable.hpp>
32 #include <com/sun/star/uno/Reference.h>
33 #include <svl/lstner.hxx>
34 #include <com/sun/star/ui/XContextMenuInterceptor.hpp>
35 #include <com/sun/star/datatransfer/clipboard/XClipboardListener.hpp>
36 #include <com/sun/star/datatransfer/clipboard/XClipboardNotifier.hpp>
37 #include <cppuhelper/interfacecontainer.hxx>
38 #include "shell.hxx"
39 #include <tools/gen.hxx>
40 #include <tools/errcode.hxx>
41 #include <vcl/jobset.hxx>
42 class SfxBaseController;
43 class Size;
44 class Fraction;
45 class Window;
46 class KeyEvent;
47 class WorkWindow;
48 class SvBorder;
49 class SdrView;
50 class SfxFrame;
51 class SfxMedium;
52 class SfxModule;
53 class SfxViewFrame;
54 class SfxItemPool;
55 class SfxTabPage;
56 class SfxPrintMonitor;
57 class SfxFrameSetDescriptor;
58 class Printer;
59 class SfxPrinter;
60 class SfxProgress;
61 class SvStringsDtor;
62 class SfxFrameItem;
63 class Dialog;
64 class Menu;
65 class NotifyEvent;
66 
67 #define SFX_PRINTER_PRINTER			 1 	// ohne JOBSETUP => temporaer
68 #define SFX_PRINTER_JOBSETUP    	 2
69 #define SFX_PRINTER_OPTIONS      	 4
70 #define SFX_PRINTER_CHG_ORIENTATION  8
71 #define SFX_PRINTER_CHG_SIZE 		16
72 #define SFX_PRINTER_ALL         	31
73 
74 #define SFX_PRINTER_CHG_ORIENTATION_FLAG  3
75 #define SFX_PRINTER_CHG_SIZE_FLAG 		  4
76 
77 #define SFX_PRINTERROR_NONE			 0
78 #define SFX_PRINTERROR_BUSY			 1
79 
80 enum SfxScrollingMode
81 {
82 	SCROLLING_NO,
83 	SCROLLING_YES,
84 	SCROLLING_AUTO,
85 	SCROLLING_DEFAULT
86 };
87 
88 // "Geeicht" mit www.apple.com und Netscape 3.01
89 #define DEFAULT_MARGIN_WIDTH 8
90 #define DEFAULT_MARGIN_HEIGHT 12
91 
92 //========================================================================
93 
94 // 	@[SfxViewShell-Flags]
95 
96 #define SFX_VIEW_HAS_PRINTOPTIONS    0x0010 /*  Options-Button und Options-
97 												Dialog im PrintDialog */
98 #define SFX_VIEW_CAN_PRINT			 0x0020 /*  enabled Printing ohne Printer
99 												erzeugen zu m"ussen */
100 #define SFX_VIEW_NO_SHOW			 0x0040 /*  Window der ViewShell darf nicht
101 												automatisch geshowed werden */
102 #define SFX_VIEW_NO_NEWWINDOW		0x0100		/* keine weitere View erlauben */
103 
104 /*	[Beschreibung]
105 
106 	Die SfxViewShell-Flags steuern das Verhalten der SfxViewShell f"ur die
107 	Dauer ihrer Lebenszeit. Sie werden im Konstruktor der <SfxViewShell>
108 	angegeben.
109 */
110 
111 //=========================================================================
112 
113 #define SFX_DECL_VIEWFACTORY(Class) \
114 private: \
115 	static SfxViewFactory *pFactory; \
116 public: \
117 	static SfxViewShell  *CreateInstance(SfxViewFrame *pFrame, SfxViewShell *pOldView); \
118 	static void 		  RegisterFactory( sal_uInt16 nPrio = USHRT_MAX ); \
119 	static SfxViewFactory&Factory() { return *pFactory; } \
120     static void           InitFactory()
121 
122 #define SFX_IMPL_NAMED_VIEWFACTORY(Class, AsciiViewName) \
123 	SfxViewFactory* Class::pFactory; \
124 	SfxViewShell* __EXPORT Class::CreateInstance(SfxViewFrame *pFrame, SfxViewShell *pOldView) \
125 	{ return new Class(pFrame, pOldView); } \
126     void Class::RegisterFactory( sal_uInt16 nPrio ) \
127 	{ \
128 		pFactory = new SfxViewFactory(&CreateInstance,&InitFactory,nPrio,AsciiViewName);\
129 		InitFactory(); \
130 	} \
131     void Class::InitFactory()
132 
133 #define SFX_VIEW_REGISTRATION(DocClass) \
134 			DocClass::Factory().RegisterViewFactory( Factory() )
135 
136 #define SFX_REGISTER_VIEW(ViewShellClass) \
137 			Factory().RegisterViewFactory( ViewShellClass::Factory() )
138 
139 class SfxInPlaceClient;
140 DECLARE_LIST( SfxInPlaceClientList, SfxInPlaceClient* )
141 
142 // -----------------------------------------------------------------------
143 class SFX2_DLLPUBLIC SfxViewShell: public SfxShell, public SfxListener
144 {
145 #ifdef _SFXVIEWSH_HXX
146 friend class SfxViewFrame;
147 friend class SfxPlugInFrame;
148 friend class SfxBaseController;
149 friend class SfxPrinterController;
150 #endif
151 
152 	struct SfxViewShell_Impl*	pImp;
153     SfxInPlaceClientList*       pIPClientList;
154 	SfxViewFrame*				pFrame;
155 	SfxShell*					pSubShell;
156 	Window*						pWindow;
157 	sal_Bool						bNoNewWindow;
158 
159 protected:
160 	virtual void                Activate(sal_Bool IsMDIActivate);
161 	virtual void                Deactivate(sal_Bool IsMDIActivate);
162 
163 	virtual Size                GetOptimalSizePixel() const;
164 
165 	virtual void				InnerResizePixel( const Point &rOfs, const Size &rSize );
166 	virtual void                OuterResizePixel( const Point &rOfs, const Size &rSize );
167 	virtual void                SetZoomFactor( const Fraction &rZoomX, const Fraction &rZoomY );
168 
169 	virtual void				Move();
170 
171 	virtual void                Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
172 
173 public:
174 	// Iteration
175 	static SfxViewShell*        GetFirst( const TypeId* pType = 0, sal_Bool bOnlyVisible = sal_True );
176 	static SfxViewShell*        GetNext( const SfxViewShell& rPrev,
177 										 const TypeId* pType = 0, sal_Bool bOnlyVisible = sal_True );
178 	static SfxViewShell*        Current();
179 
180     static SfxViewShell*        Get( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController>& i_rController );
181 
182 	// Ctoren/Dtoren Initialisierung
183 								TYPEINFO();
184 								SFX_DECL_INTERFACE(SFX_INTERFACE_SFXVIEWSH)
185 
186 								SfxViewShell( SfxViewFrame *pFrame, sal_uInt16 nFlags = 0 );
187 	virtual                     ~SfxViewShell();
188 
189     SfxInPlaceClient*           GetIPClient() const;
190     SfxInPlaceClient*           GetUIActiveClient() const;
191     SfxInPlaceClient*           FindIPClient( const ::com::sun::star::uno::Reference < ::com::sun::star::embed::XEmbeddedObject >&  xObj, Window *pObjParentWin ) const;
192 
193     virtual ErrCode             DoVerb(long nVerb);
194 
195 	virtual void				OutplaceActivated( sal_Bool bActive, SfxInPlaceClient* pClient );
196 	virtual void				InplaceActivating( SfxInPlaceClient* pClient );
197 	virtual void				InplaceDeactivated( SfxInPlaceClient* pClient );
198 	virtual void				UIActivating( SfxInPlaceClient* pClient );
199 	virtual void				UIDeactivated( SfxInPlaceClient* pClient );
200 
201 	virtual void				JumpToMark( const String& rMark );
202 	void						VisAreaChanged(const Rectangle& rRect);
203 
204 	// Verhaltens-Flags
205 	SfxScrollingMode			GetScrollingMode() const;
206 	void						SetScrollingMode( SfxScrollingMode eMode );
207 
208 	// Misc
209 	virtual sal_uInt16              PrepareClose( sal_Bool bUI = sal_True, sal_Bool bForBrowsing = sal_False );
210 	virtual String              GetSelectionText( sal_Bool bCompleteWords = sal_False );
211 	virtual sal_Bool				HasSelection( sal_Bool bText = sal_True ) const;
212 	virtual SdrView*			GetDrawView() const;
213 
214     void                        SetSubShell( SfxShell *pShell );
GetSubShell() const215 	SfxShell*                   GetSubShell() const { return pSubShell; }
216 	void						AddSubShell( SfxShell& rShell );
217 	void						RemoveSubShell( SfxShell *pShell=NULL );
218 	SfxShell*					GetSubShell( sal_uInt16 );
219 
220 	// Focus, KeyInput, Cursor
221 	void						GotFocus() const;
222 	inline void					LostFocus() const;
223 	virtual void				ShowCursor( FASTBOOL bOn = sal_True );
224 	virtual FASTBOOL			KeyInput( const KeyEvent &rKeyEvent );
225     sal_Bool                        Escape();
226 
227 	// Viewing Interface
GetWindow() const228 	Window*                     GetWindow() const { return pWindow; }
229 	void                        SetWindow( Window *pViewPort );
230 	virtual void				AdjustPosSizePixel( const Point &rOfs, const Size &rSize );
231 	const SvBorder&             GetBorderPixel() const;
232 	void                        SetBorderPixel( const SvBorder &rBorder );
233 	void						InvalidateBorder();
234 	inline SfxViewFrame*        GetViewFrame() const;
235 	void						AdjustVisArea(const Rectangle& rRect);
236 
237 	// Printing Interface
238 	virtual SfxPrinter*         GetPrinter( sal_Bool bCreate = sal_False );
239     virtual sal_uInt16              SetPrinter( SfxPrinter *pNewPrinter, sal_uInt16 nDiffFlags = SFX_PRINTER_ALL, bool bIsAPI=sal_False );
240 	virtual SfxTabPage*         CreatePrintOptionsPage( Window *pParent, const SfxItemSet &rOptions );
241 	void						LockPrinter( sal_Bool bLock = sal_True );
242 	sal_Bool					IsPrinterLocked() const;
243 	virtual JobSetup			GetJobSetup() const;
244 	Printer*                    GetActivePrinter() const;
245 
246 	// Workingset
247 	virtual void                WriteUserData( String&, sal_Bool bBrowse = sal_False );
248 	virtual void                ReadUserData( const String&, sal_Bool bBrowse = sal_False );
249     virtual void                WriteUserDataSequence ( ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue >&, sal_Bool bBrowse = sal_False );
250     virtual void                ReadUserDataSequence ( const ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue >&, sal_Bool bBrowse = sal_False );
251 	virtual void				QueryObjAreaPixel( Rectangle& rRect ) const;
252 
253 	virtual SfxObjectShell*		GetObjectShell();
254     /** retrieves the document which shall be considered the "current document" when the frame is active
255 
256         The default implementation simply returns the XModel of the associated SfxObjectShell. You will rarely
257         need to overwrite this behavior.
258     */
259     virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >
260                                 GetCurrentDocument() const;
261     /** forwards the current document, as returned by ->GetCurrentDocument, to SfxObjectShell::SetWorkingDocument
262     */
263     void                        SetCurrentDocument() const;
264 
265     /** get an XRenderable instance that can render this docuement
266     */
267     virtual com::sun::star::uno::Reference< com::sun::star::view::XRenderable > GetRenderable();
268 
269 
270 	virtual void				MarginChanged();
271 	const Size&					GetMargin() const;
272 	void						SetMargin( const Size& );
273 	void 						DisconnectAllClients();
274 	virtual SfxFrame*     		GetSmartSelf( SfxFrame* pSelf, SfxMedium& rMedium );
NewWindowAllowed() const275 	sal_Bool						NewWindowAllowed() const			{ return !bNoNewWindow; }
SetNewWindowAllowed(sal_Bool bSet)276 	void						SetNewWindowAllowed( sal_Bool bSet )	{ bNoNewWindow = !bSet; }
277 
278     void                        SetController( SfxBaseController* pController );
279     ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >
280 								GetController();
281 
282     ::cppu::OInterfaceContainerHelper& GetContextMenuInterceptors() const;
283     sal_Bool                        TryContextMenuInterception( Menu& rIn, const ::rtl::OUString& rMenuIdentifier, Menu*& rpOut, ::com::sun::star::ui::ContextMenuExecuteEvent aEvent );
284 
285 	void						SetAdditionalPrintOptions( const com::sun::star::uno::Sequence < com::sun::star::beans::PropertyValue >& );
286 	void						ExecPrint( const com::sun::star::uno::Sequence < com::sun::star::beans::PropertyValue >&, sal_Bool, sal_Bool );
287 
288 	void						AddRemoveClipboardListener( const com::sun::star::uno::Reference < com::sun::star::datatransfer::clipboard::XClipboardListener>&, sal_Bool );
289 	::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboardNotifier > GetClipboardNotifier();
290 
291 #if _SOLAR__PRIVATE
292     SAL_DLLPRIVATE SfxInPlaceClient* GetUIActiveIPClient_Impl() const;
293     SAL_DLLPRIVATE void AddContextMenuInterceptor_Impl( const ::com::sun::star::uno::Reference < ::com::sun::star::ui::XContextMenuInterceptor >& xInterceptor );
294     SAL_DLLPRIVATE void RemoveContextMenuInterceptor_Impl( const ::com::sun::star::uno::Reference < ::com::sun::star::ui::XContextMenuInterceptor >& xInterceptor );
295 	SAL_DLLPRIVATE bool GlobalKeyInput_Impl( const KeyEvent &rKeyEvent );
296 
NewIPClient_Impl(SfxInPlaceClient * pIPClient)297     SAL_DLLPRIVATE void NewIPClient_Impl( SfxInPlaceClient *pIPClient )
298                                 { GetIPClientList_Impl(sal_True)->Insert(pIPClient); }
IPClientGone_Impl(SfxInPlaceClient * pIPClient)299     SAL_DLLPRIVATE void IPClientGone_Impl( SfxInPlaceClient *pIPClient )
300                                 { GetIPClientList_Impl(sal_True)->Remove(pIPClient); }
301     SAL_DLLPRIVATE SfxInPlaceClientList* GetIPClientList_Impl( sal_Bool bCreate = sal_True ) const;
302     SAL_DLLPRIVATE void ResetAllClients_Impl( SfxInPlaceClient *pIP );
303 	SAL_DLLPRIVATE void DiscardClients_Impl();
304 	SAL_DLLPRIVATE sal_Bool PlugInsActive() const;
305 
306 	SAL_DLLPRIVATE SfxPrinter* SetPrinter_Impl( SfxPrinter *pNewPrinter );
307 	SAL_DLLPRIVATE sal_Bool IsShowView_Impl() const;
308 
309 	SAL_DLLPRIVATE long HandleNotifyEvent_Impl( NotifyEvent& rEvent );
310 	SAL_DLLPRIVATE sal_Bool HasKeyListeners_Impl();
311 	SAL_DLLPRIVATE sal_Bool HasMouseClickListeners_Impl();
312 
313     SAL_DLLPRIVATE SfxBaseController*   GetBaseController_Impl() const;
314 
315 	// Shell Interface
316 	SAL_DLLPRIVATE void ExecPrint_Impl(SfxRequest &);
317 	SAL_DLLPRIVATE void ExecMisc_Impl(SfxRequest &);
318 	SAL_DLLPRIVATE void GetState_Impl(SfxItemSet&);
319 	SAL_DLLPRIVATE SfxFrameSetDescriptor* GetFrameSet_Impl() const;
320 	SAL_DLLPRIVATE void SetFrameSet_Impl(SfxFrameSetDescriptor*);
321     SAL_DLLPRIVATE void CheckIPClient_Impl( SfxInPlaceClient*, const Rectangle& );
322 	SAL_DLLPRIVATE void PushSubShells_Impl( sal_Bool bPush=sal_True );
PopSubShells_Impl()323     SAL_DLLPRIVATE void PopSubShells_Impl() { PushSubShells_Impl( sal_False ); }
324 	SAL_DLLPRIVATE void TakeOwnerShip_Impl();
325     SAL_DLLPRIVATE void CheckOwnerShip_Impl();
326     SAL_DLLPRIVATE void TakeFrameOwnerShip_Impl();
327     SAL_DLLPRIVATE sal_Bool ExecKey_Impl(const KeyEvent& aKey);
328 #endif
329 };
330 
331 //========================================================================
332 
LostFocus() const333 inline void	SfxViewShell::LostFocus() const
334 
335 /*	[Beschreibung]
336 
337 	Diese Methode mu\s vom Applikationsentwickler gerufen werden, wenn
338 	das Edit-Window den Focus verloren hat. Der SFx hat so z.B. die
339 	M"oglichkeit, den Accelerator auszuschalten, damit in bestimmten
340 	Floating-Windows die Cursor-Tasten, die Delete-Taste etc. funktionieren,
341 	obwohl sie "uber den Accelerator umdefiniert sind.
342 
343 
344 	[Anmerkung]
345 
346 	<StarView> liefert leider keine M"oglichkeit, solche Events
347 	'von der Seite' einzuh"angen.
348 */
349 
350 {
351 }
352 
353 //------------------------------------------------------------------------
354 
GetViewFrame() const355 inline SfxViewFrame* SfxViewShell::GetViewFrame() const
356 
357 /*	[Bechreibung]
358 
359 	Diese Methode liefert einen Pointer auf die <SfxViewFrame>-Instanz,
360 	in der diese SfxViewShell dargestellt wird. Dieses ist die Instanz,
361 	die imKonstruktor durchgereicht wurde. Es ist gew"ahrleistet, da\s
362 	der zur"uckgegebene Pointer auf eine g"ultige SfxViewFrame-Instanz
363 	zeigt.
364 
365 
366 	[Querverweise]
367 
368 	<SfxShell::GetFrame()const>
369 */
370 
371 {
372 	return pFrame;
373 }
374 
375 #endif // #ifndef _SFXVIEWSH_HXX
376 
377