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