LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sd/source/ui/view - ViewTabBar.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 149 238 62.6 %
Date: 2013-07-09 Functions: 24 35 68.6 %
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             : 
      21             : #include "ViewTabBar.hxx"
      22             : 
      23             : #include "ViewShell.hxx"
      24             : #include "ViewShellBase.hxx"
      25             : #include "DrawViewShell.hxx"
      26             : #include "FrameView.hxx"
      27             : #include "EventMultiplexer.hxx"
      28             : #include "framework/FrameworkHelper.hxx"
      29             : #include "framework/Pane.hxx"
      30             : #include "DrawController.hxx"
      31             : 
      32             : #include "sdresid.hxx"
      33             : #include "strings.hrc"
      34             : #include "helpids.h"
      35             : #include "Client.hxx"
      36             : #include <vcl/svapp.hxx>
      37             : #include <vcl/tabpage.hxx>
      38             : #include <osl/mutex.hxx>
      39             : #include <sfx2/viewfrm.hxx>
      40             : #include <com/sun/star/drawing/framework/ResourceId.hpp>
      41             : #include <com/sun/star/drawing/framework/XControllerManager.hpp>
      42             : #include <com/sun/star/lang/XUnoTunnel.hpp>
      43             : #include <com/sun/star/lang/DisposedException.hpp>
      44             : #include <comphelper/processfactory.hxx>
      45             : #include <comphelper/servicehelper.hxx>
      46             : #include <tools/diagnose_ex.h>
      47             : 
      48             : using namespace ::com::sun::star;
      49             : using namespace ::com::sun::star::uno;
      50             : using namespace ::com::sun::star::drawing::framework;
      51             : using ::sd::framework::FrameworkHelper;
      52             : using ::sd::tools::EventMultiplexerEvent;
      53             : 
      54             : namespace sd {
      55             : 
      56             : namespace {
      57         260 : bool IsEqual (const TabBarButton& rButton1, const TabBarButton& rButton2)
      58             : {
      59             :     return (
      60         260 :         (rButton1.ResourceId.is()
      61         260 :             && rButton2.ResourceId.is()
      62         260 :             && rButton1.ResourceId->compareTo(rButton2.ResourceId)==0)
      63         468 :         || rButton1.ButtonLabel == rButton2.ButtonLabel);
      64             : }
      65             : 
      66          26 : class TabBarControl : public ::TabControl
      67             : {
      68             : public:
      69             :     TabBarControl (
      70             :         ::Window* pParentWindow,
      71             :         const ::rtl::Reference<ViewTabBar>& rpViewTabBar);
      72             :     virtual void Paint (const Rectangle& rRect);
      73             :     virtual void ActivatePage (void);
      74             : private:
      75             :     ::rtl::Reference<ViewTabBar> mpViewTabBar;
      76             : };
      77             : 
      78             : } // end of anonymous namespace
      79             : 
      80             : 
      81             : 
      82             : 
      83             : 
      84             : class ViewTabPage : public TabPage
      85             : {
      86             : public:
      87             :     ViewTabPage (Window* pParent) : TabPage(pParent) {}
      88             :     virtual void Resize (void)
      89             :     { SetPosSizePixel(Point(0,0),GetParent()->GetOutputSizePixel()); }
      90             : };
      91             : 
      92             : 
      93             : 
      94             : 
      95             : //===== ViewTabBar ============================================================
      96             : 
      97          13 : ViewTabBar::ViewTabBar (
      98             :     const Reference<XResourceId>& rxViewTabBarId,
      99             :     const Reference<frame::XController>& rxController)
     100             :     : ViewTabBarInterfaceBase(maMutex),
     101          13 :       mpTabControl(new TabBarControl(GetAnchorWindow(rxViewTabBarId,rxController), this)),
     102             :       mxController(rxController),
     103             :       maTabBarButtons(),
     104             :       mpTabPage(NULL),
     105             :       mxViewTabBarId(rxViewTabBarId),
     106          26 :       mpViewShellBase(NULL)
     107             : {
     108             :     // Set one new tab page for all tab entries.  We need it only to
     109             :     // determine the height of the tab bar.
     110          13 :     mpTabPage.reset(new TabPage (mpTabControl.get()));
     111          13 :     mpTabPage->Hide();
     112             : 
     113             :     // add some space before the tabitems
     114          13 :     mpTabControl->SetItemsOffset(Point(5, 3));
     115             : 
     116             :     // Tunnel through the controller and use the ViewShellBase to obtain the
     117             :     // view frame.
     118             :     try
     119             :     {
     120          13 :         Reference<lang::XUnoTunnel> xTunnel (mxController, UNO_QUERY_THROW);
     121             :         DrawController* pController = reinterpret_cast<DrawController*>(
     122          13 :             xTunnel->getSomething(DrawController::getUnoTunnelId()));
     123          13 :         mpViewShellBase = pController->GetViewShellBase();
     124             :     }
     125           0 :     catch (const RuntimeException&)
     126             :     {
     127             :     }
     128             : 
     129             :     // Register as listener at XConfigurationController.
     130          13 :     Reference<XControllerManager> xControllerManager (mxController, UNO_QUERY);
     131          13 :     if (xControllerManager.is())
     132             :     {
     133          13 :         mxConfigurationController = xControllerManager->getConfigurationController();
     134          13 :         if (mxConfigurationController.is())
     135             :         {
     136          13 :             mxConfigurationController->addConfigurationChangeListener(
     137             :                 this,
     138             :                     FrameworkHelper::msResourceActivationEvent,
     139          13 :                 Any());
     140             :         }
     141             :     }
     142             : 
     143          13 :     mpTabControl->Show();
     144             : 
     145          26 :     if (mpViewShellBase != NULL
     146          26 :         && rxViewTabBarId->isBoundToURL(
     147          13 :             FrameworkHelper::msCenterPaneURL, AnchorBindingMode_DIRECT))
     148             :     {
     149          13 :         mpViewShellBase->SetViewTabBar(this);
     150          13 :     }
     151          13 : }
     152             : 
     153             : 
     154             : 
     155             : 
     156          26 : ViewTabBar::~ViewTabBar (void)
     157             : {
     158          26 : }
     159             : 
     160             : 
     161             : 
     162             : 
     163          13 : void ViewTabBar::disposing (void)
     164             : {
     165          26 :     if (mpViewShellBase != NULL
     166          26 :         && mxViewTabBarId->isBoundToURL(
     167          13 :             FrameworkHelper::msCenterPaneURL, AnchorBindingMode_DIRECT))
     168             :     {
     169          13 :         mpViewShellBase->SetViewTabBar(NULL);
     170             :     }
     171             : 
     172          13 :     if (mxConfigurationController.is())
     173             :     {
     174             :         // Unregister listener from XConfigurationController.
     175             :         try
     176             :         {
     177          13 :             mxConfigurationController->removeConfigurationChangeListener(this);
     178             :         }
     179           0 :         catch (const lang::DisposedException&)
     180             :         {
     181             :             // Receiving a disposed exception is the normal case.  Is there
     182             :             // a way to avoid it?
     183             :         }
     184          13 :         mxConfigurationController = NULL;
     185             :     }
     186             : 
     187             :     {
     188          13 :         const SolarMutexGuard aSolarGuard;
     189             :         // Set all references to the one tab page to NULL and delete the page.
     190          78 :         for (sal_uInt16 nIndex=0; nIndex<mpTabControl->GetPageCount(); ++nIndex)
     191          65 :             mpTabControl->SetTabPage(nIndex, NULL);
     192          13 :         mpTabPage.reset();
     193          13 :         mpTabControl.reset();
     194             :     }
     195             : 
     196          13 :     mxController = NULL;
     197          13 : }
     198             : 
     199             : 
     200             : 
     201             : 
     202         263 : ::boost::shared_ptr< ::TabControl> ViewTabBar::GetTabControl (void) const
     203             : {
     204         263 :     return mpTabControl;
     205             : }
     206             : 
     207             : 
     208             : 
     209             : 
     210          13 : ::Window* ViewTabBar::GetAnchorWindow(
     211             :     const Reference<XResourceId>& rxViewTabBarId,
     212             :     const Reference<frame::XController>& rxController)
     213             : {
     214          13 :     ::Window* pWindow = NULL;
     215          13 :     ViewShellBase* pBase = NULL;
     216             : 
     217             :     // Tunnel through the controller and use the ViewShellBase to obtain the
     218             :     // view frame.
     219             :     try
     220             :     {
     221          13 :         Reference<lang::XUnoTunnel> xTunnel (rxController, UNO_QUERY_THROW);
     222             :         DrawController* pController = reinterpret_cast<DrawController*>(
     223          13 :             xTunnel->getSomething(DrawController::getUnoTunnelId()));
     224          13 :         pBase = pController->GetViewShellBase();
     225             :     }
     226           0 :     catch (const RuntimeException&)
     227             :     {
     228             :     }
     229             : 
     230             :     // The ViewTabBar supports at the moment only the center pane.
     231          26 :     if (rxViewTabBarId.is()
     232          26 :         && rxViewTabBarId->isBoundToURL(
     233          13 :             FrameworkHelper::msCenterPaneURL, AnchorBindingMode_DIRECT))
     234             :     {
     235          13 :         if (pBase != NULL && pBase->GetViewFrame() != NULL)
     236          13 :             pWindow = &pBase->GetViewFrame()->GetWindow();
     237             :     }
     238             : 
     239             :     // The rest is (at the moment) just for the emergency case.
     240          13 :     if (pWindow == NULL)
     241             :     {
     242           0 :         Reference<XPane> xPane;
     243             :         try
     244             :         {
     245           0 :             Reference<XControllerManager> xControllerManager (rxController, UNO_QUERY_THROW);
     246             :             Reference<XConfigurationController> xCC (
     247           0 :                 xControllerManager->getConfigurationController());
     248           0 :             if (xCC.is())
     249           0 :                 xPane = Reference<XPane>(xCC->getResource(rxViewTabBarId->getAnchor()), UNO_QUERY);
     250             :         }
     251           0 :         catch (const RuntimeException&)
     252             :         {
     253             :         }
     254             : 
     255             :         // Tunnel through the XWindow to the VCL side.
     256             :         try
     257             :         {
     258           0 :             Reference<lang::XUnoTunnel> xTunnel (xPane, UNO_QUERY_THROW);
     259             :             framework::Pane* pPane = reinterpret_cast<framework::Pane*>(
     260           0 :                 xTunnel->getSomething(framework::Pane::getUnoTunnelId()));
     261           0 :             if (pPane != NULL)
     262           0 :                 pWindow = pPane->GetWindow()->GetParent();
     263             :         }
     264           0 :         catch (const RuntimeException&)
     265             :         {
     266           0 :         }
     267             :     }
     268             : 
     269          13 :     return pWindow;
     270             : }
     271             : 
     272             : 
     273             : 
     274             : 
     275             : //----- XConfigurationChangeListener ------------------------------------------
     276             : 
     277          77 : void SAL_CALL  ViewTabBar::notifyConfigurationChange (
     278             :     const ConfigurationChangeEvent& rEvent)
     279             :     throw (RuntimeException)
     280             : {
     281         231 :     if (rEvent.Type.equals(FrameworkHelper::msResourceActivationEvent)
     282         231 :         && rEvent.ResourceId->getResourceURL().match(FrameworkHelper::msViewURLPrefix)
     283         257 :         && rEvent.ResourceId->isBoundTo(mxViewTabBarId->getAnchor(), AnchorBindingMode_DIRECT))
     284             :     {
     285           0 :         UpdateActiveButton();
     286             :     }
     287          77 : }
     288             : 
     289             : 
     290             : 
     291             : 
     292             : //----- XEventListener --------------------------------------------------------
     293             : 
     294           0 : void SAL_CALL ViewTabBar::disposing(
     295             :     const lang::EventObject& rEvent)
     296             :     throw (RuntimeException)
     297             : {
     298           0 :     if (rEvent.Source == mxConfigurationController)
     299             :     {
     300           0 :         mxConfigurationController = NULL;
     301           0 :         mxController = NULL;
     302             :     }
     303           0 : }
     304             : 
     305             : 
     306             : 
     307             : 
     308             : //----- XTabBar ---------------------------------------------------------------
     309             : 
     310          65 : void SAL_CALL ViewTabBar::addTabBarButtonAfter (
     311             :     const TabBarButton& rButton,
     312             :     const TabBarButton& rAnchor)
     313             :     throw (::com::sun::star::uno::RuntimeException)
     314             : {
     315          65 :     const SolarMutexGuard aSolarGuard;
     316          65 :     AddTabBarButton(rButton, rAnchor);
     317          65 : }
     318             : 
     319             : 
     320             : 
     321             : 
     322           0 : void SAL_CALL ViewTabBar::appendTabBarButton (const TabBarButton& rButton)
     323             :     throw (::com::sun::star::uno::RuntimeException)
     324             : {
     325           0 :     const SolarMutexGuard aSolarGuard;
     326           0 :     AddTabBarButton(rButton);
     327           0 : }
     328             : 
     329             : 
     330             : 
     331           0 : void SAL_CALL ViewTabBar::removeTabBarButton (const TabBarButton& rButton)
     332             :     throw (::com::sun::star::uno::RuntimeException)
     333             : {
     334           0 :     const SolarMutexGuard aSolarGuard;
     335           0 :     RemoveTabBarButton(rButton);
     336           0 : }
     337             : 
     338             : 
     339             : 
     340             : 
     341          65 : sal_Bool SAL_CALL ViewTabBar::hasTabBarButton (const TabBarButton& rButton)
     342             :     throw (::com::sun::star::uno::RuntimeException)
     343             : {
     344          65 :     const SolarMutexGuard aSolarGuard;
     345          65 :     return HasTabBarButton(rButton);
     346             : }
     347             : 
     348             : 
     349             : 
     350             : 
     351           0 : Sequence<TabBarButton> SAL_CALL ViewTabBar::getTabBarButtons (void)
     352             :     throw (::com::sun::star::uno::RuntimeException)
     353             : {
     354           0 :     const SolarMutexGuard aSolarGuard;
     355           0 :     return GetTabBarButtons();
     356             : }
     357             : 
     358             : 
     359             : 
     360             : 
     361             : //----- XResource -------------------------------------------------------------
     362             : 
     363          13 : Reference<XResourceId> SAL_CALL ViewTabBar::getResourceId (void)
     364             :     throw (RuntimeException)
     365             : {
     366          13 :     return mxViewTabBarId;
     367             : }
     368             : 
     369             : 
     370             : 
     371             : 
     372          66 : sal_Bool SAL_CALL ViewTabBar::isAnchorOnly (void)
     373             :     throw (RuntimeException)
     374             : {
     375          66 :     return false;
     376             : }
     377             : 
     378             : 
     379             : 
     380             : 
     381             : //----- XUnoTunnel ------------------------------------------------------------
     382             : 
     383             : namespace
     384             : {
     385             :     class theViewTabBarUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theViewTabBarUnoTunnelId > {};
     386             : }
     387             : 
     388           0 : const Sequence<sal_Int8>& ViewTabBar::getUnoTunnelId (void)
     389             : {
     390           0 :     return theViewTabBarUnoTunnelId::get().getSeq();
     391             : }
     392             : 
     393           0 : sal_Int64 SAL_CALL ViewTabBar::getSomething (const Sequence<sal_Int8>& rId)
     394             :     throw (RuntimeException)
     395             : {
     396           0 :     sal_Int64 nResult = 0;
     397             : 
     398           0 :     if (rId.getLength() == 16
     399           0 :         && memcmp(getUnoTunnelId().getConstArray(), rId.getConstArray(), 16) == 0)
     400             :     {
     401           0 :         nResult = reinterpret_cast<sal_Int64>(this);
     402             :     }
     403             : 
     404           0 :     return nResult;
     405             : }
     406             : 
     407             : 
     408             : 
     409             : 
     410             : //-----------------------------------------------------------------------------
     411             : 
     412           0 : bool ViewTabBar::ActivatePage (void)
     413             : {
     414             :     try
     415             :     {
     416           0 :         Reference<XControllerManager> xControllerManager (mxController,UNO_QUERY_THROW);
     417             :         Reference<XConfigurationController> xConfigurationController (
     418           0 :             xControllerManager->getConfigurationController());
     419           0 :         if ( ! xConfigurationController.is())
     420           0 :             throw RuntimeException();
     421           0 :         Reference<XView> xView;
     422             :         try
     423             :         {
     424           0 :             xView = Reference<XView>(xConfigurationController->getResource(
     425             :                 ResourceId::create(
     426             :                     ::comphelper::getProcessComponentContext(),
     427           0 :                     FrameworkHelper::msCenterPaneURL)),
     428           0 :                 UNO_QUERY);
     429             :         }
     430           0 :         catch (const DeploymentException&)
     431             :         {
     432             :         }
     433             : 
     434           0 :         Client* pIPClient = NULL;
     435           0 :         if (mpViewShellBase != NULL)
     436           0 :             pIPClient = dynamic_cast<Client*>(mpViewShellBase->GetIPClient());
     437           0 :         if (pIPClient==NULL || ! pIPClient->IsObjectInPlaceActive())
     438             :         {
     439           0 :             sal_uInt16 nIndex (mpTabControl->GetCurPageId() - 1);
     440           0 :             if (nIndex < maTabBarButtons.size())
     441             :             {
     442           0 :                 xConfigurationController->requestResourceActivation(
     443           0 :                     maTabBarButtons[nIndex].ResourceId,
     444           0 :                     ResourceActivationMode_REPLACE);
     445             :             }
     446             : 
     447           0 :             return true;
     448             :         }
     449             :         else
     450             :         {
     451             :             // When we run into this else branch then we have an active OLE
     452             :             // object.  We ignore the request to switch views.  Additionally
     453             :             // we put the active tab back to the one for the current view.
     454           0 :             UpdateActiveButton();
     455           0 :         }
     456             :     }
     457           0 :     catch (const RuntimeException&)
     458             :     {
     459             :         DBG_UNHANDLED_EXCEPTION();
     460             :     }
     461             : 
     462           0 :     return false;
     463             : }
     464             : 
     465             : 
     466             : 
     467             : 
     468         113 : int ViewTabBar::GetHeight (void)
     469             : {
     470         113 :     int nHeight (0);
     471             : 
     472         113 :     if (!maTabBarButtons.empty())
     473             :     {
     474             :         TabPage* pActivePage (mpTabControl->GetTabPage(
     475         113 :             mpTabControl->GetCurPageId()));
     476         113 :         if (pActivePage!=NULL && mpTabControl->IsReallyVisible())
     477          52 :             nHeight = pActivePage->GetPosPixel().Y();
     478             : 
     479         113 :         if (nHeight <= 0)
     480             :             // Using a default when the real height can not be determined.
     481             :             // To get correct height this method should be called when the
     482             :             // control is visible.
     483          61 :             nHeight = 21;
     484             :     }
     485             : 
     486         113 :     return nHeight;
     487             : }
     488             : 
     489             : 
     490             : 
     491             : 
     492          65 : void ViewTabBar::AddTabBarButton (
     493             :     const ::com::sun::star::drawing::framework::TabBarButton& rButton,
     494             :     const ::com::sun::star::drawing::framework::TabBarButton& rAnchor)
     495             : {
     496             :     sal_uInt32 nIndex;
     497             : 
     498         208 :     if ( ! rAnchor.ResourceId.is()
     499         260 :         || (rAnchor.ResourceId->getResourceURL().isEmpty()
     500           0 :             && rAnchor.ButtonLabel.isEmpty()))
     501             :     {
     502          13 :         nIndex = 0;
     503             :     }
     504             :     else
     505             :     {
     506         130 :         for (nIndex=0; nIndex<maTabBarButtons.size(); ++nIndex)
     507             :         {
     508         130 :             if (IsEqual(maTabBarButtons[nIndex], rAnchor))
     509             :             {
     510          52 :                 ++nIndex;
     511          52 :                 break;
     512             :             }
     513             :         }
     514             :     }
     515             : 
     516          65 :     AddTabBarButton(rButton,nIndex);
     517          65 : }
     518             : 
     519             : 
     520             : 
     521             : 
     522           0 : void ViewTabBar::AddTabBarButton (
     523             :     const ::com::sun::star::drawing::framework::TabBarButton& rButton)
     524             : {
     525           0 :     AddTabBarButton(rButton, maTabBarButtons.size());
     526           0 : }
     527             : 
     528             : 
     529             : 
     530             : 
     531          65 : void ViewTabBar::AddTabBarButton (
     532             :     const ::com::sun::star::drawing::framework::TabBarButton& rButton,
     533             :     sal_Int32 nPosition)
     534             : {
     535          65 :     if (nPosition>=0
     536          65 :         && nPosition<=mpTabControl->GetPageCount())
     537             :     {
     538          65 :         sal_uInt16 nIndex ((sal_uInt16)nPosition);
     539             : 
     540             :         // Insert the button into our local array.
     541          65 :         maTabBarButtons.insert(maTabBarButtons.begin()+nIndex, rButton);
     542          65 :         UpdateTabBarButtons();
     543          65 :         UpdateActiveButton();
     544             :     }
     545          65 : }
     546             : 
     547             : 
     548             : 
     549             : 
     550           0 : void ViewTabBar::RemoveTabBarButton (
     551             :     const ::com::sun::star::drawing::framework::TabBarButton& rButton)
     552             : {
     553             :     sal_uInt16 nIndex;
     554           0 :     for (nIndex=0; nIndex<maTabBarButtons.size(); ++nIndex)
     555             :     {
     556           0 :         if (IsEqual(maTabBarButtons[nIndex], rButton))
     557             :         {
     558           0 :             maTabBarButtons.erase(maTabBarButtons.begin()+nIndex);
     559           0 :             UpdateTabBarButtons();
     560           0 :             UpdateActiveButton();
     561           0 :             break;
     562             :         }
     563             :     }
     564           0 : }
     565             : 
     566             : 
     567             : 
     568             : 
     569          65 : bool ViewTabBar::HasTabBarButton (
     570             :     const ::com::sun::star::drawing::framework::TabBarButton& rButton)
     571             : {
     572          65 :     bool bResult (false);
     573             : 
     574         195 :     for (sal_uInt32 nIndex=0; nIndex<maTabBarButtons.size(); ++nIndex)
     575             :     {
     576         130 :         if (IsEqual(maTabBarButtons[nIndex], rButton))
     577             :         {
     578           0 :             bResult = true;
     579           0 :             break;
     580             :         }
     581             :     }
     582             : 
     583          65 :     return bResult;
     584             : }
     585             : 
     586             : 
     587             : 
     588             : 
     589             : ::com::sun::star::uno::Sequence<com::sun::star::drawing::framework::TabBarButton>
     590           0 :     ViewTabBar::GetTabBarButtons (void)
     591             : {
     592           0 :     sal_uInt32 nCount (maTabBarButtons.size());
     593             :     ::com::sun::star::uno::Sequence<com::sun::star::drawing::framework::TabBarButton>
     594           0 :           aList (nCount);
     595             : 
     596           0 :     for (sal_uInt32 nIndex=0; nIndex<nCount; ++nIndex)
     597           0 :         aList[nIndex] = maTabBarButtons[nIndex];
     598             : 
     599           0 :     return aList;
     600             : }
     601             : 
     602             : 
     603             : 
     604             : 
     605          65 : void ViewTabBar::UpdateActiveButton (void)
     606             : {
     607          65 :     Reference<XView> xView;
     608          65 :     if (mpViewShellBase != NULL)
     609         130 :         xView = FrameworkHelper::Instance(*mpViewShellBase)->GetView(
     610         130 :             mxViewTabBarId->getAnchor());
     611          65 :     if (xView.is())
     612             :     {
     613          65 :         Reference<XResourceId> xViewId (xView->getResourceId());
     614          65 :         for (sal_uInt16 nIndex=0; nIndex<maTabBarButtons.size(); ++nIndex)
     615             :         {
     616          65 :             if (maTabBarButtons[nIndex].ResourceId->compareTo(xViewId) == 0)
     617             :             {
     618          65 :                 mpTabControl->SetCurPageId(nIndex+1);
     619          65 :                 mpTabControl->::TabControl::ActivatePage();
     620          65 :                 break;
     621             :             }
     622          65 :         }
     623          65 :     }
     624          65 : }
     625             : 
     626             : 
     627             : 
     628             : 
     629          65 : void ViewTabBar::UpdateTabBarButtons (void)
     630             : {
     631          65 :     TabBarButtonList::const_iterator iTab;
     632          65 :     sal_uInt16 nPageCount (mpTabControl->GetPageCount());
     633             :     sal_uInt16 nIndex;
     634         260 :     for (iTab=maTabBarButtons.begin(),nIndex=1; iTab!=maTabBarButtons.end(); ++iTab,++nIndex)
     635             :     {
     636             :         // Create a new tab when there are not enough.
     637         195 :         if (nPageCount < nIndex)
     638          65 :             mpTabControl->InsertPage(nIndex, iTab->ButtonLabel);
     639             : 
     640             :         // Update the tab.
     641         195 :         mpTabControl->SetPageText(nIndex, iTab->ButtonLabel);
     642         195 :         mpTabControl->SetHelpText(nIndex, iTab->HelpText);
     643         195 :         mpTabControl->SetTabPage(nIndex, mpTabPage.get());
     644             :     }
     645             : 
     646             :     // Delete tabs that are no longer used.
     647          65 :     for (; nIndex<=nPageCount; ++nIndex)
     648           0 :         mpTabControl->RemovePage(nIndex);
     649             : 
     650          65 :     mpTabPage->Hide();
     651          65 : }
     652             : 
     653             : 
     654             : 
     655             : 
     656             : //===== TabBarControl =========================================================
     657             : 
     658          13 : TabBarControl::TabBarControl (
     659             :     ::Window* pParentWindow,
     660             :     const ::rtl::Reference<ViewTabBar>& rpViewTabBar)
     661             :     : ::TabControl(pParentWindow),
     662          13 :       mpViewTabBar(rpViewTabBar)
     663             : {
     664          13 : }
     665             : 
     666             : 
     667             : 
     668             : 
     669          21 : void TabBarControl::Paint (const Rectangle& rRect)
     670             : {
     671          21 :     Color aOriginalFillColor (GetFillColor());
     672          21 :     Color aOriginalLineColor (GetLineColor());
     673             : 
     674             :     // Because the actual window background is transparent--to avoid
     675             :     // flickering due to multiple background paintings by this and by child
     676             :     // windows--we have to paint the background for this control explicitly:
     677             :     // the actual control is not painted over its whole bounding box.
     678          21 :     SetFillColor (GetSettings().GetStyleSettings().GetDialogColor());
     679          21 :     SetLineColor ();
     680          21 :     DrawRect (rRect);
     681          21 :     ::TabControl::Paint (rRect);
     682             : 
     683          21 :     SetFillColor (aOriginalFillColor);
     684          21 :     SetLineColor (aOriginalLineColor);
     685          21 : }
     686             : 
     687             : 
     688             : 
     689             : 
     690           0 : void TabBarControl::ActivatePage (void)
     691             : {
     692           0 :     if (mpViewTabBar->ActivatePage())
     693             :     {
     694             :         // Call the parent so that the correct tab is highlighted.
     695           0 :         this->::TabControl::ActivatePage();
     696             :     }
     697           0 : }
     698             : 
     699          33 : } // end of namespace sd
     700             : 
     701             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10