Bump version to 6.0-36
[LibreOffice.git] / slideshow / source / engine / shapes / externalshapebase.cxx
blob148ed3a6de39968e237fdaae9860f767b899dcda
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>
24 #include <comphelper/anytostring.hxx>
25 #include <cppuhelper/exc_hlp.hxx>
27 #include "externalshapebase.hxx"
28 #include <eventmultiplexer.hxx>
29 #include <vieweventhandler.hxx>
30 #include <intrinsicanimationeventhandler.hxx>
31 #include <tools.hxx>
34 using namespace ::com::sun::star;
37 namespace slideshow
39 namespace internal
41 class ExternalShapeBase::ExternalShapeBaseListener : public ViewEventHandler,
42 public IntrinsicAnimationEventHandler
44 public:
45 explicit ExternalShapeBaseListener( ExternalShapeBase& rBase ) :
46 mrBase( rBase )
48 ExternalShapeBaseListener(const ExternalShapeBaseListener&) = delete;
49 ExternalShapeBaseListener& operator=(const ExternalShapeBaseListener&) = delete;
51 private:
52 // ViewEventHandler
55 virtual void viewAdded( const UnoViewSharedPtr& ) override {}
56 virtual void viewRemoved( const UnoViewSharedPtr& ) override {}
57 virtual void viewChanged( const UnoViewSharedPtr& rView ) override
59 mrBase.implViewChanged(rView);
61 virtual void viewsChanged() override
63 mrBase.implViewsChanged();
67 // IntrinsicAnimationEventHandler
70 virtual bool enableAnimations() override
72 return mrBase.implStartIntrinsicAnimation();
74 virtual bool disableAnimations() override
76 return mrBase.implEndIntrinsicAnimation();
79 ExternalShapeBase& mrBase;
83 ExternalShapeBase::ExternalShapeBase( const uno::Reference< drawing::XShape >& xShape,
84 double nPrio,
85 const SlideShowContext& rContext ) :
86 mxComponentContext( rContext.mxComponentContext ),
87 mxShape( xShape ),
88 mpListener( new ExternalShapeBaseListener(*this) ),
89 mpShapeManager( rContext.mpSubsettableShapeManager ),
90 mrEventMultiplexer( rContext.mrEventMultiplexer ),
91 mnPriority( nPrio ), // TODO(F1): When ZOrder someday becomes usable: make this ( getAPIShapePrio( xShape ) ),
92 maBounds( getAPIShapeBounds( xShape ) )
94 ENSURE_OR_THROW( mxShape.is(), "ExternalShapeBase::ExternalShapeBase(): Invalid XShape" );
96 mpShapeManager->addIntrinsicAnimationHandler( mpListener );
97 mrEventMultiplexer.addViewHandler( mpListener );
101 ExternalShapeBase::~ExternalShapeBase()
105 mrEventMultiplexer.removeViewHandler( mpListener );
106 mpShapeManager->removeIntrinsicAnimationHandler( mpListener );
108 catch (uno::Exception &)
110 SAL_WARN( "slideshow", comphelper::anyToString( cppu::getCaughtException() ) );
115 uno::Reference< drawing::XShape > ExternalShapeBase::getXShape() const
117 return mxShape;
121 void ExternalShapeBase::play()
123 implStartIntrinsicAnimation();
127 void ExternalShapeBase::stop()
129 implEndIntrinsicAnimation();
133 void ExternalShapeBase::pause()
135 implPauseIntrinsicAnimation();
139 bool ExternalShapeBase::isPlaying() const
141 return implIsIntrinsicAnimationPlaying();
145 void ExternalShapeBase::setMediaTime(double fTime)
147 implSetIntrinsicAnimationTime(fTime);
151 bool ExternalShapeBase::update() const
153 return render();
157 bool ExternalShapeBase::render() const
159 if( maBounds.getRange().equalZero() )
161 // zero-sized shapes are effectively invisible,
162 // thus, we save us the rendering...
163 return true;
166 return implRender( maBounds );
170 bool ExternalShapeBase::isContentChanged() const
172 return true;
176 ::basegfx::B2DRectangle ExternalShapeBase::getBounds() const
178 return maBounds;
182 ::basegfx::B2DRectangle ExternalShapeBase::getDomBounds() const
184 return maBounds;
188 ::basegfx::B2DRectangle ExternalShapeBase::getUpdateArea() const
190 return maBounds;
194 bool ExternalShapeBase::isVisible() const
196 return true;
200 double ExternalShapeBase::getPriority() const
202 return mnPriority;
206 bool ExternalShapeBase::isBackgroundDetached() const
208 // external shapes always have their own window/surface
209 return true;
215 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */