1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: animationcolornode.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_slideshow.hxx"
35 #include <canvas/debug.hxx>
36 #include <canvas/verbosetrace.hxx>
37 #include <com/sun/star/animations/AnimationColorSpace.hpp>
39 #include "coloranimation.hxx"
40 #include "hslcoloranimation.hxx"
41 #include "animationcolornode.hxx"
42 #include "animationfactory.hxx"
43 #include "activitiesfactory.hxx"
45 using namespace com::sun::star
;
51 /** Little wrapper for HSL to RGB mapping.
53 This class implements the HSLColorAnimation interface,
54 internally converting to RGB and forwarding to
57 class HSLWrapper
: public HSLColorAnimation
60 HSLWrapper( const ColorAnimationSharedPtr
& rAnimation
)
61 : mpAnimation( rAnimation
)
65 "HSLWrapper::HSLWrapper(): Invalid color animation delegate" );
68 virtual void prefetch( const AnimatableShapeSharedPtr
&,
69 const ShapeAttributeLayerSharedPtr
& )
72 virtual void start( const AnimatableShapeSharedPtr
& rShape
,
73 const ShapeAttributeLayerSharedPtr
& rAttrLayer
)
75 mpAnimation
->start( rShape
, rAttrLayer
);
83 virtual bool operator()( const HSLColor
& rColor
)
85 return (*mpAnimation
)( RGBColor( rColor
) );
88 virtual HSLColor
getUnderlyingValue() const
90 return HSLColor( mpAnimation
->getUnderlyingValue() );
94 ColorAnimationSharedPtr mpAnimation
;
99 AnimationActivitySharedPtr
AnimationColorNode::createActivity() const
101 ActivitiesFactory::CommonParameters
aParms( fillCommonParameters() );
103 switch( mxColorNode
->getColorInterpolation() )
105 case animations::AnimationColorSpace::RGB
:
106 return ActivitiesFactory::createAnimateActivity(
108 AnimationFactory::createColorPropertyAnimation(
109 mxColorNode
->getAttributeName(),
111 getContext().mpSubsettableShapeManager
,
115 case animations::AnimationColorSpace::HSL
:
116 // Wrap a plain ColorAnimation with the HSL
117 // wrapper, which implements the HSLColorAnimation
118 // interface, and internally converts HSL to RGB color
119 return ActivitiesFactory::createAnimateActivity(
121 HSLColorAnimationSharedPtr(
123 AnimationFactory::createColorPropertyAnimation(
124 mxColorNode
->getAttributeName(),
126 getContext().mpSubsettableShapeManager
,
131 ENSURE_OR_THROW( false, "AnimationColorNode::createColorActivity(): "
132 "Unexpected color space" );
135 return AnimationActivitySharedPtr();
138 } // namespace internal
139 } // namespace slideshow