Bump version to 6.4-15
[LibreOffice.git] / slideshow / source / engine / shapes / externalshapebase.cxx
blob6e557bb456de3f76ba0ffee59ebdd4dd5306d62b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
21 // must be first
22 #include <tools/diagnose_ex.h>
23 #include <sal/log.hxx>
25 #include <comphelper/anytostring.hxx>
26 #include <cppuhelper/exc_hlp.hxx>
28 #include "externalshapebase.hxx"
29 #include <eventmultiplexer.hxx>
30 #include <vieweventhandler.hxx>
31 #include <intrinsicanimationeventhandler.hxx>
32 #include <tools.hxx>
35 using namespace ::com::sun::star;
38 namespace slideshow
40 namespace internal
42 class ExternalShapeBase::ExternalShapeBaseListener : public ViewEventHandler,
43 public IntrinsicAnimationEventHandler
45 public:
46 explicit ExternalShapeBaseListener( ExternalShapeBase& rBase ) :
47 mrBase( rBase )
49 ExternalShapeBaseListener(const ExternalShapeBaseListener&) = delete;
50 ExternalShapeBaseListener& operator=(const ExternalShapeBaseListener&) = delete;
52 private:
53 // ViewEventHandler
56 virtual void viewAdded( const UnoViewSharedPtr& ) override {}
57 virtual void viewRemoved( const UnoViewSharedPtr& ) override {}
58 virtual void viewChanged( const UnoViewSharedPtr& rView ) override
60 mrBase.implViewChanged(rView);
62 virtual void viewsChanged() override
64 mrBase.implViewsChanged();
68 // IntrinsicAnimationEventHandler
71 virtual bool enableAnimations() override
73 return mrBase.implStartIntrinsicAnimation();
75 virtual bool disableAnimations() override
77 return mrBase.implEndIntrinsicAnimation();
80 ExternalShapeBase& mrBase;
84 ExternalShapeBase::ExternalShapeBase( const uno::Reference< drawing::XShape >& xShape,
85 double nPrio,
86 const SlideShowContext& rContext ) :
87 mxComponentContext( rContext.mxComponentContext ),
88 mxShape( xShape ),
89 mpListener( new ExternalShapeBaseListener(*this) ),
90 mpShapeManager( rContext.mpSubsettableShapeManager ),
91 mrEventMultiplexer( rContext.mrEventMultiplexer ),
92 mnPriority( nPrio ), // TODO(F1): When ZOrder someday becomes usable: make this ( getAPIShapePrio( xShape ) ),
93 maBounds( getAPIShapeBounds( xShape ) )
95 ENSURE_OR_THROW( mxShape.is(), "ExternalShapeBase::ExternalShapeBase(): Invalid XShape" );
97 mpShapeManager->addIntrinsicAnimationHandler( mpListener );
98 mrEventMultiplexer.addViewHandler( mpListener );
102 ExternalShapeBase::~ExternalShapeBase()
106 mrEventMultiplexer.removeViewHandler( mpListener );
107 mpShapeManager->removeIntrinsicAnimationHandler( mpListener );
109 catch (uno::Exception &)
111 TOOLS_WARN_EXCEPTION( "slideshow", "" );
116 uno::Reference< drawing::XShape > ExternalShapeBase::getXShape() const
118 return mxShape;
122 void ExternalShapeBase::play()
124 implStartIntrinsicAnimation();
128 void ExternalShapeBase::stop()
130 implEndIntrinsicAnimation();
134 void ExternalShapeBase::pause()
136 implPauseIntrinsicAnimation();
140 bool ExternalShapeBase::isPlaying() const
142 return implIsIntrinsicAnimationPlaying();
146 void ExternalShapeBase::setMediaTime(double fTime)
148 implSetIntrinsicAnimationTime(fTime);
152 bool ExternalShapeBase::update() const
154 return render();
158 bool ExternalShapeBase::render() const
160 if( maBounds.getRange().equalZero() )
162 // zero-sized shapes are effectively invisible,
163 // thus, we save us the rendering...
164 return true;
167 return implRender( maBounds );
171 bool ExternalShapeBase::isContentChanged() const
173 return true;
177 ::basegfx::B2DRectangle ExternalShapeBase::getBounds() const
179 return maBounds;
183 ::basegfx::B2DRectangle ExternalShapeBase::getDomBounds() const
185 return maBounds;
189 ::basegfx::B2DRectangle ExternalShapeBase::getUpdateArea() const
191 return maBounds;
195 bool ExternalShapeBase::isVisible() const
197 return true;
201 double ExternalShapeBase::getPriority() const
203 return mnPriority;
207 bool ExternalShapeBase::isBackgroundDetached() const
209 // external shapes always have their own window/surface
210 return true;
216 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */