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