LCOV - code coverage report
Current view: top level - framework/source/helper - dockingareadefaultacceptor.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 47 49 95.9 %
Date: 2014-04-11 Functions: 6 6 100.0 %
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 <helper/dockingareadefaultacceptor.hxx>
      21             : 
      22             : #include <com/sun/star/awt/XDevice.hpp>
      23             : #include <com/sun/star/awt/PosSize.hpp>
      24             : #include <com/sun/star/awt/XLayoutConstrains.hpp>
      25             : 
      26             : #include <vcl/svapp.hxx>
      27             : 
      28             : namespace framework{
      29             : 
      30             : using namespace ::com::sun::star::container;
      31             : using namespace ::com::sun::star::frame;
      32             : using namespace ::com::sun::star::lang;
      33             : using namespace ::com::sun::star::uno;
      34             : using namespace ::cppu;
      35             : using namespace ::osl;
      36             : 
      37             : //  constructor
      38             : 
      39        2077 : DockingAreaDefaultAcceptor::DockingAreaDefaultAcceptor( const   css::uno::Reference< XFrame >&      xOwner  )
      40        2077 :         :   m_xOwner        ( xOwner    )
      41             : {
      42        2077 : }
      43             : 
      44             : //  destructor
      45             : 
      46        4128 : DockingAreaDefaultAcceptor::~DockingAreaDefaultAcceptor()
      47             : {
      48        4128 : }
      49             : 
      50             : //  XDockingAreaAcceptor
      51        4145 : css::uno::Reference< css::awt::XWindow > SAL_CALL DockingAreaDefaultAcceptor::getContainerWindow() throw (css::uno::RuntimeException, std::exception)
      52             : {
      53        4145 :     SolarMutexGuard g;
      54             : 
      55             :     // Try to "lock" the frame for access to taskscontainer.
      56        8290 :     css::uno::Reference< XFrame > xFrame( m_xOwner );
      57             :     //TODO: check xFrame for null?
      58        4145 :     css::uno::Reference< css::awt::XWindow > xContainerWindow( xFrame->getContainerWindow() );
      59             : 
      60        8290 :     return xContainerWindow;
      61             : }
      62             : 
      63        6324 : sal_Bool SAL_CALL DockingAreaDefaultAcceptor::requestDockingAreaSpace( const css::awt::Rectangle& RequestedSpace ) throw (css::uno::RuntimeException, std::exception)
      64             : {
      65             :     // Try to "lock" the frame for access to taskscontainer.
      66        6324 :     css::uno::Reference< XFrame > xFrame( m_xOwner );
      67             : 
      68        6324 :     if ( xFrame.is() )
      69             :     {
      70        6324 :         css::uno::Reference< css::awt::XWindow > xContainerWindow( xFrame->getContainerWindow() );
      71        6324 :         css::uno::Reference< css::awt::XWindow > xComponentWindow( xFrame->getComponentWindow() );
      72             : 
      73        6324 :         if ( xContainerWindow.is() && xComponentWindow.is() )
      74             :         {
      75        6324 :             css::uno::Reference< css::awt::XDevice > xDevice( xContainerWindow, css::uno::UNO_QUERY );
      76             :             // Convert relativ size to output size.
      77        6324 :             css::awt::Rectangle  aRectangle  = xContainerWindow->getPosSize();
      78        6324 :             css::awt::DeviceInfo aInfo       = xDevice->getInfo();
      79        6324 :             css::awt::Size       aSize       (  aRectangle.Width  - aInfo.LeftInset - aInfo.RightInset  ,
      80       12648 :                                                 aRectangle.Height - aInfo.TopInset  - aInfo.BottomInset );
      81             : 
      82        6324 :             css::awt::Size aMinSize( 0, 0 ); // = xLayoutContrains->getMinimumSize();
      83             : 
      84             :             // Check if request border space would decrease component window size below minimum size
      85       12648 :             if ((( aSize.Width - RequestedSpace.X - RequestedSpace.Width ) < aMinSize.Width ) ||
      86        6324 :                 (( aSize.Height - RequestedSpace.Y - RequestedSpace.Height ) < aMinSize.Height  )       )
      87          31 :                 return sal_False;
      88             : 
      89        6293 :             return sal_True;
      90           0 :         }
      91             :     }
      92             : 
      93           0 :     return sal_False;
      94             : }
      95             : 
      96        6889 : void SAL_CALL DockingAreaDefaultAcceptor::setDockingAreaSpace( const css::awt::Rectangle& BorderSpace ) throw (css::uno::RuntimeException, std::exception)
      97             : {
      98        6889 :     SolarMutexGuard g;
      99             : 
     100             :     // Try to "lock" the frame for access to taskscontainer.
     101       13778 :     css::uno::Reference< XFrame > xFrame( m_xOwner );
     102        6889 :     if ( xFrame.is() )
     103             :     {
     104        6889 :         css::uno::Reference< css::awt::XWindow > xContainerWindow( xFrame->getContainerWindow() );
     105       13778 :         css::uno::Reference< css::awt::XWindow > xComponentWindow( xFrame->getComponentWindow() );
     106             : 
     107        6889 :         if ( xContainerWindow.is() && xComponentWindow.is() )
     108             :         {
     109        6889 :             css::uno::Reference< css::awt::XDevice > xDevice( xContainerWindow, css::uno::UNO_QUERY );
     110             :             // Convert relativ size to output size.
     111        6889 :             css::awt::Rectangle  aRectangle  = xContainerWindow->getPosSize();
     112        6889 :             css::awt::DeviceInfo aInfo       = xDevice->getInfo();
     113        6889 :             css::awt::Size       aSize       (  aRectangle.Width  - aInfo.LeftInset - aInfo.RightInset  ,
     114       13778 :                                                 aRectangle.Height - aInfo.TopInset  - aInfo.BottomInset );
     115        6889 :             css::awt::Size aMinSize( 0, 0 );// = xLayoutContrains->getMinimumSize();
     116             : 
     117             :             // Check if request border space would decrease component window size below minimum size
     118        6889 :             sal_Int32 nWidth     = aSize.Width - BorderSpace.X - BorderSpace.Width;
     119        6889 :             sal_Int32 nHeight    = aSize.Height - BorderSpace.Y - BorderSpace.Height;
     120             : 
     121        6889 :             if (( nWidth > aMinSize.Width ) && ( nHeight > aMinSize.Height ))
     122             :             {
     123             :                 // Resize our component window.
     124        6889 :                 xComponentWindow->setPosSize( BorderSpace.X, BorderSpace.Y, nWidth, nHeight, css::awt::PosSize::POSSIZE );
     125        6889 :             }
     126        6889 :         }
     127        6889 :     }
     128        6889 : }
     129             : 
     130             : } // namespace framework
     131             : 
     132             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10