summaryrefslogtreecommitdiffstats
path: root/sdext/source/minimizer/pppoptimizertoken.cxx
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:06:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:06:44 +0000
commited5640d8b587fbcfed7dd7967f3de04b37a76f26 (patch)
tree7a5f7c6c9d02226d7471cb3cc8fbbf631b415303 /sdext/source/minimizer/pppoptimizertoken.cxx
parentInitial commit. (diff)
downloadlibreoffice-cb75148ebd0135178ff46f89a30139c44f8d2040.tar.xz
libreoffice-cb75148ebd0135178ff46f89a30139c44f8d2040.zip
Adding upstream version 4:7.4.7.upstream/4%7.4.7upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sdext/source/minimizer/pppoptimizertoken.cxx')
-rw-r--r--sdext/source/minimizer/pppoptimizertoken.cxx198
1 files changed, 198 insertions, 0 deletions
diff --git a/sdext/source/minimizer/pppoptimizertoken.cxx b/sdext/source/minimizer/pppoptimizertoken.cxx
new file mode 100644
index 000000000..1e020bc02
--- /dev/null
+++ b/sdext/source/minimizer/pppoptimizertoken.cxx
@@ -0,0 +1,198 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+
+#include "pppoptimizertoken.hxx"
+
+#include <sal/macros.h>
+#include <unordered_map>
+#include <memory>
+#include <mutex>
+
+typedef std::unordered_map< const char*, PPPOptimizerTokenEnum, rtl::CStringHash, rtl::CStringEqual> TypeNameHashMap;
+static TypeNameHashMap* pHashMap = nullptr;
+static std::mutex& getHashMapMutex()
+{
+ static std::mutex s_aHashMapProtection;
+ return s_aHashMapProtection;
+}
+
+namespace {
+
+struct TokenTable
+{
+ const char* pS;
+ PPPOptimizerTokenEnum pE;
+};
+
+}
+
+const TokenTable pTokenTableArray[] =
+{
+ { "rdmNavi", TK_rdmNavi },
+ { "btnNavBack", TK_btnNavBack },
+ { "btnNavNext", TK_btnNavNext },
+ { "btnNavFinish", TK_btnNavFinish },
+ { "btnNavCancel", TK_btnNavCancel },
+
+ { "Button0Pg0", TK_Button0Pg0 },
+ { "RadioButton0Pg1", TK_RadioButton0Pg1 },
+ { "RadioButton1Pg1", TK_RadioButton1Pg1 },
+ { "CheckBox1Pg1", TK_CheckBox1Pg1 },
+ { "CheckBox2Pg1", TK_CheckBox2Pg1 },
+ { "CheckBox0Pg2", TK_CheckBox0Pg2 },
+ { "RadioButton0Pg2", TK_RadioButton0Pg2 },
+ { "RadioButton1Pg2", TK_RadioButton1Pg2 },
+ { "CheckBox0Pg3", TK_CheckBox0Pg3 },
+ { "CheckBox1Pg3", TK_CheckBox1Pg3 },
+ { "CheckBox2Pg3", TK_CheckBox2Pg3 },
+ { "CheckBox3Pg3", TK_CheckBox3Pg3 },
+ { "RadioButton0Pg4", TK_RadioButton0Pg4 },
+ { "RadioButton1Pg4", TK_RadioButton1Pg4 },
+ { "CheckBox1Pg4", TK_CheckBox1Pg4 },
+
+ { "DocumentService", TK_DocumentService },
+ { "FileSizeDestination",TK_FileSizeDestination },
+ { "FileSizeSource", TK_FileSizeSource },
+ { "FilterName", TK_FilterName },
+ { "Flags", TK_Flags },
+ { "InformationDialog", TK_InformationDialog },
+ { "Name", TK_Name },
+ { "Progress", TK_Progress },
+ { "Settings", TK_Settings },
+ { "StatusDispatcher", TK_StatusDispatcher },
+ { "Type", TK_Type },
+ { "UIName", TK_UIName },
+
+ { "JPEGCompression", TK_JPEGCompression },
+ { "JPEGQuality", TK_JPEGQuality },
+ { "RemoveCropArea", TK_RemoveCropArea },
+ { "ImageResolution", TK_ImageResolution },
+ { "EmbedLinkedGraphics",TK_EmbedLinkedGraphics },
+ { "OLEOptimization", TK_OLEOptimization },
+ { "OLEOptimizationType",TK_OLEOptimizationType },
+ { "DeleteUnusedMasterPages", TK_DeleteUnusedMasterPages },
+ { "DeleteHiddenSlides", TK_DeleteHiddenSlides },
+ { "DeleteNotesPages", TK_DeleteNotesPages },
+ { "CustomShowName", TK_CustomShowName },
+ { "SaveAs", TK_SaveAs },
+ { "SaveAsURL", TK_SaveAsURL },
+ { "OpenNewDocument", TK_OpenNewDocument },
+ { "EstimatedFileSize", TK_EstimatedFileSize },
+
+ { "Status", TK_Status },
+ { "Pages", TK_Pages },
+
+ { "STR_SUN_OPTIMIZATION_WIZARD2",STR_SUN_OPTIMIZATION_WIZARD2 },
+ { "STR_STEPS", STR_STEPS },
+ { "STR_BACK", STR_BACK },
+ { "STR_NEXT", STR_NEXT },
+ { "STR_FINISH", STR_FINISH },
+ { "STR_CANCEL", STR_CANCEL },
+ { "STR_INTRODUCTION", STR_INTRODUCTION },
+ { "STR_INTRODUCTION_T", STR_INTRODUCTION_T },
+ { "STR_CHOSE_SETTINGS", STR_CHOSE_SETTINGS },
+ { "STR_REMOVE", STR_REMOVE },
+ { "STR_GRAPHIC_OPTIMIZATION", STR_GRAPHIC_OPTIMIZATION },
+ { "STR_IMAGE_OPTIMIZATION", STR_IMAGE_OPTIMIZATION },
+ { "STR_LOSSLESS_COMPRESSION", STR_LOSSLESS_COMPRESSION },
+ { "STR_JPEG_COMPRESSION", STR_JPEG_COMPRESSION },
+ { "STR_QUALITY", STR_QUALITY },
+ { "STR_REMOVE_CROP_AREA", STR_REMOVE_CROP_AREA },
+ { "STR_IMAGE_RESOLUTION", STR_IMAGE_RESOLUTION },
+ { "STR_IMAGE_RESOLUTION_0", STR_IMAGE_RESOLUTION_0 },
+ { "STR_IMAGE_RESOLUTION_1", STR_IMAGE_RESOLUTION_1 },
+ { "STR_IMAGE_RESOLUTION_2", STR_IMAGE_RESOLUTION_2 },
+ { "STR_IMAGE_RESOLUTION_3", STR_IMAGE_RESOLUTION_3 },
+ { "STR_EMBED_LINKED_GRAPHICS", STR_EMBED_LINKED_GRAPHICS },
+ { "STR_OLE_OBJECTS", STR_OLE_OBJECTS },
+ { "STR_OLE_OPTIMIZATION", STR_OLE_OPTIMIZATION },
+ { "STR_OLE_REPLACE", STR_OLE_REPLACE },
+ { "STR_ALL_OLE_OBJECTS", STR_ALL_OLE_OBJECTS },
+ { "STR_ALIEN_OLE_OBJECTS_ONLY", STR_ALIEN_OLE_OBJECTS_ONLY },
+ { "STR__OLE_OBJECTS_DESC", STR_OLE_OBJECTS_DESC },
+ { "STR_NO_OLE_OBJECTS_DESC", STR_NO_OLE_OBJECTS_DESC },
+ { "STR_SLIDES", STR_SLIDES },
+ { "STR_CHOOSE_SLIDES", STR_CHOOSE_SLIDES },
+ { "STR_DELETE_MASTER_PAGES", STR_DELETE_MASTER_PAGES },
+ { "STR_DELETE_NOTES_PAGES", STR_DELETE_NOTES_PAGES },
+ { "STR_DELETE_HIDDEN_SLIDES", STR_DELETE_HIDDEN_SLIDES },
+ { "STR_CUSTOM_SHOW", STR_CUSTOM_SHOW },
+ { "STR_SUMMARY", STR_SUMMARY },
+ { "STR_SUMMARY_TITLE", STR_SUMMARY_TITLE },
+ { "STR_APPLY_TO_CURRENT", STR_APPLY_TO_CURRENT },
+ { "STR_AUTOMATICALLY_OPEN", STR_AUTOMATICALLY_OPEN },
+ { "STR_SAVE_SETTINGS", STR_SAVE_SETTINGS },
+ { "STR_SAVE_AS", STR_SAVE_AS },
+ { "STR_DELETE_SLIDES", STR_DELETE_SLIDES },
+ { "STR_OPTIMIZE_IMAGES", STR_OPTIMIZE_IMAGES },
+ { "STR_CREATE_REPLACEMENT", STR_CREATE_REPLACEMENT },
+ { "STR_CURRENT_FILESIZE", STR_CURRENT_FILESIZE },
+ { "STR_ESTIMATED_FILESIZE", STR_ESTIMATED_FILESIZE },
+ { "MY_SETTINGS", STR_MY_SETTINGS },
+ { "STR_OK", STR_OK },
+ { "STR_INFO_1", STR_INFO_1 },
+ { "STR_INFO_2", STR_INFO_2 },
+ { "STR_INFO_3", STR_INFO_3 },
+ { "STR_INFO_4", STR_INFO_4 },
+ { "STR_DUPLICATING_PRESENTATION",STR_DUPLICATING_PRESENTATION },
+ { "STR_DELETING_SLIDES", STR_DELETING_SLIDES },
+ { "STR_OPTIMIZING_GRAPHICS", STR_OPTIMIZING_GRAPHICS },
+ { "STR_CREATING_OLE_REPLACEMENTS",STR_CREATING_OLE_REPLACEMENTS },
+ { "STR_FileSizeSeparator", STR_FILESIZESEPARATOR },
+ { "STR_FILENAME_SUFFIX", STR_FILENAME_SUFFIX },
+ { "STR_WARN_UNSAVED_PRESENTATION", STR_WARN_UNSAVED_PRESENTATION },
+
+
+ { "NotFound", TK_NotFound }
+};
+
+PPPOptimizerTokenEnum TKGet( const OUString& rToken )
+{
+ if ( !pHashMap )
+ { // init hash map
+ std::scoped_lock aGuard( getHashMapMutex() );
+ if ( !pHashMap )
+ {
+ TypeNameHashMap* pH = new TypeNameHashMap;
+ const TokenTable* pPtr = pTokenTableArray;
+ const TokenTable* pEnd = pPtr + SAL_N_ELEMENTS( pTokenTableArray );
+ for ( ; pPtr < pEnd; pPtr++ )
+ (*pH)[ pPtr->pS ] = pPtr->pE;
+ pHashMap = pH;
+ }
+ }
+ PPPOptimizerTokenEnum eRetValue = TK_NotFound;
+ int i, nLen = rToken.getLength();
+ std::unique_ptr<char[]> pBuf(new char[ nLen + 1 ]);
+ for ( i = 0; i < nLen; i++ )
+ pBuf[ i ] = static_cast<char>(rToken[ i ]);
+ pBuf[ i ] = 0;
+ TypeNameHashMap::iterator aHashIter( pHashMap->find( pBuf.get() ) );
+ if ( aHashIter != pHashMap->end() )
+ eRetValue = (*aHashIter).second;
+ return eRetValue;
+}
+
+OUString TKGet( const PPPOptimizerTokenEnum eToken )
+{
+ return OUString::createFromAscii( pTokenTableArray[ eToken ].pS );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */