LibreOffice Module sd (master) 1
UnoDocumentSettings.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include <sal/config.h>
21
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>
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>
40
41#include <drawdoc.hxx>
42#include <DrawDocShell.hxx>
44#include <unomodel.hxx>
45
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>
53#include <editeng/editstat.hxx>
54#include <svx/unoapi.hxx>
55
56using namespace ::comphelper;
57using namespace ::cppu;
58using namespace ::com::sun::star;
59using namespace ::com::sun::star::uno;
60using namespace ::com::sun::star::util;
61using namespace ::com::sun::star::container;
62using namespace ::com::sun::star::drawing;
63using namespace ::com::sun::star::lang;
64using namespace ::com::sun::star::document;
65using namespace ::com::sun::star::beans;
66using namespace ::com::sun::star::i18n;
67
68namespace sd
69{
70 namespace {
71
72 class DocumentSettings : public WeakImplHelper< XPropertySet, XMultiPropertySet, XServiceInfo >,
74 public DocumentSettingsSerializer
75 {
76 public:
77 explicit DocumentSettings( SdXImpressDocument* pModel );
78
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;
83
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;
92
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;
99
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;
104
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;
113
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;
117
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;
125 };
126
127 }
128
130 noexcept
131 {
132 DBG_ASSERT( pModel, "I need a model for the DocumentSettings!" );
133 return static_cast<XWeak*>(new DocumentSettings( pModel ));
134 }
135
136namespace {
137
138enum SdDocumentSettingsPropertyHandles
139{
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
153};
154
155}
156
157#define MID_PRINTER 1
158
160 {
161 static PropertyMapEntry const aImpressSettingsInfoMap[] =
162 {
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 },
169 };
170
171 static PropertyMapEntry const aDrawSettingsInfoMap[] =
172 {
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 },
176 };
177
178 static PropertyMapEntry const aCommonSettingsInfoMap[] =
179 {
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 },
184
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 },
201
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 },
205
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 },
222 };
223
224 rtl::Reference<PropertySetInfo> xInfo = new PropertySetInfo( aCommonSettingsInfoMap );
225 if (bIsDraw)
226 xInfo->add( aDrawSettingsInfoMap );
227 else
228 xInfo->add( aImpressSettingsInfoMap );
229
230 return xInfo;
231 }
232}
233
234using namespace ::sd;
235
236DocumentSettings::DocumentSettings( SdXImpressDocument* pModel )
237: PropertySetHelper( createSettingsInfoImpl( !pModel->IsImpressDocument() ) ),
238 mxModel( pModel )
239{
240}
241
242bool DocumentSettings::LoadList( XPropertyListType t, const OUString &rInPath,
243 const OUString &rReferer,
244 const uno::Reference< embed::XStorage > &xStorage )
245{
246 SdDrawDocument* pDoc = mxModel->GetDoc();
247
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 );
255 }
256
258 t, aPath, rReferer );
259 pList->SetName( aName );
260
261 if( pList->LoadFrom( xStorage, rInPath, rReferer ) )
262 {
263 pDoc->SetPropertyList( pList );
264 return true;
265 }
266
267 return false;
268}
269
270void DocumentSettings::AssignURL( XPropertyListType t, const Any* pValue,
271 bool *pOk, bool *pChanged )
272{
273 OUString aURL;
274 if( !( *pValue >>= aURL ) )
275 return;
276
277 if( LoadList( t, aURL, ""/*TODO?*/, uno::Reference< embed::XStorage >() ) )
278 *pOk = *pChanged = true;
279}
280
281struct {
282 const char *pName;
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 }
292
293static XPropertyListType getTypeOfName( std::u16string_view aName )
294{
295 for(const auto & rURLPropertyName : aURLPropertyNames) {
296 if( o3tl::equalsAscii( aName, rURLPropertyName.pName ) )
297 return rURLPropertyName.t;
298 }
299 return XPropertyListType::Unknown;
300}
301
303{
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 );
309 }
310 return OUString();
311}
312
313uno::Sequence<beans::PropertyValue>
314 DocumentSettings::filterStreamsFromStorage(
315 OUString const & referer,
316 const uno::Reference< embed::XStorage > &xStorage,
317 const uno::Sequence<beans::PropertyValue>& aConfigProps )
318{
319 uno::Sequence<beans::PropertyValue> aRet( aConfigProps.getLength() );
320 auto aRetRange = asNonConstRange(aRet);
321 int nRet = 0;
322 for( const auto& rConfigProp : aConfigProps )
323 {
324 XPropertyListType t = getTypeOfName( rConfigProp.Name );
325 if (t == XPropertyListType::Unknown)
326 aRetRange[nRet++] = rConfigProp;
327 else
328 {
329 OUString aURL;
330 rConfigProp.Value >>= aURL;
331 LoadList( t, aURL, referer, xStorage );
332 }
333 }
334 aRet.realloc( nRet );
335 return aRet;
336}
337
338uno::Sequence<beans::PropertyValue>
339 DocumentSettings::filterStreamsToStorage(
340 const uno::Reference< embed::XStorage > &xStorage,
341 const uno::Sequence<beans::PropertyValue>& aConfigProps )
342{
343 uno::Sequence<beans::PropertyValue> aRet( aConfigProps.getLength() );
344
345 bool bHasEmbed = false;
346 SdDrawDocument* pDoc = mxModel->GetDoc();
347 for( size_t i = 0; i < SAL_N_ELEMENTS( aURLPropertyNames ); i++ )
348 {
349 const XPropertyListRef& pList = pDoc->GetPropertyList( static_cast<XPropertyListType>(i) );
350 bHasEmbed = pList.is() && pList->IsEmbedInDocument();
351 if( bHasEmbed )
352 break;
353 }
354 if( !bHasEmbed )
355 return aConfigProps;
356
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;
363
364 auto aRetRange = asNonConstRange(aRet);
365 // now populate it
366 for( sal_Int32 i = 0; i < aConfigProps.getLength(); i++ )
367 {
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
375 {
376 // Such specific path construction is grim.
377
378 OUString aName( getNameOfType( t ) );
379 OUString aResult;
380 if( pList->SaveTo( xSubStorage, aName, &aResult ) )
381 {
382 OUString aRealPath = "Settings/" + aResult;
383 aRetRange[i].Value <<= aRealPath;
384 }
385 }
386 }
387 }
388
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());
398 }
399
400 return aRet;
401}
402
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
407void
408DocumentSettings::_setPropertyValues(const PropertyMapEntry** ppEntries,
409 const Any* pValues)
410{
411 ::SolarMutexGuard aGuard;
412
413 SdDrawDocument* pDoc = mxModel->GetDoc();
414 ::sd::DrawDocShell* pDocSh = mxModel->GetDocShell();
415 if( nullptr == pDoc || nullptr == pDocSh )
416 {
417 throw RuntimeException("Document or Shell missing",
418 static_cast<OWeakObject *>(this));
419 }
420
421 bool bValue = false;
422 bool bOk, bChanged = false, bOptionsChanged = false;
423
424 SdOptionsPrintItem aOptionsPrintItem;
425
426 VclPtr<SfxPrinter> pPrinter = pDocSh->GetPrinter( false );
427 if( pPrinter )
428 {
429 SdOptionsPrintItem const * pPrinterOptions = pPrinter->GetOptions().GetItemIfSet( ATTR_OPTIONS_PRINT, false );
430 if(pPrinterOptions)
431 aOptionsPrintItem.GetOptionsPrint() = pPrinterOptions->GetOptionsPrint();
432 }
433 else
434 {
435 aOptionsPrintItem.SetOptions( SD_MOD()->GetSdOptions(pDoc->GetDocumentType()) );
436 }
437 SdOptionsPrint& aPrintOpts = aOptionsPrintItem.GetOptionsPrint();
438
439 for( ; *ppEntries; ppEntries++, pValues++ )
440 {
441 bOk = false;
442
443 switch( (*ppEntries)->mnHandle )
444 {
445 case HANDLE_COLORTABLEURL:
446 AssignURL( XPropertyListType::Color, pValues, &bOk, &bChanged );
447 break;
448
449 case HANDLE_DASHTABLEURL:
450 AssignURL( XPropertyListType::Dash, pValues, &bOk, &bChanged );
451 break;
452
453 case HANDLE_LINEENDTABLEURL:
454 AssignURL( XPropertyListType::LineEnd, pValues, &bOk, &bChanged );
455 break;
456
457 case HANDLE_HATCHTABLEURL:
458 AssignURL( XPropertyListType::Hatch, pValues, &bOk, &bChanged );
459 break;
460
461 case HANDLE_GRADIENTTABLEURL:
462 AssignURL( XPropertyListType::Gradient, pValues, &bOk, &bChanged );
463 break;
464
465 case HANDLE_BITMAPTABLEURL:
466 AssignURL( XPropertyListType::Bitmap, pValues, &bOk, &bChanged );
467 break;
468
469 case HANDLE_FORBIDDENCHARS:
470 bOk = true;
471 break;
472
473 case HANDLE_APPLYUSERDATA:
474 {
475 bool bApplyUserData = false;
476 if( *pValues >>= bApplyUserData )
477 {
478 bChanged = ( bApplyUserData != pDocSh->IsUseUserData() );
479 pDocSh->SetUseUserData( bApplyUserData );
480 bOk = true;
481 }
482 }
483 break;
484 case HANDLE_SAVETHUMBNAIL:
485 {
486 bool bSaveThumbnail = false;
487 if (*pValues >>= bSaveThumbnail)
488 {
489 bChanged = (bSaveThumbnail != pDocSh->IsUseThumbnailSave());
490 pDocSh->SetUseThumbnailSave(bSaveThumbnail);
491 bOk = true;
492 }
493 }
494 break;
495
496 case HANDLE_PRINTDRAWING:
497 if( *pValues >>= bValue )
498 {
499 if( aPrintOpts.IsDraw() != bValue )
500 {
501 aPrintOpts.SetDraw( bValue );
502 bOptionsChanged = true;
503 }
504
505 bOk = true;
506 }
507 break;
508 case HANDLE_PRINTNOTES:
509 if( *pValues >>= bValue )
510 {
511 if( aPrintOpts.IsNotes() != bValue )
512 {
513 aPrintOpts.SetNotes( bValue );
514 bOptionsChanged = true;
515 }
516
517 bOk = true;
518 }
519 break;
520 case HANDLE_PRINTHANDOUT:
521 if( *pValues >>= bValue )
522 {
523 if( aPrintOpts.IsHandout() != bValue)
524 {
525 aPrintOpts.SetHandout( bValue );
526 bOptionsChanged = true;
527 }
528
529 bOk = true;
530 }
531 break;
532 case HANDLE_PRINTOUTLINE:
533 if( *pValues >>= bValue )
534 {
535 if( aPrintOpts.IsOutline() != bValue)
536 {
537 aPrintOpts.SetOutline( bValue );
538 bOptionsChanged = true;
539 }
540 bOk = true;
541 }
542 break;
543 case HANDLE_SLIDESPERHANDOUT:
544 {
545 sal_Int16 nValue = 0;
546 if( (*pValues >>= nValue) && (nValue >= 1) && (nValue <= 9) )
547 {
548 if( static_cast<sal_Int16>( aPrintOpts.GetHandoutPages() ) != nValue )
549 {
550 aPrintOpts.SetHandoutPages( static_cast< sal_uInt16 >( nValue ) );
551 bOptionsChanged = true;
552 }
553 bOk = true;
554 }
555 }
556 break;
557 case HANDLE_HANDOUTHORIZONTAL:
558 if( *pValues >>= bValue )
559 {
560 if( aPrintOpts.IsHandoutHorizontal() != bValue )
561 {
562 aPrintOpts.SetHandoutHorizontal( bValue );
563 bOptionsChanged = true;
564 }
565 bOk = true;
566 }
567 break;
568
569 case HANDLE_PRINTPAGENAME:
570 if( *pValues >>= bValue )
571 {
572 if( aPrintOpts.IsPagename() != bValue)
573 {
574 aPrintOpts.SetPagename( bValue );
575 bOptionsChanged = true;
576 }
577 bOk = true;
578 }
579 break;
580 case HANDLE_PRINTDATE:
581 if( *pValues >>= bValue )
582 {
583 if( aPrintOpts.IsDate() != bValue)
584 {
585 aPrintOpts.SetDate( bValue );
586 bOptionsChanged = true;
587 }
588 bOk = true;
589 }
590 break;
591 case HANDLE_PRINTTIME:
592 if( *pValues >>= bValue )
593 {
594 if( aPrintOpts.IsDate() != bValue)
595 {
596 aPrintOpts.SetTime( bValue );
597 bOptionsChanged = true;
598 }
599 bOk = true;
600 }
601 break;
602 case HANDLE_PRINTHIDDENPAGES:
603 if( *pValues >>= bValue )
604 {
605 if( aPrintOpts.IsHiddenPages() != bValue)
606 {
607 aPrintOpts.SetHiddenPages( bValue );
608 bOptionsChanged = true;
609 }
610 bOk = true;
611 }
612 break;
613 case HANDLE_PRINTFITPAGE:
614 if( *pValues >>= bValue )
615 {
616 if( aPrintOpts.IsPagesize() != bValue)
617 {
618 aPrintOpts.SetPagesize( bValue );
619 bOptionsChanged = true;
620 }
621 bOk = true;
622 }
623 break;
624 case HANDLE_PRINTTILEPAGE:
625 if( *pValues >>= bValue )
626 {
627 if( aPrintOpts.IsPagetile() != bValue)
628 {
629 aPrintOpts.SetPagetile( bValue );
630 bOptionsChanged = true;
631 }
632 bOk = true;
633 }
634 break;
635 case HANDLE_PRINTBOOKLET:
636 if( *pValues >>= bValue )
637 {
638 if( aPrintOpts.IsBooklet() != bValue)
639 {
640 aPrintOpts.SetBooklet( bValue );
641 bOptionsChanged = true;
642 }
643 bOk = true;
644 }
645 break;
646 case HANDLE_PRINTBOOKLETFRONT:
647 if( *pValues >>= bValue )
648 {
649 if( aPrintOpts.IsFrontPage() != bValue)
650 {
651 aPrintOpts.SetFrontPage( bValue );
652 bOptionsChanged = true;
653 }
654 bOk = true;
655 }
656 break;
657 case HANDLE_PRINTBOOKLETBACK:
658 if( *pValues >>= bValue )
659 {
660 if( aPrintOpts.IsBackPage() != bValue)
661 {
662 aPrintOpts.SetBackPage( bValue );
663 bOptionsChanged = true;
664 }
665 bOk = true;
666 }
667 break;
668 case HANDLE_PRINTQUALITY:
669 {
670 sal_Int32 nValue = 0;
671 if( *pValues >>= nValue )
672 {
673 if( aPrintOpts.GetOutputQuality() != nValue)
674 {
675 aPrintOpts.SetOutputQuality( static_cast<sal_uInt16>(nValue) );
676 bOptionsChanged = true;
677 }
678 bOk = true;
679 }
680 }
681 break;
682 case HANDLE_MEASUREUNIT:
683 {
684 sal_Int16 nValue = 0;
685 if( *pValues >>= nValue )
686 {
687 FieldUnit nFieldUnit;
688 if( SvxMeasureUnitToFieldUnit( nValue, nFieldUnit ) )
689 {
690 pDoc->SetUIUnit( nFieldUnit );
691 bOk = true;
692 }
693 }
694 }
695 break;
696 case HANDLE_SCALE_NUM:
697 {
698 sal_Int32 nValue = 0;
699 if( *pValues >>= nValue )
700 {
701 Fraction aFract( nValue, pDoc->GetUIScale().GetDenominator() );
702 pDoc->SetUIScale( aFract );
703 bOk = true;
704 bChanged = true;
705 }
706 }
707 break;
708 case HANDLE_SCALE_DOM:
709 {
710 sal_Int32 nValue = 0;
711 if( *pValues >>= nValue )
712 {
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;
719 }
720 }
721 break;
722
723 case HANDLE_TABSTOP:
724 {
725 sal_Int32 nValue = 0;
726 if( (*pValues >>= nValue) && (nValue >= 0) )
727 {
728 pDoc->SetDefaultTabulator(static_cast<sal_uInt16>(nValue));
729 bOk = true;
730 bChanged = true;
731 }
732 }
733 break;
734 case HANDLE_PAGENUMFMT:
735 {
736 sal_Int32 nValue = 0;
737 if( (*pValues >>= nValue ) && (nValue >= css::style::NumberingType::CHARS_UPPER_LETTER ) && (nValue <= css::style::NumberingType::PAGE_DESCRIPTOR) )
738 {
739 pDoc->SetPageNumType(static_cast<SvxNumType>(nValue));
740 bOk = true;
741 bChanged = true;
742 }
743 }
744 break;
745 case HANDLE_PRINTERNAME:
746 {
747 OUString aPrinterName;
748 if( *pValues >>= aPrinterName )
749 {
750 bOk = true;
751 if( !aPrinterName.isEmpty() && pDocSh->GetCreateMode() != SfxObjectCreateMode::EMBEDDED )
752 {
753 SfxPrinter *pTempPrinter = pDocSh->GetPrinter( true );
754 if (pTempPrinter)
755 {
756 VclPtr<SfxPrinter> pNewPrinter = VclPtr<SfxPrinter>::Create( pTempPrinter->GetOptions().Clone(), aPrinterName );
757 pDocSh->SetPrinter( pNewPrinter );
758 }
759 }
760 }
761 }
762 break;
763 case HANDLE_PRINTERJOB:
764 {
765 Sequence < sal_Int8 > aSequence;
766 if ( *pValues >>= aSequence )
767 {
768 bOk = true;
769 sal_uInt32 nSize = aSequence.getLength();
770 if( nSize )
771 {
772 SvMemoryStream aStream (aSequence.getArray(), nSize, StreamMode::READ );
773 aStream.Seek ( STREAM_SEEK_TO_BEGIN );
774 std::unique_ptr<SfxItemSet> pItemSet;
775
776 bool bPreferPrinterPapersize = false;
777 if( pPrinter )
778 {
779 pItemSet = pPrinter->GetOptions().Clone();
780 bPreferPrinterPapersize = pPrinter->GetPrinterSettingsPreferred();
781 }
782 else
783 {
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());
788 }
789
790 pPrinter = SfxPrinter::Create ( aStream, std::move(pItemSet) );
791 pPrinter->SetPrinterSettingsPreferred( bPreferPrinterPapersize );
792
793 MapMode aMM (pPrinter->GetMapMode());
794 aMM.SetMapUnit(MapUnit::Map100thMM);
795 pPrinter->SetMapMode(aMM);
796
797 pDocSh->SetPrinter( pPrinter );
798
799 pPrinter = nullptr;
800 }
801 }
802 }
803 break;
804
805 case HANDLE_PRINTERPAPERSIZE:
806 {
807 bool bPreferPrinterPapersize;
808 if( *pValues >>= bPreferPrinterPapersize )
809 {
810 bOk = true;
811 if( pDocSh->GetCreateMode() != SfxObjectCreateMode::EMBEDDED )
812 {
813 SfxPrinter *pTempPrinter = pDocSh->GetPrinter( true );
814 if (pTempPrinter)
815 pTempPrinter->SetPrinterSettingsPreferred( bPreferPrinterPapersize );
816 }
817 }
818 }
819 break;
820
821 case HANDLE_PARAGRAPHSUMMATION :
822 {
823 bool bIsSummationOfParagraphs = false;
824 if ( *pValues >>= bIsSummationOfParagraphs )
825 {
826 bOk = true;
827 bChanged = true;
828 if ( pDoc->GetDocumentType() == DocumentType::Impress )
829 {
830 EEControlBits nSum = bIsSummationOfParagraphs ? EEControlBits::ULSPACESUMMATION : EEControlBits::NONE;
831 EEControlBits nCntrl;
832
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 )
840 {
841 nCntrl = pOutl->GetControlWord() &~ EEControlBits::ULSPACESUMMATION;
842 pOutl->SetControlWord( nCntrl | nSum );
843 }
844 pOutl = pDocument->GetInternalOutliner( false );
845 if( pOutl )
846 {
847 nCntrl = pOutl->GetControlWord() &~ EEControlBits::ULSPACESUMMATION;
848 pOutl->SetControlWord( nCntrl | nSum );
849 }
850 }
851 }
852 }
853 break;
854
855 case HANDLE_CHARCOMPRESS:
856 {
857 sal_Int16 nCharCompressType = 0;
858 if( *pValues >>= nCharCompressType )
859 {
860 bOk = true;
861
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 )
868 {
869 pOutl->SetAsianCompressionMode( static_cast<CharCompressType>(nCharCompressType) );
870 }
871 pOutl = pDocument->GetInternalOutliner( false );
872 if( pOutl )
873 {
874 pOutl->SetAsianCompressionMode( static_cast<CharCompressType>(nCharCompressType) );
875 }
876 }
877 break;
878
879 }
880 case HANDLE_ASIANPUNCT:
881 {
882 bool bAsianPunct = false;
883 if( *pValues >>= bAsianPunct )
884 {
885 bOk = true;
886
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 )
893 {
894 pOutl->SetKernAsianPunctuation( bAsianPunct );
895 }
896 pOutl = pDocument->GetInternalOutliner( false );
897 if( pOutl )
898 {
899 pOutl->SetKernAsianPunctuation( bAsianPunct );
900 }
901 }
902 break;
903
904 }
905 case HANDLE_UPDATEFROMTEMPLATE:
906 {
907 bool value = false;
908 if( *pValues >>= value )
909 {
910 bChanged = ( value != pDocSh->IsQueryLoadTemplate() );
911 pDocSh->SetQueryLoadTemplate( value );
912 bOk = true;
913 }
914 }
915 break;
916
917 case HANDLE_PRINTER_INDEPENDENT_LAYOUT:
918 {
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)
926 {
927 pDoc->SetPrinterIndependentLayout (nValue);
928 bChanged = (nValue != nOldValue);
929 bOk = true;
930 }
931 }
932 break;
933
934 // --> #i33095#
935 case HANDLE_LOAD_READONLY:
936 {
937 bool bNewValue = false;
938 if ( *pValues >>= bNewValue )
939 {
940 bChanged = ( pDocSh->IsLoadReadonly() != bNewValue );
941 pDocSh->SetLoadReadonly( bNewValue );
942 bOk = true;
943 }
944 }
945 break;
946
947 case HANDLE_MODIFY_PASSWD:
948 {
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 );
955
956 if ( !pDocSh->SetModifyPasswordInfo( aInfo ) )
957 throw beans::PropertyVetoException(
958 "The hash is not allowed to be changed now!" );
959
960 bOk = true
961;
962
963 }
964 break;
965
966 case HANDLE_SAVE_VERSION:
967 {
968 bool bNewValue = false;
969 if ( *pValues >>= bNewValue )
970 {
971 bChanged = ( pDocSh->IsSaveVersionOnClose() != bNewValue );
972 pDocSh->SetSaveVersionOnClose( bNewValue );
973 bOk = true;
974 }
975 }
976 break;
977
978 case HANDLE_EMBED_FONTS:
979 {
980 if (pValues->has<bool>())
981 {
982 bool bNewValue = pValues->get<bool>();
983 bChanged = (pDoc->IsEmbedFonts() != bNewValue);
984 pDoc->SetEmbedFonts(bNewValue);
985 bOk = true;
986 }
987 }
988 break;
989
990 case HANDLE_EMBED_USED_FONTS:
991 {
992 if (pValues->has<bool>())
993 {
994 bool bNewValue = pValues->get<bool>();
995 bChanged = (pDoc->IsEmbedUsedFontsOnly() != bNewValue);
996 pDoc->SetEmbedUsedFontsOnly(bNewValue);
997 bOk = true;
998 }
999 }
1000 break;
1001
1002 case HANDLE_EMBED_LATIN_SCRIPT_FONTS:
1003 {
1004 if (pValues->has<bool>())
1005 {
1006 bool bNewValue = pValues->get<bool>();
1007 bChanged = (pDoc->IsEmbedFontScriptLatin() != bNewValue);
1008 pDoc->SetEmbedFontScriptLatin(bNewValue);
1009 bOk = true;
1010 }
1011 }
1012 break;
1013
1014 case HANDLE_EMBED_ASIAN_SCRIPT_FONTS:
1015 {
1016 if (pValues->has<bool>())
1017 {
1018 bool bNewValue = pValues->get<bool>();
1019 bChanged = (pDoc->IsEmbedFontScriptAsian() != bNewValue);
1020 pDoc->SetEmbedFontScriptAsian(bNewValue);
1021 bOk = true;
1022 }
1023 }
1024 break;
1025
1026 case HANDLE_EMBED_COMPLEX_SCRIPT_FONTS:
1027 {
1028 if (pValues->has<bool>())
1029 {
1030 bool bNewValue = pValues->get<bool>();
1031 bChanged = (pDoc->IsEmbedFontScriptComplex() != bNewValue);
1032 pDoc->SetEmbedFontScriptComplex(bNewValue);
1033 bOk = true;
1034 }
1035 }
1036 break;
1037
1038 case HANDLE_IMAGE_PREFERRED_DPI:
1039 {
1040 if (pValues->has<sal_Int32>())
1041 {
1042 auto nNewValue = pValues->get<sal_Int32>();
1043 bChanged = (pDoc->getImagePreferredDPI() != nNewValue);
1044 pDoc->setImagePreferredDPI(nNewValue);
1045 bOk = true;
1046 }
1047 }
1048 break;
1049
1050 default:
1051 throw UnknownPropertyException( OUString::number((*ppEntries)->mnHandle), static_cast<cppu::OWeakObject*>(this));
1052 }
1053
1054 if( !bOk )
1055 throw IllegalArgumentException();
1056 }
1057
1058 if( bOptionsChanged )
1059 {
1060 if( !pPrinter )
1061 pPrinter = pDocSh->GetPrinter( true );
1062 SfxItemSet aNewOptions( pPrinter->GetOptions() );
1063 aNewOptions.Put( aOptionsPrintItem );
1064 pPrinter->SetOptions( aNewOptions );
1065 }
1066
1067 if( bChanged || bOptionsChanged )
1068 mxModel->SetModified();
1069}
1070
1071void DocumentSettings::ExtractURL( XPropertyListType t, Any* pValue )
1072{
1073 XPropertyListRef pList = mxModel->GetDoc()->GetPropertyList( t );
1074 if( !pList.is() )
1075 return;
1076
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;
1082}
1083
1084void
1085DocumentSettings::_getPropertyValues(
1086 const PropertyMapEntry** ppEntries, Any* pValue)
1087{
1088 ::SolarMutexGuard aGuard;
1089
1090 SdDrawDocument* pDoc = mxModel->GetDoc();
1091 ::sd::DrawDocShell* pDocSh = mxModel->GetDocShell();
1092 if( nullptr == pDoc || nullptr == pDocSh )
1093 {
1094 throw RuntimeException("Document or Shell missing",
1095 static_cast<OWeakObject *>(this));
1096 }
1097
1098 SdOptionsPrintItem aOptionsPrintItem;
1099
1100 SfxPrinter* pPrinter = pDocSh->GetPrinter( false );
1101 if( pPrinter )
1102 {
1103 SdOptionsPrintItem const * pPrinterOptions = pPrinter->GetOptions().GetItemIfSet( ATTR_OPTIONS_PRINT, false );
1104 if (pPrinterOptions)
1105 aOptionsPrintItem.GetOptionsPrint() = pPrinterOptions->GetOptionsPrint();
1106 }
1107 else
1108 {
1109 aOptionsPrintItem.SetOptions( SD_MOD()->GetSdOptions(pDoc->GetDocumentType()) );
1110 }
1111 SdOptionsPrint& aPrintOpts = aOptionsPrintItem.GetOptionsPrint();
1112
1113 for( ; *ppEntries; ppEntries++, pValue++ )
1114 {
1115 switch( (*ppEntries)->mnHandle )
1116 {
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:
1193 {
1194 short nMeasure;
1195 SvxFieldUnitToMeasureUnit( pDoc->GetUIUnit(), nMeasure );
1196 *pValue <<= static_cast<sal_Int16>(nMeasure);
1197 }
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:
1212 {
1213 SfxPrinter *pTempPrinter = pDocSh->GetPrinter( false );
1214 *pValue <<= pTempPrinter ? pTempPrinter->GetName() : OUString();
1215 }
1216 break;
1217 case HANDLE_PRINTERJOB:
1218 {
1219 SfxPrinter *pTempPrinter = pDocSh->GetPrinter( false );
1220 if (pTempPrinter)
1221 {
1222 SvMemoryStream aStream;
1223 pTempPrinter->Store( aStream );
1224 *pValue <<= Sequence< sal_Int8 >( static_cast< const sal_Int8* >( aStream.GetData() ),
1225 aStream.TellEnd() );
1226 }
1227 else
1228 {
1229 Sequence < sal_Int8 > aSequence;
1230 *pValue <<= aSequence;
1231 }
1232 }
1233 break;
1234
1235 case HANDLE_PRINTERPAPERSIZE:
1236 {
1237 SfxPrinter *pTempPrinter = pDocSh->GetPrinter( false );
1238 *pValue <<= pTempPrinter && pTempPrinter->GetPrinterSettingsPreferred();
1239 }
1240 break;
1241
1242 case HANDLE_PARAGRAPHSUMMATION :
1243 {
1244 bool bIsSummationOfParagraphs = pDoc->IsSummationOfParagraphs();
1245 *pValue <<= bIsSummationOfParagraphs;
1246 }
1247 break;
1248
1249 case HANDLE_CHARCOMPRESS:
1250 {
1251 *pValue <<= static_cast<sal_Int16>(pDoc->GetCharCompressType());
1252 break;
1253 }
1254
1255 case HANDLE_ASIANPUNCT:
1256 {
1257 *pValue <<= pDoc->IsKernAsianPunctuation();
1258 break;
1259 }
1260
1261 case HANDLE_UPDATEFROMTEMPLATE:
1262 {
1263 *pValue <<= pDocSh->IsQueryLoadTemplate();
1264 }
1265 break;
1266
1267 case HANDLE_PRINTER_INDEPENDENT_LAYOUT:
1268 {
1269 sal_Int16 nPrinterIndependentLayout =
1270 static_cast<sal_Int16>(pDoc->GetPrinterIndependentLayout());
1271 *pValue <<= nPrinterIndependentLayout;
1272 }
1273 break;
1274
1275 // --> #i33095#
1276 case HANDLE_LOAD_READONLY:
1277 {
1278 *pValue <<= pDocSh->IsLoadReadonly();
1279 }
1280 break;
1281
1282 case HANDLE_MODIFY_PASSWD:
1283 {
1284 *pValue <<= pDocSh->GetModifyPasswordInfo();
1285 }
1286 break;
1287
1288 case HANDLE_SAVE_VERSION:
1289 {
1290 *pValue <<= pDocSh->IsSaveVersionOnClose();
1291 }
1292 break;
1293
1294 case HANDLE_EMBED_FONTS:
1295 {
1296 *pValue <<= pDoc->IsEmbedFonts();
1297 }
1298 break;
1299
1300 case HANDLE_EMBED_USED_FONTS:
1301 {
1302 *pValue <<= pDoc->IsEmbedUsedFontsOnly();
1303 }
1304 break;
1305
1306 case HANDLE_EMBED_LATIN_SCRIPT_FONTS:
1307 {
1308 *pValue <<= pDoc->IsEmbedFontScriptLatin();
1309 }
1310 break;
1311
1312 case HANDLE_EMBED_ASIAN_SCRIPT_FONTS:
1313 {
1314 *pValue <<= pDoc->IsEmbedFontScriptAsian();
1315 }
1316 break;
1317
1318 case HANDLE_EMBED_COMPLEX_SCRIPT_FONTS:
1319 {
1320 *pValue <<= pDoc->IsEmbedFontScriptComplex();
1321 }
1322 break;
1323
1324 case HANDLE_IMAGE_PREFERRED_DPI:
1325 {
1326 *pValue <<= pDoc->getImagePreferredDPI();
1327 }
1328 break;
1329
1330 default:
1331 throw UnknownPropertyException( OUString::number((*ppEntries)->mnHandle), static_cast<cppu::OWeakObject*>(this));
1332 }
1333 }
1334}
1335
1336// XInterface
1337Any SAL_CALL DocumentSettings::queryInterface( const Type& aType )
1338{
1339 return WeakImplHelper< XPropertySet, XMultiPropertySet, XServiceInfo >::queryInterface( aType );
1340}
1341
1342void SAL_CALL DocumentSettings::acquire( ) noexcept
1343{
1344 WeakImplHelper< XPropertySet, XMultiPropertySet, XServiceInfo >::acquire();
1345}
1346
1347void SAL_CALL DocumentSettings::release( ) noexcept
1348{
1349 WeakImplHelper< XPropertySet, XMultiPropertySet, XServiceInfo >::release();
1350}
1351
1352// XPropertySet
1353Reference< XPropertySetInfo > SAL_CALL DocumentSettings::getPropertySetInfo( )
1354{
1355 return PropertySetHelper::getPropertySetInfo();
1356}
1357
1358void SAL_CALL DocumentSettings::setPropertyValue( const OUString& aPropertyName, const Any& aValue )
1359{
1360 PropertySetHelper::setPropertyValue( aPropertyName, aValue );
1361}
1362
1363Any SAL_CALL DocumentSettings::getPropertyValue( const OUString& PropertyName )
1364{
1365 return PropertySetHelper::getPropertyValue( PropertyName );
1366}
1367
1368void SAL_CALL DocumentSettings::addPropertyChangeListener( const OUString& aPropertyName, const Reference< XPropertyChangeListener >& xListener )
1369{
1370 PropertySetHelper::addPropertyChangeListener( aPropertyName, xListener );
1371}
1372
1373void SAL_CALL DocumentSettings::removePropertyChangeListener( const OUString& aPropertyName, const Reference< XPropertyChangeListener >& aListener )
1374{
1375 PropertySetHelper::removePropertyChangeListener( aPropertyName, aListener );
1376}
1377
1378void SAL_CALL DocumentSettings::addVetoableChangeListener( const OUString& PropertyName, const Reference< XVetoableChangeListener >& aListener )
1379{
1380 PropertySetHelper::addVetoableChangeListener( PropertyName, aListener );
1381}
1382
1383void SAL_CALL DocumentSettings::removeVetoableChangeListener( const OUString& PropertyName, const Reference< XVetoableChangeListener >& aListener )
1384{
1385 PropertySetHelper::removeVetoableChangeListener( PropertyName, aListener );
1386}
1387
1388// XMultiPropertySet
1389void SAL_CALL DocumentSettings::setPropertyValues( const Sequence< OUString >& aPropertyNames, const Sequence< Any >& aValues )
1390{
1391 PropertySetHelper::setPropertyValues( aPropertyNames, aValues );
1392}
1393
1394Sequence< Any > SAL_CALL DocumentSettings::getPropertyValues( const Sequence< OUString >& aPropertyNames )
1395{
1396 return PropertySetHelper::getPropertyValues( aPropertyNames );
1397}
1398
1399void SAL_CALL DocumentSettings::addPropertiesChangeListener( const Sequence< OUString >& aPropertyNames, const Reference< XPropertiesChangeListener >& xListener )
1400{
1401 PropertySetHelper::addPropertiesChangeListener( aPropertyNames, xListener );
1402}
1403
1404void SAL_CALL DocumentSettings::removePropertiesChangeListener( const Reference< XPropertiesChangeListener >& xListener )
1405{
1406 PropertySetHelper::removePropertiesChangeListener( xListener );
1407}
1408
1409void SAL_CALL DocumentSettings::firePropertiesChangeEvent( const Sequence< OUString >& aPropertyNames, const Reference< XPropertiesChangeListener >& xListener )
1410{
1411 PropertySetHelper::firePropertiesChangeEvent( aPropertyNames, xListener );
1412}
1413
1414// XServiceInfo
1415OUString SAL_CALL DocumentSettings::getImplementationName( )
1416{
1417 return "com.sun.star.comp.Draw.DocumentSettings";
1418}
1419
1420sal_Bool SAL_CALL DocumentSettings::supportsService( const OUString& ServiceName )
1421{
1422 return cppu::supportsService(this, ServiceName);
1423}
1424
1425Sequence< OUString > SAL_CALL DocumentSettings::getSupportedServiceNames( )
1426{
1427 return { "com.sun.star.document.Settings" ,
1428 mxModel->IsImpressDocument()?OUString("com.sun.star.presentation.DocumentSettings"):OUString("com.sun.star.drawing.DocumentSettings") };
1429}
1430
1431/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const PropertyValue * pValues
css::uno::Reference< css::frame::XModel2 > mxModel
static OUString getNameOfType(XPropertyListType t)
XPropertyListType t
struct @1 aURLPropertyNames[]
const char * pName
#define MID_PRINTER
static XPropertyListType getTypeOfName(std::u16string_view aName)
CharCompressType
sal_Int32 GetNumerator() const
sal_Int32 GetDenominator() const
SAL_DLLPRIVATE bool IsEmbedFonts() const
Definition: drawdoc.hxx:609
SAL_DLLPRIVATE void SetEmbedFontScriptComplex(bool bUse)
Definition: drawdoc.hxx:619
SAL_DLLPRIVATE void SetPrinterIndependentLayout(sal_Int32 nMode)
Set the mode that controls whether (and later how) the formatting of the document depends on the curr...
Definition: drawdoc.cxx:1034
SAL_DLLPRIVATE void SetEmbedFontScriptLatin(bool bUse)
Definition: drawdoc.hxx:617
SAL_DLLPRIVATE void SetEmbedFonts(bool bUse)
Definition: drawdoc.hxx:615
SAL_DLLPRIVATE SfxItemPool & GetPool()
Definition: drawdoc.hxx:237
SAL_DLLPRIVATE void SetSummationOfParagraphs(bool bOn=true)
Definition: drawdoc.hxx:405
SAL_DLLPRIVATE void SetPageNumType(SvxNumType eType)
Definition: drawdoc.hxx:248
SAL_DLLPRIVATE bool IsSummationOfParagraphs() const
Definition: drawdoc.hxx:406
SdOutliner * GetInternalOutliner(bool bCreateOutliner=true)
Definition: drawdoc.cxx:930
SAL_DLLPRIVATE SdOutliner * GetOutliner(bool bCreateOutliner=true)
Definition: drawdoc.cxx:912
SAL_DLLPRIVATE bool IsEmbedFontScriptLatin() const
Definition: drawdoc.hxx:611
SAL_DLLPRIVATE void SetEmbedUsedFontsOnly(bool bUse)
Definition: drawdoc.hxx:616
void setImagePreferredDPI(sal_Int32 nValue)
Definition: drawdoc.hxx:622
SAL_DLLPRIVATE bool IsEmbedFontScriptComplex() const
Definition: drawdoc.hxx:613
SAL_DLLPRIVATE bool IsEmbedUsedFontsOnly() const
Definition: drawdoc.hxx:610
SAL_DLLPRIVATE sal_Int32 GetPrinterIndependentLayout() const
Get the flag that controls whether the formatting of the document depends on the current printer metr...
Definition: drawdoc.hxx:428
SAL_DLLPRIVATE bool IsEmbedFontScriptAsian() const
Definition: drawdoc.hxx:612
SAL_DLLPRIVATE void SetEmbedFontScriptAsian(bool bUse)
Definition: drawdoc.hxx:618
sal_Int32 getImagePreferredDPI() const override
Definition: drawdoc.hxx:621
SAL_DLLPRIVATE SvxNumType GetPageNumType() const override
Definition: drawdoc.cxx:1029
SAL_DLLPRIVATE DocumentType GetDocumentType() const
Definition: drawdoc.hxx:251
SdOptionsPrint & GetOptionsPrint()
Definition: optsitem.hxx:570
void SetOptions(SdOptions *pOpts) const
Definition: optsitem.cxx:1354
bool IsBooklet() const
Definition: optsitem.hxx:526
sal_uInt16 GetHandoutPages() const
Definition: optsitem.hxx:533
bool IsTime() const
Definition: optsitem.hxx:518
void SetHandoutHorizontal(bool bHandoutHorizontal)
Definition: optsitem.hxx:554
bool IsDate() const
Definition: optsitem.hxx:517
bool IsNotes() const
Definition: optsitem.hxx:514
void SetNotes(bool bOn)
Definition: optsitem.hxx:536
void SetFrontPage(bool bOn)
Definition: optsitem.hxx:549
void SetDate(bool bOn)
Definition: optsitem.hxx:539
bool IsHandout() const
Definition: optsitem.hxx:515
void SetBackPage(bool bOn)
Definition: optsitem.hxx:550
void SetBooklet(bool bOn)
Definition: optsitem.hxx:548
void SetPagesize(bool bOn)
Definition: optsitem.hxx:543
void SetHiddenPages(bool bOn)
Definition: optsitem.hxx:542
bool IsOutline() const
Definition: optsitem.hxx:516
void SetDraw(bool bOn)
Definition: optsitem.hxx:535
bool IsFrontPage() const
Definition: optsitem.hxx:527
void SetTime(bool bOn)
Definition: optsitem.hxx:540
bool IsPagename() const
Definition: optsitem.hxx:519
void SetPagename(bool bOn)
Definition: optsitem.hxx:541
void SetOutline(bool bOn)
Definition: optsitem.hxx:538
bool IsPagetile() const
Definition: optsitem.hxx:522
void SetOutputQuality(sal_uInt16 nInQuality)
Definition: optsitem.hxx:553
bool IsPagesize() const
Definition: optsitem.hxx:521
bool IsHandoutHorizontal() const
Definition: optsitem.hxx:532
void SetPagetile(bool bOn)
Definition: optsitem.hxx:544
void SetHandoutPages(sal_uInt16 nHandoutPages)
Definition: optsitem.hxx:555
bool IsHiddenPages() const
Definition: optsitem.hxx:520
bool IsDraw() const
Definition: optsitem.hxx:513
void SetHandout(bool bOn)
Definition: optsitem.hxx:537
bool IsBackPage() const
Definition: optsitem.hxx:528
sal_uInt16 GetOutputQuality() const
Definition: optsitem.hxx:531
The main purpose of this class is searching and replacing as well as spelling of impress documents.
Definition: Outliner.hxx:123
void SetUIScale(const Fraction &rScale)
bool IsKernAsianPunctuation() const
void SetKernAsianPunctuation(bool bEnabled)
void SetCharCompressType(CharCompressType nType)
sal_uInt16 GetDefaultTabulator() const
void SetUIUnit(FieldUnit eUnit)
void SetDefaultTabulator(sal_uInt16 nVal)
SdrOutliner & GetDrawOutliner(const SdrTextObj *pObj=nullptr) const
CharCompressType GetCharCompressType() const
FieldUnit GetUIUnit() const
void SetPropertyList(XPropertyListRef const &p)
const Fraction & GetUIScale() const
const XPropertyListRef & GetPropertyList(XPropertyListType t) const
virtual std::unique_ptr< SfxItemSet > Clone(bool bItems=true, SfxItemPool *pToPool=nullptr) const
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
bool SetModifyPasswordInfo(const css::uno::Sequence< css::beans::PropertyValue > &aInfo)
bool IsLoadReadonly() const
bool IsUseUserData() const
void SetQueryLoadTemplate(bool b)
void SetSaveVersionOnClose(bool bSet)
void SetUseThumbnailSave(bool _bNew)
void SetUseUserData(bool bNew)
bool IsUseThumbnailSave() const
bool IsSaveVersionOnClose() const
void SetLoadReadonly(bool _bReadonly)
SfxObjectCreateMode GetCreateMode() const
const css::uno::Sequence< css::beans::PropertyValue > & GetModifyPasswordInfo() const
bool IsQueryLoadTemplate() const
void Store(SvStream &rStream) const
static VclPtr< SfxPrinter > Create(SvStream &rStream, std::unique_ptr< SfxItemSet > &&pOptions)
const SfxItemSet & GetOptions() const
const void * GetData()
virtual sal_uInt64 TellEnd() override
static VclPtr< reference_type > Create(Arg &&... arg)
static XPropertyListRef CreatePropertyList(XPropertyListType t, const OUString &rPath, const OUString &rReferer)
css::uno::Type const & get()
void SetPrinter(SfxPrinter *pNewPrinter)
Set new SfxPrinter (transfer of ownership)
Definition: docshel4.cxx:142
SfxPrinter * GetPrinter(bool bCreate)
Creates (if necessary) and returns a SfxPrinter.
Definition: docshel4.cxx:95
SdDrawDocument * GetDoc()
Any value
#define DBG_ASSERT(sCon, aError)
URL aURL
EEControlBits
FieldUnit
sal_Int16 nValue
OUString aName
#define SAL_N_ELEMENTS(arr)
Type
css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType, Interface1 *p1)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
int i
bool equalsAscii(std::u16string_view s1, std::string_view s2)
static rtl::Reference< PropertySetInfo > createSettingsInfoImpl(bool bIsDraw)
Reference< XInterface > DocumentSettings_createInstance(SdXImpressDocument *pModel) noexcept
std::pair< OUString const, DataAccessDescriptorProperty > PropertyMapEntry
#define SD_MOD()
Definition: sdmod.hxx:184
SvxNumType
unsigned char sal_Bool
signed char sal_Int8
SVXCORE_DLLPUBLIC bool SvxMeasureUnitToFieldUnit(const short eApi, FieldUnit &nVcl) noexcept
SVXCORE_DLLPUBLIC bool SvxFieldUnitToMeasureUnit(const FieldUnit nVcl, short &eApi) noexcept
XPropertyListType