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 throw ( embed::WrongStateException,
46 uno::Exception,
47 uno::RuntimeException )
48 {
49 ::osl::MutexGuard aGuard( m_aMutex );
50 if ( m_bDisposed )
51 throw lang::DisposedException(); // TODO
52
53 if ( m_nObjectState != embed::EmbedStates::INPLACE_ACTIVE
54 && m_nObjectState != embed::EmbedStates::UI_ACTIVE )
55 throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "The object is not activated inplace!\n" ),
56 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
57
58 awt::Rectangle aNewRectToShow = GetRectangleInterception( aPosRect, aClipRect );
59 awt::Rectangle aOldRectToShow = GetRectangleInterception( m_aOwnRectangle, m_aClipRectangle );
60
61 // the clip rectangle changes view only in case interception is also changed
62 if ( !RectanglesEqual( m_aOwnRectangle, aPosRect )
63 || ( !RectanglesEqual( m_aClipRectangle, aPosRect ) && !RectanglesEqual( aOldRectToShow, aNewRectToShow ) ) )
64 m_pDocHolder->PlaceFrame( aNewRectToShow );
65
66 m_aOwnRectangle = aPosRect;
67 m_aClipRectangle = aClipRect;
68 }
69
enableModeless(sal_Bool)70 void SAL_CALL OCommonEmbeddedObject::enableModeless( sal_Bool /*bEnable*/ )
71 throw ( embed::WrongStateException,
72 uno::Exception,
73 uno::RuntimeException )
74 {
75 // TODO: notify model that it can not use modal dialogs
76 }
77
translateAccelerators(const uno::Sequence<awt::KeyEvent> &)78 void SAL_CALL OCommonEmbeddedObject::translateAccelerators(
79 const uno::Sequence< awt::KeyEvent >& /*aKeys*/ )
80 throw ( embed::WrongStateException,
81 uno::RuntimeException )
82 {
83 // TODO: UI activation related
84 }
85
86