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

Generated by: LCOV version 1.10