cid#1607171 Data race condition
[LibreOffice.git] / sdext / source / minimizer / configurationaccess.hxx
blob5cf884fc13fe99ed197635e3a2059a173b78e0ad
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #ifndef INCLUDED_SDEXT_SOURCE_MINIMIZER_CONFIGURATIONACCESS_HXX
21 #define INCLUDED_SDEXT_SOURCE_MINIMIZER_CONFIGURATIONACCESS_HXX
23 #include <vector>
24 #include "pppoptimizertoken.hxx"
25 #include <com/sun/star/uno/Any.h>
26 #include <com/sun/star/uno/Reference.h>
27 #include <com/sun/star/uno/XInterface.hpp>
28 #include <com/sun/star/beans/PropertyValue.hpp>
29 #include <com/sun/star/uno/XComponentContext.hpp>
30 #include <com/sun/star/container/XNameAccess.hpp>
31 #include <com/sun/star/container/XNameReplace.hpp>
32 #include <map>
34 struct OptimizerSettings
36 OUString maName;
37 bool mbJPEGCompression;
38 sal_Int32 mnJPEGQuality;
39 bool mbRemoveCropArea;
40 sal_Int32 mnImageResolution;
41 bool mbEmbedLinkedGraphics;
42 bool mbOLEOptimization;
43 sal_Int16 mnOLEOptimizationType;
44 bool mbDeleteUnusedMasterPages;
45 bool mbDeleteHiddenSlides;
46 bool mbDeleteNotesPages;
47 OUString maCustomShowName;
48 bool mbSaveAs;
49 OUString maSaveAsURL;
50 OUString maFilterName;
51 bool mbOpenNewDocument;
52 sal_Int64 mnEstimatedFileSize;
54 OptimizerSettings() :
55 mbJPEGCompression( false ),
56 mnJPEGQuality( 90 ),
57 mbRemoveCropArea( false ),
58 mnImageResolution( 0 ),
59 mbEmbedLinkedGraphics( false ),
60 mbOLEOptimization( false ),
61 mnOLEOptimizationType( 0 ),
62 mbDeleteUnusedMasterPages( false ),
63 mbDeleteHiddenSlides( false ),
64 mbDeleteNotesPages( false ),
65 mbSaveAs( true ),
66 mbOpenNewDocument( true ),
67 mnEstimatedFileSize( 0 ){};
69 void LoadSettingsFromConfiguration( const css::uno::Reference< css::container::XNameAccess >& rSettings );
70 void SaveSettingsToConfiguration( const css::uno::Reference< css::container::XNameReplace >& rSettings );
72 bool operator==( const OptimizerSettings& rOptimizerSettings ) const;
75 class ConfigurationAccess
77 public:
79 explicit ConfigurationAccess( const css::uno::Reference< css::uno::XComponentContext >& rXFactory );
80 ~ConfigurationAccess();
81 void SaveConfiguration();
83 OUString getString( const PPPOptimizerTokenEnum ) const;
85 // access to current OptimizerSettings (stored in the first entry of maSettings)
86 css::uno::Any GetConfigProperty( const PPPOptimizerTokenEnum ) const;
87 void SetConfigProperty( const PPPOptimizerTokenEnum, const css::uno::Any& aValue );
89 bool GetConfigProperty( const PPPOptimizerTokenEnum, const bool bDefault ) const;
90 sal_Int16 GetConfigProperty( const PPPOptimizerTokenEnum, const sal_Int16 nDefault ) const;
91 sal_Int32 GetConfigProperty( const PPPOptimizerTokenEnum, const sal_Int32 nDefault ) const;
93 css::uno::Sequence< css::beans::PropertyValue > GetConfigurationSequence();
95 // getting access to the OptimizerSettings list
96 std::vector< OptimizerSettings >& GetOptimizerSettings() { return maSettings; };
97 std::vector< OptimizerSettings >::iterator GetOptimizerSettingsByName( const OUString& rName );
99 protected:
100 css::uno::Reference< css::uno::XComponentContext > mxContext;
102 private:
103 std::map < PPPOptimizerTokenEnum, OUString > maStrings;
105 std::vector< OptimizerSettings > maSettings;
107 void LoadStrings();
108 void LoadConfiguration();
109 css::uno::Reference< css::uno::XInterface > OpenConfiguration( bool bReadOnly );
110 static css::uno::Reference< css::uno::XInterface > GetConfigurationNode(
111 const css::uno::Reference< css::uno::XInterface >& xRoot, const OUString& sPathToNode );
114 #endif // INCLUDED_SDEXT_SOURCE_MINIMIZER_CONFIGURATIONACCESS_HXX
116 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */