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

Generated by: LCOV version 1.10