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 <canvas/canvastools.hxx>
22 
23 #include <attributemap.hxx>
24 #include <sal/log.hxx>
25 
26 
27 namespace slideshow::internal
28 {
29         typedef ::canvas::tools::ValueMap< AttributeType > AnimateAttributeMap;
30 
mapAttributeName(const OUString & rAttrName)31         AttributeType mapAttributeName( const OUString& rAttrName )
32         {
33             /** Maps attribute name to AttributeType enum.
34 
35                 String entries are all case-insensitive and MUST
36                 BE STORED lowercase.
37 
38                 String entries MUST BE SORTED in ascending order!
39             */
40             static const AnimateAttributeMap::MapEntry lcl_attributeMap[] =
41                 {
42                     { "charcolor", AttributeType::CharColor },
43                     { "charfontname", AttributeType::CharFontName },
44                     { "charheight", AttributeType::CharHeight },
45                     { "charposture", AttributeType::CharPosture },
46                     // TODO(Q1): This should prolly be changed in PPT import
47                     // { "charrotation", AttributeType::CharRotation },
48                     { "charrotation", AttributeType::Rotate },
49                     { "charunderline", AttributeType::CharUnderline },
50                     { "charweight", AttributeType::CharWeight },
51                     { "color", AttributeType::Color },
52                     { "dimcolor", AttributeType::DimColor },
53                     { "fillcolor", AttributeType::FillColor },
54                     { "fillstyle", AttributeType::FillStyle },
55                     { "height", AttributeType::Height },
56                     { "linecolor", AttributeType::LineColor },
57                     { "linestyle", AttributeType::LineStyle },
58                     { "opacity", AttributeType::Opacity },
59                     { "rotate", AttributeType::Rotate },
60                     { "skewx", AttributeType::SkewX },
61                     { "skewy", AttributeType::SkewY },
62                     { "visibility", AttributeType::Visibility },
63                     { "width", AttributeType::Width },
64                     { "x", AttributeType::PosX },
65                     { "y", AttributeType::PosY }
66                 };
67 
68             static const AnimateAttributeMap aMap( lcl_attributeMap,
69                                              SAL_N_ELEMENTS(lcl_attributeMap),
70                                              false );
71 
72             AttributeType eAttributeType = AttributeType::Invalid;
73 
74             // determine the type from the attribute name
75             if( !aMap.lookup( rAttrName,
76                               eAttributeType ) )
77             {
78                 SAL_WARN("slideshow", "mapAttributeName(): attribute name not found in map: " << rAttrName);
79                 return AttributeType::Invalid;
80             }
81 
82             return eAttributeType;
83         }
84 
85 }
86 
87 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
88