LCOV - code coverage report
Current view: top level - libreoffice/sdext/source/minimizer - configurationaccess.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 7 0.0 %
Date: 2012-12-17 Functions: 0 6 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             : #ifndef _CONFIGURATION_ACCESS_HXX_
      22             : #define _CONFIGURATION_ACCESS_HXX_
      23             : #include <vector>
      24             : #include "pppoptimizertoken.hxx"
      25             : #include <com/sun/star/awt/Size.hpp>
      26             : #include <com/sun/star/uno/Any.h>
      27             : #include <com/sun/star/uno/Reference.h>
      28             : #include <com/sun/star/uno/XInterface.hpp>
      29             : #include <com/sun/star/beans/XPropertySet.hpp>
      30             : #include <com/sun/star/beans/XPropertyAccess.hpp>
      31             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      32             : #ifndef _COM_SUN_STAR_UNO_XCOMPONENTCONTEXT
      33             : #include <com/sun/star/uno/XComponentContext.hpp>
      34             : #endif
      35             : #include <com/sun/star/container/XNameAccess.hpp>
      36             : #include <com/sun/star/container/XNameReplace.hpp>
      37             : #include <map>
      38             : 
      39           0 : struct OptimizerSettings
      40             : {
      41             :     rtl::OUString   maName;
      42             :     sal_Bool        mbJPEGCompression;
      43             :     sal_Int32       mnJPEGQuality;
      44             :     sal_Bool        mbRemoveCropArea;
      45             :     sal_Int32       mnImageResolution;
      46             :     sal_Bool        mbEmbedLinkedGraphics;
      47             :     sal_Bool        mbOLEOptimization;
      48             :     sal_Int16       mnOLEOptimizationType;
      49             :     sal_Bool        mbDeleteUnusedMasterPages;
      50             :     sal_Bool        mbDeleteHiddenSlides;
      51             :     sal_Bool        mbDeleteNotesPages;
      52             :     rtl::OUString   maCustomShowName;
      53             :     sal_Bool        mbSaveAs;
      54             :     rtl::OUString   maSaveAsURL;
      55             :     rtl::OUString   maFilterName;
      56             :     sal_Bool        mbOpenNewDocument;
      57             :     sal_Int64       mnEstimatedFileSize;
      58             : 
      59           0 :     OptimizerSettings() :
      60             :         mbJPEGCompression( sal_False ),
      61             :         mnJPEGQuality( 90 ),
      62             :         mbRemoveCropArea( sal_False ),
      63             :         mnImageResolution( 0 ),
      64             :         mbEmbedLinkedGraphics( sal_False ),
      65             :         mbOLEOptimization( sal_False ),
      66             :         mnOLEOptimizationType( 0 ),
      67             :         mbDeleteUnusedMasterPages( sal_False ),
      68             :         mbDeleteHiddenSlides( sal_False ),
      69             :         mbDeleteNotesPages( sal_False ),
      70             :         mbSaveAs( sal_True ),
      71             :         mbOpenNewDocument( sal_True ),
      72           0 :         mnEstimatedFileSize( 0 ){};
      73           0 :         ~OptimizerSettings(){};
      74             : 
      75             :         void LoadSettingsFromConfiguration( const com::sun::star::uno::Reference< com::sun::star::container::XNameAccess >& rSettings );
      76             :         void SaveSettingsToConfiguration( const com::sun::star::uno::Reference< com::sun::star::container::XNameReplace >& rSettings );
      77             : 
      78             :         sal_Bool operator==( const OptimizerSettings& rOptimizerSettings ) const;
      79             : 
      80             : };
      81             : class ConfigurationAccess
      82             : {
      83             :     public :
      84             : 
      85             :         ConfigurationAccess( const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& rXFactory,
      86             :                                 OptimizerSettings* pDefaultSettings = NULL );
      87             :         ~ConfigurationAccess();
      88             :         void SaveConfiguration();
      89             : 
      90             :         rtl::OUString getPath( const PPPOptimizerTokenEnum );
      91             :         rtl::OUString getString( const PPPOptimizerTokenEnum ) const;
      92             : 
      93             :         // access to current OptimizerSettings (stored in the first entry of maSettings)
      94             :         com::sun::star::uno::Any GetConfigProperty( const PPPOptimizerTokenEnum ) const;
      95             :         void SetConfigProperty( const PPPOptimizerTokenEnum, const com::sun::star::uno::Any& aValue );
      96             : 
      97             :         sal_Bool GetConfigProperty( const PPPOptimizerTokenEnum, const sal_Bool bDefault ) const;
      98             :         sal_Int16 GetConfigProperty( const PPPOptimizerTokenEnum, const sal_Int16 nDefault ) const;
      99             :         sal_Int32 GetConfigProperty( const PPPOptimizerTokenEnum, const sal_Int32 nDefault ) const;
     100             : 
     101             :         com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > GetConfigurationSequence();
     102             : 
     103             :         // getting access to the OptimizerSettings list
     104           0 :         std::vector< OptimizerSettings >& GetOptimizerSettings() { return maSettings; };
     105             :         std::vector< OptimizerSettings >::iterator GetOptimizerSettingsByName( const rtl::OUString& rName );
     106             : 
     107             :     private :
     108             : 
     109             :         struct Compare
     110             :         {
     111           0 :             bool operator()( const PPPOptimizerTokenEnum s1, const PPPOptimizerTokenEnum s2 ) const
     112             :             {
     113           0 :                 return s1 < s2;
     114             :             }
     115             :         };
     116             :         std::map < PPPOptimizerTokenEnum, rtl::OUString, Compare > maStrings;
     117             : 
     118             :         std::vector< OptimizerSettings > maSettings;
     119             :         std::vector< OptimizerSettings > maInitialSettings;
     120             : 
     121             :         com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > mxMSF;
     122             : 
     123             :         void LoadStrings();
     124             :         void LoadConfiguration();
     125             :         com::sun::star::uno::Reference< com::sun::star::uno::XInterface > OpenConfiguration( bool bReadOnly );
     126             :         com::sun::star::uno::Reference< com::sun::star::uno::XInterface > GetConfigurationNode(
     127             :             const com::sun::star::uno::Reference< com::sun::star::uno::XInterface >& xRoot, const rtl::OUString& sPathToNode );
     128             : };
     129             : 
     130             : #endif  // _CONFIGURATION_ACCESS_HXX_
     131             : 
     132             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10