LCOV - code coverage report
Current view: top level - svx/source/sidebar - PanelLayout.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 43 49 87.8 %
Date: 2014-11-03 Functions: 10 11 90.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             : 
      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        2218 : 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        2218 :     , m_bInClose(false)
      20             : {
      21        2218 :     SetStyle(GetStyle() | WB_DIALOGCONTROL);
      22        2218 :     m_pUIBuilder = new VclBuilder(this, getUIRootDir(), rUIXMLDescription, rID, rFrame);
      23        2218 :     m_aPanelLayoutTimer.SetTimeout(50);
      24        2218 :     m_aPanelLayoutTimer.SetTimeoutHdl( LINK( this, PanelLayout, ImplHandlePanelLayoutTimerHdl ) );
      25        2218 : }
      26             : 
      27        4436 : PanelLayout::~PanelLayout()
      28             : {
      29        2218 :     m_bInClose = true;
      30        2218 :     m_aPanelLayoutTimer.Stop();
      31        2218 : }
      32             : 
      33        4428 : Size PanelLayout::GetOptimalSize() const
      34             : {
      35        4428 :     if (isLayoutEnabled(this))
      36        4428 :         return VclContainer::getLayoutRequisition(*GetWindow(WINDOW_FIRSTCHILD));
      37             : 
      38           0 :     return Control::GetOptimalSize();
      39             : }
      40             : 
      41      112996 : bool PanelLayout::hasPanelPendingLayout() const
      42             : {
      43      112996 :     return m_aPanelLayoutTimer.IsActive();
      44             : }
      45             : 
      46      213388 : void PanelLayout::queue_resize(StateChangedType /*eReason*/)
      47             : {
      48      213388 :     if (m_bInClose)
      49      100392 :         return;
      50      112996 :     if (hasPanelPendingLayout())
      51      106317 :         return;
      52        6679 :     if (!isLayoutEnabled(this))
      53        4436 :         return;
      54        2243 :     m_aPanelLayoutTimer.Start();
      55             : }
      56             : 
      57        4414 : IMPL_LINK( PanelLayout, ImplHandlePanelLayoutTimerHdl, void*, EMPTYARG )
      58             : {
      59        2207 :     vcl::Window *pChild = GetWindow(WINDOW_FIRSTCHILD);
      60             :     assert(pChild);
      61        2207 :     VclContainer::setLayoutAllocation(*pChild, Point(0, 0), GetSizePixel());
      62        2207 :     return 0;
      63             : }
      64             : 
      65        2952 : void PanelLayout::setPosSizePixel(long nX, long nY, long nWidth, long nHeight, sal_uInt16 nFlags)
      66             : {
      67        2952 :     bool bCanHandleSmallerWidth = false;
      68        2952 :     bool bCanHandleSmallerHeight = false;
      69             : 
      70        2952 :     bool bIsLayoutEnabled = isLayoutEnabled(this);
      71        2952 :     vcl::Window *pChild = GetWindow(WINDOW_FIRSTCHILD);
      72             : 
      73        2952 :     if (bIsLayoutEnabled && pChild->GetType() == WINDOW_SCROLLWINDOW)
      74             :     {
      75           0 :         WinBits nStyle = pChild->GetStyle();
      76           0 :         if (nStyle & (WB_AUTOHSCROLL | WB_HSCROLL))
      77           0 :             bCanHandleSmallerWidth = true;
      78           0 :         if (nStyle & (WB_AUTOVSCROLL | WB_VSCROLL))
      79           0 :             bCanHandleSmallerHeight = true;
      80             :     }
      81             : 
      82        2952 :     Size aSize(GetOptimalSize());
      83        2952 :     if (!bCanHandleSmallerWidth)
      84        2952 :         nWidth = std::max(nWidth,aSize.Width());
      85        2952 :     if (!bCanHandleSmallerHeight)
      86        2952 :         nHeight = std::max(nHeight,aSize.Height());
      87             : 
      88        2952 :     Control::setPosSizePixel(nX, nY, nWidth, nHeight, nFlags);
      89             : 
      90        2952 :     if (bIsLayoutEnabled && (nFlags & WINDOW_POSSIZE_SIZE))
      91        2952 :         VclContainer::setLayoutAllocation(*pChild, Point(0, 0), Size(nWidth, nHeight));
      92        3546 : }
      93             : 
      94             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10