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"
23 #include <sal/macros.h>
24 #include <unordered_map>
27 typedef std::unordered_map
< const char*, PPPOptimizerTokenEnum
, rtl::CStringHash
, rtl::CStringEqual
> TypeNameHashMap
;
34 PPPOptimizerTokenEnum pE
;
39 const TokenTable pTokenTableArray
[] =
41 { "btnNavFinish", TK_btnNavFinish
},
43 { "DocumentService", TK_DocumentService
},
44 { "FileSizeDestination",TK_FileSizeDestination
},
45 { "FileSizeSource", TK_FileSizeSource
},
46 { "FilterName", TK_FilterName
},
47 { "Flags", TK_Flags
},
48 { "DocumentFrame", TK_DocumentFrame
},
49 { "DialogParentWindow", TK_DialogParentWindow
},
51 { "Progress", TK_Progress
},
52 { "Settings", TK_Settings
},
53 { "StatusDispatcher", TK_StatusDispatcher
},
55 { "UIName", TK_UIName
},
57 { "JPEGCompression", TK_JPEGCompression
},
58 { "JPEGQuality", TK_JPEGQuality
},
59 { "RemoveCropArea", TK_RemoveCropArea
},
60 { "ImageResolution", TK_ImageResolution
},
61 { "EmbedLinkedGraphics",TK_EmbedLinkedGraphics
},
62 { "OLEOptimization", TK_OLEOptimization
},
63 { "OLEOptimizationType",TK_OLEOptimizationType
},
64 { "DeleteUnusedMasterPages", TK_DeleteUnusedMasterPages
},
65 { "DeleteHiddenSlides", TK_DeleteHiddenSlides
},
66 { "DeleteNotesPages", TK_DeleteNotesPages
},
67 { "CustomShowName", TK_CustomShowName
},
68 { "SaveAs", TK_SaveAs
},
69 { "SaveAsURL", TK_SaveAsURL
},
70 { "OpenNewDocument", TK_OpenNewDocument
},
71 { "EstimatedFileSize", TK_EstimatedFileSize
},
73 { "Status", TK_Status
},
74 { "Pages", TK_Pages
},
76 { "STR_SUN_OPTIMIZATION_WIZARD2",STR_SUN_OPTIMIZATION_WIZARD2
},
77 { "STR_INTRODUCTION", STR_INTRODUCTION
},
78 { "STR_IMAGE_OPTIMIZATION", STR_IMAGE_OPTIMIZATION
},
79 { "STR_OLE_OBJECTS", STR_OLE_OBJECTS
},
80 { "STR_OLE_OBJECTS_DESC", STR_OLE_OBJECTS_DESC
},
81 { "STR_NO_OLE_OBJECTS_DESC", STR_NO_OLE_OBJECTS_DESC
},
82 { "STR_SLIDES", STR_SLIDES
},
83 { "STR_SUMMARY", STR_SUMMARY
},
84 { "STR_DELETE_SLIDES", STR_DELETE_SLIDES
},
85 { "STR_OPTIMIZE_IMAGES", STR_OPTIMIZE_IMAGES
},
86 { "STR_CREATE_REPLACEMENT", STR_CREATE_REPLACEMENT
},
87 { "MY_SETTINGS", STR_MY_SETTINGS
},
89 { "STR_INFO_PRIMARY", STR_INFO_PRIMARY
},
90 { "STR_INFO_SECONDARY_1", STR_INFO_SECONDARY_1
},
91 { "STR_INFO_SECONDARY_2", STR_INFO_SECONDARY_2
},
92 { "STR_INFO_SECONDARY_3", STR_INFO_SECONDARY_3
},
93 { "STR_INFO_SECONDARY_4", STR_INFO_SECONDARY_4
},
94 { "STR_DUPLICATING_PRESENTATION",STR_DUPLICATING_PRESENTATION
},
95 { "STR_DELETING_SLIDES", STR_DELETING_SLIDES
},
96 { "STR_OPTIMIZING_GRAPHICS", STR_OPTIMIZING_GRAPHICS
},
97 { "STR_CREATING_OLE_REPLACEMENTS",STR_CREATING_OLE_REPLACEMENTS
},
98 { "STR_FileSizeSeparator", STR_FILESIZESEPARATOR
},
99 { "STR_FILENAME_SUFFIX", STR_FILENAME_SUFFIX
},
100 { "STR_WARN_UNSAVED_PRESENTATION", STR_WARN_UNSAVED_PRESENTATION
},
103 { "NotFound", TK_NotFound
}
106 static TypeNameHashMap
* createHashMap()
108 TypeNameHashMap
* pH
= new TypeNameHashMap
;
109 const TokenTable
* pPtr
= pTokenTableArray
;
110 const TokenTable
* pEnd
= pPtr
+ SAL_N_ELEMENTS( pTokenTableArray
);
111 for ( ; pPtr
< pEnd
; pPtr
++ )
112 (*pH
)[ pPtr
->pS
] = pPtr
->pE
;
116 PPPOptimizerTokenEnum
TKGet( std::u16string_view rToken
)
118 static TypeNameHashMap
* pHashMap
= createHashMap();
119 PPPOptimizerTokenEnum eRetValue
= TK_NotFound
;
120 size_t i
, nLen
= rToken
.size();
121 std::unique_ptr
<char[]> pBuf(new char[ nLen
+ 1 ]);
122 for ( i
= 0; i
< nLen
; i
++ )
123 pBuf
[ i
] = static_cast<char>(rToken
[ i
]);
125 TypeNameHashMap::iterator
aHashIter( pHashMap
->find( pBuf
.get() ) );
126 if ( aHashIter
!= pHashMap
->end() )
127 eRetValue
= (*aHashIter
).second
;
131 OUString
TKGet( const PPPOptimizerTokenEnum eToken
)
133 return OUString::createFromAscii( pTokenTableArray
[ eToken
].pS
);
136 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */