/src/libreoffice/sc/source/ui/unoobj/confuno.cxx
Line | Count | Source |
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 <utility> |
23 | | |
24 | | #include <config_features.h> |
25 | | |
26 | | #include <confuno.hxx> |
27 | | #include <unonames.hxx> |
28 | | #include <docsh.hxx> |
29 | | #include <miscuno.hxx> |
30 | | #include <forbiuno.hxx> |
31 | | #include <appoptio.hxx> |
32 | | #include <viewopti.hxx> |
33 | | #include <docpool.hxx> |
34 | | #include <sc.hrc> |
35 | | #include <scmod.hxx> |
36 | | |
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> |
45 | | |
46 | | using namespace com::sun::star; |
47 | | |
48 | | constexpr OUString SCSAVEVERSION = u"SaveVersionOnClose"_ustr; |
49 | | |
50 | | static std::span<const SfxItemPropertyMapEntry> lcl_GetConfigPropertyMap() |
51 | 798 | { |
52 | 798 | static const SfxItemPropertyMapEntry aConfigPropertyMap_Impl[] = |
53 | 798 | { |
54 | 798 | { SC_UNO_SHOWZERO, 0, cppu::UnoType<bool>::get(), 0, 0}, |
55 | 798 | { SC_UNO_SHOWNOTES, 0, cppu::UnoType<bool>::get(), 0, 0}, |
56 | 798 | { SC_UNO_SHOWNOTEAUTHOR, 0, cppu::UnoType<bool>::get(), 0, 0}, |
57 | 798 | { SC_UNO_SHOWFORMULASMARKS, 0, cppu::UnoType<bool>::get(), 0, 0}, |
58 | 798 | { SC_UNO_SHOWGRID, 0, cppu::UnoType<bool>::get(), 0, 0}, |
59 | 798 | { SC_UNO_GRIDCOLOR, 0, cppu::UnoType<sal_Int32>::get(), 0, 0}, |
60 | 798 | { SC_UNO_SHOWPAGEBR, 0, cppu::UnoType<bool>::get(), 0, 0}, |
61 | 798 | { SC_UNONAME_LINKUPD, 0, cppu::UnoType<sal_Int16>::get(), 0, 0}, |
62 | 798 | { SC_UNO_COLROWHDR, 0, cppu::UnoType<bool>::get(), 0, 0}, |
63 | 798 | { SC_UNO_SHEETTABS, 0, cppu::UnoType<bool>::get(), 0, 0}, |
64 | 798 | { SC_UNO_OUTLSYMB, 0, cppu::UnoType<bool>::get(), 0, 0}, |
65 | 798 | { SC_UNO_SNAPTORASTER, 0, cppu::UnoType<bool>::get(), 0, 0}, |
66 | 798 | { SC_UNO_RASTERVIS, 0, cppu::UnoType<bool>::get(), 0, 0}, |
67 | 798 | { SC_UNO_RASTERRESX, 0, cppu::UnoType<sal_Int32>::get(), 0, 0}, |
68 | 798 | { SC_UNO_RASTERRESY, 0, cppu::UnoType<sal_Int32>::get(), 0, 0}, |
69 | 798 | { SC_UNO_RASTERSUBX, 0, cppu::UnoType<sal_Int32>::get(), 0, 0}, |
70 | 798 | { SC_UNO_RASTERSUBY, 0, cppu::UnoType<sal_Int32>::get(), 0, 0}, |
71 | 798 | { SC_UNO_RASTERSYNC, 0, cppu::UnoType<bool>::get(), 0, 0}, |
72 | 798 | { SC_UNO_AUTOCALC, 0, cppu::UnoType<bool>::get(), 0, 0}, |
73 | 798 | { SC_UNO_PRINTERNAME, 0, cppu::UnoType<OUString>::get(), 0, 0}, |
74 | 798 | { SC_UNO_PRINTERSETUP, 0, cppu::UnoType<uno::Sequence<sal_Int8>>::get(), 0, 0}, |
75 | 798 | { SC_UNO_PRINTERPAPER, 0, cppu::UnoType<bool>::get(), 0, 0}, |
76 | 798 | { SC_UNO_APPLYDOCINF, 0, cppu::UnoType<bool>::get(), 0, 0 }, |
77 | 798 | { SC_UNO_SAVE_THUMBNAIL, 0, cppu::UnoType<bool>::get(), 0, 0 }, |
78 | 798 | { SC_UNO_FORBIDDEN, 0, cppu::UnoType<i18n::XForbiddenCharacters>::get(), beans::PropertyAttribute::READONLY, 0}, |
79 | 798 | { SC_UNO_CHARCOMP, 0, cppu::UnoType<sal_Int16>::get(), 0, 0}, |
80 | 798 | { SC_UNO_ASIANKERN, 0, cppu::UnoType<bool>::get(), 0, 0}, |
81 | 798 | { SCSAVEVERSION, 0, cppu::UnoType<bool>::get(), 0, 0}, |
82 | 798 | { SC_UNO_UPDTEMPL, 0, cppu::UnoType<bool>::get(), 0, 0}, |
83 | | /*Stampit enable/disable print cancel */ |
84 | 798 | { SC_UNO_ALLOWPRINTJOBCANCEL, 0, cppu::UnoType<bool>::get(), 0, 0}, |
85 | 798 | { SC_UNO_LOADREADONLY, 0, cppu::UnoType<bool>::get(), 0, 0}, |
86 | 798 | { SC_UNO_SHAREDOC, 0, cppu::UnoType<bool>::get(), 0, 0}, |
87 | 798 | { SC_UNO_MODIFYPASSWORDINFO, 0, cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get(), 0, 0}, |
88 | 798 | { SC_UNO_MODIFYPASSWORDHASH, 0, cppu::UnoType<sal_Int32>::get(), 0, 0}, |
89 | 798 | { SC_UNO_EMBED_FONTS, 0, cppu::UnoType<bool>::get(), 0, 0}, |
90 | 798 | { SC_UNO_EMBED_ONLY_USED_FONTS, 0, cppu::UnoType<bool>::get(), 0, 0}, |
91 | 798 | { SC_UNO_EMBED_FONT_SCRIPT_LATIN, 0, cppu::UnoType<bool>::get(), 0, 0}, |
92 | 798 | { SC_UNO_EMBED_FONT_SCRIPT_ASIAN, 0, cppu::UnoType<bool>::get(), 0, 0}, |
93 | 798 | { SC_UNO_EMBED_FONT_SCRIPT_COMPLEX, 0, cppu::UnoType<bool>::get(), 0, 0}, |
94 | 798 | { SC_UNO_IMAGE_PREFERRED_DPI, 0, cppu::UnoType<sal_Int32>::get(), 0, 0}, |
95 | 798 | { SC_UNO_SYNTAXSTRINGREF, 0, cppu::UnoType<sal_Int16>::get(), 0, 0}, |
96 | 798 | }; |
97 | 798 | return aConfigPropertyMap_Impl; |
98 | 798 | } |
99 | | |
100 | | ScDocumentConfiguration::ScDocumentConfiguration(ScDocShell* pDocSh) |
101 | 798 | : pDocShell(pDocSh) , |
102 | 798 | aPropSet ( lcl_GetConfigPropertyMap() ) |
103 | 798 | { |
104 | 798 | pDocShell->GetDocument().AddUnoObject(*this); |
105 | 798 | } |
106 | | |
107 | | ScDocumentConfiguration::~ScDocumentConfiguration() |
108 | 798 | { |
109 | 798 | SolarMutexGuard g; |
110 | | |
111 | 798 | if (pDocShell) |
112 | 798 | pDocShell->GetDocument().RemoveUnoObject(*this); |
113 | 798 | } |
114 | | |
115 | | void ScDocumentConfiguration::Notify( SfxBroadcaster&, const SfxHint& rHint ) |
116 | 0 | { |
117 | | // reference update does not matter here |
118 | |
|
119 | 0 | if ( rHint.GetId() == SfxHintId::Dying ) |
120 | 0 | { |
121 | 0 | pDocShell = nullptr; |
122 | 0 | } |
123 | 0 | } |
124 | | |
125 | | // XPropertySet |
126 | | |
127 | | uno::Reference<beans::XPropertySetInfo> SAL_CALL ScDocumentConfiguration::getPropertySetInfo() |
128 | 798 | { |
129 | 798 | SolarMutexGuard aGuard; |
130 | 798 | static uno::Reference<beans::XPropertySetInfo> aRef( |
131 | 798 | new SfxItemPropertySetInfo( aPropSet.getPropertyMap() )); |
132 | 798 | return aRef; |
133 | 798 | } |
134 | | |
135 | | void SAL_CALL ScDocumentConfiguration::setPropertyValue( |
136 | | const OUString& aPropertyName, const uno::Any& aValue ) |
137 | 11.9k | { |
138 | 11.9k | SolarMutexGuard aGuard; |
139 | | |
140 | 11.9k | if(!pDocShell) |
141 | 0 | throw uno::RuntimeException(); |
142 | | |
143 | 11.9k | ScDocument& rDoc = pDocShell->GetDocument(); |
144 | 11.9k | bool bUpdateHeights = false; |
145 | | |
146 | 11.9k | ScViewOptions aViewOpt(rDoc.GetViewOptions()); |
147 | | |
148 | | /*Stampit enable/disable print cancel */ |
149 | 11.9k | if ( aPropertyName == SC_UNO_ALLOWPRINTJOBCANCEL ) |
150 | 450 | pDocShell->Stamp_SetPrintCancelState( ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); |
151 | | /*Stampit enable/disable print cancel */ |
152 | | |
153 | 11.5k | else if ( aPropertyName == SC_UNO_SHOWZERO ) |
154 | 409 | aViewOpt.SetOption(sc::ViewOption::NULLVALS, ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); |
155 | 11.1k | else if ( aPropertyName == SC_UNO_SHOWNOTES ) |
156 | 393 | aViewOpt.SetOption(sc::ViewOption::NOTES, ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); |
157 | 10.7k | else if ( aPropertyName == SC_UNO_SHOWNOTEAUTHOR ) |
158 | 0 | aViewOpt.SetOption(sc::ViewOption::NOTEAUTHOR, ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); |
159 | 10.7k | else if ( aPropertyName == SC_UNO_SHOWFORMULASMARKS ) |
160 | 0 | aViewOpt.SetOption(sc::ViewOption::FORMULAS_MARKS, ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); |
161 | 10.7k | else if ( aPropertyName == SC_UNO_SHOWGRID ) |
162 | 392 | aViewOpt.SetOption(sc::ViewOption::GRID, ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); |
163 | 10.3k | else if ( aPropertyName == SC_UNO_GRIDCOLOR ) |
164 | 453 | { |
165 | 453 | Color aColor; |
166 | 453 | if (aValue >>= aColor) |
167 | 1 | aViewOpt.SetGridColor(aColor, OUString()); |
168 | 453 | } |
169 | 9.86k | else if ( aPropertyName == SC_UNO_SHOWPAGEBR ) |
170 | 381 | aViewOpt.SetOption(sc::ViewOption::PAGEBREAKS, ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); |
171 | 9.48k | else if ( aPropertyName == SC_UNONAME_LINKUPD ) |
172 | 0 | { |
173 | | // XXX NOTE: this is the css::document::Settings property |
174 | | // LinkUpdateMode, not the css::sheet::XGlobalSheetSettings |
175 | | // attribute LinkUpdateMode. |
176 | 0 | sal_Int16 n; |
177 | 0 | if (!(aValue >>= n) || n < css::document::LinkUpdateModes::NEVER || |
178 | 0 | n > css::document::LinkUpdateModes::GLOBAL_SETTING) |
179 | 0 | { |
180 | 0 | throw css::lang::IllegalArgumentException( |
181 | 0 | (u"LinkUpdateMode property value must be a SHORT with a value in" |
182 | 0 | " the range of the css::document::LinkUpdateModes constants"_ustr), |
183 | 0 | css::uno::Reference<css::uno::XInterface>(), -1); |
184 | 0 | } |
185 | 0 | ScLkUpdMode eMode; |
186 | 0 | switch (n) |
187 | 0 | { |
188 | 0 | case css::document::LinkUpdateModes::NEVER: |
189 | 0 | eMode = LM_NEVER; |
190 | 0 | break; |
191 | 0 | case css::document::LinkUpdateModes::MANUAL: |
192 | 0 | eMode = LM_ON_DEMAND; |
193 | 0 | break; |
194 | 0 | case css::document::LinkUpdateModes::AUTO: |
195 | 0 | eMode = LM_ALWAYS; |
196 | 0 | break; |
197 | 0 | case css::document::LinkUpdateModes::GLOBAL_SETTING: |
198 | 0 | default: |
199 | 0 | eMode = ScModule::get()->GetAppOptions().GetLinkMode(); |
200 | 0 | break; |
201 | 0 | } |
202 | 0 | rDoc.SetLinkMode( eMode ); |
203 | 0 | } |
204 | 9.48k | else if ( aPropertyName == SC_UNO_COLROWHDR ) |
205 | 456 | aViewOpt.SetOption(sc::ViewOption::HEADER, ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); |
206 | 9.02k | else if ( aPropertyName == SC_UNO_SHEETTABS ) |
207 | 385 | aViewOpt.SetOption(sc::ViewOption::TABCONTROLS, ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); |
208 | 8.64k | else if ( aPropertyName == SC_UNO_OUTLSYMB ) |
209 | 379 | aViewOpt.SetOption(sc::ViewOption::OUTLINER, ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); |
210 | 8.26k | else if ( aPropertyName == SC_UNO_AUTOCALC ) |
211 | 381 | rDoc.SetAutoCalc( ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); |
212 | 7.88k | else if ( aPropertyName == SC_UNO_PRINTERNAME ) |
213 | 431 | { |
214 | 431 | OUString sPrinterName; |
215 | 431 | if ( !(aValue >>= sPrinterName) ) |
216 | 9 | throw lang::IllegalArgumentException(); |
217 | | |
218 | | // #i75610# if the name is empty, do nothing (don't create any printer) |
219 | 422 | if ( !sPrinterName.isEmpty() && pDocShell->GetCreateMode() != SfxObjectCreateMode::EMBEDDED ) |
220 | 0 | { |
221 | 0 | SfxPrinter* pPrinter = pDocShell->GetPrinter(); |
222 | 0 | if (!pPrinter) |
223 | 0 | throw uno::RuntimeException(); |
224 | | |
225 | 0 | if (pPrinter->GetName() != sPrinterName) |
226 | 0 | { |
227 | 0 | VclPtrInstance<SfxPrinter> pNewPrinter( pPrinter->GetOptions().Clone(), sPrinterName ); |
228 | 0 | if (pNewPrinter->IsKnown()) |
229 | 0 | pDocShell->SetPrinter( pNewPrinter, SfxPrinterChangeFlags::PRINTER ); |
230 | 0 | else |
231 | 0 | pNewPrinter.disposeAndClear(); |
232 | 0 | } |
233 | |
|
234 | 0 | } |
235 | | |
236 | 422 | } |
237 | 7.45k | else if ( aPropertyName == SC_UNO_PRINTERSETUP ) |
238 | 870 | { |
239 | 870 | uno::Sequence<sal_Int8> aSequence; |
240 | 870 | if ( aValue >>= aSequence ) |
241 | 845 | { |
242 | 845 | sal_uInt32 nSize = aSequence.getLength(); |
243 | | // #i75610# if the sequence is empty, do nothing (don't create any printer) |
244 | 845 | if ( nSize != 0 ) |
245 | 695 | { |
246 | 695 | SvMemoryStream aStream (aSequence.getArray(), nSize, StreamMode::READ ); |
247 | 695 | aStream.Seek ( STREAM_SEEK_TO_BEGIN ); |
248 | 695 | auto pSet = std::make_unique<SfxItemSetFixed |
249 | 695 | <SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN, |
250 | 695 | SID_PRINTER_CHANGESTODOC, SID_PRINTER_CHANGESTODOC, |
251 | 695 | SID_PRINT_SELECTEDSHEET, SID_PRINT_SELECTEDSHEET, |
252 | 695 | SID_SCPRINTOPTIONS, SID_SCPRINTOPTIONS>>( *rDoc.GetPool()); |
253 | | |
254 | 695 | SfxPrinter* pPrinter = pDocShell->GetPrinter(); |
255 | 695 | bool bPreferPrinterPapersize = false; |
256 | 695 | if ( pPrinter ) |
257 | 695 | bPreferPrinterPapersize = pPrinter->GetPrinterSettingsPreferred(); |
258 | | |
259 | 695 | VclPtr<SfxPrinter> pTempPrinter = SfxPrinter::Create( aStream, std::move(pSet) ); |
260 | 695 | pTempPrinter->SetPrinterSettingsPreferred( bPreferPrinterPapersize ); |
261 | 695 | pDocShell->SetPrinter( pTempPrinter ); |
262 | 695 | } |
263 | 845 | } |
264 | 870 | } |
265 | 6.58k | else if ( aPropertyName == SC_UNO_PRINTERPAPER ) |
266 | 0 | { |
267 | 0 | bool bPreferPrinterPapersize; |
268 | 0 | if( aValue >>= bPreferPrinterPapersize ) |
269 | 0 | { |
270 | 0 | if( pDocShell->GetCreateMode() != SfxObjectCreateMode::EMBEDDED ) |
271 | 0 | { |
272 | 0 | SfxPrinter *pTempPrinter = pDocShell->GetPrinter( true ); |
273 | 0 | if (pTempPrinter) |
274 | 0 | pTempPrinter->SetPrinterSettingsPreferred( bPreferPrinterPapersize ); |
275 | 0 | } |
276 | 0 | } |
277 | 0 | } |
278 | 6.58k | else if ( aPropertyName == SC_UNO_APPLYDOCINF ) |
279 | 412 | { |
280 | 412 | bool bTmp=true; |
281 | 412 | if ( aValue >>= bTmp ) |
282 | 410 | pDocShell->SetUseUserData( bTmp ); |
283 | 412 | } |
284 | 6.17k | else if ( aPropertyName == SC_UNO_SAVE_THUMBNAIL) |
285 | 0 | { |
286 | 0 | bool bTmp = true; |
287 | 0 | if (aValue >>= bTmp) |
288 | 0 | pDocShell->SetUseThumbnailSave( bTmp ); |
289 | 0 | } |
290 | 6.17k | else if ( aPropertyName == SC_UNO_FORBIDDEN ) |
291 | 195 | { |
292 | | // read-only - should not be set |
293 | 195 | } |
294 | 5.97k | else if ( aPropertyName == SC_UNO_CHARCOMP ) |
295 | 432 | { |
296 | | // Int16 contains CharacterCompressionType values |
297 | 432 | sal_Int16 nUno = ScUnoHelpFunctions::GetInt16FromAny( aValue ); |
298 | 432 | rDoc.SetAsianCompression( static_cast<CharCompressType>(nUno) ); |
299 | 432 | bUpdateHeights = true; |
300 | 432 | } |
301 | 5.54k | else if ( aPropertyName == SC_UNO_ASIANKERN ) |
302 | 447 | { |
303 | 447 | rDoc.SetAsianKerning( ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); |
304 | 447 | bUpdateHeights = true; |
305 | 447 | } |
306 | 5.09k | else if ( aPropertyName == SCSAVEVERSION ) |
307 | 435 | { |
308 | 435 | bool bTmp=false; |
309 | 435 | if ( aValue >>= bTmp ) |
310 | 435 | pDocShell->SetSaveVersionOnClose( bTmp ); |
311 | 435 | } |
312 | 4.66k | else if ( aPropertyName == SC_UNO_UPDTEMPL ) |
313 | 639 | { |
314 | 639 | bool bTmp=true; |
315 | 639 | if ( aValue >>= bTmp ) |
316 | 629 | pDocShell->SetQueryLoadTemplate( bTmp ); |
317 | 639 | } |
318 | 4.02k | else if ( aPropertyName == SC_UNO_LOADREADONLY ) |
319 | 506 | { |
320 | 506 | bool bTmp=false; |
321 | 506 | if ( aValue >>= bTmp ) |
322 | 498 | pDocShell->SetLoadReadonly( bTmp ); |
323 | 506 | } |
324 | 3.51k | else if ( aPropertyName == SC_UNO_SHAREDOC ) |
325 | 376 | { |
326 | | #if HAVE_FEATURE_MULTIUSER_ENVIRONMENT |
327 | | bool bDocShared = false; |
328 | | if ( aValue >>= bDocShared ) |
329 | | { |
330 | | pDocShell->SetSharedXMLFlag( bDocShared ); |
331 | | } |
332 | | #endif |
333 | 376 | } |
334 | 3.14k | else if ( aPropertyName == SC_UNO_MODIFYPASSWORDINFO ) |
335 | 0 | { |
336 | 0 | uno::Sequence< beans::PropertyValue > aInfo; |
337 | 0 | if ( !( aValue >>= aInfo ) ) |
338 | 0 | throw lang::IllegalArgumentException( |
339 | 0 | u"Value of type Sequence<PropertyValue> expected!"_ustr, |
340 | 0 | uno::Reference< uno::XInterface >(), |
341 | 0 | 2 ); |
342 | | |
343 | 0 | if ( !pDocShell->SetModifyPasswordInfo( aInfo ) ) |
344 | 0 | throw beans::PropertyVetoException( |
345 | 0 | u"The hash is not allowed to be changed now!"_ustr ); |
346 | 0 | } |
347 | 3.14k | else if (aPropertyName == SC_UNO_MODIFYPASSWORDHASH) |
348 | 0 | { |
349 | 0 | sal_Int32 nHash; |
350 | 0 | if (!(aValue >>= nHash)) |
351 | 0 | throw lang::IllegalArgumentException(u"Value of type sal_Int32 expected!"_ustr, |
352 | 0 | uno::Reference<uno::XInterface>(), 2); |
353 | | |
354 | 0 | if (!pDocShell->SetModifyPasswordHash(nHash)) |
355 | 0 | throw beans::PropertyVetoException(u"The hash is not allowed to be changed now!"_ustr); |
356 | 0 | } |
357 | 3.14k | else if (aPropertyName == SC_UNO_EMBED_FONTS) |
358 | 174 | { |
359 | 174 | bool bVal = aValue.has<bool>() && aValue.get<bool>(); |
360 | 174 | rDoc.SetEmbedFonts(bVal); |
361 | 174 | } |
362 | 2.96k | else if (aPropertyName == SC_UNO_EMBED_ONLY_USED_FONTS) |
363 | 0 | { |
364 | 0 | bool bVal = aValue.has<bool>() && aValue.get<bool>(); |
365 | 0 | rDoc.SetEmbedUsedFontsOnly(bVal); |
366 | 0 | } |
367 | 2.96k | else if (aPropertyName == SC_UNO_EMBED_FONT_SCRIPT_LATIN) |
368 | 0 | { |
369 | 0 | bool bVal = aValue.has<bool>() && aValue.get<bool>(); |
370 | 0 | rDoc.SetEmbedFontScriptLatin(bVal); |
371 | 0 | } |
372 | 2.96k | else if (aPropertyName == SC_UNO_EMBED_FONT_SCRIPT_ASIAN) |
373 | 0 | { |
374 | 0 | bool bVal = aValue.has<bool>() && aValue.get<bool>(); |
375 | 0 | rDoc.SetEmbedFontScriptAsian(bVal); |
376 | 0 | } |
377 | 2.96k | else if (aPropertyName == SC_UNO_EMBED_FONT_SCRIPT_COMPLEX) |
378 | 0 | { |
379 | 0 | bool bVal = aValue.has<bool>() && aValue.get<bool>(); |
380 | 0 | rDoc.SetEmbedFontScriptComplex(bVal); |
381 | 0 | } |
382 | 2.96k | else if ( aPropertyName == SC_UNO_SYNTAXSTRINGREF ) |
383 | 0 | { |
384 | 0 | ScCalcConfig aCalcConfig = rDoc.GetCalcConfig(); |
385 | 0 | sal_Int16 nUno = 0; |
386 | |
|
387 | 0 | if( aValue >>= nUno ) |
388 | 0 | { |
389 | 0 | switch (nUno) |
390 | 0 | { |
391 | 0 | case 0: // CONV_OOO |
392 | 0 | case 2: // CONV_XL_A1 |
393 | 0 | case 3: // CONV_XL_R1C1 |
394 | 0 | case 7: // CONV_A1_XL_A1 |
395 | 0 | aCalcConfig.SetStringRefSyntax( static_cast<formula::FormulaGrammar::AddressConvention>( nUno ) ); |
396 | 0 | break; |
397 | 0 | default: |
398 | 0 | aCalcConfig.SetStringRefSyntax( formula::FormulaGrammar::CONV_UNSPECIFIED ); |
399 | 0 | break; |
400 | |
|
401 | 0 | } |
402 | 0 | rDoc.SetCalcConfig( aCalcConfig ); |
403 | 0 | } |
404 | 0 | } |
405 | 2.96k | else if (aPropertyName == SC_UNO_IMAGE_PREFERRED_DPI) |
406 | 0 | { |
407 | 0 | if (aValue.has<sal_Int32>()) |
408 | 0 | { |
409 | 0 | rDoc.SetImagePreferredDPI(aValue.get<sal_Int32>()); |
410 | 0 | } |
411 | 0 | } |
412 | 2.96k | else |
413 | 2.96k | { |
414 | 2.96k | ScGridOptions aGridOpt(aViewOpt.GetGridOptions()); |
415 | 2.96k | if ( aPropertyName == SC_UNO_SNAPTORASTER ) |
416 | 453 | aGridOpt.SetUseGridSnap( ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); |
417 | 2.51k | else if ( aPropertyName == SC_UNO_RASTERVIS ) |
418 | 386 | aGridOpt.SetGridVisible( ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); |
419 | 2.12k | else if ( aPropertyName == SC_UNO_RASTERRESX ) |
420 | 380 | aGridOpt.SetFieldDrawX( static_cast <sal_uInt32> ( ScUnoHelpFunctions::GetInt32FromAny( aValue ) ) ); |
421 | 1.74k | else if ( aPropertyName == SC_UNO_RASTERRESY ) |
422 | 383 | aGridOpt.SetFieldDrawY( static_cast <sal_uInt32> ( ScUnoHelpFunctions::GetInt32FromAny( aValue ) ) ); |
423 | 1.36k | else if ( aPropertyName == SC_UNO_RASTERSUBX ) |
424 | 498 | aGridOpt.SetFieldDivisionX( static_cast <sal_uInt32> ( ScUnoHelpFunctions::GetInt32FromAny( aValue ) ) ); |
425 | 867 | else if ( aPropertyName == SC_UNO_RASTERSUBY ) |
426 | 467 | aGridOpt.SetFieldDivisionY( static_cast <sal_uInt32> ( ScUnoHelpFunctions::GetInt32FromAny( aValue ) ) ); |
427 | 400 | else if ( aPropertyName == SC_UNO_RASTERSYNC ) |
428 | 400 | aGridOpt.SetSynchronize( ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); |
429 | 0 | else |
430 | 0 | throw beans::UnknownPropertyException(aPropertyName); |
431 | 2.96k | aViewOpt.SetGridOptions(aGridOpt); |
432 | 2.96k | } |
433 | 11.9k | rDoc.SetViewOptions(aViewOpt); |
434 | | |
435 | 11.9k | if ( bUpdateHeights && !rDoc.IsImportingXML() ) |
436 | 0 | { |
437 | | // update automatic row heights and repaint |
438 | 0 | SCTAB nTabCount = rDoc.GetTableCount(); |
439 | 0 | for (SCTAB nTab=0; nTab<nTabCount; nTab++) |
440 | 0 | if ( !pDocShell->AdjustRowHeight( 0, rDoc.MaxRow(), nTab ) ) |
441 | 0 | pDocShell->PostPaint(ScRange(0, 0, nTab, rDoc.MaxCol(), rDoc.MaxRow(), nTab), PaintPartFlags::Grid); |
442 | 0 | pDocShell->SetDocumentModified(); |
443 | 0 | } |
444 | | |
445 | 11.9k | } |
446 | | |
447 | | uno::Any SAL_CALL ScDocumentConfiguration::getPropertyValue( const OUString& aPropertyName ) |
448 | 215 | { |
449 | 215 | SolarMutexGuard aGuard; |
450 | 215 | uno::Any aRet; |
451 | | |
452 | 215 | if(!pDocShell) |
453 | 0 | throw uno::RuntimeException(); |
454 | | |
455 | 215 | ScDocument& rDoc = pDocShell->GetDocument(); |
456 | 215 | const ScViewOptions& aViewOpt = rDoc.GetViewOptions(); |
457 | | |
458 | | /*Stampit enable/disable print cancel */ |
459 | 215 | if ( aPropertyName == SC_UNO_ALLOWPRINTJOBCANCEL ) |
460 | 0 | aRet <<= pDocShell->Stamp_GetPrintCancelState(); |
461 | | /*Stampit enable/disable print cancel */ |
462 | | |
463 | 215 | else if ( aPropertyName == SC_UNO_SHOWZERO ) |
464 | 0 | aRet <<= aViewOpt.GetOption(sc::ViewOption::NULLVALS); |
465 | 215 | else if ( aPropertyName == SC_UNO_SHOWNOTES ) |
466 | 0 | aRet <<= aViewOpt.GetOption(sc::ViewOption::NOTES); |
467 | 215 | else if ( aPropertyName == SC_UNO_SHOWNOTEAUTHOR ) |
468 | 0 | aRet <<= aViewOpt.GetOption(sc::ViewOption::NOTEAUTHOR); |
469 | 215 | else if ( aPropertyName == SC_UNO_SHOWFORMULASMARKS ) |
470 | 0 | aRet <<= aViewOpt.GetOption(sc::ViewOption::FORMULAS_MARKS); |
471 | 215 | else if ( aPropertyName == SC_UNO_SHOWGRID ) |
472 | 0 | aRet <<= aViewOpt.GetOption(sc::ViewOption::GRID); |
473 | 215 | else if ( aPropertyName == SC_UNO_GRIDCOLOR ) |
474 | 0 | { |
475 | 0 | OUString aColorName; |
476 | 0 | Color aColor = aViewOpt.GetGridColor(&aColorName); |
477 | 0 | aRet <<= aColor; |
478 | 0 | } |
479 | 215 | else if ( aPropertyName == SC_UNO_SHOWPAGEBR ) |
480 | 0 | aRet <<= aViewOpt.GetOption(sc::ViewOption::PAGEBREAKS); |
481 | 215 | else if ( aPropertyName == SC_UNONAME_LINKUPD ) |
482 | 0 | { |
483 | 0 | sal_Int16 nLUM; |
484 | 0 | switch (rDoc.GetLinkMode()) |
485 | 0 | { |
486 | 0 | case LM_ALWAYS: |
487 | 0 | nLUM = css::document::LinkUpdateModes::AUTO; |
488 | 0 | break; |
489 | 0 | case LM_NEVER: |
490 | 0 | nLUM = css::document::LinkUpdateModes::NEVER; |
491 | 0 | break; |
492 | 0 | case LM_ON_DEMAND: |
493 | 0 | nLUM = css::document::LinkUpdateModes::MANUAL; |
494 | 0 | break; |
495 | 0 | case LM_UNKNOWN: |
496 | 0 | default: |
497 | 0 | nLUM = css::document::LinkUpdateModes::GLOBAL_SETTING; |
498 | 0 | break; |
499 | 0 | } |
500 | 0 | aRet <<= nLUM; |
501 | 0 | } |
502 | 215 | else if ( aPropertyName == SC_UNO_COLROWHDR ) |
503 | 0 | aRet <<= aViewOpt.GetOption(sc::ViewOption::HEADER); |
504 | 215 | else if ( aPropertyName == SC_UNO_SHEETTABS ) |
505 | 0 | aRet <<= aViewOpt.GetOption(sc::ViewOption::TABCONTROLS); |
506 | 215 | else if ( aPropertyName == SC_UNO_OUTLSYMB ) |
507 | 0 | aRet <<= aViewOpt.GetOption(sc::ViewOption::OUTLINER); |
508 | 215 | else if ( aPropertyName == SC_UNO_AUTOCALC ) |
509 | 0 | aRet <<= rDoc.GetAutoCalc(); |
510 | 215 | else if ( aPropertyName == SC_UNO_PRINTERNAME ) |
511 | 0 | { |
512 | | // #i75610# don't create the printer, return empty string if no printer created yet |
513 | | // (as in SwXDocumentSettings) |
514 | 0 | SfxPrinter* pPrinter = rDoc.GetPrinter( false ); |
515 | 0 | if (pPrinter) |
516 | 0 | aRet <<= pPrinter->GetName(); |
517 | 0 | else |
518 | 0 | aRet <<= OUString(); |
519 | 0 | } |
520 | 215 | else if ( aPropertyName == SC_UNO_PRINTERSETUP ) |
521 | 0 | { |
522 | | // #i75610# don't create the printer, return empty sequence if no printer created yet |
523 | | // (as in SwXDocumentSettings) |
524 | 0 | SfxPrinter* pPrinter = rDoc.GetPrinter( false ); |
525 | 0 | if (pPrinter) |
526 | 0 | { |
527 | 0 | SvMemoryStream aStream; |
528 | 0 | pPrinter->Store( aStream ); |
529 | 0 | aRet <<= uno::Sequence< sal_Int8 >( static_cast< const sal_Int8* >( aStream.GetData() ), |
530 | 0 | aStream.TellEnd() ); |
531 | 0 | } |
532 | 0 | else |
533 | 0 | aRet <<= uno::Sequence<sal_Int8>(); |
534 | 0 | } |
535 | 215 | else if ( aPropertyName == SC_UNO_PRINTERPAPER) |
536 | 0 | { |
537 | 0 | SfxPrinter *pTempPrinter = pDocShell->GetPrinter( false ); |
538 | 0 | aRet <<= pTempPrinter && pTempPrinter->GetPrinterSettingsPreferred(); |
539 | |
|
540 | 0 | } |
541 | 215 | else if ( aPropertyName == SC_UNO_APPLYDOCINF ) |
542 | 0 | aRet <<= pDocShell->IsUseUserData(); |
543 | 215 | else if ( aPropertyName == SC_UNO_SAVE_THUMBNAIL ) |
544 | 0 | aRet <<= pDocShell->IsUseThumbnailSave(); |
545 | 215 | else if ( aPropertyName == SC_UNO_FORBIDDEN ) |
546 | 215 | { |
547 | 215 | aRet <<= uno::Reference<i18n::XForbiddenCharacters>(new ScForbiddenCharsObj( pDocShell )); |
548 | 215 | } |
549 | 0 | else if ( aPropertyName == SC_UNO_CHARCOMP ) |
550 | 0 | aRet <<= static_cast<sal_Int16> ( rDoc.GetAsianCompression() ); |
551 | 0 | else if ( aPropertyName == SC_UNO_ASIANKERN ) |
552 | 0 | aRet <<= rDoc.GetAsianKerning(); |
553 | 0 | else if ( aPropertyName == SCSAVEVERSION ) |
554 | 0 | aRet <<= pDocShell->IsSaveVersionOnClose(); |
555 | 0 | else if ( aPropertyName == SC_UNO_UPDTEMPL ) |
556 | 0 | aRet <<= pDocShell->IsQueryLoadTemplate(); |
557 | 0 | else if ( aPropertyName == SC_UNO_LOADREADONLY ) |
558 | 0 | aRet <<= pDocShell->IsLoadReadonly(); |
559 | 0 | else if ( aPropertyName == SC_UNO_SHAREDOC ) |
560 | 0 | { |
561 | | #if HAVE_FEATURE_MULTIUSER_ENVIRONMENT |
562 | | aRet <<= pDocShell->HasSharedXMLFlagSet(); |
563 | | #endif |
564 | 0 | } |
565 | 0 | else if ( aPropertyName == SC_UNO_MODIFYPASSWORDINFO ) |
566 | 0 | aRet <<= pDocShell->GetModifyPasswordInfo(); |
567 | 0 | else if (aPropertyName == SC_UNO_MODIFYPASSWORDHASH) |
568 | 0 | aRet <<= pDocShell->GetModifyPasswordHash(); |
569 | 0 | else if (aPropertyName == SC_UNO_EMBED_FONTS) |
570 | 0 | aRet <<= rDoc.IsEmbedFonts(); |
571 | 0 | else if (aPropertyName == SC_UNO_EMBED_ONLY_USED_FONTS) |
572 | 0 | aRet <<= rDoc.IsEmbedUsedFontsOnly(); |
573 | 0 | else if (aPropertyName == SC_UNO_EMBED_FONT_SCRIPT_LATIN) |
574 | 0 | aRet <<= rDoc.IsEmbedFontScriptLatin(); |
575 | 0 | else if (aPropertyName == SC_UNO_EMBED_FONT_SCRIPT_ASIAN) |
576 | 0 | aRet <<= rDoc.IsEmbedFontScriptAsian(); |
577 | 0 | else if (aPropertyName == SC_UNO_EMBED_FONT_SCRIPT_COMPLEX) |
578 | 0 | aRet <<= rDoc.IsEmbedFontScriptComplex(); |
579 | 0 | else if ( aPropertyName == SC_UNO_SYNTAXSTRINGREF ) |
580 | 0 | { |
581 | 0 | ScCalcConfig aCalcConfig = rDoc.GetCalcConfig(); |
582 | 0 | formula::FormulaGrammar::AddressConvention eConv = aCalcConfig.meStringRefAddressSyntax; |
583 | | |
584 | | // don't save "unspecified" string ref syntax ... query formula grammar |
585 | | // and save that instead |
586 | 0 | if( eConv == formula::FormulaGrammar::CONV_UNSPECIFIED) |
587 | 0 | { |
588 | 0 | eConv = rDoc.GetAddressConvention(); |
589 | 0 | } |
590 | | |
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 | 0 | if ( aCalcConfig.mbHasStringRefSyntax || |
595 | 0 | (eConv != formula::FormulaGrammar::CONV_OOO) ) |
596 | 0 | { |
597 | 0 | switch (eConv) |
598 | 0 | { |
599 | 0 | case formula::FormulaGrammar::CONV_OOO: |
600 | 0 | case formula::FormulaGrammar::CONV_XL_A1: |
601 | 0 | case formula::FormulaGrammar::CONV_XL_R1C1: |
602 | 0 | case formula::FormulaGrammar::CONV_A1_XL_A1: |
603 | 0 | aRet <<= static_cast<sal_Int16>( eConv ); |
604 | 0 | break; |
605 | | |
606 | 0 | case formula::FormulaGrammar::CONV_UNSPECIFIED: |
607 | 0 | case formula::FormulaGrammar::CONV_ODF: |
608 | 0 | case formula::FormulaGrammar::CONV_XL_OOX: |
609 | 0 | case formula::FormulaGrammar::CONV_LOTUS_A1: |
610 | 0 | case formula::FormulaGrammar::CONV_LAST: |
611 | 0 | { |
612 | 0 | aRet <<= sal_Int16(9999); |
613 | 0 | break; |
614 | 0 | } |
615 | 0 | } |
616 | 0 | } |
617 | 0 | } |
618 | 0 | else if (aPropertyName == SC_UNO_IMAGE_PREFERRED_DPI) |
619 | 0 | { |
620 | 0 | aRet <<= rDoc.GetImagePreferredDPI(); |
621 | 0 | } |
622 | 0 | else |
623 | 0 | { |
624 | 0 | const ScGridOptions& aGridOpt = aViewOpt.GetGridOptions(); |
625 | 0 | if ( aPropertyName == SC_UNO_SNAPTORASTER ) |
626 | 0 | aRet <<= aGridOpt.GetUseGridSnap(); |
627 | 0 | else if ( aPropertyName == SC_UNO_RASTERVIS ) |
628 | 0 | aRet <<= aGridOpt.GetGridVisible(); |
629 | 0 | else if ( aPropertyName == SC_UNO_RASTERRESX ) |
630 | 0 | aRet <<= static_cast<sal_Int32> ( aGridOpt.GetFieldDrawX() ); |
631 | 0 | else if ( aPropertyName == SC_UNO_RASTERRESY ) |
632 | 0 | aRet <<= static_cast<sal_Int32> ( aGridOpt.GetFieldDrawY() ); |
633 | 0 | else if ( aPropertyName == SC_UNO_RASTERSUBX ) |
634 | 0 | aRet <<= static_cast<sal_Int32> ( aGridOpt.GetFieldDivisionX() ); |
635 | 0 | else if ( aPropertyName == SC_UNO_RASTERSUBY ) |
636 | 0 | aRet <<= static_cast<sal_Int32> ( aGridOpt.GetFieldDivisionY() ); |
637 | 0 | else if ( aPropertyName == SC_UNO_RASTERSYNC ) |
638 | 0 | aRet <<= aGridOpt.GetSynchronize(); |
639 | 0 | else |
640 | 0 | throw beans::UnknownPropertyException(aPropertyName); |
641 | 0 | } |
642 | | |
643 | | |
644 | 215 | return aRet; |
645 | 215 | } |
646 | | |
647 | | SC_IMPL_DUMMY_PROPERTY_LISTENER( ScDocumentConfiguration ) |
648 | | |
649 | | // XServiceInfo |
650 | | OUString SAL_CALL ScDocumentConfiguration::getImplementationName() |
651 | 0 | { |
652 | 0 | return u"ScDocumentConfiguration"_ustr; |
653 | 0 | } |
654 | | |
655 | | sal_Bool SAL_CALL ScDocumentConfiguration::supportsService( const OUString& rServiceName ) |
656 | 0 | { |
657 | 0 | return cppu::supportsService(this, rServiceName); |
658 | 0 | } |
659 | | |
660 | | uno::Sequence<OUString> SAL_CALL ScDocumentConfiguration::getSupportedServiceNames() |
661 | 0 | { |
662 | 0 | return {u"com.sun.star.comp.SpreadsheetSettings"_ustr, |
663 | 0 | u"com.sun.star.document.Settings"_ustr}; |
664 | 0 | } |
665 | | |
666 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |