LCOV - code coverage report
Current view: top level - svx/source/sidebar - PanelLayout.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 46 55 83.6 %
Date: 2015-06-13 12:38:46 Functions: 10 12 83.3 %
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             : 
      10             : #include <com/sun/star/frame/XDispatchProvider.hpp>
      11             : #include <com/sun/star/util/URL.hpp>
      12             : #include <com/sun/star/util/URLTransformer.hpp>
      13             : #include <comphelper/processfactory.hxx>
      14             : #include <svx/sidebar/PanelLayout.hxx>
      15             : #include <vcl/layout.hxx>
      16             : 
      17        1740 : PanelLayout::PanelLayout(vcl::Window* pParent, const OString& rID, const OUString& rUIXMLDescription, const com::sun::star::uno::Reference<com::sun::star::frame::XFrame> &rFrame)
      18             :     : Control(pParent)
      19        1860 :     , m_bInClose(false)
      20             : {
      21        1740 :     SetStyle(GetStyle() | WB_DIALOGCONTROL);
      22        1860 :     m_pUIBuilder = new VclBuilder(this, getUIRootDir(), rUIXMLDescription, rID, rFrame);
      23        1620 :     m_aPanelLayoutIdle.SetPriority(SchedulerPriority::RESIZE);
      24        1620 :     m_aPanelLayoutIdle.SetIdleHdl( LINK( this, PanelLayout, ImplHandlePanelLayoutTimerHdl ) );
      25        1620 : }
      26             : 
      27           0 : PanelLayout::~PanelLayout()
      28             : {
      29           0 :     disposeOnce();
      30           0 : }
      31             : 
      32        1620 : void PanelLayout::dispose()
      33             : {
      34        1620 :     m_bInClose = true;
      35        1620 :     m_aPanelLayoutIdle.Stop();
      36        1620 :     disposeBuilder();
      37        1620 :     Control::dispose();
      38        1620 : }
      39             : 
      40        2258 : Size PanelLayout::GetOptimalSize() const
      41             : {
      42        2258 :     if (isLayoutEnabled(this))
      43        2258 :         return VclContainer::getLayoutRequisition(*GetWindow(GetWindowType::FirstChild));
      44             : 
      45           0 :     return Control::GetOptimalSize();
      46             : }
      47             : 
      48       70698 : bool PanelLayout::hasPanelPendingLayout() const
      49             : {
      50       70698 :     return m_aPanelLayoutIdle.IsActive();
      51             : }
      52             : 
      53      128787 : void PanelLayout::queue_resize(StateChangedType /*eReason*/)
      54             : {
      55      128787 :     if (m_bInClose)
      56       58089 :         return;
      57       70698 :     if (hasPanelPendingLayout())
      58       65448 :         return;
      59        5250 :     if (!isLayoutEnabled(this))
      60        3360 :         return;
      61        1890 :     InvalidateSizeCache();
      62        1890 :     m_aPanelLayoutIdle.Start();
      63             : }
      64             : 
      65        3770 : IMPL_LINK_NOARG_TYPED( PanelLayout, ImplHandlePanelLayoutTimerHdl, Idle*, void )
      66             : {
      67        1885 :     vcl::Window *pChild = GetWindow(GetWindowType::FirstChild);
      68             :     assert(pChild);
      69        1885 :     VclContainer::setLayoutAllocation(*pChild, Point(0, 0), GetSizePixel());
      70        1885 : }
      71             : 
      72        1504 : void PanelLayout::setPosSizePixel(long nX, long nY, long nWidth, long nHeight, PosSizeFlags nFlags)
      73             : {
      74        1504 :     bool bCanHandleSmallerWidth = false;
      75        1504 :     bool bCanHandleSmallerHeight = false;
      76             : 
      77        1504 :     bool bIsLayoutEnabled = isLayoutEnabled(this);
      78        1504 :     vcl::Window *pChild = GetWindow(GetWindowType::FirstChild);
      79             : 
      80        1504 :     if (bIsLayoutEnabled && pChild->GetType() == WINDOW_SCROLLWINDOW)
      81             :     {
      82           0 :         WinBits nStyle = pChild->GetStyle();
      83           0 :         if (nStyle & (WB_AUTOHSCROLL | WB_HSCROLL))
      84           0 :             bCanHandleSmallerWidth = true;
      85           0 :         if (nStyle & (WB_AUTOVSCROLL | WB_VSCROLL))
      86           0 :             bCanHandleSmallerHeight = true;
      87             :     }
      88             : 
      89        1504 :     Size aSize(GetOptimalSize());
      90        1504 :     if (!bCanHandleSmallerWidth)
      91        1504 :         nWidth = std::max(nWidth,aSize.Width());
      92        1504 :     if (!bCanHandleSmallerHeight)
      93        1504 :         nHeight = std::max(nHeight,aSize.Height());
      94             : 
      95        1504 :     Control::setPosSizePixel(nX, nY, nWidth, nHeight, nFlags);
      96             : 
      97        1504 :     if (bIsLayoutEnabled && (nFlags & PosSizeFlags::Size))
      98        1504 :         VclContainer::setLayoutAllocation(*pChild, Point(0, 0), Size(nWidth, nHeight));
      99        1894 : }
     100             : 
     101             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11