Bump version to 6.0-36
[LibreOffice.git] / slideshow / source / engine / animationnodes / animationcolornode.cxx
blob79850c84b7a963ce29f4a311674f6701f1e6e86d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
21 #include <com/sun/star/animations/AnimationColorSpace.hpp>
23 #include <coloranimation.hxx>
24 #include <hslcoloranimation.hxx>
25 #include "animationcolornode.hxx"
26 #include <animationfactory.hxx>
27 #include <activitiesfactory.hxx>
29 using namespace com::sun::star;
31 namespace slideshow {
32 namespace internal {
34 namespace {
35 /** Little wrapper for HSL to RGB mapping.
37 This class implements the HSLColorAnimation interface,
38 internally converting to RGB and forwarding to
39 ColorAnimation.
41 class HSLWrapper : public HSLColorAnimation
43 public:
44 explicit HSLWrapper( const ColorAnimationSharedPtr& rAnimation )
45 : mpAnimation( rAnimation )
47 ENSURE_OR_THROW(
48 mpAnimation,
49 "HSLWrapper::HSLWrapper(): Invalid color animation delegate" );
52 virtual void prefetch( const AnimatableShapeSharedPtr&,
53 const ShapeAttributeLayerSharedPtr& ) override
56 virtual void start( const AnimatableShapeSharedPtr& rShape,
57 const ShapeAttributeLayerSharedPtr& rAttrLayer ) override
59 mpAnimation->start( rShape, rAttrLayer );
62 virtual void end() override
64 mpAnimation->end();
67 virtual bool operator()( const HSLColor& rColor ) override
69 return (*mpAnimation)( RGBColor( rColor ) );
72 virtual HSLColor getUnderlyingValue() const override
74 return HSLColor( mpAnimation->getUnderlyingValue() );
77 private:
78 ColorAnimationSharedPtr mpAnimation;
81 } // anon namespace
83 AnimationActivitySharedPtr AnimationColorNode::createActivity() const
85 ActivitiesFactory::CommonParameters aParms( fillCommonParameters() );
87 switch( mxColorNode->getColorInterpolation() )
89 case animations::AnimationColorSpace::RGB:
90 return ActivitiesFactory::createAnimateActivity(
91 aParms,
92 AnimationFactory::createColorPropertyAnimation(
93 mxColorNode->getAttributeName(),
94 getShape(),
95 getContext().mpSubsettableShapeManager,
96 getSlideSize() ),
97 getXAnimateNode() );
99 case animations::AnimationColorSpace::HSL:
100 // Wrap a plain ColorAnimation with the HSL
101 // wrapper, which implements the HSLColorAnimation
102 // interface, and internally converts HSL to RGB color
103 return ActivitiesFactory::createAnimateActivity(
104 aParms,
105 HSLColorAnimationSharedPtr(
106 new HSLWrapper(
107 AnimationFactory::createColorPropertyAnimation(
108 mxColorNode->getAttributeName(),
109 getShape(),
110 getContext().mpSubsettableShapeManager,
111 getSlideSize() ))),
112 mxColorNode );
114 default:
115 ENSURE_OR_THROW( false, "AnimationColorNode::createColorActivity(): "
116 "Unexpected color space" );
119 return AnimationActivitySharedPtr();
122 } // namespace internal
123 } // namespace slideshow
125 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */