LCOV - code coverage report
Current view: top level - toolkit/source/awt - vclxtopwindow.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 46 114 40.4 %
Date: 2014-04-11 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        4383 : VCLXTopWindow_Base::VCLXTopWindow_Base( const bool _bSupportSystemWindowPeer )
      50        4383 :     :m_bWHWND( _bSupportSystemWindowPeer )
      51             : {
      52        4383 : }
      53             : 
      54        3957 : VCLXTopWindow_Base::~VCLXTopWindow_Base()
      55             : {
      56        3957 : }
      57             : 
      58      382843 : Any VCLXTopWindow_Base::queryInterface( const Type & rType ) throw(RuntimeException, std::exception)
      59             : {
      60      382843 :     ::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      382843 :     if ( !aRet.hasValue() && m_bWHWND )
      64      322415 :         aRet = VCLXTopWindow_SBase::queryInterface( rType );
      65             : 
      66      382843 :     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 :     Window* pWindow = GetWindowImpl();
      84           0 :     if ( pWindow )
      85             :     {
      86           0 :         const SystemEnvData* pSysData = ((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 <<= (sal_IntPtr)pSysData->hWnd;
      93             :             }
      94             : #elif (defined MACOSX)
      95             :             if( SystemType == ::com::sun::star::lang::SystemDependent::SYSTEM_MAC )
      96             :             {
      97             :                  aRet <<= (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        6256 : 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        6256 :     SolarMutexGuard aGuard;
     122             : 
     123        6256 :     GetTopWindowListenersImpl().addInterface( rxListener );
     124        6256 : }
     125             : 
     126        6243 : 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        6243 :     SolarMutexGuard aGuard;
     129             : 
     130        6243 :     GetTopWindowListenersImpl().removeInterface( rxListener );
     131        6243 : }
     132             : 
     133         663 : void VCLXTopWindow_Base::toFront(  ) throw(::com::sun::star::uno::RuntimeException, std::exception)
     134             : {
     135         663 :     SolarMutexGuard aGuard;
     136             : 
     137         663 :     Window* pWindow = GetWindowImpl();
     138         663 :     if ( pWindow )
     139         663 :         ((WorkWindow*)pWindow)->ToTop( TOTOP_RESTOREWHENMIN );
     140         663 : }
     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 :     SystemWindow* pWindow = (SystemWindow*) GetWindowImpl();
     151           4 :     if ( pWindow )
     152             :     {
     153           4 :         pWindow->SetMenuBar( NULL );
     154           4 :         if ( rxMenu.is() )
     155             :         {
     156           0 :             VCLXMenu* pMenu = VCLXMenu::GetImplementation( rxMenu );
     157           0 :             if ( pMenu && !pMenu->IsPopupMenu() )
     158           0 :                 pWindow->SetMenuBar( (MenuBar*) pMenu->GetMenu() );
     159             :         }
     160             :     }
     161           4 :     mxMenuBar = rxMenu;
     162           4 : }
     163             : 
     164             : 
     165           0 : sal_Bool SAL_CALL VCLXTopWindow_Base::getIsMaximized() throw (RuntimeException, std::exception)
     166             : {
     167           0 :     SolarMutexGuard aGuard;
     168             : 
     169           0 :     const WorkWindow* pWindow = dynamic_cast< const WorkWindow* >( GetWindowImpl() );
     170           0 :     if ( !pWindow )
     171           0 :         return sal_False;
     172             : 
     173           0 :     return pWindow->IsMaximized();
     174             : }
     175             : 
     176             : 
     177           0 : void SAL_CALL VCLXTopWindow_Base::setIsMaximized( sal_Bool _ismaximized ) throw (RuntimeException, std::exception)
     178             : {
     179           0 :     SolarMutexGuard aGuard;
     180             : 
     181           0 :     WorkWindow* pWindow = dynamic_cast< WorkWindow* >( GetWindowImpl() );
     182           0 :     if ( !pWindow )
     183           0 :         return;
     184             : 
     185           0 :     pWindow->Maximize( _ismaximized );
     186             : }
     187             : 
     188             : 
     189           0 : sal_Bool SAL_CALL VCLXTopWindow_Base::getIsMinimized() throw (RuntimeException, std::exception)
     190             : {
     191           0 :     SolarMutexGuard aGuard;
     192             : 
     193           0 :     const WorkWindow* pWindow = dynamic_cast< const WorkWindow* >( GetWindowImpl() );
     194           0 :     if ( !pWindow )
     195           0 :         return sal_False;
     196             : 
     197           0 :     return pWindow->IsMinimized();
     198             : }
     199             : 
     200             : 
     201           0 : void SAL_CALL VCLXTopWindow_Base::setIsMinimized( sal_Bool _isMinimized ) throw (RuntimeException, std::exception)
     202             : {
     203           0 :     SolarMutexGuard aGuard;
     204             : 
     205           0 :     WorkWindow* pWindow = dynamic_cast< WorkWindow* >( GetWindowImpl() );
     206           0 :     if ( !pWindow )
     207           0 :         return;
     208             : 
     209           0 :     _isMinimized ? pWindow->Minimize() : pWindow->Restore();
     210             : }
     211             : 
     212             : 
     213           0 : ::sal_Int32 SAL_CALL VCLXTopWindow_Base::getDisplay() throw (RuntimeException, std::exception)
     214             : {
     215           0 :     SolarMutexGuard aGuard;
     216             : 
     217           0 :     const SystemWindow* pWindow = dynamic_cast< const SystemWindow* >( GetWindowImpl() );
     218           0 :     if ( !pWindow )
     219           0 :         return 0;
     220             : 
     221           0 :     return pWindow->GetScreenNumber();
     222             : }
     223             : 
     224             : 
     225           0 : void SAL_CALL VCLXTopWindow_Base::setDisplay( ::sal_Int32 _display ) throw (RuntimeException, IndexOutOfBoundsException, std::exception)
     226             : {
     227           0 :     SolarMutexGuard aGuard;
     228             : 
     229           0 :     if ( ( _display < 0 ) || ( _display >= (sal_Int32)Application::GetScreenCount() ) )
     230           0 :         throw IndexOutOfBoundsException();
     231             : 
     232           0 :     SystemWindow* pWindow = dynamic_cast< SystemWindow* >( GetWindowImpl() );
     233           0 :     if ( !pWindow )
     234           0 :         return;
     235             : 
     236           0 :     pWindow->SetScreenNumber( _display );
     237             : }
     238             : 
     239             : 
     240             : //  class VCLXTopWindow
     241             : 
     242             : 
     243           0 : void VCLXTopWindow::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
     244             : {
     245           0 :     VCLXContainer::ImplGetPropertyIds( rIds );
     246           0 : }
     247             : 
     248        4383 : VCLXTopWindow::VCLXTopWindow(bool bWHWND)
     249        4383 :     : VCLXTopWindow_Base( bWHWND )
     250             : {
     251        4383 : }
     252             : 
     253        7909 : VCLXTopWindow::~VCLXTopWindow()
     254             : {
     255        7909 : }
     256             : 
     257         667 : Window* VCLXTopWindow::GetWindowImpl()
     258             : {
     259         667 :     return VCLXContainer::GetWindow();
     260             : }
     261             : 
     262       12499 : ::cppu::OInterfaceContainerHelper& VCLXTopWindow::GetTopWindowListenersImpl()
     263             : {
     264       12499 :     return GetTopWindowListeners();
     265             : }
     266             : 
     267             : // ::com::sun::star::uno::XInterface
     268      382843 : ::com::sun::star::uno::Any VCLXTopWindow::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException, std::exception)
     269             : {
     270      382843 :     ::com::sun::star::uno::Any aRet( VCLXTopWindow_Base::queryInterface( rType ) );
     271             : 
     272      382843 :     if ( !aRet.hasValue() )
     273      327598 :         aRet = VCLXContainer::queryInterface( rType );
     274             : 
     275      382843 :     return aRet;
     276             : }
     277             : 
     278           0 : ::com::sun::star::uno::Sequence< sal_Int8 > VCLXTopWindow::getImplementationId() throw(::com::sun::star::uno::RuntimeException, std::exception)
     279             : {
     280           0 :     return css::uno::Sequence<sal_Int8>();
     281             : }
     282             : 
     283           0 : ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > VCLXTopWindow::getTypes() throw(::com::sun::star::uno::RuntimeException, std::exception)
     284             : {
     285           0 :     return ::comphelper::concatSequences( VCLXTopWindow_Base::getTypes(), VCLXContainer::getTypes() );
     286             : }
     287             : 
     288             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10