106bcd5d2SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
306bcd5d2SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
406bcd5d2SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
506bcd5d2SAndrew Rist  * distributed with this work for additional information
606bcd5d2SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
706bcd5d2SAndrew Rist  * to you under the Apache License, Version 2.0 (the
806bcd5d2SAndrew Rist  * "License"); you may not use this file except in compliance
906bcd5d2SAndrew Rist  * with the License.  You may obtain a copy of the License at
1006bcd5d2SAndrew Rist  *
1106bcd5d2SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
1206bcd5d2SAndrew Rist  *
1306bcd5d2SAndrew Rist  * Unless required by applicable law or agreed to in writing,
1406bcd5d2SAndrew Rist  * software distributed under the License is distributed on an
1506bcd5d2SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1606bcd5d2SAndrew Rist  * KIND, either express or implied.  See the License for the
1706bcd5d2SAndrew Rist  * specific language governing permissions and limitations
1806bcd5d2SAndrew Rist  * under the License.
1906bcd5d2SAndrew Rist  *
2006bcd5d2SAndrew Rist  *************************************************************/
2106bcd5d2SAndrew Rist 
2206bcd5d2SAndrew 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 
43*597a4c59SAriel Constenla-Haile 
44cdf0e10cSrcweir struct OptimizerSettings
45cdf0e10cSrcweir {
46cdf0e10cSrcweir 	rtl::OUString	maName;
47cdf0e10cSrcweir 	sal_Bool		mbJPEGCompression;
48cdf0e10cSrcweir 	sal_Int32		mnJPEGQuality;
49cdf0e10cSrcweir 	sal_Bool		mbRemoveCropArea;
50cdf0e10cSrcweir 	sal_Int32		mnImageResolution;
51cdf0e10cSrcweir 	sal_Bool		mbEmbedLinkedGraphics;
52cdf0e10cSrcweir 	sal_Bool		mbOLEOptimization;
53cdf0e10cSrcweir 	sal_Int16		mnOLEOptimizationType;
54cdf0e10cSrcweir 	sal_Bool		mbDeleteUnusedMasterPages;
55cdf0e10cSrcweir 	sal_Bool		mbDeleteHiddenSlides;
56cdf0e10cSrcweir 	sal_Bool		mbDeleteNotesPages;
57cdf0e10cSrcweir 	rtl::OUString	maCustomShowName;
58cdf0e10cSrcweir 	sal_Bool		mbSaveAs;
59cdf0e10cSrcweir 	rtl::OUString	maSaveAsURL;
60cdf0e10cSrcweir 	rtl::OUString	maFilterName;
61cdf0e10cSrcweir 	sal_Bool		mbOpenNewDocument;
62cdf0e10cSrcweir 	sal_Int64		mnEstimatedFileSize;
63cdf0e10cSrcweir 
OptimizerSettingsOptimizerSettings64cdf0e10cSrcweir 	OptimizerSettings() :
65cdf0e10cSrcweir 		mbJPEGCompression( sal_False ),
66cdf0e10cSrcweir 		mnJPEGQuality( 90 ),
67cdf0e10cSrcweir 		mbRemoveCropArea( sal_False ),
68cdf0e10cSrcweir 		mnImageResolution( 0 ),
69cdf0e10cSrcweir 		mbEmbedLinkedGraphics( sal_False ),
70cdf0e10cSrcweir 		mbOLEOptimization( sal_False ),
71cdf0e10cSrcweir 		mnOLEOptimizationType( 0 ),
72cdf0e10cSrcweir 		mbDeleteUnusedMasterPages( sal_False ),
73cdf0e10cSrcweir 		mbDeleteHiddenSlides( sal_False ),
74cdf0e10cSrcweir 		mbDeleteNotesPages( sal_False ),
75cdf0e10cSrcweir 		mbSaveAs( sal_True ),
76cdf0e10cSrcweir 		mbOpenNewDocument( sal_True ),
77cdf0e10cSrcweir 		mnEstimatedFileSize( 0 ){};
~OptimizerSettingsOptimizerSettings78cdf0e10cSrcweir 		~OptimizerSettings(){};
79cdf0e10cSrcweir 
80cdf0e10cSrcweir 		void LoadSettingsFromConfiguration( const com::sun::star::uno::Reference< com::sun::star::container::XNameAccess >& rSettings );
81cdf0e10cSrcweir 		void SaveSettingsToConfiguration( const com::sun::star::uno::Reference< com::sun::star::container::XNameReplace >& rSettings );
82cdf0e10cSrcweir 
83cdf0e10cSrcweir 		sal_Bool operator==( const OptimizerSettings& rOptimizerSettings ) const;
84cdf0e10cSrcweir 
85cdf0e10cSrcweir };
86cdf0e10cSrcweir class ConfigurationAccess
87cdf0e10cSrcweir {
88cdf0e10cSrcweir 	public :
89cdf0e10cSrcweir 
90*597a4c59SAriel Constenla-Haile 		ConfigurationAccess( const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& rxContext,
91cdf0e10cSrcweir 								OptimizerSettings* pDefaultSettings = NULL );
92cdf0e10cSrcweir 		~ConfigurationAccess();
93cdf0e10cSrcweir 		void SaveConfiguration();
94cdf0e10cSrcweir 
95*597a4c59SAriel Constenla-Haile 		static rtl::OUString getString( sal_Int32 nResId );
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
GetOptimizerSettings()108cdf0e10cSrcweir 		std::vector< OptimizerSettings >& GetOptimizerSettings() { return maSettings; };
109cdf0e10cSrcweir 		std::vector< OptimizerSettings >::iterator GetOptimizerSettingsByName( const rtl::OUString& rName );
110cdf0e10cSrcweir 
111cdf0e10cSrcweir 	private :
112cdf0e10cSrcweir 
113*597a4c59SAriel Constenla-Haile         com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > m_xContext;
114cdf0e10cSrcweir 		std::vector< OptimizerSettings > maSettings;
115cdf0e10cSrcweir 		std::vector< OptimizerSettings > maInitialSettings;
116cdf0e10cSrcweir 
117cdf0e10cSrcweir 		void LoadStrings();
118cdf0e10cSrcweir 		void LoadConfiguration();
119cdf0e10cSrcweir 		com::sun::star::uno::Reference< com::sun::star::uno::XInterface > OpenConfiguration( bool bReadOnly );
120cdf0e10cSrcweir 		com::sun::star::uno::Reference< com::sun::star::uno::XInterface > GetConfigurationNode(
121cdf0e10cSrcweir 			const com::sun::star::uno::Reference< com::sun::star::uno::XInterface >& xRoot, const rtl::OUString& sPathToNode );
122cdf0e10cSrcweir };
123cdf0e10cSrcweir 
124cdf0e10cSrcweir #endif	// _CONFIGURATION_ACCESS_HXX_
125cdf0e10cSrcweir 
126