merge the formfield patch from ooo-build
[ooovba.git] / slideshow / source / engine / shapes / externalshapebase.cxx
blob85c5f579db98345bc6aa52e1506885a837b76046
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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"
34 // must be first
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"
46 #include "tools.hxx"
48 #include <boost/noncopyable.hpp>
51 using namespace ::com::sun::star;
54 namespace slideshow
56 namespace internal
58 class ExternalShapeBase::ExternalShapeBaseListener : public ViewEventHandler,
59 public IntrinsicAnimationEventHandler,
60 private boost::noncopyable
62 public:
63 explicit ExternalShapeBaseListener( ExternalShapeBase& rBase ) :
64 mrBase( rBase )
68 private:
69 // ViewEventHandler
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,
101 double nPrio,
102 const SlideShowContext& rContext ) :
103 mxComponentContext( rContext.mxComponentContext ),
104 mxShape( xShape ),
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
139 return mxShape;
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
181 return render();
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...
192 return true;
195 return implRender( maBounds );
198 // ---------------------------------------------------------------------
200 bool ExternalShapeBase::isContentChanged() const
202 return true;
205 // ---------------------------------------------------------------------
207 ::basegfx::B2DRectangle ExternalShapeBase::getBounds() const
209 return maBounds;
212 // ---------------------------------------------------------------------
214 ::basegfx::B2DRectangle ExternalShapeBase::getDomBounds() const
216 return maBounds;
219 // ---------------------------------------------------------------------
221 ::basegfx::B2DRectangle ExternalShapeBase::getUpdateArea() const
223 return maBounds;
226 // ---------------------------------------------------------------------
228 bool ExternalShapeBase::isVisible() const
230 return true;
233 // ---------------------------------------------------------------------
235 double ExternalShapeBase::getPriority() const
237 return mnPriority;
240 // ---------------------------------------------------------------------
242 bool ExternalShapeBase::isBackgroundDetached() const
244 // external shapes always have their own window/surface
245 return true;