1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: configurationaccess.hxx,v $
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_
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>
46 #include <com/sun/star/container/XNameAccess.hpp>
47 #include <com/sun/star/container/XNameReplace.hpp>
50 struct OptimizerSettings
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
;
65 rtl::OUString maSaveAsURL
;
66 rtl::OUString maFilterName
;
67 sal_Bool mbOpenNewDocument
;
68 sal_Int64 mnEstimatedFileSize
;
71 mbJPEGCompression( sal_False
),
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
),
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;
92 class ConfigurationAccess
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
);
122 bool operator()( const PPPOptimizerTokenEnum s1
, const PPPOptimizerTokenEnum s2
) const
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
;
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_