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 <canvas/debug.hxx>
23 #include <canvas/verbosetrace.hxx>
24 #include <com/sun/star/animations/AnimationColorSpace.hpp>
26 #include "coloranimation.hxx"
27 #include "hslcoloranimation.hxx"
28 #include "animationcolornode.hxx"
29 #include "animationfactory.hxx"
30 #include "activitiesfactory.hxx"
32 using namespace com::sun::star
;
38 /** Little wrapper for HSL to RGB mapping.
40 This class implements the HSLColorAnimation interface,
41 internally converting to RGB and forwarding to
44 class HSLWrapper
: public HSLColorAnimation
47 HSLWrapper( const ColorAnimationSharedPtr
& rAnimation
)
48 : mpAnimation( rAnimation
)
52 "HSLWrapper::HSLWrapper(): Invalid color animation delegate" );
55 virtual void prefetch( const AnimatableShapeSharedPtr
&,
56 const ShapeAttributeLayerSharedPtr
& ) SAL_OVERRIDE
59 virtual void start( const AnimatableShapeSharedPtr
& rShape
,
60 const ShapeAttributeLayerSharedPtr
& rAttrLayer
) SAL_OVERRIDE
62 mpAnimation
->start( rShape
, rAttrLayer
);
65 virtual void end() SAL_OVERRIDE
70 virtual bool operator()( const HSLColor
& rColor
) SAL_OVERRIDE
72 return (*mpAnimation
)( RGBColor( rColor
) );
75 virtual HSLColor
getUnderlyingValue() const SAL_OVERRIDE
77 return HSLColor( mpAnimation
->getUnderlyingValue() );
81 ColorAnimationSharedPtr mpAnimation
;
86 AnimationActivitySharedPtr
AnimationColorNode::createActivity() const
88 ActivitiesFactory::CommonParameters
aParms( fillCommonParameters() );
90 switch( mxColorNode
->getColorInterpolation() )
92 case animations::AnimationColorSpace::RGB
:
93 return ActivitiesFactory::createAnimateActivity(
95 AnimationFactory::createColorPropertyAnimation(
96 mxColorNode
->getAttributeName(),
98 getContext().mpSubsettableShapeManager
,
102 case animations::AnimationColorSpace::HSL
:
103 // Wrap a plain ColorAnimation with the HSL
104 // wrapper, which implements the HSLColorAnimation
105 // interface, and internally converts HSL to RGB color
106 return ActivitiesFactory::createAnimateActivity(
108 HSLColorAnimationSharedPtr(
110 AnimationFactory::createColorPropertyAnimation(
111 mxColorNode
->getAttributeName(),
113 getContext().mpSubsettableShapeManager
,
118 ENSURE_OR_THROW( false, "AnimationColorNode::createColorActivity(): "
119 "Unexpected color space" );
122 return AnimationActivitySharedPtr();
125 } // namespace internal
126 } // namespace slideshow
128 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */