1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include "pppoptimizertoken.hxx"
22 #include <osl/mutex.hxx>
23 #include <sal/macros.h>
24 #include <unordered_map>
27 typedef std::unordered_map
< const char*, PPPOptimizerTokenEnum
, rtl::CStringHash
, rtl::CStringEqual
> TypeNameHashMap
;
28 static TypeNameHashMap
* pHashMap
= nullptr;
29 static ::osl::Mutex
& getHashMapMutex()
31 static osl::Mutex s_aHashMapProtection
;
32 return s_aHashMapProtection
;
38 PPPOptimizerTokenEnum
const pE
;
41 static const TokenTable pTokenTableArray
[] =
43 { "rdmNavi", TK_rdmNavi
},
44 { "btnNavBack", TK_btnNavBack
},
45 { "btnNavNext", TK_btnNavNext
},
46 { "btnNavFinish", TK_btnNavFinish
},
47 { "btnNavCancel", TK_btnNavCancel
},
49 { "Button0Pg0", TK_Button0Pg0
},
50 { "RadioButton0Pg1", TK_RadioButton0Pg1
},
51 { "RadioButton1Pg1", TK_RadioButton1Pg1
},
52 { "CheckBox1Pg1", TK_CheckBox1Pg1
},
53 { "CheckBox2Pg1", TK_CheckBox2Pg1
},
54 { "CheckBox0Pg2", TK_CheckBox0Pg2
},
55 { "RadioButton0Pg2", TK_RadioButton0Pg2
},
56 { "RadioButton1Pg2", TK_RadioButton1Pg2
},
57 { "CheckBox0Pg3", TK_CheckBox0Pg3
},
58 { "CheckBox1Pg3", TK_CheckBox1Pg3
},
59 { "CheckBox2Pg3", TK_CheckBox2Pg3
},
60 { "CheckBox3Pg3", TK_CheckBox3Pg3
},
61 { "RadioButton0Pg4", TK_RadioButton0Pg4
},
62 { "RadioButton1Pg4", TK_RadioButton1Pg4
},
63 { "CheckBox1Pg4", TK_CheckBox1Pg4
},
65 { "DocumentService", TK_DocumentService
},
66 { "FileSizeDestination",TK_FileSizeDestination
},
67 { "FileSizeSource", TK_FileSizeSource
},
68 { "FilterName", TK_FilterName
},
69 { "Flags", TK_Flags
},
70 { "InformationDialog", TK_InformationDialog
},
72 { "Progress", TK_Progress
},
73 { "Settings", TK_Settings
},
74 { "StatusDispatcher", TK_StatusDispatcher
},
76 { "UIName", TK_UIName
},
78 { "JPEGCompression", TK_JPEGCompression
},
79 { "JPEGQuality", TK_JPEGQuality
},
80 { "RemoveCropArea", TK_RemoveCropArea
},
81 { "ImageResolution", TK_ImageResolution
},
82 { "EmbedLinkedGraphics",TK_EmbedLinkedGraphics
},
83 { "OLEOptimization", TK_OLEOptimization
},
84 { "OLEOptimizationType",TK_OLEOptimizationType
},
85 { "DeleteUnusedMasterPages", TK_DeleteUnusedMasterPages
},
86 { "DeleteHiddenSlides", TK_DeleteHiddenSlides
},
87 { "DeleteNotesPages", TK_DeleteNotesPages
},
88 { "CustomShowName", TK_CustomShowName
},
89 { "SaveAs", TK_SaveAs
},
90 { "SaveAsURL", TK_SaveAsURL
},
91 { "OpenNewDocument", TK_OpenNewDocument
},
92 { "EstimatedFileSize", TK_EstimatedFileSize
},
94 { "Status", TK_Status
},
95 { "Pages", TK_Pages
},
97 { "STR_SUN_OPTIMIZATION_WIZARD2",STR_SUN_OPTIMIZATION_WIZARD2
},
98 { "STR_STEPS", STR_STEPS
},
99 { "STR_BACK", STR_BACK
},
100 { "STR_NEXT", STR_NEXT
},
101 { "STR_FINISH", STR_FINISH
},
102 { "STR_CANCEL", STR_CANCEL
},
103 { "STR_INTRODUCTION", STR_INTRODUCTION
},
104 { "STR_INTRODUCTION_T", STR_INTRODUCTION_T
},
105 { "STR_CHOSE_SETTINGS", STR_CHOSE_SETTINGS
},
106 { "STR_REMOVE", STR_REMOVE
},
107 { "STR_GRAPHIC_OPTIMIZATION", STR_GRAPHIC_OPTIMIZATION
},
108 { "STR_IMAGE_OPTIMIZATION", STR_IMAGE_OPTIMIZATION
},
109 { "STR_LOSSLESS_COMPRESSION", STR_LOSSLESS_COMPRESSION
},
110 { "STR_JPEG_COMPRESSION", STR_JPEG_COMPRESSION
},
111 { "STR_QUALITY", STR_QUALITY
},
112 { "STR_REMOVE_CROP_AREA", STR_REMOVE_CROP_AREA
},
113 { "STR_IMAGE_RESOLUTION", STR_IMAGE_RESOLUTION
},
114 { "STR_IMAGE_RESOLUTION_0", STR_IMAGE_RESOLUTION_0
},
115 { "STR_IMAGE_RESOLUTION_1", STR_IMAGE_RESOLUTION_1
},
116 { "STR_IMAGE_RESOLUTION_2", STR_IMAGE_RESOLUTION_2
},
117 { "STR_IMAGE_RESOLUTION_3", STR_IMAGE_RESOLUTION_3
},
118 { "STR_EMBED_LINKED_GRAPHICS", STR_EMBED_LINKED_GRAPHICS
},
119 { "STR_OLE_OBJECTS", STR_OLE_OBJECTS
},
120 { "STR_OLE_OPTIMIZATION", STR_OLE_OPTIMIZATION
},
121 { "STR_OLE_REPLACE", STR_OLE_REPLACE
},
122 { "STR_ALL_OLE_OBJECTS", STR_ALL_OLE_OBJECTS
},
123 { "STR_ALIEN_OLE_OBJECTS_ONLY", STR_ALIEN_OLE_OBJECTS_ONLY
},
124 { "STR__OLE_OBJECTS_DESC", STR_OLE_OBJECTS_DESC
},
125 { "STR_NO_OLE_OBJECTS_DESC", STR_NO_OLE_OBJECTS_DESC
},
126 { "STR_SLIDES", STR_SLIDES
},
127 { "STR_CHOOSE_SLIDES", STR_CHOOSE_SLIDES
},
128 { "STR_DELETE_MASTER_PAGES", STR_DELETE_MASTER_PAGES
},
129 { "STR_DELETE_NOTES_PAGES", STR_DELETE_NOTES_PAGES
},
130 { "STR_DELETE_HIDDEN_SLIDES", STR_DELETE_HIDDEN_SLIDES
},
131 { "STR_CUSTOM_SHOW", STR_CUSTOM_SHOW
},
132 { "STR_SUMMARY", STR_SUMMARY
},
133 { "STR_SUMMARY_TITLE", STR_SUMMARY_TITLE
},
134 { "STR_APPLY_TO_CURRENT", STR_APPLY_TO_CURRENT
},
135 { "STR_AUTOMATICALLY_OPEN", STR_AUTOMATICALLY_OPEN
},
136 { "STR_SAVE_SETTINGS", STR_SAVE_SETTINGS
},
137 { "STR_SAVE_AS", STR_SAVE_AS
},
138 { "STR_DELETE_SLIDES", STR_DELETE_SLIDES
},
139 { "STR_OPTIMIZE_IMAGES", STR_OPTIMIZE_IMAGES
},
140 { "STR_CREATE_REPLACEMENT", STR_CREATE_REPLACEMENT
},
141 { "STR_CURRENT_FILESIZE", STR_CURRENT_FILESIZE
},
142 { "STR_ESTIMATED_FILESIZE", STR_ESTIMATED_FILESIZE
},
143 { "MY_SETTINGS", STR_MY_SETTINGS
},
144 { "STR_OK", STR_OK
},
145 { "STR_INFO_1", STR_INFO_1
},
146 { "STR_INFO_2", STR_INFO_2
},
147 { "STR_INFO_3", STR_INFO_3
},
148 { "STR_INFO_4", STR_INFO_4
},
149 { "STR_DUPLICATING_PRESENTATION",STR_DUPLICATING_PRESENTATION
},
150 { "STR_DELETING_SLIDES", STR_DELETING_SLIDES
},
151 { "STR_OPTIMIZING_GRAPHICS", STR_OPTIMIZING_GRAPHICS
},
152 { "STR_CREATING_OLE_REPLACEMENTS",STR_CREATING_OLE_REPLACEMENTS
},
153 { "STR_FileSizeSeparator", STR_FILESIZESEPARATOR
},
154 { "STR_FILENAME_SUFFIX", STR_FILENAME_SUFFIX
},
155 { "STR_WARN_UNSAVED_PRESENTATION", STR_WARN_UNSAVED_PRESENTATION
},
158 { "NotFound", TK_NotFound
}
161 PPPOptimizerTokenEnum
TKGet( const OUString
& rToken
)
165 ::osl::MutexGuard
aGuard( getHashMapMutex() );
168 TypeNameHashMap
* pH
= new TypeNameHashMap
;
169 const TokenTable
* pPtr
= pTokenTableArray
;
170 const TokenTable
* pEnd
= pPtr
+ SAL_N_ELEMENTS( pTokenTableArray
);
171 for ( ; pPtr
< pEnd
; pPtr
++ )
172 (*pH
)[ pPtr
->pS
] = pPtr
->pE
;
176 PPPOptimizerTokenEnum eRetValue
= TK_NotFound
;
177 int i
, nLen
= rToken
.getLength();
178 std::unique_ptr
<char[]> pBuf(new char[ nLen
+ 1 ]);
179 for ( i
= 0; i
< nLen
; i
++ )
180 pBuf
[ i
] = static_cast<char>(rToken
[ i
]);
182 TypeNameHashMap::iterator
aHashIter( pHashMap
->find( pBuf
.get() ) );
183 if ( aHashIter
!= pHashMap
->end() )
184 eRetValue
= (*aHashIter
).second
;
188 OUString
TKGet( const PPPOptimizerTokenEnum eToken
)
190 return OUString::createFromAscii( pTokenTableArray
[ eToken
].pS
);
193 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */