bump product version to 4.1.6.2
[LibreOffice.git] / sd / source / ui / unoidl / UnoDocumentSettings.cxx
blob22777ed698db8c6241be3e576e03283280a31043
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 .
21 #include <vector>
22 #include <com/sun/star/embed/XStorage.hpp>
23 #include <com/sun/star/embed/ElementModes.hpp>
24 #include <com/sun/star/embed/XTransactedObject.hpp>
25 #include <com/sun/star/lang/XServiceInfo.hpp>
26 #include <com/sun/star/beans/XPropertySet.hpp>
27 #include <com/sun/star/beans/XMultiPropertySet.hpp>
28 #include <com/sun/star/i18n/XForbiddenCharacters.hpp>
29 #include <cppuhelper/implbase3.hxx>
30 #include <comphelper/propertysethelper.hxx>
31 #include <comphelper/propertysetinfo.hxx>
32 #include <tools/urlobj.hxx>
33 #include <svx/xtable.hxx>
34 #include <osl/diagnose.h>
35 #include <osl/mutex.hxx>
36 #include <vcl/svapp.hxx>
38 #include "drawdoc.hxx"
39 #include "DrawDocShell.hxx"
40 #include "unomodel.hxx"
42 #include "optsitem.hxx"
43 #include <sfx2/printer.hxx>
44 #include "sdattr.hxx"
45 #include "../inc/ViewShell.hxx"
46 #include "../inc/FrameView.hxx"
47 #include "Outliner.hxx"
48 #include <xmloff/settingsstore.hxx>
49 #include <editeng/editstat.hxx>
50 #include <svx/unoapi.hxx>
52 #define MAP_LEN(x) x, sizeof(x)-1
54 using namespace ::comphelper;
55 using namespace ::osl;
56 using namespace ::cppu;
57 using namespace ::com::sun::star;
58 using namespace ::com::sun::star::uno;
59 using namespace ::com::sun::star::util;
60 using namespace ::com::sun::star::container;
61 using namespace ::com::sun::star::drawing;
62 using namespace ::com::sun::star::lang;
63 using namespace ::com::sun::star::document;
64 using namespace ::com::sun::star::frame;
65 using namespace ::com::sun::star::beans;
66 using namespace ::com::sun::star::i18n;
68 namespace sd
70 class DocumentSettings : public WeakImplHelper3< XPropertySet, XMultiPropertySet, XServiceInfo >,
71 public comphelper::PropertySetHelper,
72 public DocumentSettingsSerializer
74 public:
75 DocumentSettings( SdXImpressDocument* pModel );
76 virtual ~DocumentSettings() throw();
78 // XInterface
79 virtual Any SAL_CALL queryInterface( const Type& aType ) throw (RuntimeException);
80 virtual void SAL_CALL acquire( ) throw ();
81 virtual void SAL_CALL release( ) throw ();
83 // XPropertySet
84 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
85 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
86 virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
87 virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
88 virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
89 virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
90 virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
92 // XMultiPropertySet
93 virtual void SAL_CALL setPropertyValues( const ::com::sun::star::uno::Sequence< OUString >& aPropertyNames, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aValues ) throw(::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
94 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL getPropertyValues( const ::com::sun::star::uno::Sequence< OUString >& aPropertyNames ) throw(::com::sun::star::uno::RuntimeException);
95 virtual void SAL_CALL addPropertiesChangeListener( const ::com::sun::star::uno::Sequence< OUString >& aPropertyNames, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
96 virtual void SAL_CALL removePropertiesChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
97 virtual void SAL_CALL firePropertiesChangeEvent( const ::com::sun::star::uno::Sequence< OUString >& aPropertyNames, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
99 // XServiceInfo
100 virtual OUString SAL_CALL getImplementationName( ) throw(RuntimeException);
101 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(RuntimeException);
102 virtual Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw(RuntimeException);
104 // DocumentSettingsSerializer cf. xmloff
105 virtual uno::Sequence<beans::PropertyValue>
106 filterStreamsFromStorage(const uno::Reference< embed::XStorage > &xStorage,
107 const uno::Sequence<beans::PropertyValue>& aConfigProps );
108 virtual uno::Sequence<beans::PropertyValue>
109 filterStreamsToStorage(const uno::Reference< embed::XStorage > &xStorage,
110 const uno::Sequence<beans::PropertyValue>& aConfigProps );
112 protected:
113 virtual void _setPropertyValues( const comphelper::PropertyMapEntry** ppEntries, const ::com::sun::star::uno::Any* pValues ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, RuntimeException );
114 virtual void _getPropertyValues( const comphelper::PropertyMapEntry** ppEntries, ::com::sun::star::uno::Any* pValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, RuntimeException );
116 private:
117 bool LoadList( XPropertyListType t, const OUString &rPath,
118 const uno::Reference< embed::XStorage > &xStorage );
119 void AssignURL( XPropertyListType t, const Any* pValue, bool *pOk, bool *pChanged );
120 void ExtractURL( XPropertyListType t, Any* pValue );
121 Reference< XModel > mxModel;
122 SdXImpressDocument* mpModel;
125 Reference< XInterface > SAL_CALL DocumentSettings_createInstance( SdXImpressDocument* pModel )
126 throw( Exception )
128 DBG_ASSERT( pModel, "I need a model for the DocumentSettings!" );
129 return (XWeak*)new DocumentSettings( pModel );
132 enum SdDocumentSettingsPropertyHandles
134 HANDLE_PRINTDRAWING, HANDLE_PRINTNOTES, HANDLE_PRINTHANDOUT, HANDLE_PRINTOUTLINE, HANDLE_MEASUREUNIT, HANDLE_SCALE_NUM,
135 HANDLE_SCALE_DOM, HANDLE_TABSTOP, HANDLE_PRINTPAGENAME, HANDLE_PRINTDATE, HANDLE_PRINTTIME,
136 HANDLE_PRINTHIDENPAGES, HANDLE_PRINTFITPAGE, HANDLE_PRINTTILEPAGE, HANDLE_PRINTBOOKLET, HANDLE_PRINTBOOKLETFRONT,
137 HANDLE_PRINTBOOKLETBACK, HANDLE_PRINTQUALITY, HANDLE_COLORTABLEURL, HANDLE_DASHTABLEURL, HANDLE_LINEENDTABLEURL, HANDLE_HATCHTABLEURL,
138 HANDLE_GRADIENTTABLEURL, HANDLE_BITMAPTABLEURL, HANDLE_FORBIDDENCHARS, HANDLE_APPLYUSERDATA, HANDLE_PAGENUMFMT,
139 HANDLE_PRINTERNAME, HANDLE_PRINTERJOB, HANDLE_PARAGRAPHSUMMATION, HANDLE_CHARCOMPRESS, HANDLE_ASIANPUNCT, HANDLE_UPDATEFROMTEMPLATE,
140 HANDLE_PRINTER_INDEPENDENT_LAYOUT
141 // #i33095#
142 ,HANDLE_LOAD_READONLY, HANDLE_SAVE_VERSION
143 ,HANDLE_SLIDESPERHANDOUT, HANDLE_HANDOUTHORIZONTAL, HANDLE_EMBED_FONTS
146 #define MID_PRINTER 1
148 PropertySetInfo* createSettingsInfoImpl( sal_Bool bIsDraw )
150 static PropertyMapEntry aImpressSettingsInfoMap[] =
152 { MAP_LEN("IsPrintDrawing"), HANDLE_PRINTDRAWING, &::getBooleanCppuType(), 0, MID_PRINTER },
153 { MAP_LEN("IsPrintNotes"), HANDLE_PRINTNOTES, &::getBooleanCppuType(), 0, MID_PRINTER },
154 { MAP_LEN("IsPrintHandout"), HANDLE_PRINTHANDOUT, &::getBooleanCppuType(), 0, MID_PRINTER },
155 { MAP_LEN("IsPrintOutline"), HANDLE_PRINTOUTLINE, &::getBooleanCppuType(), 0, MID_PRINTER },
156 { MAP_LEN("SlidesPerHandout"), HANDLE_SLIDESPERHANDOUT, &::getCppuType((const sal_Int16*)0), 0, MID_PRINTER },
157 { MAP_LEN("HandoutsHorizontal"), HANDLE_HANDOUTHORIZONTAL, &::getBooleanCppuType(), 0, MID_PRINTER },
158 { NULL, 0, 0, NULL, 0, 0 }
161 static PropertyMapEntry aDrawSettingsInfoMap[] =
163 { MAP_LEN("MeasureUnit"), HANDLE_MEASUREUNIT, &::getCppuType((const sal_Int16*)0), 0, 0 },
164 { MAP_LEN("ScaleNumerator"), HANDLE_SCALE_NUM, &::getCppuType((const sal_Int32*)0), 0, 0 },
165 { MAP_LEN("ScaleDenominator"), HANDLE_SCALE_DOM, &::getCppuType((const sal_Int32*)0), 0, 0 },
166 { NULL, 0, 0, NULL, 0, 0 }
169 static PropertyMapEntry aCommonSettingsInfoMap[] =
171 { MAP_LEN("DefaultTabStop"), HANDLE_TABSTOP, &::getCppuType((const sal_Int32*)0), 0, 0 },
172 { MAP_LEN("PrinterName"), HANDLE_PRINTERNAME, &::getCppuType((const OUString*)0), 0, 0 },
173 { MAP_LEN("PrinterSetup"), HANDLE_PRINTERJOB, &::getCppuType((const uno::Sequence < sal_Int8 > *)0), 0, MID_PRINTER },
175 { MAP_LEN("IsPrintPageName"), HANDLE_PRINTPAGENAME, &::getBooleanCppuType(), 0, MID_PRINTER },
176 { MAP_LEN("IsPrintDate"), HANDLE_PRINTDATE, &::getBooleanCppuType(), 0, MID_PRINTER },
177 { MAP_LEN("IsPrintTime"), HANDLE_PRINTTIME, &::getBooleanCppuType(), 0, MID_PRINTER },
178 { MAP_LEN("IsPrintHiddenPages"), HANDLE_PRINTHIDENPAGES, &::getBooleanCppuType(), 0, MID_PRINTER },
179 { MAP_LEN("IsPrintFitPage"), HANDLE_PRINTFITPAGE, &::getBooleanCppuType(), 0, MID_PRINTER },
180 { MAP_LEN("IsPrintTilePage"), HANDLE_PRINTTILEPAGE, &::getBooleanCppuType(), 0, MID_PRINTER },
181 { MAP_LEN("IsPrintBooklet"), HANDLE_PRINTBOOKLET, &::getBooleanCppuType(), 0, MID_PRINTER },
182 { MAP_LEN("IsPrintBookletFront"), HANDLE_PRINTBOOKLETFRONT, &::getBooleanCppuType(), 0, MID_PRINTER },
183 { MAP_LEN("IsPrintBookletBack"), HANDLE_PRINTBOOKLETBACK, &::getBooleanCppuType(), 0, MID_PRINTER },
184 { MAP_LEN("PrintQuality"), HANDLE_PRINTQUALITY, &::getCppuType((const sal_Int32*)0), 0, MID_PRINTER },
185 { MAP_LEN("ColorTableURL"), HANDLE_COLORTABLEURL, &::getCppuType((const OUString*)0), 0, 0 },
186 { MAP_LEN("DashTableURL"), HANDLE_DASHTABLEURL, &::getCppuType((const OUString*)0), 0, 0 },
187 { MAP_LEN("LineEndTableURL"), HANDLE_LINEENDTABLEURL, &::getCppuType((const OUString*)0), 0, 0 },
188 { MAP_LEN("HatchTableURL"), HANDLE_HATCHTABLEURL, &::getCppuType((const OUString*)0), 0, 0 },
189 { MAP_LEN("GradientTableURL"), HANDLE_GRADIENTTABLEURL, &::getCppuType((const OUString*)0), 0, 0 },
190 { MAP_LEN("BitmapTableURL"), HANDLE_BITMAPTABLEURL, &::getCppuType((const OUString*)0), 0, 0 },
192 { MAP_LEN("ForbiddenCharacters"), HANDLE_FORBIDDENCHARS, &::getCppuType((const Reference< XForbiddenCharacters >*)0), 0, 0 },
193 { MAP_LEN("ApplyUserData"), HANDLE_APPLYUSERDATA, &::getBooleanCppuType(), 0, 0 },
195 { MAP_LEN("PageNumberFormat"), HANDLE_PAGENUMFMT, &::getCppuType((const sal_Int32*)0), 0, 0 },
196 { MAP_LEN("ParagraphSummation"), HANDLE_PARAGRAPHSUMMATION, &::getBooleanCppuType(), 0, 0 },
197 { MAP_LEN("CharacterCompressionType"),HANDLE_CHARCOMPRESS, &::getCppuType((sal_Int16*)0), 0, 0 },
198 { MAP_LEN("IsKernAsianPunctuation"),HANDLE_ASIANPUNCT, &::getBooleanCppuType(), 0, 0 },
199 { MAP_LEN("UpdateFromTemplate"), HANDLE_UPDATEFROMTEMPLATE, &::getBooleanCppuType(), 0, 0 },
200 { MAP_LEN("PrinterIndependentLayout"),HANDLE_PRINTER_INDEPENDENT_LAYOUT,&::getCppuType((const sal_Int16*)0), 0, 0 },
201 // --> #i33095#
202 { MAP_LEN("LoadReadonly"), HANDLE_LOAD_READONLY, &::getBooleanCppuType(), 0, 0 },
203 { MAP_LEN("SaveVersionOnClose"), HANDLE_SAVE_VERSION, &::getBooleanCppuType(), 0, 0 },
204 { MAP_LEN("EmbedFonts"), HANDLE_EMBED_FONTS, &::getBooleanCppuType(), 0, 0 },
205 { NULL, 0, 0, NULL, 0, 0 }
208 PropertySetInfo* pInfo = new PropertySetInfo( aCommonSettingsInfoMap );
209 pInfo->add( bIsDraw ? aDrawSettingsInfoMap : aImpressSettingsInfoMap );
211 return pInfo;
215 using namespace ::sd;
217 DocumentSettings::DocumentSettings( SdXImpressDocument* pModel )
218 : PropertySetHelper( createSettingsInfoImpl( !pModel->IsImpressDocument() ) ),
219 mxModel( pModel ),
220 mpModel( pModel )
224 DocumentSettings::~DocumentSettings() throw()
228 bool DocumentSettings::LoadList( XPropertyListType t, const OUString &rInPath,
229 const uno::Reference< embed::XStorage > &xStorage )
231 SdDrawDocument* pDoc = mpModel->GetDoc();
233 sal_Int32 nSlash = rInPath.lastIndexOf('/');
234 OUString aPath, aName;
235 if (nSlash < -1)
236 aName = rInPath;
237 else {
238 aName = rInPath.copy( nSlash + 1 );
239 aPath = rInPath.copy( 0, nSlash );
242 XPropertyListRef pList = XPropertyList::CreatePropertyList(
243 t, aPath, (XOutdevItemPool*)&pDoc->GetPool() );
244 pList->SetName( aName );
246 if( pList->LoadFrom( xStorage, rInPath ) )
248 pDoc->SetPropertyList( pList );
249 return true;
252 return false;
255 void DocumentSettings::AssignURL( XPropertyListType t, const Any* pValue,
256 bool *pOk, bool *pChanged )
258 OUString aURL;
259 if( !(bool)( *pValue >>= aURL ) )
260 return;
262 if( LoadList( t, aURL, uno::Reference< embed::XStorage >() ) )
263 *pOk = *pChanged = true;
266 static struct {
267 const char *pName;
268 XPropertyListType t;
269 } aURLPropertyNames[] = {
270 { "ColorTableURL", XCOLOR_LIST },
271 { "DashTableURL", XDASH_LIST },
272 { "LineEndTableURL", XLINE_END_LIST },
273 { "HatchTableURL", XHATCH_LIST },
274 { "GradientTableURL", XGRADIENT_LIST },
275 { "BitmapTableURL", XBITMAP_LIST }
278 static XPropertyListType getTypeOfName( const OUString &aName )
280 for( size_t i = 0; i < SAL_N_ELEMENTS( aURLPropertyNames ); i++ ) {
281 if( aName.equalsAscii( aURLPropertyNames[i].pName ) )
282 return aURLPropertyNames[i].t;
284 return (XPropertyListType) -1;
287 static OUString getNameOfType( XPropertyListType t )
289 for( size_t i = 0; i < SAL_N_ELEMENTS( aURLPropertyNames ); i++ ) {
290 if( t == aURLPropertyNames[i].t )
291 return OUString( aURLPropertyNames[i].pName,
292 strlen( aURLPropertyNames[i].pName ) - 3,
293 RTL_TEXTENCODING_UTF8 );
295 return OUString();
298 uno::Sequence<beans::PropertyValue>
299 DocumentSettings::filterStreamsFromStorage(
300 const uno::Reference< embed::XStorage > &xStorage,
301 const uno::Sequence<beans::PropertyValue>& aConfigProps )
303 uno::Sequence<beans::PropertyValue> aRet( aConfigProps.getLength() );
304 int nRet = 0;
305 for( sal_Int32 i = 0; i < aConfigProps.getLength(); i++ )
307 XPropertyListType t = getTypeOfName( aConfigProps[i].Name );
308 if (t < 0)
309 aRet[nRet++] = aConfigProps[i];
310 else
312 OUString aURL;
313 aConfigProps[i].Value >>= aURL;
314 LoadList( t, aURL, xStorage );
317 aRet.realloc( nRet );
318 return aRet;
321 uno::Sequence<beans::PropertyValue>
322 DocumentSettings::filterStreamsToStorage(
323 const uno::Reference< embed::XStorage > &xStorage,
324 const uno::Sequence<beans::PropertyValue>& aConfigProps )
326 uno::Sequence<beans::PropertyValue> aRet( aConfigProps.getLength() );
328 bool bHasEmbed = false;
329 SdDrawDocument* pDoc = mpModel->GetDoc();
330 for( size_t i = 0; i < SAL_N_ELEMENTS( aURLPropertyNames ); i++ )
332 XPropertyListRef pList = pDoc->GetPropertyList( (XPropertyListType) i );
333 if( ( bHasEmbed = pList.is() && pList->IsEmbedInDocument() ) )
334 break;
336 if( !bHasEmbed )
337 return aConfigProps;
339 try {
340 // create Settings/ sub storage.
341 uno::Reference< embed::XStorage > xSubStorage;
342 xSubStorage = xStorage->openStorageElement( "Settings" ,
343 embed::ElementModes::WRITE | embed::ElementModes::TRUNCATE );
344 if( !xSubStorage.is() )
345 return aRet;
347 // now populate it
348 for( sal_Int32 i = 0; i < aConfigProps.getLength(); i++ )
350 XPropertyListType t = getTypeOfName( aConfigProps[i].Name );
351 aRet[i] = aConfigProps[i];
352 if (t >= 0) {
353 XPropertyListRef pList = pDoc->GetPropertyList( t );
354 if( !pList.is() || !pList->IsEmbedInDocument() )
355 continue; // no change ...
356 else
358 // Such specific path construction is grim.
359 OUString aValue;
360 aRet[i].Value >>= aValue;
362 OUStringBuffer aName( getNameOfType( t ) );
363 OUString aResult;
364 if( pList->SaveTo( xSubStorage, aName.makeStringAndClear(), &aResult ) )
366 OUString aRealPath( "Settings/" );
367 aRealPath += aResult;
368 aRet[i].Value <<= aRealPath;
374 // surprisingly difficult to make it really exist
375 uno::Reference< embed::XTransactedObject > xTrans( xSubStorage, UNO_QUERY );
376 if( xTrans.is() )
377 xTrans->commit();
378 uno::Reference< lang::XComponent > xComp( xSubStorage, UNO_QUERY );
379 if( xComp.is() )
380 xSubStorage->dispose();
381 } catch (const uno::Exception &e) {
382 (void)e;
383 // fprintf (stderr, "saving etc. exception '%s'\n",
384 // OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8).getStr());
387 return aRet;
390 void
391 DocumentSettings::_setPropertyValues(const PropertyMapEntry** ppEntries,
392 const Any* pValues)
393 throw (UnknownPropertyException, PropertyVetoException,
394 IllegalArgumentException, WrappedTargetException, RuntimeException)
396 ::SolarMutexGuard aGuard;
398 SdDrawDocument* pDoc = mpModel->GetDoc();
399 ::sd::DrawDocShell* pDocSh = mpModel->GetDocShell();
400 if( NULL == pDoc || NULL == pDocSh )
402 throw RuntimeException("Document or Shell missing",
403 static_cast<OWeakObject *>(this));
406 sal_Bool bValue = sal_False;
407 bool bOk, bChanged = false, bOptionsChanged = false;
409 SdOptionsPrintItem aOptionsPrintItem( ATTR_OPTIONS_PRINT );
411 SfxPrinter* pPrinter = pDocSh->GetPrinter( sal_False );
412 if( pPrinter )
414 SdOptionsPrintItem* pPrinterOptions = NULL;
415 if(pPrinter->GetOptions().GetItemState( ATTR_OPTIONS_PRINT, sal_False, (const SfxPoolItem**) &pPrinterOptions) == SFX_ITEM_SET)
416 aOptionsPrintItem.GetOptionsPrint() = pPrinterOptions->GetOptionsPrint();
418 else
420 aOptionsPrintItem.SetOptions( SD_MOD()->GetSdOptions(pDoc->GetDocumentType()) );
422 SdOptionsPrint& aPrintOpts = aOptionsPrintItem.GetOptionsPrint();
424 for( ; *ppEntries; ppEntries++, pValues++ )
426 bOk = false;
428 switch( (*ppEntries)->mnHandle )
430 case HANDLE_COLORTABLEURL:
431 AssignURL( XCOLOR_LIST, pValues, &bOk, &bChanged );
432 break;
434 case HANDLE_DASHTABLEURL:
435 AssignURL( XDASH_LIST, pValues, &bOk, &bChanged );
436 break;
438 case HANDLE_LINEENDTABLEURL:
439 AssignURL( XLINE_END_LIST, pValues, &bOk, &bChanged );
440 break;
442 case HANDLE_HATCHTABLEURL:
443 AssignURL( XHATCH_LIST, pValues, &bOk, &bChanged );
444 break;
446 case HANDLE_GRADIENTTABLEURL:
447 AssignURL( XGRADIENT_LIST, pValues, &bOk, &bChanged );
448 break;
450 case HANDLE_BITMAPTABLEURL:
451 AssignURL( XBITMAP_LIST, pValues, &bOk, &bChanged );
452 break;
454 case HANDLE_FORBIDDENCHARS:
455 bOk = true;
456 break;
458 case HANDLE_APPLYUSERDATA:
460 sal_Bool bApplyUserData = sal_False;
461 if( *pValues >>= bApplyUserData )
463 bChanged = ( bApplyUserData != pDocSh->IsUseUserData() );
464 pDocSh->SetUseUserData( bApplyUserData );
465 bOk = true;
468 break;
469 case HANDLE_PRINTDRAWING:
470 if( *pValues >>= bValue )
472 if( aPrintOpts.IsDraw() != bValue )
474 aPrintOpts.SetDraw( bValue );
475 bOptionsChanged = true;
478 bOk = true;
480 break;
481 case HANDLE_PRINTNOTES:
482 if( *pValues >>= bValue )
484 if( aPrintOpts.IsNotes() != bValue )
486 aPrintOpts.SetNotes( bValue );
487 bOptionsChanged = true;
490 bOk = true;
492 break;
493 case HANDLE_PRINTHANDOUT:
494 if( *pValues >>= bValue )
496 if( aPrintOpts.IsHandout() != bValue)
498 aPrintOpts.SetHandout( bValue );
499 bOptionsChanged = true;
502 bOk = true;
504 break;
505 case HANDLE_PRINTOUTLINE:
506 if( *pValues >>= bValue )
508 if( aPrintOpts.IsOutline() != bValue)
510 aPrintOpts.SetOutline( bValue );
511 bOptionsChanged = true;
513 bOk = true;
515 break;
516 case HANDLE_SLIDESPERHANDOUT:
518 sal_Int16 nValue = 0;
519 if( (*pValues >>= nValue) && (nValue >= 1) && (nValue <= 9) )
521 if( static_cast<sal_Int16>( aPrintOpts.GetHandoutPages() ) != nValue )
523 aPrintOpts.SetHandoutPages( static_cast< sal_uInt16 >( nValue ) );
524 bOptionsChanged = true;
526 bOk = true;
529 break;
530 case HANDLE_HANDOUTHORIZONTAL:
531 if( *pValues >>= bValue )
533 if( aPrintOpts.IsHandoutHorizontal() != bValue )
535 aPrintOpts.SetHandoutHorizontal( bValue );
536 bOptionsChanged = true;
538 bOk = true;
540 break;
542 case HANDLE_PRINTPAGENAME:
543 if( *pValues >>= bValue )
545 if( aPrintOpts.IsPagename() != bValue)
547 aPrintOpts.SetPagename( bValue );
548 bOptionsChanged = true;
550 bOk = true;
552 break;
553 case HANDLE_PRINTDATE:
554 if( *pValues >>= bValue )
556 if( aPrintOpts.IsDate() != bValue)
558 aPrintOpts.SetDate( bValue );
559 bOptionsChanged = true;
561 bOk = true;
563 break;
564 case HANDLE_PRINTTIME:
565 if( *pValues >>= bValue )
567 if( aPrintOpts.IsDate() != bValue)
569 aPrintOpts.SetTime( bValue );
570 bOptionsChanged = true;
572 bOk = true;
574 break;
575 case HANDLE_PRINTHIDENPAGES:
576 if( *pValues >>= bValue )
578 if( aPrintOpts.IsHiddenPages() != bValue)
580 aPrintOpts.SetHiddenPages( bValue );
581 bOptionsChanged = true;
583 bOk = true;
585 break;
586 case HANDLE_PRINTFITPAGE:
587 if( *pValues >>= bValue )
589 if( aPrintOpts.IsPagesize() != bValue)
591 aPrintOpts.SetPagesize( bValue );
592 bOptionsChanged = true;
594 bOk = true;
596 break;
597 case HANDLE_PRINTTILEPAGE:
598 if( *pValues >>= bValue )
600 if( aPrintOpts.IsPagetile() != bValue)
602 aPrintOpts.SetPagetile( bValue );
603 bOptionsChanged = true;
605 bOk = true;
607 break;
608 case HANDLE_PRINTBOOKLET:
609 if( *pValues >>= bValue )
611 if( aPrintOpts.IsBooklet() != bValue)
613 aPrintOpts.SetBooklet( bValue );
614 bOptionsChanged = true;
616 bOk = true;
618 break;
619 case HANDLE_PRINTBOOKLETFRONT:
620 if( *pValues >>= bValue )
622 if( aPrintOpts.IsFrontPage() != bValue)
624 aPrintOpts.SetFrontPage( bValue );
625 bOptionsChanged = true;
627 bOk = true;
629 break;
630 case HANDLE_PRINTBOOKLETBACK:
631 if( *pValues >>= bValue )
633 if( aPrintOpts.IsBackPage() != bValue)
635 aPrintOpts.SetBackPage( bValue );
636 bOptionsChanged = true;
638 bOk = true;
640 break;
641 case HANDLE_PRINTQUALITY:
643 sal_Int32 nValue = 0;
644 if( *pValues >>= nValue )
646 if( aPrintOpts.GetOutputQuality() != nValue)
648 aPrintOpts.SetOutputQuality( (sal_uInt16)nValue );
649 bOptionsChanged = true;
651 bOk = true;
654 break;
655 case HANDLE_MEASUREUNIT:
657 sal_Int16 nValue = 0;
658 if( *pValues >>= nValue )
660 short nFieldUnit;
661 if( SvxMeasureUnitToFieldUnit( nValue, nFieldUnit ) )
663 pDoc->SetUIUnit((FieldUnit)nFieldUnit );
664 bOk = true;
668 break;
669 case HANDLE_SCALE_NUM:
671 sal_Int32 nValue = 0;
672 if( *pValues >>= nValue )
674 Fraction aFract( nValue, pDoc->GetUIScale().GetDenominator() );
675 pDoc->SetUIScale( aFract );
676 bOk = true;
677 bChanged = true;
680 break;
681 case HANDLE_SCALE_DOM:
683 sal_Int32 nValue = 0;
684 if( *pValues >>= nValue )
686 Fraction aFract( pDoc->GetUIScale().GetNumerator(), nValue );
687 pDoc->SetUIScale( aFract );
688 bOk = true;
689 bChanged = true;
692 break;
694 case HANDLE_TABSTOP:
696 sal_Int32 nValue = 0;
697 if( (*pValues >>= nValue) && (nValue >= 0) )
699 pDoc->SetDefaultTabulator((sal_uInt16)nValue);
700 bOk = true;
701 bChanged = true;
704 break;
705 case HANDLE_PAGENUMFMT:
707 sal_Int32 nValue = 0;
708 if( (*pValues >>= nValue ) && (nValue >= SVX_CHARS_UPPER_LETTER ) && (nValue <= SVX_PAGEDESC) )
710 pDoc->SetPageNumType((SvxNumType)nValue);
711 bOk = true;
712 bChanged = true;
715 break;
716 case HANDLE_PRINTERNAME:
718 OUString aPrinterName;
719 if( *pValues >>= aPrinterName )
721 bOk = true;
722 if( !aPrinterName.isEmpty() && pDocSh->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED )
724 SfxPrinter *pTempPrinter = pDocSh->GetPrinter( sal_True );
725 if (pTempPrinter)
727 SfxPrinter *pNewPrinter = new SfxPrinter( pTempPrinter->GetOptions().Clone(), aPrinterName );
728 pDocSh->SetPrinter( pNewPrinter );
733 break;
734 case HANDLE_PRINTERJOB:
736 Sequence < sal_Int8 > aSequence;
737 if ( *pValues >>= aSequence )
739 bOk = true;
740 sal_uInt32 nSize = aSequence.getLength();
741 if( nSize )
743 SvMemoryStream aStream (aSequence.getArray(), nSize, STREAM_READ );
744 aStream.Seek ( STREAM_SEEK_TO_BEGIN );
745 SfxItemSet* pItemSet;
747 if( pPrinter )
749 pItemSet = pPrinter->GetOptions().Clone();
751 else
753 pItemSet = new SfxItemSet(pDoc->GetPool(),
754 SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN,
755 SID_PRINTER_CHANGESTODOC, SID_PRINTER_CHANGESTODOC,
756 ATTR_OPTIONS_PRINT, ATTR_OPTIONS_PRINT,
757 0 );
760 pPrinter = SfxPrinter::Create ( aStream, pItemSet );
762 MapMode aMM (pPrinter->GetMapMode());
763 aMM.SetMapUnit(MAP_100TH_MM);
764 pPrinter->SetMapMode(aMM);
766 pDocSh->SetPrinter( pPrinter );
768 pPrinter = NULL;
772 break;
774 case HANDLE_PARAGRAPHSUMMATION :
776 sal_Bool bIsSummationOfParagraphs = sal_False;
777 if ( *pValues >>= bIsSummationOfParagraphs )
779 bOk = true;
780 bChanged = true;
781 if ( pDoc->GetDocumentType() == DOCUMENT_TYPE_IMPRESS )
783 sal_uInt32 nSum = bIsSummationOfParagraphs ? EE_CNTRL_ULSPACESUMMATION : 0;
784 sal_uInt32 nCntrl;
786 pDoc->SetSummationOfParagraphs( bIsSummationOfParagraphs );
787 SdDrawDocument* pDocument = pDocSh->GetDoc();
788 SdrOutliner& rOutl = pDocument->GetDrawOutliner();
789 nCntrl = rOutl.GetControlWord() &~ EE_CNTRL_ULSPACESUMMATION;
790 rOutl.SetControlWord( nCntrl | nSum );
791 ::sd::Outliner* pOutl = pDocument->GetOutliner( sal_False );
792 if( pOutl )
794 nCntrl = pOutl->GetControlWord() &~ EE_CNTRL_ULSPACESUMMATION;
795 pOutl->SetControlWord( nCntrl | nSum );
797 pOutl = pDocument->GetInternalOutliner( sal_False );
798 if( pOutl )
800 nCntrl = pOutl->GetControlWord() &~ EE_CNTRL_ULSPACESUMMATION;
801 pOutl->SetControlWord( nCntrl | nSum );
806 break;
808 case HANDLE_CHARCOMPRESS:
810 sal_Int16 nCharCompressType = 0;
811 if( *pValues >>= nCharCompressType )
813 bOk = true;
815 pDoc->SetCharCompressType( (sal_uInt16)nCharCompressType );
816 SdDrawDocument* pDocument = pDocSh->GetDoc();
817 SdrOutliner& rOutl = pDocument->GetDrawOutliner();
818 rOutl.SetAsianCompressionMode( (sal_uInt16)nCharCompressType );
819 ::sd::Outliner* pOutl = pDocument->GetOutliner( sal_False );
820 if( pOutl )
822 pOutl->SetAsianCompressionMode( (sal_uInt16)nCharCompressType );
824 pOutl = pDocument->GetInternalOutliner( sal_False );
825 if( pOutl )
827 pOutl->SetAsianCompressionMode( (sal_uInt16)nCharCompressType );
830 break;
833 case HANDLE_ASIANPUNCT:
835 sal_Bool bAsianPunct = sal_False;
836 if( *pValues >>= bAsianPunct )
838 bOk = true;
840 pDoc->SetKernAsianPunctuation( bAsianPunct );
841 SdDrawDocument* pDocument = pDocSh->GetDoc();
842 SdrOutliner& rOutl = pDocument->GetDrawOutliner();
843 rOutl.SetKernAsianPunctuation( bAsianPunct );
844 ::sd::Outliner* pOutl = pDocument->GetOutliner( sal_False );
845 if( pOutl )
847 pOutl->SetKernAsianPunctuation( bAsianPunct );
849 pOutl = pDocument->GetInternalOutliner( sal_False );
850 if( pOutl )
852 pOutl->SetKernAsianPunctuation( bAsianPunct );
855 break;
858 case HANDLE_UPDATEFROMTEMPLATE:
860 sal_Bool value = sal_False;
861 if( *pValues >>= value )
863 bChanged = ( value != pDocSh->IsQueryLoadTemplate() );
864 pDocSh->SetQueryLoadTemplate( value );
865 bOk = true;
868 break;
870 case HANDLE_PRINTER_INDEPENDENT_LAYOUT:
872 // Just propagate the new printer independent layout mode to
873 // the document and determine it really differs from the old
874 // one.
875 sal_Int16 nOldValue =
876 (sal_Int16)pDoc->GetPrinterIndependentLayout ();
877 sal_Int16 nValue = 0;
878 if (*pValues >>= nValue)
880 pDoc->SetPrinterIndependentLayout (nValue);
881 bChanged = (nValue != nOldValue);
882 bOk = true;
885 break;
887 // --> #i33095#
888 case HANDLE_LOAD_READONLY:
890 sal_Bool bNewValue = sal_False;
891 if ( *pValues >>= bNewValue )
893 bChanged = ( pDocSh->IsLoadReadonly() != bNewValue );
894 pDocSh->SetLoadReadonly( bNewValue );
895 bOk = true;
898 break;
900 case HANDLE_SAVE_VERSION:
902 sal_Bool bNewValue = sal_False;
903 if ( *pValues >>= bNewValue )
905 bChanged = ( pDocSh->IsSaveVersionOnClose() != bNewValue );
906 pDocSh->SetSaveVersionOnClose( bNewValue );
907 bOk = true;
910 break;
912 case HANDLE_EMBED_FONTS:
914 bool bNewValue = false;
915 if ( *pValues >>= bNewValue )
917 bChanged = ( pDoc->IsUsingEmbededFonts() != bNewValue );
918 pDoc->SetIsUsingEmbededFonts( bNewValue );
919 bOk = true;
922 break;
924 default:
925 throw UnknownPropertyException();
928 if( !bOk )
929 throw IllegalArgumentException();
932 if( bOptionsChanged )
934 if( !pPrinter )
935 pPrinter = pDocSh->GetPrinter( sal_True );
936 SfxItemSet aNewOptions( pPrinter->GetOptions() );
937 aNewOptions.Put( aOptionsPrintItem );
938 pPrinter->SetOptions( aNewOptions );
941 if( bChanged || bOptionsChanged )
942 mpModel->SetModified( sal_True );
945 void DocumentSettings::ExtractURL( XPropertyListType t, Any* pValue )
947 XPropertyListRef pList = mpModel->GetDoc()->GetPropertyList( t );
948 if( !pList.is() )
949 return;
951 INetURLObject aPathURL( pList->GetPath() );
952 aPathURL.insertName( pList->GetName() );
953 aPathURL.setExtension( pList->GetDefaultExt() );
954 OUString aPath( aPathURL.GetMainURL( INetURLObject::NO_DECODE ) );
955 *pValue <<= aPath;
958 void
959 DocumentSettings::_getPropertyValues(
960 const PropertyMapEntry** ppEntries, Any* pValue)
961 throw (UnknownPropertyException, WrappedTargetException, RuntimeException)
963 ::SolarMutexGuard aGuard;
965 SdDrawDocument* pDoc = mpModel->GetDoc();
966 ::sd::DrawDocShell* pDocSh = mpModel->GetDocShell();
967 if( NULL == pDoc || NULL == pDocSh )
969 throw RuntimeException("Document or Shell missing",
970 static_cast<OWeakObject *>(this));
973 SdOptionsPrintItem aOptionsPrintItem( ATTR_OPTIONS_PRINT );
975 SfxPrinter* pPrinter = pDocSh->GetPrinter( sal_False );
976 if( pPrinter )
978 SdOptionsPrintItem* pPrinterOptions = NULL;
979 if(pPrinter->GetOptions().GetItemState( ATTR_OPTIONS_PRINT, sal_False, (const SfxPoolItem**) &pPrinterOptions) == SFX_ITEM_SET)
980 aOptionsPrintItem.GetOptionsPrint() = pPrinterOptions->GetOptionsPrint();
982 else
984 aOptionsPrintItem.SetOptions( SD_MOD()->GetSdOptions(pDoc->GetDocumentType()) );
986 SdOptionsPrint& aPrintOpts = aOptionsPrintItem.GetOptionsPrint();
988 for( ; *ppEntries; ppEntries++, pValue++ )
990 switch( (*ppEntries)->mnHandle )
992 case HANDLE_COLORTABLEURL:
993 ExtractURL( XCOLOR_LIST, pValue );
994 break;
995 case HANDLE_DASHTABLEURL:
996 ExtractURL( XDASH_LIST, pValue );
997 break;
998 case HANDLE_LINEENDTABLEURL:
999 ExtractURL( XLINE_END_LIST, pValue );
1000 break;
1001 case HANDLE_HATCHTABLEURL:
1002 ExtractURL( XHATCH_LIST, pValue );
1003 break;
1004 case HANDLE_GRADIENTTABLEURL:
1005 ExtractURL( XGRADIENT_LIST, pValue );
1006 break;
1007 case HANDLE_BITMAPTABLEURL:
1008 ExtractURL( XBITMAP_LIST, pValue );
1009 break;
1010 case HANDLE_FORBIDDENCHARS:
1011 *pValue <<= mpModel->getForbiddenCharsTable();
1012 break;
1013 case HANDLE_APPLYUSERDATA:
1014 *pValue <<= pDocSh->IsUseUserData();
1015 break;
1016 case HANDLE_PRINTDRAWING:
1017 *pValue <<= (sal_Bool)aPrintOpts.IsDraw();
1018 break;
1019 case HANDLE_PRINTNOTES:
1020 *pValue <<= (sal_Bool)aPrintOpts.IsNotes();
1021 break;
1022 case HANDLE_PRINTHANDOUT:
1023 *pValue <<= (sal_Bool)aPrintOpts.IsHandout();
1024 break;
1025 case HANDLE_PRINTOUTLINE:
1026 *pValue <<= (sal_Bool)aPrintOpts.IsOutline();
1027 break;
1028 case HANDLE_SLIDESPERHANDOUT:
1029 *pValue <<= (sal_Int16)aPrintOpts.GetHandoutPages();
1030 break;
1031 case HANDLE_HANDOUTHORIZONTAL:
1032 *pValue <<= (sal_Bool)aPrintOpts.IsHandoutHorizontal();
1033 break;
1034 case HANDLE_PRINTPAGENAME:
1035 *pValue <<= (sal_Bool)aPrintOpts.IsPagename();
1036 break;
1037 case HANDLE_PRINTDATE:
1038 *pValue <<= (sal_Bool)aPrintOpts.IsDate();
1039 break;
1040 case HANDLE_PRINTTIME:
1041 *pValue <<= (sal_Bool)aPrintOpts.IsTime();
1042 break;
1043 case HANDLE_PRINTHIDENPAGES:
1044 *pValue <<= (sal_Bool)aPrintOpts.IsHiddenPages();
1045 break;
1046 case HANDLE_PRINTFITPAGE:
1047 *pValue <<= (sal_Bool)aPrintOpts.IsPagesize();
1048 break;
1049 case HANDLE_PRINTTILEPAGE:
1050 *pValue <<= (sal_Bool)aPrintOpts.IsPagetile();
1051 break;
1052 case HANDLE_PRINTBOOKLET:
1053 *pValue <<= (sal_Bool)aPrintOpts.IsBooklet();
1054 break;
1055 case HANDLE_PRINTBOOKLETFRONT:
1056 *pValue <<= (sal_Bool)aPrintOpts.IsFrontPage();
1057 break;
1058 case HANDLE_PRINTBOOKLETBACK:
1059 *pValue <<= (sal_Bool)aPrintOpts.IsBackPage();
1060 break;
1061 case HANDLE_PRINTQUALITY:
1062 *pValue <<= (sal_Int32)aPrintOpts.GetOutputQuality();
1063 break;
1064 case HANDLE_MEASUREUNIT:
1066 short nMeasure;
1067 SvxFieldUnitToMeasureUnit( (const short)pDoc->GetUIUnit(), nMeasure );
1068 *pValue <<= (sal_Int16)nMeasure;
1070 break;
1071 case HANDLE_SCALE_NUM:
1072 *pValue <<= (sal_Int32)pDoc->GetUIScale().GetNumerator();
1073 break;
1074 case HANDLE_SCALE_DOM:
1075 *pValue <<= (sal_Int32)pDoc->GetUIScale().GetDenominator();
1076 break;
1077 case HANDLE_TABSTOP:
1078 *pValue <<= (sal_Int32)pDoc->GetDefaultTabulator();
1079 break;
1080 case HANDLE_PAGENUMFMT:
1081 *pValue <<= (sal_Int32)pDoc->GetPageNumType();
1082 break;
1083 case HANDLE_PRINTERNAME:
1085 SfxPrinter *pTempPrinter = pDocSh->GetPrinter( sal_False );
1086 *pValue <<= pTempPrinter ? OUString ( pTempPrinter->GetName()) : OUString();
1088 break;
1089 case HANDLE_PRINTERJOB:
1091 SfxPrinter *pTempPrinter = pDocSh->GetPrinter( sal_False );
1092 if (pTempPrinter)
1094 SvMemoryStream aStream;
1095 pTempPrinter->Store( aStream );
1096 aStream.Seek ( STREAM_SEEK_TO_END );
1097 sal_uInt32 nSize = aStream.Tell();
1098 aStream.Seek ( STREAM_SEEK_TO_BEGIN );
1099 Sequence < sal_Int8 > aSequence ( nSize );
1100 memcpy ( aSequence.getArray(), aStream.GetData(), nSize );
1101 *pValue <<= aSequence;
1103 else
1105 Sequence < sal_Int8 > aSequence;
1106 *pValue <<= aSequence;
1109 break;
1111 case HANDLE_PARAGRAPHSUMMATION :
1113 sal_Bool bIsSummationOfParagraphs = pDoc->IsSummationOfParagraphs();
1114 *pValue <<= bIsSummationOfParagraphs;
1116 break;
1118 case HANDLE_CHARCOMPRESS:
1120 *pValue <<= (sal_Int16)pDoc->GetCharCompressType();
1121 break;
1124 case HANDLE_ASIANPUNCT:
1126 *pValue <<= (sal_Bool)pDoc->IsKernAsianPunctuation();
1127 break;
1130 case HANDLE_UPDATEFROMTEMPLATE:
1132 *pValue <<= pDocSh->IsQueryLoadTemplate();
1134 break;
1136 case HANDLE_PRINTER_INDEPENDENT_LAYOUT:
1138 sal_Int16 nPrinterIndependentLayout =
1139 (sal_Int16)pDoc->GetPrinterIndependentLayout();
1140 *pValue <<= nPrinterIndependentLayout;
1142 break;
1144 // --> #i33095#
1145 case HANDLE_LOAD_READONLY:
1147 *pValue <<= pDocSh->IsLoadReadonly();
1149 break;
1151 case HANDLE_SAVE_VERSION:
1153 *pValue <<= pDocSh->IsSaveVersionOnClose();
1155 break;
1157 case HANDLE_EMBED_FONTS:
1159 *pValue <<= pDoc->IsUsingEmbededFonts();
1161 break;
1163 default:
1164 throw UnknownPropertyException();
1169 // XInterface
1170 Any SAL_CALL DocumentSettings::queryInterface( const Type& aType ) throw (RuntimeException)
1172 return WeakImplHelper3< XPropertySet, XMultiPropertySet, XServiceInfo >::queryInterface( aType );
1175 void SAL_CALL DocumentSettings::acquire( ) throw ()
1177 WeakImplHelper3< XPropertySet, XMultiPropertySet, XServiceInfo >::acquire();
1180 void SAL_CALL DocumentSettings::release( ) throw ()
1182 WeakImplHelper3< XPropertySet, XMultiPropertySet, XServiceInfo >::release();
1186 // XPropertySet
1187 Reference< XPropertySetInfo > SAL_CALL DocumentSettings::getPropertySetInfo( ) throw(RuntimeException)
1189 return PropertySetHelper::getPropertySetInfo();
1192 void SAL_CALL DocumentSettings::setPropertyValue( const OUString& aPropertyName, const Any& aValue ) throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException)
1194 PropertySetHelper::setPropertyValue( aPropertyName, aValue );
1197 Any SAL_CALL DocumentSettings::getPropertyValue( const OUString& PropertyName ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
1199 return PropertySetHelper::getPropertyValue( PropertyName );
1202 void SAL_CALL DocumentSettings::addPropertyChangeListener( const OUString& aPropertyName, const Reference< XPropertyChangeListener >& xListener ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
1204 PropertySetHelper::addPropertyChangeListener( aPropertyName, xListener );
1207 void SAL_CALL DocumentSettings::removePropertyChangeListener( const OUString& aPropertyName, const Reference< XPropertyChangeListener >& aListener ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
1209 PropertySetHelper::removePropertyChangeListener( aPropertyName, aListener );
1212 void SAL_CALL DocumentSettings::addVetoableChangeListener( const OUString& PropertyName, const Reference< XVetoableChangeListener >& aListener ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
1214 PropertySetHelper::addVetoableChangeListener( PropertyName, aListener );
1217 void SAL_CALL DocumentSettings::removeVetoableChangeListener( const OUString& PropertyName, const Reference< XVetoableChangeListener >& aListener ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
1219 PropertySetHelper::removeVetoableChangeListener( PropertyName, aListener );
1222 // XMultiPropertySet
1223 void SAL_CALL DocumentSettings::setPropertyValues( const Sequence< OUString >& aPropertyNames, const Sequence< Any >& aValues ) throw(PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException)
1225 PropertySetHelper::setPropertyValues( aPropertyNames, aValues );
1228 Sequence< Any > SAL_CALL DocumentSettings::getPropertyValues( const Sequence< OUString >& aPropertyNames ) throw(RuntimeException)
1230 return PropertySetHelper::getPropertyValues( aPropertyNames );
1233 void SAL_CALL DocumentSettings::addPropertiesChangeListener( const Sequence< OUString >& aPropertyNames, const Reference< XPropertiesChangeListener >& xListener ) throw(RuntimeException)
1235 PropertySetHelper::addPropertiesChangeListener( aPropertyNames, xListener );
1238 void SAL_CALL DocumentSettings::removePropertiesChangeListener( const Reference< XPropertiesChangeListener >& xListener ) throw(RuntimeException)
1240 PropertySetHelper::removePropertiesChangeListener( xListener );
1243 void SAL_CALL DocumentSettings::firePropertiesChangeEvent( const Sequence< OUString >& aPropertyNames, const Reference< XPropertiesChangeListener >& xListener ) throw(RuntimeException)
1245 PropertySetHelper::firePropertiesChangeEvent( aPropertyNames, xListener );
1248 // XServiceInfo
1249 OUString SAL_CALL DocumentSettings::getImplementationName( )
1250 throw(RuntimeException)
1252 return OUString( "com.sun.star.comp.Draw.DocumentSettings" );
1255 sal_Bool SAL_CALL DocumentSettings::supportsService( const OUString& ServiceName )
1256 throw(RuntimeException)
1258 const Sequence< OUString > aSeq( getSupportedServiceNames() );
1259 sal_Int32 nCount = aSeq.getLength();
1260 const OUString* pServices = aSeq.getConstArray();
1261 while( nCount-- )
1263 if( *pServices++ == ServiceName )
1264 return sal_True;
1267 return sal_True;
1270 Sequence< OUString > SAL_CALL DocumentSettings::getSupportedServiceNames( )
1271 throw(RuntimeException)
1273 Sequence< OUString > aSeq( 2 );
1274 aSeq[0] = "com.sun.star.document.Settings" ;
1275 if( mpModel->IsImpressDocument() )
1277 aSeq[1] = "com.sun.star.presentation.DocumentSettings" ;
1279 else
1281 aSeq[1] = "com.sun.star.drawing.DocumentSettings" ;
1284 return aSeq;
1287 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */