LCOV - code coverage report
Current view: top level - toolkit/source/awt - vclxtopwindow.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 46 128 35.9 %
Date: 2012-08-25 Functions: 13 26 50.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 34 226 15.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <com/sun/star/lang/SystemDependent.hpp>
      30                 :            : #include <com/sun/star/awt/SystemDependentXWindow.hpp>
      31                 :            : 
      32                 :            : #if defined ( QUARTZ )
      33                 :            : #include "premac.h"
      34                 :            : #include <Cocoa/Cocoa.h>
      35                 :            : #include "postmac.h"
      36                 :            : #endif
      37                 :            : 
      38                 :            : #if defined ( IOS )
      39                 :            : #include "premac.h"
      40                 :            : #include <UIKit/UIKit.h>
      41                 :            : #include "postmac.h"
      42                 :            : #endif
      43                 :            : 
      44                 :            : #include <vcl/syschild.hxx>
      45                 :            : #include <vcl/sysdata.hxx>
      46                 :            : #include <cppuhelper/typeprovider.hxx>
      47                 :            : #include <comphelper/sequence.hxx>
      48                 :            : 
      49                 :            : #include <toolkit/awt/vclxtopwindow.hxx>
      50                 :            : #include <toolkit/awt/vclxmenu.hxx>
      51                 :            : #include <toolkit/helper/macros.hxx>
      52                 :            : 
      53                 :            : #include <vcl/wrkwin.hxx>
      54                 :            : #include <vcl/syswin.hxx>
      55                 :            : #include <vcl/menu.hxx>
      56                 :            : #include <vcl/svapp.hxx>
      57                 :            : 
      58                 :            : using ::com::sun::star::uno::RuntimeException;
      59                 :            : using ::com::sun::star::uno::Sequence;
      60                 :            : using ::com::sun::star::uno::Type;
      61                 :            : using ::com::sun::star::uno::Any;
      62                 :            : using ::com::sun::star::lang::IndexOutOfBoundsException;
      63                 :            : 
      64                 :       5635 : VCLXTopWindow_Base::VCLXTopWindow_Base( const bool _bSupportSystemWindowPeer )
      65                 :       5635 :     :m_bWHWND( _bSupportSystemWindowPeer )
      66                 :            : {
      67                 :       5635 : }
      68                 :            : 
      69                 :       5413 : VCLXTopWindow_Base::~VCLXTopWindow_Base()
      70                 :            : {
      71         [ -  + ]:       5413 : }
      72                 :            : 
      73                 :     328198 : Any VCLXTopWindow_Base::queryInterface( const Type & rType ) throw(RuntimeException)
      74                 :            : {
      75                 :     328198 :     ::com::sun::star::uno::Any aRet( VCLXTopWindow_XBase::queryInterface( rType ) );
      76                 :            : 
      77                 :            :     // do not expose XSystemDependentWindowPeer if we do not have a system window handle
      78 [ +  + ][ +  + ]:     328198 :     if ( !aRet.hasValue() && m_bWHWND )
                 [ +  + ]
      79         [ +  - ]:     274549 :         aRet = VCLXTopWindow_SBase::queryInterface( rType );
      80                 :            : 
      81                 :     328198 :     return aRet;
      82                 :            : }
      83                 :            : 
      84                 :          0 : Sequence< Type > VCLXTopWindow_Base::getTypes() throw(RuntimeException)
      85                 :            : {
      86                 :          0 :     Sequence< Type > aTypes( VCLXTopWindow_XBase::getTypes() );
      87         [ #  # ]:          0 :     if ( m_bWHWND )
      88 [ #  # ][ #  # ]:          0 :         aTypes = ::comphelper::concatSequences( aTypes, VCLXTopWindow_SBase::getTypes() );
         [ #  # ][ #  # ]
                 [ #  # ]
      89                 :          0 :     return aTypes;
      90                 :            : }
      91                 :            : 
      92                 :          0 : ::com::sun::star::uno::Any VCLXTopWindow_Base::getWindowHandle( const ::com::sun::star::uno::Sequence< sal_Int8 >& /*ProcessId*/, sal_Int16 SystemType ) throw(::com::sun::star::uno::RuntimeException)
      93                 :            : {
      94         [ #  # ]:          0 :     SolarMutexGuard aGuard;
      95                 :            : 
      96                 :            :     // TODO, check the process id
      97                 :          0 :     ::com::sun::star::uno::Any aRet;
      98         [ #  # ]:          0 :     Window* pWindow = GetWindowImpl();
      99         [ #  # ]:          0 :     if ( pWindow )
     100                 :            :     {
     101         [ #  # ]:          0 :         const SystemEnvData* pSysData = ((SystemWindow *)pWindow)->GetSystemData();
     102         [ #  # ]:          0 :         if( pSysData )
     103                 :            :         {
     104                 :            : #if (defined WNT)
     105                 :            :             if( SystemType == ::com::sun::star::lang::SystemDependent::SYSTEM_WIN32 )
     106                 :            :             {
     107                 :            :                  aRet <<= (sal_Int32)pSysData->hWnd;
     108                 :            :             }
     109                 :            : #elif (defined QUARTZ)
     110                 :            :             if( SystemType == ::com::sun::star::lang::SystemDependent::SYSTEM_MAC )
     111                 :            :             {
     112                 :            :                  aRet <<= (sal_IntPtr)pSysData->pView;
     113                 :            :             }
     114                 :            : #elif (defined IOS)
     115                 :            :             if( SystemType == ::com::sun::star::lang::SystemDependent::SYSTEM_IOS )
     116                 :            :             {
     117                 :            :                  aRet <<= (sal_IntPtr)pSysData->pView;
     118                 :            :             }
     119                 :            : #elif (defined UNX)
     120         [ #  # ]:          0 :             if( SystemType == ::com::sun::star::lang::SystemDependent::SYSTEM_XWINDOW )
     121                 :            :             {
     122                 :          0 :                 ::com::sun::star::awt::SystemDependentXWindow aSD;
     123                 :          0 :                 aSD.DisplayPointer = sal::static_int_cast< sal_Int64 >(reinterpret_cast< sal_IntPtr >(pSysData->pDisplay));
     124                 :          0 :                 aSD.WindowHandle = pSysData->aWindow;
     125         [ #  # ]:          0 :                 aRet <<= aSD;
     126                 :            :             }
     127                 :            : #endif
     128                 :            :         }
     129                 :            :     }
     130         [ #  # ]:          0 :     return aRet;
     131                 :            : }
     132                 :            : 
     133                 :       5174 : void VCLXTopWindow_Base::addTopWindowListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTopWindowListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException)
     134                 :            : {
     135         [ +  - ]:       5174 :     SolarMutexGuard aGuard;
     136                 :            : 
     137 [ +  - ][ +  - ]:       5174 :     GetTopWindowListenersImpl().addInterface( rxListener );
                 [ +  - ]
     138                 :       5174 : }
     139                 :            : 
     140                 :       5083 : void VCLXTopWindow_Base::removeTopWindowListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTopWindowListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException)
     141                 :            : {
     142         [ +  - ]:       5083 :     SolarMutexGuard aGuard;
     143                 :            : 
     144 [ +  - ][ +  - ]:       5083 :     GetTopWindowListenersImpl().removeInterface( rxListener );
                 [ +  - ]
     145                 :       5083 : }
     146                 :            : 
     147                 :       1126 : void VCLXTopWindow_Base::toFront(  ) throw(::com::sun::star::uno::RuntimeException)
     148                 :            : {
     149         [ +  - ]:       1126 :     SolarMutexGuard aGuard;
     150                 :            : 
     151         [ +  - ]:       1126 :     Window* pWindow = GetWindowImpl();
     152         [ +  - ]:       1126 :     if ( pWindow )
     153 [ +  - ][ +  - ]:       1126 :         ((WorkWindow*)pWindow)->ToTop( TOTOP_RESTOREWHENMIN );
     154                 :       1126 : }
     155                 :            : 
     156                 :          0 : void VCLXTopWindow_Base::toBack(  ) throw(::com::sun::star::uno::RuntimeException)
     157                 :            : {
     158                 :          0 : }
     159                 :            : 
     160                 :          2 : void VCLXTopWindow_Base::setMenuBar( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMenuBar >& rxMenu ) throw(::com::sun::star::uno::RuntimeException)
     161                 :            : {
     162         [ +  - ]:          2 :     SolarMutexGuard aGuard;
     163                 :            : 
     164         [ +  - ]:          2 :     SystemWindow* pWindow = (SystemWindow*) GetWindowImpl();
     165         [ +  - ]:          2 :     if ( pWindow )
     166                 :            :     {
     167         [ +  - ]:          2 :         pWindow->SetMenuBar( NULL );
     168         [ -  + ]:          2 :         if ( rxMenu.is() )
     169                 :            :         {
     170                 :          0 :             VCLXMenu* pMenu = VCLXMenu::GetImplementation( rxMenu );
     171 [ #  # ][ #  # ]:          0 :             if ( pMenu && !pMenu->IsPopupMenu() )
         [ #  # ][ #  # ]
     172         [ #  # ]:          0 :                 pWindow->SetMenuBar( (MenuBar*) pMenu->GetMenu() );
     173                 :            :         }
     174                 :            :     }
     175 [ +  - ][ +  - ]:          2 :     mxMenuBar = rxMenu;
     176                 :          2 : }
     177                 :            : 
     178                 :            : //--------------------------------------------------------------------
     179                 :          0 : ::sal_Bool SAL_CALL VCLXTopWindow_Base::getIsMaximized() throw (RuntimeException)
     180                 :            : {
     181         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     182                 :            : 
     183 [ #  # ][ #  # ]:          0 :     const WorkWindow* pWindow = dynamic_cast< const WorkWindow* >( GetWindowImpl() );
     184         [ #  # ]:          0 :     if ( !pWindow )
     185                 :          0 :         return sal_False;
     186                 :            : 
     187 [ #  # ][ #  # ]:          0 :     return pWindow->IsMaximized();
     188                 :            : }
     189                 :            : 
     190                 :            : //--------------------------------------------------------------------
     191                 :          0 : void SAL_CALL VCLXTopWindow_Base::setIsMaximized( ::sal_Bool _ismaximized ) throw (RuntimeException)
     192                 :            : {
     193         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     194                 :            : 
     195 [ #  # ][ #  # ]:          0 :     WorkWindow* pWindow = dynamic_cast< WorkWindow* >( GetWindowImpl() );
     196         [ #  # ]:          0 :     if ( !pWindow )
     197                 :          0 :         return;
     198                 :            : 
     199 [ #  # ][ #  # ]:          0 :     pWindow->Maximize( _ismaximized );
                 [ #  # ]
     200                 :            : }
     201                 :            : 
     202                 :            : //--------------------------------------------------------------------
     203                 :          0 : ::sal_Bool SAL_CALL VCLXTopWindow_Base::getIsMinimized() throw (RuntimeException)
     204                 :            : {
     205         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     206                 :            : 
     207 [ #  # ][ #  # ]:          0 :     const WorkWindow* pWindow = dynamic_cast< const WorkWindow* >( GetWindowImpl() );
     208         [ #  # ]:          0 :     if ( !pWindow )
     209                 :          0 :         return sal_False;
     210                 :            : 
     211 [ #  # ][ #  # ]:          0 :     return pWindow->IsMinimized();
     212                 :            : }
     213                 :            : 
     214                 :            : //--------------------------------------------------------------------
     215                 :          0 : void SAL_CALL VCLXTopWindow_Base::setIsMinimized( ::sal_Bool _isMinimized ) throw (RuntimeException)
     216                 :            : {
     217         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     218                 :            : 
     219 [ #  # ][ #  # ]:          0 :     WorkWindow* pWindow = dynamic_cast< WorkWindow* >( GetWindowImpl() );
     220         [ #  # ]:          0 :     if ( !pWindow )
     221                 :          0 :         return;
     222                 :            : 
     223 [ #  # ][ #  # ]:          0 :     _isMinimized ? pWindow->Minimize() : pWindow->Restore();
         [ #  # ][ #  # ]
                 [ #  # ]
     224                 :            : }
     225                 :            : 
     226                 :            : //--------------------------------------------------------------------
     227                 :          0 : ::sal_Int32 SAL_CALL VCLXTopWindow_Base::getDisplay() throw (RuntimeException)
     228                 :            : {
     229         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     230                 :            : 
     231 [ #  # ][ #  # ]:          0 :     const SystemWindow* pWindow = dynamic_cast< const SystemWindow* >( GetWindowImpl() );
     232         [ #  # ]:          0 :     if ( !pWindow )
     233                 :          0 :         return 0;
     234                 :            : 
     235 [ #  # ][ #  # ]:          0 :     return pWindow->GetScreenNumber();
     236                 :            : }
     237                 :            : 
     238                 :            : //--------------------------------------------------------------------
     239                 :          0 : void SAL_CALL VCLXTopWindow_Base::setDisplay( ::sal_Int32 _display ) throw (RuntimeException, IndexOutOfBoundsException)
     240                 :            : {
     241         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     242                 :            : 
     243 [ #  # ][ #  # ]:          0 :     if ( ( _display < 0 ) || ( _display >= (sal_Int32)Application::GetScreenCount() ) )
         [ #  # ][ #  # ]
     244         [ #  # ]:          0 :         throw IndexOutOfBoundsException();
     245                 :            : 
     246 [ #  # ][ #  # ]:          0 :     SystemWindow* pWindow = dynamic_cast< SystemWindow* >( GetWindowImpl() );
     247         [ #  # ]:          0 :     if ( !pWindow )
     248                 :          0 :         return;
     249                 :            : 
     250 [ #  # ][ #  # ]:          0 :     pWindow->SetScreenNumber( _display );
                 [ #  # ]
     251                 :            : }
     252                 :            : 
     253                 :            : //  ----------------------------------------------------
     254                 :            : //  class VCLXTopWindow
     255                 :            : //  ----------------------------------------------------
     256                 :            : 
     257                 :          0 : void VCLXTopWindow::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
     258                 :            : {
     259                 :          0 :     VCLXContainer::ImplGetPropertyIds( rIds );
     260                 :          0 : }
     261                 :            : 
     262                 :       5635 : VCLXTopWindow::VCLXTopWindow(bool bWHWND)
     263         [ +  - ]:       5635 :     : VCLXTopWindow_Base( bWHWND )
     264                 :            : {
     265                 :       5635 : }
     266                 :            : 
     267         [ +  - ]:       5413 : VCLXTopWindow::~VCLXTopWindow()
     268                 :            : {
     269         [ -  + ]:      10824 : }
     270                 :            : 
     271                 :       1128 : Window* VCLXTopWindow::GetWindowImpl()
     272                 :            : {
     273                 :       1128 :     return VCLXContainer::GetWindow();
     274                 :            : }
     275                 :            : 
     276                 :      10257 : ::cppu::OInterfaceContainerHelper& VCLXTopWindow::GetTopWindowListenersImpl()
     277                 :            : {
     278                 :      10257 :     return GetTopWindowListeners();
     279                 :            : }
     280                 :            : 
     281                 :            : // ::com::sun::star::uno::XInterface
     282                 :     328198 : ::com::sun::star::uno::Any VCLXTopWindow::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException)
     283                 :            : {
     284                 :     328198 :     ::com::sun::star::uno::Any aRet( VCLXTopWindow_Base::queryInterface( rType ) );
     285                 :            : 
     286         [ +  + ]:     328198 :     if ( !aRet.hasValue() )
     287         [ +  - ]:     283080 :         aRet = VCLXContainer::queryInterface( rType );
     288                 :            : 
     289                 :     328198 :     return aRet;
     290                 :            : }
     291                 :            : 
     292                 :          0 : ::com::sun::star::uno::Sequence< sal_Int8 > VCLXTopWindow::getImplementationId() throw(::com::sun::star::uno::RuntimeException)
     293                 :            : {
     294                 :            :     static ::cppu::OImplementationId* pId = NULL;
     295                 :            :     static ::cppu::OImplementationId* pIdWithHandle = NULL;
     296         [ #  # ]:          0 :     if ( isSystemDependentWindowPeer() )
     297                 :            :     {
     298         [ #  # ]:          0 :         if( !pIdWithHandle )
     299                 :            :         {
     300 [ #  # ][ #  # ]:          0 :             ::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() );
     301         [ #  # ]:          0 :             if( !pIdWithHandle )
     302                 :            :             {
     303 [ #  # ][ #  # ]:          0 :                 static ::cppu::OImplementationId idWithHandle( sal_False );
     304                 :          0 :                 pIdWithHandle = &idWithHandle;
     305         [ #  # ]:          0 :             }
     306                 :            :         }
     307                 :            : 
     308                 :          0 :         return (*pIdWithHandle).getImplementationId();
     309                 :            :     }
     310                 :            :     else
     311                 :            :     {
     312         [ #  # ]:          0 :         if( !pId )
     313                 :            :         {
     314 [ #  # ][ #  # ]:          0 :             ::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() );
     315         [ #  # ]:          0 :             if( !pId )
     316                 :            :             {
     317 [ #  # ][ #  # ]:          0 :                 static ::cppu::OImplementationId id( sal_False );
     318                 :          0 :                 pId = &id;
     319         [ #  # ]:          0 :             }
     320                 :            :         }
     321                 :            : 
     322                 :          0 :         return (*pId).getImplementationId();
     323                 :            :     }
     324                 :            : }
     325                 :            : 
     326                 :          0 : ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > VCLXTopWindow::getTypes() throw(::com::sun::star::uno::RuntimeException)
     327                 :            : {
     328 [ #  # ][ #  # ]:          0 :     return ::comphelper::concatSequences( VCLXTopWindow_Base::getTypes(), VCLXContainer::getTypes() );
                 [ #  # ]
     329                 :            : }
     330                 :            : 
     331                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10