LCOV - code coverage report
Current view: top level - libreoffice/toolkit/source/awt - vclxtabpagecontainer.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 113 0.0 %
Date: 2012-12-27 Functions: 0 20 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/vclxtabpagecontainer.hxx>
      21             : #include <com/sun/star/awt/tab/XTabPageModel.hpp>
      22             : #include <com/sun/star/awt/XControl.hpp>
      23             : #include <vcl/tabpage.hxx>
      24             : #include <vcl/tabctrl.hxx>
      25             : #include <vcl/svapp.hxx>
      26             : #include <toolkit/helper/property.hxx>
      27             : #include <toolkit/helper/vclunohelper.hxx>
      28             : #include <toolkit/helper/tkresmgr.hxx>
      29             : #include <cppuhelper/typeprovider.hxx>
      30             : 
      31             : using ::rtl::OUString;
      32             : using namespace ::com::sun::star;
      33             : using namespace ::com::sun::star::uno;
      34             : using namespace ::com::sun::star::lang;
      35             : using namespace ::com::sun::star::beans;
      36             : using namespace ::com::sun::star::container;
      37             : using namespace ::com::sun::star::view;
      38             : //  ----------------------------------------------------
      39             : //  class VCLXTabPageContainer
      40             : //  ----------------------------------------------------
      41           0 : void VCLXTabPageContainer::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
      42             : {
      43           0 :     VCLXWindow::ImplGetPropertyIds( rIds );
      44           0 : }
      45             : 
      46           0 : VCLXTabPageContainer::VCLXTabPageContainer() :
      47           0 :     m_aTabPageListeners( *this )
      48             : {
      49           0 : }
      50             : 
      51           0 : VCLXTabPageContainer::~VCLXTabPageContainer()
      52             : {
      53             : #ifndef __SUNPRO_CC
      54             :     OSL_TRACE ("%s", __FUNCTION__);
      55             : #endif
      56           0 : }
      57             : 
      58           0 : void SAL_CALL VCLXTabPageContainer::draw( sal_Int32 nX, sal_Int32 nY ) throw(RuntimeException)
      59             : {
      60           0 :     SolarMutexGuard aGuard;
      61           0 :     TabControl* pTabControl = (TabControl*)GetWindow();
      62           0 :     if ( pTabControl )
      63             :     {
      64           0 :         TabPage *pTabPage = pTabControl->GetTabPage( sal::static_int_cast< sal_uInt16 >(  pTabControl->GetCurPageId( ) ) );
      65           0 :         if ( pTabPage )
      66             :         {
      67           0 :             ::Point aPos( nX, nY );
      68           0 :             ::Size  aSize = pTabPage->GetSizePixel();
      69             : 
      70           0 :             OutputDevice* pDev = VCLUnoHelper::GetOutputDevice( getGraphics() );
      71           0 :             aPos  = pDev->PixelToLogic( aPos );
      72           0 :             aSize = pDev->PixelToLogic( aSize );
      73             : 
      74           0 :             pTabPage->Draw( pDev, aPos, aSize, 0 );
      75             :         }
      76             :     }
      77             : 
      78           0 :     VCLXWindow::draw( nX, nY );
      79           0 : }
      80             : 
      81           0 : ::com::sun::star::awt::DeviceInfo VCLXTabPageContainer::getInfo() throw(RuntimeException)
      82             : {
      83           0 :     ::com::sun::star::awt::DeviceInfo aInfo = VCLXDevice::getInfo();
      84           0 :     return aInfo;
      85             : }
      86             : 
      87           0 : void SAL_CALL VCLXTabPageContainer::setProperty(const ::rtl::OUString& PropertyName,   const Any& Value ) throw(RuntimeException)
      88             : {
      89           0 :     SolarMutexGuard aGuard;
      90             : 
      91           0 :     TabControl* pTabPage = (TabControl*)GetWindow();
      92           0 :     if ( pTabPage )
      93             :     {
      94           0 :         VCLXWindow::setProperty( PropertyName, Value );
      95           0 :     }
      96           0 : }
      97           0 : ::sal_Int16 SAL_CALL VCLXTabPageContainer::getActiveTabPageID() throw (RuntimeException)
      98             : {
      99           0 :     TabControl* pTabCtrl = (TabControl*)GetWindow();
     100           0 :     return pTabCtrl != NULL ? pTabCtrl->GetCurPageId( ) : 0;
     101             : }
     102           0 : void SAL_CALL VCLXTabPageContainer::setActiveTabPageID( ::sal_Int16 _activetabpageid ) throw (RuntimeException)
     103             : {
     104           0 :     TabControl* pTabCtrl = (TabControl*)GetWindow();
     105           0 :     if ( pTabCtrl )
     106           0 :         pTabCtrl->SelectTabPage(_activetabpageid);
     107           0 : }
     108           0 : ::sal_Int16 SAL_CALL VCLXTabPageContainer::getTabPageCount(  ) throw (RuntimeException)
     109             : {
     110           0 :     TabControl* pTabCtrl = (TabControl*)GetWindow();
     111           0 :     return pTabCtrl != NULL ? pTabCtrl->GetPageCount() : 0;
     112             : }
     113           0 : ::sal_Bool SAL_CALL VCLXTabPageContainer::isTabPageActive( ::sal_Int16 tabPageIndex ) throw (RuntimeException)
     114             : {
     115           0 :     return (getActiveTabPageID() == tabPageIndex);
     116             : }
     117           0 : Reference< ::com::sun::star::awt::tab::XTabPage > SAL_CALL VCLXTabPageContainer::getTabPage( ::sal_Int16 tabPageIndex ) throw (RuntimeException)
     118             : {
     119           0 :     return (tabPageIndex >= 0 && tabPageIndex < static_cast<sal_Int16>(m_aTabPages.size())) ? m_aTabPages[tabPageIndex] : NULL;
     120             : }
     121           0 : Reference< ::com::sun::star::awt::tab::XTabPage > SAL_CALL VCLXTabPageContainer::getTabPageByID( ::sal_Int16 tabPageID ) throw (RuntimeException)
     122             : {
     123           0 :     SolarMutexGuard aGuard;
     124           0 :     Reference< ::com::sun::star::awt::tab::XTabPage > xTabPage;
     125           0 :     ::std::vector< Reference< ::com::sun::star::awt::tab::XTabPage > >::iterator aIter = m_aTabPages.begin();
     126           0 :     ::std::vector< Reference< ::com::sun::star::awt::tab::XTabPage > >::iterator aEnd = m_aTabPages.end();
     127           0 :     for(;aIter != aEnd;++aIter)
     128             :     {
     129           0 :         Reference< awt::XControl > xControl(*aIter,UNO_QUERY );
     130           0 :         Reference< awt::tab::XTabPageModel > xP( xControl->getModel(), UNO_QUERY );
     131           0 :         if ( tabPageID == xP->getTabPageID() )
     132             :         {
     133           0 :             xTabPage = *aIter;
     134             :             break;
     135             :         }
     136           0 :     }
     137           0 :     return xTabPage;
     138             : }
     139           0 : void SAL_CALL VCLXTabPageContainer::addTabPageContainerListener( const Reference< ::com::sun::star::awt::tab::XTabPageContainerListener >& listener ) throw (RuntimeException)
     140             : {
     141           0 :     m_aTabPageListeners.addInterface( listener );
     142           0 : }
     143           0 : void SAL_CALL VCLXTabPageContainer::removeTabPageContainerListener( const Reference< ::com::sun::star::awt::tab::XTabPageContainerListener >& listener ) throw (RuntimeException)
     144             : {
     145           0 :     m_aTabPageListeners.removeInterface( listener );
     146           0 : }
     147             : 
     148           0 : void VCLXTabPageContainer::ProcessWindowEvent( const VclWindowEvent& _rVclWindowEvent )
     149             : {
     150           0 :     SolarMutexClearableGuard aGuard;
     151           0 :     TabControl* pTabControl = static_cast< TabControl* >( GetWindow() );
     152           0 :     if ( pTabControl )
     153             :     {
     154           0 :         switch ( _rVclWindowEvent.GetId() )
     155             :         {
     156             :             case VCLEVENT_TABPAGE_ACTIVATE:
     157             :             {
     158           0 :                 sal_uLong page = (sal_uLong)_rVclWindowEvent.GetData();
     159           0 :                 awt::tab::TabPageActivatedEvent aEvent(NULL,page);
     160           0 :                 m_aTabPageListeners.tabPageActivated(aEvent);
     161           0 :                 break;
     162             :             }
     163             :             default:
     164           0 :                 aGuard.clear();
     165           0 :                 VCLXWindow::ProcessWindowEvent( _rVclWindowEvent );
     166           0 :                 break;
     167             :         }
     168           0 :     }
     169           0 : }
     170           0 : void SAL_CALL VCLXTabPageContainer::disposing( const ::com::sun::star::lang::EventObject& /*Source*/ ) throw (::com::sun::star::uno::RuntimeException)
     171             : {
     172           0 : }
     173           0 : void SAL_CALL VCLXTabPageContainer::elementInserted( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException)
     174             : {
     175           0 :     SolarMutexGuard aGuard;
     176           0 :     TabControl* pTabCtrl = (TabControl*)GetWindow();
     177           0 :     Reference< ::com::sun::star::awt::tab::XTabPage > xTabPage(Event.Element,uno::UNO_QUERY);
     178           0 :     if ( pTabCtrl && xTabPage.is() )
     179             :     {
     180           0 :         Reference< awt::XControl > xControl(xTabPage,UNO_QUERY );
     181           0 :         Reference< awt::tab::XTabPageModel > xP( xControl->getModel(), UNO_QUERY );
     182           0 :         sal_Int16 nPageID = xP->getTabPageID();
     183             : 
     184           0 :         Window* pWindow = VCLUnoHelper::GetWindow(xControl->getPeer());
     185           0 :         TabPage* pPage = (TabPage*)pWindow;
     186           0 :         pTabCtrl->InsertPage(nPageID,pPage->GetText());
     187             : 
     188           0 :         pPage->Hide();
     189           0 :         pTabCtrl->SetTabPage(nPageID,pPage);
     190           0 :         pTabCtrl->SetHelpText(nPageID,xP->getToolTip());
     191           0 :         pTabCtrl->SetPageImage(nPageID,TkResMgr::getImageFromURL(xP->getImageURL()));
     192           0 :         pTabCtrl->SelectTabPage(nPageID);
     193           0 :         m_aTabPages.push_back(xTabPage);
     194           0 :     }
     195           0 : }
     196           0 : void SAL_CALL VCLXTabPageContainer::elementRemoved( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException)
     197             : {
     198           0 :     SolarMutexGuard aGuard;
     199           0 :     TabControl* pTabCtrl = (TabControl*)GetWindow();
     200           0 :     Reference< ::com::sun::star::awt::tab::XTabPage > xTabPage(Event.Element,uno::UNO_QUERY);
     201           0 :     if ( pTabCtrl && xTabPage.is() )
     202             :     {
     203           0 :         Reference< awt::XControl > xControl(xTabPage,UNO_QUERY );
     204           0 :         Reference< awt::tab::XTabPageModel > xP( xControl->getModel(), UNO_QUERY );
     205           0 :         pTabCtrl->RemovePage(xP->getTabPageID());
     206           0 :         m_aTabPages.erase(::std::remove(m_aTabPages.begin(),m_aTabPages.end(),xTabPage));
     207           0 :     }
     208           0 : }
     209           0 : void SAL_CALL VCLXTabPageContainer::elementReplaced( const ::com::sun::star::container::ContainerEvent& /*Event*/ ) throw (::com::sun::star::uno::RuntimeException)
     210             : {
     211           0 : }
     212             : 
     213             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10