LCOV - code coverage report
Current view: top level - toolkit/source/awt - vclxtabpagecontainer.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 114 0.0 %
Date: 2015-06-13 12:38:46 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 <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 :     VclPtr<TabControl> pTabControl = GetAs<TabControl>();
      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, DrawFlags::NONE );
      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           0 :     VclPtr<TabControl> pTabPage = GetAs<TabControl>();
      90           0 :     if ( pTabPage )
      91           0 :         VCLXWindow::setProperty( PropertyName, Value );
      92           0 : }
      93             : 
      94           0 : ::sal_Int16 SAL_CALL VCLXTabPageContainer::getActiveTabPageID() throw (RuntimeException, std::exception)
      95             : {
      96           0 :     VclPtr<TabControl> pTabCtrl = GetAs<TabControl>();
      97           0 :     return pTabCtrl ? pTabCtrl->GetCurPageId( ) : 0;
      98             : }
      99             : 
     100           0 : void SAL_CALL VCLXTabPageContainer::setActiveTabPageID( ::sal_Int16 _activetabpageid ) throw (RuntimeException, std::exception)
     101             : {
     102           0 :     VclPtr<TabControl> pTabCtrl = GetAs<TabControl>();
     103           0 :     if ( pTabCtrl )
     104           0 :         pTabCtrl->SelectTabPage(_activetabpageid);
     105           0 : }
     106             : 
     107           0 : ::sal_Int16 SAL_CALL VCLXTabPageContainer::getTabPageCount(  ) throw (RuntimeException, std::exception)
     108             : {
     109           0 :     VclPtr<TabControl> pTabCtrl = GetAs<TabControl>();
     110           0 :     return pTabCtrl ? pTabCtrl->GetPageCount() : 0;
     111             : }
     112             : 
     113           0 : sal_Bool SAL_CALL VCLXTabPageContainer::isTabPageActive( ::sal_Int16 tabPageIndex ) throw (RuntimeException, std::exception)
     114             : {
     115           0 :     return (getActiveTabPageID() == tabPageIndex);
     116             : }
     117             : 
     118           0 : Reference< ::com::sun::star::awt::tab::XTabPage > SAL_CALL VCLXTabPageContainer::getTabPage( ::sal_Int16 tabPageIndex ) throw (RuntimeException, std::exception)
     119             : {
     120           0 :     return (tabPageIndex >= 0 && tabPageIndex < static_cast<sal_Int16>(m_aTabPages.size())) ? m_aTabPages[tabPageIndex] : NULL;
     121             : }
     122             : 
     123           0 : Reference< ::com::sun::star::awt::tab::XTabPage > SAL_CALL VCLXTabPageContainer::getTabPageByID( ::sal_Int16 tabPageID ) throw (RuntimeException, std::exception)
     124             : {
     125           0 :     SolarMutexGuard aGuard;
     126           0 :     Reference< ::com::sun::star::awt::tab::XTabPage > xTabPage;
     127           0 :     ::std::vector< Reference< ::com::sun::star::awt::tab::XTabPage > >::iterator aIter = m_aTabPages.begin();
     128           0 :     ::std::vector< Reference< ::com::sun::star::awt::tab::XTabPage > >::iterator aEnd = m_aTabPages.end();
     129           0 :     for(;aIter != aEnd;++aIter)
     130             :     {
     131           0 :         Reference< awt::XControl > xControl(*aIter,UNO_QUERY );
     132           0 :         Reference< awt::tab::XTabPageModel > xP( xControl->getModel(), UNO_QUERY );
     133           0 :         if ( tabPageID == xP->getTabPageID() )
     134             :         {
     135           0 :             xTabPage = *aIter;
     136           0 :             break;
     137             :         }
     138           0 :     }
     139           0 :     return xTabPage;
     140             : }
     141             : 
     142           0 : void SAL_CALL VCLXTabPageContainer::addTabPageContainerListener( const Reference< ::com::sun::star::awt::tab::XTabPageContainerListener >& listener ) throw (RuntimeException, std::exception)
     143             : {
     144           0 :     m_aTabPageListeners.addInterface( listener );
     145           0 : }
     146             : 
     147           0 : void SAL_CALL VCLXTabPageContainer::removeTabPageContainerListener( const Reference< ::com::sun::star::awt::tab::XTabPageContainerListener >& listener ) throw (RuntimeException, std::exception)
     148             : {
     149           0 :     m_aTabPageListeners.removeInterface( listener );
     150           0 : }
     151             : 
     152           0 : void VCLXTabPageContainer::ProcessWindowEvent( const VclWindowEvent& _rVclWindowEvent )
     153             : {
     154           0 :     SolarMutexClearableGuard aGuard;
     155           0 :     VclPtr<TabControl> pTabControl = GetAs<TabControl>();
     156           0 :     if ( pTabControl )
     157             :     {
     158           0 :         switch ( _rVclWindowEvent.GetId() )
     159             :         {
     160             :             case VCLEVENT_TABPAGE_ACTIVATE:
     161             :             {
     162           0 :                 sal_uLong page = reinterpret_cast<sal_uLong>(_rVclWindowEvent.GetData());
     163           0 :                 awt::tab::TabPageActivatedEvent aEvent(NULL,page);
     164           0 :                 m_aTabPageListeners.tabPageActivated(aEvent);
     165           0 :                 break;
     166             :             }
     167             :             default:
     168           0 :                 aGuard.clear();
     169           0 :                 VCLXWindow::ProcessWindowEvent( _rVclWindowEvent );
     170           0 :                 break;
     171             :         }
     172           0 :     }
     173           0 : }
     174           0 : void SAL_CALL VCLXTabPageContainer::disposing( const ::com::sun::star::lang::EventObject& /*Source*/ ) throw (::com::sun::star::uno::RuntimeException, std::exception)
     175             : {
     176           0 : }
     177           0 : void SAL_CALL VCLXTabPageContainer::elementInserted( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException, std::exception)
     178             : {
     179           0 :     SolarMutexGuard aGuard;
     180           0 :     VclPtr<TabControl> pTabCtrl = GetAs<TabControl>();
     181           0 :     Reference< ::com::sun::star::awt::tab::XTabPage > xTabPage(Event.Element,uno::UNO_QUERY);
     182           0 :     if ( pTabCtrl && xTabPage.is() )
     183             :     {
     184           0 :         Reference< awt::XControl > xControl(xTabPage,UNO_QUERY );
     185           0 :         Reference< awt::tab::XTabPageModel > xP( xControl->getModel(), UNO_QUERY );
     186           0 :         sal_Int16 nPageID = xP->getTabPageID();
     187             : 
     188           0 :         vcl::Window* pWindow = VCLUnoHelper::GetWindow(xControl->getPeer());
     189           0 :         TabPage* pPage = static_cast<TabPage*>(pWindow);
     190           0 :         pTabCtrl->InsertPage(nPageID,pPage->GetText());
     191             : 
     192           0 :         pPage->Hide();
     193           0 :         pTabCtrl->SetTabPage(nPageID,pPage);
     194           0 :         pTabCtrl->SetHelpText(nPageID,xP->getToolTip());
     195           0 :         pTabCtrl->SetPageImage(nPageID,TkResMgr::getImageFromURL(xP->getImageURL()));
     196           0 :         pTabCtrl->SelectTabPage(nPageID);
     197           0 :         pTabCtrl->EnablePage(nPageID,xP->getEnabled());
     198           0 :         m_aTabPages.push_back(xTabPage);
     199           0 :     }
     200           0 : }
     201           0 : void SAL_CALL VCLXTabPageContainer::elementRemoved( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException, std::exception)
     202             : {
     203           0 :     SolarMutexGuard aGuard;
     204           0 :     VclPtr<TabControl> pTabCtrl = GetAs<TabControl>();
     205           0 :     Reference< ::com::sun::star::awt::tab::XTabPage > xTabPage(Event.Element,uno::UNO_QUERY);
     206           0 :     if ( pTabCtrl && xTabPage.is() )
     207             :     {
     208           0 :         Reference< awt::XControl > xControl(xTabPage,UNO_QUERY );
     209           0 :         Reference< awt::tab::XTabPageModel > xP( xControl->getModel(), UNO_QUERY );
     210           0 :         pTabCtrl->RemovePage(xP->getTabPageID());
     211           0 :         m_aTabPages.erase(::std::remove(m_aTabPages.begin(),m_aTabPages.end(),xTabPage));
     212           0 :     }
     213           0 : }
     214           0 : void SAL_CALL VCLXTabPageContainer::elementReplaced( const ::com::sun::star::container::ContainerEvent& /*Event*/ ) throw (::com::sun::star::uno::RuntimeException, std::exception)
     215             : {
     216           0 : }
     217             : 
     218             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11