build fix
[LibreOffice.git] / slideshow / source / engine / shapes / externalshapebase.cxx
blob40c0d99b2df056aece7b9c055ba182fdc4a550c9
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 OSL_FAIL( OUStringToOString(
111 comphelper::anyToString(
112 cppu::getCaughtException() ),
113 RTL_TEXTENCODING_UTF8 ).getStr() );
118 uno::Reference< drawing::XShape > ExternalShapeBase::getXShape() const
120 return mxShape;
124 void ExternalShapeBase::play()
126 implStartIntrinsicAnimation();
130 void ExternalShapeBase::stop()
132 implEndIntrinsicAnimation();
136 void ExternalShapeBase::pause()
138 implPauseIntrinsicAnimation();
142 bool ExternalShapeBase::isPlaying() const
144 return implIsIntrinsicAnimationPlaying();
148 void ExternalShapeBase::setMediaTime(double fTime)
150 implSetIntrinsicAnimationTime(fTime);
154 bool ExternalShapeBase::update() const
156 return render();
160 bool ExternalShapeBase::render() const
162 if( maBounds.getRange().equalZero() )
164 // zero-sized shapes are effectively invisible,
165 // thus, we save us the rendering...
166 return true;
169 return implRender( maBounds );
173 bool ExternalShapeBase::isContentChanged() const
175 return true;
179 ::basegfx::B2DRectangle ExternalShapeBase::getBounds() const
181 return maBounds;
185 ::basegfx::B2DRectangle ExternalShapeBase::getDomBounds() const
187 return maBounds;
191 ::basegfx::B2DRectangle ExternalShapeBase::getUpdateArea() const
193 return maBounds;
197 bool ExternalShapeBase::isVisible() const
199 return true;
203 double ExternalShapeBase::getPriority() const
205 return mnPriority;
209 bool ExternalShapeBase::isBackgroundDetached() const
211 // external shapes always have their own window/surface
212 return true;
218 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */