LibreOffice Module slideshow (master) 1
animationcolornode.cxx
Go to the documentation of this file.
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#include <com/sun/star/animations/AnimationColorSpace.hpp>
22
23#include <coloranimation.hxx>
24#include <hslcoloranimation.hxx>
26#include <animationfactory.hxx>
27#include <activitiesfactory.hxx>
28#include <utility>
29
30using namespace com::sun::star;
31
32namespace slideshow::internal {
33
34namespace {
41class HSLWrapper : public HSLColorAnimation
42{
43public:
44 explicit HSLWrapper( ColorAnimationSharedPtr xAnimation )
45 : mpAnimation(std::move( xAnimation ))
46 {
49 "HSLWrapper::HSLWrapper(): Invalid color animation delegate" );
50 }
51
52 virtual void prefetch() override
53 {}
54
55 virtual void start( const AnimatableShapeSharedPtr& rShape,
56 const ShapeAttributeLayerSharedPtr& rAttrLayer ) override
57 {
58 mpAnimation->start( rShape, rAttrLayer );
59 }
60
61 virtual void end() override
62 {
63 mpAnimation->end();
64 }
65
66 virtual bool operator()( const HSLColor& rColor ) override
67 {
68 return (*mpAnimation)( RGBColor( rColor ) );
69 }
70
71 virtual HSLColor getUnderlyingValue() const override
72 {
73 return HSLColor( mpAnimation->getUnderlyingValue() );
74 }
75
76private:
78};
79
80} // anon namespace
81
83{
85
86 switch( mxColorNode->getColorInterpolation() )
87 {
88 case animations::AnimationColorSpace::RGB:
90 aParms,
92 mxColorNode->getAttributeName(),
93 getShape(),
98
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
104 aParms,
105 std::make_shared<HSLWrapper>(
107 mxColorNode->getAttributeName(),
108 getShape(),
110 getSlideSize(),
112 mxColorNode );
113
114 default:
115 ENSURE_OR_THROW( false, "AnimationColorNode::createColorActivity(): "
116 "Unexpected color space" );
117 }
118
120}
121
122} // namespace slideshow::internal
123
124/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ColorAnimationSharedPtr mpAnimation
box2d::utils::Box2DWorldSharedPtr mpBox2DWorld
AttributableShapeSharedPtr const & getShape() const
::basegfx::B2DVector const & getSlideSize() const
css::uno::Reference< css::animations::XAnimate > const & getXAnimateNode() const
ActivitiesFactory::CommonParameters fillCommonParameters() const
Create parameter struct for ActivitiesFactory.
virtual AnimationActivitySharedPtr createActivity() const override
css::uno::Reference< css::animations::XAnimateColor > mxColorNode
SlideShowContext const & getContext() const
Definition: basenode.hxx:135
#define ENSURE_OR_THROW(c, m)
end
AnimationActivitySharedPtr createAnimateActivity(const CommonParameters &rParms, const NumberAnimationSharedPtr &rAnimator, const css::uno::Reference< css::animations::XAnimate > &xNode)
Create an activity from an XAnimate node.
ColorAnimationSharedPtr createColorPropertyAnimation(const OUString &rAttrName, const AnimatableShapeSharedPtr &rShape, const ShapeManagerSharedPtr &rShapeManager, const ::basegfx::B2DVector &rSlideSize, const box2d::utils::Box2DWorldSharedPtr &pBox2DWorld, int nFlags=0)
::std::shared_ptr< AnimatableShape > AnimatableShapeSharedPtr
::std::shared_ptr< AnimationActivity > AnimationActivitySharedPtr
::std::shared_ptr< ShapeAttributeLayer > ShapeAttributeLayerSharedPtr
::std::shared_ptr< ColorAnimation > ColorAnimationSharedPtr
std::shared_ptr< SubsettableShapeManager > mpSubsettableShapeManager
Definition: slideimpl.cxx:199