LCOV - code coverage report
Current view: top level - include/sfx2 - childwin.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 28 32 87.5 %
Date: 2015-06-13 12:38:46 Functions: 16 18 88.9 %
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_CHILDWIN_HXX
      20             : #define INCLUDED_SFX2_CHILDWIN_HXX
      21             : 
      22             : #include <sal/config.h>
      23             : 
      24             : #include <sfx2/dllapi.h>
      25             : #include <sal/types.h>
      26             : #include <o3tl/typed_flags_set.hxx>
      27             : #include <vcl/window.hxx>
      28             : #include <com/sun/star/frame/XFrame.hpp>
      29             : 
      30             : #include <sfx2/shell.hxx>
      31             : #include <sfx2/chalign.hxx>
      32             : 
      33             : #include <sfx2/bindings.hxx>
      34             :     // complete SfxBindings for complete SfxChildWinCtor, SfxChildWinContextCtor
      35             :     // under -fsanitize=function
      36             : 
      37             : class SfxWorkWindow;
      38             : class SfxModule;
      39             : class SfxShell;
      40             : class SfxChildWindow;
      41             : class SfxChildWindowContext;
      42             : 
      43             : enum class SfxChildWindowFlags
      44             : {
      45             :     NONE            = 0x00,
      46             :     ZOOMIN          = 0x01, // Fully retracted Float
      47             :     FORCEDOCK       = 0x04, // Float forbidden
      48             :     TASK            = 0x10, // ChildWindow inside the Task
      49             :     CANTGETFOCUS    = 0x20, // ChildWindow can not get focus
      50             :     ALWAYSAVAILABLE = 0x40, // ChildWindow is never disabled
      51             :     NEVERHIDE       = 0x80  // ChildWindow is can always made
      52             :                             // visible/is visible
      53             : };
      54             : 
      55             : namespace o3tl
      56             : {
      57             :     template<> struct typed_flags<SfxChildWindowFlags> : is_typed_flags<SfxChildWindowFlags, 0xf5> {};
      58             : }
      59             : 
      60             : 
      61             : #define CHILDWIN_NOPOS            USHRT_MAX
      62             : 
      63             : // ChildWindow Configuration
      64      348771 : struct SAL_DLLPUBLIC_RTTI SfxChildWinInfo
      65             : {
      66             :     bool                bVisible;
      67             :     Point               aPos;
      68             :     Size                aSize;
      69             :     SfxChildWindowFlags nFlags;
      70             :     OUString            aExtraString;
      71             :     OUString            aModule;
      72             :     OString             aWinState;
      73             : 
      74      113395 :                         SfxChildWinInfo()
      75      113395 :                         {
      76      113395 :                             bVisible = false;
      77      113395 :                             nFlags = SfxChildWindowFlags::NONE;
      78      113395 :                         }
      79             :     bool                GetExtraData_Impl( SfxChildAlignment    *pAlign,
      80             :                                            SfxChildAlignment    *pLastAlign = 0,
      81             :                                            Size                 *pSize = 0,
      82             :                                            sal_uInt16               *pLine = 0,
      83             :                                            sal_uInt16               *pPos = 0 ) const;
      84             : };
      85             : 
      86             : // ChildWindow factory methods
      87             : typedef SfxChildWindow* (*SfxChildWinCtor)( vcl::Window *pParentWindow,
      88             :                                             sal_uInt16 nId,
      89             :                                             SfxBindings *pBindings,
      90             :                                             SfxChildWinInfo *pInfo);
      91             : 
      92             : // ChildWindowsContexts factory methods
      93             : typedef SfxChildWindowContext* (*SfxChildWinContextCtor)( vcl::Window *pParentWindow,
      94             :                                             SfxBindings *pBindings,
      95             :                                             SfxChildWinInfo *pInfo);
      96          64 : struct SfxChildWinContextFactory
      97             : {
      98             :     SfxChildWinContextCtor  pCtor;      // Factory method
      99             :     sal_uInt16              nContextId; // Idenifier for SfxInterface
     100             :     SfxChildWinInfo         aInfo;      // Configuration
     101             : 
     102         153 :     SfxChildWinContextFactory( SfxChildWinContextCtor pTheCtor, sal_uInt16 nID )
     103             :         : pCtor(pTheCtor)
     104         153 :         , nContextId(nID)
     105         153 :     {}
     106             : };
     107             : 
     108             : class SfxChildWinContextArr_Impl;
     109             : 
     110             : struct SFX2_DLLPUBLIC SfxChildWinFactory
     111             : {
     112             :     SfxChildWinCtor            pCtor;  // Factory method
     113             :     sal_uInt16              nId;            // ChildWindow-Id ( SlotId )
     114             :     SfxChildWinInfo            aInfo;  // Configuration
     115             :     sal_uInt16                  nPos;  // Position in UI
     116             :     SfxChildWinContextArr_Impl *pArr;  // Array for Contexts
     117             : 
     118             :     SfxChildWinFactory( SfxChildWinCtor pTheCtor, sal_uInt16 nID, sal_uInt16 n );
     119             :     ~SfxChildWinFactory();
     120             : };
     121             : 
     122             : class FloatingWindow;
     123             : struct SfxChildWindow_Impl;
     124             : class SFX2_DLLPUBLIC SfxChildWindowContext
     125             : {
     126             : friend class SfxChildWindow;
     127             :     VclPtr<vcl::Window> pWindow;
     128             :     sal_uInt16          nContextId;
     129             : 
     130             : protected:
     131             :                         SfxChildWindowContext( sal_uInt16 nId );
     132             : 
     133             : public:
     134             :     virtual             ~SfxChildWindowContext();
     135             : 
     136           8 :     void                SetWindow( vcl::Window* pWin )
     137           8 :                         { pWindow=pWin; }
     138          36 :     vcl::Window*           GetWindow() const
     139          36 :                         { return pWindow; }
     140          16 :     sal_uInt16              GetContextId() const
     141          16 :                         { return nContextId; }
     142             : 
     143             :     FloatingWindow*     GetFloatingWindow() const;
     144             : 
     145             :     virtual void        Resizing( Size& rSize );
     146             :     static void         RegisterChildWindowContext(SfxModule*, sal_uInt16, SfxChildWinContextFactory*);
     147             : };
     148             : 
     149             : class SFX2_DLLPUBLIC SfxChildWindow
     150             : {
     151             :     VclPtr<vcl::Window>        pParent;        // parent window ( Topwindow )
     152             :     sal_uInt16                 nType;          // ChildWindow-Id
     153             : 
     154             : protected:
     155             :     SfxChildAlignment           eChildAlignment; // Current ::com::sun::star::drawing::Alignment
     156             :     VclPtr<vcl::Window>         pWindow;         // actual contents
     157             :     SfxChildWindow_Impl*        pImp;            // Implementation data
     158             : 
     159             : private:
     160             :     SfxChildWindowContext*      pContext;        // With context-sensitive ChildWindows:
     161             :                                                  // Annother window in pWindow
     162             :     SAL_DLLPRIVATE SfxChildWindowContext*
     163             :                         GetContext() const
     164             :                         { return pContext; }
     165             : 
     166             : protected:
     167             :                         SfxChildWindow(vcl::Window *pParentWindow, sal_uInt16 nId);
     168             : 
     169             : public:
     170             :     virtual             ~SfxChildWindow();
     171             :     void                Destroy();
     172       34959 :     vcl::Window*           GetWindow() const
     173       34959 :                         { return pWindow; }
     174        3157 :     vcl::Window*           GetParent() const
     175        3157 :                         { return pParent; }
     176       49874 :     SfxChildAlignment   GetAlignment() const
     177       49874 :                         { return eChildAlignment; }
     178             :     void                SetAlignment(SfxChildAlignment eAlign);
     179           0 :     Size                GetSizePixel() const
     180           0 :                         { return pWindow->GetSizePixel(); }
     181             :     void                SetPosSizePixel(const Point& rPoint, const Size& rSize)
     182             :                         { pWindow->SetPosSizePixel(rPoint, rSize); }
     183             :     Point               GetPosPixel()
     184             :                         { return pWindow->GetPosPixel(); }
     185             :     virtual void        Hide();
     186             :     virtual void        Show( ShowFlags nFlags );
     187             :     SfxChildWindowFlags GetFlags() const
     188             :                         { return GetInfo().nFlags; }
     189             :     bool                CanGetFocus() const;
     190             :     sal_uInt16          GetPosition();
     191       40787 :     sal_uInt16          GetType()
     192       40787 :                         { return nType; }
     193             : 
     194             :     void                CreateContext( sal_uInt16 nContextId, SfxBindings& );
     195       14562 :     sal_uInt16              GetContextId() const
     196       14562 :                         { return pContext ? pContext->GetContextId(): 0; }
     197             : 
     198          16 :     vcl::Window*           GetContextWindow() const
     199          16 :                         { return pContext ? pContext->GetWindow(): 0; }
     200             : 
     201             :     vcl::Window*           GetContextWindow( SfxModule *pModule ) const;
     202             : 
     203             :     virtual SfxChildWinInfo GetInfo() const;
     204             :     void                SaveStatus(const SfxChildWinInfo& rInfo);
     205             : 
     206             :     static void         RegisterChildWindow(SfxModule*, SfxChildWinFactory*);
     207             : 
     208             :     static SfxChildWindow* CreateChildWindow( sal_uInt16, vcl::Window*, SfxBindings*, SfxChildWinInfo&);
     209             :     void                SetHideNotDelete( bool bOn );
     210             :     bool                IsHideNotDelete() const;
     211             :     bool                IsHideAtToggle() const;
     212             :     bool                IsVisible() const;
     213             :     void                SetWantsFocus( bool );
     214             :     bool                WantsFocus() const;
     215             : 
     216             :     virtual bool        QueryClose();
     217             :     com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >           GetFrame();
     218             :     void                SetFrame( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > & );
     219             : 
     220             :     SAL_DLLPRIVATE static void InitializeChildWinFactory_Impl(sal_uInt16, SfxChildWinInfo&);
     221             :     void SetVisible_Impl( bool bVis );
     222             :     SAL_DLLPRIVATE void SetWorkWindow_Impl( SfxWorkWindow* );
     223             :     SAL_DLLPRIVATE void Activate_Impl();
     224             :     SAL_DLLPRIVATE void Deactivate_Impl();
     225             : 
     226             :     SAL_DLLPRIVATE SfxChildWindowContext*
     227           0 :                         GetContext_Impl() const
     228           0 :                         { return pContext; }
     229             :     SAL_DLLPRIVATE void SetFactory_Impl( SfxChildWinFactory* );
     230             : };
     231             : 
     232             : 
     233             : //! soon obsolete !
     234             : #define SFX_DECL_CHILDWINDOW_CONTEXT(Class) \
     235             :         static  SfxChildWindowContext* CreateImpl(vcl::Window *pParent, \
     236             :                     SfxBindings *pBindings, SfxChildWinInfo* pInfo ); \
     237             :         static  void RegisterChildWindowContext(SfxModule *pMod=0); \
     238             : 
     239             : //! The Macro of the future ...
     240             : #define SFX_DECL_CHILDWINDOWCONTEXT(Class) \
     241             :         static  SfxChildWindowContext* CreateImpl(vcl::Window *pParent, \
     242             :                     SfxBindings *pBindings, SfxChildWinInfo* pInfo ); \
     243             :         static  void RegisterChildWindowContext(sal_uInt16, SfxModule *pMod=0); \
     244             : 
     245             : //! soon obsolete !
     246             : #define SFX_IMPL_CHILDWINDOW_CONTEXT(Class, MyID, ShellClass) \
     247             :         SfxChildWindowContext* Class::CreateImpl( vcl::Window *pParent, \
     248             :                 SfxBindings *pBindings, SfxChildWinInfo* pInfo ) \
     249             :         {   \
     250             :             SfxChildWindowContext *pContext = new Class(pParent, \
     251             :                     /* cast is safe here! */static_cast< sal_uInt16 >(ShellClass::GetInterfaceId()), \
     252             :                     pBindings,pInfo); \
     253             :             return pContext; \
     254             :         } \
     255             :         void    Class::RegisterChildWindowContext(SfxModule* pMod)   \
     256             :         {   \
     257             :             SfxChildWinContextFactory *pFact = new SfxChildWinContextFactory( \
     258             :                 Class::CreateImpl, \
     259             :                 /* cast is safe here! */static_cast< sal_uInt16 >(ShellClass::GetInterfaceId()) );   \
     260             :             SfxChildWindowContext::RegisterChildWindowContext(pMod, MyID, pFact); \
     261             :         }
     262             : 
     263             : //! The Macro of the future ...
     264             : // As a parameter and because of ContextId, CreateImpl must be handed the
     265             : // factory. As long as Id is set to 0 and patched in
     266             : // SfxChildWindow::CreateContext
     267             : #define SFX_IMPL_CHILDWINDOWCONTEXT(Class, MyID) \
     268             :         SfxChildWindowContext* Class::CreateImpl( vcl::Window *pParent, \
     269             :                 SfxBindings *pBindings, SfxChildWinInfo* pInfo ) \
     270             :         {   \
     271             :             SfxChildWindowContext *pContext = new Class(pParent,0,pBindings,pInfo);\
     272             :             return pContext; \
     273             :         } \
     274             :         void    Class::RegisterChildWindowContext(sal_uInt16 nId, SfxModule* pMod)   \
     275             :         {   \
     276             :             SfxChildWinContextFactory *pFact = new SfxChildWinContextFactory( \
     277             :                 Class::CreateImpl, nId );   \
     278             :             SfxChildWindowContext::RegisterChildWindowContext(pMod, MyID, pFact); \
     279             :         }
     280             : 
     281             : #define SFX_DECL_CHILDWINDOW(Class) \
     282             :     public  :   \
     283             :         static  SfxChildWindow* CreateImpl(vcl::Window *pParent, sal_uInt16 nId, \
     284             :                     SfxBindings *pBindings, SfxChildWinInfo* pInfo ); \
     285             :         static  void RegisterChildWindow (bool bVisible=false, SfxModule *pMod=NULL, SfxChildWindowFlags nFlags=SfxChildWindowFlags::NONE); \
     286             :         virtual SfxChildWinInfo GetInfo() const SAL_OVERRIDE
     287             : 
     288             : #define SFX_DECL_CHILDWINDOW_WITHID(Class) \
     289             :         SFX_DECL_CHILDWINDOW(Class); \
     290             :         static  sal_uInt16 GetChildWindowId ()\
     291             : 
     292             : #define SFX_IMPL_CHILDWINDOW(Class, MyID) \
     293             :         SFX_IMPL_POS_CHILDWINDOW(Class, MyID, CHILDWIN_NOPOS)
     294             : 
     295             : #define SFX_IMPL_CHILDWINDOW_WITHID(Class, MyID) \
     296             :         SFX_IMPL_POS_CHILDWINDOW_WITHID(Class, MyID, CHILDWIN_NOPOS)
     297             : 
     298             : #define SFX_IMPL_POS_CHILDWINDOW(Class, MyID, Pos) \
     299             :         SfxChildWindow* Class::CreateImpl( vcl::Window *pParent, \
     300             :                 sal_uInt16 nId, SfxBindings *pBindings, SfxChildWinInfo* pInfo ) \
     301             :                 {   \
     302             :                     SfxChildWindow *pWin = new Class(pParent, nId, pBindings, pInfo);\
     303             :                     return pWin; \
     304             :                 } \
     305             :         void    Class::RegisterChildWindow (bool bVis, SfxModule *pMod, SfxChildWindowFlags nFlags)   \
     306             :                 {   \
     307             :                     SfxChildWinFactory *pFact = new SfxChildWinFactory( \
     308             :                         Class::CreateImpl, MyID, Pos );   \
     309             :                     pFact->aInfo.nFlags |= nFlags;  \
     310             :                     pFact->aInfo.bVisible = bVis;         \
     311             :                     SfxChildWindow::RegisterChildWindow(pMod, pFact); \
     312             :                 }
     313             : 
     314             : #define SFX_IMPL_POS_CHILDWINDOW_WITHID(Class, MyID, Pos) \
     315             :         SFX_IMPL_POS_CHILDWINDOW(Class, MyID, Pos) \
     316             :         sal_uInt16 Class::GetChildWindowId () \
     317             :                 { return MyID; } \
     318             : 
     319             : #define SFX_IMPL_FLOATINGWINDOW(Class, MyID)    \
     320             :         SFX_IMPL_CHILDWINDOW(Class, MyID)       \
     321             :         SfxChildWinInfo Class::GetInfo() const \
     322             :         {                                       \
     323             :             SfxChildWinInfo aInfo = SfxChildWindow::GetInfo();     \
     324             :             static_cast<SfxFloatingWindow*>(GetWindow())->FillInfo( aInfo );  \
     325             :             return aInfo; }
     326             : 
     327             : #define SFX_IMPL_FLOATINGWINDOW_WITHID(Class, MyID)    \
     328             :         SFX_IMPL_CHILDWINDOW_WITHID(Class, MyID)       \
     329             :         SfxChildWinInfo Class::GetInfo() const \
     330             :         {                                       \
     331             :             SfxChildWinInfo aInfo = SfxChildWindow::GetInfo();     \
     332             :             static_cast<SfxFloatingWindow*>(GetWindow())->FillInfo( aInfo );  \
     333             :             return aInfo; }
     334             : 
     335             : #define SFX_IMPL_MODELESSDIALOG_WITHID(Class, MyID)    \
     336             :         SFX_IMPL_CHILDWINDOW_WITHID(Class, MyID)       \
     337             :         SfxChildWinInfo Class::GetInfo() const \
     338             :         {                                       \
     339             :             SfxChildWinInfo aInfo = SfxChildWindow::GetInfo();     \
     340             :             static_cast<SfxModelessDialog*>(GetWindow())->FillInfo( aInfo );  \
     341             :             return aInfo; }
     342             : 
     343             : 
     344             : #define SFX_IMPL_DOCKINGWINDOW(Class, MyID) \
     345             :         SFX_IMPL_CHILDWINDOW(Class, MyID)       \
     346             :         SfxChildWinInfo Class::GetInfo() const \
     347             :         {                                       \
     348             :             SfxChildWinInfo aInfo = SfxChildWindow::GetInfo();     \
     349             :             static_cast<SfxDockingWindow*>(GetWindow())->FillInfo( aInfo );  \
     350             :             return aInfo; }
     351             : 
     352             : #define SFX_IMPL_DOCKINGWINDOW_WITHID(Class, MyID) \
     353             :         SFX_IMPL_CHILDWINDOW_WITHID(Class, MyID)       \
     354             :         SfxChildWinInfo Class::GetInfo() const \
     355             :         {                                       \
     356             :             SfxChildWinInfo aInfo = SfxChildWindow::GetInfo();     \
     357             :             static_cast<SfxDockingWindow*>(GetWindow())->FillInfo( aInfo );  \
     358             :             return aInfo; }
     359             : 
     360             : #define SFX_IMPL_TOOLBOX(Class, MyID)   \
     361             :         SFX_IMPL_CHILDWINDOW(Class, MyID)       \
     362             :         SfxChildWinInfo Class::GetInfo() const \
     363             :         {                                       \
     364             :             SfxChildWinInfo aInfo = SfxChildWindow::GetInfo();     \
     365             :             static_cast<SfxToolbox*>(GetWindow())->FillInfo( aInfo );  \
     366             :             return aInfo; }
     367             : 
     368             : bool GetPosSizeFromString( const OUString& rStr, Point& rPos, Size& rSize );
     369             : 
     370             : bool GetSplitSizeFromString( const OUString& rStr, Size& rSize );
     371             : 
     372             : #endif
     373             : 
     374             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11