1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_slideshow.hxx"
26 
27 // must be first
28 #include <canvas/debug.hxx>
29 #include <canvas/canvastools.hxx>
30 
31 #include "attributemap.hxx"
32 #include "tools.hxx"
33 
34 
35 namespace slideshow
36 {
37     namespace internal
38     {
39         typedef ::canvas::tools::ValueMap< AttributeType > AnimateAttributeMap;
40 
mapAttributeName(const::rtl::OUString & rAttrName)41         AttributeType mapAttributeName( const ::rtl::OUString& rAttrName )
42         {
43             /** Maps attribute name to AttributeType enum.
44 
45 	            String entries are all case-insensitive and MUST
46     	        BE STORED lowercase.
47 
48         	    String entries MUST BE SORTED in ascending order!
49             */
50             static AnimateAttributeMap::MapEntry lcl_attributeMap[] =
51                 {
52                     { "charcolor", ATTRIBUTE_CHAR_COLOR },
53 
54                     { "charfontname", ATTRIBUTE_CHAR_FONT_NAME },
55 
56                     { "charheight", ATTRIBUTE_CHAR_HEIGHT },
57 
58                     { "charposture", ATTRIBUTE_CHAR_POSTURE },
59 
60                     // TODO(Q1): This should prolly be changed in PPT import
61                     // { "charrotation", ATTRIBUTE_CHAR_ROTATION },
62                     { "charrotation", ATTRIBUTE_ROTATE },
63 
64                     { "charunderline", ATTRIBUTE_CHAR_UNDERLINE },
65 
66                     { "charweight", ATTRIBUTE_CHAR_WEIGHT },
67 
68                     { "color", ATTRIBUTE_COLOR },
69 
70                     { "dimcolor", ATTRIBUTE_DIMCOLOR },
71 
72                     { "fillcolor", ATTRIBUTE_FILL_COLOR },
73 
74                     { "fillstyle", ATTRIBUTE_FILL_STYLE },
75 
76                     { "height", ATTRIBUTE_HEIGHT },
77 
78                     { "linecolor", ATTRIBUTE_LINE_COLOR },
79 
80                     { "linestyle", ATTRIBUTE_LINE_STYLE },
81 
82                     { "opacity", ATTRIBUTE_OPACITY },
83 
84                     { "rotate", ATTRIBUTE_ROTATE },
85 
86                     { "skewx", ATTRIBUTE_SKEW_X },
87 
88                     { "skewy", ATTRIBUTE_SKEW_Y },
89 
90                     { "visibility", ATTRIBUTE_VISIBILITY },
91 
92                     { "width", ATTRIBUTE_WIDTH },
93 
94                     { "x", ATTRIBUTE_POS_X },
95 
96                     { "y", ATTRIBUTE_POS_Y }
97                 };
98 
99             static AnimateAttributeMap aMap( lcl_attributeMap,
100                                              sizeof(lcl_attributeMap)/sizeof(*lcl_attributeMap),
101                                              false );
102 
103             AttributeType eAttributeType = ATTRIBUTE_INVALID;
104 
105             // determine the type from the attribute name
106             if( !aMap.lookup( rAttrName,
107                               eAttributeType ) )
108             {
109                 OSL_TRACE( "mapAttributeName(): attribute name %s not found in map.",
110                            ::rtl::OUStringToOString( rAttrName,
111                                                      RTL_TEXTENCODING_ASCII_US ).getStr() );
112                 return ATTRIBUTE_INVALID;
113             }
114 
115             return eAttributeType;
116         }
117 
118     }
119 }
120