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