LCOV - code coverage report
Current view: top level - sfx2/source/sidebar - SidebarPanelBase.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 1 69 1.4 %
Date: 2014-04-14 Functions: 2 17 11.8 %
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             : #include <sfx2/sidebar/SidebarPanelBase.hxx>
      20             : #include <sfx2/sidebar/Theme.hxx>
      21             : #include <sfx2/sidebar/ILayoutableWindow.hxx>
      22             : #include <sfx2/sidebar/IContextChangeReceiver.hxx>
      23             : #include <sfx2/imagemgr.hxx>
      24             : #include <vcl/ctrl.hxx>
      25             : #include <vcl/layout.hxx>
      26             : #include <comphelper/processfactory.hxx>
      27             : 
      28             : #include <com/sun/star/ui/ContextChangeEventMultiplexer.hpp>
      29             : #include <com/sun/star/ui/UIElementType.hpp>
      30             : 
      31             : using namespace css;
      32             : using namespace cssu;
      33             : 
      34             : 
      35             : namespace sfx2 { namespace sidebar {
      36             : 
      37           0 : Reference<ui::XUIElement> SidebarPanelBase::Create (
      38             :     const ::rtl::OUString& rsResourceURL,
      39             :     const cssu::Reference<css::frame::XFrame>& rxFrame,
      40             :     Window* pWindow,
      41             :     const css::ui::LayoutSize& rLayoutSize)
      42             : {
      43             :     Reference<ui::XUIElement> xUIElement (
      44             :         new SidebarPanelBase(
      45             :             rsResourceURL,
      46             :             rxFrame,
      47             :             pWindow,
      48           0 :             rLayoutSize));
      49           0 :     return xUIElement;
      50             : }
      51             : 
      52             : 
      53             : 
      54             : 
      55           0 : SidebarPanelBase::SidebarPanelBase (
      56             :     const ::rtl::OUString& rsResourceURL,
      57             :     const cssu::Reference<css::frame::XFrame>& rxFrame,
      58             :     Window* pWindow,
      59             :     const css::ui::LayoutSize& rLayoutSize)
      60             :     : SidebarPanelBaseInterfaceBase(m_aMutex),
      61             :       mxFrame(rxFrame),
      62             :       mpControl(pWindow),
      63             :       msResourceURL(rsResourceURL),
      64           0 :       maLayoutSize(rLayoutSize)
      65             : {
      66           0 :     if (mxFrame.is())
      67             :     {
      68             :         cssu::Reference<css::ui::XContextChangeEventMultiplexer> xMultiplexer (
      69             :             css::ui::ContextChangeEventMultiplexer::get(
      70           0 :                 ::comphelper::getProcessComponentContext()));
      71           0 :         if (xMultiplexer.is())
      72           0 :             xMultiplexer->addContextChangeEventListener(this, mxFrame->getController());
      73             :     }
      74           0 :     if (mpControl != NULL)
      75             :     {
      76           0 :         mpControl->SetBackground(Theme::GetWallpaper(Theme::Paint_PanelBackground));
      77           0 :         mpControl->Show();
      78             :     }
      79           0 : }
      80             : 
      81             : 
      82             : 
      83             : 
      84           0 : SidebarPanelBase::~SidebarPanelBase (void)
      85             : {
      86           0 : }
      87             : 
      88             : 
      89             : 
      90             : 
      91           0 : void SAL_CALL SidebarPanelBase::disposing (void)
      92             :     throw (cssu::RuntimeException)
      93             : {
      94           0 :     if (mpControl != NULL)
      95             :     {
      96           0 :         delete mpControl;
      97           0 :         mpControl = NULL;
      98             :     }
      99             : 
     100           0 :     if (mxFrame.is())
     101             :     {
     102             :         cssu::Reference<css::ui::XContextChangeEventMultiplexer> xMultiplexer (
     103             :             css::ui::ContextChangeEventMultiplexer::get(
     104           0 :                 ::comphelper::getProcessComponentContext()));
     105           0 :         if (xMultiplexer.is())
     106           0 :             xMultiplexer->removeAllContextChangeEventListeners(this);
     107           0 :         mxFrame = NULL;
     108             :     }
     109           0 : }
     110             : 
     111             : 
     112             : 
     113             : 
     114             : // XContextChangeEventListener
     115           0 : void SAL_CALL SidebarPanelBase::notifyContextChangeEvent (
     116             :     const ui::ContextChangeEventObject& rEvent)
     117             :     throw (cssu::RuntimeException, std::exception)
     118             : {
     119             :     IContextChangeReceiver* pContextChangeReceiver
     120           0 :         = dynamic_cast<IContextChangeReceiver*>(mpControl);
     121           0 :     if (pContextChangeReceiver != NULL)
     122             :     {
     123             :         const EnumContext aContext(
     124             :             EnumContext::GetApplicationEnum(rEvent.ApplicationName),
     125           0 :             EnumContext::GetContextEnum(rEvent.ContextName));
     126           0 :         pContextChangeReceiver->HandleContextChange(aContext);
     127             :     }
     128           0 : }
     129             : 
     130             : 
     131             : 
     132             : 
     133           0 : void SAL_CALL SidebarPanelBase::disposing (
     134             :     const css::lang::EventObject& rEvent)
     135             :     throw (cssu::RuntimeException, std::exception)
     136             : {
     137             :     (void)rEvent;
     138             : 
     139           0 :     mxFrame = NULL;
     140           0 :     mpControl = NULL;
     141           0 : }
     142             : 
     143             : 
     144             : 
     145             : 
     146           0 : cssu::Reference<css::frame::XFrame> SAL_CALL SidebarPanelBase::getFrame (void)
     147             :     throw(cssu::RuntimeException, std::exception)
     148             : {
     149           0 :     return mxFrame;
     150             : }
     151             : 
     152             : 
     153             : 
     154             : 
     155           0 : ::rtl::OUString SAL_CALL SidebarPanelBase::getResourceURL (void)
     156             :     throw(cssu::RuntimeException, std::exception)
     157             : {
     158           0 :     return msResourceURL;
     159             : }
     160             : 
     161             : 
     162             : 
     163             : 
     164           0 : sal_Int16 SAL_CALL SidebarPanelBase::getType (void)
     165             :     throw(cssu::RuntimeException, std::exception)
     166             : {
     167           0 :     return ui::UIElementType::TOOLPANEL;
     168             : }
     169             : 
     170             : 
     171             : 
     172             : 
     173           0 : Reference<XInterface> SAL_CALL SidebarPanelBase::getRealInterface (void)
     174             :     throw(cssu::RuntimeException, std::exception)
     175             : {
     176           0 :     return Reference<XInterface>(static_cast<XWeak*>(this));
     177             : }
     178             : 
     179             : 
     180             : 
     181             : 
     182           0 : Reference<accessibility::XAccessible> SAL_CALL SidebarPanelBase::createAccessible (
     183             :     const Reference<accessibility::XAccessible>& rxParentAccessible)
     184             :     throw(cssu::RuntimeException, std::exception)
     185             : {
     186             :     (void)rxParentAccessible;
     187             : 
     188             :     // Not yet implemented.
     189           0 :     return NULL;
     190             : }
     191             : 
     192             : 
     193             : 
     194             : 
     195           0 : Reference<awt::XWindow> SAL_CALL SidebarPanelBase::getWindow (void)
     196             :     throw(cssu::RuntimeException, std::exception)
     197             : {
     198           0 :     if (mpControl != NULL)
     199             :         return Reference<awt::XWindow>(
     200           0 :             mpControl->GetComponentInterface(),
     201           0 :             UNO_QUERY);
     202             :     else
     203           0 :         return NULL;
     204             : }
     205             : 
     206             : 
     207             : 
     208             : 
     209           0 : ui::LayoutSize SAL_CALL SidebarPanelBase::getHeightForWidth (const sal_Int32 nWidth)
     210             :     throw(cssu::RuntimeException, std::exception)
     211             : {
     212           0 :     if (maLayoutSize.Minimum >= 0)
     213           0 :         return maLayoutSize;
     214             :     else
     215             :     {
     216           0 :         ILayoutableWindow* pLayoutableWindow = dynamic_cast<ILayoutableWindow*>(mpControl);
     217             : 
     218           0 :         if (isLayoutEnabled(mpControl))
     219             :         {
     220             :             // widget layout-based sidebar
     221           0 :             Size aSize(mpControl->GetOptimalSize());
     222           0 :             return ui::LayoutSize(aSize.Height(), aSize.Height(), aSize.Height());
     223             :         }
     224           0 :         else if (pLayoutableWindow != NULL)
     225           0 :             return pLayoutableWindow->GetHeightForWidth(nWidth);
     226           0 :         else if (mpControl != NULL)
     227             :         {
     228           0 :             const sal_Int32 nHeight (mpControl->GetSizePixel().Height());
     229           0 :             return ui::LayoutSize(nHeight,nHeight,nHeight);
     230             :         }
     231             :     }
     232             : 
     233           0 :     return ui::LayoutSize(0,0,0);
     234             : }
     235             : 
     236           0 : sal_Int32 SAL_CALL SidebarPanelBase::getMinimalWidth () throw(cssu::RuntimeException, std::exception)
     237             : {
     238           0 :     if (isLayoutEnabled(mpControl))
     239             :     {
     240             :         // widget layout-based sidebar
     241           0 :         Size aSize(mpControl->GetOptimalSize());
     242           0 :         return aSize.Width();
     243             :     }
     244           0 :     return 0;
     245             : }
     246             : 
     247           3 : } } // end of namespace sfx2::sidebar
     248             : 
     249             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10