LCOV - code coverage report
Current view: top level - sfx2/source/sidebar - Panel.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 52 71 73.2 %
Date: 2014-04-11 Functions: 15 19 78.9 %
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 "Panel.hxx"
      21             : #include "PanelTitleBar.hxx"
      22             : #include "PanelDescriptor.hxx"
      23             : #include <sfx2/sidebar/Theme.hxx>
      24             : #include "Paint.hxx"
      25             : #include "ResourceManager.hxx"
      26             : 
      27             : #ifdef DEBUG
      28             : #include <sfx2/sidebar/Tools.hxx>
      29             : #include "Deck.hxx"
      30             : #endif
      31             : 
      32             : #include <tools/svborder.hxx>
      33             : #include <toolkit/helper/vclunohelper.hxx>
      34             : 
      35             : #include <com/sun/star/awt/XWindowPeer.hpp>
      36             : #include <com/sun/star/awt/PosSize.hpp>
      37             : #include <com/sun/star/ui/XToolPanel.hpp>
      38             : 
      39             : #include <boost/bind.hpp>
      40             : 
      41             : 
      42             : using namespace css;
      43             : using namespace cssu;
      44             : 
      45             : 
      46             : 
      47             : namespace sfx2 { namespace sidebar {
      48             : 
      49          11 : Panel::Panel (
      50             :     const PanelDescriptor& rPanelDescriptor,
      51             :     Window* pParentWindow,
      52             :     const bool bIsInitiallyExpanded,
      53             :     const ::boost::function<void(void)>& rDeckLayoutTrigger,
      54             :     const ::boost::function<Context(void)>& rContextAccess)
      55             :     : Window(pParentWindow),
      56             :       msPanelId(rPanelDescriptor.msId),
      57             :       mpTitleBar(new PanelTitleBar(
      58             :               rPanelDescriptor.msTitle,
      59             :               pParentWindow,
      60          11 :               this)),
      61             :       mbIsTitleBarOptional(rPanelDescriptor.mbIsTitleBarOptional),
      62             :       mxElement(),
      63             :       mxPanelComponent(),
      64             :       mbIsExpanded(bIsInitiallyExpanded),
      65             :       maDeckLayoutTrigger(rDeckLayoutTrigger),
      66          22 :       maContextAccess(rContextAccess)
      67             : {
      68          11 :     SetBackground(Theme::GetPaint(Theme::Paint_PanelBackground).GetWallpaper());
      69             : 
      70             : #ifdef DEBUG
      71             :     SetText(OUString("Panel"));
      72             : #endif
      73          11 : }
      74             : 
      75             : 
      76             : 
      77             : 
      78          33 : Panel::~Panel (void)
      79             : {
      80          11 :     Dispose();
      81          22 : }
      82             : 
      83             : 
      84             : 
      85             : 
      86          22 : void Panel::Dispose (void)
      87             : {
      88          22 :     mxPanelComponent = NULL;
      89             : 
      90             :     {
      91          22 :         Reference<lang::XComponent> xComponent (mxElement, UNO_QUERY);
      92          22 :         mxElement = NULL;
      93          22 :         if (xComponent.is())
      94          11 :             xComponent->dispose();
      95             :     }
      96             : 
      97             :     {
      98          22 :         Reference<lang::XComponent> xComponent (GetElementWindow(), UNO_QUERY);
      99          22 :         if (xComponent.is())
     100           0 :             xComponent->dispose();
     101             :     }
     102             : 
     103          22 :     mpTitleBar.reset();
     104          22 : }
     105             : 
     106             : 
     107             : 
     108             : 
     109         132 : PanelTitleBar* Panel::GetTitleBar (void) const
     110             : {
     111         132 :     return mpTitleBar.get();
     112             : }
     113             : 
     114             : 
     115             : 
     116             : 
     117          66 : bool Panel::IsTitleBarOptional (void) const
     118             : {
     119          66 :     return mbIsTitleBarOptional;
     120             : }
     121             : 
     122             : 
     123             : 
     124             : 
     125          11 : void Panel::SetUIElement (const Reference<ui::XUIElement>& rxElement)
     126             : {
     127          11 :     mxElement = rxElement;
     128          11 :     if (mxElement.is())
     129             :     {
     130          11 :         mxPanelComponent.set(mxElement->getRealInterface(), UNO_QUERY);
     131             :     }
     132          11 : }
     133             : 
     134             : 
     135             : 
     136             : 
     137           0 : void Panel::SetExpanded (const bool bIsExpanded)
     138             : {
     139           0 :     if (mbIsExpanded != bIsExpanded)
     140             :     {
     141           0 :         mbIsExpanded = bIsExpanded;
     142           0 :         maDeckLayoutTrigger();
     143             : 
     144           0 :         if (maContextAccess)
     145           0 :             ResourceManager::Instance().StorePanelExpansionState(
     146             :                 msPanelId,
     147             :                 bIsExpanded,
     148           0 :                 maContextAccess());
     149             :     }
     150           0 : }
     151             : 
     152             : 
     153             : 
     154             : 
     155         141 : bool Panel::IsExpanded (void) const
     156             : {
     157         141 :     return mbIsExpanded;
     158             : }
     159             : 
     160             : 
     161             : 
     162             : 
     163           0 : bool Panel::HasIdPredicate (const ::rtl::OUString& rsId) const
     164             : {
     165           0 :     if (this == NULL)
     166           0 :         return false;
     167             :     else
     168           0 :         return msPanelId.equals(rsId);
     169             : }
     170             : 
     171             : 
     172             : 
     173             : 
     174          11 : const ::rtl::OUString& Panel::GetId (void) const
     175             : {
     176          11 :     return msPanelId;
     177             : }
     178             : 
     179             : 
     180             : 
     181             : 
     182          21 : void Panel::Paint (const Rectangle& rUpdateArea)
     183             : {
     184          21 :     Window::Paint(rUpdateArea);
     185          21 : }
     186             : 
     187             : 
     188             : 
     189             : 
     190          22 : void Panel::Resize (void)
     191             : {
     192          22 :     Window::Resize();
     193             : 
     194             :     // Forward new size to window of XUIElement.
     195          22 :     Reference<awt::XWindow> xElementWindow (GetElementWindow());
     196          22 :     if (xElementWindow.is())
     197             :     {
     198          22 :         const Size aSize (GetSizePixel());
     199          22 :         xElementWindow->setPosSize(
     200             :             0,
     201             :             0,
     202             :             aSize.Width(),
     203             :             aSize.Height(),
     204          22 :             awt::PosSize::POSSIZE);
     205          22 :     }
     206          22 : }
     207             : 
     208             : 
     209             : 
     210             : 
     211           0 : void Panel::Activate (void)
     212             : {
     213           0 :     Window::Activate();
     214           0 : }
     215             : 
     216             : 
     217             : 
     218             : 
     219             : 
     220           0 : void Panel::DataChanged (const DataChangedEvent& rEvent)
     221             : {
     222             :     (void)rEvent;
     223           0 :     SetBackground(Theme::GetPaint(Theme::Paint_PanelBackground).GetWallpaper());
     224           0 : }
     225             : 
     226          66 : Reference<ui::XSidebarPanel> Panel::GetPanelComponent (void) const
     227             : {
     228          66 :     return mxPanelComponent;
     229             : }
     230             : 
     231          44 : Reference<awt::XWindow> Panel::GetElementWindow (void)
     232             : {
     233          44 :     if (mxElement.is())
     234             :     {
     235          22 :         Reference<ui::XToolPanel> xToolPanel(mxElement->getRealInterface(), UNO_QUERY);
     236          22 :         if (xToolPanel.is())
     237          22 :             return xToolPanel->getWindow();
     238             :     }
     239             : 
     240          22 :     return NULL;
     241             : }
     242             : 
     243             : 
     244         447 : } } // end of namespace sfx2::sidebar
     245             : 
     246             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10