Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sd / source / ui / unoidl / UnoDocumentSettings.cxx
blob331f90b53a50dbb8058b2733e0b2aeb09ae0d770
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 #include <sal/config.h>
22 #include <memory>
23 #include <utility>
24 #include <com/sun/star/embed/XStorage.hpp>
25 #include <com/sun/star/embed/ElementModes.hpp>
26 #include <com/sun/star/embed/XTransactedObject.hpp>
27 #include <com/sun/star/lang/XServiceInfo.hpp>
28 #include <com/sun/star/beans/XPropertySet.hpp>
29 #include <com/sun/star/beans/XMultiPropertySet.hpp>
30 #include <com/sun/star/i18n/XForbiddenCharacters.hpp>
31 #include <cppuhelper/implbase.hxx>
32 #include <cppuhelper/supportsservice.hxx>
33 #include <comphelper/propertysethelper.hxx>
34 #include <comphelper/propertysetinfo.hxx>
35 #include <o3tl/string_view.hxx>
36 #include <tools/debug.hxx>
37 #include <tools/urlobj.hxx>
38 #include <svx/xtable.hxx>
39 #include <vcl/svapp.hxx>
41 #include <drawdoc.hxx>
42 #include <DrawDocShell.hxx>
43 #include "UnoDocumentSettings.hxx"
44 #include <unomodel.hxx>
46 #include <optsitem.hxx>
47 #include <sfx2/printer.hxx>
48 #include <sfx2/sfxsids.hrc>
49 #include <sdattr.hrc>
50 #include <sdmod.hxx>
51 #include <Outliner.hxx>
52 #include <xmloff/settingsstore.hxx>
53 #include <editeng/editstat.hxx>
54 #include <svx/unoapi.hxx>
56 using namespace ::comphelper;
57 using namespace ::cppu;
58 using namespace ::com::sun::star;
59 using namespace ::com::sun::star::uno;
60 using namespace ::com::sun::star::util;
61 using namespace ::com::sun::star::container;
62 using namespace ::com::sun::star::drawing;
63 using namespace ::com::sun::star::lang;
64 using namespace ::com::sun::star::document;
65 using namespace ::com::sun::star::beans;
66 using namespace ::com::sun::star::i18n;
68 namespace sd
70 namespace {
72 class DocumentSettings : public WeakImplHelper< XPropertySet, XMultiPropertySet, XServiceInfo >,
73 public comphelper::PropertySetHelper,
74 public DocumentSettingsSerializer
76 public:
77 explicit DocumentSettings( SdXImpressDocument* pModel );
79 // XInterface
80 virtual Any SAL_CALL queryInterface( const Type& aType ) override;
81 virtual void SAL_CALL acquire( ) noexcept override;
82 virtual void SAL_CALL release( ) noexcept override;
84 // XPropertySet
85 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override;
86 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override;
87 virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override;
88 virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
89 virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
90 virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
91 virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
93 // XMultiPropertySet
94 virtual void SAL_CALL setPropertyValues( const css::uno::Sequence< OUString >& aPropertyNames, const css::uno::Sequence< css::uno::Any >& aValues ) override;
95 virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyValues( const css::uno::Sequence< OUString >& aPropertyNames ) override;
96 virtual void SAL_CALL addPropertiesChangeListener( const css::uno::Sequence< OUString >& aPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override;
97 virtual void SAL_CALL removePropertiesChangeListener( const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override;
98 virtual void SAL_CALL firePropertiesChangeEvent( const css::uno::Sequence< OUString >& aPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override;
100 // XServiceInfo
101 virtual OUString SAL_CALL getImplementationName( ) override;
102 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
103 virtual Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
105 // DocumentSettingsSerializer cf. xmloff
106 virtual uno::Sequence<beans::PropertyValue>
107 filterStreamsFromStorage(OUString const & referer,
108 const uno::Reference< embed::XStorage > &xStorage,
109 const uno::Sequence<beans::PropertyValue>& aConfigProps ) override;
110 virtual uno::Sequence<beans::PropertyValue>
111 filterStreamsToStorage(const uno::Reference< embed::XStorage > &xStorage,
112 const uno::Sequence<beans::PropertyValue>& aConfigProps ) override;
114 protected:
115 virtual void _setPropertyValues( const comphelper::PropertyMapEntry** ppEntries, const css::uno::Any* pValues ) override;
116 virtual void _getPropertyValues( const comphelper::PropertyMapEntry** ppEntries, css::uno::Any* pValue ) override;
118 private:
119 bool LoadList( XPropertyListType t, const OUString &rPath,
120 const OUString &rReferer,
121 const uno::Reference< embed::XStorage > &xStorage );
122 void AssignURL( XPropertyListType t, const Any* pValue, bool *pOk, bool *pChanged );
123 void ExtractURL( XPropertyListType t, Any* pValue );
124 rtl::Reference<SdXImpressDocument> mxModel;
129 Reference< XInterface > DocumentSettings_createInstance( SdXImpressDocument* pModel )
130 noexcept
132 DBG_ASSERT( pModel, "I need a model for the DocumentSettings!" );
133 return static_cast<XWeak*>(new DocumentSettings( pModel ));
136 namespace {
138 enum SdDocumentSettingsPropertyHandles
140 HANDLE_PRINTDRAWING, HANDLE_PRINTNOTES, HANDLE_PRINTHANDOUT, HANDLE_PRINTOUTLINE, HANDLE_MEASUREUNIT, HANDLE_SCALE_NUM,
141 HANDLE_SCALE_DOM, HANDLE_TABSTOP, HANDLE_PRINTPAGENAME, HANDLE_PRINTDATE, HANDLE_PRINTTIME,
142 HANDLE_PRINTHIDDENPAGES, HANDLE_PRINTFITPAGE, HANDLE_PRINTTILEPAGE, HANDLE_PRINTBOOKLET, HANDLE_PRINTBOOKLETFRONT,
143 HANDLE_PRINTBOOKLETBACK, HANDLE_PRINTQUALITY, HANDLE_COLORTABLEURL, HANDLE_DASHTABLEURL, HANDLE_LINEENDTABLEURL, HANDLE_HATCHTABLEURL,
144 HANDLE_GRADIENTTABLEURL, HANDLE_BITMAPTABLEURL, HANDLE_FORBIDDENCHARS, HANDLE_APPLYUSERDATA, HANDLE_SAVETHUMBNAIL, HANDLE_PAGENUMFMT,
145 HANDLE_PRINTERNAME, HANDLE_PRINTERJOB, HANDLE_PRINTERPAPERSIZE, HANDLE_PARAGRAPHSUMMATION, HANDLE_CHARCOMPRESS, HANDLE_ASIANPUNCT,
146 HANDLE_UPDATEFROMTEMPLATE, HANDLE_PRINTER_INDEPENDENT_LAYOUT
147 // #i33095#
148 ,HANDLE_LOAD_READONLY, HANDLE_MODIFY_PASSWD, HANDLE_SAVE_VERSION
149 ,HANDLE_SLIDESPERHANDOUT, HANDLE_HANDOUTHORIZONTAL,
150 HANDLE_EMBED_FONTS, HANDLE_EMBED_USED_FONTS,
151 HANDLE_EMBED_LATIN_SCRIPT_FONTS, HANDLE_EMBED_ASIAN_SCRIPT_FONTS, HANDLE_EMBED_COMPLEX_SCRIPT_FONTS,
152 HANDLE_IMAGE_PREFERRED_DPI
157 #define MID_PRINTER 1
159 static rtl::Reference<PropertySetInfo> createSettingsInfoImpl( bool bIsDraw )
161 static PropertyMapEntry const aImpressSettingsInfoMap[] =
163 { OUString("IsPrintDrawing"), HANDLE_PRINTDRAWING, cppu::UnoType<bool>::get(), 0, MID_PRINTER },
164 { OUString("IsPrintNotes"), HANDLE_PRINTNOTES, cppu::UnoType<bool>::get(), 0, MID_PRINTER },
165 { OUString("IsPrintHandout"), HANDLE_PRINTHANDOUT, cppu::UnoType<bool>::get(), 0, MID_PRINTER },
166 { OUString("IsPrintOutline"), HANDLE_PRINTOUTLINE, cppu::UnoType<bool>::get(), 0, MID_PRINTER },
167 { OUString("SlidesPerHandout"), HANDLE_SLIDESPERHANDOUT, ::cppu::UnoType<sal_Int16>::get(), 0, MID_PRINTER },
168 { OUString("HandoutsHorizontal"), HANDLE_HANDOUTHORIZONTAL, cppu::UnoType<bool>::get(), 0, MID_PRINTER },
171 static PropertyMapEntry const aDrawSettingsInfoMap[] =
173 { OUString("MeasureUnit"), HANDLE_MEASUREUNIT, ::cppu::UnoType<sal_Int16>::get(), 0, 0 },
174 { OUString("ScaleNumerator"), HANDLE_SCALE_NUM, ::cppu::UnoType<sal_Int32>::get(), 0, 0 },
175 { OUString("ScaleDenominator"), HANDLE_SCALE_DOM, ::cppu::UnoType<sal_Int32>::get(), 0, 0 },
178 static PropertyMapEntry const aCommonSettingsInfoMap[] =
180 { OUString("DefaultTabStop"), HANDLE_TABSTOP, ::cppu::UnoType<sal_Int32>::get(), 0, 0 },
181 { OUString("PrinterName"), HANDLE_PRINTERNAME, ::cppu::UnoType<OUString>::get(), 0, 0 },
182 { OUString("PrinterSetup"), HANDLE_PRINTERJOB, cppu::UnoType<uno::Sequence < sal_Int8 >>::get(), 0, MID_PRINTER },
183 { OUString("PrinterPaperFromSetup"), HANDLE_PRINTERPAPERSIZE, cppu::UnoType<bool>::get(), 0, MID_PRINTER },
185 { OUString("IsPrintPageName"), HANDLE_PRINTPAGENAME, cppu::UnoType<bool>::get(), 0, MID_PRINTER },
186 { OUString("IsPrintDate"), HANDLE_PRINTDATE, cppu::UnoType<bool>::get(), 0, MID_PRINTER },
187 { OUString("IsPrintTime"), HANDLE_PRINTTIME, cppu::UnoType<bool>::get(), 0, MID_PRINTER },
188 { OUString("IsPrintHiddenPages"), HANDLE_PRINTHIDDENPAGES, cppu::UnoType<bool>::get(), 0, MID_PRINTER },
189 { OUString("IsPrintFitPage"), HANDLE_PRINTFITPAGE, cppu::UnoType<bool>::get(), 0, MID_PRINTER },
190 { OUString("IsPrintTilePage"), HANDLE_PRINTTILEPAGE, cppu::UnoType<bool>::get(), 0, MID_PRINTER },
191 { OUString("IsPrintBooklet"), HANDLE_PRINTBOOKLET, cppu::UnoType<bool>::get(), 0, MID_PRINTER },
192 { OUString("IsPrintBookletFront"), HANDLE_PRINTBOOKLETFRONT, cppu::UnoType<bool>::get(), 0, MID_PRINTER },
193 { OUString("IsPrintBookletBack"), HANDLE_PRINTBOOKLETBACK, cppu::UnoType<bool>::get(), 0, MID_PRINTER },
194 { OUString("PrintQuality"), HANDLE_PRINTQUALITY, ::cppu::UnoType<sal_Int32>::get(), 0, MID_PRINTER },
195 { OUString("ColorTableURL"), HANDLE_COLORTABLEURL, ::cppu::UnoType<OUString>::get(), 0, 0 },
196 { OUString("DashTableURL"), HANDLE_DASHTABLEURL, ::cppu::UnoType<OUString>::get(), 0, 0 },
197 { OUString("LineEndTableURL"), HANDLE_LINEENDTABLEURL, ::cppu::UnoType<OUString>::get(), 0, 0 },
198 { OUString("HatchTableURL"), HANDLE_HATCHTABLEURL, ::cppu::UnoType<OUString>::get(), 0, 0 },
199 { OUString("GradientTableURL"), HANDLE_GRADIENTTABLEURL, ::cppu::UnoType<OUString>::get(), 0, 0 },
200 { OUString("BitmapTableURL"), HANDLE_BITMAPTABLEURL, ::cppu::UnoType<OUString>::get(), 0, 0 },
202 { OUString("ForbiddenCharacters"), HANDLE_FORBIDDENCHARS, cppu::UnoType<XForbiddenCharacters>::get(), 0, 0 },
203 { OUString("ApplyUserData"), HANDLE_APPLYUSERDATA, cppu::UnoType<bool>::get(), 0, 0 },
204 { OUString("SaveThumbnail"), HANDLE_SAVETHUMBNAIL, cppu::UnoType<bool>::get(), 0, 0 },
206 { OUString("PageNumberFormat"), HANDLE_PAGENUMFMT, ::cppu::UnoType<sal_Int32>::get(), 0, 0 },
207 { OUString("ParagraphSummation"), HANDLE_PARAGRAPHSUMMATION, cppu::UnoType<bool>::get(), 0, 0 },
208 { OUString("CharacterCompressionType"),HANDLE_CHARCOMPRESS, ::cppu::UnoType<sal_Int16>::get(), 0, 0 },
209 { OUString("IsKernAsianPunctuation"),HANDLE_ASIANPUNCT, cppu::UnoType<bool>::get(), 0, 0 },
210 { OUString("UpdateFromTemplate"), HANDLE_UPDATEFROMTEMPLATE, cppu::UnoType<bool>::get(), 0, 0 },
211 { OUString("PrinterIndependentLayout"),HANDLE_PRINTER_INDEPENDENT_LAYOUT,::cppu::UnoType<sal_Int16>::get(), 0, 0 },
212 // --> #i33095#
213 { OUString("LoadReadonly"), HANDLE_LOAD_READONLY, cppu::UnoType<bool>::get(), 0, 0 },
214 { OUString("ModifyPasswordInfo"), HANDLE_MODIFY_PASSWD, cppu::UnoType<uno::Sequence < beans::PropertyValue >>::get(), 0, 0 },
215 { OUString("SaveVersionOnClose"), HANDLE_SAVE_VERSION, cppu::UnoType<bool>::get(), 0, 0 },
216 { OUString("EmbedFonts"), HANDLE_EMBED_FONTS, cppu::UnoType<bool>::get(), 0, 0 },
217 { OUString("EmbedOnlyUsedFonts"), HANDLE_EMBED_USED_FONTS, cppu::UnoType<bool>::get(), 0, 0 },
218 { OUString("EmbedLatinScriptFonts"), HANDLE_EMBED_LATIN_SCRIPT_FONTS, cppu::UnoType<bool>::get(), 0, 0 },
219 { OUString("EmbedAsianScriptFonts"), HANDLE_EMBED_ASIAN_SCRIPT_FONTS, cppu::UnoType<bool>::get(), 0, 0 },
220 { OUString("EmbedComplexScriptFonts"), HANDLE_EMBED_COMPLEX_SCRIPT_FONTS, cppu::UnoType<bool>::get(), 0, 0 },
221 { OUString("ImagePreferredDPI"), HANDLE_IMAGE_PREFERRED_DPI, cppu::UnoType<sal_Int32>::get(), 0, 0 },
224 rtl::Reference<PropertySetInfo> xInfo = new PropertySetInfo( aCommonSettingsInfoMap );
225 if (bIsDraw)
226 xInfo->add( aDrawSettingsInfoMap );
227 else
228 xInfo->add( aImpressSettingsInfoMap );
230 return xInfo;
234 using namespace ::sd;
236 DocumentSettings::DocumentSettings( SdXImpressDocument* pModel )
237 : PropertySetHelper( createSettingsInfoImpl( !pModel->IsImpressDocument() ) ),
238 mxModel( pModel )
242 bool DocumentSettings::LoadList( XPropertyListType t, const OUString &rInPath,
243 const OUString &rReferer,
244 const uno::Reference< embed::XStorage > &xStorage )
246 SdDrawDocument* pDoc = mxModel->GetDoc();
248 sal_Int32 nSlash = rInPath.lastIndexOf('/');
249 OUString aPath, aName;
250 if (nSlash < 0)
251 aName = rInPath;
252 else {
253 aName = rInPath.copy( nSlash + 1 );
254 aPath = rInPath.copy( 0, nSlash );
257 XPropertyListRef pList = XPropertyList::CreatePropertyList(
258 t, aPath, rReferer );
259 pList->SetName( aName );
261 if( pList->LoadFrom( xStorage, rInPath, rReferer ) )
263 pDoc->SetPropertyList( pList );
264 return true;
267 return false;
270 void DocumentSettings::AssignURL( XPropertyListType t, const Any* pValue,
271 bool *pOk, bool *pChanged )
273 OUString aURL;
274 if( !( *pValue >>= aURL ) )
275 return;
277 if( LoadList( t, aURL, ""/*TODO?*/, uno::Reference< embed::XStorage >() ) )
278 *pOk = *pChanged = true;
281 struct {
282 const char *pName;
283 XPropertyListType t;
284 } const aURLPropertyNames[] = {
285 { "ColorTableURL", XPropertyListType::Color },
286 { "DashTableURL", XPropertyListType::Dash },
287 { "LineEndTableURL", XPropertyListType::LineEnd },
288 { "HatchTableURL", XPropertyListType::Hatch },
289 { "GradientTableURL", XPropertyListType::Gradient },
290 { "BitmapTableURL", XPropertyListType::Bitmap }
293 static XPropertyListType getTypeOfName( std::u16string_view aName )
295 for(const auto & rURLPropertyName : aURLPropertyNames) {
296 if( o3tl::equalsAscii( aName, rURLPropertyName.pName ) )
297 return rURLPropertyName.t;
299 return XPropertyListType::Unknown;
302 static OUString getNameOfType( XPropertyListType t )
304 for(const auto & rURLPropertyName : aURLPropertyNames) {
305 if( t == rURLPropertyName.t )
306 return OUString( rURLPropertyName.pName,
307 strlen( rURLPropertyName.pName ) - 3,
308 RTL_TEXTENCODING_ASCII_US );
310 return OUString();
313 uno::Sequence<beans::PropertyValue>
314 DocumentSettings::filterStreamsFromStorage(
315 OUString const & referer,
316 const uno::Reference< embed::XStorage > &xStorage,
317 const uno::Sequence<beans::PropertyValue>& aConfigProps )
319 uno::Sequence<beans::PropertyValue> aRet( aConfigProps.getLength() );
320 auto aRetRange = asNonConstRange(aRet);
321 int nRet = 0;
322 for( const auto& rConfigProp : aConfigProps )
324 XPropertyListType t = getTypeOfName( rConfigProp.Name );
325 if (t == XPropertyListType::Unknown)
326 aRetRange[nRet++] = rConfigProp;
327 else
329 OUString aURL;
330 rConfigProp.Value >>= aURL;
331 LoadList( t, aURL, referer, xStorage );
334 aRet.realloc( nRet );
335 return aRet;
338 uno::Sequence<beans::PropertyValue>
339 DocumentSettings::filterStreamsToStorage(
340 const uno::Reference< embed::XStorage > &xStorage,
341 const uno::Sequence<beans::PropertyValue>& aConfigProps )
343 uno::Sequence<beans::PropertyValue> aRet( aConfigProps.getLength() );
345 bool bHasEmbed = false;
346 SdDrawDocument* pDoc = mxModel->GetDoc();
347 for( size_t i = 0; i < SAL_N_ELEMENTS( aURLPropertyNames ); i++ )
349 const XPropertyListRef& pList = pDoc->GetPropertyList( static_cast<XPropertyListType>(i) );
350 bHasEmbed = pList.is() && pList->IsEmbedInDocument();
351 if( bHasEmbed )
352 break;
354 if( !bHasEmbed )
355 return aConfigProps;
357 try {
358 // create Settings/ sub storage.
359 uno::Reference< embed::XStorage > xSubStorage = xStorage->openStorageElement( "Settings" ,
360 embed::ElementModes::WRITE | embed::ElementModes::TRUNCATE );
361 if( !xSubStorage.is() )
362 return aRet;
364 auto aRetRange = asNonConstRange(aRet);
365 // now populate it
366 for( sal_Int32 i = 0; i < aConfigProps.getLength(); i++ )
368 XPropertyListType t = getTypeOfName( aConfigProps[i].Name );
369 aRetRange[i] = aConfigProps[i];
370 if (t != XPropertyListType::Unknown) {
371 const XPropertyListRef& pList = pDoc->GetPropertyList( t );
372 if( !pList.is() || !pList->IsEmbedInDocument() )
373 continue; // no change ...
374 else
376 // Such specific path construction is grim.
378 OUString aName( getNameOfType( t ) );
379 OUString aResult;
380 if( pList->SaveTo( xSubStorage, aName, &aResult ) )
382 OUString aRealPath = "Settings/" + aResult;
383 aRetRange[i].Value <<= aRealPath;
389 // surprisingly difficult to make it really exist
390 uno::Reference< embed::XTransactedObject > xTrans( xSubStorage, UNO_QUERY );
391 if( xTrans.is() )
392 xTrans->commit();
393 if( xSubStorage.is() )
394 xSubStorage->dispose();
395 } catch (const uno::Exception &) {
396 // fprintf (stderr, "saving etc. exception '%s'\n",
397 // OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8).getStr());
400 return aRet;
403 // Most of the code reading/writing UNO document settings is the same in
404 // sd, sc and sw and it is mostly copy-pasted back and forth.
405 // TODO: Move _setPropertyValues and _getPropertyValues to some shared
406 // place, at least for the settings that are common to sd, sc and sw
407 void
408 DocumentSettings::_setPropertyValues(const PropertyMapEntry** ppEntries,
409 const Any* pValues)
411 ::SolarMutexGuard aGuard;
413 SdDrawDocument* pDoc = mxModel->GetDoc();
414 ::sd::DrawDocShell* pDocSh = mxModel->GetDocShell();
415 if( nullptr == pDoc || nullptr == pDocSh )
417 throw RuntimeException("Document or Shell missing",
418 static_cast<OWeakObject *>(this));
421 bool bValue = false;
422 bool bOk, bChanged = false, bOptionsChanged = false;
424 SdOptionsPrintItem aOptionsPrintItem;
426 VclPtr<SfxPrinter> pPrinter = pDocSh->GetPrinter( false );
427 if( pPrinter )
429 SdOptionsPrintItem const * pPrinterOptions = pPrinter->GetOptions().GetItemIfSet( ATTR_OPTIONS_PRINT, false );
430 if(pPrinterOptions)
431 aOptionsPrintItem.GetOptionsPrint() = pPrinterOptions->GetOptionsPrint();
433 else
435 aOptionsPrintItem.SetOptions( SD_MOD()->GetSdOptions(pDoc->GetDocumentType()) );
437 SdOptionsPrint& aPrintOpts = aOptionsPrintItem.GetOptionsPrint();
439 for( ; *ppEntries; ppEntries++, pValues++ )
441 bOk = false;
443 switch( (*ppEntries)->mnHandle )
445 case HANDLE_COLORTABLEURL:
446 AssignURL( XPropertyListType::Color, pValues, &bOk, &bChanged );
447 break;
449 case HANDLE_DASHTABLEURL:
450 AssignURL( XPropertyListType::Dash, pValues, &bOk, &bChanged );
451 break;
453 case HANDLE_LINEENDTABLEURL:
454 AssignURL( XPropertyListType::LineEnd, pValues, &bOk, &bChanged );
455 break;
457 case HANDLE_HATCHTABLEURL:
458 AssignURL( XPropertyListType::Hatch, pValues, &bOk, &bChanged );
459 break;
461 case HANDLE_GRADIENTTABLEURL:
462 AssignURL( XPropertyListType::Gradient, pValues, &bOk, &bChanged );
463 break;
465 case HANDLE_BITMAPTABLEURL:
466 AssignURL( XPropertyListType::Bitmap, pValues, &bOk, &bChanged );
467 break;
469 case HANDLE_FORBIDDENCHARS:
470 bOk = true;
471 break;
473 case HANDLE_APPLYUSERDATA:
475 bool bApplyUserData = false;
476 if( *pValues >>= bApplyUserData )
478 bChanged = ( bApplyUserData != pDocSh->IsUseUserData() );
479 pDocSh->SetUseUserData( bApplyUserData );
480 bOk = true;
483 break;
484 case HANDLE_SAVETHUMBNAIL:
486 bool bSaveThumbnail = false;
487 if (*pValues >>= bSaveThumbnail)
489 bChanged = (bSaveThumbnail != pDocSh->IsUseThumbnailSave());
490 pDocSh->SetUseThumbnailSave(bSaveThumbnail);
491 bOk = true;
494 break;
496 case HANDLE_PRINTDRAWING:
497 if( *pValues >>= bValue )
499 if( aPrintOpts.IsDraw() != bValue )
501 aPrintOpts.SetDraw( bValue );
502 bOptionsChanged = true;
505 bOk = true;
507 break;
508 case HANDLE_PRINTNOTES:
509 if( *pValues >>= bValue )
511 if( aPrintOpts.IsNotes() != bValue )
513 aPrintOpts.SetNotes( bValue );
514 bOptionsChanged = true;
517 bOk = true;
519 break;
520 case HANDLE_PRINTHANDOUT:
521 if( *pValues >>= bValue )
523 if( aPrintOpts.IsHandout() != bValue)
525 aPrintOpts.SetHandout( bValue );
526 bOptionsChanged = true;
529 bOk = true;
531 break;
532 case HANDLE_PRINTOUTLINE:
533 if( *pValues >>= bValue )
535 if( aPrintOpts.IsOutline() != bValue)
537 aPrintOpts.SetOutline( bValue );
538 bOptionsChanged = true;
540 bOk = true;
542 break;
543 case HANDLE_SLIDESPERHANDOUT:
545 sal_Int16 nValue = 0;
546 if( (*pValues >>= nValue) && (nValue >= 1) && (nValue <= 9) )
548 if( static_cast<sal_Int16>( aPrintOpts.GetHandoutPages() ) != nValue )
550 aPrintOpts.SetHandoutPages( static_cast< sal_uInt16 >( nValue ) );
551 bOptionsChanged = true;
553 bOk = true;
556 break;
557 case HANDLE_HANDOUTHORIZONTAL:
558 if( *pValues >>= bValue )
560 if( aPrintOpts.IsHandoutHorizontal() != bValue )
562 aPrintOpts.SetHandoutHorizontal( bValue );
563 bOptionsChanged = true;
565 bOk = true;
567 break;
569 case HANDLE_PRINTPAGENAME:
570 if( *pValues >>= bValue )
572 if( aPrintOpts.IsPagename() != bValue)
574 aPrintOpts.SetPagename( bValue );
575 bOptionsChanged = true;
577 bOk = true;
579 break;
580 case HANDLE_PRINTDATE:
581 if( *pValues >>= bValue )
583 if( aPrintOpts.IsDate() != bValue)
585 aPrintOpts.SetDate( bValue );
586 bOptionsChanged = true;
588 bOk = true;
590 break;
591 case HANDLE_PRINTTIME:
592 if( *pValues >>= bValue )
594 if( aPrintOpts.IsDate() != bValue)
596 aPrintOpts.SetTime( bValue );
597 bOptionsChanged = true;
599 bOk = true;
601 break;
602 case HANDLE_PRINTHIDDENPAGES:
603 if( *pValues >>= bValue )
605 if( aPrintOpts.IsHiddenPages() != bValue)
607 aPrintOpts.SetHiddenPages( bValue );
608 bOptionsChanged = true;
610 bOk = true;
612 break;
613 case HANDLE_PRINTFITPAGE:
614 if( *pValues >>= bValue )
616 if( aPrintOpts.IsPagesize() != bValue)
618 aPrintOpts.SetPagesize( bValue );
619 bOptionsChanged = true;
621 bOk = true;
623 break;
624 case HANDLE_PRINTTILEPAGE:
625 if( *pValues >>= bValue )
627 if( aPrintOpts.IsPagetile() != bValue)
629 aPrintOpts.SetPagetile( bValue );
630 bOptionsChanged = true;
632 bOk = true;
634 break;
635 case HANDLE_PRINTBOOKLET:
636 if( *pValues >>= bValue )
638 if( aPrintOpts.IsBooklet() != bValue)
640 aPrintOpts.SetBooklet( bValue );
641 bOptionsChanged = true;
643 bOk = true;
645 break;
646 case HANDLE_PRINTBOOKLETFRONT:
647 if( *pValues >>= bValue )
649 if( aPrintOpts.IsFrontPage() != bValue)
651 aPrintOpts.SetFrontPage( bValue );
652 bOptionsChanged = true;
654 bOk = true;
656 break;
657 case HANDLE_PRINTBOOKLETBACK:
658 if( *pValues >>= bValue )
660 if( aPrintOpts.IsBackPage() != bValue)
662 aPrintOpts.SetBackPage( bValue );
663 bOptionsChanged = true;
665 bOk = true;
667 break;
668 case HANDLE_PRINTQUALITY:
670 sal_Int32 nValue = 0;
671 if( *pValues >>= nValue )
673 if( aPrintOpts.GetOutputQuality() != nValue)
675 aPrintOpts.SetOutputQuality( static_cast<sal_uInt16>(nValue) );
676 bOptionsChanged = true;
678 bOk = true;
681 break;
682 case HANDLE_MEASUREUNIT:
684 sal_Int16 nValue = 0;
685 if( *pValues >>= nValue )
687 FieldUnit nFieldUnit;
688 if( SvxMeasureUnitToFieldUnit( nValue, nFieldUnit ) )
690 pDoc->SetUIUnit( nFieldUnit );
691 bOk = true;
695 break;
696 case HANDLE_SCALE_NUM:
698 sal_Int32 nValue = 0;
699 if( *pValues >>= nValue )
701 Fraction aFract( nValue, pDoc->GetUIScale().GetDenominator() );
702 pDoc->SetUIScale( aFract );
703 bOk = true;
704 bChanged = true;
707 break;
708 case HANDLE_SCALE_DOM:
710 sal_Int32 nValue = 0;
711 if( *pValues >>= nValue )
713 auto nNumerator = pDoc->GetUIScale().GetNumerator();
714 assert(nNumerator != 0);
715 Fraction aFract(nNumerator, nValue);
716 pDoc->SetUIScale( aFract );
717 bOk = true;
718 bChanged = true;
721 break;
723 case HANDLE_TABSTOP:
725 sal_Int32 nValue = 0;
726 if( (*pValues >>= nValue) && (nValue >= 0) )
728 pDoc->SetDefaultTabulator(static_cast<sal_uInt16>(nValue));
729 bOk = true;
730 bChanged = true;
733 break;
734 case HANDLE_PAGENUMFMT:
736 sal_Int32 nValue = 0;
737 if( (*pValues >>= nValue ) && (nValue >= css::style::NumberingType::CHARS_UPPER_LETTER ) && (nValue <= css::style::NumberingType::PAGE_DESCRIPTOR) )
739 pDoc->SetPageNumType(static_cast<SvxNumType>(nValue));
740 bOk = true;
741 bChanged = true;
744 break;
745 case HANDLE_PRINTERNAME:
747 OUString aPrinterName;
748 if( *pValues >>= aPrinterName )
750 bOk = true;
751 if( !aPrinterName.isEmpty() && pDocSh->GetCreateMode() != SfxObjectCreateMode::EMBEDDED )
753 SfxPrinter *pTempPrinter = pDocSh->GetPrinter( true );
754 if (pTempPrinter)
756 VclPtr<SfxPrinter> pNewPrinter = VclPtr<SfxPrinter>::Create( pTempPrinter->GetOptions().Clone(), aPrinterName );
757 pDocSh->SetPrinter( pNewPrinter );
762 break;
763 case HANDLE_PRINTERJOB:
765 Sequence < sal_Int8 > aSequence;
766 if ( *pValues >>= aSequence )
768 bOk = true;
769 sal_uInt32 nSize = aSequence.getLength();
770 if( nSize )
772 SvMemoryStream aStream (aSequence.getArray(), nSize, StreamMode::READ );
773 aStream.Seek ( STREAM_SEEK_TO_BEGIN );
774 std::unique_ptr<SfxItemSet> pItemSet;
776 bool bPreferPrinterPapersize = false;
777 if( pPrinter )
779 pItemSet = pPrinter->GetOptions().Clone();
780 bPreferPrinterPapersize = pPrinter->GetPrinterSettingsPreferred();
782 else
784 pItemSet = std::make_unique<SfxItemSetFixed
785 <SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN,
786 SID_PRINTER_CHANGESTODOC, SID_PRINTER_CHANGESTODOC,
787 ATTR_OPTIONS_PRINT, ATTR_OPTIONS_PRINT>>(pDoc->GetPool());
790 pPrinter = SfxPrinter::Create ( aStream, std::move(pItemSet) );
791 pPrinter->SetPrinterSettingsPreferred( bPreferPrinterPapersize );
793 MapMode aMM (pPrinter->GetMapMode());
794 aMM.SetMapUnit(MapUnit::Map100thMM);
795 pPrinter->SetMapMode(aMM);
797 pDocSh->SetPrinter( pPrinter );
799 pPrinter = nullptr;
803 break;
805 case HANDLE_PRINTERPAPERSIZE:
807 bool bPreferPrinterPapersize;
808 if( *pValues >>= bPreferPrinterPapersize )
810 bOk = true;
811 if( pDocSh->GetCreateMode() != SfxObjectCreateMode::EMBEDDED )
813 SfxPrinter *pTempPrinter = pDocSh->GetPrinter( true );
814 if (pTempPrinter)
815 pTempPrinter->SetPrinterSettingsPreferred( bPreferPrinterPapersize );
819 break;
821 case HANDLE_PARAGRAPHSUMMATION :
823 bool bIsSummationOfParagraphs = false;
824 if ( *pValues >>= bIsSummationOfParagraphs )
826 bOk = true;
827 bChanged = true;
828 if ( pDoc->GetDocumentType() == DocumentType::Impress )
830 EEControlBits nSum = bIsSummationOfParagraphs ? EEControlBits::ULSPACESUMMATION : EEControlBits::NONE;
831 EEControlBits nCntrl;
833 pDoc->SetSummationOfParagraphs( bIsSummationOfParagraphs );
834 SdDrawDocument* pDocument = pDocSh->GetDoc();
835 SdrOutliner& rOutl = pDocument->GetDrawOutliner();
836 nCntrl = rOutl.GetControlWord() &~ EEControlBits::ULSPACESUMMATION;
837 rOutl.SetControlWord( nCntrl | nSum );
838 SdOutliner* pOutl = pDocument->GetOutliner( false );
839 if( pOutl )
841 nCntrl = pOutl->GetControlWord() &~ EEControlBits::ULSPACESUMMATION;
842 pOutl->SetControlWord( nCntrl | nSum );
844 pOutl = pDocument->GetInternalOutliner( false );
845 if( pOutl )
847 nCntrl = pOutl->GetControlWord() &~ EEControlBits::ULSPACESUMMATION;
848 pOutl->SetControlWord( nCntrl | nSum );
853 break;
855 case HANDLE_CHARCOMPRESS:
857 sal_Int16 nCharCompressType = 0;
858 if( *pValues >>= nCharCompressType )
860 bOk = true;
862 pDoc->SetCharCompressType( static_cast<CharCompressType>(nCharCompressType) );
863 SdDrawDocument* pDocument = pDocSh->GetDoc();
864 SdrOutliner& rOutl = pDocument->GetDrawOutliner();
865 rOutl.SetAsianCompressionMode( static_cast<CharCompressType>(nCharCompressType) );
866 SdOutliner* pOutl = pDocument->GetOutliner( false );
867 if( pOutl )
869 pOutl->SetAsianCompressionMode( static_cast<CharCompressType>(nCharCompressType) );
871 pOutl = pDocument->GetInternalOutliner( false );
872 if( pOutl )
874 pOutl->SetAsianCompressionMode( static_cast<CharCompressType>(nCharCompressType) );
877 break;
880 case HANDLE_ASIANPUNCT:
882 bool bAsianPunct = false;
883 if( *pValues >>= bAsianPunct )
885 bOk = true;
887 pDoc->SetKernAsianPunctuation( bAsianPunct );
888 SdDrawDocument* pDocument = pDocSh->GetDoc();
889 SdrOutliner& rOutl = pDocument->GetDrawOutliner();
890 rOutl.SetKernAsianPunctuation( bAsianPunct );
891 SdOutliner* pOutl = pDocument->GetOutliner( false );
892 if( pOutl )
894 pOutl->SetKernAsianPunctuation( bAsianPunct );
896 pOutl = pDocument->GetInternalOutliner( false );
897 if( pOutl )
899 pOutl->SetKernAsianPunctuation( bAsianPunct );
902 break;
905 case HANDLE_UPDATEFROMTEMPLATE:
907 bool value = false;
908 if( *pValues >>= value )
910 bChanged = ( value != pDocSh->IsQueryLoadTemplate() );
911 pDocSh->SetQueryLoadTemplate( value );
912 bOk = true;
915 break;
917 case HANDLE_PRINTER_INDEPENDENT_LAYOUT:
919 // Just propagate the new printer independent layout mode to
920 // the document and determine it really differs from the old
921 // one.
922 sal_Int16 nOldValue =
923 static_cast<sal_Int16>(pDoc->GetPrinterIndependentLayout ());
924 sal_Int16 nValue = 0;
925 if (*pValues >>= nValue)
927 pDoc->SetPrinterIndependentLayout (nValue);
928 bChanged = (nValue != nOldValue);
929 bOk = true;
932 break;
934 // --> #i33095#
935 case HANDLE_LOAD_READONLY:
937 bool bNewValue = false;
938 if ( *pValues >>= bNewValue )
940 bChanged = ( pDocSh->IsLoadReadonly() != bNewValue );
941 pDocSh->SetLoadReadonly( bNewValue );
942 bOk = true;
945 break;
947 case HANDLE_MODIFY_PASSWD:
949 uno::Sequence< beans::PropertyValue > aInfo;
950 if ( !( *pValues >>= aInfo ) )
951 throw lang::IllegalArgumentException(
952 "Value of type Sequence<PropertyValue> expected!",
953 uno::Reference< uno::XInterface >(),
954 2 );
956 if ( !pDocSh->SetModifyPasswordInfo( aInfo ) )
957 throw beans::PropertyVetoException(
958 "The hash is not allowed to be changed now!" );
960 bOk = true
964 break;
966 case HANDLE_SAVE_VERSION:
968 bool bNewValue = false;
969 if ( *pValues >>= bNewValue )
971 bChanged = ( pDocSh->IsSaveVersionOnClose() != bNewValue );
972 pDocSh->SetSaveVersionOnClose( bNewValue );
973 bOk = true;
976 break;
978 case HANDLE_EMBED_FONTS:
980 if (pValues->has<bool>())
982 bool bNewValue = pValues->get<bool>();
983 bChanged = (pDoc->IsEmbedFonts() != bNewValue);
984 pDoc->SetEmbedFonts(bNewValue);
985 bOk = true;
988 break;
990 case HANDLE_EMBED_USED_FONTS:
992 if (pValues->has<bool>())
994 bool bNewValue = pValues->get<bool>();
995 bChanged = (pDoc->IsEmbedUsedFontsOnly() != bNewValue);
996 pDoc->SetEmbedUsedFontsOnly(bNewValue);
997 bOk = true;
1000 break;
1002 case HANDLE_EMBED_LATIN_SCRIPT_FONTS:
1004 if (pValues->has<bool>())
1006 bool bNewValue = pValues->get<bool>();
1007 bChanged = (pDoc->IsEmbedFontScriptLatin() != bNewValue);
1008 pDoc->SetEmbedFontScriptLatin(bNewValue);
1009 bOk = true;
1012 break;
1014 case HANDLE_EMBED_ASIAN_SCRIPT_FONTS:
1016 if (pValues->has<bool>())
1018 bool bNewValue = pValues->get<bool>();
1019 bChanged = (pDoc->IsEmbedFontScriptAsian() != bNewValue);
1020 pDoc->SetEmbedFontScriptAsian(bNewValue);
1021 bOk = true;
1024 break;
1026 case HANDLE_EMBED_COMPLEX_SCRIPT_FONTS:
1028 if (pValues->has<bool>())
1030 bool bNewValue = pValues->get<bool>();
1031 bChanged = (pDoc->IsEmbedFontScriptComplex() != bNewValue);
1032 pDoc->SetEmbedFontScriptComplex(bNewValue);
1033 bOk = true;
1036 break;
1038 case HANDLE_IMAGE_PREFERRED_DPI:
1040 if (pValues->has<sal_Int32>())
1042 auto nNewValue = pValues->get<sal_Int32>();
1043 bChanged = (pDoc->getImagePreferredDPI() != nNewValue);
1044 pDoc->setImagePreferredDPI(nNewValue);
1045 bOk = true;
1048 break;
1050 default:
1051 throw UnknownPropertyException( OUString::number((*ppEntries)->mnHandle), static_cast<cppu::OWeakObject*>(this));
1054 if( !bOk )
1055 throw IllegalArgumentException();
1058 if( bOptionsChanged )
1060 if( !pPrinter )
1061 pPrinter = pDocSh->GetPrinter( true );
1062 SfxItemSet aNewOptions( pPrinter->GetOptions() );
1063 aNewOptions.Put( aOptionsPrintItem );
1064 pPrinter->SetOptions( aNewOptions );
1067 if( bChanged || bOptionsChanged )
1068 mxModel->SetModified();
1071 void DocumentSettings::ExtractURL( XPropertyListType t, Any* pValue )
1073 XPropertyListRef pList = mxModel->GetDoc()->GetPropertyList( t );
1074 if( !pList.is() )
1075 return;
1077 INetURLObject aPathURL( pList->GetPath() );
1078 aPathURL.insertName( pList->GetName() );
1079 aPathURL.setExtension( pList->GetDefaultExt() );
1080 OUString aPath( aPathURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ) );
1081 *pValue <<= aPath;
1084 void
1085 DocumentSettings::_getPropertyValues(
1086 const PropertyMapEntry** ppEntries, Any* pValue)
1088 ::SolarMutexGuard aGuard;
1090 SdDrawDocument* pDoc = mxModel->GetDoc();
1091 ::sd::DrawDocShell* pDocSh = mxModel->GetDocShell();
1092 if( nullptr == pDoc || nullptr == pDocSh )
1094 throw RuntimeException("Document or Shell missing",
1095 static_cast<OWeakObject *>(this));
1098 SdOptionsPrintItem aOptionsPrintItem;
1100 SfxPrinter* pPrinter = pDocSh->GetPrinter( false );
1101 if( pPrinter )
1103 SdOptionsPrintItem const * pPrinterOptions = pPrinter->GetOptions().GetItemIfSet( ATTR_OPTIONS_PRINT, false );
1104 if (pPrinterOptions)
1105 aOptionsPrintItem.GetOptionsPrint() = pPrinterOptions->GetOptionsPrint();
1107 else
1109 aOptionsPrintItem.SetOptions( SD_MOD()->GetSdOptions(pDoc->GetDocumentType()) );
1111 SdOptionsPrint& aPrintOpts = aOptionsPrintItem.GetOptionsPrint();
1113 for( ; *ppEntries; ppEntries++, pValue++ )
1115 switch( (*ppEntries)->mnHandle )
1117 case HANDLE_COLORTABLEURL:
1118 ExtractURL( XPropertyListType::Color, pValue );
1119 break;
1120 case HANDLE_DASHTABLEURL:
1121 ExtractURL( XPropertyListType::Dash, pValue );
1122 break;
1123 case HANDLE_LINEENDTABLEURL:
1124 ExtractURL( XPropertyListType::LineEnd, pValue );
1125 break;
1126 case HANDLE_HATCHTABLEURL:
1127 ExtractURL( XPropertyListType::Hatch, pValue );
1128 break;
1129 case HANDLE_GRADIENTTABLEURL:
1130 ExtractURL( XPropertyListType::Gradient, pValue );
1131 break;
1132 case HANDLE_BITMAPTABLEURL:
1133 ExtractURL( XPropertyListType::Bitmap, pValue );
1134 break;
1135 case HANDLE_FORBIDDENCHARS:
1136 *pValue <<= mxModel->getForbiddenCharsTable();
1137 break;
1138 case HANDLE_APPLYUSERDATA:
1139 *pValue <<= pDocSh->IsUseUserData();
1140 break;
1141 case HANDLE_SAVETHUMBNAIL:
1142 *pValue <<= pDocSh->IsUseThumbnailSave();
1143 break;
1144 case HANDLE_PRINTDRAWING:
1145 *pValue <<= aPrintOpts.IsDraw();
1146 break;
1147 case HANDLE_PRINTNOTES:
1148 *pValue <<= aPrintOpts.IsNotes();
1149 break;
1150 case HANDLE_PRINTHANDOUT:
1151 *pValue <<= aPrintOpts.IsHandout();
1152 break;
1153 case HANDLE_PRINTOUTLINE:
1154 *pValue <<= aPrintOpts.IsOutline();
1155 break;
1156 case HANDLE_SLIDESPERHANDOUT:
1157 *pValue <<= static_cast<sal_Int16>(aPrintOpts.GetHandoutPages());
1158 break;
1159 case HANDLE_HANDOUTHORIZONTAL:
1160 *pValue <<= aPrintOpts.IsHandoutHorizontal();
1161 break;
1162 case HANDLE_PRINTPAGENAME:
1163 *pValue <<= aPrintOpts.IsPagename();
1164 break;
1165 case HANDLE_PRINTDATE:
1166 *pValue <<= aPrintOpts.IsDate();
1167 break;
1168 case HANDLE_PRINTTIME:
1169 *pValue <<= aPrintOpts.IsTime();
1170 break;
1171 case HANDLE_PRINTHIDDENPAGES:
1172 *pValue <<= aPrintOpts.IsHiddenPages();
1173 break;
1174 case HANDLE_PRINTFITPAGE:
1175 *pValue <<= aPrintOpts.IsPagesize();
1176 break;
1177 case HANDLE_PRINTTILEPAGE:
1178 *pValue <<= aPrintOpts.IsPagetile();
1179 break;
1180 case HANDLE_PRINTBOOKLET:
1181 *pValue <<= aPrintOpts.IsBooklet();
1182 break;
1183 case HANDLE_PRINTBOOKLETFRONT:
1184 *pValue <<= aPrintOpts.IsFrontPage();
1185 break;
1186 case HANDLE_PRINTBOOKLETBACK:
1187 *pValue <<= aPrintOpts.IsBackPage();
1188 break;
1189 case HANDLE_PRINTQUALITY:
1190 *pValue <<= static_cast<sal_Int32>(aPrintOpts.GetOutputQuality());
1191 break;
1192 case HANDLE_MEASUREUNIT:
1194 short nMeasure;
1195 SvxFieldUnitToMeasureUnit( pDoc->GetUIUnit(), nMeasure );
1196 *pValue <<= static_cast<sal_Int16>(nMeasure);
1198 break;
1199 case HANDLE_SCALE_NUM:
1200 *pValue <<= pDoc->GetUIScale().GetNumerator();
1201 break;
1202 case HANDLE_SCALE_DOM:
1203 *pValue <<= pDoc->GetUIScale().GetDenominator();
1204 break;
1205 case HANDLE_TABSTOP:
1206 *pValue <<= static_cast<sal_Int32>(pDoc->GetDefaultTabulator());
1207 break;
1208 case HANDLE_PAGENUMFMT:
1209 *pValue <<= static_cast<sal_Int32>(pDoc->GetPageNumType());
1210 break;
1211 case HANDLE_PRINTERNAME:
1213 SfxPrinter *pTempPrinter = pDocSh->GetPrinter( false );
1214 *pValue <<= pTempPrinter ? pTempPrinter->GetName() : OUString();
1216 break;
1217 case HANDLE_PRINTERJOB:
1219 SfxPrinter *pTempPrinter = pDocSh->GetPrinter( false );
1220 if (pTempPrinter)
1222 SvMemoryStream aStream;
1223 pTempPrinter->Store( aStream );
1224 *pValue <<= Sequence< sal_Int8 >( static_cast< const sal_Int8* >( aStream.GetData() ),
1225 aStream.TellEnd() );
1227 else
1229 Sequence < sal_Int8 > aSequence;
1230 *pValue <<= aSequence;
1233 break;
1235 case HANDLE_PRINTERPAPERSIZE:
1237 SfxPrinter *pTempPrinter = pDocSh->GetPrinter( false );
1238 *pValue <<= pTempPrinter && pTempPrinter->GetPrinterSettingsPreferred();
1240 break;
1242 case HANDLE_PARAGRAPHSUMMATION :
1244 bool bIsSummationOfParagraphs = pDoc->IsSummationOfParagraphs();
1245 *pValue <<= bIsSummationOfParagraphs;
1247 break;
1249 case HANDLE_CHARCOMPRESS:
1251 *pValue <<= static_cast<sal_Int16>(pDoc->GetCharCompressType());
1252 break;
1255 case HANDLE_ASIANPUNCT:
1257 *pValue <<= pDoc->IsKernAsianPunctuation();
1258 break;
1261 case HANDLE_UPDATEFROMTEMPLATE:
1263 *pValue <<= pDocSh->IsQueryLoadTemplate();
1265 break;
1267 case HANDLE_PRINTER_INDEPENDENT_LAYOUT:
1269 sal_Int16 nPrinterIndependentLayout =
1270 static_cast<sal_Int16>(pDoc->GetPrinterIndependentLayout());
1271 *pValue <<= nPrinterIndependentLayout;
1273 break;
1275 // --> #i33095#
1276 case HANDLE_LOAD_READONLY:
1278 *pValue <<= pDocSh->IsLoadReadonly();
1280 break;
1282 case HANDLE_MODIFY_PASSWD:
1284 *pValue <<= pDocSh->GetModifyPasswordInfo();
1286 break;
1288 case HANDLE_SAVE_VERSION:
1290 *pValue <<= pDocSh->IsSaveVersionOnClose();
1292 break;
1294 case HANDLE_EMBED_FONTS:
1296 *pValue <<= pDoc->IsEmbedFonts();
1298 break;
1300 case HANDLE_EMBED_USED_FONTS:
1302 *pValue <<= pDoc->IsEmbedUsedFontsOnly();
1304 break;
1306 case HANDLE_EMBED_LATIN_SCRIPT_FONTS:
1308 *pValue <<= pDoc->IsEmbedFontScriptLatin();
1310 break;
1312 case HANDLE_EMBED_ASIAN_SCRIPT_FONTS:
1314 *pValue <<= pDoc->IsEmbedFontScriptAsian();
1316 break;
1318 case HANDLE_EMBED_COMPLEX_SCRIPT_FONTS:
1320 *pValue <<= pDoc->IsEmbedFontScriptComplex();
1322 break;
1324 case HANDLE_IMAGE_PREFERRED_DPI:
1326 *pValue <<= pDoc->getImagePreferredDPI();
1328 break;
1330 default:
1331 throw UnknownPropertyException( OUString::number((*ppEntries)->mnHandle), static_cast<cppu::OWeakObject*>(this));
1336 // XInterface
1337 Any SAL_CALL DocumentSettings::queryInterface( const Type& aType )
1339 return WeakImplHelper< XPropertySet, XMultiPropertySet, XServiceInfo >::queryInterface( aType );
1342 void SAL_CALL DocumentSettings::acquire( ) noexcept
1344 WeakImplHelper< XPropertySet, XMultiPropertySet, XServiceInfo >::acquire();
1347 void SAL_CALL DocumentSettings::release( ) noexcept
1349 WeakImplHelper< XPropertySet, XMultiPropertySet, XServiceInfo >::release();
1352 // XPropertySet
1353 Reference< XPropertySetInfo > SAL_CALL DocumentSettings::getPropertySetInfo( )
1355 return PropertySetHelper::getPropertySetInfo();
1358 void SAL_CALL DocumentSettings::setPropertyValue( const OUString& aPropertyName, const Any& aValue )
1360 PropertySetHelper::setPropertyValue( aPropertyName, aValue );
1363 Any SAL_CALL DocumentSettings::getPropertyValue( const OUString& PropertyName )
1365 return PropertySetHelper::getPropertyValue( PropertyName );
1368 void SAL_CALL DocumentSettings::addPropertyChangeListener( const OUString& aPropertyName, const Reference< XPropertyChangeListener >& xListener )
1370 PropertySetHelper::addPropertyChangeListener( aPropertyName, xListener );
1373 void SAL_CALL DocumentSettings::removePropertyChangeListener( const OUString& aPropertyName, const Reference< XPropertyChangeListener >& aListener )
1375 PropertySetHelper::removePropertyChangeListener( aPropertyName, aListener );
1378 void SAL_CALL DocumentSettings::addVetoableChangeListener( const OUString& PropertyName, const Reference< XVetoableChangeListener >& aListener )
1380 PropertySetHelper::addVetoableChangeListener( PropertyName, aListener );
1383 void SAL_CALL DocumentSettings::removeVetoableChangeListener( const OUString& PropertyName, const Reference< XVetoableChangeListener >& aListener )
1385 PropertySetHelper::removeVetoableChangeListener( PropertyName, aListener );
1388 // XMultiPropertySet
1389 void SAL_CALL DocumentSettings::setPropertyValues( const Sequence< OUString >& aPropertyNames, const Sequence< Any >& aValues )
1391 PropertySetHelper::setPropertyValues( aPropertyNames, aValues );
1394 Sequence< Any > SAL_CALL DocumentSettings::getPropertyValues( const Sequence< OUString >& aPropertyNames )
1396 return PropertySetHelper::getPropertyValues( aPropertyNames );
1399 void SAL_CALL DocumentSettings::addPropertiesChangeListener( const Sequence< OUString >& aPropertyNames, const Reference< XPropertiesChangeListener >& xListener )
1401 PropertySetHelper::addPropertiesChangeListener( aPropertyNames, xListener );
1404 void SAL_CALL DocumentSettings::removePropertiesChangeListener( const Reference< XPropertiesChangeListener >& xListener )
1406 PropertySetHelper::removePropertiesChangeListener( xListener );
1409 void SAL_CALL DocumentSettings::firePropertiesChangeEvent( const Sequence< OUString >& aPropertyNames, const Reference< XPropertiesChangeListener >& xListener )
1411 PropertySetHelper::firePropertiesChangeEvent( aPropertyNames, xListener );
1414 // XServiceInfo
1415 OUString SAL_CALL DocumentSettings::getImplementationName( )
1417 return "com.sun.star.comp.Draw.DocumentSettings";
1420 sal_Bool SAL_CALL DocumentSettings::supportsService( const OUString& ServiceName )
1422 return cppu::supportsService(this, ServiceName);
1425 Sequence< OUString > SAL_CALL DocumentSettings::getSupportedServiceNames( )
1427 return { "com.sun.star.document.Settings" ,
1428 mxModel->IsImpressDocument()?OUString("com.sun.star.presentation.DocumentSettings"):OUString("com.sun.star.drawing.DocumentSettings") };
1431 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */