Version 3.6.0.2, tag libreoffice-3.6.0.2
[LibreOffice.git] / embeddedobj / source / commonembedding / inplaceobj.cxx
blob5d8fe330065607804daf538e7a574c787d3185c1
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
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.
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).
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.
27 ************************************************************************/
29 #include <com/sun/star/embed/EmbedStates.hpp>
30 #include <com/sun/star/lang/DisposedException.hpp>
32 #include "commonembobj.hxx"
35 using namespace ::com::sun::star;
37 awt::Rectangle GetRectangleInterception( const awt::Rectangle& aRect1, const awt::Rectangle& aRect2 );
38 sal_Bool RectanglesEqual( const awt::Rectangle& aRect1, const awt::Rectangle& aRect2 )
40 return ( aRect1.X == aRect2.X
41 && aRect1.Y == aRect2.Y
42 && aRect1.Width == aRect2.Width
43 && aRect1.Height == aRect2.Height );
46 void SAL_CALL OCommonEmbeddedObject::setObjectRectangles( const awt::Rectangle& aPosRect,
47 const awt::Rectangle& aClipRect )
48 throw ( embed::WrongStateException,
49 uno::Exception,
50 uno::RuntimeException )
52 ::osl::MutexGuard aGuard( m_aMutex );
53 if ( m_bDisposed )
54 throw lang::DisposedException(); // TODO
56 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 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
61 awt::Rectangle aNewRectToShow = GetRectangleInterception( aPosRect, aClipRect );
62 awt::Rectangle aOldRectToShow = GetRectangleInterception( m_aOwnRectangle, m_aClipRectangle );
64 // the clip rectangle changes view only in case interception is also changed
65 if ( !RectanglesEqual( m_aOwnRectangle, aPosRect )
66 || ( !RectanglesEqual( m_aClipRectangle, aPosRect ) && !RectanglesEqual( aOldRectToShow, aNewRectToShow ) ) )
67 m_pDocHolder->PlaceFrame( aNewRectToShow );
69 m_aOwnRectangle = aPosRect;
70 m_aClipRectangle = aClipRect;
73 void SAL_CALL OCommonEmbeddedObject::enableModeless( sal_Bool /*bEnable*/ )
74 throw ( embed::WrongStateException,
75 uno::Exception,
76 uno::RuntimeException )
78 // TODO: notify model that it can not use modal dialogs
81 void SAL_CALL OCommonEmbeddedObject::translateAccelerators(
82 const uno::Sequence< awt::KeyEvent >& /*aKeys*/ )
83 throw ( embed::WrongStateException,
84 uno::RuntimeException )
86 // TODO: UI activation related
89 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */