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>
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>
34 using namespace ::com::sun::star
;
41 class ExternalShapeBase::ExternalShapeBaseListener
: public ViewEventHandler
,
42 public IntrinsicAnimationEventHandler
45 explicit ExternalShapeBaseListener( ExternalShapeBase
& rBase
) :
48 ExternalShapeBaseListener(const ExternalShapeBaseListener
&) = delete;
49 ExternalShapeBaseListener
& operator=(const ExternalShapeBaseListener
&) = delete;
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
,
85 const SlideShowContext
& rContext
) :
86 mxComponentContext( rContext
.mxComponentContext
),
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
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
157 bool ExternalShapeBase::render() const
159 if( maBounds
.getRange().equalZero() )
161 // zero-sized shapes are effectively invisible,
162 // thus, we save us the rendering...
166 return implRender( maBounds
);
170 bool ExternalShapeBase::isContentChanged() const
176 ::basegfx::B2DRectangle
ExternalShapeBase::getBounds() const
182 ::basegfx::B2DRectangle
ExternalShapeBase::getDomBounds() const
188 ::basegfx::B2DRectangle
ExternalShapeBase::getUpdateArea() const
194 bool ExternalShapeBase::isVisible() const
200 double ExternalShapeBase::getPriority() const
206 bool ExternalShapeBase::isBackgroundDetached() const
208 // external shapes always have their own window/surface
215 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */