LCOV - code coverage report
Current view: top level - embeddedobj/source/commonembedding - inplaceobj.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 14 20 70.0 %
Date: 2012-08-25 Functions: 2 4 50.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 19 40 47.5 %

           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 <com/sun/star/embed/EmbedStates.hpp>
      30                 :            : #include <com/sun/star/lang/DisposedException.hpp>
      31                 :            : 
      32                 :            : #include "commonembobj.hxx"
      33                 :            : 
      34                 :            : 
      35                 :            : using namespace ::com::sun::star;
      36                 :            : 
      37                 :            : awt::Rectangle GetRectangleInterception( const awt::Rectangle& aRect1, const awt::Rectangle& aRect2 );
      38                 :          6 : sal_Bool RectanglesEqual( const awt::Rectangle& aRect1, const awt::Rectangle& aRect2 )
      39                 :            : {
      40                 :            :     return ( aRect1.X == aRect2.X
      41                 :            :             && aRect1.Y == aRect2.Y
      42                 :            :             && aRect1.Width == aRect2.Width
      43 [ +  + ][ +  - ]:          6 :             && aRect1.Height == aRect2.Height );
         [ +  - ][ +  - ]
      44                 :            : }
      45                 :            : 
      46                 :          4 : void SAL_CALL OCommonEmbeddedObject::setObjectRectangles( const awt::Rectangle& aPosRect,
      47                 :            :                                                            const awt::Rectangle& aClipRect )
      48                 :            :         throw ( embed::WrongStateException,
      49                 :            :                 uno::Exception,
      50                 :            :                 uno::RuntimeException )
      51                 :            : {
      52         [ +  - ]:          4 :     ::osl::MutexGuard aGuard( m_aMutex );
      53         [ -  + ]:          4 :     if ( m_bDisposed )
      54         [ #  # ]:          0 :         throw lang::DisposedException(); // TODO
      55                 :            : 
      56 [ +  + ][ -  + ]:          4 :     if ( m_nObjectState != embed::EmbedStates::INPLACE_ACTIVE
      57                 :            :       && m_nObjectState != embed::EmbedStates::UI_ACTIVE )
      58                 :            :         throw embed::WrongStateException( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "The object is not activated inplace!\n" )),
      59 [ #  # ][ #  # ]:          0 :                                     uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
                 [ #  # ]
      60                 :            : 
      61         [ +  - ]:          4 :     awt::Rectangle aNewRectToShow = GetRectangleInterception( aPosRect, aClipRect );
      62         [ +  - ]:          4 :     awt::Rectangle aOldRectToShow = GetRectangleInterception( m_aOwnRectangle, m_aClipRectangle );
      63                 :            : 
      64                 :            :     // the clip rectangle changes view only in case interception is also changed
      65   [ +  +  -  +  :          6 :     if ( !RectanglesEqual( m_aOwnRectangle, aPosRect )
           #  # ][ +  + ]
      66                 :          2 :       || ( !RectanglesEqual( m_aClipRectangle, aPosRect ) && !RectanglesEqual( aOldRectToShow, aNewRectToShow ) ) )
      67         [ +  - ]:          2 :         m_pDocHolder->PlaceFrame( aNewRectToShow );
      68                 :            : 
      69                 :          4 :     m_aOwnRectangle = aPosRect;
      70         [ +  - ]:          4 :     m_aClipRectangle = aClipRect;
      71                 :          4 : }
      72                 :            : 
      73                 :          0 : void SAL_CALL OCommonEmbeddedObject::enableModeless( sal_Bool /*bEnable*/ )
      74                 :            :         throw ( embed::WrongStateException,
      75                 :            :                 uno::Exception,
      76                 :            :                 uno::RuntimeException )
      77                 :            : {
      78                 :            :     // TODO: notify model that it can not use modal dialogs
      79                 :          0 : }
      80                 :            : 
      81                 :          0 : void SAL_CALL OCommonEmbeddedObject::translateAccelerators(
      82                 :            :                     const uno::Sequence< awt::KeyEvent >& /*aKeys*/ )
      83                 :            :         throw ( embed::WrongStateException,
      84                 :            :                 uno::RuntimeException )
      85                 :            : {
      86                 :            :     // TODO: UI activation related
      87                 :          0 : }
      88                 :            : 
      89                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10