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