LCOV - code coverage report
Current view: top level - include/sfx2 - viewsh.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 12 14 85.7 %
Date: 2014-11-03 Functions: 9 11 81.8 %
Legend: Lines: hit not hit

          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 <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>
      38             : #include <vector>
      39             : 
      40             : class SfxBaseController;
      41             : class Size;
      42             : class Fraction;
      43             : namespace vcl { class Window; }
      44             : class KeyEvent;
      45             : class WorkWindow;
      46             : class SvBorder;
      47             : class SdrView;
      48             : class SfxFrame;
      49             : class SfxMedium;
      50             : class SfxModule;
      51             : class SfxViewFrame;
      52             : class SfxItemPool;
      53             : class SfxTabPage;
      54             : class SfxFrameSetDescriptor;
      55             : class Printer;
      56             : class SfxPrinter;
      57             : class SfxProgress;
      58             : class SfxFrameItem;
      59             : class Dialog;
      60             : class Menu;
      61             : class NotifyEvent;
      62             : 
      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
      69             : 
      70             : #define SFX_PRINTER_CHG_ORIENTATION_FLAG  3
      71             : #define SFX_PRINTER_CHG_SIZE_FLAG         4
      72             : 
      73             : #define SFX_PRINTERROR_NONE          0
      74             : #define SFX_PRINTERROR_BUSY          1
      75             : 
      76             : // "Verified" using www.apple.com and Netscape 3.01
      77             : #define DEFAULT_MARGIN_WIDTH 8
      78             : #define DEFAULT_MARGIN_HEIGHT 12
      79             : 
      80             : 
      81             : 
      82             : //  @[SfxViewShell-Flags]
      83             : 
      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 */
      91             : 
      92             : /*  [Description]
      93             : 
      94             :     The SfxViewShell flags control the behavior of SfxViewShell for the
      95             :     duration of its lifetime. They are defined in the constructor of
      96             :     <SfxViewShell>.
      97             : */
      98             : 
      99             : 
     100             : 
     101             : #define SFX_DECL_VIEWFACTORY(Class) \
     102             : private: \
     103             :     static SfxViewFactory *pFactory; \
     104             : public: \
     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()
     109             : 
     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 ) \
     115             :     { \
     116             :         pFactory = new SfxViewFactory(&CreateInstance,nPrio,AsciiViewName);\
     117             :         InitFactory(); \
     118             :     } \
     119             :     void Class::InitFactory()
     120             : 
     121             : #define SFX_VIEW_REGISTRATION(DocClass) \
     122             :             DocClass::Factory().RegisterViewFactory( *Factory() )
     123             : 
     124             : class SfxInPlaceClient;
     125             : typedef ::std::vector< SfxInPlaceClient* > SfxInPlaceClientList;
     126             : 
     127             : 
     128             : class SFX2_DLLPUBLIC SfxViewShell: public SfxShell, public SfxListener
     129             : {
     130             : #ifdef INCLUDED_SFX2_VIEWSH_HXX
     131             : friend class SfxViewFrame;
     132             : friend class SfxBaseController;
     133             : friend class SfxPrinterController;
     134             : #endif
     135             : 
     136             :     struct SfxViewShell_Impl*   pImp;
     137             :     SfxInPlaceClientList*       pIPClientList;
     138             :     SfxViewFrame*               pFrame;
     139             :     SfxShell*                   pSubShell;
     140             :     vcl::Window*                     pWindow;
     141             :     bool                        bNoNewWindow;
     142             : 
     143             : protected:
     144             :     virtual void                Activate(bool IsMDIActivate) SAL_OVERRIDE;
     145             :     virtual void                Deactivate(bool IsMDIActivate) SAL_OVERRIDE;
     146             : 
     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 );
     150             : 
     151             :     virtual void                Move();
     152             : 
     153             :     virtual void                Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) SAL_OVERRIDE;
     154             : 
     155             : public:
     156             :     // Iteration
     157             :     static SfxViewShell*        GetFirst( const TypeId* pType = 0, bool bOnlyVisible = true );
     158             :     static SfxViewShell*        GetNext( const SfxViewShell& rPrev,
     159             :                                          const TypeId* pType = 0, bool bOnlyVisible = true );
     160             :     static SfxViewShell*        Current();
     161             : 
     162             :     static SfxViewShell*        Get( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController>& i_rController );
     163             : 
     164             :     // Initialize Constructors/Destructors
     165             :                                 TYPEINFO_OVERRIDE();
     166         303 :                                 SFX_DECL_INTERFACE(SFX_INTERFACE_SFXVIEWSH)
     167             : 
     168             : private:
     169             :     /// SfxInterface initializer.
     170             :     static void InitInterface_Impl();
     171             : 
     172             : public:
     173             : 
     174             :                                 SfxViewShell( SfxViewFrame *pFrame, sal_uInt16 nFlags = 0 );
     175             :     virtual                     ~SfxViewShell();
     176             : 
     177             :     SfxInPlaceClient*           GetIPClient() const;
     178             :     SfxInPlaceClient*           GetUIActiveClient() const;
     179             :     SfxInPlaceClient*           FindIPClient( const ::com::sun::star::uno::Reference < ::com::sun::star::embed::XEmbeddedObject >&  xObj, vcl::Window *pObjParentWin ) const;
     180             : 
     181             :     virtual ErrCode             DoVerb(long nVerb);
     182             : 
     183             :     virtual void                OutplaceActivated( bool bActive, SfxInPlaceClient* pClient );
     184             :     virtual void                InplaceActivating( SfxInPlaceClient* pClient );
     185             :     virtual void                InplaceDeactivated( SfxInPlaceClient* pClient );
     186             :     virtual void                UIActivating( SfxInPlaceClient* pClient );
     187             :     virtual void                UIDeactivated( SfxInPlaceClient* pClient );
     188             : 
     189             :     void                        JumpToMark( const OUString& rMark );
     190             :     void                        VisAreaChanged(const Rectangle& rRect);
     191             : 
     192             :     // Misc
     193             : 
     194             :     /**
     195             :      * Initialize is called after the frame has been loaded and the controller
     196             :      * has been set.  By the time this is called the document has been fully
     197             :      * imported.
     198             :      */
     199             :     virtual void                Initialize();
     200             :     virtual bool                PrepareClose( bool bUI = true );
     201             :     virtual OUString            GetSelectionText( bool bCompleteWords = false );
     202             :     virtual bool                HasSelection( bool bText = true ) const;
     203             :     virtual SdrView*            GetDrawView() const;
     204             : 
     205       10216 :     SfxShell*                   GetSubShell() const { return pSubShell; }
     206             :     void                        AddSubShell( SfxShell& rShell );
     207             :     void                        RemoveSubShell( SfxShell *pShell=NULL );
     208             :     SfxShell*                   GetSubShell( sal_uInt16 );
     209             : 
     210           0 :     virtual       SfxShell*     GetFormShell()       { return 0; };
     211           0 :     virtual const SfxShell*     GetFormShell() const { return 0; };
     212             : 
     213             :     // Focus, KeyInput, Cursor
     214             :     void                        GotFocus() const;
     215             :     inline void                 LostFocus() const;
     216             :     virtual void                ShowCursor( bool bOn = true );
     217             :     virtual bool                KeyInput( const KeyEvent &rKeyEvent );
     218             :     bool                        Escape();
     219             : 
     220             :     // Viewing Interface
     221       94088 :     vcl::Window*                     GetWindow() const { return pWindow; }
     222             :     void                        SetWindow( vcl::Window *pViewPort );
     223             :     virtual void                AdjustPosSizePixel( const Point &rOfs, const Size &rSize );
     224             :     const SvBorder&             GetBorderPixel() const;
     225             :     void                        SetBorderPixel( const SvBorder &rBorder );
     226             :     void                        InvalidateBorder();
     227             :     inline SfxViewFrame*        GetViewFrame() const;
     228             : 
     229             :     // Printing Interface
     230             :     virtual SfxPrinter*         GetPrinter( bool bCreate = false );
     231             :     virtual sal_uInt16          SetPrinter( SfxPrinter *pNewPrinter, sal_uInt16 nDiffFlags = SFX_PRINTER_ALL, bool bIsAPI=false );
     232             :     virtual bool                HasPrintOptionsPage() const;
     233             :     virtual SfxTabPage*         CreatePrintOptionsPage( vcl::Window *pParent, const SfxItemSet &rOptions );
     234             :     virtual JobSetup            GetJobSetup() const;
     235             :     Printer*                    GetActivePrinter() const;
     236             : 
     237             :     // Working set
     238             :     virtual void                WriteUserData( OUString&, bool bBrowse = false );
     239             :     virtual void                ReadUserData( const OUString&, bool bBrowse = false );
     240             :     virtual void                WriteUserDataSequence ( ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue >&, bool bBrowse = false );
     241             :     virtual void                ReadUserDataSequence ( const ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue >&, bool bBrowse = false );
     242             :     virtual void                QueryObjAreaPixel( Rectangle& rRect ) const;
     243             : 
     244             :     virtual SfxObjectShell*     GetObjectShell() SAL_OVERRIDE;
     245             : 
     246             :     /** retrieves the document which shall be considered the "current document" when the frame is active
     247             : 
     248             :         The default implementation simply returns the XModel of the associated SfxObjectShell. You will rarely
     249             :         need to overwrite this behavior.
     250             :     */
     251             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >
     252             :                                 GetCurrentDocument() const;
     253             : 
     254             :     /** forwards the current document, as returned by ->GetCurrentDocument, to SfxObjectShell::SetWorkingDocument
     255             :     */
     256             :     void                        SetCurrentDocument() const;
     257             : 
     258             :     /** get an XRenderable instance that can render this document
     259             :     */
     260             :     virtual com::sun::star::uno::Reference< com::sun::star::view::XRenderable > GetRenderable();
     261             : 
     262             : 
     263             :     virtual void                MarginChanged();
     264             :     const Size&                 GetMargin() const;
     265             :     void                        SetMargin( const Size& );
     266             :     void                        DisconnectAllClients();
     267             :     virtual SfxFrame*           GetSmartSelf( SfxFrame* pSelf, SfxMedium& rMedium );
     268           4 :     bool                        NewWindowAllowed() const            { return !bNoNewWindow; }
     269        4710 :     void                        SetNewWindowAllowed( bool bSet )    { bNoNewWindow = !bSet; }
     270             : 
     271             :     void                        SetController( SfxBaseController* pController );
     272             :     ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >
     273             :                                 GetController();
     274             : 
     275             :     bool                        TryContextMenuInterception( Menu& rIn, const OUString& rMenuIdentifier, Menu*& rpOut, ::com::sun::star::ui::ContextMenuExecuteEvent aEvent );
     276             : 
     277             :     void                        ExecPrint( const com::sun::star::uno::Sequence < com::sun::star::beans::PropertyValue >&, bool, bool );
     278             : 
     279             :     void                        AddRemoveClipboardListener( const com::sun::star::uno::Reference < com::sun::star::datatransfer::clipboard::XClipboardListener>&, bool );
     280             :     ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboardNotifier > GetClipboardNotifier();
     281             : 
     282             :     SAL_DLLPRIVATE SfxInPlaceClient* GetUIActiveIPClient_Impl() const;
     283             :     SAL_DLLPRIVATE void AddContextMenuInterceptor_Impl( const ::com::sun::star::uno::Reference < ::com::sun::star::ui::XContextMenuInterceptor >& xInterceptor );
     284             :     SAL_DLLPRIVATE void RemoveContextMenuInterceptor_Impl( const ::com::sun::star::uno::Reference < ::com::sun::star::ui::XContextMenuInterceptor >& xInterceptor );
     285             :     SAL_DLLPRIVATE bool GlobalKeyInput_Impl( const KeyEvent &rKeyEvent );
     286             : 
     287          20 :     SAL_DLLPRIVATE void NewIPClient_Impl( SfxInPlaceClient *pIPClient )
     288          20 :                                 { GetIPClientList_Impl(true)->push_back(pIPClient); }
     289             :     SAL_DLLPRIVATE void IPClientGone_Impl( SfxInPlaceClient *pIPClient );
     290             :     SAL_DLLPRIVATE SfxInPlaceClientList* GetIPClientList_Impl( bool bCreate = true ) const;
     291             :     SAL_DLLPRIVATE void ResetAllClients_Impl( SfxInPlaceClient *pIP );
     292             :     SAL_DLLPRIVATE void DiscardClients_Impl();
     293             : 
     294             :     SAL_DLLPRIVATE SfxPrinter* SetPrinter_Impl( SfxPrinter *pNewPrinter );
     295             :     SAL_DLLPRIVATE bool IsShowView_Impl() const;
     296             : 
     297             :     SAL_DLLPRIVATE bool HandleNotifyEvent_Impl( NotifyEvent& rEvent );
     298             :     SAL_DLLPRIVATE bool HasKeyListeners_Impl();
     299             :     SAL_DLLPRIVATE bool HasMouseClickListeners_Impl();
     300             : 
     301             :     SAL_DLLPRIVATE SfxBaseController*   GetBaseController_Impl() const;
     302             : 
     303             :     // Shell Interface
     304             :     SAL_DLLPRIVATE void ExecPrint_Impl(SfxRequest &);
     305             :     SAL_DLLPRIVATE void ExecMisc_Impl(SfxRequest &);
     306             :     SAL_DLLPRIVATE void GetState_Impl(SfxItemSet&);
     307             :     SAL_DLLPRIVATE SfxFrameSetDescriptor* GetFrameSet_Impl() const;
     308             :     SAL_DLLPRIVATE void SetFrameSet_Impl(SfxFrameSetDescriptor*);
     309             :     SAL_DLLPRIVATE void CheckIPClient_Impl( SfxInPlaceClient*, const Rectangle& );
     310             :     SAL_DLLPRIVATE void PushSubShells_Impl( bool bPush=true );
     311        5522 :     SAL_DLLPRIVATE void PopSubShells_Impl() { PushSubShells_Impl( false ); }
     312             :     SAL_DLLPRIVATE void TakeOwnership_Impl();
     313             :     SAL_DLLPRIVATE void TakeFrameOwnership_Impl();
     314             :     SAL_DLLPRIVATE bool ExecKey_Impl(const KeyEvent& aKey);
     315             : };
     316             : 
     317             : 
     318             : 
     319        4829 : inline void SfxViewShell::LostFocus() const
     320             : 
     321             : /*  [Description]
     322             : 
     323             :     This method has to be  called by the application developer, if the edit
     324             :     window has lost the focus. The SFx has for example the ability to turn off
     325             :     the accelerator, so that the cursor keys, the Delete button, etc. work in
     326             :     certain Floating-Windows, even though they are redefined by the
     327             :     Accelerator.
     328             : 
     329             :     [Note]
     330             : 
     331             :     <StarView> unfortunately does not provide the possibility to define
     332             :     such events 'from the side'.
     333             : */
     334             : 
     335             : {
     336        4829 : }
     337             : 
     338             : 
     339             : 
     340     1741799 : inline SfxViewFrame* SfxViewShell::GetViewFrame() const
     341             : 
     342             : /*  [Description]
     343             : 
     344             :     This method returns a pointer to the <SfxViewFrame> Instance in which
     345             :     this SfxViewShell is displayed. This is the instance that was passed
     346             :     on in the constructor. It is guaranteed that the returned pointer
     347             :     points on the valid SfxViewFrame instance.
     348             : 
     349             :     [Cross-reference]
     350             : 
     351             :     <SfxShell::GetFrame()const>
     352             : */
     353             : 
     354             : {
     355     1741799 :     return pFrame;
     356             : }
     357             : 
     358             : #endif // INCLUDED_SFX2_VIEWSH_HXX
     359             : 
     360             : 
     361             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10