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 <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>
35 using namespace ::com::sun::star
;
42 class ExternalShapeBase::ExternalShapeBaseListener
: public ViewEventHandler
,
43 public IntrinsicAnimationEventHandler
46 explicit ExternalShapeBaseListener( ExternalShapeBase
& rBase
) :
49 ExternalShapeBaseListener(const ExternalShapeBaseListener
&) = delete;
50 ExternalShapeBaseListener
& operator=(const ExternalShapeBaseListener
&) = delete;
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
,
86 const SlideShowContext
& rContext
) :
87 mxComponentContext( rContext
.mxComponentContext
),
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
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
158 bool ExternalShapeBase::render() const
160 if( maBounds
.getRange().equalZero() )
162 // zero-sized shapes are effectively invisible,
163 // thus, we save us the rendering...
167 return implRender( maBounds
);
171 bool ExternalShapeBase::isContentChanged() const
177 ::basegfx::B2DRectangle
ExternalShapeBase::getBounds() const
183 ::basegfx::B2DRectangle
ExternalShapeBase::getDomBounds() const
189 ::basegfx::B2DRectangle
ExternalShapeBase::getUpdateArea() const
195 bool ExternalShapeBase::isVisible() const
201 double ExternalShapeBase::getPriority() const
207 bool ExternalShapeBase::isBackgroundDetached() const
209 // external shapes always have their own window/surface
216 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */