update dev300-m58
[ooovba.git] / sdext / source / minimizer / configurationaccess.hxx
blob25370af760d51f0dc2dd34be82bc3c1a8be0861c
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: configurationaccess.hxx,v $
10 * $Revision: 1.3 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
32 #ifndef _CONFIGURATION_ACCESS_HXX_
33 #define _CONFIGURATION_ACCESS_HXX_
34 #include <vector>
35 #include "pppoptimizertoken.hxx"
36 #include <com/sun/star/awt/Size.hpp>
37 #include <com/sun/star/uno/Any.h>
38 #include <com/sun/star/uno/Reference.h>
39 #include <com/sun/star/uno/XInterface.hpp>
40 #include <com/sun/star/beans/XPropertySet.hpp>
41 #include <com/sun/star/beans/XPropertyAccess.hpp>
42 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
43 #ifndef _COM_SUN_STAR_UNO_XCOMPONENTCONTEXT
44 #include <com/sun/star/uno/XComponentContext.hpp>
45 #endif
46 #include <com/sun/star/container/XNameAccess.hpp>
47 #include <com/sun/star/container/XNameReplace.hpp>
48 #include <map>
50 struct OptimizerSettings
52 rtl::OUString maName;
53 sal_Bool mbJPEGCompression;
54 sal_Int32 mnJPEGQuality;
55 sal_Bool mbRemoveCropArea;
56 sal_Int32 mnImageResolution;
57 sal_Bool mbEmbedLinkedGraphics;
58 sal_Bool mbOLEOptimization;
59 sal_Int16 mnOLEOptimizationType;
60 sal_Bool mbDeleteUnusedMasterPages;
61 sal_Bool mbDeleteHiddenSlides;
62 sal_Bool mbDeleteNotesPages;
63 rtl::OUString maCustomShowName;
64 sal_Bool mbSaveAs;
65 rtl::OUString maSaveAsURL;
66 rtl::OUString maFilterName;
67 sal_Bool mbOpenNewDocument;
68 sal_Int64 mnEstimatedFileSize;
70 OptimizerSettings() :
71 mbJPEGCompression( sal_False ),
72 mnJPEGQuality( 90 ),
73 mbRemoveCropArea( sal_False ),
74 mnImageResolution( 0 ),
75 mbEmbedLinkedGraphics( sal_False ),
76 mbOLEOptimization( sal_False ),
77 mnOLEOptimizationType( 0 ),
78 mbDeleteUnusedMasterPages( sal_False ),
79 mbDeleteHiddenSlides( sal_False ),
80 mbDeleteNotesPages( sal_False ),
81 mbSaveAs( sal_True ),
82 mbOpenNewDocument( sal_True ),
83 mnEstimatedFileSize( 0 ){};
84 ~OptimizerSettings(){};
86 void LoadSettingsFromConfiguration( const com::sun::star::uno::Reference< com::sun::star::container::XNameAccess >& rSettings );
87 void SaveSettingsToConfiguration( const com::sun::star::uno::Reference< com::sun::star::container::XNameReplace >& rSettings );
89 sal_Bool operator==( const OptimizerSettings& rOptimizerSettings ) const;
91 };
92 class ConfigurationAccess
94 public :
96 ConfigurationAccess( const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& rXFactory,
97 OptimizerSettings* pDefaultSettings = NULL );
98 ~ConfigurationAccess();
99 void SaveConfiguration();
101 rtl::OUString getPath( const PPPOptimizerTokenEnum );
102 rtl::OUString getString( const PPPOptimizerTokenEnum ) const;
104 // access to current OptimizerSettings (stored in the first entry of maSettings)
105 com::sun::star::uno::Any GetConfigProperty( const PPPOptimizerTokenEnum ) const;
106 void SetConfigProperty( const PPPOptimizerTokenEnum, const com::sun::star::uno::Any& aValue );
108 sal_Bool GetConfigProperty( const PPPOptimizerTokenEnum, const sal_Bool bDefault ) const;
109 sal_Int16 GetConfigProperty( const PPPOptimizerTokenEnum, const sal_Int16 nDefault ) const;
110 sal_Int32 GetConfigProperty( const PPPOptimizerTokenEnum, const sal_Int32 nDefault ) const;
112 com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > GetConfigurationSequence();
114 // getting access to the OptimizerSettings list
115 std::vector< OptimizerSettings >& GetOptimizerSettings() { return maSettings; };
116 std::vector< OptimizerSettings >::iterator GetOptimizerSettingsByName( const rtl::OUString& rName );
118 private :
120 struct Compare
122 bool operator()( const PPPOptimizerTokenEnum s1, const PPPOptimizerTokenEnum s2 ) const
124 return s1 < s2;
127 std::map < PPPOptimizerTokenEnum, rtl::OUString, Compare > maStrings;
129 std::vector< OptimizerSettings > maSettings;
130 std::vector< OptimizerSettings > maInitialSettings;
132 com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > mxMSF;
134 void LoadStrings();
135 void LoadConfiguration();
136 com::sun::star::uno::Reference< com::sun::star::uno::XInterface > OpenConfiguration( bool bReadOnly );
137 com::sun::star::uno::Reference< com::sun::star::uno::XInterface > GetConfigurationNode(
138 const com::sun::star::uno::Reference< com::sun::star::uno::XInterface >& xRoot, const rtl::OUString& sPathToNode );
141 #endif // _CONFIGURATION_ACCESS_HXX_