|
1 /* |
|
2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Primitive value type resolver for CSS Style properties |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 package com.nokia.tools.themeinstaller.odtconverter; |
|
20 |
|
21 import java.util.Hashtable; |
|
22 |
|
23 import org.w3c.css.sac.LexicalUnit; |
|
24 |
|
25 /** |
|
26 * Resolves primitive value types by keys. |
|
27 * Property types that are taken into account are |
|
28 * from Symbian side: ...\epoc32\include\middleware\xndompropertyvalue.h |
|
29 */ |
|
30 public class ValueTypeResolver |
|
31 { |
|
32 |
|
33 // CONSTANTS |
|
34 // Primitive Value Types |
|
35 public static final short E_UNKNOWN = 0; |
|
36 public static final short E_NUMBER = 1; |
|
37 public static final short E_PERCENTAGE = 2; |
|
38 public static final short E_EMS = 3; |
|
39 public static final short E_EXS = 4; |
|
40 public static final short E_PX = 5; |
|
41 public static final short E_CM = 6; |
|
42 public static final short E_MM = 7; |
|
43 public static final short E_IN = 8; |
|
44 public static final short E_PT = 9; |
|
45 public static final short E_PC = 10; |
|
46 public static final short E_DEG = 11; |
|
47 public static final short E_RAD = 12; |
|
48 public static final short E_GRAD = 13; |
|
49 public static final short E_MS = 14; |
|
50 public static final short E_S = 15; |
|
51 public static final short E_HZ = 16; |
|
52 public static final short E_KHZ = 17; |
|
53 public static final short E_STRING = 19; |
|
54 public static final short E_URI = 20; |
|
55 public static final short E_IDENT = 21; |
|
56 public static final short E_ATTR = 22; |
|
57 public static final short E_RGB_COLOR = 25; |
|
58 public static final short E_RGBA_COLOR = 26; |
|
59 public static final short E_UNIT_VALUE = 28; |
|
60 |
|
61 // Ident Types |
|
62 public static final short E_NOT_SET = 0; |
|
63 public static final short E_AUTO = 1; |
|
64 public static final short E_NONE = 2; |
|
65 public static final short E_INHERIT = 3; |
|
66 |
|
67 private Hashtable iValueTypeResolver; |
|
68 |
|
69 /** |
|
70 * Instantiates a new value type resolver. |
|
71 */ |
|
72 public ValueTypeResolver() |
|
73 { |
|
74 iValueTypeResolver = new Hashtable(); |
|
75 |
|
76 //Real Value Types |
|
77 iValueTypeResolver.put( new Short( LexicalUnit.SAC_INTEGER ), new Short( E_NUMBER )); |
|
78 iValueTypeResolver.put( new Short( LexicalUnit.SAC_REAL ), new Short( E_NUMBER )); |
|
79 iValueTypeResolver.put( new Short( LexicalUnit.SAC_PERCENTAGE ), new Short( E_PERCENTAGE )); |
|
80 iValueTypeResolver.put( new Short( LexicalUnit.SAC_EM ), new Short( E_EMS )); |
|
81 iValueTypeResolver.put( new Short( LexicalUnit.SAC_EX ), new Short( E_EXS )); |
|
82 iValueTypeResolver.put( new Short( LexicalUnit.SAC_PIXEL ), new Short( E_PX )); |
|
83 iValueTypeResolver.put( new Short( LexicalUnit.SAC_CENTIMETER ), new Short( E_CM )); |
|
84 iValueTypeResolver.put( new Short( LexicalUnit.SAC_MILLIMETER ), new Short( E_MM )); |
|
85 iValueTypeResolver.put( new Short( LexicalUnit.SAC_INCH ), new Short( E_IN )); |
|
86 iValueTypeResolver.put( new Short( LexicalUnit.SAC_POINT ), new Short( E_PT )); |
|
87 iValueTypeResolver.put( new Short( LexicalUnit.SAC_PICA ), new Short( E_PC )); |
|
88 iValueTypeResolver.put( new Short( LexicalUnit.SAC_DEGREE ), new Short( E_DEG )); |
|
89 iValueTypeResolver.put( new Short( LexicalUnit.SAC_RADIAN ), new Short( E_RAD )); |
|
90 iValueTypeResolver.put( new Short( LexicalUnit.SAC_GRADIAN ), new Short( E_GRAD )); |
|
91 iValueTypeResolver.put( new Short( LexicalUnit.SAC_MILLISECOND ), new Short( E_MS )); |
|
92 iValueTypeResolver.put( new Short( LexicalUnit.SAC_SECOND ), new Short( E_S )); |
|
93 iValueTypeResolver.put( new Short( LexicalUnit.SAC_HERTZ ), new Short( E_HZ )); |
|
94 iValueTypeResolver.put( new Short( LexicalUnit.SAC_KILOHERTZ ), new Short( E_KHZ )); |
|
95 iValueTypeResolver.put( new Short( LexicalUnit.SAC_DIMENSION ), new Short( E_UNIT_VALUE )); |
|
96 |
|
97 //String Value Types |
|
98 iValueTypeResolver.put( new Short( LexicalUnit.SAC_STRING_VALUE ), new Short( E_STRING )); |
|
99 iValueTypeResolver.put( new Short( LexicalUnit.SAC_IDENT ), new Short( E_IDENT )); |
|
100 iValueTypeResolver.put( new Short( LexicalUnit.SAC_URI ), new Short( E_URI )); |
|
101 iValueTypeResolver.put( new Short( LexicalUnit.SAC_ATTR ), new Short( E_ATTR )); |
|
102 |
|
103 //Color value Types |
|
104 iValueTypeResolver.put( new Short( LexicalUnit.SAC_RGBCOLOR ), new Short( E_RGB_COLOR )); |
|
105 |
|
106 } |
|
107 |
|
108 /** |
|
109 * Gets the value of the Symbian specific code for value type. |
|
110 * |
|
111 * @param aKey The key for Lexical Unit |
|
112 * |
|
113 * @return the The value of the Symbian specific code |
|
114 */ |
|
115 public Short getValue( Short aKey ) |
|
116 { |
|
117 if ( iValueTypeResolver.containsKey( aKey ) ) |
|
118 { |
|
119 return ( Short ) iValueTypeResolver.get( aKey ); |
|
120 } |
|
121 else |
|
122 throw new IllegalStateException( |
|
123 "Invalid value type while resolving CSS : " + aKey ); |
|
124 } |
|
125 |
|
126 } |