LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/embeddedobj/source/commonembedding - inplaceobj.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 18 24 75.0 %
Date: 2013-07-09 Functions: 2 4 50.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 <com/sun/star/embed/EmbedStates.hpp>
      21             : #include <com/sun/star/lang/DisposedException.hpp>
      22             : 
      23             : #include "commonembobj.hxx"
      24             : 
      25             : 
      26             : using namespace ::com::sun::star;
      27             : 
      28             : awt::Rectangle GetRectangleInterception( const awt::Rectangle& aRect1, const awt::Rectangle& aRect2 );
      29           4 : sal_Bool RectanglesEqual( const awt::Rectangle& aRect1, const awt::Rectangle& aRect2 )
      30             : {
      31           4 :     return ( aRect1.X == aRect2.X
      32           3 :             && aRect1.Y == aRect2.Y
      33           2 :             && aRect1.Width == aRect2.Width
      34           6 :             && aRect1.Height == aRect2.Height );
      35             : }
      36             : 
      37           3 : void SAL_CALL OCommonEmbeddedObject::setObjectRectangles( const awt::Rectangle& aPosRect,
      38             :                                                            const awt::Rectangle& aClipRect )
      39             :         throw ( embed::WrongStateException,
      40             :                 uno::Exception,
      41             :                 uno::RuntimeException )
      42             : {
      43           3 :     ::osl::MutexGuard aGuard( m_aMutex );
      44           3 :     if ( m_bDisposed )
      45           0 :         throw lang::DisposedException(); // TODO
      46             : 
      47           3 :     if ( m_nObjectState != embed::EmbedStates::INPLACE_ACTIVE
      48           2 :       && m_nObjectState != embed::EmbedStates::UI_ACTIVE )
      49             :         throw embed::WrongStateException( OUString( "The object is not activated inplace!\n" ),
      50           0 :                                     uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
      51             : 
      52           3 :     awt::Rectangle aNewRectToShow = GetRectangleInterception( aPosRect, aClipRect );
      53           3 :     awt::Rectangle aOldRectToShow = GetRectangleInterception( m_aOwnRectangle, m_aClipRectangle );
      54             : 
      55             :     // the clip rectangle changes view only in case interception is also changed
      56           6 :     if ( !RectanglesEqual( m_aOwnRectangle, aPosRect )
      57           3 :       || ( !RectanglesEqual( m_aClipRectangle, aPosRect ) && !RectanglesEqual( aOldRectToShow, aNewRectToShow ) ) )
      58           2 :         m_pDocHolder->PlaceFrame( aNewRectToShow );
      59             : 
      60           3 :     m_aOwnRectangle = aPosRect;
      61           3 :     m_aClipRectangle = aClipRect;
      62           3 : }
      63             : 
      64           0 : void SAL_CALL OCommonEmbeddedObject::enableModeless( sal_Bool /*bEnable*/ )
      65             :         throw ( embed::WrongStateException,
      66             :                 uno::Exception,
      67             :                 uno::RuntimeException )
      68             : {
      69             :     // TODO: notify model that it can not use modal dialogs
      70           0 : }
      71             : 
      72           0 : void SAL_CALL OCommonEmbeddedObject::translateAccelerators(
      73             :                     const uno::Sequence< awt::KeyEvent >& /*aKeys*/ )
      74             :         throw ( embed::WrongStateException,
      75             :                 uno::RuntimeException )
      76             : {
      77             :     // TODO: UI activation related
      78           0 : }
      79             : 
      80             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10