LCOV - code coverage report
Current view: top level - sfx2/source/sidebar - Panel.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 51 63 81.0 %
Date: 2015-06-13 12:38:46 Functions: 14 16 87.5 %
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             : using namespace css;
      42             : using namespace css::uno;
      43             : 
      44             : namespace sfx2 { namespace sidebar {
      45             : 
      46        4927 : Panel::Panel(const PanelDescriptor& rPanelDescriptor,
      47             :              vcl::Window* pParentWindow,
      48             :              const bool bIsInitiallyExpanded,
      49             :              const std::function<void()>& rDeckLayoutTrigger,
      50             :              const std::function<Context()>& rContextAccess)
      51             :     : Window(pParentWindow)
      52             :     , msPanelId(rPanelDescriptor.msId)
      53             :     , mpTitleBar(VclPtr<PanelTitleBar>::Create(rPanelDescriptor.msTitle, pParentWindow, this))
      54             :     , mbIsTitleBarOptional(rPanelDescriptor.mbIsTitleBarOptional)
      55             :     , mxElement()
      56             :     , mxPanelComponent()
      57             :     , mbIsExpanded(bIsInitiallyExpanded)
      58             :     , maDeckLayoutTrigger(rDeckLayoutTrigger)
      59        4927 :     , maContextAccess(rContextAccess)
      60             : {
      61             : #ifdef DEBUG
      62             :     SetText(OUString("Panel"));
      63             : #endif
      64        4927 : }
      65             : 
      66       14781 : Panel::~Panel()
      67             : {
      68        4927 :     disposeOnce();
      69        9854 : }
      70             : 
      71         145 : void Panel::ApplySettings(vcl::RenderContext& rRenderContext)
      72             : {
      73         145 :     rRenderContext.SetBackground(Theme::GetPaint(Theme::Paint_PanelBackground).GetWallpaper());
      74         145 : }
      75             : 
      76        4927 : void Panel::dispose()
      77             : {
      78        4927 :     mxPanelComponent = NULL;
      79             : 
      80             :     {
      81        4927 :         Reference<lang::XComponent> xComponent (mxElement, UNO_QUERY);
      82        4927 :         mxElement = NULL;
      83        4927 :         if (xComponent.is())
      84        4248 :             xComponent->dispose();
      85             :     }
      86             : 
      87             :     {
      88        4927 :         Reference<lang::XComponent> xComponent (GetElementWindow(), UNO_QUERY);
      89        4927 :         if (xComponent.is())
      90           0 :             xComponent->dispose();
      91             :     }
      92             : 
      93        4927 :     mpTitleBar.disposeAndClear();
      94             : 
      95        4927 :     vcl::Window::dispose();
      96        4927 : }
      97             : 
      98       43348 : PanelTitleBar* Panel::GetTitleBar() const
      99             : {
     100       43348 :     return mpTitleBar.get();
     101             : }
     102             : 
     103        4248 : void Panel::SetUIElement (const Reference<ui::XUIElement>& rxElement)
     104             : {
     105        4248 :     mxElement = rxElement;
     106        4248 :     if (mxElement.is())
     107             :     {
     108        4248 :         mxPanelComponent.set(mxElement->getRealInterface(), UNO_QUERY);
     109             :     }
     110        4248 : }
     111             : 
     112         125 : void Panel::SetExpanded (const bool bIsExpanded)
     113             : {
     114         125 :     if (mbIsExpanded != bIsExpanded)
     115             :     {
     116           0 :         mbIsExpanded = bIsExpanded;
     117           0 :         maDeckLayoutTrigger();
     118             : 
     119           0 :         if (maContextAccess)
     120             :         {
     121           0 :             ResourceManager::Instance().StorePanelExpansionState(
     122             :                 msPanelId,
     123             :                 bIsExpanded,
     124           0 :                 maContextAccess());
     125             :         }
     126             :     }
     127         125 : }
     128             : 
     129        1958 : bool Panel::HasIdPredicate (const OUString& rsId) const
     130             : {
     131        1958 :     return msPanelId.equals(rsId);
     132             : }
     133             : 
     134         145 : void Panel::Paint (vcl::RenderContext& rRenderContext, const Rectangle& rUpdateArea)
     135             : {
     136         145 :     Window::Paint(rRenderContext, rUpdateArea);
     137         145 : }
     138             : 
     139        3182 : void Panel::Resize()
     140             : {
     141        3182 :     Window::Resize();
     142             : 
     143             :     // Forward new size to window of XUIElement.
     144        3182 :     Reference<awt::XWindow> xElementWindow (GetElementWindow());
     145        3182 :     if(xElementWindow.is())
     146             :     {
     147        3182 :         const Size aSize(GetSizePixel());
     148        9546 :         xElementWindow->setPosSize(0, 0, aSize.Width(), aSize.Height(),
     149        9546 :                                    awt::PosSize::POSSIZE);
     150        3182 :     }
     151        3182 : }
     152             : 
     153           0 : void Panel::Activate()
     154             : {
     155           0 :     Window::Activate();
     156           0 : }
     157             : 
     158           0 : void Panel::DataChanged (const DataChangedEvent& rEvent)
     159             : {
     160             :     (void)rEvent;
     161           0 :     Invalidate();
     162           0 : }
     163             : 
     164        8109 : Reference<awt::XWindow> Panel::GetElementWindow()
     165             : {
     166        8109 :     if (mxElement.is())
     167             :     {
     168        3182 :         Reference<ui::XToolPanel> xToolPanel(mxElement->getRealInterface(), UNO_QUERY);
     169        3182 :         if (xToolPanel.is())
     170        3182 :             return xToolPanel->getWindow();
     171             :     }
     172             : 
     173        4927 :     return NULL;
     174             : }
     175             : 
     176         648 : } } // end of namespace sfx2::sidebar
     177             : 
     178             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11