Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 :
21 : // must be first
22 : #include <canvas/debug.hxx>
23 : #include <canvas/verbosetrace.hxx>
24 : #include <com/sun/star/animations/AnimationColorSpace.hpp>
25 :
26 : #include "coloranimation.hxx"
27 : #include "hslcoloranimation.hxx"
28 : #include "animationcolornode.hxx"
29 : #include "animationfactory.hxx"
30 : #include "activitiesfactory.hxx"
31 :
32 : using namespace com::sun::star;
33 :
34 : namespace slideshow {
35 : namespace internal {
36 :
37 : namespace {
38 : /** Little wrapper for HSL to RGB mapping.
39 :
40 : This class implements the HSLColorAnimation interface,
41 : internally converting to RGB and forwarding to
42 : ColorAnimation.
43 : */
44 0 : class HSLWrapper : public HSLColorAnimation
45 : {
46 : public:
47 0 : HSLWrapper( const ColorAnimationSharedPtr& rAnimation )
48 0 : : mpAnimation( rAnimation )
49 : {
50 0 : ENSURE_OR_THROW(
51 : mpAnimation,
52 : "HSLWrapper::HSLWrapper(): Invalid color animation delegate" );
53 0 : }
54 :
55 0 : virtual void prefetch( const AnimatableShapeSharedPtr&,
56 : const ShapeAttributeLayerSharedPtr& ) SAL_OVERRIDE
57 0 : {}
58 :
59 0 : virtual void start( const AnimatableShapeSharedPtr& rShape,
60 : const ShapeAttributeLayerSharedPtr& rAttrLayer ) SAL_OVERRIDE
61 : {
62 0 : mpAnimation->start( rShape, rAttrLayer );
63 0 : }
64 :
65 0 : virtual void end() SAL_OVERRIDE
66 : {
67 0 : mpAnimation->end();
68 0 : }
69 :
70 0 : virtual bool operator()( const HSLColor& rColor ) SAL_OVERRIDE
71 : {
72 0 : return (*mpAnimation)( RGBColor( rColor ) );
73 : }
74 :
75 0 : virtual HSLColor getUnderlyingValue() const SAL_OVERRIDE
76 : {
77 0 : return HSLColor( mpAnimation->getUnderlyingValue() );
78 : }
79 :
80 : private:
81 : ColorAnimationSharedPtr mpAnimation;
82 : };
83 :
84 : } // anon namespace
85 :
86 0 : AnimationActivitySharedPtr AnimationColorNode::createActivity() const
87 : {
88 0 : ActivitiesFactory::CommonParameters aParms( fillCommonParameters() );
89 :
90 0 : switch( mxColorNode->getColorInterpolation() )
91 : {
92 : case animations::AnimationColorSpace::RGB:
93 : return ActivitiesFactory::createAnimateActivity(
94 : aParms,
95 : AnimationFactory::createColorPropertyAnimation(
96 0 : mxColorNode->getAttributeName(),
97 : getShape(),
98 0 : getContext().mpSubsettableShapeManager,
99 0 : getSlideSize() ),
100 0 : getXAnimateNode() );
101 :
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(
107 : aParms,
108 : HSLColorAnimationSharedPtr(
109 : new HSLWrapper(
110 : AnimationFactory::createColorPropertyAnimation(
111 0 : mxColorNode->getAttributeName(),
112 : getShape(),
113 0 : getContext().mpSubsettableShapeManager,
114 0 : getSlideSize() ))),
115 0 : mxColorNode );
116 :
117 : default:
118 0 : ENSURE_OR_THROW( false, "AnimationColorNode::createColorActivity(): "
119 : "Unexpected color space" );
120 : }
121 :
122 0 : return AnimationActivitySharedPtr();
123 : }
124 :
125 : } // namespace internal
126 : } // namespace slideshow
127 :
128 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|