1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: externalshapebase.cxx,v $
10 * $Revision: 1.4.2.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_slideshow.hxx"
35 #include <canvas/debug.hxx>
36 #include <tools/diagnose_ex.h>
37 #include <canvas/verbosetrace.hxx>
39 #include <comphelper/anytostring.hxx>
40 #include <cppuhelper/exc_hlp.hxx>
42 #include "externalshapebase.hxx"
43 #include "eventmultiplexer.hxx"
44 #include "vieweventhandler.hxx"
45 #include "intrinsicanimationeventhandler.hxx"
48 #include <boost/noncopyable.hpp>
51 using namespace ::com::sun::star
;
58 class ExternalShapeBase::ExternalShapeBaseListener
: public ViewEventHandler
,
59 public IntrinsicAnimationEventHandler
,
60 private boost::noncopyable
63 explicit ExternalShapeBaseListener( ExternalShapeBase
& rBase
) :
70 // -------------------------------------------------
72 virtual void viewAdded( const UnoViewSharedPtr
& ) {}
73 virtual void viewRemoved( const UnoViewSharedPtr
& ) {}
74 virtual void viewChanged( const UnoViewSharedPtr
& rView
)
76 mrBase
.implViewChanged(rView
);
78 virtual void viewsChanged()
80 mrBase
.implViewsChanged();
84 // IntrinsicAnimationEventHandler
85 // -------------------------------------------------
87 virtual bool enableAnimations()
89 return mrBase
.implStartIntrinsicAnimation();
91 virtual bool disableAnimations()
93 return mrBase
.implEndIntrinsicAnimation();
96 ExternalShapeBase
& mrBase
;
100 ExternalShapeBase::ExternalShapeBase( const uno::Reference
< drawing::XShape
>& xShape
,
102 const SlideShowContext
& rContext
) :
103 mxComponentContext( rContext
.mxComponentContext
),
105 mpListener( new ExternalShapeBaseListener(*this) ),
106 mpShapeManager( rContext
.mpSubsettableShapeManager
),
107 mrEventMultiplexer( rContext
.mrEventMultiplexer
),
108 mnPriority( nPrio
), // TODO(F1): When ZOrder someday becomes usable: make this ( getAPIShapePrio( xShape ) ),
109 maBounds( getAPIShapeBounds( xShape
) )
111 ENSURE_OR_THROW( mxShape
.is(), "ExternalShapeBase::ExternalShapeBase(): Invalid XShape" );
113 mpShapeManager
->addIntrinsicAnimationHandler( mpListener
);
114 mrEventMultiplexer
.addViewHandler( mpListener
);
117 // ---------------------------------------------------------------------
119 ExternalShapeBase::~ExternalShapeBase()
123 mrEventMultiplexer
.removeViewHandler( mpListener
);
124 mpShapeManager
->removeIntrinsicAnimationHandler( mpListener
);
126 catch (uno::Exception
&)
128 OSL_ENSURE( false, rtl::OUStringToOString(
129 comphelper::anyToString(
130 cppu::getCaughtException() ),
131 RTL_TEXTENCODING_UTF8
).getStr() );
135 // ---------------------------------------------------------------------
137 uno::Reference
< drawing::XShape
> ExternalShapeBase::getXShape() const
142 // ---------------------------------------------------------------------
144 void ExternalShapeBase::play()
146 implStartIntrinsicAnimation();
149 // ---------------------------------------------------------------------
151 void ExternalShapeBase::stop()
153 implEndIntrinsicAnimation();
156 // ---------------------------------------------------------------------
158 void ExternalShapeBase::pause()
160 implPauseIntrinsicAnimation();
163 // ---------------------------------------------------------------------
165 bool ExternalShapeBase::isPlaying() const
167 return implIsIntrinsicAnimationPlaying();
170 // ---------------------------------------------------------------------
172 void ExternalShapeBase::setMediaTime(double fTime
)
174 implSetIntrinsicAnimationTime(fTime
);
177 // ---------------------------------------------------------------------
179 bool ExternalShapeBase::update() const
184 // ---------------------------------------------------------------------
186 bool ExternalShapeBase::render() const
188 if( maBounds
.getRange().equalZero() )
190 // zero-sized shapes are effectively invisible,
191 // thus, we save us the rendering...
195 return implRender( maBounds
);
198 // ---------------------------------------------------------------------
200 bool ExternalShapeBase::isContentChanged() const
205 // ---------------------------------------------------------------------
207 ::basegfx::B2DRectangle
ExternalShapeBase::getBounds() const
212 // ---------------------------------------------------------------------
214 ::basegfx::B2DRectangle
ExternalShapeBase::getDomBounds() const
219 // ---------------------------------------------------------------------
221 ::basegfx::B2DRectangle
ExternalShapeBase::getUpdateArea() const
226 // ---------------------------------------------------------------------
228 bool ExternalShapeBase::isVisible() const
233 // ---------------------------------------------------------------------
235 double ExternalShapeBase::getPriority() const
240 // ---------------------------------------------------------------------
242 bool ExternalShapeBase::isBackgroundDetached() const
244 // external shapes always have their own window/surface