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_sdext.hxx"
26
27 #include "pppoptimizertoken.hxx"
28 #include <osl/mutex.hxx>
29 #include <hash_map>
30 #include <rtl/string.hxx>
31
32 typedef std::hash_map< const char*, PPPOptimizerTokenEnum, rtl::CStringHash, rtl::CStringEqual> TypeNameHashMap;
33 static TypeNameHashMap* pHashMap = NULL;
getHashMapMutex()34 static ::osl::Mutex& getHashMapMutex()
35 {
36 static osl::Mutex s_aHashMapProtection;
37 return s_aHashMapProtection;
38 }
39
40 struct TokenTable
41 {
42 const char* pS;
43 PPPOptimizerTokenEnum pE;
44 };
45
46 static const TokenTable pTokenTableArray[] =
47 {
48 { "rdmNavi", TK_rdmNavi },
49 { "lnNavSep1", TK_lnNavSep1 },
50 { "lnNavSep2", TK_lnNavSep2 },
51 { "btnNavHelp", TK_btnNavHelp },
52 { "btnNavBack", TK_btnNavBack },
53 { "btnNavNext", TK_btnNavNext },
54 { "btnNavFinish", TK_btnNavFinish },
55 { "btnNavCancel", TK_btnNavCancel },
56
57 { "FixedText0Pg0", TK_FixedText0Pg0 },
58 { "FixedText1Pg0", TK_FixedText1Pg0 },
59 { "Separator1Pg0", TK_Separator1Pg0 },
60 { "FixedText2Pg0", TK_FixedText2Pg0 },
61 { "ListBox0Pg0", TK_ListBox0Pg0 },
62 { "Button0Pg0", TK_Button0Pg0 },
63 { "RadioButton0Pg1", TK_RadioButton0Pg1 },
64 { "RadioButton1Pg1", TK_RadioButton1Pg1 },
65 { "FixedText0Pg1", TK_FixedText0Pg1 },
66 { "CheckBox1Pg1", TK_CheckBox1Pg1 },
67 { "FixedText1Pg1", TK_FixedText1Pg1 },
68 { "FixedText2Pg1", TK_FixedText2Pg1 },
69 { "FormattedField0Pg1", TK_FormattedField0Pg1 },
70 { "ComboBox0Pg1", TK_ComboBox0Pg1 },
71 { "CheckBox2Pg1", TK_CheckBox2Pg1 },
72 { "FixedText0Pg2", TK_FixedText0Pg2 },
73 { "FixedText1Pg2", TK_FixedText1Pg2 },
74 { "CheckBox0Pg2", TK_CheckBox0Pg2 },
75 { "RadioButton0Pg2", TK_RadioButton0Pg2 },
76 { "RadioButton1Pg2", TK_RadioButton1Pg2 },
77 { "FixedText0Pg3", TK_FixedText0Pg3 },
78 { "CheckBox0Pg3", TK_CheckBox0Pg3 },
79 { "FixedText1Pg3", TK_FixedText1Pg3 },
80 { "CheckBox1Pg3", TK_CheckBox1Pg3 },
81 { "FixedText2Pg3", TK_FixedText2Pg3 },
82 { "CheckBox2Pg3", TK_CheckBox2Pg3 },
83 { "CheckBox3Pg3", TK_CheckBox3Pg3 },
84 { "ListBox0Pg3", TK_ListBox0Pg3 },
85 { "Separator0Pg4", TK_Separator0Pg4 },
86 { "RadioButton0Pg4", TK_RadioButton0Pg4 },
87 { "RadioButton1Pg4", TK_RadioButton1Pg4 },
88 { "Separator1Pg4", TK_Separator1Pg4 },
89 { "FixedText0Pg4", TK_FixedText0Pg4 },
90 { "FixedText1Pg4", TK_FixedText1Pg4 },
91 { "FixedText2Pg4", TK_FixedText2Pg4 },
92 { "FixedText3Pg4", TK_FixedText3Pg4 },
93 { "FixedText4Pg4", TK_FixedText4Pg4 },
94 { "FixedText5Pg4", TK_FixedText5Pg4 },
95 { "FixedText6Pg4", TK_FixedText6Pg4 },
96 { "FixedText7Pg4", TK_FixedText7Pg4 },
97 { "FixedText8Pg4", TK_FixedText8Pg4 },
98 { "CheckBox1Pg4", TK_CheckBox1Pg4 },
99 { "ComboBox0Pg4", TK_ComboBox0Pg4 },
100
101 { "_blank", TK__blank },
102 { "_self", TK__self },
103 { "Activated", TK_Activated },
104 { "Align", TK_Align },
105 { "Alpha", TK_Alpha },
106 { "Animated", TK_Animated },
107 { "Background", TK_Background },
108 { "Border", TK_Border },
109 { "Closeable", TK_Closeable },
110 { "ColorMode", TK_ColorMode },
111 { "Complete", TK_Complete },
112 { "Compression", TK_Compression },
113 { "CurrentItemID", TK_CurrentItemID },
114 { "DefaultButton", TK_DefaultButton },
115 { "DocumentService", TK_DocumentService },
116 { "Dropdown", TK_Dropdown },
117 { "EffectiveValue", TK_EffectiveValue },
118 { "EffectiveMin", TK_EffectiveMin },
119 { "EffectiveMax", TK_EffectiveMax },
120 { "Enabled", TK_Enabled },
121 { "Extensions", TK_Extensions },
122 { "FileSizeDestination",TK_FileSizeDestination },
123 { "FileSizeSource", TK_FileSizeSource },
124 { "FillBitmap", TK_FillBitmap },
125 { "FillBitmapLogicalSize",TK_FillBitmapLogicalSize },
126 { "FillBitmapMode", TK_FillBitmapMode },
127 { "FillBitmapSizeX", TK_FillBitmapSizeX },
128 { "FillBitmapSizeY", TK_FillBitmapSizeY },
129 { "FillBitmapURL", TK_FillBitmapURL },
130 { "FillStyle", TK_FillStyle },
131 { "FilterData", TK_FilterData },
132 { "FilterName", TK_FilterName },
133 { "Flags", TK_Flags },
134 { "FontDescriptor", TK_FontDescriptor },
135 { "Graphic", TK_Graphic },
136 { "GraphicCrop", TK_GraphicCrop },
137 { "GraphicCropLogic", TK_GraphicCropLogic },
138 { "GraphicURL", TK_GraphicURL },
139 { "GraphicStreamURL", TK_GraphicStreamURL },
140 { "Height", TK_Height },
141 { "HelpURL", TK_HelpURL },
142 { "Hidden", TK_Hidden },
143 { "ID", TK_ID },
144 { "ImageURL", TK_ImageURL },
145 { "ParentWindow", TK_ParentWindow },// TODO move it
146 { "InputStream", TK_InputStream },
147 { "Interlaced", TK_Interlaced },
148 { "IsInternal", TK_IsInternal },
149 { "Label", TK_Label },
150 { "LineCount", TK_LineCount },
151 { "LogicalHeight", TK_LogicalHeight },
152 { "LogicalWidth", TK_LogicalWidth },
153 { "LogicalSize", TK_LogicalSize },
154 { "MimeType", TK_MimeType },
155 { "Moveable", TK_Moveable },
156 { "MultiLine", TK_MultiLine },
157 { "MultiSelection", TK_MultiSelection },
158 { "Name", TK_Name },
159 { "Orientation", TK_Orientation },
160 { "OutputStream", TK_OutputStream },
161 { "PixelHeight", TK_PixelHeight },
162 { "PixelWidth", TK_PixelWidth },
163 { "PositionX", TK_PositionX },
164 { "PositionY", TK_PositionY },
165 { "Progress", TK_Progress },
166 { "ProgressValue", TK_ProgressValue },
167 { "ProgressValueMax", TK_ProgressValueMax },
168 { "ProgressValueMin", TK_ProgressValueMin },
169 { "PushButtonType", TK_PushButtonType },
170 { "Quality", TK_Quality },
171 { "ReadOnly", TK_ReadOnly },
172 { "Repeat", TK_Repeat },
173 { "ScaleImage", TK_ScaleImage },
174 { "SelectedItems", TK_SelectedItems },
175 { "Settings", TK_Settings },
176 { "Size100thMM", TK_Size100thMM },
177 { "SizePixel", TK_SizePixel },
178 { "Spin", TK_Spin },
179 { "Step", TK_Step },
180 { "State", TK_State },
181 { "StatusListener", TK_StatusListener },
182 { "StringItemList", TK_StringItemList },
183 { "Strings", TK_Strings },
184 { "TabIndex", TK_TabIndex },
185 { "Template", TK_Template },
186 { "Text", TK_Text },
187 { "Title", TK_Title },
188 { "Transparent", TK_Transparent },
189 { "Type", TK_Type },
190 { "UIName", TK_UIName },
191 { "Value", TK_Value },
192 { "Width", TK_Width },
193 { "ZOrder", TK_ZOrder },
194
195 { "LastUsedSettings", TK_LastUsedSettings },
196 { "Settings/Templates", TK_Settings_Templates },
197 { "Settings/Templates/",TK_Settings_Templates_ },
198 { "JPEGCompression", TK_JPEGCompression },
199 { "JPEGQuality", TK_JPEGQuality },
200 { "RemoveCropArea", TK_RemoveCropArea },
201 { "ImageResolution", TK_ImageResolution },
202 { "EmbedLinkedGraphics",TK_EmbedLinkedGraphics },
203 { "OLEOptimization", TK_OLEOptimization },
204 { "OLEOptimizationType",TK_OLEOptimizationType },
205 { "DeleteUnusedMasterPages", TK_DeleteUnusedMasterPages },
206 { "DeleteHiddenSlides", TK_DeleteHiddenSlides },
207 { "DeleteNotesPages", TK_DeleteNotesPages },
208 { "CustomShowName", TK_CustomShowName },
209 { "SaveAs", TK_SaveAs },
210 { "SaveAsURL", TK_SaveAsURL },
211 { "OpenNewDocument", TK_OpenNewDocument },
212 { "EstimatedFileSize", TK_EstimatedFileSize },
213
214 { "Status", TK_Status },
215 { "Pages", TK_Pages },
216 { "CurrentPage", TK_CurrentPage },
217 { "GraphicObjects", TK_GraphicObjects },
218 { "CurrentGraphicObject",TK_CurrentGraphicObject },
219 { "OLEObjects", TK_OLEObjects },
220 { "CurrentOLEObject", TK_CurrentOLEObject },
221 #if 0
222 { "STR_PRESENTATION_MINIMIZER",STR_PRESENTATION_MINIMIZER },
223 { "STR_STEPS", STR_STEPS },
224 { "STR_HELP", STR_HELP },
225 { "STR_BACK", STR_BACK },
226 { "STR_NEXT", STR_NEXT },
227 { "STR_FINISH", STR_FINISH },
228 { "STR_CANCEL", STR_CANCEL },
229 { "STR_INTRODUCTION", STR_INTRODUCTION },
230 { "STR_INTRODUCTION_T", STR_INTRODUCTION_T },
231 { "STR_CHOSE_SETTINGS", STR_CHOSE_SETTINGS },
232 { "STR_REMOVE", STR_REMOVE },
233 { "STR_GRAPHIC_OPTIMIZATION", STR_GRAPHIC_OPTIMIZATION },
234 { "STR_IMAGE_OPTIMIZATION", STR_IMAGE_OPTIMIZATION },
235 { "STR_LOSSLESS_COMPRESSION", STR_LOSSLESS_COMPRESSION },
236 { "STR_JPEG_COMPRESSION", STR_JPEG_COMPRESSION },
237 { "STR_QUALITY", STR_QUALITY },
238 { "STR_REMOVE_CROP_AREA", STR_REMOVE_CROP_AREA },
239 { "STR_IMAGE_RESOLUTION", STR_IMAGE_RESOLUTION },
240 { "STR_IMAGE_RESOLUTION_0", STR_IMAGE_RESOLUTION_0 },
241 { "STR_IMAGE_RESOLUTION_1", STR_IMAGE_RESOLUTION_1 },
242 { "STR_IMAGE_RESOLUTION_2", STR_IMAGE_RESOLUTION_2 },
243 { "STR_IMAGE_RESOLUTION_3", STR_IMAGE_RESOLUTION_3 },
244 { "STR_EMBED_LINKED_GRAPHICS", STR_EMBED_LINKED_GRAPHICS },
245 { "STR_OLE_OBJECTS", STR_OLE_OBJECTS },
246 { "STR_OLE_OPTIMIZATION", STR_OLE_OPTIMIZATION },
247 { "STR_OLE_REPLACE", STR_OLE_REPLACE },
248 { "STR_ALL_OLE_OBJECTS", STR_ALL_OLE_OBJECTS },
249 { "STR_ALIEN_OLE_OBJECTS_ONLY", STR_ALIEN_OLE_OBJECTS_ONLY },
250 { "STR__OLE_OBJECTS_DESC", STR_OLE_OBJECTS_DESC },
251 { "STR_NO_OLE_OBJECTS_DESC", STR_NO_OLE_OBJECTS_DESC },
252 { "STR_SLIDES", STR_SLIDES },
253 { "STR_CHOOSE_SLIDES", STR_CHOOSE_SLIDES },
254 { "STR_MASTER_PAGES", STR_MASTER_PAGES },
255 { "STR_DELETE_MASTER_PAGES", STR_DELETE_MASTER_PAGES },
256 { "STR_DELETE_NOTES_PAGES", STR_DELETE_NOTES_PAGES },
257 { "STR_DELETE_HIDDEN_SLIDES", STR_DELETE_HIDDEN_SLIDES },
258 { "STR_CUSTOM_SHOW", STR_CUSTOM_SHOW },
259 { "STR_SUMMARY", STR_SUMMARY },
260 { "STR_SUMMARY_TITLE", STR_SUMMARY_TITLE },
261 { "STR_PROGRESS", STR_PROGRESS },
262 { "STR_OBJECTS_OPTIMIZED", STR_OBJECTS_OPTIMIZED },
263 { "STR_APPLY_TO_CURRENT", STR_APPLY_TO_CURRENT },
264 { "STR_AUTOMATICALLY_OPEN", STR_AUTOMATICALLY_OPEN },
265 { "STR_SAVE_SETTINGS", STR_SAVE_SETTINGS },
266 { "STR_SAVE_AS", STR_SAVE_AS },
267 { "STR_DELETE_SLIDES", STR_DELETE_SLIDES },
268 { "STR_OPTIMIZE_IMAGES", STR_OPTIMIZE_IMAGES },
269 { "STR_CREATE_REPLACEMENT", STR_CREATE_REPLACEMENT },
270 { "STR_CURRENT_FILESIZE", STR_CURRENT_FILESIZE },
271 { "STR_ESTIMATED_FILESIZE", STR_ESTIMATED_FILESIZE },
272 { "STR_MB", STR_MB },
273 { "MY_SETTINGS", STR_MY_SETTINGS },
274 { "STR_DEFAULT_SESSION", STR_DEFAULT_SESSION },
275 { "STR_MODIFY_WARNING", STR_MODIFY_WARNING },
276 { "STR_YES", STR_YES },
277 { "STR_OK", STR_OK },
278 { "STR_INFO_1", STR_INFO_1 },
279 { "STR_INFO_2", STR_INFO_2 },
280 { "STR_INFO_3", STR_INFO_3 },
281 { "STR_INFO_4", STR_INFO_4 },
282 { "STR_DUPLICATING_PRESENTATION",STR_DUPLICATING_PRESENTATION },
283 { "STR_DELETING_SLIDES", STR_DELETING_SLIDES },
284 { "STR_OPTIMIZING_GRAPHICS", STR_OPTIMIZING_GRAPHICS },
285 { "STR_CREATING_OLE_REPLACEMENTS",STR_CREATING_OLE_REPLACEMENTS },
286 { "STR_FileSizeSeparator", STR_FILESIZESEPARATOR },
287 #endif
288 { "Last", TK_Last },
289 { "NotFound", TK_NotFound }
290 };
291
TKGet(const rtl::OUString & rToken)292 PPPOptimizerTokenEnum TKGet( const rtl::OUString& rToken )
293 {
294 if ( !pHashMap )
295 { // init hash map
296 ::osl::MutexGuard aGuard( getHashMapMutex() );
297 if ( !pHashMap )
298 {
299 TypeNameHashMap* pH = new TypeNameHashMap;
300 const TokenTable* pPtr = pTokenTableArray;
301 const TokenTable* pEnd = pPtr + ( sizeof( pTokenTableArray ) / sizeof( TokenTable ) );
302 for ( ; pPtr < pEnd; pPtr++ )
303 (*pH)[ pPtr->pS ] = pPtr->pE;
304 pHashMap = pH;
305 }
306 }
307 PPPOptimizerTokenEnum eRetValue = TK_NotFound;
308 int i, nLen = rToken.getLength();
309 char* pBuf = new char[ nLen + 1 ];
310 for ( i = 0; i < nLen; i++ )
311 pBuf[ i ] = (char)rToken[ i ];
312 pBuf[ i ] = 0;
313 TypeNameHashMap::iterator aHashIter( pHashMap->find( pBuf ) );
314 delete[] pBuf;
315 if ( aHashIter != pHashMap->end() )
316 eRetValue = (*aHashIter).second;
317 return eRetValue;
318 }
319
TKGet(const PPPOptimizerTokenEnum eToken)320 rtl::OUString TKGet( const PPPOptimizerTokenEnum eToken )
321 {
322 sal_uInt32 i = eToken >= TK_Last
323 ? (sal_uInt32)TK_NotFound
324 : (sal_uInt32)eToken;
325 return rtl::OUString::createFromAscii( pTokenTableArray[ i ].pS );
326 }
327