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 OSL_FAIL( OUStringToOString(
111 comphelper::anyToString(
112 cppu::getCaughtException() ),
113 RTL_TEXTENCODING_UTF8
).getStr() );
118 uno::Reference
< drawing::XShape
> ExternalShapeBase::getXShape() const
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
160 bool ExternalShapeBase::render() const
162 if( maBounds
.getRange().equalZero() )
164 // zero-sized shapes are effectively invisible,
165 // thus, we save us the rendering...
169 return implRender( maBounds
);
173 bool ExternalShapeBase::isContentChanged() const
179 ::basegfx::B2DRectangle
ExternalShapeBase::getBounds() const
185 ::basegfx::B2DRectangle
ExternalShapeBase::getDomBounds() const
191 ::basegfx::B2DRectangle
ExternalShapeBase::getUpdateArea() const
197 bool ExternalShapeBase::isVisible() const
203 double ExternalShapeBase::getPriority() const
209 bool ExternalShapeBase::isBackgroundDetached() const
211 // external shapes always have their own window/surface
218 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */