LCOV - code coverage report
Current view: top level - libreoffice/toolkit/source/awt - vclxtopwindow.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 30 128 23.4 %
Date: 2012-12-27 Functions: 10 26 38.5 %
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             : 
      20             : #include <com/sun/star/lang/SystemDependent.hpp>
      21             : #include <com/sun/star/awt/SystemDependentXWindow.hpp>
      22             : 
      23             : #if defined ( QUARTZ )
      24             : #include "premac.h"
      25             : #include <Cocoa/Cocoa.h>
      26             : #include "postmac.h"
      27             : #endif
      28             : 
      29             : #if defined ( IOS )
      30             : #include "premac.h"
      31             : #include <UIKit/UIKit.h>
      32             : #include "postmac.h"
      33             : #endif
      34             : 
      35             : #include <vcl/syschild.hxx>
      36             : #include <vcl/sysdata.hxx>
      37             : #include <cppuhelper/typeprovider.hxx>
      38             : #include <comphelper/sequence.hxx>
      39             : 
      40             : #include <toolkit/awt/vclxtopwindow.hxx>
      41             : #include <toolkit/awt/vclxmenu.hxx>
      42             : #include <toolkit/helper/macros.hxx>
      43             : 
      44             : #include <vcl/wrkwin.hxx>
      45             : #include <vcl/syswin.hxx>
      46             : #include <vcl/menu.hxx>
      47             : #include <vcl/svapp.hxx>
      48             : 
      49             : using ::com::sun::star::uno::RuntimeException;
      50             : using ::com::sun::star::uno::Sequence;
      51             : using ::com::sun::star::uno::Type;
      52             : using ::com::sun::star::uno::Any;
      53             : using ::com::sun::star::lang::IndexOutOfBoundsException;
      54             : 
      55         254 : VCLXTopWindow_Base::VCLXTopWindow_Base( const bool _bSupportSystemWindowPeer )
      56         254 :     :m_bWHWND( _bSupportSystemWindowPeer )
      57             : {
      58         254 : }
      59             : 
      60          12 : VCLXTopWindow_Base::~VCLXTopWindow_Base()
      61             : {
      62          12 : }
      63             : 
      64       28514 : Any VCLXTopWindow_Base::queryInterface( const Type & rType ) throw(RuntimeException)
      65             : {
      66       28514 :     ::com::sun::star::uno::Any aRet( VCLXTopWindow_XBase::queryInterface( rType ) );
      67             : 
      68             :     // do not expose XSystemDependentWindowPeer if we do not have a system window handle
      69       28514 :     if ( !aRet.hasValue() && m_bWHWND )
      70       23290 :         aRet = VCLXTopWindow_SBase::queryInterface( rType );
      71             : 
      72       28514 :     return aRet;
      73             : }
      74             : 
      75           0 : Sequence< Type > VCLXTopWindow_Base::getTypes() throw(RuntimeException)
      76             : {
      77           0 :     Sequence< Type > aTypes( VCLXTopWindow_XBase::getTypes() );
      78           0 :     if ( m_bWHWND )
      79           0 :         aTypes = ::comphelper::concatSequences( aTypes, VCLXTopWindow_SBase::getTypes() );
      80           0 :     return aTypes;
      81             : }
      82             : 
      83           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)
      84             : {
      85           0 :     SolarMutexGuard aGuard;
      86             : 
      87             :     // TODO, check the process id
      88           0 :     ::com::sun::star::uno::Any aRet;
      89           0 :     Window* pWindow = GetWindowImpl();
      90           0 :     if ( pWindow )
      91             :     {
      92           0 :         const SystemEnvData* pSysData = ((SystemWindow *)pWindow)->GetSystemData();
      93           0 :         if( pSysData )
      94             :         {
      95             : #if (defined WNT)
      96             :             if( SystemType == ::com::sun::star::lang::SystemDependent::SYSTEM_WIN32 )
      97             :             {
      98             :                  aRet <<= (sal_Int32)pSysData->hWnd;
      99             :             }
     100             : #elif (defined QUARTZ)
     101             :             if( SystemType == ::com::sun::star::lang::SystemDependent::SYSTEM_MAC )
     102             :             {
     103             :                  aRet <<= (sal_IntPtr)pSysData->pView;
     104             :             }
     105             : #elif (defined IOS)
     106             :             if( SystemType == ::com::sun::star::lang::SystemDependent::SYSTEM_IOS )
     107             :             {
     108             :                  aRet <<= (sal_IntPtr)pSysData->pView;
     109             :             }
     110             : #elif (defined UNX)
     111           0 :             if( SystemType == ::com::sun::star::lang::SystemDependent::SYSTEM_XWINDOW )
     112             :             {
     113           0 :                 ::com::sun::star::awt::SystemDependentXWindow aSD;
     114           0 :                 aSD.DisplayPointer = sal::static_int_cast< sal_Int64 >(reinterpret_cast< sal_IntPtr >(pSysData->pDisplay));
     115           0 :                 aSD.WindowHandle = pSysData->aWindow;
     116           0 :                 aRet <<= aSD;
     117             :             }
     118             : #endif
     119             :         }
     120             :     }
     121           0 :     return aRet;
     122             : }
     123             : 
     124         543 : void VCLXTopWindow_Base::addTopWindowListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTopWindowListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException)
     125             : {
     126         543 :     SolarMutexGuard aGuard;
     127             : 
     128         543 :     GetTopWindowListenersImpl().addInterface( rxListener );
     129         543 : }
     130             : 
     131         366 : void VCLXTopWindow_Base::removeTopWindowListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTopWindowListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException)
     132             : {
     133         366 :     SolarMutexGuard aGuard;
     134             : 
     135         366 :     GetTopWindowListenersImpl().removeInterface( rxListener );
     136         366 : }
     137             : 
     138           0 : void VCLXTopWindow_Base::toFront(  ) throw(::com::sun::star::uno::RuntimeException)
     139             : {
     140           0 :     SolarMutexGuard aGuard;
     141             : 
     142           0 :     Window* pWindow = GetWindowImpl();
     143           0 :     if ( pWindow )
     144           0 :         ((WorkWindow*)pWindow)->ToTop( TOTOP_RESTOREWHENMIN );
     145           0 : }
     146             : 
     147           0 : void VCLXTopWindow_Base::toBack(  ) throw(::com::sun::star::uno::RuntimeException)
     148             : {
     149           0 : }
     150             : 
     151           0 : void VCLXTopWindow_Base::setMenuBar( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMenuBar >& rxMenu ) throw(::com::sun::star::uno::RuntimeException)
     152             : {
     153           0 :     SolarMutexGuard aGuard;
     154             : 
     155           0 :     SystemWindow* pWindow = (SystemWindow*) GetWindowImpl();
     156           0 :     if ( pWindow )
     157             :     {
     158           0 :         pWindow->SetMenuBar( NULL );
     159           0 :         if ( rxMenu.is() )
     160             :         {
     161           0 :             VCLXMenu* pMenu = VCLXMenu::GetImplementation( rxMenu );
     162           0 :             if ( pMenu && !pMenu->IsPopupMenu() )
     163           0 :                 pWindow->SetMenuBar( (MenuBar*) pMenu->GetMenu() );
     164             :         }
     165             :     }
     166           0 :     mxMenuBar = rxMenu;
     167           0 : }
     168             : 
     169             : //--------------------------------------------------------------------
     170           0 : ::sal_Bool SAL_CALL VCLXTopWindow_Base::getIsMaximized() throw (RuntimeException)
     171             : {
     172           0 :     SolarMutexGuard aGuard;
     173             : 
     174           0 :     const WorkWindow* pWindow = dynamic_cast< const WorkWindow* >( GetWindowImpl() );
     175           0 :     if ( !pWindow )
     176           0 :         return sal_False;
     177             : 
     178           0 :     return pWindow->IsMaximized();
     179             : }
     180             : 
     181             : //--------------------------------------------------------------------
     182           0 : void SAL_CALL VCLXTopWindow_Base::setIsMaximized( ::sal_Bool _ismaximized ) throw (RuntimeException)
     183             : {
     184           0 :     SolarMutexGuard aGuard;
     185             : 
     186           0 :     WorkWindow* pWindow = dynamic_cast< WorkWindow* >( GetWindowImpl() );
     187           0 :     if ( !pWindow )
     188           0 :         return;
     189             : 
     190           0 :     pWindow->Maximize( _ismaximized );
     191             : }
     192             : 
     193             : //--------------------------------------------------------------------
     194           0 : ::sal_Bool SAL_CALL VCLXTopWindow_Base::getIsMinimized() throw (RuntimeException)
     195             : {
     196           0 :     SolarMutexGuard aGuard;
     197             : 
     198           0 :     const WorkWindow* pWindow = dynamic_cast< const WorkWindow* >( GetWindowImpl() );
     199           0 :     if ( !pWindow )
     200           0 :         return sal_False;
     201             : 
     202           0 :     return pWindow->IsMinimized();
     203             : }
     204             : 
     205             : //--------------------------------------------------------------------
     206           0 : void SAL_CALL VCLXTopWindow_Base::setIsMinimized( ::sal_Bool _isMinimized ) throw (RuntimeException)
     207             : {
     208           0 :     SolarMutexGuard aGuard;
     209             : 
     210           0 :     WorkWindow* pWindow = dynamic_cast< WorkWindow* >( GetWindowImpl() );
     211           0 :     if ( !pWindow )
     212           0 :         return;
     213             : 
     214           0 :     _isMinimized ? pWindow->Minimize() : pWindow->Restore();
     215             : }
     216             : 
     217             : //--------------------------------------------------------------------
     218           0 : ::sal_Int32 SAL_CALL VCLXTopWindow_Base::getDisplay() throw (RuntimeException)
     219             : {
     220           0 :     SolarMutexGuard aGuard;
     221             : 
     222           0 :     const SystemWindow* pWindow = dynamic_cast< const SystemWindow* >( GetWindowImpl() );
     223           0 :     if ( !pWindow )
     224           0 :         return 0;
     225             : 
     226           0 :     return pWindow->GetScreenNumber();
     227             : }
     228             : 
     229             : //--------------------------------------------------------------------
     230           0 : void SAL_CALL VCLXTopWindow_Base::setDisplay( ::sal_Int32 _display ) throw (RuntimeException, IndexOutOfBoundsException)
     231             : {
     232           0 :     SolarMutexGuard aGuard;
     233             : 
     234           0 :     if ( ( _display < 0 ) || ( _display >= (sal_Int32)Application::GetScreenCount() ) )
     235           0 :         throw IndexOutOfBoundsException();
     236             : 
     237           0 :     SystemWindow* pWindow = dynamic_cast< SystemWindow* >( GetWindowImpl() );
     238           0 :     if ( !pWindow )
     239           0 :         return;
     240             : 
     241           0 :     pWindow->SetScreenNumber( _display );
     242             : }
     243             : 
     244             : //  ----------------------------------------------------
     245             : //  class VCLXTopWindow
     246             : //  ----------------------------------------------------
     247             : 
     248           0 : void VCLXTopWindow::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
     249             : {
     250           0 :     VCLXContainer::ImplGetPropertyIds( rIds );
     251           0 : }
     252             : 
     253         254 : VCLXTopWindow::VCLXTopWindow(bool bWHWND)
     254         254 :     : VCLXTopWindow_Base( bWHWND )
     255             : {
     256         254 : }
     257             : 
     258          24 : VCLXTopWindow::~VCLXTopWindow()
     259             : {
     260          24 : }
     261             : 
     262           0 : Window* VCLXTopWindow::GetWindowImpl()
     263             : {
     264           0 :     return VCLXContainer::GetWindow();
     265             : }
     266             : 
     267         909 : ::cppu::OInterfaceContainerHelper& VCLXTopWindow::GetTopWindowListenersImpl()
     268             : {
     269         909 :     return GetTopWindowListeners();
     270             : }
     271             : 
     272             : // ::com::sun::star::uno::XInterface
     273       28514 : ::com::sun::star::uno::Any VCLXTopWindow::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException)
     274             : {
     275       28514 :     ::com::sun::star::uno::Any aRet( VCLXTopWindow_Base::queryInterface( rType ) );
     276             : 
     277       28514 :     if ( !aRet.hasValue() )
     278       23308 :         aRet = VCLXContainer::queryInterface( rType );
     279             : 
     280       28514 :     return aRet;
     281             : }
     282             : 
     283           0 : ::com::sun::star::uno::Sequence< sal_Int8 > VCLXTopWindow::getImplementationId() throw(::com::sun::star::uno::RuntimeException)
     284             : {
     285             :     static ::cppu::OImplementationId* pId = NULL;
     286             :     static ::cppu::OImplementationId* pIdWithHandle = NULL;
     287           0 :     if ( isSystemDependentWindowPeer() )
     288             :     {
     289           0 :         if( !pIdWithHandle )
     290             :         {
     291           0 :             ::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() );
     292           0 :             if( !pIdWithHandle )
     293             :             {
     294           0 :                 static ::cppu::OImplementationId idWithHandle( sal_False );
     295           0 :                 pIdWithHandle = &idWithHandle;
     296           0 :             }
     297             :         }
     298             : 
     299           0 :         return (*pIdWithHandle).getImplementationId();
     300             :     }
     301             :     else
     302             :     {
     303           0 :         if( !pId )
     304             :         {
     305           0 :             ::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() );
     306           0 :             if( !pId )
     307             :             {
     308           0 :                 static ::cppu::OImplementationId id( sal_False );
     309           0 :                 pId = &id;
     310           0 :             }
     311             :         }
     312             : 
     313           0 :         return (*pId).getImplementationId();
     314             :     }
     315             : }
     316             : 
     317           0 : ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > VCLXTopWindow::getTypes() throw(::com::sun::star::uno::RuntimeException)
     318             : {
     319           0 :     return ::comphelper::concatSequences( VCLXTopWindow_Base::getTypes(), VCLXContainer::getTypes() );
     320             : }
     321             : 
     322             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10