LibreOffice Module embeddedobj (master) 1
inplaceobj.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <com/sun/star/embed/EmbedStates.hpp>
21#include <com/sun/star/embed/WrongStateException.hpp>
22#include <com/sun/star/lang/DisposedException.hpp>
23
24#include <commonembobj.hxx>
25#include "embedobj.hxx"
26
27
28using namespace ::com::sun::star;
29
30static bool RectanglesEqual( const awt::Rectangle& aRect1, const awt::Rectangle& aRect2 )
31{
32 return ( aRect1.X == aRect2.X
33 && aRect1.Y == aRect2.Y
34 && aRect1.Width == aRect2.Width
35 && aRect1.Height == aRect2.Height );
36}
37
38void SAL_CALL OCommonEmbeddedObject::setObjectRectangles( const awt::Rectangle& aPosRect,
39 const awt::Rectangle& aClipRect )
40{
41 ::osl::MutexGuard aGuard( m_aMutex );
42 if ( m_bDisposed )
43 throw lang::DisposedException(); // TODO
44
45 if ( m_nObjectState != embed::EmbedStates::INPLACE_ACTIVE
46 && m_nObjectState != embed::EmbedStates::UI_ACTIVE )
47 throw embed::WrongStateException( "The object is not activated inplace!",
48 static_cast< ::cppu::OWeakObject* >(this) );
49
50 awt::Rectangle aNewRectToShow = GetRectangleInterception( aPosRect, aClipRect );
51 awt::Rectangle aOldRectToShow = GetRectangleInterception( m_aOwnRectangle, m_aClipRectangle );
52
53 // the clip rectangle changes view only in case interception is also changed
54 if ( !RectanglesEqual( m_aOwnRectangle, aPosRect )
55 || ( !RectanglesEqual( m_aClipRectangle, aPosRect ) && !RectanglesEqual( aOldRectToShow, aNewRectToShow ) ) )
56 m_xDocHolder->PlaceFrame( aNewRectToShow );
57
58 m_aOwnRectangle = aPosRect;
59 m_aClipRectangle = aClipRect;
60}
61
63{
64 // TODO: notify model that it can not use modal dialogs
65}
66
68 const uno::Sequence< awt::KeyEvent >& /*aKeys*/ )
69{
70 // TODO: UI activation related
71}
72
73/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void SAL_CALL setObjectRectangles(const css::awt::Rectangle &aPosRect, const css::awt::Rectangle &aClipRect) override
Definition: inplaceobj.cxx:38
css::awt::Rectangle m_aClipRectangle
css::awt::Rectangle m_aOwnRectangle
rtl::Reference< DocumentHolder > m_xDocHolder
virtual void SAL_CALL translateAccelerators(const css::uno::Sequence< css::awt::KeyEvent > &aKeys) override
Definition: inplaceobj.cxx:67
virtual void SAL_CALL enableModeless(sal_Bool bEnable) override
Definition: inplaceobj.cxx:62
awt::Rectangle GetRectangleInterception(const awt::Rectangle &aRect1, const awt::Rectangle &aRect2)
Definition: embedobj.cxx:55
static bool RectanglesEqual(const awt::Rectangle &aRect1, const awt::Rectangle &aRect2)
Definition: inplaceobj.cxx:30
unsigned char sal_Bool