LCOV - code coverage report
Current view: top level - sdext/source/minimizer - configurationaccess.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 267 0.0 %
Date: 2014-04-14 Functions: 0 20 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 "configurationaccess.hxx"
      22             : #include <com/sun/star/frame/XComponentLoader.hpp>
      23             : #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
      24             : #include <com/sun/star/configuration/theDefaultProvider.hpp>
      25             : #include <com/sun/star/util/XChangesBatch.hpp>
      26             : #include <com/sun/star/container/XNameContainer.hpp>
      27             : #include <com/sun/star/util/theMacroExpander.hpp>
      28             : #include <com/sun/star/lang/XSingleServiceFactory.hpp>
      29             : #include <sal/macros.h>
      30             : 
      31             : using namespace ::rtl;
      32             : using namespace ::com::sun::star;
      33             : using namespace ::com::sun::star::uno;
      34             : using namespace ::com::sun::star::beans;
      35             : using namespace ::com::sun::star::container;
      36             : 
      37           0 : static const OUString& GetPathToConfigurationRoot (void)
      38             : {
      39           0 :     static const OUString sPathToConfigurationRoot ("org.openoffice.Office.PresentationMinimizer");
      40           0 :     return sPathToConfigurationRoot;
      41             : }
      42             : 
      43           0 : void OptimizerSettings::LoadSettingsFromConfiguration( const Reference< XNameAccess >& rSettings )
      44             : {
      45           0 :     if ( rSettings.is() )
      46             :     {
      47           0 :         const Sequence< OUString > aElements( rSettings->getElementNames() );
      48           0 :         for ( int i = 0; i < aElements.getLength(); i++ )
      49             :         {
      50             :             try
      51             :             {
      52           0 :                 const OUString aPropertyName( aElements[ i ] );
      53           0 :                 Any aValue( rSettings->getByName( aPropertyName ) );
      54           0 :                 switch( TKGet( aPropertyName ) )
      55             :                 {
      56           0 :                     case TK_Name :                      aValue >>= maName; break;
      57           0 :                     case TK_JPEGCompression :           aValue >>= mbJPEGCompression; break;
      58           0 :                     case TK_JPEGQuality :               aValue >>= mnJPEGQuality; break;
      59           0 :                     case TK_RemoveCropArea :            aValue >>= mbRemoveCropArea; break;
      60           0 :                     case TK_ImageResolution :           aValue >>= mnImageResolution; break;
      61           0 :                     case TK_EmbedLinkedGraphics :       aValue >>= mbEmbedLinkedGraphics; break;
      62           0 :                     case TK_OLEOptimization :           aValue >>= mbOLEOptimization; break;
      63           0 :                     case TK_OLEOptimizationType :       aValue >>= mnOLEOptimizationType; break;
      64           0 :                     case TK_DeleteUnusedMasterPages :   aValue >>= mbDeleteUnusedMasterPages; break;
      65           0 :                     case TK_DeleteHiddenSlides :        aValue >>= mbDeleteHiddenSlides; break;
      66           0 :                     case TK_DeleteNotesPages :          aValue >>= mbDeleteNotesPages ;break;
      67           0 :                     case TK_SaveAs :                    aValue >>= mbSaveAs; break;
      68             : //                  case TK_SaveAsURL :                 aValue >>= maSaveAsURL; break;      // URL is not saved to configuration
      69             : //                  case TK_FilterName :                aValue >>= maFilterName; break;     // URL is not saved to configuration
      70           0 :                     case TK_OpenNewDocument :           aValue >>= mbOpenNewDocument; break;
      71           0 :                     default: break;
      72           0 :                 }
      73             :             }
      74           0 :             catch (const Exception&)
      75             :             {
      76             :             }
      77           0 :         }
      78             :     }
      79           0 : }
      80             : 
      81           0 : void OptimizerSettings::SaveSettingsToConfiguration( const Reference< XNameReplace >& rSettings )
      82             : {
      83           0 :     if ( rSettings.is() )
      84             :     {
      85             :         OUString pNames[] = {
      86             :             OUString("Name"),
      87             :             OUString("JPEGCompression"),
      88             :             OUString("JPEGQuality"),
      89             :             OUString("RemoveCropArea"),
      90             :             OUString("ImageResolution"),
      91             :             OUString("EmbedLinkedGraphics"),
      92             :             OUString("OLEOptimization"),
      93             :             OUString("OLEOptimizationType"),
      94             :             OUString("DeleteUnusedMasterPages"),
      95             :             OUString("DeleteHiddenSlides"),
      96             :             OUString("DeleteNotesPages"),
      97             :             OUString("SaveAs"),
      98             : //          OUString("SaveAsURL"),
      99             : //          OUString("FilterName"),
     100           0 :             OUString("OpenNewDocument") };
     101             : 
     102             :         Any pValues[] = {
     103             :             Any( maName ),
     104             :             Any( mbJPEGCompression ),
     105             :             Any( mnJPEGQuality ),
     106             :             Any( mbRemoveCropArea ),
     107             :             Any( mnImageResolution ),
     108             :             Any( mbEmbedLinkedGraphics ),
     109             :             Any( mbOLEOptimization ),
     110             :             Any( mnOLEOptimizationType ),
     111             :             Any( mbDeleteUnusedMasterPages ),
     112             :             Any( mbDeleteHiddenSlides ),
     113             :             Any( mbDeleteNotesPages ),
     114             :             Any( mbSaveAs ),
     115             : //          Any( maSaveAsURL ),
     116             : //          Any( maFilterName ),
     117           0 :             Any( mbOpenNewDocument ) };
     118             : 
     119           0 :         sal_Int32 i, nCount = SAL_N_ELEMENTS( pNames );
     120             : 
     121           0 :         for ( i = 0; i < nCount; i++ )
     122             :         {
     123             :             try
     124             :             {
     125           0 :                 rSettings->replaceByName( pNames[ i ], pValues[ i ] );
     126             :             }
     127           0 :             catch (const Exception&)
     128             :             {
     129             :             }
     130           0 :         }
     131             :     }
     132           0 : }
     133             : 
     134           0 : sal_Bool OptimizerSettings::operator==( const OptimizerSettings& rOptimizerSettings ) const
     135             : {
     136           0 :     return ( rOptimizerSettings.mbJPEGCompression == mbJPEGCompression )
     137           0 :         && ( rOptimizerSettings.mnJPEGQuality == mnJPEGQuality )
     138           0 :         && ( rOptimizerSettings.mbRemoveCropArea == mbRemoveCropArea )
     139           0 :         && ( rOptimizerSettings.mnImageResolution == mnImageResolution )
     140           0 :         && ( rOptimizerSettings.mbEmbedLinkedGraphics == mbEmbedLinkedGraphics )
     141           0 :         && ( rOptimizerSettings.mbOLEOptimization == mbOLEOptimization )
     142           0 :         && ( rOptimizerSettings.mnOLEOptimizationType == mnOLEOptimizationType )
     143           0 :         && ( rOptimizerSettings.mbDeleteUnusedMasterPages == mbDeleteUnusedMasterPages )
     144           0 :         && ( rOptimizerSettings.mbDeleteHiddenSlides == mbDeleteHiddenSlides )
     145           0 :         && ( rOptimizerSettings.mbDeleteNotesPages == mbDeleteNotesPages );
     146             : //      && ( rOptimizerSettings.mbOpenNewDocument == mbOpenNewDocument );
     147             : }
     148             : 
     149             : 
     150           0 : ConfigurationAccess::ConfigurationAccess( const Reference< uno::XComponentContext >& rxContext, OptimizerSettings* pDefaultSettings ) :
     151           0 :     mxContext( rxContext )
     152             : {
     153           0 :     LoadStrings();
     154             :     maSettings.push_back( pDefaultSettings ?
     155           0 :         *pDefaultSettings : OptimizerSettings() );
     156           0 :     maSettings.back().maName = "LastUsedSettings";
     157           0 :     LoadConfiguration();
     158           0 :     maInitialSettings = maSettings;
     159           0 : };
     160             : 
     161           0 : ConfigurationAccess::~ConfigurationAccess()
     162             : {
     163           0 : }
     164             : 
     165           0 : OUString ConfigurationAccess::getPath( OUString const & token )
     166             : {
     167           0 :     OUString aPath;
     168             :     try
     169             :     {
     170           0 :         static const OUString sProtocol( "vnd.sun.star.expand:" );
     171           0 :         Reference< container::XNameAccess > xSet( OpenConfiguration( true ), UNO_QUERY_THROW );
     172           0 :         if ( xSet->hasByName( token ) )
     173           0 :             xSet->getByName( token ) >>= aPath;
     174           0 :         if ( aPath.match( sProtocol, 0 ) )
     175             :         {
     176           0 :             OUString aTmp( aPath.copy( 20 ) );
     177           0 :             Reference< util::XMacroExpander > xExpander = util::theMacroExpander::get(mxContext);
     178           0 :             aPath = xExpander->expandMacros( aTmp );
     179           0 :         }
     180             :     }
     181           0 :     catch (const Exception&)
     182             :     {
     183             :     }
     184           0 :     return aPath;
     185             : }
     186             : 
     187           0 : OUString ConfigurationAccess::getString( const PPPOptimizerTokenEnum eToken ) const
     188             : {
     189           0 :     std::map< PPPOptimizerTokenEnum, OUString, Compare >::const_iterator aIter( maStrings.find( eToken ) );
     190           0 :     return aIter != maStrings.end() ? ((*aIter).second) : OUString();
     191             : }
     192             : 
     193           0 : void ConfigurationAccess::LoadStrings()
     194             : {
     195             :     try
     196             :     {
     197             :         do
     198             :         {
     199           0 :             Reference< XInterface > xRoot( OpenConfiguration( true ) );
     200           0 :             if ( !xRoot.is() )
     201           0 :                 break;
     202           0 :             Reference< container::XNameAccess > xSet( GetConfigurationNode( xRoot, "Strings" ), UNO_QUERY );
     203           0 :             if ( xSet.is() )
     204             :             {
     205           0 :                 const Sequence< OUString > aElements( xSet->getElementNames() );
     206           0 :                 for ( int i = 0; i < aElements.getLength(); i++ )
     207             :                 {
     208             :                     try
     209             :                     {
     210           0 :                         OUString aString, aPropertyName( aElements[ i ] );
     211           0 :                         if ( xSet->getByName( aPropertyName ) >>= aString )
     212           0 :                             maStrings[ TKGet( aPropertyName ) ] = aString;
     213             :                     }
     214           0 :                     catch (const Exception&)
     215             :                     {
     216             :                     }
     217           0 :                 }
     218           0 :             }
     219             :         }
     220             :         while( false );
     221             :     }
     222           0 :     catch (const Exception&)
     223             :     {
     224             :     }
     225           0 : }
     226             : 
     227           0 : void ConfigurationAccess::LoadConfiguration()
     228             : {
     229             :     try
     230             :     {
     231             :         do
     232             :         {
     233           0 :             Reference< XInterface > xRoot( OpenConfiguration( true ) );
     234           0 :             if ( !xRoot.is() )
     235           0 :                 break;
     236           0 :             Reference< container::XNameAccess > xSet( GetConfigurationNode( xRoot, "LastUsedSettings" ), UNO_QUERY );
     237           0 :             if ( xSet.is() )
     238             :             {
     239           0 :                 OptimizerSettings& rCurrent( maSettings.front() );
     240           0 :                 rCurrent.LoadSettingsFromConfiguration( xSet );
     241             :             }
     242           0 :             xSet = Reference< container::XNameAccess >( GetConfigurationNode( xRoot, "Settings/Templates" ), UNO_QUERY );
     243           0 :             if ( xSet.is() )
     244             :             {
     245           0 :                 const Sequence< OUString > aElements( xSet->getElementNames() );
     246           0 :                 for ( int i = 0; i < aElements.getLength(); i++ )
     247             :                 {
     248             :                     try
     249             :                     {
     250           0 :                         OUString aPath( "Settings/Templates/" + aElements[ i ] );
     251           0 :                         Reference< container::XNameAccess > xTemplates( GetConfigurationNode( xRoot, aPath ), UNO_QUERY );
     252           0 :                         if ( xTemplates.is() )
     253             :                         {
     254           0 :                             maSettings.push_back( OptimizerSettings() );
     255           0 :                             maSettings.back().LoadSettingsFromConfiguration( xTemplates );
     256           0 :                         }
     257             :                     }
     258           0 :                     catch (const Exception&)
     259             :                     {
     260             :                     }
     261           0 :                 }
     262           0 :             }
     263             :         }
     264             :         while( false );
     265             :     }
     266           0 :     catch (const Exception&)
     267             :     {
     268             :     }
     269           0 : }
     270             : 
     271           0 : void ConfigurationAccess::SaveConfiguration()
     272             : {
     273             :     try
     274             :     {
     275             :         do
     276             :         {
     277             :             int i;
     278             :             unsigned int k;
     279           0 :             Reference<util::XChangesBatch> xRoot( OpenConfiguration( false ), UNO_QUERY_THROW );
     280             : 
     281             :             // storing the last used settings
     282           0 :             Reference< container::XNameReplace > xSet( GetConfigurationNode( xRoot, "LastUsedSettings" ), UNO_QUERY_THROW );
     283           0 :             OptimizerSettings& rCurrent( maSettings.front() );
     284           0 :             rCurrent.SaveSettingsToConfiguration( xSet );
     285             : 
     286             :             // updating template elements
     287           0 :             xSet = Reference< container::XNameReplace >( GetConfigurationNode( xRoot, "Settings/Templates" ), UNO_QUERY_THROW );
     288           0 :             Reference< container::XNameContainer > xNameContainer( xSet, UNO_QUERY_THROW );
     289             : 
     290           0 :             const Sequence< OUString > aElements( xSet->getElementNames() );
     291           0 :             for( i = 0; i < aElements.getLength(); i++ )
     292           0 :                 xNameContainer->removeByName( aElements[ i ] );
     293             : 
     294           0 :             for( k = 1; k < maSettings.size(); k++ )
     295             :             {
     296           0 :                 OptimizerSettings& rSettings( maSettings[ k ] );
     297           0 :                 OUString aElementName( "Template" + OUString::number( k ) );
     298           0 :                 Reference< lang::XSingleServiceFactory > xChildFactory ( xSet, UNO_QUERY_THROW );
     299           0 :                 Reference< container::XNameReplace > xChild( xChildFactory->createInstance(), UNO_QUERY_THROW );
     300           0 :                 xNameContainer->insertByName( aElementName, Any( xChild ) );
     301             : 
     302           0 :                 OUString aPath( "Settings/Templates/" + aElementName );
     303           0 :                 Reference< container::XNameReplace > xTemplates( GetConfigurationNode( xRoot, aPath ), UNO_QUERY );
     304           0 :                 rSettings.SaveSettingsToConfiguration( xTemplates );
     305           0 :             }
     306           0 :             xRoot->commitChanges();
     307             :         }
     308             :         while( false );
     309             :     }
     310           0 :     catch (const Exception&)
     311             :     {
     312             :     }
     313           0 : }
     314             : 
     315           0 : Reference< XInterface > ConfigurationAccess::OpenConfiguration( bool bReadOnly )
     316             : {
     317           0 :     Reference< XInterface > xRoot;
     318             :     try
     319             :     {
     320           0 :         Reference< lang::XMultiServiceFactory > xProvider = configuration::theDefaultProvider::get( mxContext );
     321           0 :         Sequence< Any > aCreationArguments( 2 );
     322           0 :         aCreationArguments[0] = makeAny( PropertyValue(
     323             :             OUString( "nodepath" ), 0,
     324           0 :             makeAny( GetPathToConfigurationRoot() ),
     325           0 :             PropertyState_DIRECT_VALUE ) );
     326           0 :         aCreationArguments[1] = makeAny(beans::PropertyValue(
     327             :             OUString( "lazywrite" ), 0, makeAny( true ),
     328           0 :             PropertyState_DIRECT_VALUE ) );
     329           0 :         OUString sAccessService;
     330           0 :         if ( bReadOnly )
     331           0 :             sAccessService = OUString(
     332           0 :                 "com.sun.star.configuration.ConfigurationAccess" );
     333             :         else
     334           0 :             sAccessService = OUString(
     335           0 :                 "com.sun.star.configuration.ConfigurationUpdateAccess" );
     336             : 
     337           0 :         xRoot = xProvider->createInstanceWithArguments(
     338           0 :             sAccessService, aCreationArguments );
     339             :     }
     340           0 :     catch (const Exception&)
     341             :     {
     342             :     }
     343           0 :     return xRoot;
     344             : }
     345             : 
     346           0 : Reference< XInterface > ConfigurationAccess::GetConfigurationNode(
     347             :     const Reference< XInterface >& xRoot,
     348             :     const OUString& sPathToNode )
     349             : {
     350           0 :     Reference< XInterface > xNode;
     351             :     try
     352             :     {
     353           0 :         if ( sPathToNode.isEmpty() )
     354           0 :             xNode = xRoot;
     355             :         else
     356             :         {
     357           0 :             Reference< XHierarchicalNameAccess > xHierarchy( xRoot, UNO_QUERY );
     358           0 :             if ( xHierarchy.is() )
     359             :             {
     360           0 :                 xHierarchy->getByHierarchicalName( sPathToNode ) >>= xNode;
     361           0 :             }
     362             :         }
     363             :     }
     364           0 :     catch (const Exception& rException)
     365             :     {
     366             :         OSL_TRACE ("caught exception while getting configuration node %s: %s",
     367             :             OUStringToOString(sPathToNode,
     368             :                 RTL_TEXTENCODING_UTF8).getStr(),
     369             :             OUStringToOString(rException.Message,
     370             :                 RTL_TEXTENCODING_UTF8).getStr());
     371             :         (void)rException;
     372             :     }
     373           0 :     return xNode;
     374             : }
     375             : 
     376           0 : com::sun::star::uno::Any ConfigurationAccess::GetConfigProperty( const PPPOptimizerTokenEnum ePropertyToken ) const
     377             : {
     378           0 :     Any aRetValue;
     379           0 :     const OptimizerSettings& rSettings( maSettings.front() );
     380             :     try
     381             :     {
     382           0 :         switch( ePropertyToken )
     383             :         {
     384           0 :             case TK_Name :                      aRetValue <<= rSettings.maName; break;
     385           0 :             case TK_JPEGCompression :           aRetValue <<= rSettings.mbJPEGCompression; break;
     386           0 :             case TK_JPEGQuality :               aRetValue <<= rSettings.mnJPEGQuality; break;
     387           0 :             case TK_RemoveCropArea :            aRetValue <<= rSettings.mbRemoveCropArea; break;
     388           0 :             case TK_ImageResolution :           aRetValue <<= rSettings.mnImageResolution; break;
     389           0 :             case TK_EmbedLinkedGraphics :       aRetValue <<= rSettings.mbEmbedLinkedGraphics; break;
     390           0 :             case TK_OLEOptimization :           aRetValue <<= rSettings.mbOLEOptimization; break;
     391           0 :             case TK_OLEOptimizationType :       aRetValue <<= rSettings.mnOLEOptimizationType; break;
     392           0 :             case TK_DeleteUnusedMasterPages :   aRetValue <<= rSettings.mbDeleteUnusedMasterPages; break;
     393           0 :             case TK_DeleteHiddenSlides :        aRetValue <<= rSettings.mbDeleteHiddenSlides; break;
     394           0 :             case TK_DeleteNotesPages :          aRetValue <<= rSettings.mbDeleteNotesPages; break;
     395           0 :             case TK_SaveAs :                    aRetValue <<= rSettings.mbSaveAs; break;
     396           0 :             case TK_SaveAsURL :                 aRetValue <<= rSettings.maSaveAsURL; break;
     397           0 :             case TK_FilterName :                aRetValue <<= rSettings.maFilterName; break;
     398           0 :             case TK_OpenNewDocument :           aRetValue <<= rSettings.mbOpenNewDocument; break;
     399           0 :             case TK_EstimatedFileSize :         aRetValue <<= rSettings.mnEstimatedFileSize; break;
     400             :             default:
     401           0 :                 break;
     402             :         }
     403             :     }
     404           0 :     catch (const Exception&)
     405             :     {
     406             :     }
     407           0 :     return aRetValue;
     408             : }
     409             : 
     410           0 : void ConfigurationAccess::SetConfigProperty( const PPPOptimizerTokenEnum ePropertyToken, const com::sun::star::uno::Any& rValue )
     411             : {
     412           0 :     OptimizerSettings& rSettings( maSettings.front() );
     413             :     try
     414             :     {
     415           0 :         switch( ePropertyToken )
     416             :         {
     417           0 :             case TK_Name :                      rValue >>= rSettings.maName; break;
     418           0 :             case TK_JPEGCompression :           rValue >>= rSettings.mbJPEGCompression; break;
     419           0 :             case TK_JPEGQuality :               rValue >>= rSettings.mnJPEGQuality; break;
     420           0 :             case TK_RemoveCropArea :            rValue >>= rSettings.mbRemoveCropArea; break;
     421           0 :             case TK_ImageResolution :           rValue >>= rSettings.mnImageResolution; break;
     422           0 :             case TK_EmbedLinkedGraphics :       rValue >>= rSettings.mbEmbedLinkedGraphics; break;
     423           0 :             case TK_OLEOptimization :           rValue >>= rSettings.mbOLEOptimization; break;
     424           0 :             case TK_OLEOptimizationType :       rValue >>= rSettings.mnOLEOptimizationType; break;
     425           0 :             case TK_DeleteUnusedMasterPages :   rValue >>= rSettings.mbDeleteUnusedMasterPages; break;
     426           0 :             case TK_DeleteHiddenSlides :        rValue >>= rSettings.mbDeleteHiddenSlides; break;
     427           0 :             case TK_DeleteNotesPages :          rValue >>= rSettings.mbDeleteNotesPages; break;
     428           0 :             case TK_CustomShowName :            rValue >>= rSettings.maCustomShowName; break;
     429           0 :             case TK_SaveAs :                    rValue >>= rSettings.mbSaveAs; break;
     430           0 :             case TK_SaveAsURL :                 rValue >>= rSettings.maSaveAsURL; break;
     431           0 :             case TK_FilterName :                rValue >>= rSettings.maFilterName; break;
     432           0 :             case TK_OpenNewDocument :           rValue >>= rSettings.mbOpenNewDocument; break;
     433           0 :             case TK_EstimatedFileSize :         rValue >>= rSettings.mnEstimatedFileSize; break;
     434             :             default:
     435           0 :                 break;
     436             :         }
     437             :     }
     438             :     catch (const Exception&)
     439             :     {
     440             :     }
     441           0 : }
     442             : 
     443           0 : sal_Bool ConfigurationAccess::GetConfigProperty( const PPPOptimizerTokenEnum ePropertyToken, const sal_Bool bDefault ) const
     444             : {
     445           0 :     sal_Bool bRetValue = bDefault;
     446           0 :     if ( ! ( GetConfigProperty( ePropertyToken ) >>= bRetValue ) )
     447           0 :         bRetValue = bDefault;
     448           0 :     return bRetValue;
     449             : }
     450             : 
     451           0 : sal_Int16 ConfigurationAccess::GetConfigProperty( const PPPOptimizerTokenEnum ePropertyToken, const sal_Int16 nDefault ) const
     452             : {
     453           0 :     sal_Int16 nRetValue = nDefault;
     454           0 :     if ( ! ( GetConfigProperty( ePropertyToken ) >>= nRetValue ) )
     455           0 :         nRetValue = nDefault;
     456           0 :     return nRetValue;
     457             : }
     458             : 
     459           0 : sal_Int32 ConfigurationAccess::GetConfigProperty( const PPPOptimizerTokenEnum ePropertyToken, const sal_Int32 nDefault ) const
     460             : {
     461           0 :     sal_Int32 nRetValue = nDefault;
     462           0 :     if ( ! ( GetConfigProperty( ePropertyToken ) >>= nRetValue ) )
     463           0 :         nRetValue = nDefault;
     464           0 :     return nRetValue;
     465             : }
     466             : 
     467           0 : Sequence< PropertyValue > ConfigurationAccess::GetConfigurationSequence()
     468             : {
     469           0 :     Sequence< PropertyValue > aRet( 15 );
     470           0 :     OptimizerSettings& rSettings( maSettings.front() );
     471           0 :     aRet[ 0 ].Name = "JPEGCompression";
     472           0 :     aRet[ 0 ].Value= Any( rSettings.mbJPEGCompression );
     473           0 :     aRet[ 1 ].Name = "JPEGQuality";
     474           0 :     aRet[ 1 ].Value= Any( rSettings.mnJPEGQuality );
     475           0 :     aRet[ 2 ].Name = "RemoveCropArea";
     476           0 :     aRet[ 2 ].Value= Any( rSettings.mbRemoveCropArea );
     477           0 :     aRet[ 3 ].Name = "ImageResolution";
     478           0 :     aRet[ 3 ].Value= Any( rSettings.mnImageResolution );
     479           0 :     aRet[ 4 ].Name = "EmbedLinkedGraphics";
     480           0 :     aRet[ 4 ].Value= Any( rSettings.mbEmbedLinkedGraphics );
     481           0 :     aRet[ 5 ].Name = "OLEOptimization";
     482           0 :     aRet[ 5 ].Value= Any( rSettings.mbOLEOptimization );
     483           0 :     aRet[ 6 ].Name = "OLEOptimizationType";
     484           0 :     aRet[ 6 ].Value= Any( rSettings.mnOLEOptimizationType );
     485           0 :     aRet[ 7 ].Name = "DeleteUnusedMasterPages";
     486           0 :     aRet[ 7 ].Value= Any( rSettings.mbDeleteUnusedMasterPages );
     487           0 :     aRet[ 8 ].Name = "DeleteHiddenSlides";
     488           0 :     aRet[ 8 ].Value= Any( rSettings.mbDeleteHiddenSlides );
     489           0 :     aRet[ 9 ].Name = "DeleteNotesPages";
     490           0 :     aRet[ 9 ].Value= Any( rSettings.mbDeleteNotesPages );
     491           0 :     aRet[ 10].Name = "CustomShowName";
     492           0 :     aRet[ 10].Value= Any( rSettings.maCustomShowName );
     493           0 :     aRet[ 11].Name = "SaveAsURL";
     494           0 :     aRet[ 11].Value= Any( rSettings.maSaveAsURL );
     495           0 :     aRet[ 12].Name = "FilterName";
     496           0 :     aRet[ 12].Value= Any( rSettings.maFilterName );
     497           0 :     aRet[ 13].Name = "OpenNewDocument";
     498           0 :     aRet[ 13].Value= Any( rSettings.mbOpenNewDocument );
     499           0 :     aRet[ 14].Name = "EstimatedFileSize";
     500           0 :     aRet[ 14].Value= Any( rSettings.mnEstimatedFileSize );
     501           0 :     return aRet;
     502             : }
     503             : 
     504           0 : std::vector< OptimizerSettings >::iterator ConfigurationAccess::GetOptimizerSettingsByName( const OUString& rName )
     505             : {
     506           0 :     std::vector< OptimizerSettings >::iterator aIter( maSettings.begin() + 1 );
     507           0 :     const std::vector< OptimizerSettings >::const_iterator aEnd( maSettings.end() );
     508           0 :     for ( ; aIter != aEnd; ++aIter )
     509             :     {
     510           0 :         if ( aIter->maName == rName )
     511           0 :             break;
     512             :     }
     513           0 :     return aIter;
     514             : }
     515             : 
     516             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10