LCOV - code coverage report
Current view: top level - framework/source/helper - dockingareadefaultacceptor.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 51 51 100.0 %
Date: 2012-08-25 Functions: 6 6 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 55 108 50.9 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <helper/dockingareadefaultacceptor.hxx>
      30                 :            : #include <threadhelp/resetableguard.hxx>
      31                 :            : 
      32                 :            : #include <com/sun/star/awt/XDevice.hpp>
      33                 :            : #include <com/sun/star/awt/PosSize.hpp>
      34                 :            : #include <com/sun/star/awt/XLayoutConstrains.hpp>
      35                 :            : 
      36                 :            : #include <vcl/svapp.hxx>
      37                 :            : 
      38                 :            : namespace framework{
      39                 :            : 
      40                 :            : using namespace ::com::sun::star::container     ;
      41                 :            : using namespace ::com::sun::star::frame         ;
      42                 :            : using namespace ::com::sun::star::lang          ;
      43                 :            : using namespace ::com::sun::star::uno           ;
      44                 :            : using namespace ::cppu                          ;
      45                 :            : using namespace ::osl                           ;
      46                 :            : 
      47                 :            : //*****************************************************************************************************************
      48                 :            : //  constructor
      49                 :            : //*****************************************************************************************************************
      50                 :       1747 : DockingAreaDefaultAcceptor::DockingAreaDefaultAcceptor( const   css::uno::Reference< XFrame >&      xOwner  )
      51                 :            :         //  Init baseclasses first
      52                 :       1747 :         :   ThreadHelpBase  ( &Application::GetSolarMutex() )
      53                 :            :         // Init member
      54 [ +  - ][ +  - ]:       1747 :         ,   m_xOwner        ( xOwner    )
      55                 :            : {
      56                 :       1747 : }
      57                 :            : 
      58                 :            : //*****************************************************************************************************************
      59                 :            : //  destructor
      60                 :            : //*****************************************************************************************************************
      61 [ +  - ][ +  - ]:       1656 : DockingAreaDefaultAcceptor::~DockingAreaDefaultAcceptor()
      62                 :            : {
      63         [ -  + ]:       3312 : }
      64                 :            : 
      65                 :            : //*****************************************************************************************************************
      66                 :            : //  XDockingAreaAcceptor
      67                 :            : //*****************************************************************************************************************
      68                 :       3411 : css::uno::Reference< css::awt::XWindow > SAL_CALL DockingAreaDefaultAcceptor::getContainerWindow() throw (css::uno::RuntimeException)
      69                 :            : {
      70                 :            :     // Ready for multithreading
      71         [ +  - ]:       3411 :     ResetableGuard aGuard( m_aLock );
      72                 :            : 
      73                 :            :     // Try to "lock" the frame for access to taskscontainer.
      74 [ +  - ][ +  - ]:       3411 :     css::uno::Reference< XFrame > xFrame( m_xOwner.get(), UNO_QUERY );
      75 [ +  - ][ +  - ]:       3411 :     css::uno::Reference< css::awt::XWindow > xContainerWindow( xFrame->getContainerWindow() );
      76                 :            : 
      77         [ +  - ]:       3411 :     return xContainerWindow;
      78                 :            : }
      79                 :            : 
      80                 :       3876 : sal_Bool SAL_CALL DockingAreaDefaultAcceptor::requestDockingAreaSpace( const css::awt::Rectangle& RequestedSpace ) throw (css::uno::RuntimeException)
      81                 :            : {
      82                 :            :     // Ready for multithreading
      83         [ +  - ]:       3876 :     ResetableGuard aGuard( m_aLock );
      84                 :            : 
      85                 :            :     // Try to "lock" the frame for access to taskscontainer.
      86 [ +  - ][ +  - ]:       3876 :     css::uno::Reference< XFrame > xFrame( m_xOwner.get(), UNO_QUERY );
      87         [ +  - ]:       3876 :     aGuard.unlock();
      88                 :            : 
      89         [ +  - ]:       3876 :     if ( xFrame.is() == sal_True )
      90                 :            :     {
      91 [ +  - ][ +  - ]:       3876 :         css::uno::Reference< css::awt::XWindow > xContainerWindow( xFrame->getContainerWindow() );
      92 [ +  - ][ +  - ]:       3876 :         css::uno::Reference< css::awt::XWindow > xComponentWindow( xFrame->getComponentWindow() );
      93                 :            : 
      94   [ +  -  +  - ]:       7752 :         if (( xContainerWindow.is() == sal_True ) &&
                 [ +  - ]
      95                 :       3876 :             ( xComponentWindow.is() == sal_True )       )
      96                 :            :         {
      97         [ +  - ]:       3876 :             css::uno::Reference< css::awt::XDevice > xDevice( xContainerWindow, css::uno::UNO_QUERY );
      98                 :            :             // Convert relativ size to output size.
      99 [ +  - ][ +  - ]:       3876 :             css::awt::Rectangle  aRectangle  = xContainerWindow->getPosSize();
     100 [ +  - ][ +  - ]:       3876 :             css::awt::DeviceInfo aInfo       = xDevice->getInfo();
     101                 :            :             css::awt::Size       aSize       (  aRectangle.Width  - aInfo.LeftInset - aInfo.RightInset  ,
     102                 :       3876 :                                                 aRectangle.Height - aInfo.TopInset  - aInfo.BottomInset );
     103                 :            : 
     104                 :       3876 :             css::awt::Size aMinSize( 0, 0 ); // = xLayoutContrains->getMinimumSize();
     105                 :            : 
     106                 :            :             // Check if request border space would decrease component window size below minimum size
     107 [ +  + ][ +  - ]:       3876 :             if ((( aSize.Width - RequestedSpace.X - RequestedSpace.Width ) < aMinSize.Width ) ||
     108                 :            :                 (( aSize.Height - RequestedSpace.Y - RequestedSpace.Height ) < aMinSize.Height  )       )
     109                 :         64 :                 return sal_False;
     110                 :            : 
     111                 :       3876 :             return sal_True;
     112 [ +  - ][ -  + ]:       3876 :         }
     113                 :            :     }
     114                 :            : 
     115         [ +  - ]:       3876 :     return sal_False;
     116                 :            : }
     117                 :            : 
     118                 :       5155 : void SAL_CALL DockingAreaDefaultAcceptor::setDockingAreaSpace( const css::awt::Rectangle& BorderSpace ) throw (css::uno::RuntimeException)
     119                 :            : {
     120                 :            :     // Ready for multithreading
     121         [ +  - ]:       5155 :     ResetableGuard aGuard( m_aLock );
     122                 :            : 
     123                 :            :     // Try to "lock" the frame for access to taskscontainer.
     124 [ +  - ][ +  - ]:       5155 :     css::uno::Reference< XFrame > xFrame( m_xOwner.get(), UNO_QUERY );
     125         [ +  - ]:       5155 :     if ( xFrame.is() == sal_True )
     126                 :            :     {
     127 [ +  - ][ +  - ]:       5155 :         css::uno::Reference< css::awt::XWindow > xContainerWindow( xFrame->getContainerWindow() );
     128 [ +  - ][ +  - ]:       5155 :         css::uno::Reference< css::awt::XWindow > xComponentWindow( xFrame->getComponentWindow() );
     129                 :            : 
     130   [ +  -  +  - ]:      10310 :         if (( xContainerWindow.is() == sal_True ) &&
                 [ +  - ]
     131                 :       5155 :             ( xComponentWindow.is() == sal_True )       )
     132                 :            :         {
     133         [ +  - ]:       5155 :             css::uno::Reference< css::awt::XDevice > xDevice( xContainerWindow, css::uno::UNO_QUERY );
     134                 :            :             // Convert relativ size to output size.
     135 [ +  - ][ +  - ]:       5155 :             css::awt::Rectangle  aRectangle  = xContainerWindow->getPosSize();
     136 [ +  - ][ +  - ]:       5155 :             css::awt::DeviceInfo aInfo       = xDevice->getInfo();
     137                 :            :             css::awt::Size       aSize       (  aRectangle.Width  - aInfo.LeftInset - aInfo.RightInset  ,
     138                 :       5155 :                                                 aRectangle.Height - aInfo.TopInset  - aInfo.BottomInset );
     139                 :       5155 :             css::awt::Size aMinSize( 0, 0 );// = xLayoutContrains->getMinimumSize();
     140                 :            : 
     141                 :            :             // Check if request border space would decrease component window size below minimum size
     142                 :       5155 :             sal_Int32 nWidth     = aSize.Width - BorderSpace.X - BorderSpace.Width;
     143                 :       5155 :             sal_Int32 nHeight    = aSize.Height - BorderSpace.Y - BorderSpace.Height;
     144                 :            : 
     145 [ +  - ][ +  - ]:       5155 :             if (( nWidth > aMinSize.Width ) && ( nHeight > aMinSize.Height ))
     146                 :            :             {
     147                 :            :                 // Resize our component window.
     148 [ +  - ][ +  - ]:       5155 :                 xComponentWindow->setPosSize( BorderSpace.X, BorderSpace.Y, nWidth, nHeight, css::awt::PosSize::POSSIZE );
     149                 :       5155 :             }
     150                 :       5155 :         }
     151         [ +  - ]:       5155 :     }
     152                 :       5155 : }
     153                 :            : 
     154                 :            : } // namespace framework
     155                 :            : 
     156                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10