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

Generated by: LCOV version 1.10