22#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
23#include <com/sun/star/configuration/theDefaultProvider.hpp>
24#include <com/sun/star/util/XChangesBatch.hpp>
25#include <com/sun/star/container/XNameContainer.hpp>
26#include <com/sun/star/lang/XSingleServiceFactory.hpp>
40 return "org.openoffice.Office.PresentationMinimizer";
45 if ( !rSettings.is() )
48 const Sequence< OUString > aElements( rSettings->getElementNames() );
49 for (
const OUString& aPropertyName : aElements )
53 Any aValue( rSettings->getByName( aPropertyName ) );
54 switch(
TKGet( aPropertyName ) )
82 if ( !rSettings.is() )
87 OUString(
"JPEGCompression"),
88 OUString(
"JPEGQuality"),
89 OUString(
"RemoveCropArea"),
90 OUString(
"ImageResolution"),
91 OUString(
"EmbedLinkedGraphics"),
92 OUString(
"OLEOptimization"),
93 OUString(
"OLEOptimizationType"),
94 OUString(
"DeleteUnusedMasterPages"),
95 OUString(
"DeleteHiddenSlides"),
96 OUString(
"DeleteNotesPages"),
100 OUString(
"OpenNewDocument") };
123 rSettings->replaceByName( pNames[
i ],
pValues[
i ] );
149 maSettings.emplace_back( );
150 maSettings.back().maName =
"LastUsedSettings";
160 std::map< PPPOptimizerTokenEnum, OUString >::const_iterator aIter(
maStrings.find(
eToken ) );
161 return aIter !=
maStrings.end() ? ((*aIter).second) : OUString();
173 Reference< container::XNameAccess > xSet(
GetConfigurationNode( xRoot,
"Strings" ), UNO_QUERY );
176 const Sequence< OUString > aElements( xSet->getElementNames() );
177 for (
const auto& rElement : aElements )
181 OUString aString, aPropertyName( rElement );
182 if ( xSet->getByName( aPropertyName ) >>= aString )
207 Reference< container::XNameAccess > xSet(
GetConfigurationNode( xRoot,
"LastUsedSettings" ), UNO_QUERY );
216 const Sequence< OUString > aElements( xSet->getElementNames() );
217 for (
const auto& rElement : aElements )
221 OUString aPath(
"Settings/Templates/" + rElement );
222 Reference< container::XNameAccess > xTemplates(
GetConfigurationNode( xRoot, aPath ), UNO_QUERY );
223 if ( xTemplates.is() )
226 maSettings.back().LoadSettingsFromConfiguration( xTemplates );
248 Reference<util::XChangesBatch> xRoot(
OpenConfiguration(
false ), UNO_QUERY_THROW );
251 Reference< container::XNameReplace > xSet(
GetConfigurationNode( xRoot,
"LastUsedSettings" ), UNO_QUERY_THROW );
257 Reference< container::XNameContainer > xNameContainer( xSet, UNO_QUERY_THROW );
259 const Sequence< OUString > aElements( xSet->getElementNames() );
260 for(
const auto& rElement : aElements )
261 xNameContainer->removeByName( rElement );
263 for( std::vector<OptimizerSettings>::size_type k = 1; k <
maSettings.size(); k++ )
266 OUString aElementName(
"Template" + OUString::number( k ) );
267 Reference< lang::XSingleServiceFactory > xChildFactory ( xSet, UNO_QUERY_THROW );
268 Reference< container::XNameReplace > xChild( xChildFactory->createInstance(), UNO_QUERY_THROW );
269 xNameContainer->insertByName( aElementName,
Any( xChild ) );
271 OUString aPath(
"Settings/Templates/" + aElementName );
272 Reference< container::XNameReplace > xTemplates(
GetConfigurationNode( xRoot, aPath ), UNO_QUERY );
275 xRoot->commitChanges();
286 Reference< XInterface > xRoot;
289 Reference< lang::XMultiServiceFactory > xProvider = configuration::theDefaultProvider::get(
mxContext );
294 OUString sAccessService;
296 sAccessService =
"com.sun.star.configuration.ConfigurationAccess";
299 "com.sun.star.configuration.ConfigurationUpdateAccess";
301 xRoot = xProvider->createInstanceWithArguments(
302 sAccessService, aCreationArguments );
311 const Reference< XInterface >& xRoot,
312 const OUString& sPathToNode )
314 Reference< XInterface > xNode;
317 if ( sPathToNode.isEmpty() )
321 Reference< XHierarchicalNameAccess > xHierarchy( xRoot, UNO_QUERY );
322 if ( xHierarchy.is() )
324 xHierarchy->getByHierarchicalName( sPathToNode ) >>= xNode;
328 catch (
const Exception&)
342 switch( ePropertyToken )
375 switch( ePropertyToken )
405 bool bRetValue = bDefault;
407 bRetValue = bDefault;
413 sal_Int16 nRetValue = nDefault;
415 nRetValue = nDefault;
421 sal_Int32 nRetValue = nDefault;
423 nRetValue = nDefault;
430 Sequence< PropertyValue > aRet{
453 [&rName](
const OptimizerSettings& rSettings) { return rSettings.maName == rName; });
const PropertyValue * pValues
css::uno::Reference< css::uno::XInterface > OpenConfiguration(bool bReadOnly)
static css::uno::Reference< css::uno::XInterface > GetConfigurationNode(const css::uno::Reference< css::uno::XInterface > &xRoot, const OUString &sPathToNode)
OUString getString(const PPPOptimizerTokenEnum) const
css::uno::Sequence< css::beans::PropertyValue > GetConfigurationSequence()
std::vector< OptimizerSettings > maSettings
ConfigurationAccess(const css::uno::Reference< css::uno::XComponentContext > &rXFactory)
void SetConfigProperty(const PPPOptimizerTokenEnum, const css::uno::Any &aValue)
css::uno::Any GetConfigProperty(const PPPOptimizerTokenEnum) const
std::vector< OptimizerSettings >::iterator GetOptimizerSettingsByName(const OUString &rName)
css::uno::Reference< css::uno::XComponentContext > mxContext
std::map< PPPOptimizerTokenEnum, OUString > maStrings
static OUString GetPathToConfigurationRoot()
#define TOOLS_WARN_EXCEPTION(area, stream)
#define SAL_N_ELEMENTS(arr)
css::uno::Sequence< css::uno::Any > InitAnyPropertySequence(::std::initializer_list< ::std::pair< OUString, css::uno::Any > > vInit)
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
PPPOptimizerTokenEnum TKGet(std::u16string_view rToken)
@ TK_DeleteUnusedMasterPages
const wchar_t *typedef int(__stdcall *DllNativeUnregProc)(int
bool mbDeleteHiddenSlides
void LoadSettingsFromConfiguration(const css::uno::Reference< css::container::XNameAccess > &rSettings)
sal_Int64 mnEstimatedFileSize
OUString maCustomShowName
sal_Int16 mnOLEOptimizationType
bool operator==(const OptimizerSettings &rOptimizerSettings) const
void SaveSettingsToConfiguration(const css::uno::Reference< css::container::XNameReplace > &rSettings)
bool mbDeleteUnusedMasterPages
bool mbEmbedLinkedGraphics
sal_Int32 mnImageResolution