1*06bcd5d2SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*06bcd5d2SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*06bcd5d2SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*06bcd5d2SAndrew Rist * distributed with this work for additional information 6*06bcd5d2SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*06bcd5d2SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*06bcd5d2SAndrew Rist * "License"); you may not use this file except in compliance 9*06bcd5d2SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*06bcd5d2SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*06bcd5d2SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*06bcd5d2SAndrew Rist * software distributed under the License is distributed on an 15*06bcd5d2SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*06bcd5d2SAndrew Rist * KIND, either express or implied. See the License for the 17*06bcd5d2SAndrew Rist * specific language governing permissions and limitations 18*06bcd5d2SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*06bcd5d2SAndrew Rist *************************************************************/ 21*06bcd5d2SAndrew Rist 22*06bcd5d2SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir 25cdf0e10cSrcweir #ifndef _CONFIGURATION_ACCESS_HXX_ 26cdf0e10cSrcweir #define _CONFIGURATION_ACCESS_HXX_ 27cdf0e10cSrcweir #include <vector> 28cdf0e10cSrcweir #include "pppoptimizertoken.hxx" 29cdf0e10cSrcweir #include <com/sun/star/awt/Size.hpp> 30cdf0e10cSrcweir #include <com/sun/star/uno/Any.h> 31cdf0e10cSrcweir #include <com/sun/star/uno/Reference.h> 32cdf0e10cSrcweir #include <com/sun/star/uno/XInterface.hpp> 33cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 34cdf0e10cSrcweir #include <com/sun/star/beans/XPropertyAccess.hpp> 35cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp> 36cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UNO_XCOMPONENTCONTEXT 37cdf0e10cSrcweir #include <com/sun/star/uno/XComponentContext.hpp> 38cdf0e10cSrcweir #endif 39cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp> 40cdf0e10cSrcweir #include <com/sun/star/container/XNameReplace.hpp> 41cdf0e10cSrcweir #include <map> 42cdf0e10cSrcweir 43cdf0e10cSrcweir struct OptimizerSettings 44cdf0e10cSrcweir { 45cdf0e10cSrcweir rtl::OUString maName; 46cdf0e10cSrcweir sal_Bool mbJPEGCompression; 47cdf0e10cSrcweir sal_Int32 mnJPEGQuality; 48cdf0e10cSrcweir sal_Bool mbRemoveCropArea; 49cdf0e10cSrcweir sal_Int32 mnImageResolution; 50cdf0e10cSrcweir sal_Bool mbEmbedLinkedGraphics; 51cdf0e10cSrcweir sal_Bool mbOLEOptimization; 52cdf0e10cSrcweir sal_Int16 mnOLEOptimizationType; 53cdf0e10cSrcweir sal_Bool mbDeleteUnusedMasterPages; 54cdf0e10cSrcweir sal_Bool mbDeleteHiddenSlides; 55cdf0e10cSrcweir sal_Bool mbDeleteNotesPages; 56cdf0e10cSrcweir rtl::OUString maCustomShowName; 57cdf0e10cSrcweir sal_Bool mbSaveAs; 58cdf0e10cSrcweir rtl::OUString maSaveAsURL; 59cdf0e10cSrcweir rtl::OUString maFilterName; 60cdf0e10cSrcweir sal_Bool mbOpenNewDocument; 61cdf0e10cSrcweir sal_Int64 mnEstimatedFileSize; 62cdf0e10cSrcweir 63cdf0e10cSrcweir OptimizerSettings() : 64cdf0e10cSrcweir mbJPEGCompression( sal_False ), 65cdf0e10cSrcweir mnJPEGQuality( 90 ), 66cdf0e10cSrcweir mbRemoveCropArea( sal_False ), 67cdf0e10cSrcweir mnImageResolution( 0 ), 68cdf0e10cSrcweir mbEmbedLinkedGraphics( sal_False ), 69cdf0e10cSrcweir mbOLEOptimization( sal_False ), 70cdf0e10cSrcweir mnOLEOptimizationType( 0 ), 71cdf0e10cSrcweir mbDeleteUnusedMasterPages( sal_False ), 72cdf0e10cSrcweir mbDeleteHiddenSlides( sal_False ), 73cdf0e10cSrcweir mbDeleteNotesPages( sal_False ), 74cdf0e10cSrcweir mbSaveAs( sal_True ), 75cdf0e10cSrcweir mbOpenNewDocument( sal_True ), 76cdf0e10cSrcweir mnEstimatedFileSize( 0 ){}; 77cdf0e10cSrcweir ~OptimizerSettings(){}; 78cdf0e10cSrcweir 79cdf0e10cSrcweir void LoadSettingsFromConfiguration( const com::sun::star::uno::Reference< com::sun::star::container::XNameAccess >& rSettings ); 80cdf0e10cSrcweir void SaveSettingsToConfiguration( const com::sun::star::uno::Reference< com::sun::star::container::XNameReplace >& rSettings ); 81cdf0e10cSrcweir 82cdf0e10cSrcweir sal_Bool operator==( const OptimizerSettings& rOptimizerSettings ) const; 83cdf0e10cSrcweir 84cdf0e10cSrcweir }; 85cdf0e10cSrcweir class ConfigurationAccess 86cdf0e10cSrcweir { 87cdf0e10cSrcweir public : 88cdf0e10cSrcweir 89cdf0e10cSrcweir ConfigurationAccess( const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& rXFactory, 90cdf0e10cSrcweir OptimizerSettings* pDefaultSettings = NULL ); 91cdf0e10cSrcweir ~ConfigurationAccess(); 92cdf0e10cSrcweir void SaveConfiguration(); 93cdf0e10cSrcweir 94cdf0e10cSrcweir rtl::OUString getPath( const PPPOptimizerTokenEnum ); 95cdf0e10cSrcweir rtl::OUString getString( const PPPOptimizerTokenEnum ) const; 96cdf0e10cSrcweir 97cdf0e10cSrcweir // access to current OptimizerSettings (stored in the first entry of maSettings) 98cdf0e10cSrcweir com::sun::star::uno::Any GetConfigProperty( const PPPOptimizerTokenEnum ) const; 99cdf0e10cSrcweir void SetConfigProperty( const PPPOptimizerTokenEnum, const com::sun::star::uno::Any& aValue ); 100cdf0e10cSrcweir 101cdf0e10cSrcweir sal_Bool GetConfigProperty( const PPPOptimizerTokenEnum, const sal_Bool bDefault ) const; 102cdf0e10cSrcweir sal_Int16 GetConfigProperty( const PPPOptimizerTokenEnum, const sal_Int16 nDefault ) const; 103cdf0e10cSrcweir sal_Int32 GetConfigProperty( const PPPOptimizerTokenEnum, const sal_Int32 nDefault ) const; 104cdf0e10cSrcweir 105cdf0e10cSrcweir com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > GetConfigurationSequence(); 106cdf0e10cSrcweir 107cdf0e10cSrcweir // getting access to the OptimizerSettings list 108cdf0e10cSrcweir std::vector< OptimizerSettings >& GetOptimizerSettings() { return maSettings; }; 109cdf0e10cSrcweir std::vector< OptimizerSettings >::iterator GetOptimizerSettingsByName( const rtl::OUString& rName ); 110cdf0e10cSrcweir 111cdf0e10cSrcweir private : 112cdf0e10cSrcweir 113cdf0e10cSrcweir struct Compare 114cdf0e10cSrcweir { 115cdf0e10cSrcweir bool operator()( const PPPOptimizerTokenEnum s1, const PPPOptimizerTokenEnum s2 ) const 116cdf0e10cSrcweir { 117cdf0e10cSrcweir return s1 < s2; 118cdf0e10cSrcweir } 119cdf0e10cSrcweir }; 120cdf0e10cSrcweir std::map < PPPOptimizerTokenEnum, rtl::OUString, Compare > maStrings; 121cdf0e10cSrcweir 122cdf0e10cSrcweir std::vector< OptimizerSettings > maSettings; 123cdf0e10cSrcweir std::vector< OptimizerSettings > maInitialSettings; 124cdf0e10cSrcweir 125cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > mxMSF; 126cdf0e10cSrcweir 127cdf0e10cSrcweir void LoadStrings(); 128cdf0e10cSrcweir void LoadConfiguration(); 129cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::uno::XInterface > OpenConfiguration( bool bReadOnly ); 130cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::uno::XInterface > GetConfigurationNode( 131cdf0e10cSrcweir const com::sun::star::uno::Reference< com::sun::star::uno::XInterface >& xRoot, const rtl::OUString& sPathToNode ); 132cdf0e10cSrcweir }; 133cdf0e10cSrcweir 134cdf0e10cSrcweir #endif // _CONFIGURATION_ACCESS_HXX_ 135cdf0e10cSrcweir 136