1*bfd08df8SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*bfd08df8SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*bfd08df8SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*bfd08df8SAndrew Rist * distributed with this work for additional information
6*bfd08df8SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*bfd08df8SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*bfd08df8SAndrew Rist * "License"); you may not use this file except in compliance
9*bfd08df8SAndrew Rist * with the License. You may obtain a copy of the License at
10*bfd08df8SAndrew Rist *
11*bfd08df8SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*bfd08df8SAndrew Rist *
13*bfd08df8SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*bfd08df8SAndrew Rist * software distributed under the License is distributed on an
15*bfd08df8SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*bfd08df8SAndrew Rist * KIND, either express or implied. See the License for the
17*bfd08df8SAndrew Rist * specific language governing permissions and limitations
18*bfd08df8SAndrew Rist * under the License.
19*bfd08df8SAndrew Rist *
20*bfd08df8SAndrew Rist *************************************************************/
21*bfd08df8SAndrew Rist
22*bfd08df8SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_embeddedobj.hxx"
26cdf0e10cSrcweir #include <com/sun/star/embed/EmbedStates.hpp>
27cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp>
28cdf0e10cSrcweir
29cdf0e10cSrcweir #include "commonembobj.hxx"
30cdf0e10cSrcweir
31cdf0e10cSrcweir
32cdf0e10cSrcweir using namespace ::com::sun::star;
33cdf0e10cSrcweir
34cdf0e10cSrcweir awt::Rectangle GetRectangleInterception( const awt::Rectangle& aRect1, const awt::Rectangle& aRect2 );
RectanglesEqual(const awt::Rectangle & aRect1,const awt::Rectangle & aRect2)35cdf0e10cSrcweir sal_Bool RectanglesEqual( const awt::Rectangle& aRect1, const awt::Rectangle& aRect2 )
36cdf0e10cSrcweir {
37cdf0e10cSrcweir return ( aRect1.X == aRect2.X
38cdf0e10cSrcweir && aRect1.Y == aRect2.Y
39cdf0e10cSrcweir && aRect1.Width == aRect2.Width
40cdf0e10cSrcweir && aRect1.Height == aRect2.Height );
41cdf0e10cSrcweir }
42cdf0e10cSrcweir
setObjectRectangles(const awt::Rectangle & aPosRect,const awt::Rectangle & aClipRect)43cdf0e10cSrcweir void SAL_CALL OCommonEmbeddedObject::setObjectRectangles( const awt::Rectangle& aPosRect,
44cdf0e10cSrcweir const awt::Rectangle& aClipRect )
45cdf0e10cSrcweir throw ( embed::WrongStateException,
46cdf0e10cSrcweir uno::Exception,
47cdf0e10cSrcweir uno::RuntimeException )
48cdf0e10cSrcweir {
49cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex );
50cdf0e10cSrcweir if ( m_bDisposed )
51cdf0e10cSrcweir throw lang::DisposedException(); // TODO
52cdf0e10cSrcweir
53cdf0e10cSrcweir if ( m_nObjectState != embed::EmbedStates::INPLACE_ACTIVE
54cdf0e10cSrcweir && m_nObjectState != embed::EmbedStates::UI_ACTIVE )
55cdf0e10cSrcweir throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "The object is not activated inplace!\n" ),
56cdf0e10cSrcweir uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
57cdf0e10cSrcweir
58cdf0e10cSrcweir awt::Rectangle aNewRectToShow = GetRectangleInterception( aPosRect, aClipRect );
59cdf0e10cSrcweir awt::Rectangle aOldRectToShow = GetRectangleInterception( m_aOwnRectangle, m_aClipRectangle );
60cdf0e10cSrcweir
61cdf0e10cSrcweir // the clip rectangle changes view only in case interception is also changed
62cdf0e10cSrcweir if ( !RectanglesEqual( m_aOwnRectangle, aPosRect )
63cdf0e10cSrcweir || ( !RectanglesEqual( m_aClipRectangle, aPosRect ) && !RectanglesEqual( aOldRectToShow, aNewRectToShow ) ) )
64cdf0e10cSrcweir m_pDocHolder->PlaceFrame( aNewRectToShow );
65cdf0e10cSrcweir
66cdf0e10cSrcweir m_aOwnRectangle = aPosRect;
67cdf0e10cSrcweir m_aClipRectangle = aClipRect;
68cdf0e10cSrcweir }
69cdf0e10cSrcweir
enableModeless(sal_Bool)70cdf0e10cSrcweir void SAL_CALL OCommonEmbeddedObject::enableModeless( sal_Bool /*bEnable*/ )
71cdf0e10cSrcweir throw ( embed::WrongStateException,
72cdf0e10cSrcweir uno::Exception,
73cdf0e10cSrcweir uno::RuntimeException )
74cdf0e10cSrcweir {
75cdf0e10cSrcweir // TODO: notify model that it can not use modal dialogs
76cdf0e10cSrcweir }
77cdf0e10cSrcweir
translateAccelerators(const uno::Sequence<awt::KeyEvent> &)78cdf0e10cSrcweir void SAL_CALL OCommonEmbeddedObject::translateAccelerators(
79cdf0e10cSrcweir const uno::Sequence< awt::KeyEvent >& /*aKeys*/ )
80cdf0e10cSrcweir throw ( embed::WrongStateException,
81cdf0e10cSrcweir uno::RuntimeException )
82cdf0e10cSrcweir {
83cdf0e10cSrcweir // TODO: UI activation related
84cdf0e10cSrcweir }
85cdf0e10cSrcweir
86