Update ooo320-m1
[ooovba.git] / slideshow / source / engine / animationnodes / animationcolornode.cxx
blob69138420416c585d63abfd9dbe46ecf8992fc99b
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: animationcolornode.cxx,v $
10 * $Revision: 1.9 $
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"
34 // must be first
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;
47 namespace slideshow {
48 namespace internal {
50 namespace {
51 /** Little wrapper for HSL to RGB mapping.
53 This class implements the HSLColorAnimation interface,
54 internally converting to RGB and forwarding to
55 ColorAnimation.
57 class HSLWrapper : public HSLColorAnimation
59 public:
60 HSLWrapper( const ColorAnimationSharedPtr& rAnimation )
61 : mpAnimation( rAnimation )
63 ENSURE_OR_THROW(
64 mpAnimation,
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 );
78 virtual void end()
80 mpAnimation->end();
83 virtual bool operator()( const HSLColor& rColor )
85 return (*mpAnimation)( RGBColor( rColor ) );
88 virtual HSLColor getUnderlyingValue() const
90 return HSLColor( mpAnimation->getUnderlyingValue() );
93 private:
94 ColorAnimationSharedPtr mpAnimation;
97 } // anon namespace
99 AnimationActivitySharedPtr AnimationColorNode::createActivity() const
101 ActivitiesFactory::CommonParameters aParms( fillCommonParameters() );
103 switch( mxColorNode->getColorInterpolation() )
105 case animations::AnimationColorSpace::RGB:
106 return ActivitiesFactory::createAnimateActivity(
107 aParms,
108 AnimationFactory::createColorPropertyAnimation(
109 mxColorNode->getAttributeName(),
110 getShape(),
111 getContext().mpSubsettableShapeManager,
112 getSlideSize() ),
113 getXAnimateNode() );
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(
120 aParms,
121 HSLColorAnimationSharedPtr(
122 new HSLWrapper(
123 AnimationFactory::createColorPropertyAnimation(
124 mxColorNode->getAttributeName(),
125 getShape(),
126 getContext().mpSubsettableShapeManager,
127 getSlideSize() ))),
128 mxColorNode );
130 default:
131 ENSURE_OR_THROW( false, "AnimationColorNode::createColorActivity(): "
132 "Unexpected color space" );
135 return AnimationActivitySharedPtr();
138 } // namespace internal
139 } // namespace slideshow