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

Generated by: LCOV version 1.11