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_VIEWSH_HXX
20 : #define INCLUDED_SFX2_VIEWSH_HXX
21 :
22 : #include <sal/config.h>
23 : #include <memory>
24 : #include <sfx2/dllapi.h>
25 : #include <sal/types.h>
26 : #include <com/sun/star/embed/XEmbeddedObject.hpp>
27 : #include <com/sun/star/frame/XController.hpp>
28 : #include <com/sun/star/view/XRenderable.hpp>
29 : #include <com/sun/star/uno/Reference.h>
30 : #include <svl/lstner.hxx>
31 : #include <com/sun/star/ui/XContextMenuInterceptor.hpp>
32 : #include <com/sun/star/datatransfer/clipboard/XClipboardListener.hpp>
33 : #include <com/sun/star/datatransfer/clipboard/XClipboardNotifier.hpp>
34 : #include <cppuhelper/interfacecontainer.hxx>
35 : #include <sfx2/shell.hxx>
36 : #include <tools/gen.hxx>
37 : #include <tools/errcode.hxx>
38 : #include <vcl/jobset.hxx>
39 : #include <o3tl/typed_flags_set.hxx>
40 : #include <vcl/vclptr.hxx>
41 : #include <sfx2/tabdlg.hxx>
42 :
43 : class SfxBaseController;
44 : class Size;
45 : class Fraction;
46 : namespace vcl { 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 SfxFrameSetDescriptor;
57 : class Printer;
58 : class SfxPrinter;
59 : class SfxProgress;
60 : class SfxFrameItem;
61 : class Dialog;
62 : class Menu;
63 : class NotifyEvent;
64 : class SfxInPlaceClient;
65 : namespace vcl { class PrinterController; }
66 :
67 :
68 : enum class SfxPrinterChangeFlags
69 : {
70 : NONE = 0,
71 : PRINTER = 1, // without JOB SETUP => Temporary
72 : JOBSETUP = 2,
73 : OPTIONS = 4,
74 : CHG_ORIENTATION = 8,
75 : CHG_SIZE = 16
76 : };
77 : namespace o3tl
78 : {
79 : template<> struct typed_flags<SfxPrinterChangeFlags> : is_typed_flags<SfxPrinterChangeFlags, 31> {};
80 : }
81 : #define SFX_PRINTER_ALL (SfxPrinterChangeFlags::PRINTER | SfxPrinterChangeFlags::JOBSETUP | SfxPrinterChangeFlags::OPTIONS | SfxPrinterChangeFlags::CHG_ORIENTATION | SfxPrinterChangeFlags::CHG_SIZE)
82 :
83 : #define SFX_PRINTERROR_BUSY 1
84 :
85 : // "Verified" using www.apple.com and Netscape 3.01
86 : #define DEFAULT_MARGIN_WIDTH 8
87 : #define DEFAULT_MARGIN_HEIGHT 12
88 :
89 :
90 :
91 : // @[SfxViewShell-Flags]
92 :
93 : enum class SfxViewShellFlags
94 : {
95 : NONE = 0x0000,
96 : HAS_PRINTOPTIONS = 0x0010, /* Options-Button and Options-Dialog in PrintDialog */
97 : CAN_PRINT = 0x0020, /* Printing enabled without having to create a Printer */
98 : NO_SHOW = 0x0040, /* Window of the ViewShell shall not be showed automatically */
99 : NO_NEWWINDOW = 0x0100, /* Allow N View */
100 : };
101 : namespace o3tl
102 : {
103 : template<> struct typed_flags<SfxViewShellFlags> : is_typed_flags<SfxViewShellFlags, 0x0170> {};
104 : }
105 :
106 : /* [Description]
107 :
108 : The SfxViewShell flags control the behavior of SfxViewShell for the
109 : duration of its lifetime. They are defined in the constructor of
110 : <SfxViewShell>.
111 : */
112 :
113 :
114 :
115 : #define SFX_DECL_VIEWFACTORY(Class) \
116 : private: \
117 : static SfxViewFactory *pFactory; \
118 : public: \
119 : static SfxViewShell *CreateInstance(SfxViewFrame *pFrame, SfxViewShell *pOldView); \
120 : static void RegisterFactory( sal_uInt16 nPrio = USHRT_MAX ); \
121 : static SfxViewFactory*Factory() { return pFactory; } \
122 : static void InitFactory()
123 :
124 : #define SFX_IMPL_NAMED_VIEWFACTORY(Class, AsciiViewName) \
125 : SfxViewFactory* Class::pFactory; \
126 : SfxViewShell* Class::CreateInstance(SfxViewFrame *pFrame, SfxViewShell *pOldView) \
127 : { return new Class(pFrame, pOldView); } \
128 : void Class::RegisterFactory( sal_uInt16 nPrio ) \
129 : { \
130 : pFactory = new SfxViewFactory(&CreateInstance,nPrio,AsciiViewName);\
131 : InitFactory(); \
132 : } \
133 : void Class::InitFactory()
134 :
135 : #define SFX_VIEW_REGISTRATION(DocClass) \
136 : DocClass::Factory().RegisterViewFactory( *Factory() )
137 :
138 : class SFX2_DLLPUBLIC SfxViewShell: public SfxShell, public SfxListener
139 : {
140 : #ifdef INCLUDED_SFX2_VIEWSH_HXX
141 : friend class SfxViewFrame;
142 : friend class SfxBaseController;
143 : friend class SfxPrinterController;
144 : #endif
145 :
146 : struct SfxViewShell_Impl* pImp;
147 : SfxViewFrame* pFrame;
148 : SfxShell* pSubShell;
149 : VclPtr<vcl::Window> pWindow;
150 : bool bNoNewWindow;
151 :
152 : protected:
153 : virtual void Activate(bool IsMDIActivate) SAL_OVERRIDE;
154 : virtual void Deactivate(bool IsMDIActivate) SAL_OVERRIDE;
155 :
156 : virtual void InnerResizePixel( const Point &rOfs, const Size &rSize );
157 : virtual void OuterResizePixel( const Point &rOfs, const Size &rSize );
158 : virtual void SetZoomFactor( const Fraction &rZoomX, const Fraction &rZoomY );
159 :
160 : virtual void Move();
161 :
162 : virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) SAL_OVERRIDE;
163 :
164 : public:
165 : // Iteration
166 : static SfxViewShell* GetFirst( const TypeId* pType = 0, bool bOnlyVisible = true );
167 : static SfxViewShell* GetNext( const SfxViewShell& rPrev,
168 : const TypeId* pType = 0, bool bOnlyVisible = true );
169 : static SfxViewShell* Current();
170 :
171 : static SfxViewShell* Get( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController>& i_rController );
172 :
173 : // Initialize Constructors/Destructors
174 : TYPEINFO_OVERRIDE();
175 208 : SFX_DECL_INTERFACE(SFX_INTERFACE_SFXVIEWSH)
176 :
177 : private:
178 : /// SfxInterface initializer.
179 : static void InitInterface_Impl();
180 :
181 : public:
182 :
183 : SfxViewShell( SfxViewFrame *pFrame, SfxViewShellFlags nFlags = SfxViewShellFlags::NONE );
184 : virtual ~SfxViewShell();
185 :
186 : SfxInPlaceClient* GetIPClient() const;
187 : SfxInPlaceClient* GetUIActiveClient() const;
188 : SfxInPlaceClient* FindIPClient( const ::com::sun::star::uno::Reference < ::com::sun::star::embed::XEmbeddedObject >& xObj, vcl::Window *pObjParentWin ) const;
189 :
190 : virtual ErrCode DoVerb(long nVerb);
191 :
192 : void OutplaceActivated( bool bActive, SfxInPlaceClient* pClient );
193 : virtual void UIActivating( SfxInPlaceClient* pClient );
194 : virtual void UIDeactivated( SfxInPlaceClient* pClient );
195 :
196 : void JumpToMark( const OUString& rMark );
197 : void VisAreaChanged(const Rectangle& rRect);
198 :
199 : // Misc
200 :
201 : /**
202 : * Initialize is called after the frame has been loaded and the controller
203 : * has been set. By the time this is called the document has been fully
204 : * imported.
205 : */
206 : virtual bool PrepareClose( bool bUI = true );
207 : virtual OUString GetSelectionText( bool bCompleteWords = false );
208 : virtual bool HasSelection( bool bText = true ) const;
209 : virtual SdrView* GetDrawView() const;
210 :
211 6015 : SfxShell* GetSubShell() const { return pSubShell; }
212 : void AddSubShell( SfxShell& rShell );
213 : void RemoveSubShell( SfxShell *pShell=NULL );
214 : SfxShell* GetSubShell( sal_uInt16 );
215 :
216 0 : virtual SfxShell* GetFormShell() { return 0; };
217 0 : virtual const SfxShell* GetFormShell() const { return 0; };
218 :
219 : // Focus, KeyInput, Cursor
220 : virtual void ShowCursor( bool bOn = true );
221 : virtual bool KeyInput( const KeyEvent &rKeyEvent );
222 : bool Escape();
223 :
224 : // Viewing Interface
225 56170 : vcl::Window* GetWindow() const { return pWindow; }
226 : void SetWindow( vcl::Window *pViewPort );
227 : virtual void AdjustPosSizePixel( const Point &rOfs, const Size &rSize );
228 : const SvBorder& GetBorderPixel() const;
229 : void SetBorderPixel( const SvBorder &rBorder );
230 : void InvalidateBorder();
231 : inline SfxViewFrame* GetViewFrame() const;
232 :
233 : // Printing Interface
234 : virtual SfxPrinter* GetPrinter( bool bCreate = false );
235 : virtual sal_uInt16 SetPrinter( SfxPrinter *pNewPrinter, SfxPrinterChangeFlags nDiffFlags = SFX_PRINTER_ALL, bool bIsAPI=false );
236 : virtual bool HasPrintOptionsPage() const;
237 : virtual VclPtr<SfxTabPage> CreatePrintOptionsPage( vcl::Window *pParent, const SfxItemSet &rOptions );
238 : static JobSetup GetJobSetup();
239 : Printer* GetActivePrinter() const;
240 :
241 : // Working set
242 : virtual void WriteUserData( OUString&, bool bBrowse = false );
243 : virtual void ReadUserData( const OUString&, bool bBrowse = false );
244 : virtual void WriteUserDataSequence ( ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue >&, bool bBrowse = false );
245 : virtual void ReadUserDataSequence ( const ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue >&, bool bBrowse = false );
246 : virtual void QueryObjAreaPixel( Rectangle& rRect ) const;
247 :
248 : virtual SfxObjectShell* GetObjectShell() SAL_OVERRIDE;
249 :
250 : /** retrieves the document which shall be considered the "current document" when the frame is active
251 :
252 : The default implementation simply returns the XModel of the associated SfxObjectShell. You will rarely
253 : need to overwrite this behavior.
254 : */
255 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >
256 : GetCurrentDocument() const;
257 :
258 : /** forwards the current document, as returned by ->GetCurrentDocument, to SfxObjectShell::SetWorkingDocument
259 : */
260 : void SetCurrentDocument() const;
261 :
262 : /** get an XRenderable instance that can render this document
263 : */
264 : virtual com::sun::star::uno::Reference< com::sun::star::view::XRenderable > GetRenderable();
265 :
266 :
267 : virtual void MarginChanged();
268 : const Size& GetMargin() const;
269 : void SetMargin( const Size& );
270 : void DisconnectAllClients();
271 2 : bool NewWindowAllowed() const { return !bNoNewWindow; }
272 2762 : void SetNewWindowAllowed( bool bSet ) { bNoNewWindow = !bSet; }
273 :
274 : void SetController( SfxBaseController* pController );
275 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >
276 : GetController();
277 :
278 : bool TryContextMenuInterception( Menu& rIn, const OUString& rMenuIdentifier, Menu*& rpOut, ::com::sun::star::ui::ContextMenuExecuteEvent aEvent );
279 :
280 : void ExecPrint( const com::sun::star::uno::Sequence < com::sun::star::beans::PropertyValue >&, bool, bool );
281 : // Like ExecPrint(), but only sets up for printing. Use Printer::ExecutePrintJob() and Printer::FinishPrintJob() afterwards.
282 : void StartPrint( const com::sun::star::uno::Sequence < com::sun::star::beans::PropertyValue >&, bool, bool );
283 : std::shared_ptr< vcl::PrinterController > GetPrinterController() const;
284 :
285 : void AddRemoveClipboardListener( const com::sun::star::uno::Reference < com::sun::star::datatransfer::clipboard::XClipboardListener>&, bool );
286 : ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboardNotifier > GetClipboardNotifier();
287 :
288 : SAL_DLLPRIVATE SfxInPlaceClient* GetUIActiveIPClient_Impl() const;
289 : SAL_DLLPRIVATE void AddContextMenuInterceptor_Impl( const ::com::sun::star::uno::Reference < ::com::sun::star::ui::XContextMenuInterceptor >& xInterceptor );
290 : SAL_DLLPRIVATE void RemoveContextMenuInterceptor_Impl( const ::com::sun::star::uno::Reference < ::com::sun::star::ui::XContextMenuInterceptor >& xInterceptor );
291 : SAL_DLLPRIVATE bool GlobalKeyInput_Impl( const KeyEvent &rKeyEvent );
292 :
293 : SAL_DLLPRIVATE void NewIPClient_Impl( SfxInPlaceClient *pIPClient );
294 : SAL_DLLPRIVATE void IPClientGone_Impl( SfxInPlaceClient *pIPClient );
295 : SAL_DLLPRIVATE void ResetAllClients_Impl( SfxInPlaceClient *pIP );
296 : SAL_DLLPRIVATE void DiscardClients_Impl();
297 :
298 : SAL_DLLPRIVATE SfxPrinter* SetPrinter_Impl( VclPtr<SfxPrinter>& pNewPrinter );
299 : SAL_DLLPRIVATE bool IsShowView_Impl() const;
300 :
301 : SAL_DLLPRIVATE bool HandleNotifyEvent_Impl( NotifyEvent& rEvent );
302 : SAL_DLLPRIVATE bool HasKeyListeners_Impl();
303 : SAL_DLLPRIVATE bool HasMouseClickListeners_Impl();
304 :
305 : SAL_DLLPRIVATE SfxBaseController* GetBaseController_Impl() const;
306 :
307 : // Shell Interface
308 : SAL_DLLPRIVATE void ExecPrint_Impl(SfxRequest &);
309 : SAL_DLLPRIVATE void ExecMisc_Impl(SfxRequest &);
310 : SAL_DLLPRIVATE void GetState_Impl(SfxItemSet&);
311 : SAL_DLLPRIVATE SfxFrameSetDescriptor* GetFrameSet_Impl() const;
312 : SAL_DLLPRIVATE void SetFrameSet_Impl(SfxFrameSetDescriptor*);
313 : SAL_DLLPRIVATE void CheckIPClient_Impl( SfxInPlaceClient*, const Rectangle& );
314 : SAL_DLLPRIVATE void PushSubShells_Impl( bool bPush=true );
315 3258 : SAL_DLLPRIVATE void PopSubShells_Impl() { PushSubShells_Impl( false ); }
316 : SAL_DLLPRIVATE void TakeOwnership_Impl();
317 : SAL_DLLPRIVATE void TakeFrameOwnership_Impl();
318 : SAL_DLLPRIVATE bool ExecKey_Impl(const KeyEvent& aKey);
319 : };
320 :
321 :
322 :
323 1091476 : inline SfxViewFrame* SfxViewShell::GetViewFrame() const
324 :
325 : /* [Description]
326 :
327 : This method returns a pointer to the <SfxViewFrame> Instance in which
328 : this SfxViewShell is displayed. This is the instance that was passed
329 : on in the constructor. It is guaranteed that the returned pointer
330 : points on the valid SfxViewFrame instance.
331 :
332 : [Cross-reference]
333 :
334 : <SfxShell::GetFrame()const>
335 : */
336 :
337 : {
338 1091476 : return pFrame;
339 : }
340 :
341 : #endif // INCLUDED_SFX2_VIEWSH_HXX
342 :
343 :
344 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|