LCOV - code coverage report
Current view: top level - sdext/source/minimizer - pppoptimizertoken.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 27 0.0 %
Date: 2014-11-03 Functions: 0 3 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10