1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
22 #include <comphelper/diagnose_ex.hxx>
24 #include "externalshapebase.hxx"
25 #include <eventmultiplexer.hxx>
26 #include <subsettableshapemanager.hxx>
27 #include <vieweventhandler.hxx>
28 #include <intrinsicanimationeventhandler.hxx>
32 using namespace ::com::sun::star
;
35 namespace slideshow::internal
37 class ExternalShapeBase::ExternalShapeBaseListener
: public ViewEventHandler
,
38 public IntrinsicAnimationEventHandler
41 explicit ExternalShapeBaseListener( ExternalShapeBase
& rBase
) :
44 ExternalShapeBaseListener(const ExternalShapeBaseListener
&) = delete;
45 ExternalShapeBaseListener
& operator=(const ExternalShapeBaseListener
&) = delete;
51 virtual void viewAdded( const UnoViewSharedPtr
& ) override
{}
52 virtual void viewRemoved( const UnoViewSharedPtr
& ) override
{}
53 virtual void viewChanged( const UnoViewSharedPtr
& rView
) override
55 mrBase
.implViewChanged(rView
);
57 virtual void viewsChanged() override
59 mrBase
.implViewsChanged();
63 // IntrinsicAnimationEventHandler
66 virtual bool enableAnimations() override
68 return mrBase
.implStartIntrinsicAnimation();
70 virtual bool disableAnimations() override
72 return mrBase
.implEndIntrinsicAnimation();
75 ExternalShapeBase
& mrBase
;
79 ExternalShapeBase::ExternalShapeBase( const uno::Reference
< drawing::XShape
>& xShape
,
81 const SlideShowContext
& rContext
) :
82 mxComponentContext( rContext
.mxComponentContext
),
84 mpListener( std::make_shared
<ExternalShapeBaseListener
>(*this) ),
85 mpShapeManager( rContext
.mpSubsettableShapeManager
),
86 mrEventMultiplexer( rContext
.mrEventMultiplexer
),
87 mnPriority( nPrio
), // TODO(F1): When ZOrder someday becomes usable: make this ( getAPIShapePrio( xShape ) ),
88 maBounds( getAPIShapeBounds( xShape
) )
90 ENSURE_OR_THROW( mxShape
.is(), "ExternalShapeBase::ExternalShapeBase(): Invalid XShape" );
92 mpShapeManager
->addIntrinsicAnimationHandler( mpListener
);
93 mrEventMultiplexer
.addViewHandler( mpListener
);
97 ExternalShapeBase::~ExternalShapeBase()
101 mrEventMultiplexer
.removeViewHandler( mpListener
);
102 mpShapeManager
->removeIntrinsicAnimationHandler( mpListener
);
104 catch (uno::Exception
&)
106 TOOLS_WARN_EXCEPTION( "slideshow", "" );
111 uno::Reference
< drawing::XShape
> ExternalShapeBase::getXShape() const
117 void ExternalShapeBase::play()
119 implStartIntrinsicAnimation();
123 void ExternalShapeBase::stop()
125 implEndIntrinsicAnimation();
129 void ExternalShapeBase::pause()
131 implPauseIntrinsicAnimation();
135 bool ExternalShapeBase::isPlaying() const
137 return implIsIntrinsicAnimationPlaying();
141 void ExternalShapeBase::setMediaTime(double fTime
)
143 implSetIntrinsicAnimationTime(fTime
);
146 void ExternalShapeBase::setLooping(bool bLooping
) { implSetLooping(bLooping
); }
148 bool ExternalShapeBase::update() const
154 bool ExternalShapeBase::render() const
156 if( maBounds
.getRange().equalZero() )
158 // zero-sized shapes are effectively invisible,
159 // thus, we save us the rendering...
163 return implRender( maBounds
);
167 bool ExternalShapeBase::isContentChanged() const
173 ::basegfx::B2DRectangle
ExternalShapeBase::getBounds() const
179 ::basegfx::B2DRectangle
ExternalShapeBase::getDomBounds() const
185 ::basegfx::B2DRectangle
ExternalShapeBase::getUpdateArea() const
191 bool ExternalShapeBase::isVisible() const
197 double ExternalShapeBase::getPriority() const
203 bool ExternalShapeBase::isBackgroundDetached() const
205 // external shapes always have their own window/surface
211 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */