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

Generated by: LCOV version 1.10