LCOV - code coverage report
Current view: top level - sfx2/inc/sfx2 - viewsh.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 9 9 100.0 %
Date: 2012-08-25 Functions: 7 7 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     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 _SFXVIEWSH_HXX
      20                 :            : #define _SFXVIEWSH_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 "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                 :            : 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 _SFXVIEWSH_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                 :            :     Window*                     pWindow;
     141                 :            :     sal_Bool                        bNoNewWindow;
     142                 :            : 
     143                 :            : protected:
     144                 :            :     virtual void                Activate(sal_Bool IsMDIActivate);
     145                 :            :     virtual void                Deactivate(sal_Bool IsMDIActivate);
     146                 :            : 
     147                 :            :     virtual Size                GetOptimalSizePixel() const;
     148                 :            : 
     149                 :            :     virtual void                InnerResizePixel( const Point &rOfs, const Size &rSize );
     150                 :            :     virtual void                OuterResizePixel( const Point &rOfs, const Size &rSize );
     151                 :            :     virtual void                SetZoomFactor( const Fraction &rZoomX, const Fraction &rZoomY );
     152                 :            : 
     153                 :            :     virtual void                Move();
     154                 :            : 
     155                 :            :     virtual void                Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
     156                 :            : 
     157                 :            : public:
     158                 :            :     // Iteration
     159                 :            :     static SfxViewShell*        GetFirst( const TypeId* pType = 0, sal_Bool bOnlyVisible = sal_True );
     160                 :            :     static SfxViewShell*        GetNext( const SfxViewShell& rPrev,
     161                 :            :                                          const TypeId* pType = 0, sal_Bool bOnlyVisible = sal_True );
     162                 :            :     static SfxViewShell*        Current();
     163                 :            : 
     164                 :            :     static SfxViewShell*        Get( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController>& i_rController );
     165                 :            : 
     166                 :            :     // Initialize Constructors/Destructors
     167                 :            :                                 TYPEINFO();
     168                 :        233 :                                 SFX_DECL_INTERFACE(SFX_INTERFACE_SFXVIEWSH)
     169                 :            : 
     170                 :            :                                 SfxViewShell( SfxViewFrame *pFrame, sal_uInt16 nFlags = 0 );
     171                 :            :     virtual                     ~SfxViewShell();
     172                 :            : 
     173                 :            :     SfxInPlaceClient*           GetIPClient() const;
     174                 :            :     SfxInPlaceClient*           GetUIActiveClient() const;
     175                 :            :     SfxInPlaceClient*           FindIPClient( const ::com::sun::star::uno::Reference < ::com::sun::star::embed::XEmbeddedObject >&  xObj, Window *pObjParentWin ) const;
     176                 :            : 
     177                 :            :     virtual ErrCode             DoVerb(long nVerb);
     178                 :            : 
     179                 :            :     virtual void                OutplaceActivated( sal_Bool bActive, SfxInPlaceClient* pClient );
     180                 :            :     virtual void                InplaceActivating( SfxInPlaceClient* pClient );
     181                 :            :     virtual void                InplaceDeactivated( SfxInPlaceClient* pClient );
     182                 :            :     virtual void                UIActivating( SfxInPlaceClient* pClient );
     183                 :            :     virtual void                UIDeactivated( SfxInPlaceClient* pClient );
     184                 :            : 
     185                 :            :     virtual void                JumpToMark( const String& rMark );
     186                 :            :     void                        VisAreaChanged(const Rectangle& rRect);
     187                 :            : 
     188                 :            :     // Misc
     189                 :            :     virtual sal_uInt16              PrepareClose( sal_Bool bUI = sal_True, sal_Bool bForBrowsing = sal_False );
     190                 :            :     virtual String              GetSelectionText( sal_Bool bCompleteWords = sal_False );
     191                 :            :     virtual sal_Bool                HasSelection( sal_Bool bText = sal_True ) const;
     192                 :            :     virtual SdrView*            GetDrawView() const;
     193                 :            : 
     194                 :       2950 :     SfxShell*                   GetSubShell() const { return pSubShell; }
     195                 :            :     void                        AddSubShell( SfxShell& rShell );
     196                 :            :     void                        RemoveSubShell( SfxShell *pShell=NULL );
     197                 :            :     SfxShell*                   GetSubShell( sal_uInt16 );
     198                 :            : 
     199                 :            :     // Focus, KeyInput, Cursor
     200                 :            :     void                        GotFocus() const;
     201                 :            :     inline void                 LostFocus() const;
     202                 :            :     virtual void                ShowCursor( bool bOn = true );
     203                 :            :     virtual bool                KeyInput( const KeyEvent &rKeyEvent );
     204                 :            :     sal_Bool                        Escape();
     205                 :            : 
     206                 :            :     // Viewing Interface
     207                 :      17981 :     Window*                     GetWindow() const { return pWindow; }
     208                 :            :     void                        SetWindow( Window *pViewPort );
     209                 :            :     virtual void                AdjustPosSizePixel( const Point &rOfs, const Size &rSize );
     210                 :            :     const SvBorder&             GetBorderPixel() const;
     211                 :            :     void                        SetBorderPixel( const SvBorder &rBorder );
     212                 :            :     void                        InvalidateBorder();
     213                 :            :     inline SfxViewFrame*        GetViewFrame() const;
     214                 :            : 
     215                 :            :     // Printing Interface
     216                 :            :     virtual SfxPrinter*         GetPrinter( sal_Bool bCreate = sal_False );
     217                 :            :     virtual sal_uInt16              SetPrinter( SfxPrinter *pNewPrinter, sal_uInt16 nDiffFlags = SFX_PRINTER_ALL, bool bIsAPI=sal_False );
     218                 :            :     virtual SfxTabPage*         CreatePrintOptionsPage( Window *pParent, const SfxItemSet &rOptions );
     219                 :            :     virtual JobSetup            GetJobSetup() const;
     220                 :            :     Printer*                    GetActivePrinter() const;
     221                 :            : 
     222                 :            :     // Working set
     223                 :            :     virtual void                WriteUserData( String&, sal_Bool bBrowse = sal_False );
     224                 :            :     virtual void                ReadUserData( const String&, sal_Bool bBrowse = sal_False );
     225                 :            :     virtual void                WriteUserDataSequence ( ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue >&, sal_Bool bBrowse = sal_False );
     226                 :            :     virtual void                ReadUserDataSequence ( const ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue >&, sal_Bool bBrowse = sal_False );
     227                 :            :     virtual void                QueryObjAreaPixel( Rectangle& rRect ) const;
     228                 :            : 
     229                 :            :     virtual SfxObjectShell*     GetObjectShell();
     230                 :            :     /** retrieves the document which shall be considered the "current document" when the frame is active
     231                 :            : 
     232                 :            :         The default implementation simply returns the XModel of the associated SfxObjectShell. You will rarely
     233                 :            :         need to overwrite this behavior.
     234                 :            :     */
     235                 :            :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >
     236                 :            :                                 GetCurrentDocument() const;
     237                 :            :     /** forwards the current document, as returned by ->GetCurrentDocument, to SfxObjectShell::SetWorkingDocument
     238                 :            :     */
     239                 :            :     void                        SetCurrentDocument() const;
     240                 :            : 
     241                 :            :     /** get an XRenderable instance that can render this docuement
     242                 :            :     */
     243                 :            :     virtual com::sun::star::uno::Reference< com::sun::star::view::XRenderable > GetRenderable();
     244                 :            : 
     245                 :            : 
     246                 :            :     virtual void                MarginChanged();
     247                 :            :     const Size&                 GetMargin() const;
     248                 :            :     void                        SetMargin( const Size& );
     249                 :            :     void                        DisconnectAllClients();
     250                 :            :     virtual SfxFrame*           GetSmartSelf( SfxFrame* pSelf, SfxMedium& rMedium );
     251                 :          4 :     sal_Bool                        NewWindowAllowed() const            { return !bNoNewWindow; }
     252                 :            :     void                        SetNewWindowAllowed( sal_Bool bSet )    { bNoNewWindow = !bSet; }
     253                 :            : 
     254                 :            :     void                        SetController( SfxBaseController* pController );
     255                 :            :     ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >
     256                 :            :                                 GetController();
     257                 :            : 
     258                 :            :     sal_Bool                        TryContextMenuInterception( Menu& rIn, const ::rtl::OUString& rMenuIdentifier, Menu*& rpOut, ::com::sun::star::ui::ContextMenuExecuteEvent aEvent );
     259                 :            : 
     260                 :            :     void                        ExecPrint( const com::sun::star::uno::Sequence < com::sun::star::beans::PropertyValue >&, sal_Bool, sal_Bool );
     261                 :            : 
     262                 :            :     void                        AddRemoveClipboardListener( const com::sun::star::uno::Reference < com::sun::star::datatransfer::clipboard::XClipboardListener>&, sal_Bool );
     263                 :            :     ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboardNotifier > GetClipboardNotifier();
     264                 :            : 
     265                 :            : #if _SOLAR__PRIVATE
     266                 :            :     SAL_DLLPRIVATE SfxInPlaceClient* GetUIActiveIPClient_Impl() const;
     267                 :            :     SAL_DLLPRIVATE void AddContextMenuInterceptor_Impl( const ::com::sun::star::uno::Reference < ::com::sun::star::ui::XContextMenuInterceptor >& xInterceptor );
     268                 :            :     SAL_DLLPRIVATE void RemoveContextMenuInterceptor_Impl( const ::com::sun::star::uno::Reference < ::com::sun::star::ui::XContextMenuInterceptor >& xInterceptor );
     269                 :            :     SAL_DLLPRIVATE bool GlobalKeyInput_Impl( const KeyEvent &rKeyEvent );
     270                 :            : 
     271                 :          2 :     SAL_DLLPRIVATE void NewIPClient_Impl( SfxInPlaceClient *pIPClient )
     272                 :          2 :                                 { GetIPClientList_Impl(sal_True)->push_back(pIPClient); }
     273                 :            :     SAL_DLLPRIVATE void IPClientGone_Impl( SfxInPlaceClient *pIPClient );
     274                 :            :     SAL_DLLPRIVATE SfxInPlaceClientList* GetIPClientList_Impl( sal_Bool bCreate = sal_True ) const;
     275                 :            :     SAL_DLLPRIVATE void ResetAllClients_Impl( SfxInPlaceClient *pIP );
     276                 :            :     SAL_DLLPRIVATE void DiscardClients_Impl();
     277                 :            : 
     278                 :            :     SAL_DLLPRIVATE SfxPrinter* SetPrinter_Impl( SfxPrinter *pNewPrinter );
     279                 :            :     SAL_DLLPRIVATE sal_Bool IsShowView_Impl() const;
     280                 :            : 
     281                 :            :     SAL_DLLPRIVATE long HandleNotifyEvent_Impl( NotifyEvent& rEvent );
     282                 :            :     SAL_DLLPRIVATE sal_Bool HasKeyListeners_Impl();
     283                 :            :     SAL_DLLPRIVATE sal_Bool HasMouseClickListeners_Impl();
     284                 :            : 
     285                 :            :     SAL_DLLPRIVATE SfxBaseController*   GetBaseController_Impl() const;
     286                 :            : 
     287                 :            :     // Shell Interface
     288                 :            :     SAL_DLLPRIVATE void ExecPrint_Impl(SfxRequest &);
     289                 :            :     SAL_DLLPRIVATE void ExecMisc_Impl(SfxRequest &);
     290                 :            :     SAL_DLLPRIVATE void GetState_Impl(SfxItemSet&);
     291                 :            :     SAL_DLLPRIVATE SfxFrameSetDescriptor* GetFrameSet_Impl() const;
     292                 :            :     SAL_DLLPRIVATE void SetFrameSet_Impl(SfxFrameSetDescriptor*);
     293                 :            :     SAL_DLLPRIVATE void CheckIPClient_Impl( SfxInPlaceClient*, const Rectangle& );
     294                 :            :     SAL_DLLPRIVATE void PushSubShells_Impl( sal_Bool bPush=sal_True );
     295                 :       1636 :     SAL_DLLPRIVATE void PopSubShells_Impl() { PushSubShells_Impl( sal_False ); }
     296                 :            :     SAL_DLLPRIVATE void TakeOwnerShip_Impl();
     297                 :            :     SAL_DLLPRIVATE void TakeFrameOwnerShip_Impl();
     298                 :            :     SAL_DLLPRIVATE sal_Bool ExecKey_Impl(const KeyEvent& aKey);
     299                 :            : #endif
     300                 :            : };
     301                 :            : 
     302                 :            : //========================================================================
     303                 :            : 
     304                 :            : inline void SfxViewShell::LostFocus() const
     305                 :            : 
     306                 :            : /*  [Description]
     307                 :            : 
     308                 :            :     This method has to be  called by the application developer, if the edit
     309                 :            :     window has lost the focus. The SFx has for example the ability to turn off
     310                 :            :     the accelerator, so that the cursor keys, the Delete button, etc. work in
     311                 :            :     certain Floating-Windows, even though they are redefined by the
     312                 :            :     Accelerator.
     313                 :            : 
     314                 :            :     [Note]
     315                 :            : 
     316                 :            :     <StarView> unfortunatly does not provide the possibility to define
     317                 :            :     such events 'from the side'.
     318                 :            : */
     319                 :            : 
     320                 :            : {
     321                 :            : }
     322                 :            : 
     323                 :            : //------------------------------------------------------------------------
     324                 :            : 
     325                 :     609592 : inline SfxViewFrame* SfxViewShell::GetViewFrame() const
     326                 :            : 
     327                 :            : /*  [Description]
     328                 :            : 
     329                 :            :     This method returns a pointer to the <SfxViewFrame> Instance in which
     330                 :            :     this SfxViewShell is displayed. This is the instance that was passed
     331                 :            :     on in the constructor. It is guaranteed that the returned pointer
     332                 :            :     points on the valid SfxViewFrame instance.
     333                 :            : 
     334                 :            :     [Cross-reference]
     335                 :            : 
     336                 :            :     <SfxShell::GetFrame()const>
     337                 :            : */
     338                 :            : 
     339                 :            : {
     340                 :     609592 :     return pFrame;
     341                 :            : }
     342                 :            : 
     343                 :            : #endif // #ifndef _SFXVIEWSH_HXX
     344                 :            : 
     345                 :            : 
     346                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10