1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
24 #include <config_features.h>
26 #include <confuno.hxx>
27 #include <unonames.hxx>
29 #include <miscuno.hxx>
30 #include <forbiuno.hxx>
31 #include <appoptio.hxx>
32 #include <viewopti.hxx>
33 #include <docpool.hxx>
37 #include <com/sun/star/beans/PropertyAttribute.hpp>
38 #include <com/sun/star/document/LinkUpdateModes.hpp>
39 #include <cppuhelper/supportsservice.hxx>
40 #include <formula/grammar.hxx>
41 #include <sfx2/printer.hxx>
42 #include <svl/itemset.hxx>
43 #include <vcl/svapp.hxx>
44 #include <tools/stream.hxx>
46 using namespace com::sun::star
;
48 constexpr OUString SCSAVEVERSION
= u
"SaveVersionOnClose"_ustr
;
50 static std::span
<const SfxItemPropertyMapEntry
> lcl_GetConfigPropertyMap()
52 static const SfxItemPropertyMapEntry aConfigPropertyMap_Impl
[] =
54 { SC_UNO_SHOWZERO
, 0, cppu::UnoType
<bool>::get(), 0, 0},
55 { SC_UNO_SHOWNOTES
, 0, cppu::UnoType
<bool>::get(), 0, 0},
56 { SC_UNO_SHOWNOTEAUTHOR
, 0, cppu::UnoType
<bool>::get(), 0, 0},
57 { SC_UNO_SHOWFORMULASMARKS
, 0, cppu::UnoType
<bool>::get(), 0, 0},
58 { SC_UNO_SHOWGRID
, 0, cppu::UnoType
<bool>::get(), 0, 0},
59 { SC_UNO_GRIDCOLOR
, 0, cppu::UnoType
<sal_Int32
>::get(), 0, 0},
60 { SC_UNO_SHOWPAGEBR
, 0, cppu::UnoType
<bool>::get(), 0, 0},
61 { SC_UNONAME_LINKUPD
, 0, cppu::UnoType
<sal_Int16
>::get(), 0, 0},
62 { SC_UNO_COLROWHDR
, 0, cppu::UnoType
<bool>::get(), 0, 0},
63 { SC_UNO_SHEETTABS
, 0, cppu::UnoType
<bool>::get(), 0, 0},
64 { SC_UNO_OUTLSYMB
, 0, cppu::UnoType
<bool>::get(), 0, 0},
65 { SC_UNO_SNAPTORASTER
, 0, cppu::UnoType
<bool>::get(), 0, 0},
66 { SC_UNO_RASTERVIS
, 0, cppu::UnoType
<bool>::get(), 0, 0},
67 { SC_UNO_RASTERRESX
, 0, cppu::UnoType
<sal_Int32
>::get(), 0, 0},
68 { SC_UNO_RASTERRESY
, 0, cppu::UnoType
<sal_Int32
>::get(), 0, 0},
69 { SC_UNO_RASTERSUBX
, 0, cppu::UnoType
<sal_Int32
>::get(), 0, 0},
70 { SC_UNO_RASTERSUBY
, 0, cppu::UnoType
<sal_Int32
>::get(), 0, 0},
71 { SC_UNO_RASTERSYNC
, 0, cppu::UnoType
<bool>::get(), 0, 0},
72 { SC_UNO_AUTOCALC
, 0, cppu::UnoType
<bool>::get(), 0, 0},
73 { SC_UNO_PRINTERNAME
, 0, cppu::UnoType
<OUString
>::get(), 0, 0},
74 { SC_UNO_PRINTERSETUP
, 0, cppu::UnoType
<uno::Sequence
<sal_Int8
>>::get(), 0, 0},
75 { SC_UNO_PRINTERPAPER
, 0, cppu::UnoType
<bool>::get(), 0, 0},
76 { SC_UNO_APPLYDOCINF
, 0, cppu::UnoType
<bool>::get(), 0, 0 },
77 { SC_UNO_SAVE_THUMBNAIL
, 0, cppu::UnoType
<bool>::get(), 0, 0 },
78 { SC_UNO_FORBIDDEN
, 0, cppu::UnoType
<i18n::XForbiddenCharacters
>::get(), beans::PropertyAttribute::READONLY
, 0},
79 { SC_UNO_CHARCOMP
, 0, cppu::UnoType
<sal_Int16
>::get(), 0, 0},
80 { SC_UNO_ASIANKERN
, 0, cppu::UnoType
<bool>::get(), 0, 0},
81 { SCSAVEVERSION
, 0, cppu::UnoType
<bool>::get(), 0, 0},
82 { SC_UNO_UPDTEMPL
, 0, cppu::UnoType
<bool>::get(), 0, 0},
83 /*Stampit enable/disable print cancel */
84 { SC_UNO_ALLOWPRINTJOBCANCEL
, 0, cppu::UnoType
<bool>::get(), 0, 0},
85 { SC_UNO_LOADREADONLY
, 0, cppu::UnoType
<bool>::get(), 0, 0},
86 { SC_UNO_SHAREDOC
, 0, cppu::UnoType
<bool>::get(), 0, 0},
87 { SC_UNO_MODIFYPASSWORDINFO
, 0, cppu::UnoType
<uno::Sequence
< beans::PropertyValue
>>::get(), 0, 0},
88 { SC_UNO_MODIFYPASSWORDHASH
, 0, cppu::UnoType
<sal_Int32
>::get(), 0, 0},
89 { SC_UNO_EMBED_FONTS
, 0, cppu::UnoType
<bool>::get(), 0, 0},
90 { SC_UNO_EMBED_ONLY_USED_FONTS
, 0, cppu::UnoType
<bool>::get(), 0, 0},
91 { SC_UNO_EMBED_FONT_SCRIPT_LATIN
, 0, cppu::UnoType
<bool>::get(), 0, 0},
92 { SC_UNO_EMBED_FONT_SCRIPT_ASIAN
, 0, cppu::UnoType
<bool>::get(), 0, 0},
93 { SC_UNO_EMBED_FONT_SCRIPT_COMPLEX
, 0, cppu::UnoType
<bool>::get(), 0, 0},
94 { SC_UNO_IMAGE_PREFERRED_DPI
, 0, cppu::UnoType
<sal_Int32
>::get(), 0, 0},
95 { SC_UNO_SYNTAXSTRINGREF
, 0, cppu::UnoType
<sal_Int16
>::get(), 0, 0},
97 return aConfigPropertyMap_Impl
;
100 ScDocumentConfiguration::ScDocumentConfiguration(ScDocShell
* pDocSh
)
101 : pDocShell(pDocSh
) ,
102 aPropSet ( lcl_GetConfigPropertyMap() )
104 pDocShell
->GetDocument().AddUnoObject(*this);
107 ScDocumentConfiguration::~ScDocumentConfiguration()
112 pDocShell
->GetDocument().RemoveUnoObject(*this);
115 void ScDocumentConfiguration::Notify( SfxBroadcaster
&, const SfxHint
& rHint
)
117 // reference update does not matter here
119 if ( rHint
.GetId() == SfxHintId::Dying
)
127 uno::Reference
<beans::XPropertySetInfo
> SAL_CALL
ScDocumentConfiguration::getPropertySetInfo()
129 SolarMutexGuard aGuard
;
130 static uno::Reference
<beans::XPropertySetInfo
> aRef(
131 new SfxItemPropertySetInfo( aPropSet
.getPropertyMap() ));
135 void SAL_CALL
ScDocumentConfiguration::setPropertyValue(
136 const OUString
& aPropertyName
, const uno::Any
& aValue
)
138 SolarMutexGuard aGuard
;
141 throw uno::RuntimeException();
143 ScDocument
& rDoc
= pDocShell
->GetDocument();
144 bool bUpdateHeights
= false;
146 ScViewOptions
aViewOpt(rDoc
.GetViewOptions());
148 /*Stampit enable/disable print cancel */
149 if ( aPropertyName
== SC_UNO_ALLOWPRINTJOBCANCEL
)
150 pDocShell
->Stamp_SetPrintCancelState( ScUnoHelpFunctions::GetBoolFromAny( aValue
) );
151 /*Stampit enable/disable print cancel */
153 else if ( aPropertyName
== SC_UNO_SHOWZERO
)
154 aViewOpt
.SetOption(VOPT_NULLVALS
, ScUnoHelpFunctions::GetBoolFromAny( aValue
) );
155 else if ( aPropertyName
== SC_UNO_SHOWNOTES
)
156 aViewOpt
.SetOption(VOPT_NOTES
, ScUnoHelpFunctions::GetBoolFromAny( aValue
) );
157 else if ( aPropertyName
== SC_UNO_SHOWNOTEAUTHOR
)
158 aViewOpt
.SetOption(VOPT_NOTEAUTHOR
, ScUnoHelpFunctions::GetBoolFromAny( aValue
) );
159 else if ( aPropertyName
== SC_UNO_SHOWFORMULASMARKS
)
160 aViewOpt
.SetOption(VOPT_FORMULAS_MARKS
, ScUnoHelpFunctions::GetBoolFromAny( aValue
) );
161 else if ( aPropertyName
== SC_UNO_SHOWGRID
)
162 aViewOpt
.SetOption(VOPT_GRID
, ScUnoHelpFunctions::GetBoolFromAny( aValue
) );
163 else if ( aPropertyName
== SC_UNO_GRIDCOLOR
)
166 if (aValue
>>= aColor
)
167 aViewOpt
.SetGridColor(aColor
, OUString());
169 else if ( aPropertyName
== SC_UNO_SHOWPAGEBR
)
170 aViewOpt
.SetOption(VOPT_PAGEBREAKS
, ScUnoHelpFunctions::GetBoolFromAny( aValue
) );
171 else if ( aPropertyName
== SC_UNONAME_LINKUPD
)
173 // XXX NOTE: this is the css::document::Settings property
174 // LinkUpdateMode, not the css::sheet::XGlobalSheetSettings
175 // attribute LinkUpdateMode.
177 if (!(aValue
>>= n
) || n
< css::document::LinkUpdateModes::NEVER
||
178 n
> css::document::LinkUpdateModes::GLOBAL_SETTING
)
180 throw css::lang::IllegalArgumentException(
181 (u
"LinkUpdateMode property value must be a SHORT with a value in"
182 " the range of the css::document::LinkUpdateModes constants"_ustr
),
183 css::uno::Reference
<css::uno::XInterface
>(), -1);
188 case css::document::LinkUpdateModes::NEVER
:
191 case css::document::LinkUpdateModes::MANUAL
:
192 eMode
= LM_ON_DEMAND
;
194 case css::document::LinkUpdateModes::AUTO
:
197 case css::document::LinkUpdateModes::GLOBAL_SETTING
:
199 eMode
= ScModule::get()->GetAppOptions().GetLinkMode();
202 rDoc
.SetLinkMode( eMode
);
204 else if ( aPropertyName
== SC_UNO_COLROWHDR
)
205 aViewOpt
.SetOption(VOPT_HEADER
, ScUnoHelpFunctions::GetBoolFromAny( aValue
) );
206 else if ( aPropertyName
== SC_UNO_SHEETTABS
)
207 aViewOpt
.SetOption(VOPT_TABCONTROLS
, ScUnoHelpFunctions::GetBoolFromAny( aValue
) );
208 else if ( aPropertyName
== SC_UNO_OUTLSYMB
)
209 aViewOpt
.SetOption(VOPT_OUTLINER
, ScUnoHelpFunctions::GetBoolFromAny( aValue
) );
210 else if ( aPropertyName
== SC_UNO_AUTOCALC
)
211 rDoc
.SetAutoCalc( ScUnoHelpFunctions::GetBoolFromAny( aValue
) );
212 else if ( aPropertyName
== SC_UNO_PRINTERNAME
)
214 OUString sPrinterName
;
215 if ( !(aValue
>>= sPrinterName
) )
216 throw lang::IllegalArgumentException();
218 // #i75610# if the name is empty, do nothing (don't create any printer)
219 if ( !sPrinterName
.isEmpty() && pDocShell
->GetCreateMode() != SfxObjectCreateMode::EMBEDDED
)
221 SfxPrinter
* pPrinter
= pDocShell
->GetPrinter();
223 throw uno::RuntimeException();
225 if (pPrinter
->GetName() != sPrinterName
)
227 VclPtrInstance
<SfxPrinter
> pNewPrinter( pPrinter
->GetOptions().Clone(), sPrinterName
);
228 if (pNewPrinter
->IsKnown())
229 pDocShell
->SetPrinter( pNewPrinter
, SfxPrinterChangeFlags::PRINTER
);
231 pNewPrinter
.disposeAndClear();
237 else if ( aPropertyName
== SC_UNO_PRINTERSETUP
)
239 uno::Sequence
<sal_Int8
> aSequence
;
240 if ( aValue
>>= aSequence
)
242 sal_uInt32 nSize
= aSequence
.getLength();
243 // #i75610# if the sequence is empty, do nothing (don't create any printer)
246 SvMemoryStream
aStream (aSequence
.getArray(), nSize
, StreamMode::READ
);
247 aStream
.Seek ( STREAM_SEEK_TO_BEGIN
);
248 auto pSet
= std::make_unique
<SfxItemSetFixed
249 <SID_PRINTER_NOTFOUND_WARN
, SID_PRINTER_NOTFOUND_WARN
,
250 SID_PRINTER_CHANGESTODOC
, SID_PRINTER_CHANGESTODOC
,
251 SID_PRINT_SELECTEDSHEET
, SID_PRINT_SELECTEDSHEET
,
252 SID_SCPRINTOPTIONS
, SID_SCPRINTOPTIONS
>>( *rDoc
.GetPool());
254 SfxPrinter
* pPrinter
= pDocShell
->GetPrinter();
255 bool bPreferPrinterPapersize
= false;
257 bPreferPrinterPapersize
= pPrinter
->GetPrinterSettingsPreferred();
259 VclPtr
<SfxPrinter
> pTempPrinter
= SfxPrinter::Create( aStream
, std::move(pSet
) );
260 pTempPrinter
->SetPrinterSettingsPreferred( bPreferPrinterPapersize
);
261 pDocShell
->SetPrinter( pTempPrinter
);
265 else if ( aPropertyName
== SC_UNO_PRINTERPAPER
)
267 bool bPreferPrinterPapersize
;
268 if( aValue
>>= bPreferPrinterPapersize
)
270 if( pDocShell
->GetCreateMode() != SfxObjectCreateMode::EMBEDDED
)
272 SfxPrinter
*pTempPrinter
= pDocShell
->GetPrinter( true );
274 pTempPrinter
->SetPrinterSettingsPreferred( bPreferPrinterPapersize
);
278 else if ( aPropertyName
== SC_UNO_APPLYDOCINF
)
281 if ( aValue
>>= bTmp
)
282 pDocShell
->SetUseUserData( bTmp
);
284 else if ( aPropertyName
== SC_UNO_SAVE_THUMBNAIL
)
288 pDocShell
->SetUseThumbnailSave( bTmp
);
290 else if ( aPropertyName
== SC_UNO_FORBIDDEN
)
292 // read-only - should not be set
294 else if ( aPropertyName
== SC_UNO_CHARCOMP
)
296 // Int16 contains CharacterCompressionType values
297 sal_Int16 nUno
= ScUnoHelpFunctions::GetInt16FromAny( aValue
);
298 rDoc
.SetAsianCompression( static_cast<CharCompressType
>(nUno
) );
299 bUpdateHeights
= true;
301 else if ( aPropertyName
== SC_UNO_ASIANKERN
)
303 rDoc
.SetAsianKerning( ScUnoHelpFunctions::GetBoolFromAny( aValue
) );
304 bUpdateHeights
= true;
306 else if ( aPropertyName
== SCSAVEVERSION
)
309 if ( aValue
>>= bTmp
)
310 pDocShell
->SetSaveVersionOnClose( bTmp
);
312 else if ( aPropertyName
== SC_UNO_UPDTEMPL
)
315 if ( aValue
>>= bTmp
)
316 pDocShell
->SetQueryLoadTemplate( bTmp
);
318 else if ( aPropertyName
== SC_UNO_LOADREADONLY
)
321 if ( aValue
>>= bTmp
)
322 pDocShell
->SetLoadReadonly( bTmp
);
324 else if ( aPropertyName
== SC_UNO_SHAREDOC
)
326 #if HAVE_FEATURE_MULTIUSER_ENVIRONMENT
327 bool bDocShared
= false;
328 if ( aValue
>>= bDocShared
)
330 pDocShell
->SetSharedXMLFlag( bDocShared
);
334 else if ( aPropertyName
== SC_UNO_MODIFYPASSWORDINFO
)
336 uno::Sequence
< beans::PropertyValue
> aInfo
;
337 if ( !( aValue
>>= aInfo
) )
338 throw lang::IllegalArgumentException(
339 u
"Value of type Sequence<PropertyValue> expected!"_ustr
,
340 uno::Reference
< uno::XInterface
>(),
343 if ( !pDocShell
->SetModifyPasswordInfo( aInfo
) )
344 throw beans::PropertyVetoException(
345 u
"The hash is not allowed to be changed now!"_ustr
);
347 else if (aPropertyName
== SC_UNO_MODIFYPASSWORDHASH
)
350 if (!(aValue
>>= nHash
))
351 throw lang::IllegalArgumentException(u
"Value of type sal_Int32 expected!"_ustr
,
352 uno::Reference
<uno::XInterface
>(), 2);
354 if (!pDocShell
->SetModifyPasswordHash(nHash
))
355 throw beans::PropertyVetoException(u
"The hash is not allowed to be changed now!"_ustr
);
357 else if (aPropertyName
== SC_UNO_EMBED_FONTS
)
359 bool bVal
= aValue
.has
<bool>() && aValue
.get
<bool>();
360 rDoc
.SetEmbedFonts(bVal
);
362 else if (aPropertyName
== SC_UNO_EMBED_ONLY_USED_FONTS
)
364 bool bVal
= aValue
.has
<bool>() && aValue
.get
<bool>();
365 rDoc
.SetEmbedUsedFontsOnly(bVal
);
367 else if (aPropertyName
== SC_UNO_EMBED_FONT_SCRIPT_LATIN
)
369 bool bVal
= aValue
.has
<bool>() && aValue
.get
<bool>();
370 rDoc
.SetEmbedFontScriptLatin(bVal
);
372 else if (aPropertyName
== SC_UNO_EMBED_FONT_SCRIPT_ASIAN
)
374 bool bVal
= aValue
.has
<bool>() && aValue
.get
<bool>();
375 rDoc
.SetEmbedFontScriptAsian(bVal
);
377 else if (aPropertyName
== SC_UNO_EMBED_FONT_SCRIPT_COMPLEX
)
379 bool bVal
= aValue
.has
<bool>() && aValue
.get
<bool>();
380 rDoc
.SetEmbedFontScriptComplex(bVal
);
382 else if ( aPropertyName
== SC_UNO_SYNTAXSTRINGREF
)
384 ScCalcConfig aCalcConfig
= rDoc
.GetCalcConfig();
387 if( aValue
>>= nUno
)
392 case 2: // CONV_XL_A1
393 case 3: // CONV_XL_R1C1
394 case 7: // CONV_A1_XL_A1
395 aCalcConfig
.SetStringRefSyntax( static_cast<formula::FormulaGrammar::AddressConvention
>( nUno
) );
398 aCalcConfig
.SetStringRefSyntax( formula::FormulaGrammar::CONV_UNSPECIFIED
);
402 rDoc
.SetCalcConfig( aCalcConfig
);
405 else if (aPropertyName
== SC_UNO_IMAGE_PREFERRED_DPI
)
407 if (aValue
.has
<sal_Int32
>())
409 rDoc
.SetImagePreferredDPI(aValue
.get
<sal_Int32
>());
414 ScGridOptions
aGridOpt(aViewOpt
.GetGridOptions());
415 if ( aPropertyName
== SC_UNO_SNAPTORASTER
)
416 aGridOpt
.SetUseGridSnap( ScUnoHelpFunctions::GetBoolFromAny( aValue
) );
417 else if ( aPropertyName
== SC_UNO_RASTERVIS
)
418 aGridOpt
.SetGridVisible( ScUnoHelpFunctions::GetBoolFromAny( aValue
) );
419 else if ( aPropertyName
== SC_UNO_RASTERRESX
)
420 aGridOpt
.SetFieldDrawX( static_cast <sal_uInt32
> ( ScUnoHelpFunctions::GetInt32FromAny( aValue
) ) );
421 else if ( aPropertyName
== SC_UNO_RASTERRESY
)
422 aGridOpt
.SetFieldDrawY( static_cast <sal_uInt32
> ( ScUnoHelpFunctions::GetInt32FromAny( aValue
) ) );
423 else if ( aPropertyName
== SC_UNO_RASTERSUBX
)
424 aGridOpt
.SetFieldDivisionX( static_cast <sal_uInt32
> ( ScUnoHelpFunctions::GetInt32FromAny( aValue
) ) );
425 else if ( aPropertyName
== SC_UNO_RASTERSUBY
)
426 aGridOpt
.SetFieldDivisionY( static_cast <sal_uInt32
> ( ScUnoHelpFunctions::GetInt32FromAny( aValue
) ) );
427 else if ( aPropertyName
== SC_UNO_RASTERSYNC
)
428 aGridOpt
.SetSynchronize( ScUnoHelpFunctions::GetBoolFromAny( aValue
) );
430 throw beans::UnknownPropertyException(aPropertyName
);
431 aViewOpt
.SetGridOptions(aGridOpt
);
433 rDoc
.SetViewOptions(aViewOpt
);
435 if ( bUpdateHeights
&& !rDoc
.IsImportingXML() )
437 // update automatic row heights and repaint
438 SCTAB nTabCount
= rDoc
.GetTableCount();
439 for (SCTAB nTab
=0; nTab
<nTabCount
; nTab
++)
440 if ( !pDocShell
->AdjustRowHeight( 0, rDoc
.MaxRow(), nTab
) )
441 pDocShell
->PostPaint(ScRange(0, 0, nTab
, rDoc
.MaxCol(), rDoc
.MaxRow(), nTab
), PaintPartFlags::Grid
);
442 pDocShell
->SetDocumentModified();
447 uno::Any SAL_CALL
ScDocumentConfiguration::getPropertyValue( const OUString
& aPropertyName
)
449 SolarMutexGuard aGuard
;
453 throw uno::RuntimeException();
455 ScDocument
& rDoc
= pDocShell
->GetDocument();
456 const ScViewOptions
& aViewOpt
= rDoc
.GetViewOptions();
458 /*Stampit enable/disable print cancel */
459 if ( aPropertyName
== SC_UNO_ALLOWPRINTJOBCANCEL
)
460 aRet
<<= pDocShell
->Stamp_GetPrintCancelState();
461 /*Stampit enable/disable print cancel */
463 else if ( aPropertyName
== SC_UNO_SHOWZERO
)
464 aRet
<<= aViewOpt
.GetOption( VOPT_NULLVALS
);
465 else if ( aPropertyName
== SC_UNO_SHOWNOTES
)
466 aRet
<<= aViewOpt
.GetOption( VOPT_NOTES
);
467 else if ( aPropertyName
== SC_UNO_SHOWNOTEAUTHOR
)
468 aRet
<<= aViewOpt
.GetOption( VOPT_NOTEAUTHOR
);
469 else if ( aPropertyName
== SC_UNO_SHOWFORMULASMARKS
)
470 aRet
<<= aViewOpt
.GetOption( VOPT_FORMULAS_MARKS
);
471 else if ( aPropertyName
== SC_UNO_SHOWGRID
)
472 aRet
<<= aViewOpt
.GetOption( VOPT_GRID
);
473 else if ( aPropertyName
== SC_UNO_GRIDCOLOR
)
476 Color aColor
= aViewOpt
.GetGridColor(&aColorName
);
479 else if ( aPropertyName
== SC_UNO_SHOWPAGEBR
)
480 aRet
<<= aViewOpt
.GetOption( VOPT_PAGEBREAKS
);
481 else if ( aPropertyName
== SC_UNONAME_LINKUPD
)
484 switch (rDoc
.GetLinkMode())
487 nLUM
= css::document::LinkUpdateModes::AUTO
;
490 nLUM
= css::document::LinkUpdateModes::NEVER
;
493 nLUM
= css::document::LinkUpdateModes::MANUAL
;
497 nLUM
= css::document::LinkUpdateModes::GLOBAL_SETTING
;
502 else if ( aPropertyName
== SC_UNO_COLROWHDR
)
503 aRet
<<= aViewOpt
.GetOption( VOPT_HEADER
);
504 else if ( aPropertyName
== SC_UNO_SHEETTABS
)
505 aRet
<<= aViewOpt
.GetOption( VOPT_TABCONTROLS
);
506 else if ( aPropertyName
== SC_UNO_OUTLSYMB
)
507 aRet
<<= aViewOpt
.GetOption( VOPT_OUTLINER
);
508 else if ( aPropertyName
== SC_UNO_AUTOCALC
)
509 aRet
<<= rDoc
.GetAutoCalc();
510 else if ( aPropertyName
== SC_UNO_PRINTERNAME
)
512 // #i75610# don't create the printer, return empty string if no printer created yet
513 // (as in SwXDocumentSettings)
514 SfxPrinter
* pPrinter
= rDoc
.GetPrinter( false );
516 aRet
<<= pPrinter
->GetName();
520 else if ( aPropertyName
== SC_UNO_PRINTERSETUP
)
522 // #i75610# don't create the printer, return empty sequence if no printer created yet
523 // (as in SwXDocumentSettings)
524 SfxPrinter
* pPrinter
= rDoc
.GetPrinter( false );
527 SvMemoryStream aStream
;
528 pPrinter
->Store( aStream
);
529 aRet
<<= uno::Sequence
< sal_Int8
>( static_cast< const sal_Int8
* >( aStream
.GetData() ),
533 aRet
<<= uno::Sequence
<sal_Int8
>();
535 else if ( aPropertyName
== SC_UNO_PRINTERPAPER
)
537 SfxPrinter
*pTempPrinter
= pDocShell
->GetPrinter( false );
538 aRet
<<= pTempPrinter
&& pTempPrinter
->GetPrinterSettingsPreferred();
541 else if ( aPropertyName
== SC_UNO_APPLYDOCINF
)
542 aRet
<<= pDocShell
->IsUseUserData();
543 else if ( aPropertyName
== SC_UNO_SAVE_THUMBNAIL
)
544 aRet
<<= pDocShell
->IsUseThumbnailSave();
545 else if ( aPropertyName
== SC_UNO_FORBIDDEN
)
547 aRet
<<= uno::Reference
<i18n::XForbiddenCharacters
>(new ScForbiddenCharsObj( pDocShell
));
549 else if ( aPropertyName
== SC_UNO_CHARCOMP
)
550 aRet
<<= static_cast<sal_Int16
> ( rDoc
.GetAsianCompression() );
551 else if ( aPropertyName
== SC_UNO_ASIANKERN
)
552 aRet
<<= rDoc
.GetAsianKerning();
553 else if ( aPropertyName
== SCSAVEVERSION
)
554 aRet
<<= pDocShell
->IsSaveVersionOnClose();
555 else if ( aPropertyName
== SC_UNO_UPDTEMPL
)
556 aRet
<<= pDocShell
->IsQueryLoadTemplate();
557 else if ( aPropertyName
== SC_UNO_LOADREADONLY
)
558 aRet
<<= pDocShell
->IsLoadReadonly();
559 else if ( aPropertyName
== SC_UNO_SHAREDOC
)
561 #if HAVE_FEATURE_MULTIUSER_ENVIRONMENT
562 aRet
<<= pDocShell
->HasSharedXMLFlagSet();
565 else if ( aPropertyName
== SC_UNO_MODIFYPASSWORDINFO
)
566 aRet
<<= pDocShell
->GetModifyPasswordInfo();
567 else if (aPropertyName
== SC_UNO_MODIFYPASSWORDHASH
)
568 aRet
<<= pDocShell
->GetModifyPasswordHash();
569 else if (aPropertyName
== SC_UNO_EMBED_FONTS
)
570 aRet
<<= rDoc
.IsEmbedFonts();
571 else if (aPropertyName
== SC_UNO_EMBED_ONLY_USED_FONTS
)
572 aRet
<<= rDoc
.IsEmbedUsedFontsOnly();
573 else if (aPropertyName
== SC_UNO_EMBED_FONT_SCRIPT_LATIN
)
574 aRet
<<= rDoc
.IsEmbedFontScriptLatin();
575 else if (aPropertyName
== SC_UNO_EMBED_FONT_SCRIPT_ASIAN
)
576 aRet
<<= rDoc
.IsEmbedFontScriptAsian();
577 else if (aPropertyName
== SC_UNO_EMBED_FONT_SCRIPT_COMPLEX
)
578 aRet
<<= rDoc
.IsEmbedFontScriptComplex();
579 else if ( aPropertyName
== SC_UNO_SYNTAXSTRINGREF
)
581 ScCalcConfig aCalcConfig
= rDoc
.GetCalcConfig();
582 formula::FormulaGrammar::AddressConvention eConv
= aCalcConfig
.meStringRefAddressSyntax
;
584 // don't save "unspecified" string ref syntax ... query formula grammar
585 // and save that instead
586 if( eConv
== formula::FormulaGrammar::CONV_UNSPECIFIED
)
588 eConv
= rDoc
.GetAddressConvention();
591 // write if it has been read|imported or explicitly changed
592 // or if ref syntax isn't what would be native for our file format
593 // i.e. CalcA1 in this case
594 if ( aCalcConfig
.mbHasStringRefSyntax
||
595 (eConv
!= formula::FormulaGrammar::CONV_OOO
) )
599 case formula::FormulaGrammar::CONV_OOO
:
600 case formula::FormulaGrammar::CONV_XL_A1
:
601 case formula::FormulaGrammar::CONV_XL_R1C1
:
602 case formula::FormulaGrammar::CONV_A1_XL_A1
:
603 aRet
<<= static_cast<sal_Int16
>( eConv
);
606 case formula::FormulaGrammar::CONV_UNSPECIFIED
:
607 case formula::FormulaGrammar::CONV_ODF
:
608 case formula::FormulaGrammar::CONV_XL_OOX
:
609 case formula::FormulaGrammar::CONV_LOTUS_A1
:
610 case formula::FormulaGrammar::CONV_LAST
:
612 aRet
<<= sal_Int16(9999);
618 else if (aPropertyName
== SC_UNO_IMAGE_PREFERRED_DPI
)
620 aRet
<<= rDoc
.GetImagePreferredDPI();
624 const ScGridOptions
& aGridOpt
= aViewOpt
.GetGridOptions();
625 if ( aPropertyName
== SC_UNO_SNAPTORASTER
)
626 aRet
<<= aGridOpt
.GetUseGridSnap();
627 else if ( aPropertyName
== SC_UNO_RASTERVIS
)
628 aRet
<<= aGridOpt
.GetGridVisible();
629 else if ( aPropertyName
== SC_UNO_RASTERRESX
)
630 aRet
<<= static_cast<sal_Int32
> ( aGridOpt
.GetFieldDrawX() );
631 else if ( aPropertyName
== SC_UNO_RASTERRESY
)
632 aRet
<<= static_cast<sal_Int32
> ( aGridOpt
.GetFieldDrawY() );
633 else if ( aPropertyName
== SC_UNO_RASTERSUBX
)
634 aRet
<<= static_cast<sal_Int32
> ( aGridOpt
.GetFieldDivisionX() );
635 else if ( aPropertyName
== SC_UNO_RASTERSUBY
)
636 aRet
<<= static_cast<sal_Int32
> ( aGridOpt
.GetFieldDivisionY() );
637 else if ( aPropertyName
== SC_UNO_RASTERSYNC
)
638 aRet
<<= aGridOpt
.GetSynchronize();
640 throw beans::UnknownPropertyException(aPropertyName
);
647 SC_IMPL_DUMMY_PROPERTY_LISTENER( ScDocumentConfiguration
)
650 OUString SAL_CALL
ScDocumentConfiguration::getImplementationName()
652 return u
"ScDocumentConfiguration"_ustr
;
655 sal_Bool SAL_CALL
ScDocumentConfiguration::supportsService( const OUString
& rServiceName
)
657 return cppu::supportsService(this, rServiceName
);
660 uno::Sequence
<OUString
> SAL_CALL
ScDocumentConfiguration::getSupportedServiceNames()
662 return {u
"com.sun.star.comp.SpreadsheetSettings"_ustr
,
663 u
"com.sun.star.document.Settings"_ustr
};
666 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */