1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_slideshow.hxx"
30 
31 // must be first
32 #include <canvas/debug.hxx>
33 #include <canvas/canvastools.hxx>
34 
35 #include "attributemap.hxx"
36 #include "tools.hxx"
37 
38 
39 namespace slideshow
40 {
41     namespace internal
42     {
43         typedef ::canvas::tools::ValueMap< AttributeType > AnimateAttributeMap;
44 
45         AttributeType mapAttributeName( const ::rtl::OUString& rAttrName )
46         {
47             /** Maps attribute name to AttributeType enum.
48 
49 	            String entries are all case-insensitive and MUST
50     	        BE STORED lowercase.
51 
52         	    String entries MUST BE SORTED in ascending order!
53             */
54             static AnimateAttributeMap::MapEntry lcl_attributeMap[] =
55                 {
56                     { "charcolor", ATTRIBUTE_CHAR_COLOR },
57 
58                     { "charfontname", ATTRIBUTE_CHAR_FONT_NAME },
59 
60                     { "charheight", ATTRIBUTE_CHAR_HEIGHT },
61 
62                     { "charposture", ATTRIBUTE_CHAR_POSTURE },
63 
64                     // TODO(Q1): This should prolly be changed in PPT import
65                     // { "charrotation", ATTRIBUTE_CHAR_ROTATION },
66                     { "charrotation", ATTRIBUTE_ROTATE },
67 
68                     { "charunderline", ATTRIBUTE_CHAR_UNDERLINE },
69 
70                     { "charweight", ATTRIBUTE_CHAR_WEIGHT },
71 
72                     { "color", ATTRIBUTE_COLOR },
73 
74                     { "dimcolor", ATTRIBUTE_DIMCOLOR },
75 
76                     { "fillcolor", ATTRIBUTE_FILL_COLOR },
77 
78                     { "fillstyle", ATTRIBUTE_FILL_STYLE },
79 
80                     { "height", ATTRIBUTE_HEIGHT },
81 
82                     { "linecolor", ATTRIBUTE_LINE_COLOR },
83 
84                     { "linestyle", ATTRIBUTE_LINE_STYLE },
85 
86                     { "opacity", ATTRIBUTE_OPACITY },
87 
88                     { "rotate", ATTRIBUTE_ROTATE },
89 
90                     { "skewx", ATTRIBUTE_SKEW_X },
91 
92                     { "skewy", ATTRIBUTE_SKEW_Y },
93 
94                     { "visibility", ATTRIBUTE_VISIBILITY },
95 
96                     { "width", ATTRIBUTE_WIDTH },
97 
98                     { "x", ATTRIBUTE_POS_X },
99 
100                     { "y", ATTRIBUTE_POS_Y }
101                 };
102 
103             static AnimateAttributeMap aMap( lcl_attributeMap,
104                                              sizeof(lcl_attributeMap)/sizeof(*lcl_attributeMap),
105                                              false );
106 
107             AttributeType eAttributeType = ATTRIBUTE_INVALID;
108 
109             // determine the type from the attribute name
110             if( !aMap.lookup( rAttrName,
111                               eAttributeType ) )
112             {
113                 OSL_TRACE( "mapAttributeName(): attribute name %s not found in map.",
114                            ::rtl::OUStringToOString( rAttrName,
115                                                      RTL_TEXTENCODING_ASCII_US ).getStr() );
116                 return ATTRIBUTE_INVALID;
117             }
118 
119             return eAttributeType;
120         }
121 
122     }
123 }
124