xref: /aoo41x/main/sc/source/ui/unoobj/confuno.cxx (revision b3f79822)
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 														throw(uno::RuntimeException)
123 {
124 	ScUnoGuard aGuard;
125 	static uno::Reference<beans::XPropertySetInfo> aRef(
126 		new SfxItemPropertySetInfo( aPropSet.getPropertyMap() ));
127 	return aRef;
128 }
129 
setPropertyValue(const rtl::OUString & aPropertyName,const uno::Any & aValue)130 void SAL_CALL ScDocumentConfiguration::setPropertyValue(
131 						const rtl::OUString& aPropertyName, const uno::Any& aValue )
132 				throw(beans::UnknownPropertyException, beans::PropertyVetoException,
133 						lang::IllegalArgumentException, lang::WrappedTargetException,
134 						uno::RuntimeException)
135 {
136 	ScUnoGuard aGuard;
137 
138 	if(pDocShell)
139 	{
140 		ScDocument* pDoc = pDocShell->GetDocument();
141 		if (pDoc)
142 		{
143 			sal_Bool bUpdateHeights = sal_False;
144 
145 			ScViewOptions aViewOpt(pDoc->GetViewOptions());
146 
147             /*Stampit enable/disable print cancel */
148             if ( aPropertyName.compareToAscii( SC_UNO_ALLOWPRINTJOBCANCEL ) == 0 )
149                 pDocShell->Stamp_SetPrintCancelState( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
150             /*Stampit enable/disable print cancel */
151 
152             else if ( aPropertyName.compareToAscii( SC_UNO_SHOWZERO ) == 0 )
153 				aViewOpt.SetOption(VOPT_NULLVALS, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
154 			else if ( aPropertyName.compareToAscii( SC_UNO_SHOWNOTES ) == 0 )
155 				aViewOpt.SetOption(VOPT_NOTES, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
156 			else if ( aPropertyName.compareToAscii( SC_UNO_SHOWGRID ) == 0 )
157 				aViewOpt.SetOption(VOPT_GRID, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
158 			else if ( aPropertyName.compareToAscii( SC_UNO_GRIDCOLOR ) == 0 )
159 			{
160 				sal_Int64 nColor = 0;
161 				if (aValue >>= nColor)
162 				{
163 					String aColorName;
164 					Color aColor(static_cast<sal_uInt32>(nColor));
165 					aViewOpt.SetGridColor(aColor, aColorName);
166 				}
167 			}
168 			else if ( aPropertyName.compareToAscii( SC_UNO_SHOWPAGEBR ) == 0 )
169 				aViewOpt.SetOption(VOPT_PAGEBREAKS, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
170 			else if ( aPropertyName.compareToAscii( SC_UNONAME_LINKUPD ) == 0 )
171 				pDoc->SetLinkMode( static_cast<ScLkUpdMode> ( ScUnoHelpFunctions::GetInt16FromAny( aValue ) ) );
172 			else if ( aPropertyName.compareToAscii( SC_UNO_COLROWHDR ) == 0 )
173 				aViewOpt.SetOption(VOPT_HEADER, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
174 			else if ( aPropertyName.compareToAscii( SC_UNO_SHEETTABS ) == 0 )
175 				aViewOpt.SetOption(VOPT_TABCONTROLS, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
176 			else if ( aPropertyName.compareToAscii( SC_UNO_OUTLSYMB ) == 0 )
177 				aViewOpt.SetOption(VOPT_OUTLINER, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
178 			else if ( aPropertyName.compareToAscii( SC_UNO_AUTOCALC ) == 0 )
179 				pDoc->SetAutoCalc( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
180 			else if ( aPropertyName.compareToAscii( SC_UNO_PRINTERNAME ) == 0 )
181 			{
182                 rtl::OUString sPrinterName;
183                 if ( aValue >>= sPrinterName )
184                 {
185                     // #i75610# if the name is empty, do nothing (don't create any printer)
186                     if ( sPrinterName.getLength() != 0 && pDocShell->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED )
187                     {
188                         SfxPrinter* pPrinter = pDocShell->GetPrinter();
189                         if (pPrinter)
190                         {
191                             String aString(sPrinterName);
192                             if (pPrinter->GetName() != aString)
193                             {
194                                 SfxPrinter* pNewPrinter = new SfxPrinter( pPrinter->GetOptions().Clone(), aString );
195                                 if (pNewPrinter->IsKnown())
196                                     pDocShell->SetPrinter( pNewPrinter, SFX_PRINTER_PRINTER );
197                                 else
198                                     delete pNewPrinter;
199                             }
200                         }
201                         else
202                             throw uno::RuntimeException();
203                     }
204                 }
205                 else
206                     throw lang::IllegalArgumentException();
207 			}
208 			else if ( aPropertyName.compareToAscii( SC_UNO_PRINTERSETUP ) == 0 )
209 			{
210 				uno::Sequence<sal_Int8> aSequence;
211 				if ( aValue >>= aSequence )
212 				{
213 					sal_uInt32 nSize = aSequence.getLength();
214                     // #i75610# if the sequence is empty, do nothing (don't create any printer)
215                     if ( nSize != 0 )
216                     {
217                         SvMemoryStream aStream (aSequence.getArray(), nSize, STREAM_READ );
218                         aStream.Seek ( STREAM_SEEK_TO_BEGIN );
219                         SfxItemSet* pSet = new SfxItemSet( *pDoc->GetPool(),
220                                 SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN,
221                                 SID_PRINTER_CHANGESTODOC,  SID_PRINTER_CHANGESTODOC,
222                                 SID_PRINT_SELECTEDSHEET,   SID_PRINT_SELECTEDSHEET,
223                                 SID_SCPRINTOPTIONS,        SID_SCPRINTOPTIONS,
224                                 NULL );
225                         pDocShell->SetPrinter( SfxPrinter::Create( aStream, pSet ) );
226                     }
227 				}
228 			}
229 			else if ( aPropertyName.compareToAscii( SC_UNO_APPLYDOCINF ) == 0 )
230 			{
231                 sal_Bool bTmp=sal_True;
232 				if ( aValue >>= bTmp )
233 					pDocShell->SetUseUserData( bTmp );
234 			}
235 			else if ( aPropertyName.compareToAscii( SC_UNO_FORBIDDEN ) == 0 )
236 			{
237 				//	read-only - should not be set
238 			}
239 			else if ( aPropertyName.compareToAscii( SC_UNO_CHARCOMP ) == 0 )
240 			{
241 				// Int16 contains CharacterCompressionType values
242 				sal_Int16 nUno = ScUnoHelpFunctions::GetInt16FromAny( aValue );
243 				pDoc->SetAsianCompression( (sal_uInt8) nUno );
244 				bUpdateHeights = sal_True;
245 			}
246 			else if ( aPropertyName.compareToAscii( SC_UNO_ASIANKERN ) == 0 )
247 			{
248 				pDoc->SetAsianKerning( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
249 				bUpdateHeights = sal_True;
250 			}
251 			else if ( aPropertyName.compareToAscii( SCSAVEVERSION ) == 0)
252 			{
253                 sal_Bool bTmp=sal_False;
254 				if ( aValue >>= bTmp )
255 					pDocShell->SetSaveVersionOnClose( bTmp );
256 			}
257             else if ( aPropertyName.compareToAscii( SC_UNO_UPDTEMPL ) == 0 )
258 			{
259                 sal_Bool bTmp=sal_True;
260 				if ( aValue >>= bTmp )
261 					pDocShell->SetQueryLoadTemplate( bTmp );
262 			}
263             else if ( aPropertyName.compareToAscii( SC_UNO_LOADREADONLY ) == 0 )
264 			{
265                 sal_Bool bTmp=sal_False;
266 				if ( aValue >>= bTmp )
267 					pDocShell->SetLoadReadonly( bTmp );
268 			}
269             else if ( aPropertyName.compareToAscii( SC_UNO_SHAREDOC ) == 0 )
270             {
271                 sal_Bool bDocShared = sal_False;
272                 if ( aValue >>= bDocShared )
273                 {
274                     pDocShell->SetSharedXMLFlag( bDocShared );
275                 }
276             }
277             else if ( aPropertyName.compareToAscii( SC_UNO_MODIFYPASSWORDINFO ) == 0 )
278             {
279                 uno::Sequence< beans::PropertyValue > aInfo;
280                 if ( !( aValue >>= aInfo ) )
281                     throw lang::IllegalArgumentException(
282                         ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Value of type Sequence<PropertyValue> expected!" ) ),
283                         uno::Reference< uno::XInterface >(),
284                         2 );
285 
286                 if ( !pDocShell->SetModifyPasswordInfo( aInfo ) )
287                     throw beans::PropertyVetoException(
288                         ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "The hash is not allowed to be changed now!" ) ),
289                         uno::Reference< uno::XInterface >() );
290             }
291 			else
292 			{
293 				ScGridOptions aGridOpt(aViewOpt.GetGridOptions());
294 				if ( aPropertyName.compareToAscii( SC_UNO_SNAPTORASTER ) == 0 )
295 					aGridOpt.SetUseGridSnap( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
296 				else if ( aPropertyName.compareToAscii( SC_UNO_RASTERVIS ) == 0 )
297                     aGridOpt.SetGridVisible( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
298 				else if ( aPropertyName.compareToAscii( SC_UNO_RASTERRESX ) == 0 )
299 					aGridOpt.SetFldDrawX( static_cast <sal_uInt32> ( ScUnoHelpFunctions::GetInt32FromAny( aValue ) ) );
300 				else if ( aPropertyName.compareToAscii( SC_UNO_RASTERRESY ) == 0 )
301 					aGridOpt.SetFldDrawY( static_cast <sal_uInt32> ( ScUnoHelpFunctions::GetInt32FromAny( aValue ) ) );
302 				else if ( aPropertyName.compareToAscii( SC_UNO_RASTERSUBX ) == 0 )
303 					aGridOpt.SetFldDivisionX( static_cast <sal_uInt32> ( ScUnoHelpFunctions::GetInt32FromAny( aValue ) ) );
304 				else if ( aPropertyName.compareToAscii( SC_UNO_RASTERSUBY ) == 0 )
305 					aGridOpt.SetFldDivisionY( static_cast <sal_uInt32> ( ScUnoHelpFunctions::GetInt32FromAny( aValue ) ) );
306 				else if ( aPropertyName.compareToAscii( SC_UNO_RASTERSYNC ) == 0 )
307                     aGridOpt.SetSynchronize( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
308 				else
309 					throw beans::UnknownPropertyException();
310 				aViewOpt.SetGridOptions(aGridOpt);
311 			}
312 			pDoc->SetViewOptions(aViewOpt);
313 
314 			if ( bUpdateHeights && !pDoc->IsImportingXML() )
315 			{
316 				//	update automatic row heights and repaint
317 				SCTAB nTabCount = pDoc->GetTableCount();
318 				for (SCTAB nTab=0; nTab<nTabCount; nTab++)
319 					if ( !pDocShell->AdjustRowHeight( 0, MAXROW, nTab ) )
320 						pDocShell->PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab, PAINT_GRID );
321 				pDocShell->SetDocumentModified();
322 			}
323 		}
324 		else
325 			throw uno::RuntimeException();
326 	}
327 	else
328 		throw uno::RuntimeException();
329 }
330 
getPropertyValue(const rtl::OUString & aPropertyName)331 uno::Any SAL_CALL ScDocumentConfiguration::getPropertyValue( const rtl::OUString& aPropertyName )
332 				throw(beans::UnknownPropertyException, lang::WrappedTargetException,
333 						uno::RuntimeException)
334 {
335 	ScUnoGuard aGuard;
336 	uno::Any aRet;
337 
338 	if(pDocShell)
339 	{
340 		ScDocument* pDoc = pDocShell->GetDocument();
341 		if (pDoc)
342 		{
343 			const ScViewOptions& aViewOpt = pDoc->GetViewOptions();
344 
345             /*Stampit enable/disable print cancel */
346             if ( aPropertyName.compareToAscii( SC_UNO_ALLOWPRINTJOBCANCEL ) == 0 )
347                 ScUnoHelpFunctions::SetBoolInAny( aRet, pDocShell->Stamp_GetPrintCancelState() );
348             /*Stampit enable/disable print cancel */
349 
350             else if ( aPropertyName.compareToAscii( SC_UNO_SHOWZERO ) == 0 )
351 				ScUnoHelpFunctions::SetBoolInAny( aRet, aViewOpt.GetOption( VOPT_NULLVALS ) );
352 			else if ( aPropertyName.compareToAscii( SC_UNO_SHOWNOTES ) == 0 )
353 				ScUnoHelpFunctions::SetBoolInAny( aRet, aViewOpt.GetOption( VOPT_NOTES ) );
354 			else if ( aPropertyName.compareToAscii( SC_UNO_SHOWGRID ) == 0 )
355 				ScUnoHelpFunctions::SetBoolInAny( aRet, aViewOpt.GetOption( VOPT_GRID ) );
356 			else if ( aPropertyName.compareToAscii( SC_UNO_GRIDCOLOR ) == 0 )
357 			{
358 				String aColorName;
359 				Color aColor = aViewOpt.GetGridColor(&aColorName);
360 				aRet <<= static_cast<sal_Int64>(aColor.GetColor());
361 			}
362 			else if ( aPropertyName.compareToAscii( SC_UNO_SHOWPAGEBR ) == 0 )
363 				ScUnoHelpFunctions::SetBoolInAny( aRet, aViewOpt.GetOption( VOPT_PAGEBREAKS ) );
364 			else if ( aPropertyName.compareToAscii( SC_UNONAME_LINKUPD ) == 0 )
365 				aRet <<= static_cast<sal_Int16> ( pDoc->GetLinkMode() );
366 			else if ( aPropertyName.compareToAscii( SC_UNO_COLROWHDR ) == 0 )
367 				ScUnoHelpFunctions::SetBoolInAny( aRet, aViewOpt.GetOption( VOPT_HEADER ) );
368 			else if ( aPropertyName.compareToAscii( SC_UNO_SHEETTABS ) == 0 )
369 				ScUnoHelpFunctions::SetBoolInAny( aRet, aViewOpt.GetOption( VOPT_TABCONTROLS ) );
370 			else if ( aPropertyName.compareToAscii( SC_UNO_OUTLSYMB ) == 0 )
371 				ScUnoHelpFunctions::SetBoolInAny( aRet, aViewOpt.GetOption( VOPT_OUTLINER ) );
372 			else if ( aPropertyName.compareToAscii( SC_UNO_AUTOCALC ) == 0 )
373 				ScUnoHelpFunctions::SetBoolInAny( aRet, pDoc->GetAutoCalc() );
374 			else if ( aPropertyName.compareToAscii( SC_UNO_PRINTERNAME ) == 0 )
375 			{
376                 // #i75610# don't create the printer, return empty string if no printer created yet
377                 // (as in SwXDocumentSettings)
378                 SfxPrinter* pPrinter = pDoc->GetPrinter( sal_False );
379 				if (pPrinter)
380 					aRet <<= rtl::OUString ( pPrinter->GetName());
381 				else
382                     aRet <<= rtl::OUString();
383 			}
384 			else if ( aPropertyName.compareToAscii( SC_UNO_PRINTERSETUP ) == 0 )
385 			{
386                 // #i75610# don't create the printer, return empty sequence if no printer created yet
387                 // (as in SwXDocumentSettings)
388                 SfxPrinter* pPrinter = pDoc->GetPrinter( sal_False );
389 				if (pPrinter)
390 				{
391 					SvMemoryStream aStream;
392 					pPrinter->Store( aStream );
393 					aStream.Seek ( STREAM_SEEK_TO_END );
394 					sal_uInt32 nSize = aStream.Tell();
395 					aStream.Seek ( STREAM_SEEK_TO_BEGIN );
396 					uno::Sequence < sal_Int8 > aSequence( nSize );
397 					aStream.Read ( aSequence.getArray(), nSize );
398 					aRet <<= aSequence;
399 				}
400                 else
401                     aRet <<= uno::Sequence<sal_Int8>();
402 			}
403 			else if ( aPropertyName.compareToAscii( SC_UNO_APPLYDOCINF ) == 0 )
404 				aRet <<= pDocShell->IsUseUserData();
405 			else if ( aPropertyName.compareToAscii( SC_UNO_FORBIDDEN ) == 0 )
406 			{
407 				aRet <<= uno::Reference<i18n::XForbiddenCharacters>(new ScForbiddenCharsObj( pDocShell ));
408 			}
409 			else if ( aPropertyName.compareToAscii( SC_UNO_CHARCOMP ) == 0 )
410 				aRet <<= static_cast<sal_Int16> ( pDoc->GetAsianCompression() );
411 			else if ( aPropertyName.compareToAscii( SC_UNO_ASIANKERN ) == 0 )
412 				ScUnoHelpFunctions::SetBoolInAny( aRet, pDoc->GetAsianKerning() );
413 			else if ( aPropertyName.compareToAscii( SCSAVEVERSION ) == 0)
414 				aRet <<= pDocShell->IsSaveVersionOnClose();
415             else if ( aPropertyName.compareToAscii( SC_UNO_UPDTEMPL ) == 0 )
416 				aRet <<= pDocShell->IsQueryLoadTemplate();
417             else if ( aPropertyName.compareToAscii( SC_UNO_LOADREADONLY ) == 0 )
418 				aRet <<= pDocShell->IsLoadReadonly();
419 			// <--
420             else if ( aPropertyName.compareToAscii( SC_UNO_SHAREDOC ) == 0 )
421             {
422                 ScUnoHelpFunctions::SetBoolInAny( aRet, pDocShell->HasSharedXMLFlagSet() );
423             }
424             else if ( aPropertyName.compareToAscii( SC_UNO_MODIFYPASSWORDINFO ) == 0 )
425                 aRet <<= pDocShell->GetModifyPasswordInfo();
426 			else
427 			{
428 				const ScGridOptions& aGridOpt = aViewOpt.GetGridOptions();
429 				if ( aPropertyName.compareToAscii( SC_UNO_SNAPTORASTER ) == 0 )
430 					ScUnoHelpFunctions::SetBoolInAny( aRet, aGridOpt.GetUseGridSnap() );
431 				else if ( aPropertyName.compareToAscii( SC_UNO_RASTERVIS ) == 0 )
432 					ScUnoHelpFunctions::SetBoolInAny( aRet, aGridOpt.GetGridVisible() );
433 				else if ( aPropertyName.compareToAscii( SC_UNO_RASTERRESX ) == 0 )
434 					aRet <<= static_cast<sal_Int32> ( aGridOpt.GetFldDrawX() );
435 				else if ( aPropertyName.compareToAscii( SC_UNO_RASTERRESY ) == 0 )
436 					aRet <<= static_cast<sal_Int32> ( aGridOpt.GetFldDrawY() );
437 				else if ( aPropertyName.compareToAscii( SC_UNO_RASTERSUBX ) == 0 )
438 					aRet <<= static_cast<sal_Int32> ( aGridOpt.GetFldDivisionX() );
439 				else if ( aPropertyName.compareToAscii( SC_UNO_RASTERSUBY ) == 0 )
440 					aRet <<= static_cast<sal_Int32> ( aGridOpt.GetFldDivisionY() );
441 				else if ( aPropertyName.compareToAscii( SC_UNO_RASTERSYNC ) == 0 )
442 					ScUnoHelpFunctions::SetBoolInAny( aRet, aGridOpt.GetSynchronize() );
443 				else
444 					throw beans::UnknownPropertyException();
445 			}
446 		}
447 		else
448 			throw uno::RuntimeException();
449 	}
450 	else
451 		throw uno::RuntimeException();
452 
453 	return aRet;
454 }
455 
SC_IMPL_DUMMY_PROPERTY_LISTENER(ScDocumentConfiguration)456 SC_IMPL_DUMMY_PROPERTY_LISTENER( ScDocumentConfiguration )
457 
458 // XServiceInfo
459 
460 rtl::OUString SAL_CALL ScDocumentConfiguration::getImplementationName() throw(uno::RuntimeException)
461 {
462 	return rtl::OUString::createFromAscii( "ScDocumentConfiguration" );
463 }
464 
supportsService(const rtl::OUString & rServiceName)465 sal_Bool SAL_CALL ScDocumentConfiguration::supportsService( const rtl::OUString& rServiceName )
466 													throw(uno::RuntimeException)
467 {
468 	String aServiceStr( rServiceName );
469 	return aServiceStr.EqualsAscii( SCCOMPSCPREADSHEETSETTINGS_SERVICE ) ||
470 		   aServiceStr.EqualsAscii( SCDOCUMENTSETTINGS_SERVICE );
471 }
472 
getSupportedServiceNames()473 uno::Sequence<rtl::OUString> SAL_CALL ScDocumentConfiguration::getSupportedServiceNames()
474 													throw(uno::RuntimeException)
475 {
476 	uno::Sequence<rtl::OUString> aRet(2);
477 	rtl::OUString* pArray = aRet.getArray();
478 	pArray[0] = rtl::OUString::createFromAscii( SCCOMPSCPREADSHEETSETTINGS_SERVICE );
479 	pArray[1] = rtl::OUString::createFromAscii( SCDOCUMENTSETTINGS_SERVICE );
480 	return aRet;
481 }
482 
483 //-------------------------------------------------------------------------
484 
485