Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include "configurationaccess.hxx"
31 : : #include <com/sun/star/frame/XComponentLoader.hpp>
32 : : #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
33 : : #include <com/sun/star/util/XChangesBatch.hpp>
34 : : #include <com/sun/star/container/XNameContainer.hpp>
35 : : #include <com/sun/star/util/XMacroExpander.hpp>
36 : : #include <com/sun/star/lang/XSingleServiceFactory.hpp>
37 : : #include <sal/macros.h>
38 : :
39 : : using namespace ::rtl;
40 : : using namespace ::com::sun::star;
41 : : using namespace ::com::sun::star::uno;
42 : : using namespace ::com::sun::star::beans;
43 : : using namespace ::com::sun::star::container;
44 : :
45 : 0 : static const OUString& GetConfigurationProviderServiceName (void)
46 : : {
47 : : static const OUString sConfigurationProviderServiceName (
48 : : RTL_CONSTASCII_USTRINGPARAM(
49 : 0 : "com.sun.star.configuration.ConfigurationProvider"));
50 : 0 : return sConfigurationProviderServiceName;
51 : : }
52 : 0 : static const OUString& GetPathToConfigurationRoot (void)
53 : : {
54 : : static const OUString sPathToConfigurationRoot (
55 : 0 : RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Office.extension.SunPresentationMinimizer"));
56 : 0 : return sPathToConfigurationRoot;
57 : : }
58 : :
59 : 0 : void OptimizerSettings::LoadSettingsFromConfiguration( const Reference< XNameAccess >& rSettings )
60 : : {
61 : 0 : if ( rSettings.is() )
62 : : {
63 : 0 : const Sequence< OUString > aElements( rSettings->getElementNames() );
64 : 0 : for ( int i = 0; i < aElements.getLength(); i++ )
65 : : {
66 : : try
67 : : {
68 : 0 : const OUString aPropertyName( aElements[ i ] );
69 : 0 : Any aValue( rSettings->getByName( aPropertyName ) );
70 : 0 : switch( TKGet( aPropertyName ) )
71 : : {
72 : 0 : case TK_Name : aValue >>= maName; break;
73 : 0 : case TK_JPEGCompression : aValue >>= mbJPEGCompression; break;
74 : 0 : case TK_JPEGQuality : aValue >>= mnJPEGQuality; break;
75 : 0 : case TK_RemoveCropArea : aValue >>= mbRemoveCropArea; break;
76 : 0 : case TK_ImageResolution : aValue >>= mnImageResolution; break;
77 : 0 : case TK_EmbedLinkedGraphics : aValue >>= mbEmbedLinkedGraphics; break;
78 : 0 : case TK_OLEOptimization : aValue >>= mbOLEOptimization; break;
79 : 0 : case TK_OLEOptimizationType : aValue >>= mnOLEOptimizationType; break;
80 : 0 : case TK_DeleteUnusedMasterPages : aValue >>= mbDeleteUnusedMasterPages; break;
81 : 0 : case TK_DeleteHiddenSlides : aValue >>= mbDeleteHiddenSlides; break;
82 : 0 : case TK_DeleteNotesPages : aValue >>= mbDeleteNotesPages ;break;
83 : 0 : case TK_SaveAs : aValue >>= mbSaveAs; break;
84 : : // case TK_SaveAsURL : aValue >>= maSaveAsURL; break; // URL is not saved to configuration
85 : : // case TK_FilterName : aValue >>= maFilterName; break; // URL is not saved to configuration
86 : 0 : case TK_OpenNewDocument : aValue >>= mbOpenNewDocument; break;
87 : 0 : default: break;
88 : 0 : }
89 : : }
90 : 0 : catch (const Exception&)
91 : : {
92 : : }
93 : 0 : }
94 : : }
95 : 0 : }
96 : :
97 : 0 : void OptimizerSettings::SaveSettingsToConfiguration( const Reference< XNameReplace >& rSettings )
98 : : {
99 : 0 : if ( rSettings.is() )
100 : : {
101 : : OUString pNames[] = {
102 : : TKGet( TK_Name ),
103 : : TKGet( TK_JPEGCompression ),
104 : : TKGet( TK_JPEGQuality ),
105 : : TKGet( TK_RemoveCropArea ),
106 : : TKGet( TK_ImageResolution ),
107 : : TKGet( TK_EmbedLinkedGraphics ),
108 : : TKGet( TK_OLEOptimization ),
109 : : TKGet( TK_OLEOptimizationType ),
110 : : TKGet( TK_DeleteUnusedMasterPages ),
111 : : TKGet( TK_DeleteHiddenSlides ),
112 : : TKGet( TK_DeleteNotesPages ),
113 : : TKGet( TK_SaveAs ),
114 : : // TKGet( TK_SaveAsURL ),
115 : : // TKGet( TK_FilterName ),
116 : 0 : TKGet( TK_OpenNewDocument ) };
117 : :
118 : : Any pValues[] = {
119 : : Any( maName ),
120 : : Any( mbJPEGCompression ),
121 : : Any( mnJPEGQuality ),
122 : : Any( mbRemoveCropArea ),
123 : : Any( mnImageResolution ),
124 : : Any( mbEmbedLinkedGraphics ),
125 : : Any( mbOLEOptimization ),
126 : : Any( mnOLEOptimizationType ),
127 : : Any( mbDeleteUnusedMasterPages ),
128 : : Any( mbDeleteHiddenSlides ),
129 : : Any( mbDeleteNotesPages ),
130 : : Any( mbSaveAs ),
131 : : // Any( maSaveAsURL ),
132 : : // Any( maFilterName ),
133 : 0 : Any( mbOpenNewDocument ) };
134 : :
135 : 0 : sal_Int32 i, nCount = SAL_N_ELEMENTS( pNames );
136 : :
137 : 0 : for ( i = 0; i < nCount; i++ )
138 : : {
139 : : try
140 : : {
141 : 0 : rSettings->replaceByName( pNames[ i ], pValues[ i ] );
142 : : }
143 : 0 : catch (const Exception&)
144 : : {
145 : : }
146 : 0 : }
147 : : }
148 : 0 : }
149 : :
150 : 0 : sal_Bool OptimizerSettings::operator==( const OptimizerSettings& rOptimizerSettings ) const
151 : : {
152 : : return ( rOptimizerSettings.mbJPEGCompression == mbJPEGCompression )
153 : : && ( rOptimizerSettings.mnJPEGQuality == mnJPEGQuality )
154 : : && ( rOptimizerSettings.mbRemoveCropArea == mbRemoveCropArea )
155 : : && ( rOptimizerSettings.mnImageResolution == mnImageResolution )
156 : : && ( rOptimizerSettings.mbEmbedLinkedGraphics == mbEmbedLinkedGraphics )
157 : : && ( rOptimizerSettings.mbOLEOptimization == mbOLEOptimization )
158 : : && ( rOptimizerSettings.mnOLEOptimizationType == mnOLEOptimizationType )
159 : : && ( rOptimizerSettings.mbDeleteUnusedMasterPages == mbDeleteUnusedMasterPages )
160 : : && ( rOptimizerSettings.mbDeleteHiddenSlides == mbDeleteHiddenSlides )
161 : 0 : && ( rOptimizerSettings.mbDeleteNotesPages == mbDeleteNotesPages );
162 : : // && ( rOptimizerSettings.mbOpenNewDocument == mbOpenNewDocument );
163 : : }
164 : :
165 : :
166 : 0 : ConfigurationAccess::ConfigurationAccess( const Reference< uno::XComponentContext >& rxMSF, OptimizerSettings* pDefaultSettings ) :
167 : 0 : mxMSF( rxMSF )
168 : : {
169 : 0 : LoadStrings();
170 : : maSettings.push_back( pDefaultSettings ?
171 : 0 : *pDefaultSettings : OptimizerSettings() );
172 : 0 : maSettings.back().maName = TKGet( TK_LastUsedSettings );
173 : 0 : LoadConfiguration();
174 : 0 : maInitialSettings = maSettings;
175 : 0 : };
176 : :
177 : 0 : ConfigurationAccess::~ConfigurationAccess()
178 : : {
179 : 0 : }
180 : :
181 : 0 : rtl::OUString ConfigurationAccess::getPath( const PPPOptimizerTokenEnum eToken )
182 : : {
183 : 0 : rtl::OUString aPath;
184 : : try
185 : : {
186 : 0 : static const OUString sProtocol( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.expand:" ) );
187 : 0 : static const OUString stheMacroExpander( RTL_CONSTASCII_USTRINGPARAM( "/singletons/com.sun.star.util.theMacroExpander" ) );
188 : 0 : Reference< container::XNameAccess > xSet( OpenConfiguration( true ), UNO_QUERY_THROW );
189 : 0 : if ( xSet->hasByName( TKGet( eToken ) ) )
190 : 0 : xSet->getByName( TKGet( eToken ) ) >>= aPath;
191 : 0 : if ( aPath.match( sProtocol, 0 ) )
192 : : {
193 : 0 : rtl::OUString aTmp( aPath.copy( 20 ) );
194 : 0 : Reference< util::XMacroExpander > xExpander;
195 : 0 : if ( mxMSF->getValueByName( stheMacroExpander ) >>= xExpander )
196 : : {
197 : 0 : aPath = xExpander->expandMacros( aTmp );
198 : 0 : }
199 : 0 : }
200 : : }
201 : 0 : catch (const Exception&)
202 : : {
203 : : }
204 : 0 : return aPath;
205 : : }
206 : :
207 : 0 : rtl::OUString ConfigurationAccess::getString( const PPPOptimizerTokenEnum eToken ) const
208 : : {
209 : 0 : std::map< PPPOptimizerTokenEnum, rtl::OUString, Compare >::const_iterator aIter( maStrings.find( eToken ) );
210 : 0 : return aIter != maStrings.end() ? ((*aIter).second) : rtl::OUString();
211 : : }
212 : :
213 : 0 : void ConfigurationAccess::LoadStrings()
214 : : {
215 : : try
216 : : {
217 : : do
218 : : {
219 : 0 : Reference< XInterface > xRoot( OpenConfiguration( true ) );
220 : 0 : if ( !xRoot.is() )
221 : : break;
222 : 0 : Reference< container::XNameAccess > xSet( GetConfigurationNode( xRoot, TKGet( TK_Strings ) ), UNO_QUERY );
223 : 0 : if ( xSet.is() )
224 : : {
225 : 0 : const Sequence< OUString > aElements( xSet->getElementNames() );
226 : 0 : for ( int i = 0; i < aElements.getLength(); i++ )
227 : : {
228 : : try
229 : : {
230 : 0 : OUString aString, aPropertyName( aElements[ i ] );
231 : 0 : if ( xSet->getByName( aPropertyName ) >>= aString )
232 : 0 : maStrings[ TKGet( aPropertyName ) ] = aString;
233 : : }
234 : 0 : catch (const Exception&)
235 : : {
236 : : }
237 : 0 : }
238 : 0 : }
239 : : }
240 : : while( false );
241 : : }
242 : 0 : catch (const Exception&)
243 : : {
244 : : }
245 : 0 : }
246 : :
247 : 0 : void ConfigurationAccess::LoadConfiguration()
248 : : {
249 : : try
250 : : {
251 : : do
252 : : {
253 : 0 : Reference< XInterface > xRoot( OpenConfiguration( true ) );
254 : 0 : if ( !xRoot.is() )
255 : : break;
256 : 0 : Reference< container::XNameAccess > xSet( GetConfigurationNode( xRoot, TKGet( TK_LastUsedSettings ) ), UNO_QUERY );
257 : 0 : if ( xSet.is() )
258 : : {
259 : 0 : OptimizerSettings& rCurrent( maSettings.front() );
260 : 0 : rCurrent.LoadSettingsFromConfiguration( xSet );
261 : : }
262 : 0 : xSet = Reference< container::XNameAccess >( GetConfigurationNode( xRoot, TKGet( TK_Settings_Templates ) ), UNO_QUERY );
263 : 0 : if ( xSet.is() )
264 : : {
265 : 0 : const Sequence< OUString > aElements( xSet->getElementNames() );
266 : 0 : for ( int i = 0; i < aElements.getLength(); i++ )
267 : : {
268 : : try
269 : : {
270 : 0 : OUString aPath( TKGet( TK_Settings_Templates_ ).concat( aElements[ i ] ) );
271 : 0 : Reference< container::XNameAccess > xTemplates( GetConfigurationNode( xRoot, aPath ), UNO_QUERY );
272 : 0 : if ( xTemplates.is() )
273 : : {
274 : 0 : maSettings.push_back( OptimizerSettings() );
275 : 0 : maSettings.back().LoadSettingsFromConfiguration( xTemplates );
276 : 0 : }
277 : : }
278 : 0 : catch (const Exception&)
279 : : {
280 : : }
281 : 0 : }
282 : 0 : }
283 : : }
284 : : while( false );
285 : : }
286 : 0 : catch (const Exception&)
287 : : {
288 : : }
289 : 0 : }
290 : :
291 : 0 : void ConfigurationAccess::SaveConfiguration()
292 : : {
293 : : try
294 : : {
295 : : do
296 : : {
297 : : int i;
298 : : unsigned int k;
299 : 0 : Reference<util::XChangesBatch> xRoot( OpenConfiguration( false ), UNO_QUERY_THROW );
300 : :
301 : : // storing the last used settings
302 : 0 : Reference< container::XNameReplace > xSet( GetConfigurationNode( xRoot, TKGet( TK_LastUsedSettings ) ), UNO_QUERY_THROW );
303 : 0 : OptimizerSettings& rCurrent( maSettings.front() );
304 : 0 : rCurrent.SaveSettingsToConfiguration( xSet );
305 : :
306 : : // updating template elements
307 : 0 : xSet = Reference< container::XNameReplace >( GetConfigurationNode( xRoot, TKGet( TK_Settings_Templates ) ), UNO_QUERY_THROW );
308 : 0 : Reference< container::XNameContainer > xNameContainer( xSet, UNO_QUERY_THROW );
309 : :
310 : 0 : const Sequence< OUString > aElements( xSet->getElementNames() );
311 : 0 : for( i = 0; i < aElements.getLength(); i++ )
312 : 0 : xNameContainer->removeByName( aElements[ i ] );
313 : :
314 : 0 : for( k = 1; k < maSettings.size(); k++ )
315 : : {
316 : 0 : OptimizerSettings& rSettings( maSettings[ k ] );
317 : 0 : OUString aElementName( TKGet( TK_Template ).concat( OUString::valueOf( static_cast< sal_Int32 >( k ) ) ) );
318 : 0 : Reference< lang::XSingleServiceFactory > xChildFactory ( xSet, UNO_QUERY_THROW );
319 : 0 : Reference< container::XNameReplace > xChild( xChildFactory->createInstance(), UNO_QUERY_THROW );
320 : 0 : xNameContainer->insertByName( aElementName, Any( xChild ) );
321 : :
322 : 0 : OUString aPath( TKGet( TK_Settings_Templates_ ).concat( aElementName ) );
323 : 0 : Reference< container::XNameReplace > xTemplates( GetConfigurationNode( xRoot, aPath ), UNO_QUERY );
324 : 0 : rSettings.SaveSettingsToConfiguration( xTemplates );
325 : 0 : }
326 : 0 : xRoot->commitChanges();
327 : : }
328 : : while( false );
329 : : }
330 : 0 : catch (const Exception&)
331 : : {
332 : : }
333 : 0 : }
334 : :
335 : 0 : Reference< XInterface > ConfigurationAccess::OpenConfiguration( bool bReadOnly )
336 : : {
337 : 0 : Reference< XInterface > xRoot;
338 : : try
339 : : {
340 : 0 : Reference< lang::XMultiServiceFactory > xProvider( mxMSF->getServiceManager()->createInstanceWithContext( GetConfigurationProviderServiceName(), mxMSF ), UNO_QUERY );
341 : 0 : if ( xProvider.is() )
342 : : {
343 : 0 : Sequence< Any > aCreationArguments( 2 );
344 : 0 : aCreationArguments[0] = makeAny( PropertyValue(
345 : : OUString( RTL_CONSTASCII_USTRINGPARAM( "nodepath" ) ), 0,
346 : 0 : makeAny( GetPathToConfigurationRoot() ),
347 : 0 : PropertyState_DIRECT_VALUE ) );
348 : 0 : aCreationArguments[1] = makeAny(beans::PropertyValue(
349 : : OUString( RTL_CONSTASCII_USTRINGPARAM( "lazywrite" ) ), 0, makeAny( true ),
350 : 0 : PropertyState_DIRECT_VALUE ) );
351 : 0 : OUString sAccessService;
352 : 0 : if ( bReadOnly )
353 : : sAccessService = OUString( RTL_CONSTASCII_USTRINGPARAM(
354 : 0 : "com.sun.star.configuration.ConfigurationAccess" ) );
355 : : else
356 : : sAccessService = OUString( RTL_CONSTASCII_USTRINGPARAM(
357 : 0 : "com.sun.star.configuration.ConfigurationUpdateAccess" ) );
358 : :
359 : 0 : xRoot = xProvider->createInstanceWithArguments(
360 : 0 : sAccessService, aCreationArguments );
361 : 0 : }
362 : : }
363 : 0 : catch (const Exception&)
364 : : {
365 : : }
366 : 0 : return xRoot;
367 : : }
368 : :
369 : 0 : Reference< XInterface > ConfigurationAccess::GetConfigurationNode(
370 : : const Reference< XInterface >& xRoot,
371 : : const OUString& sPathToNode )
372 : : {
373 : 0 : Reference< XInterface > xNode;
374 : : try
375 : : {
376 : 0 : if ( sPathToNode.isEmpty() )
377 : 0 : xNode = xRoot;
378 : : else
379 : : {
380 : 0 : Reference< XHierarchicalNameAccess > xHierarchy( xRoot, UNO_QUERY );
381 : 0 : if ( xHierarchy.is() )
382 : : {
383 : 0 : xHierarchy->getByHierarchicalName( sPathToNode ) >>= xNode;
384 : 0 : }
385 : : }
386 : : }
387 : 0 : catch (const Exception& rException)
388 : : {
389 : : OSL_TRACE ("caught exception while getting configuration node %s: %s",
390 : : ::rtl::OUStringToOString(sPathToNode,
391 : : RTL_TEXTENCODING_UTF8).getStr(),
392 : : ::rtl::OUStringToOString(rException.Message,
393 : : RTL_TEXTENCODING_UTF8).getStr());
394 : : (void)rException;
395 : : }
396 : 0 : return xNode;
397 : : }
398 : :
399 : 0 : com::sun::star::uno::Any ConfigurationAccess::GetConfigProperty( const PPPOptimizerTokenEnum ePropertyToken ) const
400 : : {
401 : 0 : Any aRetValue;
402 : 0 : const OptimizerSettings& rSettings( maSettings.front() );
403 : : try
404 : : {
405 : 0 : switch( ePropertyToken )
406 : : {
407 : 0 : case TK_Name : aRetValue <<= rSettings.maName; break;
408 : 0 : case TK_JPEGCompression : aRetValue <<= rSettings.mbJPEGCompression; break;
409 : 0 : case TK_JPEGQuality : aRetValue <<= rSettings.mnJPEGQuality; break;
410 : 0 : case TK_RemoveCropArea : aRetValue <<= rSettings.mbRemoveCropArea; break;
411 : 0 : case TK_ImageResolution : aRetValue <<= rSettings.mnImageResolution; break;
412 : 0 : case TK_EmbedLinkedGraphics : aRetValue <<= rSettings.mbEmbedLinkedGraphics; break;
413 : 0 : case TK_OLEOptimization : aRetValue <<= rSettings.mbOLEOptimization; break;
414 : 0 : case TK_OLEOptimizationType : aRetValue <<= rSettings.mnOLEOptimizationType; break;
415 : 0 : case TK_DeleteUnusedMasterPages : aRetValue <<= rSettings.mbDeleteUnusedMasterPages; break;
416 : 0 : case TK_DeleteHiddenSlides : aRetValue <<= rSettings.mbDeleteHiddenSlides; break;
417 : 0 : case TK_DeleteNotesPages : aRetValue <<= rSettings.mbDeleteNotesPages; break;
418 : 0 : case TK_SaveAs : aRetValue <<= rSettings.mbSaveAs; break;
419 : 0 : case TK_SaveAsURL : aRetValue <<= rSettings.maSaveAsURL; break;
420 : 0 : case TK_FilterName : aRetValue <<= rSettings.maFilterName; break;
421 : 0 : case TK_OpenNewDocument : aRetValue <<= rSettings.mbOpenNewDocument; break;
422 : 0 : case TK_EstimatedFileSize : aRetValue <<= rSettings.mnEstimatedFileSize; break;
423 : : default:
424 : 0 : break;
425 : : }
426 : : }
427 : 0 : catch (const Exception&)
428 : : {
429 : : }
430 : 0 : return aRetValue;
431 : : }
432 : :
433 : 0 : void ConfigurationAccess::SetConfigProperty( const PPPOptimizerTokenEnum ePropertyToken, const com::sun::star::uno::Any& rValue )
434 : : {
435 : 0 : OptimizerSettings& rSettings( maSettings.front() );
436 : : try
437 : : {
438 : 0 : switch( ePropertyToken )
439 : : {
440 : 0 : case TK_Name : rValue >>= rSettings.maName; break;
441 : 0 : case TK_JPEGCompression : rValue >>= rSettings.mbJPEGCompression; break;
442 : 0 : case TK_JPEGQuality : rValue >>= rSettings.mnJPEGQuality; break;
443 : 0 : case TK_RemoveCropArea : rValue >>= rSettings.mbRemoveCropArea; break;
444 : 0 : case TK_ImageResolution : rValue >>= rSettings.mnImageResolution; break;
445 : 0 : case TK_EmbedLinkedGraphics : rValue >>= rSettings.mbEmbedLinkedGraphics; break;
446 : 0 : case TK_OLEOptimization : rValue >>= rSettings.mbOLEOptimization; break;
447 : 0 : case TK_OLEOptimizationType : rValue >>= rSettings.mnOLEOptimizationType; break;
448 : 0 : case TK_DeleteUnusedMasterPages : rValue >>= rSettings.mbDeleteUnusedMasterPages; break;
449 : 0 : case TK_DeleteHiddenSlides : rValue >>= rSettings.mbDeleteHiddenSlides; break;
450 : 0 : case TK_DeleteNotesPages : rValue >>= rSettings.mbDeleteNotesPages; break;
451 : 0 : case TK_CustomShowName : rValue >>= rSettings.maCustomShowName; break;
452 : 0 : case TK_SaveAs : rValue >>= rSettings.mbSaveAs; break;
453 : 0 : case TK_SaveAsURL : rValue >>= rSettings.maSaveAsURL; break;
454 : 0 : case TK_FilterName : rValue >>= rSettings.maFilterName; break;
455 : 0 : case TK_OpenNewDocument : rValue >>= rSettings.mbOpenNewDocument; break;
456 : 0 : case TK_EstimatedFileSize : rValue >>= rSettings.mnEstimatedFileSize; break;
457 : : default:
458 : 0 : break;
459 : : }
460 : : }
461 : : catch (const Exception&)
462 : : {
463 : : }
464 : 0 : }
465 : :
466 : 0 : sal_Bool ConfigurationAccess::GetConfigProperty( const PPPOptimizerTokenEnum ePropertyToken, const sal_Bool bDefault ) const
467 : : {
468 : 0 : sal_Bool bRetValue = bDefault;
469 : 0 : if ( ! ( GetConfigProperty( ePropertyToken ) >>= bRetValue ) )
470 : 0 : bRetValue = bDefault;
471 : 0 : return bRetValue;
472 : : }
473 : :
474 : 0 : sal_Int16 ConfigurationAccess::GetConfigProperty( const PPPOptimizerTokenEnum ePropertyToken, const sal_Int16 nDefault ) const
475 : : {
476 : 0 : sal_Int16 nRetValue = nDefault;
477 : 0 : if ( ! ( GetConfigProperty( ePropertyToken ) >>= nRetValue ) )
478 : 0 : nRetValue = nDefault;
479 : 0 : return nRetValue;
480 : : }
481 : :
482 : 0 : sal_Int32 ConfigurationAccess::GetConfigProperty( const PPPOptimizerTokenEnum ePropertyToken, const sal_Int32 nDefault ) const
483 : : {
484 : 0 : sal_Int32 nRetValue = nDefault;
485 : 0 : if ( ! ( GetConfigProperty( ePropertyToken ) >>= nRetValue ) )
486 : 0 : nRetValue = nDefault;
487 : 0 : return nRetValue;
488 : : }
489 : :
490 : 0 : Sequence< PropertyValue > ConfigurationAccess::GetConfigurationSequence()
491 : : {
492 : 0 : Sequence< PropertyValue > aRet( 15 );
493 : 0 : OptimizerSettings& rSettings( maSettings.front() );
494 : 0 : aRet[ 0 ].Name = TKGet( TK_JPEGCompression );
495 : 0 : aRet[ 0 ].Value= Any( rSettings.mbJPEGCompression );
496 : 0 : aRet[ 1 ].Name = TKGet( TK_JPEGQuality );
497 : 0 : aRet[ 1 ].Value= Any( rSettings.mnJPEGQuality );
498 : 0 : aRet[ 2 ].Name = TKGet( TK_RemoveCropArea );
499 : 0 : aRet[ 2 ].Value= Any( rSettings.mbRemoveCropArea );
500 : 0 : aRet[ 3 ].Name = TKGet( TK_ImageResolution );
501 : 0 : aRet[ 3 ].Value= Any( rSettings.mnImageResolution );
502 : 0 : aRet[ 4 ].Name = TKGet( TK_EmbedLinkedGraphics );
503 : 0 : aRet[ 4 ].Value= Any( rSettings.mbEmbedLinkedGraphics );
504 : 0 : aRet[ 5 ].Name = TKGet( TK_OLEOptimization );
505 : 0 : aRet[ 5 ].Value= Any( rSettings.mbOLEOptimization );
506 : 0 : aRet[ 6 ].Name = TKGet( TK_OLEOptimizationType );
507 : 0 : aRet[ 6 ].Value= Any( rSettings.mnOLEOptimizationType );
508 : 0 : aRet[ 7 ].Name = TKGet( TK_DeleteUnusedMasterPages );
509 : 0 : aRet[ 7 ].Value= Any( rSettings.mbDeleteUnusedMasterPages );
510 : 0 : aRet[ 8 ].Name = TKGet( TK_DeleteHiddenSlides );
511 : 0 : aRet[ 8 ].Value= Any( rSettings.mbDeleteHiddenSlides );
512 : 0 : aRet[ 9 ].Name = TKGet( TK_DeleteNotesPages );
513 : 0 : aRet[ 9 ].Value= Any( rSettings.mbDeleteNotesPages );
514 : 0 : aRet[ 10].Name = TKGet( TK_CustomShowName );
515 : 0 : aRet[ 10].Value= Any( rSettings.maCustomShowName );
516 : 0 : aRet[ 11].Name = TKGet( TK_SaveAsURL );
517 : 0 : aRet[ 11].Value= Any( rSettings.maSaveAsURL );
518 : 0 : aRet[ 12].Name = TKGet( TK_FilterName );
519 : 0 : aRet[ 12].Value= Any( rSettings.maFilterName );
520 : 0 : aRet[ 13].Name = TKGet( TK_OpenNewDocument );
521 : 0 : aRet[ 13].Value= Any( rSettings.mbOpenNewDocument );
522 : 0 : aRet[ 14].Name = TKGet( TK_EstimatedFileSize );
523 : 0 : aRet[ 14].Value= Any( rSettings.mnEstimatedFileSize );
524 : 0 : return aRet;
525 : : }
526 : :
527 : 0 : std::vector< OptimizerSettings >::iterator ConfigurationAccess::GetOptimizerSettingsByName( const rtl::OUString& rName )
528 : : {
529 : 0 : std::vector< OptimizerSettings >::iterator aIter( maSettings.begin() + 1 );
530 : 0 : while ( aIter != maSettings.end() )
531 : : {
532 : 0 : if ( aIter->maName == rName )
533 : 0 : break;
534 : 0 : aIter++;
535 : : }
536 : 0 : return aIter;
537 : : }
538 : :
539 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|