1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #ifndef _CONFIGURATION_ACCESS_HXX_
22 #define _CONFIGURATION_ACCESS_HXX_
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>
35 #include <com/sun/star/container/XNameAccess.hpp>
36 #include <com/sun/star/container/XNameReplace.hpp>
39 struct OptimizerSettings
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 OUString maCustomShowName
;
55 OUString maFilterName
;
56 sal_Bool mbOpenNewDocument
;
57 sal_Int64 mnEstimatedFileSize
;
60 mbJPEGCompression( sal_False
),
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
),
71 mbOpenNewDocument( sal_True
),
72 mnEstimatedFileSize( 0 ){};
73 ~OptimizerSettings(){};
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
);
78 sal_Bool
operator==( const OptimizerSettings
& rOptimizerSettings
) const;
81 class ConfigurationAccess
85 ConfigurationAccess( const com::sun::star::uno::Reference
< com::sun::star::uno::XComponentContext
>& rXFactory
,
86 OptimizerSettings
* pDefaultSettings
= NULL
);
87 ~ConfigurationAccess();
88 void SaveConfiguration();
90 OUString
getPath( const PPPOptimizerTokenEnum
);
91 OUString
getString( const PPPOptimizerTokenEnum
) const;
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
);
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;
101 com::sun::star::uno::Sequence
< com::sun::star::beans::PropertyValue
> GetConfigurationSequence();
103 // getting access to the OptimizerSettings list
104 std::vector
< OptimizerSettings
>& GetOptimizerSettings() { return maSettings
; };
105 std::vector
< OptimizerSettings
>::iterator
GetOptimizerSettingsByName( const OUString
& rName
);
111 bool operator()( const PPPOptimizerTokenEnum s1
, const PPPOptimizerTokenEnum s2
) const
116 std::map
< PPPOptimizerTokenEnum
, OUString
, Compare
> maStrings
;
118 std::vector
< OptimizerSettings
> maSettings
;
119 std::vector
< OptimizerSettings
> maInitialSettings
;
121 com::sun::star::uno::Reference
< com::sun::star::uno::XComponentContext
> mxMSF
;
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 OUString
& sPathToNode
);
130 #endif // _CONFIGURATION_ACCESS_HXX_
132 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */