LCOV - code coverage report
Current view: top level - toolkit/source/awt - vclxcontainer.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 139 0.0 %
Date: 2014-04-14 Functions: 0 14 0.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 <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           0 : VCLXContainer::VCLXContainer()
      42             : {
      43           0 : }
      44             : 
      45           0 : VCLXContainer::~VCLXContainer()
      46             : {
      47           0 : }
      48             : 
      49             : // ::com::sun::star::uno::XInterface
      50           0 : ::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           0 :                                         (static_cast< ::com::sun::star::awt::XVclContainerPeer* >(this)) );
      55           0 :     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           0 : void VCLXContainer::enableDialogControl( sal_Bool bEnable ) throw(::com::sun::star::uno::RuntimeException, std::exception)
     110             : {
     111           0 :     SolarMutexGuard aGuard;
     112             : 
     113           0 :     Window* pWindow = GetWindow();
     114           0 :     if ( pWindow )
     115             :     {
     116           0 :         WinBits nStyle = pWindow->GetStyle();
     117           0 :         if ( bEnable )
     118           0 :             nStyle |= WB_DIALOGCONTROL;
     119             :         else
     120           0 :             nStyle &= (~WB_DIALOGCONTROL);
     121           0 :         pWindow->SetStyle( nStyle );
     122           0 :     }
     123           0 : }
     124             : 
     125           0 : 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           0 :     SolarMutexGuard aGuard;
     128             : 
     129           0 :     sal_uInt32 nCount = Components.getLength();
     130             :     DBG_ASSERT( nCount == (sal_uInt32)Tabs.getLength(), "setTabOrder: TabCount != ComponentCount" );
     131           0 :     const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > * pComps = Components.getConstArray();
     132           0 :     const ::com::sun::star::uno::Any* pTabs = Tabs.getConstArray();
     133             : 
     134           0 :     Window* pPrevWin = NULL;
     135           0 :     for ( sal_uInt32 n = 0; n < nCount; n++ )
     136             :     {
     137             :         // ::com::sun::star::style::TabStop
     138           0 :         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           0 :         if ( pWin )
     141             :         {
     142             :             // Order windows before manipulating their style, because elements such as the
     143             :             // RadioButton considers the PREV-window in StateChanged.
     144           0 :             if ( pPrevWin )
     145           0 :                 pWin->SetZOrder( pPrevWin, WINDOW_ZORDER_BEHIND );
     146             : 
     147           0 :             WinBits nStyle = pWin->GetStyle();
     148           0 :             nStyle &= ~(WB_TABSTOP|WB_NOTABSTOP|WB_GROUP);
     149           0 :             if ( pTabs[n].getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_BOOLEAN )
     150             :             {
     151           0 :                 bool bTab = false;
     152           0 :                 pTabs[n] >>= bTab;
     153           0 :                 nStyle |= ( bTab ? WB_TABSTOP : WB_NOTABSTOP );
     154             :             }
     155           0 :             pWin->SetStyle( nStyle );
     156             : 
     157           0 :             if ( bGroupControl )
     158             :             {
     159           0 :                 if ( n == 0 )
     160           0 :                     pWin->SetDialogControlStart( true );
     161             :                 else
     162           0 :                     pWin->SetDialogControlStart( false );
     163             :             }
     164             : 
     165           0 :             pPrevWin = pWin;
     166             :         }
     167           0 :     }
     168           0 : }
     169             : 
     170           0 : 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           0 :     SolarMutexGuard aGuard;
     173             : 
     174           0 :     sal_uInt32 nCount = Components.getLength();
     175           0 :     const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > * pComps = Components.getConstArray();
     176             : 
     177           0 :     Window* pPrevWin = NULL;
     178           0 :     Window* pPrevRadio = NULL;
     179           0 :     for ( sal_uInt32 n = 0; n < nCount; n++ )
     180             :     {
     181           0 :         Window* pWin = VCLUnoHelper::GetWindow( pComps[n] );
     182           0 :         if ( pWin )
     183             :         {
     184           0 :             Window* pSortBehind = pPrevWin;
     185             :             // #57096# Sort all radios consecutively
     186           0 :             bool bNewPrevWin = true;
     187           0 :             if ( pWin->GetType() == WINDOW_RADIOBUTTON )
     188             :             {
     189           0 :                 if ( pPrevRadio )
     190             :                 {
     191             :                     // This RadioButton was sorted before PrevWin
     192           0 :                     bNewPrevWin = ( pPrevWin == pPrevRadio );
     193           0 :                     pSortBehind = pPrevRadio;
     194             :                 }
     195           0 :                 pPrevRadio = pWin;
     196             :             }
     197             : 
     198             :             // Z-Order
     199           0 :             if ( pSortBehind )
     200           0 :                 pWin->SetZOrder( pSortBehind, WINDOW_ZORDER_BEHIND );
     201             : 
     202           0 :             WinBits nStyle = pWin->GetStyle();
     203           0 :             if ( n == 0 )
     204           0 :                 nStyle |= WB_GROUP;
     205             :             else
     206           0 :                 nStyle &= (~WB_GROUP);
     207           0 :             pWin->SetStyle( nStyle );
     208             : 
     209             :             // Add WB_GROUP after the last group
     210           0 :             if ( n == ( nCount - 1 ) )
     211             :             {
     212           0 :                 Window* pBehindLast = pWin->GetWindow( WINDOW_NEXT );
     213           0 :                 if ( pBehindLast )
     214             :                 {
     215           0 :                     WinBits nLastStyle = pBehindLast->GetStyle();
     216           0 :                     nLastStyle |= WB_GROUP;
     217           0 :                     pBehindLast->SetStyle( nLastStyle );
     218             :                 }
     219             :             }
     220             : 
     221           0 :             if ( bNewPrevWin )
     222           0 :                 pPrevWin = pWin;
     223             :         }
     224           0 :     }
     225           0 : }
     226             : 
     227           0 : 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           0 :     SolarMutexGuard aGuard;
     233             : 
     234           0 :     sal_uInt16 nPropType = GetPropertyId( PropertyName );
     235           0 :     switch ( nPropType )
     236             :     {
     237             :         case BASEPROPERTY_SCROLLHEIGHT:
     238             :         case BASEPROPERTY_SCROLLWIDTH:
     239             :         case BASEPROPERTY_SCROLLTOP:
     240             :         case BASEPROPERTY_SCROLLLEFT:
     241             :         {
     242           0 :             sal_Int32 nVal =0;
     243           0 :             Value >>= nVal;
     244           0 :             Size aSize( nVal, nVal );
     245           0 :             Window* pWindow = GetWindow();
     246           0 :             MapMode aMode( MAP_APPFONT );
     247           0 :             toolkit::ScrollableInterface* pScrollable = dynamic_cast< toolkit::ScrollableInterface* >( pWindow );
     248           0 :             if ( pWindow && pScrollable )
     249             :             {
     250           0 :                 OutputDevice* pDev = VCLUnoHelper::GetOutputDevice( getGraphics() );
     251           0 :                 if ( !pDev )
     252           0 :                     pDev = pWindow->GetParent();
     253             :                 // shouldn't happen but it appears pDev can be NULL
     254             :                 // #FIXME ( find out how/why )
     255           0 :                 if ( !pDev )
     256           0 :                     break;
     257             : 
     258           0 :                 aSize = pDev->LogicToPixel( aSize, aMode );
     259           0 :                 switch ( nPropType )
     260             :                 {
     261             :                     case BASEPROPERTY_SCROLLHEIGHT:
     262           0 :                         pScrollable->SetScrollHeight( aSize.Height() );
     263           0 :                         break;
     264             :                     case BASEPROPERTY_SCROLLWIDTH:
     265           0 :                         pScrollable->SetScrollWidth( aSize.Width() );
     266           0 :                         break;
     267             :                     case BASEPROPERTY_SCROLLTOP:
     268           0 :                         pScrollable->SetScrollTop( aSize.Height() );
     269           0 :                         break;
     270             :                     case BASEPROPERTY_SCROLLLEFT:
     271           0 :                         pScrollable->SetScrollLeft( aSize.Width() );
     272           0 :                         break;
     273             :                     default:
     274           0 :                         break;
     275             :                 }
     276           0 :                 break;
     277             :             }
     278           0 :             break;
     279             :         }
     280             : 
     281             :         default:
     282             :         {
     283           0 :             VCLXWindow::setProperty( PropertyName, Value );
     284             :         }
     285           0 :     }
     286           0 : }
     287             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10