1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
22 #include <canvas/debug.hxx>
23 #include <tools/diagnose_ex.h>
24 #include <canvas/verbosetrace.hxx>
26 #include <comphelper/anytostring.hxx>
27 #include <cppuhelper/exc_hlp.hxx>
29 #include "externalshapebase.hxx"
30 #include "eventmultiplexer.hxx"
31 #include "vieweventhandler.hxx"
32 #include "intrinsicanimationeventhandler.hxx"
35 #include <boost/noncopyable.hpp>
38 using namespace ::com::sun::star
;
45 class ExternalShapeBase::ExternalShapeBaseListener
: public ViewEventHandler
,
46 public IntrinsicAnimationEventHandler
,
47 private boost::noncopyable
50 explicit ExternalShapeBaseListener( ExternalShapeBase
& rBase
) :
59 virtual void viewAdded( const UnoViewSharedPtr
& ) SAL_OVERRIDE
{}
60 virtual void viewRemoved( const UnoViewSharedPtr
& ) SAL_OVERRIDE
{}
61 virtual void viewChanged( const UnoViewSharedPtr
& rView
) SAL_OVERRIDE
63 mrBase
.implViewChanged(rView
);
65 virtual void viewsChanged() SAL_OVERRIDE
67 mrBase
.implViewsChanged();
71 // IntrinsicAnimationEventHandler
74 virtual bool enableAnimations() SAL_OVERRIDE
76 return mrBase
.implStartIntrinsicAnimation();
78 virtual bool disableAnimations() SAL_OVERRIDE
80 return mrBase
.implEndIntrinsicAnimation();
83 ExternalShapeBase
& mrBase
;
87 ExternalShapeBase::ExternalShapeBase( const uno::Reference
< drawing::XShape
>& xShape
,
89 const SlideShowContext
& rContext
) :
90 mxComponentContext( rContext
.mxComponentContext
),
92 mpListener( new ExternalShapeBaseListener(*this) ),
93 mpShapeManager( rContext
.mpSubsettableShapeManager
),
94 mrEventMultiplexer( rContext
.mrEventMultiplexer
),
95 mnPriority( nPrio
), // TODO(F1): When ZOrder someday becomes usable: make this ( getAPIShapePrio( xShape ) ),
96 maBounds( getAPIShapeBounds( xShape
) )
98 ENSURE_OR_THROW( mxShape
.is(), "ExternalShapeBase::ExternalShapeBase(): Invalid XShape" );
100 mpShapeManager
->addIntrinsicAnimationHandler( mpListener
);
101 mrEventMultiplexer
.addViewHandler( mpListener
);
106 ExternalShapeBase::~ExternalShapeBase()
110 mrEventMultiplexer
.removeViewHandler( mpListener
);
111 mpShapeManager
->removeIntrinsicAnimationHandler( mpListener
);
113 catch (uno::Exception
&)
115 OSL_FAIL( OUStringToOString(
116 comphelper::anyToString(
117 cppu::getCaughtException() ),
118 RTL_TEXTENCODING_UTF8
).getStr() );
124 uno::Reference
< drawing::XShape
> ExternalShapeBase::getXShape() const
131 void ExternalShapeBase::play()
133 implStartIntrinsicAnimation();
138 void ExternalShapeBase::stop()
140 implEndIntrinsicAnimation();
145 void ExternalShapeBase::pause()
147 implPauseIntrinsicAnimation();
152 bool ExternalShapeBase::isPlaying() const
154 return implIsIntrinsicAnimationPlaying();
159 void ExternalShapeBase::setMediaTime(double fTime
)
161 implSetIntrinsicAnimationTime(fTime
);
166 bool ExternalShapeBase::update() const
173 bool ExternalShapeBase::render() const
175 if( maBounds
.getRange().equalZero() )
177 // zero-sized shapes are effectively invisible,
178 // thus, we save us the rendering...
182 return implRender( maBounds
);
187 bool ExternalShapeBase::isContentChanged() const
194 ::basegfx::B2DRectangle
ExternalShapeBase::getBounds() const
201 ::basegfx::B2DRectangle
ExternalShapeBase::getDomBounds() const
208 ::basegfx::B2DRectangle
ExternalShapeBase::getUpdateArea() const
215 bool ExternalShapeBase::isVisible() const
222 double ExternalShapeBase::getPriority() const
229 bool ExternalShapeBase::isBackgroundDetached() const
231 // external shapes always have their own window/surface
238 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */