xref: /aoo41x/main/sc/source/core/tool/appoptio.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sc.hxx"
30 
31 
32 
33 //------------------------------------------------------------------
34 
35 #include <vcl/svapp.hxx>
36 
37 #include <com/sun/star/uno/Any.hxx>
38 #include <com/sun/star/uno/Sequence.hxx>
39 
40 #include "cfgids.hxx"
41 #include "appoptio.hxx"
42 #include "rechead.hxx"
43 #include "scresid.hxx"
44 #include "global.hxx"
45 #include "userlist.hxx"
46 #include "sc.hrc"
47 #include <formula/compiler.hrc>
48 #include "miscuno.hxx"
49 
50 using namespace utl;
51 using namespace rtl;
52 using namespace com::sun::star::uno;
53 
54 // STATIC DATA -----------------------------------------------------------
55 
56 #define SC_VERSION ((sal_uInt16)304)
57 
58 //========================================================================
59 //      ScAppOptions - Applikations-Optionen
60 //========================================================================
61 
62 ScAppOptions::ScAppOptions() : pLRUList( NULL )
63 {
64 	SetDefaults();
65 }
66 
67 //------------------------------------------------------------------------
68 
69 ScAppOptions::ScAppOptions( const ScAppOptions& rCpy ) : pLRUList( NULL )
70 {
71 	*this = rCpy;
72 }
73 
74 //------------------------------------------------------------------------
75 
76 ScAppOptions::~ScAppOptions()
77 {
78 	delete [] pLRUList;
79 }
80 
81 //------------------------------------------------------------------------
82 
83 void ScAppOptions::SetDefaults()
84 {
85 	if ( ScOptionsUtil::IsMetricSystem() )
86 		eMetric		= FUNIT_CM;				// default for countries with metric system
87 	else
88 		eMetric		= FUNIT_INCH;			// default for others
89 
90 	nZoom 			= 100;
91 	eZoomType		= SVX_ZOOM_PERCENT;
92     bSynchronizeZoom = sal_True;
93 	nStatusFunc		= SUBTOTAL_FUNC_SUM;
94 	bAutoComplete	= sal_True;
95 	bDetectiveAuto	= sal_True;
96 
97 	delete [] pLRUList;
98 	pLRUList = new sal_uInt16[5];				// sinnvoll vorbelegen
99 	pLRUList[0] = SC_OPCODE_SUM;
100 	pLRUList[1] = SC_OPCODE_AVERAGE;
101 	pLRUList[2] = SC_OPCODE_MIN;
102 	pLRUList[3] = SC_OPCODE_MAX;
103 	pLRUList[4] = SC_OPCODE_IF;
104 	nLRUFuncCount = 5;
105 
106 	nTrackContentColor = COL_TRANSPARENT;
107 	nTrackInsertColor  = COL_TRANSPARENT;
108 	nTrackDeleteColor  = COL_TRANSPARENT;
109 	nTrackMoveColor    = COL_TRANSPARENT;
110 	eLinkMode		   = LM_ON_DEMAND;
111 
112 	nDefaultObjectSizeWidth = 8000;
113 	nDefaultObjectSizeHeight = 5000;
114 
115     mbShowSharedDocumentWarning = true;
116 }
117 
118 //------------------------------------------------------------------------
119 
120 const ScAppOptions& ScAppOptions::operator=( const ScAppOptions& rCpy )
121 {
122 	eMetric			= rCpy.eMetric;
123 	eZoomType		= rCpy.eZoomType;
124     bSynchronizeZoom = rCpy.bSynchronizeZoom;
125 	nZoom			= rCpy.nZoom;
126 	SetLRUFuncList( rCpy.pLRUList, rCpy.nLRUFuncCount );
127 	nStatusFunc		= rCpy.nStatusFunc;
128 	bAutoComplete	= rCpy.bAutoComplete;
129 	bDetectiveAuto	= rCpy.bDetectiveAuto;
130 	nTrackContentColor = rCpy.nTrackContentColor;
131 	nTrackInsertColor  = rCpy.nTrackInsertColor;
132 	nTrackDeleteColor  = rCpy.nTrackDeleteColor;
133 	nTrackMoveColor    = rCpy.nTrackMoveColor;
134 	eLinkMode		= rCpy.eLinkMode;
135 	nDefaultObjectSizeWidth = rCpy.nDefaultObjectSizeWidth;
136 	nDefaultObjectSizeHeight = rCpy.nDefaultObjectSizeHeight;
137     mbShowSharedDocumentWarning = rCpy.mbShowSharedDocumentWarning;
138 	return *this;
139 }
140 
141 //------------------------------------------------------------------------
142 
143 void ScAppOptions::SetLRUFuncList( const sal_uInt16* pList,	const sal_uInt16 nCount )
144 {
145 	delete [] pLRUList;
146 
147 	nLRUFuncCount = nCount;
148 
149 	if ( nLRUFuncCount > 0 )
150 	{
151 		pLRUList = new sal_uInt16[nLRUFuncCount];
152 
153 		for ( sal_uInt16 i=0; i<nLRUFuncCount; i++ )
154 			pLRUList[i] = pList[i];
155 	}
156 	else
157 		pLRUList = NULL;
158 }
159 
160 //==================================================================
161 //	Config Item containing app options
162 //==================================================================
163 
164 void lcl_SetLastFunctions( ScAppOptions& rOpt, const Any& rValue )
165 {
166 	Sequence<sal_Int32> aSeq;
167 	if ( rValue >>= aSeq )
168 	{
169 		long nCount = aSeq.getLength();
170 		if ( nCount < USHRT_MAX )
171 		{
172 			const sal_Int32* pArray = aSeq.getConstArray();
173 			sal_uInt16* pUShorts = new sal_uInt16[nCount];
174 			for (long i=0; i<nCount; i++)
175 				pUShorts[i] = (sal_uInt16) pArray[i];
176 
177             rOpt.SetLRUFuncList( pUShorts, sal::static_int_cast<sal_uInt16>(nCount) );
178 
179 			delete[] pUShorts;
180 		}
181 	}
182 }
183 
184 void lcl_GetLastFunctions( Any& rDest, const ScAppOptions& rOpt )
185 {
186 	long nCount = rOpt.GetLRUFuncListCount();
187 	sal_uInt16* pUShorts = rOpt.GetLRUFuncList();
188 	if ( nCount && pUShorts )
189 	{
190 		Sequence<sal_Int32> aSeq( nCount );
191 		sal_Int32* pArray = aSeq.getArray();
192 		for (long i=0; i<nCount; i++)
193 			pArray[i] = pUShorts[i];
194 		rDest <<= aSeq;
195 	}
196 	else
197 		rDest <<= Sequence<sal_Int32>(0);	// empty
198 }
199 
200 void lcl_SetSortList( const Any& rValue )
201 {
202 	Sequence<OUString> aSeq;
203 	if ( rValue >>= aSeq )
204 	{
205 		long nCount = aSeq.getLength();
206 		const OUString* pArray = aSeq.getConstArray();
207 		ScUserList aList;
208 
209 		//	if setting is "default", keep default values from ScUserList ctor
210 		//!	mark "default" in a safe way
211 		sal_Bool bDefault = ( nCount == 1 &&
212 						pArray[0].equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "NULL" ) ) );
213 
214 		if (!bDefault)
215 		{
216 			aList.FreeAll();
217 
218 			for (long i=0; i<nCount; i++)
219 			{
220 				ScUserListData* pNew = new ScUserListData( pArray[i] );
221 				if ( !aList.Insert(pNew) )
222 					delete pNew;
223 			}
224 		}
225 
226 		ScGlobal::SetUserList( &aList );
227 	}
228 }
229 
230 void lcl_GetSortList( Any& rDest )
231 {
232 	const ScUserList* pUserList = ScGlobal::GetUserList();
233 	if (pUserList)
234 	{
235 		long nCount = pUserList->GetCount();
236 		Sequence<OUString> aSeq( nCount );
237 		OUString* pArray = aSeq.getArray();
238 		for (long i=0; i<nCount; i++)
239 			pArray[i] = (*pUserList)[sal::static_int_cast<sal_uInt16>(i)]->GetString();
240 		rDest <<= aSeq;
241 	}
242 	else
243 		rDest <<= Sequence<OUString>(0);	// empty
244 }
245 
246 //------------------------------------------------------------------
247 
248 #define CFGPATH_LAYOUT		"Office.Calc/Layout"
249 
250 #define SCLAYOUTOPT_MEASURE			0
251 #define SCLAYOUTOPT_STATUSBAR		1
252 #define SCLAYOUTOPT_ZOOMVAL			2
253 #define SCLAYOUTOPT_ZOOMTYPE		3
254 #define SCLAYOUTOPT_SYNCZOOM        4
255 #define SCLAYOUTOPT_COUNT           5
256 
257 #define CFGPATH_INPUT		"Office.Calc/Input"
258 
259 #define SCINPUTOPT_LASTFUNCS		0
260 #define SCINPUTOPT_AUTOINPUT		1
261 #define SCINPUTOPT_DET_AUTO			2
262 #define SCINPUTOPT_COUNT			3
263 
264 #define CFGPATH_REVISION	"Office.Calc/Revision/Color"
265 
266 #define SCREVISOPT_CHANGE			0
267 #define SCREVISOPT_INSERTION		1
268 #define SCREVISOPT_DELETION			2
269 #define SCREVISOPT_MOVEDENTRY		3
270 #define SCREVISOPT_COUNT			4
271 
272 #define CFGPATH_CONTENT		"Office.Calc/Content/Update"
273 
274 #define SCCONTENTOPT_LINK			0
275 #define SCCONTENTOPT_COUNT			1
276 
277 #define CFGPATH_SORTLIST	"Office.Calc/SortList"
278 
279 #define SCSORTLISTOPT_LIST			0
280 #define SCSORTLISTOPT_COUNT			1
281 
282 #define CFGPATH_MISC		"Office.Calc/Misc"
283 
284 #define SCMISCOPT_DEFOBJWIDTH		0
285 #define SCMISCOPT_DEFOBJHEIGHT		1
286 #define SCMISCOPT_SHOWSHAREDDOCWARN 2
287 #define SCMISCOPT_COUNT				3
288 
289 
290 Sequence<OUString> ScAppCfg::GetLayoutPropertyNames()
291 {
292 	static const char* aPropNames[] =
293 	{
294 		"Other/MeasureUnit/NonMetric",	// SCLAYOUTOPT_MEASURE
295 		"Other/StatusbarFunction",		// SCLAYOUTOPT_STATUSBAR
296 		"Zoom/Value",					// SCLAYOUTOPT_ZOOMVAL
297         "Zoom/Type",                    // SCLAYOUTOPT_ZOOMTYPE
298         "Zoom/Synchronize"              // SCLAYOUTOPT_SYNCZOOM
299 	};
300 	Sequence<OUString> aNames(SCLAYOUTOPT_COUNT);
301 	OUString* pNames = aNames.getArray();
302 	for(int i = 0; i < SCLAYOUTOPT_COUNT; i++)
303 		pNames[i] = OUString::createFromAscii(aPropNames[i]);
304 
305 	//	adjust for metric system
306 	if (ScOptionsUtil::IsMetricSystem())
307 		pNames[SCLAYOUTOPT_MEASURE] = OUString::createFromAscii( "Other/MeasureUnit/Metric" );
308 
309 	return aNames;
310 }
311 
312 Sequence<OUString> ScAppCfg::GetInputPropertyNames()
313 {
314 	static const char* aPropNames[] =
315 	{
316 		"LastFunctions",			// SCINPUTOPT_LASTFUNCS
317 		"AutoInput",				// SCINPUTOPT_AUTOINPUT
318 		"DetectiveAuto"				// SCINPUTOPT_DET_AUTO
319 	};
320 	Sequence<OUString> aNames(SCINPUTOPT_COUNT);
321 	OUString* pNames = aNames.getArray();
322 	for(int i = 0; i < SCINPUTOPT_COUNT; i++)
323 		pNames[i] = OUString::createFromAscii(aPropNames[i]);
324 
325 	return aNames;
326 }
327 
328 Sequence<OUString> ScAppCfg::GetRevisionPropertyNames()
329 {
330 	static const char* aPropNames[] =
331 	{
332 		"Change",					// SCREVISOPT_CHANGE
333 		"Insertion",				// SCREVISOPT_INSERTION
334 		"Deletion",					// SCREVISOPT_DELETION
335 		"MovedEntry"				// SCREVISOPT_MOVEDENTRY
336 	};
337 	Sequence<OUString> aNames(SCREVISOPT_COUNT);
338 	OUString* pNames = aNames.getArray();
339 	for(int i = 0; i < SCREVISOPT_COUNT; i++)
340 		pNames[i] = OUString::createFromAscii(aPropNames[i]);
341 
342 	return aNames;
343 }
344 
345 Sequence<OUString> ScAppCfg::GetContentPropertyNames()
346 {
347 	static const char* aPropNames[] =
348 	{
349 		"Link"						// SCCONTENTOPT_LINK
350 	};
351 	Sequence<OUString> aNames(SCCONTENTOPT_COUNT);
352 	OUString* pNames = aNames.getArray();
353 	for(int i = 0; i < SCCONTENTOPT_COUNT; i++)
354 		pNames[i] = OUString::createFromAscii(aPropNames[i]);
355 
356 	return aNames;
357 }
358 
359 Sequence<OUString> ScAppCfg::GetSortListPropertyNames()
360 {
361 	static const char* aPropNames[] =
362 	{
363 		"List"						// SCSORTLISTOPT_LIST
364 	};
365 	Sequence<OUString> aNames(SCSORTLISTOPT_COUNT);
366 	OUString* pNames = aNames.getArray();
367 	for(int i = 0; i < SCSORTLISTOPT_COUNT; i++)
368 		pNames[i] = OUString::createFromAscii(aPropNames[i]);
369 
370 	return aNames;
371 }
372 
373 Sequence<OUString> ScAppCfg::GetMiscPropertyNames()
374 {
375 	static const char* aPropNames[] =
376 	{
377 		"DefaultObjectSize/Width",	    // SCMISCOPT_DEFOBJWIDTH
378 		"DefaultObjectSize/Height",     // SCMISCOPT_DEFOBJHEIGHT
379         "SharedDocument/ShowWarning"    // SCMISCOPT_SHOWSHAREDDOCWARN
380 	};
381 	Sequence<OUString> aNames(SCMISCOPT_COUNT);
382 	OUString* pNames = aNames.getArray();
383 	for(int i = 0; i < SCMISCOPT_COUNT; i++)
384 		pNames[i] = OUString::createFromAscii(aPropNames[i]);
385 
386 	return aNames;
387 }
388 
389 
390 ScAppCfg::ScAppCfg() :
391 	aLayoutItem( OUString::createFromAscii( CFGPATH_LAYOUT ) ),
392 	aInputItem( OUString::createFromAscii( CFGPATH_INPUT ) ),
393 	aRevisionItem( OUString::createFromAscii( CFGPATH_REVISION ) ),
394 	aContentItem( OUString::createFromAscii( CFGPATH_CONTENT ) ),
395 	aSortListItem( OUString::createFromAscii( CFGPATH_SORTLIST ) ),
396 	aMiscItem( OUString::createFromAscii( CFGPATH_MISC ) )
397 {
398 	sal_Int32 nIntVal = 0;
399 
400 	Sequence<OUString> aNames;
401 	Sequence<Any> aValues;
402 	const Any* pValues = NULL;
403 
404 	aNames = GetLayoutPropertyNames();
405 	aValues = aLayoutItem.GetProperties(aNames);
406 	aLayoutItem.EnableNotification(aNames);
407 	pValues = aValues.getConstArray();
408 	DBG_ASSERT(aValues.getLength() == aNames.getLength(), "GetProperties failed");
409 	if(aValues.getLength() == aNames.getLength())
410 	{
411 		for(int nProp = 0; nProp < aNames.getLength(); nProp++)
412 		{
413 			DBG_ASSERT(pValues[nProp].hasValue(), "property value missing");
414 			if(pValues[nProp].hasValue())
415 			{
416 				switch(nProp)
417 				{
418 					case SCLAYOUTOPT_MEASURE:
419 						if (pValues[nProp] >>= nIntVal) SetAppMetric( (FieldUnit) nIntVal );
420 						break;
421 					case SCLAYOUTOPT_STATUSBAR:
422 						if (pValues[nProp] >>= nIntVal) SetStatusFunc( (sal_uInt16) nIntVal );
423 						break;
424 					case SCLAYOUTOPT_ZOOMVAL:
425 						if (pValues[nProp] >>= nIntVal) SetZoom( (sal_uInt16) nIntVal );
426 						break;
427 					case SCLAYOUTOPT_ZOOMTYPE:
428 						if (pValues[nProp] >>= nIntVal) SetZoomType( (SvxZoomType) nIntVal );
429 						break;
430                     case SCLAYOUTOPT_SYNCZOOM:
431                         SetSynchronizeZoom( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
432                         break;
433 				}
434 			}
435 		}
436 	}
437 	aLayoutItem.SetCommitLink( LINK( this, ScAppCfg, LayoutCommitHdl ) );
438 
439 	aNames = GetInputPropertyNames();
440 	aValues = aInputItem.GetProperties(aNames);
441 	aInputItem.EnableNotification(aNames);
442 	pValues = aValues.getConstArray();
443 	DBG_ASSERT(aValues.getLength() == aNames.getLength(), "GetProperties failed");
444 	if(aValues.getLength() == aNames.getLength())
445 	{
446 		for(int nProp = 0; nProp < aNames.getLength(); nProp++)
447 		{
448 			DBG_ASSERT(pValues[nProp].hasValue(), "property value missing");
449 			if(pValues[nProp].hasValue())
450 			{
451 				switch(nProp)
452 				{
453 					case SCINPUTOPT_LASTFUNCS:
454 						lcl_SetLastFunctions( *this, pValues[nProp] );
455 						break;
456 					case SCINPUTOPT_AUTOINPUT:
457 						SetAutoComplete( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
458 						break;
459 					case SCINPUTOPT_DET_AUTO:
460 						SetDetectiveAuto( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
461 						break;
462 				}
463 			}
464 		}
465 	}
466 	aInputItem.SetCommitLink( LINK( this, ScAppCfg, InputCommitHdl ) );
467 
468 	aNames = GetRevisionPropertyNames();
469 	aValues = aRevisionItem.GetProperties(aNames);
470 	aRevisionItem.EnableNotification(aNames);
471 	pValues = aValues.getConstArray();
472 	DBG_ASSERT(aValues.getLength() == aNames.getLength(), "GetProperties failed");
473 	if(aValues.getLength() == aNames.getLength())
474 	{
475 		for(int nProp = 0; nProp < aNames.getLength(); nProp++)
476 		{
477 			DBG_ASSERT(pValues[nProp].hasValue(), "property value missing");
478 			if(pValues[nProp].hasValue())
479 			{
480 				switch(nProp)
481 				{
482 					case SCREVISOPT_CHANGE:
483 						if (pValues[nProp] >>= nIntVal) SetTrackContentColor( (sal_uInt32) nIntVal );
484 						break;
485 					case SCREVISOPT_INSERTION:
486 						if (pValues[nProp] >>= nIntVal) SetTrackInsertColor( (sal_uInt32) nIntVal );
487 						break;
488 					case SCREVISOPT_DELETION:
489 						if (pValues[nProp] >>= nIntVal) SetTrackDeleteColor( (sal_uInt32) nIntVal );
490 						break;
491 					case SCREVISOPT_MOVEDENTRY:
492 						if (pValues[nProp] >>= nIntVal) SetTrackMoveColor( (sal_uInt32) nIntVal );
493 						break;
494 				}
495 			}
496 		}
497 	}
498 	aRevisionItem.SetCommitLink( LINK( this, ScAppCfg, RevisionCommitHdl ) );
499 
500 	aNames = GetContentPropertyNames();
501 	aValues = aContentItem.GetProperties(aNames);
502 	aContentItem.EnableNotification(aNames);
503 	pValues = aValues.getConstArray();
504 	DBG_ASSERT(aValues.getLength() == aNames.getLength(), "GetProperties failed");
505 	if(aValues.getLength() == aNames.getLength())
506 	{
507 		for(int nProp = 0; nProp < aNames.getLength(); nProp++)
508 		{
509 			DBG_ASSERT(pValues[nProp].hasValue(), "property value missing");
510 			if(pValues[nProp].hasValue())
511 			{
512 				switch(nProp)
513 				{
514 					case SCCONTENTOPT_LINK:
515 						if (pValues[nProp] >>= nIntVal) SetLinkMode( (ScLkUpdMode) nIntVal );
516 						break;
517 				}
518 			}
519 		}
520 	}
521 	aContentItem.SetCommitLink( LINK( this, ScAppCfg, ContentCommitHdl ) );
522 
523 	aNames = GetSortListPropertyNames();
524 	aValues = aSortListItem.GetProperties(aNames);
525 	aSortListItem.EnableNotification(aNames);
526 	pValues = aValues.getConstArray();
527 	DBG_ASSERT(aValues.getLength() == aNames.getLength(), "GetProperties failed");
528 	if(aValues.getLength() == aNames.getLength())
529 	{
530 		for(int nProp = 0; nProp < aNames.getLength(); nProp++)
531 		{
532 			DBG_ASSERT(pValues[nProp].hasValue(), "property value missing");
533 			if(pValues[nProp].hasValue())
534 			{
535 				switch(nProp)
536 				{
537 					case SCSORTLISTOPT_LIST:
538 						lcl_SetSortList( pValues[nProp] );
539 						break;
540 				}
541 			}
542 		}
543 	}
544 	aSortListItem.SetCommitLink( LINK( this, ScAppCfg, SortListCommitHdl ) );
545 
546 	aNames = GetMiscPropertyNames();
547 	aValues = aMiscItem.GetProperties(aNames);
548 	aMiscItem.EnableNotification(aNames);
549 	pValues = aValues.getConstArray();
550 	DBG_ASSERT(aValues.getLength() == aNames.getLength(), "GetProperties failed");
551 	if(aValues.getLength() == aNames.getLength())
552 	{
553 		for(int nProp = 0; nProp < aNames.getLength(); nProp++)
554 		{
555 			DBG_ASSERT(pValues[nProp].hasValue(), "property value missing");
556 			if(pValues[nProp].hasValue())
557 			{
558 				switch(nProp)
559 				{
560 					case SCMISCOPT_DEFOBJWIDTH:
561 						if (pValues[nProp] >>= nIntVal) SetDefaultObjectSizeWidth( nIntVal );
562 						break;
563 					case SCMISCOPT_DEFOBJHEIGHT:
564 						if (pValues[nProp] >>= nIntVal) SetDefaultObjectSizeHeight( nIntVal );
565 						break;
566                     case SCMISCOPT_SHOWSHAREDDOCWARN:
567                         SetShowSharedDocumentWarning( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
568                         break;
569                 }
570 			}
571 		}
572 	}
573 	aMiscItem.SetCommitLink( LINK( this, ScAppCfg, MiscCommitHdl ) );
574 }
575 
576 IMPL_LINK( ScAppCfg, LayoutCommitHdl, void *, EMPTYARG )
577 {
578 	Sequence<OUString> aNames = GetLayoutPropertyNames();
579 	Sequence<Any> aValues(aNames.getLength());
580 	Any* pValues = aValues.getArray();
581 
582 	for(int nProp = 0; nProp < aNames.getLength(); nProp++)
583 	{
584 		switch(nProp)
585 		{
586 			case SCLAYOUTOPT_MEASURE:
587 				pValues[nProp] <<= (sal_Int32) GetAppMetric();
588 				break;
589 			case SCLAYOUTOPT_STATUSBAR:
590 				pValues[nProp] <<= (sal_Int32) GetStatusFunc();
591 				break;
592 			case SCLAYOUTOPT_ZOOMVAL:
593 				pValues[nProp] <<= (sal_Int32) GetZoom();
594 				break;
595 			case SCLAYOUTOPT_ZOOMTYPE:
596 				pValues[nProp] <<= (sal_Int32) GetZoomType();
597 				break;
598             case SCLAYOUTOPT_SYNCZOOM:
599                 ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetSynchronizeZoom() );
600                 break;
601 		}
602 	}
603 	aLayoutItem.PutProperties(aNames, aValues);
604 
605 	return 0;
606 }
607 
608 IMPL_LINK( ScAppCfg, InputCommitHdl, void *, EMPTYARG )
609 {
610 	Sequence<OUString> aNames = GetInputPropertyNames();
611 	Sequence<Any> aValues(aNames.getLength());
612 	Any* pValues = aValues.getArray();
613 
614 	for(int nProp = 0; nProp < aNames.getLength(); nProp++)
615 	{
616 		switch(nProp)
617 		{
618 			case SCINPUTOPT_LASTFUNCS:
619 				lcl_GetLastFunctions( pValues[nProp], *this );
620 				break;
621 			case SCINPUTOPT_AUTOINPUT:
622 				ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetAutoComplete() );
623 				break;
624 			case SCINPUTOPT_DET_AUTO:
625 				ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetDetectiveAuto() );
626 				break;
627 		}
628 	}
629 	aInputItem.PutProperties(aNames, aValues);
630 
631 	return 0;
632 }
633 
634 IMPL_LINK( ScAppCfg, RevisionCommitHdl, void *, EMPTYARG )
635 {
636 	Sequence<OUString> aNames = GetRevisionPropertyNames();
637 	Sequence<Any> aValues(aNames.getLength());
638 	Any* pValues = aValues.getArray();
639 
640 	for(int nProp = 0; nProp < aNames.getLength(); nProp++)
641 	{
642 		switch(nProp)
643 		{
644 			case SCREVISOPT_CHANGE:
645 				pValues[nProp] <<= (sal_Int32) GetTrackContentColor();
646 				break;
647 			case SCREVISOPT_INSERTION:
648 				pValues[nProp] <<= (sal_Int32) GetTrackInsertColor();
649 				break;
650 			case SCREVISOPT_DELETION:
651 				pValues[nProp] <<= (sal_Int32) GetTrackDeleteColor();
652 				break;
653 			case SCREVISOPT_MOVEDENTRY:
654 				pValues[nProp] <<= (sal_Int32) GetTrackMoveColor();
655 				break;
656 		}
657 	}
658 	aRevisionItem.PutProperties(aNames, aValues);
659 
660 	return 0;
661 }
662 
663 IMPL_LINK( ScAppCfg, ContentCommitHdl, void *, EMPTYARG )
664 {
665 	Sequence<OUString> aNames = GetContentPropertyNames();
666 	Sequence<Any> aValues(aNames.getLength());
667 	Any* pValues = aValues.getArray();
668 
669 	for(int nProp = 0; nProp < aNames.getLength(); nProp++)
670 	{
671 		switch(nProp)
672 		{
673 			case SCCONTENTOPT_LINK:
674 				pValues[nProp] <<= (sal_Int32) GetLinkMode();
675 				break;
676 		}
677 	}
678 	aContentItem.PutProperties(aNames, aValues);
679 
680 	return 0;
681 }
682 
683 IMPL_LINK( ScAppCfg, SortListCommitHdl, void *, EMPTYARG )
684 {
685 	Sequence<OUString> aNames = GetSortListPropertyNames();
686 	Sequence<Any> aValues(aNames.getLength());
687 	Any* pValues = aValues.getArray();
688 
689 	for(int nProp = 0; nProp < aNames.getLength(); nProp++)
690 	{
691 		switch(nProp)
692 		{
693 			case SCSORTLISTOPT_LIST:
694 				lcl_GetSortList( pValues[nProp] );
695 				break;
696 		}
697 	}
698 	aSortListItem.PutProperties(aNames, aValues);
699 
700 	return 0;
701 }
702 
703 IMPL_LINK( ScAppCfg, MiscCommitHdl, void *, EMPTYARG )
704 {
705 	Sequence<OUString> aNames = GetMiscPropertyNames();
706 	Sequence<Any> aValues(aNames.getLength());
707 	Any* pValues = aValues.getArray();
708 
709 	for(int nProp = 0; nProp < aNames.getLength(); nProp++)
710 	{
711 		switch(nProp)
712 		{
713 			case SCMISCOPT_DEFOBJWIDTH:
714 				pValues[nProp] <<= (sal_Int32) GetDefaultObjectSizeWidth();
715 				break;
716 			case SCMISCOPT_DEFOBJHEIGHT:
717 				pValues[nProp] <<= (sal_Int32) GetDefaultObjectSizeHeight();
718 				break;
719             case SCMISCOPT_SHOWSHAREDDOCWARN:
720                 ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetShowSharedDocumentWarning() );
721                 break;
722 		}
723 	}
724 	aMiscItem.PutProperties(aNames, aValues);
725 
726 	return 0;
727 }
728 
729 void ScAppCfg::SetOptions( const ScAppOptions& rNew )
730 {
731 	*(ScAppOptions*)this = rNew;
732 	OptionsChanged();
733 }
734 
735 void ScAppCfg::OptionsChanged()
736 {
737 	aLayoutItem.SetModified();
738 	aInputItem.SetModified();
739 	aRevisionItem.SetModified();
740 	aContentItem.SetModified();
741 	aSortListItem.SetModified();
742 	aMiscItem.SetModified();
743 }
744 
745 
746