1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: pppoptimizertoken.cxx,v $
13 * This file is part of OpenOffice.org.
15 * OpenOffice.org is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License version 3
17 * only, as published by the Free Software Foundation.
19 * OpenOffice.org is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License version 3 for more details
23 * (a copy is included in the LICENSE file that accompanied this code).
25 * You should have received a copy of the GNU Lesser General Public License
26 * version 3 along with OpenOffice.org. If not, see
27 * <http://www.openoffice.org/license.html>
28 * for a copy of the LGPLv3 License.
30 ************************************************************************/
32 // MARKER(update_precomp.py): autogen include statement, do not remove
33 #include "precompiled_sdext.hxx"
35 #include "pppoptimizertoken.hxx"
36 #include <osl/mutex.hxx>
42 bool operator()( const char* s1
, const char* s2
) const
44 return strcmp( s1
, s2
) == 0;
47 typedef std::hash_map
< const char*, PPPOptimizerTokenEnum
, std::hash
<const char*>, TCheck
> TypeNameHashMap
;
48 static TypeNameHashMap
* pHashMap
= NULL
;
49 static ::osl::Mutex
& getHashMapMutex()
51 static osl::Mutex s_aHashMapProtection
;
52 return s_aHashMapProtection
;
58 PPPOptimizerTokenEnum pE
;
61 static const TokenTable pTokenTableArray
[] =
63 { "rdmNavi", TK_rdmNavi
},
64 { "lnNavSep1", TK_lnNavSep1
},
65 { "lnNavSep2", TK_lnNavSep2
},
66 { "btnNavHelp", TK_btnNavHelp
},
67 { "btnNavBack", TK_btnNavBack
},
68 { "btnNavNext", TK_btnNavNext
},
69 { "btnNavFinish", TK_btnNavFinish
},
70 { "btnNavCancel", TK_btnNavCancel
},
72 { "FixedText0Pg0", TK_FixedText0Pg0
},
73 { "FixedText1Pg0", TK_FixedText1Pg0
},
74 { "Separator1Pg0", TK_Separator1Pg0
},
75 { "FixedText2Pg0", TK_FixedText2Pg0
},
76 { "ListBox0Pg0", TK_ListBox0Pg0
},
77 { "Button0Pg0", TK_Button0Pg0
},
78 { "RadioButton0Pg1", TK_RadioButton0Pg1
},
79 { "RadioButton1Pg1", TK_RadioButton1Pg1
},
80 { "FixedText0Pg1", TK_FixedText0Pg1
},
81 { "CheckBox1Pg1", TK_CheckBox1Pg1
},
82 { "FixedText1Pg1", TK_FixedText1Pg1
},
83 { "FixedText2Pg1", TK_FixedText2Pg1
},
84 { "FormattedField0Pg1", TK_FormattedField0Pg1
},
85 { "ComboBox0Pg1", TK_ComboBox0Pg1
},
86 { "CheckBox2Pg1", TK_CheckBox2Pg1
},
87 { "FixedText0Pg2", TK_FixedText0Pg2
},
88 { "FixedText1Pg2", TK_FixedText1Pg2
},
89 { "CheckBox0Pg2", TK_CheckBox0Pg2
},
90 { "RadioButton0Pg2", TK_RadioButton0Pg2
},
91 { "RadioButton1Pg2", TK_RadioButton1Pg2
},
92 { "FixedText0Pg3", TK_FixedText0Pg3
},
93 { "CheckBox0Pg3", TK_CheckBox0Pg3
},
94 { "FixedText1Pg3", TK_FixedText1Pg3
},
95 { "CheckBox1Pg3", TK_CheckBox1Pg3
},
96 { "FixedText2Pg3", TK_FixedText2Pg3
},
97 { "CheckBox2Pg3", TK_CheckBox2Pg3
},
98 { "CheckBox3Pg3", TK_CheckBox3Pg3
},
99 { "ListBox0Pg3", TK_ListBox0Pg3
},
100 { "Separator0Pg4", TK_Separator0Pg4
},
101 { "RadioButton0Pg4", TK_RadioButton0Pg4
},
102 { "RadioButton1Pg4", TK_RadioButton1Pg4
},
103 { "Separator1Pg4", TK_Separator1Pg4
},
104 { "FixedText0Pg4", TK_FixedText0Pg4
},
105 { "FixedText1Pg4", TK_FixedText1Pg4
},
106 { "FixedText2Pg4", TK_FixedText2Pg4
},
107 { "FixedText3Pg4", TK_FixedText3Pg4
},
108 { "FixedText4Pg4", TK_FixedText4Pg4
},
109 { "FixedText5Pg4", TK_FixedText5Pg4
},
110 { "FixedText6Pg4", TK_FixedText6Pg4
},
111 { "FixedText7Pg4", TK_FixedText7Pg4
},
112 { "FixedText8Pg4", TK_FixedText8Pg4
},
113 { "CheckBox1Pg4", TK_CheckBox1Pg4
},
114 { "ComboBox0Pg4", TK_ComboBox0Pg4
},
116 { "_blank", TK__blank
},
117 { "_self", TK__self
},
118 { "Activated", TK_Activated
},
119 { "Align", TK_Align
},
120 { "Alpha", TK_Alpha
},
121 { "Animated", TK_Animated
},
122 { "Background", TK_Background
},
123 { "BitmapPath", TK_BitmapPath
},
124 { "Border", TK_Border
},
125 { "Closeable", TK_Closeable
},
126 { "ColorMode", TK_ColorMode
},
127 { "Complete", TK_Complete
},
128 { "Compression", TK_Compression
},
129 { "CurrentItemID", TK_CurrentItemID
},
130 { "DefaultButton", TK_DefaultButton
},
131 { "DocumentService", TK_DocumentService
},
132 { "Dropdown", TK_Dropdown
},
133 { "EffectiveValue", TK_EffectiveValue
},
134 { "EffectiveMin", TK_EffectiveMin
},
135 { "EffectiveMax", TK_EffectiveMax
},
136 { "Enabled", TK_Enabled
},
137 { "Extensions", TK_Extensions
},
138 { "FileSizeDestination",TK_FileSizeDestination
},
139 { "FileSizeSource", TK_FileSizeSource
},
140 { "FillBitmap", TK_FillBitmap
},
141 { "FillBitmapLogicalSize",TK_FillBitmapLogicalSize
},
142 { "FillBitmapMode", TK_FillBitmapMode
},
143 { "FillBitmapSizeX", TK_FillBitmapSizeX
},
144 { "FillBitmapSizeY", TK_FillBitmapSizeY
},
145 { "FillBitmapURL", TK_FillBitmapURL
},
146 { "FillStyle", TK_FillStyle
},
147 { "FilterData", TK_FilterData
},
148 { "FilterName", TK_FilterName
},
149 { "Flags", TK_Flags
},
150 { "FontDescriptor", TK_FontDescriptor
},
151 { "Graphic", TK_Graphic
},
152 { "GraphicCrop", TK_GraphicCrop
},
153 { "GraphicCropLogic", TK_GraphicCropLogic
},
154 { "GraphicURL", TK_GraphicURL
},
155 { "GraphicStreamURL", TK_GraphicStreamURL
},
156 { "Height", TK_Height
},
157 { "HelpFile", TK_HelpFile
},
158 { "Hidden", TK_Hidden
},
160 { "ImageURL", TK_ImageURL
},
161 { "InformationDialog", TK_InformationDialog
},
162 { "InputStream", TK_InputStream
},
163 { "Interlaced", TK_Interlaced
},
164 { "IsInternal", TK_IsInternal
},
165 { "Label", TK_Label
},
166 { "LineCount", TK_LineCount
},
167 { "LogicalHeight", TK_LogicalHeight
},
168 { "LogicalWidth", TK_LogicalWidth
},
169 { "LogicalSize", TK_LogicalSize
},
170 { "MimeType", TK_MimeType
},
171 { "Moveable", TK_Moveable
},
172 { "MultiLine", TK_MultiLine
},
173 { "MultiSelection", TK_MultiSelection
},
175 { "Orientation", TK_Orientation
},
176 { "OutputStream", TK_OutputStream
},
177 { "PixelHeight", TK_PixelHeight
},
178 { "PixelWidth", TK_PixelWidth
},
179 { "PositionX", TK_PositionX
},
180 { "PositionY", TK_PositionY
},
181 { "Progress", TK_Progress
},
182 { "ProgressValue", TK_ProgressValue
},
183 { "ProgressValueMax", TK_ProgressValueMax
},
184 { "ProgressValueMin", TK_ProgressValueMin
},
185 { "PushButtonType", TK_PushButtonType
},
186 { "Quality", TK_Quality
},
187 { "ReadOnly", TK_ReadOnly
},
188 { "Repeat", TK_Repeat
},
189 { "ScaleImage", TK_ScaleImage
},
190 { "SelectedItems", TK_SelectedItems
},
191 { "Settings", TK_Settings
},
192 { "Size100thMM", TK_Size100thMM
},
193 { "SizePixel", TK_SizePixel
},
196 { "State", TK_State
},
197 { "StatusDispatcher", TK_StatusDispatcher
},
198 { "StringItemList", TK_StringItemList
},
199 { "Strings", TK_Strings
},
200 { "TabIndex", TK_TabIndex
},
201 { "Template", TK_Template
},
203 { "Title", TK_Title
},
204 { "Transparent", TK_Transparent
},
206 { "UIName", TK_UIName
},
207 { "Value", TK_Value
},
208 { "Width", TK_Width
},
209 { "ZOrder", TK_ZOrder
},
211 { "LastUsedSettings", TK_LastUsedSettings
},
212 { "Settings/Templates", TK_Settings_Templates
},
213 { "Settings/Templates/",TK_Settings_Templates_
},
214 { "JPEGCompression", TK_JPEGCompression
},
215 { "JPEGQuality", TK_JPEGQuality
},
216 { "RemoveCropArea", TK_RemoveCropArea
},
217 { "ImageResolution", TK_ImageResolution
},
218 { "EmbedLinkedGraphics",TK_EmbedLinkedGraphics
},
219 { "OLEOptimization", TK_OLEOptimization
},
220 { "OLEOptimizationType",TK_OLEOptimizationType
},
221 { "DeleteUnusedMasterPages", TK_DeleteUnusedMasterPages
},
222 { "DeleteHiddenSlides", TK_DeleteHiddenSlides
},
223 { "DeleteNotesPages", TK_DeleteNotesPages
},
224 { "CustomShowName", TK_CustomShowName
},
225 { "SaveAs", TK_SaveAs
},
226 { "SaveAsURL", TK_SaveAsURL
},
227 { "OpenNewDocument", TK_OpenNewDocument
},
228 { "EstimatedFileSize", TK_EstimatedFileSize
},
230 { "Status", TK_Status
},
231 { "Pages", TK_Pages
},
232 { "CurrentPage", TK_CurrentPage
},
233 { "GraphicObjects", TK_GraphicObjects
},
234 { "CurrentGraphicObject",TK_CurrentGraphicObject
},
235 { "OLEObjects", TK_OLEObjects
},
236 { "CurrentOLEObject", TK_CurrentOLEObject
},
238 { "STR_SUN_OPTIMIZATION_WIZARD2",STR_SUN_OPTIMIZATION_WIZARD2
},
239 { "STR_STEPS", STR_STEPS
},
240 { "STR_HELP", STR_HELP
},
241 { "STR_BACK", STR_BACK
},
242 { "STR_NEXT", STR_NEXT
},
243 { "STR_FINISH", STR_FINISH
},
244 { "STR_CANCEL", STR_CANCEL
},
245 { "STR_INTRODUCTION", STR_INTRODUCTION
},
246 { "STR_INTRODUCTION_T", STR_INTRODUCTION_T
},
247 { "STR_CHOSE_SETTINGS", STR_CHOSE_SETTINGS
},
248 { "STR_REMOVE", STR_REMOVE
},
249 { "STR_GRAPHIC_OPTIMIZATION", STR_GRAPHIC_OPTIMIZATION
},
250 { "STR_IMAGE_OPTIMIZATION", STR_IMAGE_OPTIMIZATION
},
251 { "STR_LOSSLESS_COMPRESSION", STR_LOSSLESS_COMPRESSION
},
252 { "STR_JPEG_COMPRESSION", STR_JPEG_COMPRESSION
},
253 { "STR_QUALITY", STR_QUALITY
},
254 { "STR_REMOVE_CROP_AREA", STR_REMOVE_CROP_AREA
},
255 { "STR_IMAGE_RESOLUTION", STR_IMAGE_RESOLUTION
},
256 { "STR_IMAGE_RESOLUTION_0", STR_IMAGE_RESOLUTION_0
},
257 { "STR_IMAGE_RESOLUTION_1", STR_IMAGE_RESOLUTION_1
},
258 { "STR_IMAGE_RESOLUTION_2", STR_IMAGE_RESOLUTION_2
},
259 { "STR_IMAGE_RESOLUTION_3", STR_IMAGE_RESOLUTION_3
},
260 { "STR_EMBED_LINKED_GRAPHICS", STR_EMBED_LINKED_GRAPHICS
},
261 { "STR_OLE_OBJECTS", STR_OLE_OBJECTS
},
262 { "STR_OLE_OPTIMIZATION", STR_OLE_OPTIMIZATION
},
263 { "STR_OLE_REPLACE", STR_OLE_REPLACE
},
264 { "STR_ALL_OLE_OBJECTS", STR_ALL_OLE_OBJECTS
},
265 { "STR_ALIEN_OLE_OBJECTS_ONLY", STR_ALIEN_OLE_OBJECTS_ONLY
},
266 { "STR__OLE_OBJECTS_DESC", STR_OLE_OBJECTS_DESC
},
267 { "STR_NO_OLE_OBJECTS_DESC", STR_NO_OLE_OBJECTS_DESC
},
268 { "STR_SLIDES", STR_SLIDES
},
269 { "STR_CHOOSE_SLIDES", STR_CHOOSE_SLIDES
},
270 { "STR_MASTER_PAGES", STR_MASTER_PAGES
},
271 { "STR_DELETE_MASTER_PAGES", STR_DELETE_MASTER_PAGES
},
272 { "STR_DELETE_NOTES_PAGES", STR_DELETE_NOTES_PAGES
},
273 { "STR_DELETE_HIDDEN_SLIDES", STR_DELETE_HIDDEN_SLIDES
},
274 { "STR_CUSTOM_SHOW", STR_CUSTOM_SHOW
},
275 { "STR_SUMMARY", STR_SUMMARY
},
276 { "STR_SUMMARY_TITLE", STR_SUMMARY_TITLE
},
277 { "STR_PROGRESS", STR_PROGRESS
},
278 { "STR_OBJECTS_OPTIMIZED", STR_OBJECTS_OPTIMIZED
},
279 { "STR_APPLY_TO_CURRENT", STR_APPLY_TO_CURRENT
},
280 { "STR_AUTOMATICALLY_OPEN", STR_AUTOMATICALLY_OPEN
},
281 { "STR_SAVE_SETTINGS", STR_SAVE_SETTINGS
},
282 { "STR_SAVE_AS", STR_SAVE_AS
},
283 { "STR_DELETE_SLIDES", STR_DELETE_SLIDES
},
284 { "STR_OPTIMIZE_IMAGES", STR_OPTIMIZE_IMAGES
},
285 { "STR_CREATE_REPLACEMENT", STR_CREATE_REPLACEMENT
},
286 { "STR_CURRENT_FILESIZE", STR_CURRENT_FILESIZE
},
287 { "STR_ESTIMATED_FILESIZE", STR_ESTIMATED_FILESIZE
},
288 { "STR_MB", STR_MB
},
289 { "MY_SETTINGS", STR_MY_SETTINGS
},
290 { "STR_DEFAULT_SESSION", STR_DEFAULT_SESSION
},
291 { "STR_MODIFY_WARNING", STR_MODIFY_WARNING
},
292 { "STR_YES", STR_YES
},
293 { "STR_ABOUT2", STR_ABOUT2
},
294 { "STR_ABOUT_VERSION2", STR_ABOUT_VERSION2
},
295 { "STR_ABOUT_PRN", STR_ABOUT_PRN
},
296 { "STR_OK", STR_OK
},
297 { "STR_INFO_1", STR_INFO_1
},
298 { "STR_INFO_2", STR_INFO_2
},
299 { "STR_INFO_3", STR_INFO_3
},
300 { "STR_INFO_4", STR_INFO_4
},
301 { "STR_DUPLICATING_PRESENTATION",STR_DUPLICATING_PRESENTATION
},
302 { "STR_DELETING_SLIDES", STR_DELETING_SLIDES
},
303 { "STR_OPTIMIZING_GRAPHICS", STR_OPTIMIZING_GRAPHICS
},
304 { "STR_CREATING_OLE_REPLACEMENTS",STR_CREATING_OLE_REPLACEMENTS
},
305 { "STR_FileSizeSeparator", STR_FILESIZESEPARATOR
},
308 { "NotFound", TK_NotFound
}
311 PPPOptimizerTokenEnum
TKGet( const rtl::OUString
& rToken
)
315 ::osl::MutexGuard
aGuard( getHashMapMutex() );
318 TypeNameHashMap
* pH
= new TypeNameHashMap
;
319 const TokenTable
* pPtr
= pTokenTableArray
;
320 const TokenTable
* pEnd
= pPtr
+ ( sizeof( pTokenTableArray
) / sizeof( TokenTable
) );
321 for ( ; pPtr
< pEnd
; pPtr
++ )
322 (*pH
)[ pPtr
->pS
] = pPtr
->pE
;
326 PPPOptimizerTokenEnum eRetValue
= TK_NotFound
;
327 int i
, nLen
= rToken
.getLength();
328 char* pBuf
= new char[ nLen
+ 1 ];
329 for ( i
= 0; i
< nLen
; i
++ )
330 pBuf
[ i
] = (char)rToken
[ i
];
332 TypeNameHashMap::iterator
aHashIter( pHashMap
->find( pBuf
) );
334 if ( aHashIter
!= pHashMap
->end() )
335 eRetValue
= (*aHashIter
).second
;
339 rtl::OUString
TKGet( const PPPOptimizerTokenEnum eToken
)
341 sal_uInt32 i
= eToken
>= TK_Last
342 ? (sal_uInt32
)TK_NotFound
343 : (sal_uInt32
)eToken
;
344 return rtl::OUString::createFromAscii( pTokenTableArray
[ i
].pS
);