1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sc.hxx"
26
27
28
29 #include "confuno.hxx"
30 #include "unonames.hxx"
31 #include "unoguard.hxx"
32 #include "scdll.hxx"
33 #include "docsh.hxx"
34 #include "miscuno.hxx"
35 #include "forbiuno.hxx"
36 #include "viewopti.hxx"
37 #include "docpool.hxx"
38 #include "sc.hrc"
39
40 #include <com/sun/star/beans/PropertyAttribute.hpp>
41 #include <sfx2/printer.hxx>
42 #include <xmloff/xmluconv.hxx>
43 #include <rtl/ustrbuf.hxx>
44
45 using namespace com::sun::star;
46
47 #define SCCOMPSCPREADSHEETSETTINGS_SERVICE "com.sun.star.comp.SpreadsheetSettings"
48 #define SCDOCUMENTSETTINGS_SERVICE "com.sun.star.document.Settings"
49 #define SCSAVEVERSION "SaveVersionOnClose"
50
51
lcl_GetConfigPropertyMap()52 const SfxItemPropertyMapEntry* lcl_GetConfigPropertyMap()
53 {
54 static SfxItemPropertyMapEntry aConfigPropertyMap_Impl[] =
55 {
56 {MAP_CHAR_LEN(SC_UNO_SHOWZERO), 0, &getBooleanCppuType(), 0, 0},
57 {MAP_CHAR_LEN(SC_UNO_SHOWNOTES), 0, &getBooleanCppuType(), 0, 0},
58 {MAP_CHAR_LEN(SC_UNO_SHOWGRID), 0, &getBooleanCppuType(), 0, 0},
59 {MAP_CHAR_LEN(SC_UNO_GRIDCOLOR), 0, &getCppuType((sal_Int32*)0), 0, 0},
60 {MAP_CHAR_LEN(SC_UNO_SHOWPAGEBR), 0, &getBooleanCppuType(), 0, 0},
61 {MAP_CHAR_LEN(SC_UNONAME_LINKUPD), 0, &getCppuType((sal_Int16*)0), 0, 0},
62 {MAP_CHAR_LEN(SC_UNO_COLROWHDR), 0, &getBooleanCppuType(), 0, 0},
63 {MAP_CHAR_LEN(SC_UNO_SHEETTABS), 0, &getBooleanCppuType(), 0, 0},
64 {MAP_CHAR_LEN(SC_UNO_OUTLSYMB), 0, &getBooleanCppuType(), 0, 0},
65 {MAP_CHAR_LEN(SC_UNO_SNAPTORASTER), 0, &getBooleanCppuType(), 0, 0},
66 {MAP_CHAR_LEN(SC_UNO_RASTERVIS), 0, &getBooleanCppuType(), 0, 0},
67 {MAP_CHAR_LEN(SC_UNO_RASTERRESX), 0, &getCppuType((sal_Int32*)0), 0, 0},
68 {MAP_CHAR_LEN(SC_UNO_RASTERRESY), 0, &getCppuType((sal_Int32*)0), 0, 0},
69 {MAP_CHAR_LEN(SC_UNO_RASTERSUBX), 0, &getCppuType((sal_Int32*)0), 0, 0},
70 {MAP_CHAR_LEN(SC_UNO_RASTERSUBY), 0, &getCppuType((sal_Int32*)0), 0, 0},
71 {MAP_CHAR_LEN(SC_UNO_RASTERSYNC), 0, &getBooleanCppuType(), 0, 0},
72 {MAP_CHAR_LEN(SC_UNO_AUTOCALC), 0, &getBooleanCppuType(), 0, 0},
73 {MAP_CHAR_LEN(SC_UNO_PRINTERNAME), 0, &getCppuType((rtl::OUString*)0), 0, 0},
74 {MAP_CHAR_LEN(SC_UNO_PRINTERSETUP), 0, &getCppuType((uno::Sequence<sal_Int8>*)0), 0, 0},
75 {MAP_CHAR_LEN(SC_UNO_APPLYDOCINF), 0, &getBooleanCppuType(), 0, 0},
76 {MAP_CHAR_LEN(SC_UNO_FORBIDDEN), 0, &getCppuType((uno::Reference<i18n::XForbiddenCharacters>*)0), beans::PropertyAttribute::READONLY, 0},
77 {MAP_CHAR_LEN(SC_UNO_CHARCOMP), 0, &getCppuType((sal_Int16*)0), 0, 0},
78 {MAP_CHAR_LEN(SC_UNO_ASIANKERN), 0, &getBooleanCppuType(), 0, 0},
79 {MAP_CHAR_LEN(SCSAVEVERSION), 0, &getBooleanCppuType(), 0, 0},
80 {MAP_CHAR_LEN(SC_UNO_UPDTEMPL), 0, &getBooleanCppuType(), 0, 0},
81 /*Stampit enable/disable print cancel */
82 {MAP_CHAR_LEN(SC_UNO_ALLOWPRINTJOBCANCEL), 0, &getBooleanCppuType(), 0, 0},
83 // --> PB 2004-08-25 #i33095# Security Options
84 {MAP_CHAR_LEN(SC_UNO_LOADREADONLY), 0, &getBooleanCppuType(), 0, 0},
85 // <--
86 {MAP_CHAR_LEN(SC_UNO_SHAREDOC), 0, &getBooleanCppuType(), 0, 0},
87 {MAP_CHAR_LEN(SC_UNO_MODIFYPASSWORDINFO), 0, &getCppuType((uno::Sequence< beans::PropertyValue >*)0), 0, 0},
88 {0,0,0,0,0,0}
89 };
90 return aConfigPropertyMap_Impl;
91 }
92
93 //------------------------------------------------------------------------
94
ScDocumentConfiguration(ScDocShell * pDocSh)95 ScDocumentConfiguration::ScDocumentConfiguration(ScDocShell* pDocSh)
96 : pDocShell(pDocSh) ,
97 aPropSet ( lcl_GetConfigPropertyMap() )
98 {
99 pDocShell->GetDocument()->AddUnoObject(*this);
100 }
101
~ScDocumentConfiguration()102 ScDocumentConfiguration::~ScDocumentConfiguration()
103 {
104 if (pDocShell)
105 pDocShell->GetDocument()->RemoveUnoObject(*this);
106 }
107
Notify(SfxBroadcaster &,const SfxHint & rHint)108 void ScDocumentConfiguration::Notify( SfxBroadcaster&, const SfxHint& rHint )
109 {
110 // Referenz-Update interessiert hier nicht
111
112 if ( rHint.ISA( SfxSimpleHint ) &&
113 ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
114 {
115 pDocShell = NULL; // ungueltig geworden
116 }
117 }
118
119 // XPropertySet
120
getPropertySetInfo()121 uno::Reference<beans::XPropertySetInfo> SAL_CALL ScDocumentConfiguration::getPropertySetInfo()
122 {
123 ScUnoGuard aGuard;
124 static uno::Reference<beans::XPropertySetInfo> aRef(
125 new SfxItemPropertySetInfo( aPropSet.getPropertyMap() ));
126 return aRef;
127 }
128
setPropertyValue(const rtl::OUString & aPropertyName,const uno::Any & aValue)129 void SAL_CALL ScDocumentConfiguration::setPropertyValue(
130 const rtl::OUString& aPropertyName, const uno::Any& aValue )
131 {
132 ScUnoGuard aGuard;
133
134 if(pDocShell)
135 {
136 ScDocument* pDoc = pDocShell->GetDocument();
137 if (pDoc)
138 {
139 sal_Bool bUpdateHeights = sal_False;
140
141 ScViewOptions aViewOpt(pDoc->GetViewOptions());
142
143 /*Stampit enable/disable print cancel */
144 if ( aPropertyName.compareToAscii( SC_UNO_ALLOWPRINTJOBCANCEL ) == 0 )
145 pDocShell->Stamp_SetPrintCancelState( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
146 /*Stampit enable/disable print cancel */
147
148 else if ( aPropertyName.compareToAscii( SC_UNO_SHOWZERO ) == 0 )
149 aViewOpt.SetOption(VOPT_NULLVALS, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
150 else if ( aPropertyName.compareToAscii( SC_UNO_SHOWNOTES ) == 0 )
151 aViewOpt.SetOption(VOPT_NOTES, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
152 else if ( aPropertyName.compareToAscii( SC_UNO_SHOWGRID ) == 0 )
153 aViewOpt.SetOption(VOPT_GRID, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
154 else if ( aPropertyName.compareToAscii( SC_UNO_GRIDCOLOR ) == 0 )
155 {
156 sal_Int64 nColor = 0;
157 if (aValue >>= nColor)
158 {
159 String aColorName;
160 Color aColor(static_cast<sal_uInt32>(nColor));
161 aViewOpt.SetGridColor(aColor, aColorName);
162 }
163 }
164 else if ( aPropertyName.compareToAscii( SC_UNO_SHOWPAGEBR ) == 0 )
165 aViewOpt.SetOption(VOPT_PAGEBREAKS, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
166 else if ( aPropertyName.compareToAscii( SC_UNONAME_LINKUPD ) == 0 )
167 pDoc->SetLinkMode( static_cast<ScLkUpdMode> ( ScUnoHelpFunctions::GetInt16FromAny( aValue ) ) );
168 else if ( aPropertyName.compareToAscii( SC_UNO_COLROWHDR ) == 0 )
169 aViewOpt.SetOption(VOPT_HEADER, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
170 else if ( aPropertyName.compareToAscii( SC_UNO_SHEETTABS ) == 0 )
171 aViewOpt.SetOption(VOPT_TABCONTROLS, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
172 else if ( aPropertyName.compareToAscii( SC_UNO_OUTLSYMB ) == 0 )
173 aViewOpt.SetOption(VOPT_OUTLINER, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
174 else if ( aPropertyName.compareToAscii( SC_UNO_AUTOCALC ) == 0 )
175 pDoc->SetAutoCalc( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
176 else if ( aPropertyName.compareToAscii( SC_UNO_PRINTERNAME ) == 0 )
177 {
178 rtl::OUString sPrinterName;
179 if ( aValue >>= sPrinterName )
180 {
181 // #i75610# if the name is empty, do nothing (don't create any printer)
182 if ( sPrinterName.getLength() != 0 && pDocShell->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED )
183 {
184 SfxPrinter* pPrinter = pDocShell->GetPrinter();
185 if (pPrinter)
186 {
187 String aString(sPrinterName);
188 if (pPrinter->GetName() != aString)
189 {
190 SfxPrinter* pNewPrinter = new SfxPrinter( pPrinter->GetOptions().Clone(), aString );
191 if (pNewPrinter->IsKnown())
192 pDocShell->SetPrinter( pNewPrinter, SFX_PRINTER_PRINTER );
193 else
194 delete pNewPrinter;
195 }
196 }
197 else
198 throw uno::RuntimeException();
199 }
200 }
201 else
202 throw lang::IllegalArgumentException();
203 }
204 else if ( aPropertyName.compareToAscii( SC_UNO_PRINTERSETUP ) == 0 )
205 {
206 uno::Sequence<sal_Int8> aSequence;
207 if ( aValue >>= aSequence )
208 {
209 sal_uInt32 nSize = aSequence.getLength();
210 // #i75610# if the sequence is empty, do nothing (don't create any printer)
211 if ( nSize != 0 )
212 {
213 SvMemoryStream aStream (aSequence.getArray(), nSize, STREAM_READ );
214 aStream.Seek ( STREAM_SEEK_TO_BEGIN );
215 SfxItemSet* pSet = new SfxItemSet( *pDoc->GetPool(),
216 SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN,
217 SID_PRINTER_CHANGESTODOC, SID_PRINTER_CHANGESTODOC,
218 SID_PRINT_SELECTEDSHEET, SID_PRINT_SELECTEDSHEET,
219 SID_SCPRINTOPTIONS, SID_SCPRINTOPTIONS,
220 NULL );
221 pDocShell->SetPrinter( SfxPrinter::Create( aStream, pSet ) );
222 }
223 }
224 }
225 else if ( aPropertyName.compareToAscii( SC_UNO_APPLYDOCINF ) == 0 )
226 {
227 sal_Bool bTmp=sal_True;
228 if ( aValue >>= bTmp )
229 pDocShell->SetUseUserData( bTmp );
230 }
231 else if ( aPropertyName.compareToAscii( SC_UNO_FORBIDDEN ) == 0 )
232 {
233 // read-only - should not be set
234 }
235 else if ( aPropertyName.compareToAscii( SC_UNO_CHARCOMP ) == 0 )
236 {
237 // Int16 contains CharacterCompressionType values
238 sal_Int16 nUno = ScUnoHelpFunctions::GetInt16FromAny( aValue );
239 pDoc->SetAsianCompression( (sal_uInt8) nUno );
240 bUpdateHeights = sal_True;
241 }
242 else if ( aPropertyName.compareToAscii( SC_UNO_ASIANKERN ) == 0 )
243 {
244 pDoc->SetAsianKerning( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
245 bUpdateHeights = sal_True;
246 }
247 else if ( aPropertyName.compareToAscii( SCSAVEVERSION ) == 0)
248 {
249 sal_Bool bTmp=sal_False;
250 if ( aValue >>= bTmp )
251 pDocShell->SetSaveVersionOnClose( bTmp );
252 }
253 else if ( aPropertyName.compareToAscii( SC_UNO_UPDTEMPL ) == 0 )
254 {
255 sal_Bool bTmp=sal_True;
256 if ( aValue >>= bTmp )
257 pDocShell->SetQueryLoadTemplate( bTmp );
258 }
259 else if ( aPropertyName.compareToAscii( SC_UNO_LOADREADONLY ) == 0 )
260 {
261 sal_Bool bTmp=sal_False;
262 if ( aValue >>= bTmp )
263 pDocShell->SetLoadReadonly( bTmp );
264 }
265 else if ( aPropertyName.compareToAscii( SC_UNO_SHAREDOC ) == 0 )
266 {
267 sal_Bool bDocShared = sal_False;
268 if ( aValue >>= bDocShared )
269 {
270 pDocShell->SetSharedXMLFlag( bDocShared );
271 }
272 }
273 else if ( aPropertyName.compareToAscii( SC_UNO_MODIFYPASSWORDINFO ) == 0 )
274 {
275 uno::Sequence< beans::PropertyValue > aInfo;
276 if ( !( aValue >>= aInfo ) )
277 throw lang::IllegalArgumentException(
278 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Value of type Sequence<PropertyValue> expected!" ) ),
279 uno::Reference< uno::XInterface >(),
280 2 );
281
282 if ( !pDocShell->SetModifyPasswordInfo( aInfo ) )
283 throw beans::PropertyVetoException(
284 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "The hash is not allowed to be changed now!" ) ),
285 uno::Reference< uno::XInterface >() );
286 }
287 else
288 {
289 ScGridOptions aGridOpt(aViewOpt.GetGridOptions());
290 if ( aPropertyName.compareToAscii( SC_UNO_SNAPTORASTER ) == 0 )
291 aGridOpt.SetUseGridSnap( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
292 else if ( aPropertyName.compareToAscii( SC_UNO_RASTERVIS ) == 0 )
293 aGridOpt.SetGridVisible( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
294 else if ( aPropertyName.compareToAscii( SC_UNO_RASTERRESX ) == 0 )
295 aGridOpt.SetFldDrawX( static_cast <sal_uInt32> ( ScUnoHelpFunctions::GetInt32FromAny( aValue ) ) );
296 else if ( aPropertyName.compareToAscii( SC_UNO_RASTERRESY ) == 0 )
297 aGridOpt.SetFldDrawY( static_cast <sal_uInt32> ( ScUnoHelpFunctions::GetInt32FromAny( aValue ) ) );
298 else if ( aPropertyName.compareToAscii( SC_UNO_RASTERSUBX ) == 0 )
299 aGridOpt.SetFldDivisionX( static_cast <sal_uInt32> ( ScUnoHelpFunctions::GetInt32FromAny( aValue ) ) );
300 else if ( aPropertyName.compareToAscii( SC_UNO_RASTERSUBY ) == 0 )
301 aGridOpt.SetFldDivisionY( static_cast <sal_uInt32> ( ScUnoHelpFunctions::GetInt32FromAny( aValue ) ) );
302 else if ( aPropertyName.compareToAscii( SC_UNO_RASTERSYNC ) == 0 )
303 aGridOpt.SetSynchronize( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
304 else
305 throw beans::UnknownPropertyException();
306 aViewOpt.SetGridOptions(aGridOpt);
307 }
308 pDoc->SetViewOptions(aViewOpt);
309
310 if ( bUpdateHeights && !pDoc->IsImportingXML() )
311 {
312 // update automatic row heights and repaint
313 SCTAB nTabCount = pDoc->GetTableCount();
314 for (SCTAB nTab=0; nTab<nTabCount; nTab++)
315 if ( !pDocShell->AdjustRowHeight( 0, MAXROW, nTab ) )
316 pDocShell->PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab, PAINT_GRID );
317 pDocShell->SetDocumentModified();
318 }
319 }
320 else
321 throw uno::RuntimeException();
322 }
323 else
324 throw uno::RuntimeException();
325 }
326
getPropertyValue(const rtl::OUString & aPropertyName)327 uno::Any SAL_CALL ScDocumentConfiguration::getPropertyValue( const rtl::OUString& aPropertyName )
328 {
329 ScUnoGuard aGuard;
330 uno::Any aRet;
331
332 if(pDocShell)
333 {
334 ScDocument* pDoc = pDocShell->GetDocument();
335 if (pDoc)
336 {
337 const ScViewOptions& aViewOpt = pDoc->GetViewOptions();
338
339 /*Stampit enable/disable print cancel */
340 if ( aPropertyName.compareToAscii( SC_UNO_ALLOWPRINTJOBCANCEL ) == 0 )
341 ScUnoHelpFunctions::SetBoolInAny( aRet, pDocShell->Stamp_GetPrintCancelState() );
342 /*Stampit enable/disable print cancel */
343
344 else if ( aPropertyName.compareToAscii( SC_UNO_SHOWZERO ) == 0 )
345 ScUnoHelpFunctions::SetBoolInAny( aRet, aViewOpt.GetOption( VOPT_NULLVALS ) );
346 else if ( aPropertyName.compareToAscii( SC_UNO_SHOWNOTES ) == 0 )
347 ScUnoHelpFunctions::SetBoolInAny( aRet, aViewOpt.GetOption( VOPT_NOTES ) );
348 else if ( aPropertyName.compareToAscii( SC_UNO_SHOWGRID ) == 0 )
349 ScUnoHelpFunctions::SetBoolInAny( aRet, aViewOpt.GetOption( VOPT_GRID ) );
350 else if ( aPropertyName.compareToAscii( SC_UNO_GRIDCOLOR ) == 0 )
351 {
352 String aColorName;
353 Color aColor = aViewOpt.GetGridColor(&aColorName);
354 aRet <<= static_cast<sal_Int64>(aColor.GetColor());
355 }
356 else if ( aPropertyName.compareToAscii( SC_UNO_SHOWPAGEBR ) == 0 )
357 ScUnoHelpFunctions::SetBoolInAny( aRet, aViewOpt.GetOption( VOPT_PAGEBREAKS ) );
358 else if ( aPropertyName.compareToAscii( SC_UNONAME_LINKUPD ) == 0 )
359 aRet <<= static_cast<sal_Int16> ( pDoc->GetLinkMode() );
360 else if ( aPropertyName.compareToAscii( SC_UNO_COLROWHDR ) == 0 )
361 ScUnoHelpFunctions::SetBoolInAny( aRet, aViewOpt.GetOption( VOPT_HEADER ) );
362 else if ( aPropertyName.compareToAscii( SC_UNO_SHEETTABS ) == 0 )
363 ScUnoHelpFunctions::SetBoolInAny( aRet, aViewOpt.GetOption( VOPT_TABCONTROLS ) );
364 else if ( aPropertyName.compareToAscii( SC_UNO_OUTLSYMB ) == 0 )
365 ScUnoHelpFunctions::SetBoolInAny( aRet, aViewOpt.GetOption( VOPT_OUTLINER ) );
366 else if ( aPropertyName.compareToAscii( SC_UNO_AUTOCALC ) == 0 )
367 ScUnoHelpFunctions::SetBoolInAny( aRet, pDoc->GetAutoCalc() );
368 else if ( aPropertyName.compareToAscii( SC_UNO_PRINTERNAME ) == 0 )
369 {
370 // #i75610# don't create the printer, return empty string if no printer created yet
371 // (as in SwXDocumentSettings)
372 SfxPrinter* pPrinter = pDoc->GetPrinter( sal_False );
373 if (pPrinter)
374 aRet <<= rtl::OUString ( pPrinter->GetName());
375 else
376 aRet <<= rtl::OUString();
377 }
378 else if ( aPropertyName.compareToAscii( SC_UNO_PRINTERSETUP ) == 0 )
379 {
380 // #i75610# don't create the printer, return empty sequence if no printer created yet
381 // (as in SwXDocumentSettings)
382 SfxPrinter* pPrinter = pDoc->GetPrinter( sal_False );
383 if (pPrinter)
384 {
385 SvMemoryStream aStream;
386 pPrinter->Store( aStream );
387 aStream.Seek ( STREAM_SEEK_TO_END );
388 sal_uInt32 nSize = aStream.Tell();
389 aStream.Seek ( STREAM_SEEK_TO_BEGIN );
390 uno::Sequence < sal_Int8 > aSequence( nSize );
391 aStream.Read ( aSequence.getArray(), nSize );
392 aRet <<= aSequence;
393 }
394 else
395 aRet <<= uno::Sequence<sal_Int8>();
396 }
397 else if ( aPropertyName.compareToAscii( SC_UNO_APPLYDOCINF ) == 0 )
398 aRet <<= pDocShell->IsUseUserData();
399 else if ( aPropertyName.compareToAscii( SC_UNO_FORBIDDEN ) == 0 )
400 {
401 aRet <<= uno::Reference<i18n::XForbiddenCharacters>(new ScForbiddenCharsObj( pDocShell ));
402 }
403 else if ( aPropertyName.compareToAscii( SC_UNO_CHARCOMP ) == 0 )
404 aRet <<= static_cast<sal_Int16> ( pDoc->GetAsianCompression() );
405 else if ( aPropertyName.compareToAscii( SC_UNO_ASIANKERN ) == 0 )
406 ScUnoHelpFunctions::SetBoolInAny( aRet, pDoc->GetAsianKerning() );
407 else if ( aPropertyName.compareToAscii( SCSAVEVERSION ) == 0)
408 aRet <<= pDocShell->IsSaveVersionOnClose();
409 else if ( aPropertyName.compareToAscii( SC_UNO_UPDTEMPL ) == 0 )
410 aRet <<= pDocShell->IsQueryLoadTemplate();
411 else if ( aPropertyName.compareToAscii( SC_UNO_LOADREADONLY ) == 0 )
412 aRet <<= pDocShell->IsLoadReadonly();
413 // <--
414 else if ( aPropertyName.compareToAscii( SC_UNO_SHAREDOC ) == 0 )
415 {
416 ScUnoHelpFunctions::SetBoolInAny( aRet, pDocShell->HasSharedXMLFlagSet() );
417 }
418 else if ( aPropertyName.compareToAscii( SC_UNO_MODIFYPASSWORDINFO ) == 0 )
419 aRet <<= pDocShell->GetModifyPasswordInfo();
420 else
421 {
422 const ScGridOptions& aGridOpt = aViewOpt.GetGridOptions();
423 if ( aPropertyName.compareToAscii( SC_UNO_SNAPTORASTER ) == 0 )
424 ScUnoHelpFunctions::SetBoolInAny( aRet, aGridOpt.GetUseGridSnap() );
425 else if ( aPropertyName.compareToAscii( SC_UNO_RASTERVIS ) == 0 )
426 ScUnoHelpFunctions::SetBoolInAny( aRet, aGridOpt.GetGridVisible() );
427 else if ( aPropertyName.compareToAscii( SC_UNO_RASTERRESX ) == 0 )
428 aRet <<= static_cast<sal_Int32> ( aGridOpt.GetFldDrawX() );
429 else if ( aPropertyName.compareToAscii( SC_UNO_RASTERRESY ) == 0 )
430 aRet <<= static_cast<sal_Int32> ( aGridOpt.GetFldDrawY() );
431 else if ( aPropertyName.compareToAscii( SC_UNO_RASTERSUBX ) == 0 )
432 aRet <<= static_cast<sal_Int32> ( aGridOpt.GetFldDivisionX() );
433 else if ( aPropertyName.compareToAscii( SC_UNO_RASTERSUBY ) == 0 )
434 aRet <<= static_cast<sal_Int32> ( aGridOpt.GetFldDivisionY() );
435 else if ( aPropertyName.compareToAscii( SC_UNO_RASTERSYNC ) == 0 )
436 ScUnoHelpFunctions::SetBoolInAny( aRet, aGridOpt.GetSynchronize() );
437 else
438 throw beans::UnknownPropertyException();
439 }
440 }
441 else
442 throw uno::RuntimeException();
443 }
444 else
445 throw uno::RuntimeException();
446
447 return aRet;
448 }
449
SC_IMPL_DUMMY_PROPERTY_LISTENER(ScDocumentConfiguration)450 SC_IMPL_DUMMY_PROPERTY_LISTENER( ScDocumentConfiguration )
451
452 // XServiceInfo
453
454 rtl::OUString SAL_CALL ScDocumentConfiguration::getImplementationName()
455 {
456 return rtl::OUString::createFromAscii( "ScDocumentConfiguration" );
457 }
458
supportsService(const rtl::OUString & rServiceName)459 sal_Bool SAL_CALL ScDocumentConfiguration::supportsService( const rtl::OUString& rServiceName )
460 {
461 String aServiceStr( rServiceName );
462 return aServiceStr.EqualsAscii( SCCOMPSCPREADSHEETSETTINGS_SERVICE ) ||
463 aServiceStr.EqualsAscii( SCDOCUMENTSETTINGS_SERVICE );
464 }
465
getSupportedServiceNames()466 uno::Sequence<rtl::OUString> SAL_CALL ScDocumentConfiguration::getSupportedServiceNames()
467 {
468 uno::Sequence<rtl::OUString> aRet(2);
469 rtl::OUString* pArray = aRet.getArray();
470 pArray[0] = rtl::OUString::createFromAscii( SCCOMPSCPREADSHEETSETTINGS_SERVICE );
471 pArray[1] = rtl::OUString::createFromAscii( SCDOCUMENTSETTINGS_SERVICE );
472 return aRet;
473 }
474
475 //-------------------------------------------------------------------------
476