1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: inplaceobj.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_embeddedobj.hxx"
33 #include <com/sun/star/embed/EmbedStates.hpp>
34 #include <com/sun/star/lang/DisposedException.hpp>
36 #include "commonembobj.hxx"
39 using namespace ::com::sun::star
;
41 awt::Rectangle
GetRectangleInterception( const awt::Rectangle
& aRect1
, const awt::Rectangle
& aRect2
);
42 sal_Bool
RectanglesEqual( const awt::Rectangle
& aRect1
, const awt::Rectangle
& aRect2
)
44 return ( aRect1
.X
== aRect2
.X
45 && aRect1
.Y
== aRect2
.Y
46 && aRect1
.Width
== aRect2
.Width
47 && aRect1
.Height
== aRect2
.Height
);
50 void SAL_CALL
OCommonEmbeddedObject::setObjectRectangles( const awt::Rectangle
& aPosRect
,
51 const awt::Rectangle
& aClipRect
)
52 throw ( embed::WrongStateException
,
54 uno::RuntimeException
)
56 ::osl::MutexGuard
aGuard( m_aMutex
);
58 throw lang::DisposedException(); // TODO
60 if ( m_nObjectState
!= embed::EmbedStates::INPLACE_ACTIVE
61 && m_nObjectState
!= embed::EmbedStates::UI_ACTIVE
)
62 throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "The object is not activated inplace!\n" ),
63 uno::Reference
< uno::XInterface
>( static_cast< ::cppu::OWeakObject
* >(this) ) );
65 awt::Rectangle aNewRectToShow
= GetRectangleInterception( aPosRect
, aClipRect
);
66 awt::Rectangle aOldRectToShow
= GetRectangleInterception( m_aOwnRectangle
, m_aClipRectangle
);
68 // the clip rectangle changes view only in case interception is also changed
69 if ( !RectanglesEqual( m_aOwnRectangle
, aPosRect
)
70 || ( !RectanglesEqual( m_aClipRectangle
, aPosRect
) && !RectanglesEqual( aOldRectToShow
, aNewRectToShow
) ) )
71 m_pDocHolder
->PlaceFrame( aNewRectToShow
);
73 m_aOwnRectangle
= aPosRect
;
74 m_aClipRectangle
= aClipRect
;
77 void SAL_CALL
OCommonEmbeddedObject::enableModeless( sal_Bool
/*bEnable*/ )
78 throw ( embed::WrongStateException
,
80 uno::RuntimeException
)
82 // TODO: notify model that it can not use modal dialogs
85 void SAL_CALL
OCommonEmbeddedObject::translateAccelerators(
86 const uno::Sequence
< awt::KeyEvent
>& /*aKeys*/ )
87 throw ( embed::WrongStateException
,
88 uno::RuntimeException
)
90 // TODO: UI activation related