LCOV - code coverage report
Current view: top level - toolkit/source/awt - vclxtopwindow.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 47 115 40.9 %
Date: 2015-06-13 12:38:46 Functions: 13 26 50.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             : 
      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        6551 : VCLXTopWindow_Base::VCLXTopWindow_Base( const bool _bSupportSystemWindowPeer )
      50        6551 :     :m_bWHWND( _bSupportSystemWindowPeer )
      51             : {
      52        6551 : }
      53             : 
      54        5842 : VCLXTopWindow_Base::~VCLXTopWindow_Base()
      55             : {
      56        5842 : }
      57             : 
      58      630488 : Any VCLXTopWindow_Base::queryInterface( const Type & rType ) throw(RuntimeException, std::exception)
      59             : {
      60      630488 :     ::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      630488 :     if ( !aRet.hasValue() && m_bWHWND )
      64      535354 :         aRet = VCLXTopWindow_SBase::queryInterface( rType );
      65             : 
      66      630488 :     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        9885 : 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        9885 :     SolarMutexGuard aGuard;
     122             : 
     123        9885 :     GetTopWindowListenersImpl().addInterface( rxListener );
     124        9885 : }
     125             : 
     126        9876 : 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        9876 :     SolarMutexGuard aGuard;
     129             : 
     130        9876 :     GetTopWindowListenersImpl().removeInterface( rxListener );
     131        9876 : }
     132             : 
     133         615 : void VCLXTopWindow_Base::toFront(  ) throw(::com::sun::star::uno::RuntimeException, std::exception)
     134             : {
     135         615 :     SolarMutexGuard aGuard;
     136             : 
     137         615 :     vcl::Window* pWindow = GetWindowImpl();
     138         615 :     if ( pWindow )
     139         615 :         static_cast<WorkWindow*>(pWindow)->ToTop( ToTopFlags::RestoreWhenMin );
     140         615 : }
     141             : 
     142           0 : void VCLXTopWindow_Base::toBack(  ) throw(::com::sun::star::uno::RuntimeException, std::exception)
     143             : {
     144           0 : }
     145             : 
     146           4 : 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           4 :     SolarMutexGuard aGuard;
     149             : 
     150           4 :     vcl::Window* pWindow = GetWindowImpl();
     151           4 :     if ( pWindow )
     152             :     {
     153           4 :         SystemWindow* pSystemWindow = static_cast<SystemWindow*>( pWindow );
     154           4 :         pSystemWindow->SetMenuBar( NULL );
     155           4 :         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           4 :     mxMenuBar = rxMenu;
     163           4 : }
     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        6551 : VCLXTopWindow::VCLXTopWindow(bool bWHWND)
     250        6551 :     : VCLXTopWindow_Base( bWHWND )
     251             : {
     252        6551 : }
     253             : 
     254       11675 : VCLXTopWindow::~VCLXTopWindow()
     255             : {
     256       11675 : }
     257             : 
     258         619 : vcl::Window* VCLXTopWindow::GetWindowImpl()
     259             : {
     260         619 :     return VCLXContainer::GetWindow();
     261             : }
     262             : 
     263       19761 : ::cppu::OInterfaceContainerHelper& VCLXTopWindow::GetTopWindowListenersImpl()
     264             : {
     265       19761 :     return GetTopWindowListeners();
     266             : }
     267             : 
     268             : // ::com::sun::star::uno::XInterface
     269      630488 : ::com::sun::star::uno::Any VCLXTopWindow::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException, std::exception)
     270             : {
     271      630488 :     ::com::sun::star::uno::Any aRet( VCLXTopWindow_Base::queryInterface( rType ) );
     272             : 
     273      630488 :     if ( !aRet.hasValue() )
     274      542573 :         aRet = VCLXContainer::queryInterface( rType );
     275             : 
     276      630488 :     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             : }
     288             : 
     289             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11