LCOV - code coverage report
Current view: top level - toolkit/source/awt - vclxcontainer.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 103 139 74.1 %
Date: 2014-04-11 Functions: 8 14 57.1 %
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 <toolkit/awt/vclxcontainer.hxx>
      21             : #include <toolkit/helper/macros.hxx>
      22             : #include <toolkit/helper/vclunohelper.hxx>
      23             : #include <cppuhelper/typeprovider.hxx>
      24             : #include <rtl/uuid.h>
      25             : 
      26             : #include <vcl/svapp.hxx>
      27             : #include <vcl/window.hxx>
      28             : #include <tools/debug.hxx>
      29             : #include "toolkit/awt/scrollabledialog.hxx"
      30             : #include <toolkit/helper/property.hxx>
      31             : 
      32             : 
      33             : //  class VCLXContainer
      34             : 
      35             : 
      36           0 : void VCLXContainer::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
      37             : {
      38           0 :     VCLXWindow::ImplGetPropertyIds( rIds );
      39           0 : }
      40             : 
      41        7188 : VCLXContainer::VCLXContainer()
      42             : {
      43        7188 : }
      44             : 
      45        8749 : VCLXContainer::~VCLXContainer()
      46             : {
      47        8749 : }
      48             : 
      49             : // ::com::sun::star::uno::XInterface
      50      350565 : ::com::sun::star::uno::Any VCLXContainer::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException, std::exception)
      51             : {
      52             :     ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
      53             :                                         (static_cast< ::com::sun::star::awt::XVclContainer* >(this)),
      54      350565 :                                         (static_cast< ::com::sun::star::awt::XVclContainerPeer* >(this)) );
      55      350565 :     return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType ));
      56             : }
      57             : 
      58             : // ::com::sun::star::lang::XTypeProvider
      59           0 : IMPL_XTYPEPROVIDER_START( VCLXContainer )
      60           0 :     getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XVclContainer>* ) NULL ),
      61           0 :     getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XVclContainerPeer>* ) NULL ),
      62             :     VCLXWindow::getTypes()
      63           0 : IMPL_XTYPEPROVIDER_END
      64             : 
      65             : 
      66             : // ::com::sun::star::awt::XVclContainer
      67           0 : void VCLXContainer::addVclContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XVclContainerListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException, std::exception)
      68             : {
      69           0 :     SolarMutexGuard aGuard;
      70             : 
      71           0 :     GetContainerListeners().addInterface( rxListener );
      72           0 : }
      73             : 
      74           0 : void VCLXContainer::removeVclContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XVclContainerListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException, std::exception)
      75             : {
      76           0 :     SolarMutexGuard aGuard;
      77             : 
      78           0 :     GetContainerListeners().removeInterface( rxListener );
      79           0 : }
      80             : 
      81           0 : ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > > VCLXContainer::getWindows(  ) throw(::com::sun::star::uno::RuntimeException, std::exception)
      82             : {
      83           0 :     SolarMutexGuard aGuard;
      84             : 
      85             :     // Request container interface from all children
      86           0 :     ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > > aSeq;
      87           0 :     Window* pWindow = GetWindow();
      88           0 :     if ( pWindow )
      89             :     {
      90           0 :         sal_uInt16 nChildren = pWindow->GetChildCount();
      91           0 :         if ( nChildren )
      92             :         {
      93           0 :             aSeq = ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > >( nChildren );
      94           0 :             ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > * pChildRefs = aSeq.getArray();
      95           0 :             for ( sal_uInt16 n = 0; n < nChildren; n++ )
      96             :             {
      97           0 :                 Window* pChild = pWindow->GetChild( n );
      98           0 :                 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >  xWP = pChild->GetComponentInterface( sal_True );
      99           0 :                 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xW( xWP, ::com::sun::star::uno::UNO_QUERY );
     100           0 :                 pChildRefs[n] = xW;
     101           0 :             }
     102             :         }
     103             :     }
     104           0 :     return aSeq;
     105             : }
     106             : 
     107             : 
     108             : // ::com::sun::star::awt::XVclContainerPeer
     109           4 : void VCLXContainer::enableDialogControl( sal_Bool bEnable ) throw(::com::sun::star::uno::RuntimeException, std::exception)
     110             : {
     111           4 :     SolarMutexGuard aGuard;
     112             : 
     113           4 :     Window* pWindow = GetWindow();
     114           4 :     if ( pWindow )
     115             :     {
     116           4 :         WinBits nStyle = pWindow->GetStyle();
     117           4 :         if ( bEnable )
     118           4 :             nStyle |= WB_DIALOGCONTROL;
     119             :         else
     120           0 :             nStyle &= (~WB_DIALOGCONTROL);
     121           4 :         pWindow->SetStyle( nStyle );
     122           4 :     }
     123           4 : }
     124             : 
     125         130 : void VCLXContainer::setTabOrder( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > >& Components, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Tabs, sal_Bool bGroupControl ) throw(::com::sun::star::uno::RuntimeException, std::exception)
     126             : {
     127         130 :     SolarMutexGuard aGuard;
     128             : 
     129         130 :     sal_uInt32 nCount = Components.getLength();
     130             :     DBG_ASSERT( nCount == (sal_uInt32)Tabs.getLength(), "setTabOrder: TabCount != ComponentCount" );
     131         130 :     const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > * pComps = Components.getConstArray();
     132         130 :     const ::com::sun::star::uno::Any* pTabs = Tabs.getConstArray();
     133             : 
     134         130 :     Window* pPrevWin = NULL;
     135         212 :     for ( sal_uInt32 n = 0; n < nCount; n++ )
     136             :     {
     137             :         // ::com::sun::star::style::TabStop
     138          82 :         Window* pWin = VCLUnoHelper::GetWindow( pComps[n] );
     139             :         // May be NULL if a ::com::sun::star::uno::Sequence is originated from TabController and is missing a peer!
     140          82 :         if ( pWin )
     141             :         {
     142             :             // Order windows before manipulating their style, because elements such as the
     143             :             // RadioButton considers the PREV-window in StateChanged.
     144          82 :             if ( pPrevWin )
     145          25 :                 pWin->SetZOrder( pPrevWin, WINDOW_ZORDER_BEHIND );
     146             : 
     147          82 :             WinBits nStyle = pWin->GetStyle();
     148          82 :             nStyle &= ~(WB_TABSTOP|WB_NOTABSTOP|WB_GROUP);
     149          82 :             if ( pTabs[n].getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_BOOLEAN )
     150             :             {
     151           6 :                 bool bTab = false;
     152           6 :                 pTabs[n] >>= bTab;
     153           6 :                 nStyle |= ( bTab ? WB_TABSTOP : WB_NOTABSTOP );
     154             :             }
     155          82 :             pWin->SetStyle( nStyle );
     156             : 
     157          82 :             if ( bGroupControl )
     158             :             {
     159           8 :                 if ( n == 0 )
     160           4 :                     pWin->SetDialogControlStart( true );
     161             :                 else
     162           4 :                     pWin->SetDialogControlStart( false );
     163             :             }
     164             : 
     165          82 :             pPrevWin = pWin;
     166             :         }
     167         130 :     }
     168         130 : }
     169             : 
     170           9 : void VCLXContainer::setGroup( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > >& Components ) throw(::com::sun::star::uno::RuntimeException, std::exception)
     171             : {
     172           9 :     SolarMutexGuard aGuard;
     173             : 
     174           9 :     sal_uInt32 nCount = Components.getLength();
     175           9 :     const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > * pComps = Components.getConstArray();
     176             : 
     177           9 :     Window* pPrevWin = NULL;
     178           9 :     Window* pPrevRadio = NULL;
     179          20 :     for ( sal_uInt32 n = 0; n < nCount; n++ )
     180             :     {
     181          11 :         Window* pWin = VCLUnoHelper::GetWindow( pComps[n] );
     182          11 :         if ( pWin )
     183             :         {
     184          11 :             Window* pSortBehind = pPrevWin;
     185             :             // #57096# Sort all radios consecutively
     186          11 :             bool bNewPrevWin = true;
     187          11 :             if ( pWin->GetType() == WINDOW_RADIOBUTTON )
     188             :             {
     189           3 :                 if ( pPrevRadio )
     190             :                 {
     191             :                     // This RadioButton was sorted before PrevWin
     192           0 :                     bNewPrevWin = ( pPrevWin == pPrevRadio );
     193           0 :                     pSortBehind = pPrevRadio;
     194             :                 }
     195           3 :                 pPrevRadio = pWin;
     196             :             }
     197             : 
     198             :             // Z-Order
     199          11 :             if ( pSortBehind )
     200           6 :                 pWin->SetZOrder( pSortBehind, WINDOW_ZORDER_BEHIND );
     201             : 
     202          11 :             WinBits nStyle = pWin->GetStyle();
     203          11 :             if ( n == 0 )
     204           5 :                 nStyle |= WB_GROUP;
     205             :             else
     206           6 :                 nStyle &= (~WB_GROUP);
     207          11 :             pWin->SetStyle( nStyle );
     208             : 
     209             :             // Add WB_GROUP after the last group
     210          11 :             if ( n == ( nCount - 1 ) )
     211             :             {
     212           5 :                 Window* pBehindLast = pWin->GetWindow( WINDOW_NEXT );
     213           5 :                 if ( pBehindLast )
     214             :                 {
     215           3 :                     WinBits nLastStyle = pBehindLast->GetStyle();
     216           3 :                     nLastStyle |= WB_GROUP;
     217           3 :                     pBehindLast->SetStyle( nLastStyle );
     218             :                 }
     219             :             }
     220             : 
     221          11 :             if ( bNewPrevWin )
     222          11 :                 pPrevWin = pWin;
     223             :         }
     224           9 :     }
     225           9 : }
     226             : 
     227         210 : void SAL_CALL VCLXContainer::setProperty(
     228             :     const OUString& PropertyName,
     229             :     const ::com::sun::star::uno::Any& Value )
     230             : throw(::com::sun::star::uno::RuntimeException, std::exception)
     231             : {
     232         210 :     SolarMutexGuard aGuard;
     233             : 
     234         210 :     sal_uInt16 nPropType = GetPropertyId( PropertyName );
     235         210 :     switch ( nPropType )
     236             :     {
     237             :         case BASEPROPERTY_SCROLLHEIGHT:
     238             :         case BASEPROPERTY_SCROLLWIDTH:
     239             :         case BASEPROPERTY_SCROLLTOP:
     240             :         case BASEPROPERTY_SCROLLLEFT:
     241             :         {
     242          24 :             sal_Int32 nVal =0;
     243          24 :             Value >>= nVal;
     244          24 :             Size aSize( nVal, nVal );
     245          24 :             Window* pWindow = GetWindow();
     246          24 :             MapMode aMode( MAP_APPFONT );
     247          24 :             toolkit::ScrollableInterface* pScrollable = dynamic_cast< toolkit::ScrollableInterface* >( pWindow );
     248          24 :             if ( pWindow && pScrollable )
     249             :             {
     250          24 :                 OutputDevice* pDev = VCLUnoHelper::GetOutputDevice( getGraphics() );
     251          24 :                 if ( !pDev )
     252          24 :                     pDev = pWindow->GetParent();
     253             :                 // shouldn't happen but it appears pDev can be NULL
     254             :                 // #FIXME ( find out how/why )
     255          24 :                 if ( !pDev )
     256          12 :                     break;
     257             : 
     258          12 :                 aSize = pDev->LogicToPixel( aSize, aMode );
     259          12 :                 switch ( nPropType )
     260             :                 {
     261             :                     case BASEPROPERTY_SCROLLHEIGHT:
     262           2 :                         pScrollable->SetScrollHeight( aSize.Height() );
     263           2 :                         break;
     264             :                     case BASEPROPERTY_SCROLLWIDTH:
     265           2 :                         pScrollable->SetScrollWidth( aSize.Width() );
     266           2 :                         break;
     267             :                     case BASEPROPERTY_SCROLLTOP:
     268           4 :                         pScrollable->SetScrollTop( aSize.Height() );
     269           4 :                         break;
     270             :                     case BASEPROPERTY_SCROLLLEFT:
     271           4 :                         pScrollable->SetScrollLeft( aSize.Width() );
     272           4 :                         break;
     273             :                     default:
     274           0 :                         break;
     275             :                 }
     276          12 :                 break;
     277             :             }
     278           0 :             break;
     279             :         }
     280             : 
     281             :         default:
     282             :         {
     283         186 :             VCLXWindow::setProperty( PropertyName, Value );
     284             :         }
     285         210 :     }
     286         210 : }
     287             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10