xref: /trunk/main/sc/source/core/tool/viewopti.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 #include <vcl/svapp.hxx>
34 
35 #include <com/sun/star/uno/Any.hxx>
36 #include <com/sun/star/uno/Sequence.hxx>
37 
38 #include "global.hxx"
39 #include "globstr.hrc"
40 #include "cfgids.hxx"
41 #include "viewopti.hxx"
42 #include "rechead.hxx"
43 #include "scresid.hxx"
44 #include "sc.hrc"
45 #include "miscuno.hxx"
46 
47 using namespace utl;
48 using namespace rtl;
49 using namespace com::sun::star::uno;
50 
51 //------------------------------------------------------------------
52 
53 TYPEINIT1(ScTpViewItem,	SfxPoolItem);
54 
55 #define SC_VERSION ((sal_uInt16)302)
56 
57 
58 //========================================================================
59 // class ScGridOptions
60 //========================================================================
61 
62 
63 void ScGridOptions::SetDefaults()
64 {
65 	*this = ScGridOptions();
66 
67 	//	Raster-Defaults sind jetzt zwischen den Apps unterschiedlich
68 	//	darum hier selber eintragen (alles in 1/100mm)
69 
70 	if ( ScOptionsUtil::IsMetricSystem() )
71 	{
72 		nFldDrawX = 1000;	// 1cm
73 		nFldDrawY = 1000;
74 		nFldSnapX = 1000;
75 		nFldSnapY = 1000;
76 	}
77 	else
78 	{
79 		nFldDrawX = 1270;	// 0,5"
80 		nFldDrawY = 1270;
81 		nFldSnapX = 1270;
82 		nFldSnapY = 1270;
83 	}
84 	nFldDivisionX = 1;
85 	nFldDivisionY = 1;
86 }
87 
88 //------------------------------------------------------------------------
89 
90 const ScGridOptions& ScGridOptions::operator=( const ScGridOptions& rCpy )
91 {
92 	nFldDrawX		= rCpy.nFldDrawX;		// UINT32
93 	nFldDrawX		= rCpy.nFldDrawX;
94 	nFldDivisionX	= rCpy.nFldDivisionX;
95 	nFldDrawY		= rCpy.nFldDrawY;
96 	nFldDivisionY	= rCpy.nFldDivisionY;
97 	nFldSnapX		= rCpy.nFldSnapX;
98 	nFldSnapY		= rCpy.nFldSnapY;
99 	bUseGridsnap	= rCpy.bUseGridsnap;	// BitBool
100 	bSynchronize	= rCpy.bSynchronize;
101 	bGridVisible	= rCpy.bGridVisible;
102 	bEqualGrid		= rCpy.bEqualGrid;
103 
104 	return *this;
105 }
106 
107 //------------------------------------------------------------------------
108 
109 int ScGridOptions::operator==( const ScGridOptions& rCpy ) const
110 {
111 	return (   nFldDrawX		== rCpy.nFldDrawX
112 			&& nFldDrawX		== rCpy.nFldDrawX
113 			&& nFldDivisionX	== rCpy.nFldDivisionX
114 			&& nFldDrawY		== rCpy.nFldDrawY
115 			&& nFldDivisionY	== rCpy.nFldDivisionY
116 			&& nFldSnapX		== rCpy.nFldSnapX
117 			&& nFldSnapY		== rCpy.nFldSnapY
118 			&& bUseGridsnap		== rCpy.bUseGridsnap
119 			&& bSynchronize		== rCpy.bSynchronize
120 			&& bGridVisible		== rCpy.bGridVisible
121 			&& bEqualGrid		== rCpy.bEqualGrid );
122 }
123 
124 
125 //========================================================================
126 // class ScViewOptions
127 //========================================================================
128 
129 ScViewOptions::ScViewOptions()
130 {
131 	SetDefaults();
132 }
133 
134 //------------------------------------------------------------------------
135 
136 ScViewOptions::ScViewOptions( const ScViewOptions& rCpy )
137 {
138 	*this = rCpy;
139 }
140 
141 //------------------------------------------------------------------------
142 
143 __EXPORT ScViewOptions::~ScViewOptions()
144 {
145 }
146 
147 //------------------------------------------------------------------------
148 
149 void ScViewOptions::SetDefaults()
150 {
151 	aOptArr[ VOPT_FORMULAS	  ] =
152 	aOptArr[ VOPT_SYNTAX	  ] =
153 	aOptArr[ VOPT_HELPLINES   ] =
154 	aOptArr[ VOPT_BIGHANDLES  ] = sal_False;
155 	aOptArr[ VOPT_NOTES		  ] =
156 	aOptArr[ VOPT_NULLVALS	  ] =
157 	aOptArr[ VOPT_VSCROLL	  ] =
158 	aOptArr[ VOPT_HSCROLL	  ] =
159 	aOptArr[ VOPT_TABCONTROLS ] =
160 	aOptArr[ VOPT_OUTLINER	  ] =
161 	aOptArr[ VOPT_HEADER	  ] =
162 	aOptArr[ VOPT_GRID		  ] =
163 	aOptArr[ VOPT_ANCHOR	  ] =
164 	aOptArr[ VOPT_PAGEBREAKS  ] =
165 	aOptArr[ VOPT_SOLIDHANDLES] =
166 	aOptArr[ VOPT_CLIPMARKS	  ] = sal_True;
167 
168 	aModeArr[VOBJ_TYPE_OLE ]  =
169 	aModeArr[VOBJ_TYPE_CHART] =
170 	aModeArr[VOBJ_TYPE_DRAW ] = VOBJ_MODE_SHOW;
171 
172 	aGridCol     = Color( SC_STD_GRIDCOLOR );
173 	aGridColName = ScGlobal::GetRscString( STR_GRIDCOLOR );
174 
175 	aGridOpt.SetDefaults();
176 }
177 
178 //------------------------------------------------------------------------
179 
180 Color ScViewOptions::GetGridColor( String* pStrName ) const
181 {
182 	if ( pStrName )
183 		*pStrName = aGridColName;
184 
185 	return aGridCol;
186 }
187 
188 //------------------------------------------------------------------------
189 
190 const ScViewOptions& ScViewOptions::operator=( const ScViewOptions& rCpy )
191 {
192 	sal_uInt16 i;
193 
194 	for ( i=0; i<MAX_OPT; i++ )	 aOptArr [i] = rCpy.aOptArr[i];
195 	for ( i=0; i<MAX_TYPE; i++ ) aModeArr[i] = rCpy.aModeArr[i];
196 
197 	aGridCol     	= rCpy.aGridCol;
198 	aGridColName 	= rCpy.aGridColName;
199 	aGridOpt		= rCpy.aGridOpt;
200 
201 	return *this;
202 }
203 
204 //------------------------------------------------------------------------
205 
206 int ScViewOptions::operator==( const ScViewOptions& rOpt ) const
207 {
208 	sal_Bool	bEqual = sal_True;
209 	sal_uInt16	i;
210 
211 	for ( i=0; i<MAX_OPT && bEqual; i++ )  bEqual = (aOptArr [i] == rOpt.aOptArr[i]);
212 	for ( i=0; i<MAX_TYPE && bEqual; i++ ) bEqual = (aModeArr[i] == rOpt.aModeArr[i]);
213 
214 	bEqual = bEqual && (aGridCol       == rOpt.aGridCol);
215 	bEqual = bEqual && (aGridColName   == rOpt.aGridColName);
216 	bEqual = bEqual && (aGridOpt 	   == rOpt.aGridOpt);
217 
218 	return bEqual;
219 }
220 
221 //------------------------------------------------------------------------
222 
223 SvxGridItem* ScViewOptions::CreateGridItem( sal_uInt16 nId /* = SID_ATTR_GRID_OPTIONS */ ) const
224 {
225 	SvxGridItem* pItem = new SvxGridItem( nId );
226 
227 	pItem->SetFldDrawX		( aGridOpt.GetFldDrawX() );
228 	pItem->SetFldDivisionX	( aGridOpt.GetFldDivisionX() );
229 	pItem->SetFldDrawY   	( aGridOpt.GetFldDrawY() );
230 	pItem->SetFldDivisionY	( aGridOpt.GetFldDivisionY() );
231 	pItem->SetFldSnapX		( aGridOpt.GetFldSnapX() );
232 	pItem->SetFldSnapY   	( aGridOpt.GetFldSnapY() );
233 	pItem->SetUseGridSnap	( aGridOpt.GetUseGridSnap() );
234 	pItem->SetSynchronize	( aGridOpt.GetSynchronize() );
235 	pItem->SetGridVisible	( aGridOpt.GetGridVisible() );
236 	pItem->SetEqualGrid		( aGridOpt.GetEqualGrid() );
237 
238 	return pItem;
239 }
240 
241 //========================================================================
242 //      ScTpViewItem - Daten fuer die ViewOptions-TabPage
243 //========================================================================
244 
245 //UNUSED2008-05  ScTpViewItem::ScTpViewItem( sal_uInt16 nWhichP ) : SfxPoolItem( nWhichP )
246 //UNUSED2008-05  {
247 //UNUSED2008-05  }
248 
249 //------------------------------------------------------------------------
250 
251 ScTpViewItem::ScTpViewItem( sal_uInt16 nWhichP, const ScViewOptions& rOpt )
252     :   SfxPoolItem ( nWhichP ),
253 		theOptions	( rOpt )
254 {
255 }
256 
257 //------------------------------------------------------------------------
258 
259 ScTpViewItem::ScTpViewItem( const ScTpViewItem& rItem )
260 	:   SfxPoolItem	( rItem ),
261 		theOptions	( rItem.theOptions )
262 {
263 }
264 
265 //------------------------------------------------------------------------
266 
267 __EXPORT ScTpViewItem::~ScTpViewItem()
268 {
269 }
270 
271 //------------------------------------------------------------------------
272 
273 String __EXPORT ScTpViewItem::GetValueText() const
274 {
275 	return String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM("ScTpViewItem") );
276 }
277 
278 //------------------------------------------------------------------------
279 
280 int __EXPORT ScTpViewItem::operator==( const SfxPoolItem& rItem ) const
281 {
282 	DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal Which or Type" );
283 
284 	const ScTpViewItem& rPItem = (const ScTpViewItem&)rItem;
285 
286 	return ( theOptions == rPItem.theOptions );
287 }
288 
289 //------------------------------------------------------------------------
290 
291 SfxPoolItem* __EXPORT ScTpViewItem::Clone( SfxItemPool * ) const
292 {
293 	return new ScTpViewItem( *this );
294 }
295 
296 //==================================================================
297 //	Config Item containing view options
298 //==================================================================
299 
300 #define CFGPATH_LAYOUT		"Office.Calc/Layout"
301 
302 #define SCLAYOUTOPT_GRIDLINES		0
303 #define SCLAYOUTOPT_GRIDCOLOR		1
304 #define SCLAYOUTOPT_PAGEBREAK		2
305 #define SCLAYOUTOPT_GUIDE			3
306 #define SCLAYOUTOPT_SIMPLECONT		4
307 #define SCLAYOUTOPT_LARGECONT		5
308 #define SCLAYOUTOPT_COLROWHDR		6
309 #define SCLAYOUTOPT_HORISCROLL		7
310 #define SCLAYOUTOPT_VERTSCROLL		8
311 #define SCLAYOUTOPT_SHEETTAB		9
312 #define SCLAYOUTOPT_OUTLINE			10
313 #define SCLAYOUTOPT_COUNT			11
314 
315 #define CFGPATH_DISPLAY		"Office.Calc/Content/Display"
316 
317 #define SCDISPLAYOPT_FORMULA		0
318 #define SCDISPLAYOPT_ZEROVALUE		1
319 #define SCDISPLAYOPT_NOTETAG		2
320 #define SCDISPLAYOPT_VALUEHI		3
321 #define SCDISPLAYOPT_ANCHOR			4
322 #define SCDISPLAYOPT_TEXTOVER		5
323 #define SCDISPLAYOPT_OBJECTGRA		6
324 #define SCDISPLAYOPT_CHART			7
325 #define SCDISPLAYOPT_DRAWING		8
326 #define SCDISPLAYOPT_COUNT			9
327 
328 #define CFGPATH_GRID		"Office.Calc/Grid"
329 
330 #define SCGRIDOPT_RESOLU_X			0
331 #define SCGRIDOPT_RESOLU_Y			1
332 #define SCGRIDOPT_SUBDIV_X			2
333 #define SCGRIDOPT_SUBDIV_Y			3
334 #define SCGRIDOPT_OPTION_X			4
335 #define SCGRIDOPT_OPTION_Y			5
336 #define SCGRIDOPT_SNAPTOGRID		6
337 #define SCGRIDOPT_SYNCHRON			7
338 #define SCGRIDOPT_VISIBLE			8
339 #define SCGRIDOPT_SIZETOGRID		9
340 #define SCGRIDOPT_COUNT				10
341 
342 
343 Sequence<OUString> ScViewCfg::GetLayoutPropertyNames()
344 {
345 	static const char* aPropNames[] =
346 	{
347 		"Line/GridLine",			// SCLAYOUTOPT_GRIDLINES
348 		"Line/GridLineColor",		// SCLAYOUTOPT_GRIDCOLOR
349 		"Line/PageBreak",			// SCLAYOUTOPT_PAGEBREAK
350 		"Line/Guide",				// SCLAYOUTOPT_GUIDE
351 		"Line/SimpleControlPoint",	// SCLAYOUTOPT_SIMPLECONT
352 		"Line/LargeControlPoint",	// SCLAYOUTOPT_LARGECONT
353 		"Window/ColumnRowHeader",	// SCLAYOUTOPT_COLROWHDR
354 		"Window/HorizontalScroll",	// SCLAYOUTOPT_HORISCROLL
355 		"Window/VerticalScroll",	// SCLAYOUTOPT_VERTSCROLL
356 		"Window/SheetTab",			// SCLAYOUTOPT_SHEETTAB
357 		"Window/OutlineSymbol"		// SCLAYOUTOPT_OUTLINE
358 	};
359 	Sequence<OUString> aNames(SCLAYOUTOPT_COUNT);
360 	OUString* pNames = aNames.getArray();
361 	for(int i = 0; i < SCLAYOUTOPT_COUNT; i++)
362 		pNames[i] = OUString::createFromAscii(aPropNames[i]);
363 
364 	return aNames;
365 }
366 
367 Sequence<OUString> ScViewCfg::GetDisplayPropertyNames()
368 {
369 	static const char* aPropNames[] =
370 	{
371 		"Formula",					// SCDISPLAYOPT_FORMULA
372 		"ZeroValue",				// SCDISPLAYOPT_ZEROVALUE
373 		"NoteTag",					// SCDISPLAYOPT_NOTETAG
374 		"ValueHighlighting",		// SCDISPLAYOPT_VALUEHI
375 		"Anchor",					// SCDISPLAYOPT_ANCHOR
376 		"TextOverflow",				// SCDISPLAYOPT_TEXTOVER
377 		"ObjectGraphic",			// SCDISPLAYOPT_OBJECTGRA
378 		"Chart",					// SCDISPLAYOPT_CHART
379 		"DrawingObject"				// SCDISPLAYOPT_DRAWING
380 	};
381 	Sequence<OUString> aNames(SCDISPLAYOPT_COUNT);
382 	OUString* pNames = aNames.getArray();
383 	for(int i = 0; i < SCDISPLAYOPT_COUNT; i++)
384 		pNames[i] = OUString::createFromAscii(aPropNames[i]);
385 
386 	return aNames;
387 }
388 
389 Sequence<OUString> ScViewCfg::GetGridPropertyNames()
390 {
391 	static const char* aPropNames[] =
392 	{
393 		"Resolution/XAxis/NonMetric",	// SCGRIDOPT_RESOLU_X
394 		"Resolution/YAxis/NonMetric",	// SCGRIDOPT_RESOLU_Y
395 		"Subdivision/XAxis",			// SCGRIDOPT_SUBDIV_X
396 		"Subdivision/YAxis",			// SCGRIDOPT_SUBDIV_Y
397 		"Option/XAxis/NonMetric",		// SCGRIDOPT_OPTION_X
398 		"Option/YAxis/NonMetric",		// SCGRIDOPT_OPTION_Y
399 		"Option/SnapToGrid",			// SCGRIDOPT_SNAPTOGRID
400 		"Option/Synchronize",			// SCGRIDOPT_SYNCHRON
401 		"Option/VisibleGrid",			// SCGRIDOPT_VISIBLE
402 		"Option/SizeToGrid"				// SCGRIDOPT_SIZETOGRID
403 	};
404 	Sequence<OUString> aNames(SCGRIDOPT_COUNT);
405 	OUString* pNames = aNames.getArray();
406 	for(int i = 0; i < SCGRIDOPT_COUNT; i++)
407 		pNames[i] = OUString::createFromAscii(aPropNames[i]);
408 
409 	//	adjust for metric system
410 	if (ScOptionsUtil::IsMetricSystem())
411 	{
412 		pNames[SCGRIDOPT_RESOLU_X] = OUString::createFromAscii( "Resolution/XAxis/Metric" );
413 		pNames[SCGRIDOPT_RESOLU_Y] = OUString::createFromAscii( "Resolution/YAxis/Metric" );
414 		pNames[SCGRIDOPT_OPTION_X] = OUString::createFromAscii( "Option/XAxis/Metric" );
415 		pNames[SCGRIDOPT_OPTION_Y] = OUString::createFromAscii( "Option/YAxis/Metric" );
416 	}
417 
418 	return aNames;
419 }
420 
421 
422 ScViewCfg::ScViewCfg() :
423 	aLayoutItem( OUString::createFromAscii( CFGPATH_LAYOUT ) ),
424 	aDisplayItem( OUString::createFromAscii( CFGPATH_DISPLAY ) ),
425 	aGridItem( OUString::createFromAscii( CFGPATH_GRID ) )
426 {
427 	sal_Int32 nIntVal = 0;
428 
429 	Sequence<OUString> aNames = GetLayoutPropertyNames();
430 	Sequence<Any> aValues = aLayoutItem.GetProperties(aNames);
431 	aLayoutItem.EnableNotification(aNames);
432 	const Any* pValues = aValues.getConstArray();
433 	DBG_ASSERT(aValues.getLength() == aNames.getLength(), "GetProperties failed");
434 	if(aValues.getLength() == aNames.getLength())
435 	{
436 		for(int nProp = 0; nProp < aNames.getLength(); nProp++)
437 		{
438 			DBG_ASSERT(pValues[nProp].hasValue(), "property value missing");
439 			if(pValues[nProp].hasValue())
440 			{
441 				switch(nProp)
442 				{
443 					case SCLAYOUTOPT_GRIDCOLOR:
444 						if ( pValues[nProp] >>= nIntVal )
445 							SetGridColor( Color(nIntVal), EMPTY_STRING );
446 						break;
447 					case SCLAYOUTOPT_GRIDLINES:
448 						SetOption( VOPT_GRID, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
449 						break;
450 					case SCLAYOUTOPT_PAGEBREAK:
451 						SetOption( VOPT_PAGEBREAKS, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
452 						break;
453 					case SCLAYOUTOPT_GUIDE:
454 						SetOption( VOPT_HELPLINES, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
455 						break;
456 					case SCLAYOUTOPT_SIMPLECONT:
457 						// content is reversed
458 						SetOption( VOPT_SOLIDHANDLES, !ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
459 						break;
460 					case SCLAYOUTOPT_LARGECONT:
461 						SetOption( VOPT_BIGHANDLES, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
462 						break;
463 					case SCLAYOUTOPT_COLROWHDR:
464 						SetOption( VOPT_HEADER, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
465 						break;
466 					case SCLAYOUTOPT_HORISCROLL:
467 						SetOption( VOPT_HSCROLL, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
468 						break;
469 					case SCLAYOUTOPT_VERTSCROLL:
470 						SetOption( VOPT_VSCROLL, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
471 						break;
472 					case SCLAYOUTOPT_SHEETTAB:
473 						SetOption( VOPT_TABCONTROLS, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
474 						break;
475 					case SCLAYOUTOPT_OUTLINE:
476 						SetOption( VOPT_OUTLINER, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
477 						break;
478 				}
479 			}
480 		}
481 	}
482 	aLayoutItem.SetCommitLink( LINK( this, ScViewCfg, LayoutCommitHdl ) );
483 
484 	aNames = GetDisplayPropertyNames();
485 	aValues = aDisplayItem.GetProperties(aNames);
486 	aDisplayItem.EnableNotification(aNames);
487 	pValues = aValues.getConstArray();
488 	DBG_ASSERT(aValues.getLength() == aNames.getLength(), "GetProperties failed");
489 	if(aValues.getLength() == aNames.getLength())
490 	{
491 		for(int nProp = 0; nProp < aNames.getLength(); nProp++)
492 		{
493 			DBG_ASSERT(pValues[nProp].hasValue(), "property value missing");
494 			if(pValues[nProp].hasValue())
495 			{
496 				switch(nProp)
497 				{
498 					case SCDISPLAYOPT_FORMULA:
499 						SetOption( VOPT_FORMULAS, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
500 						break;
501 					case SCDISPLAYOPT_ZEROVALUE:
502 						SetOption( VOPT_NULLVALS, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
503 						break;
504 					case SCDISPLAYOPT_NOTETAG:
505 						SetOption( VOPT_NOTES, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
506 						break;
507 					case SCDISPLAYOPT_VALUEHI:
508 						SetOption( VOPT_SYNTAX, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
509 						break;
510 					case SCDISPLAYOPT_ANCHOR:
511 						SetOption( VOPT_ANCHOR, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
512 						break;
513 					case SCDISPLAYOPT_TEXTOVER:
514 						SetOption( VOPT_CLIPMARKS, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
515 						break;
516 					case SCDISPLAYOPT_OBJECTGRA:
517 						if ( pValues[nProp] >>= nIntVal )
518 						{
519 							//#i80528# adapt to new range eventually
520 							if((sal_Int32)VOBJ_MODE_HIDE < nIntVal) nIntVal = (sal_Int32)VOBJ_MODE_SHOW;
521 
522 							SetObjMode( VOBJ_TYPE_OLE, (ScVObjMode)nIntVal);
523 						}
524 						break;
525 					case SCDISPLAYOPT_CHART:
526 						if ( pValues[nProp] >>= nIntVal )
527 						{
528 							//#i80528# adapt to new range eventually
529 							if((sal_Int32)VOBJ_MODE_HIDE < nIntVal) nIntVal = (sal_Int32)VOBJ_MODE_SHOW;
530 
531 							SetObjMode( VOBJ_TYPE_CHART, (ScVObjMode)nIntVal);
532 						}
533 						break;
534 					case SCDISPLAYOPT_DRAWING:
535 						if ( pValues[nProp] >>= nIntVal )
536 						{
537 							//#i80528# adapt to new range eventually
538 							if((sal_Int32)VOBJ_MODE_HIDE < nIntVal) nIntVal = (sal_Int32)VOBJ_MODE_SHOW;
539 
540 							SetObjMode( VOBJ_TYPE_DRAW, (ScVObjMode)nIntVal);
541 						}
542 						break;
543 				}
544 			}
545 		}
546 	}
547 	aDisplayItem.SetCommitLink( LINK( this, ScViewCfg, DisplayCommitHdl ) );
548 
549 	ScGridOptions aGrid = GetGridOptions();		//! initialization necessary?
550 	aNames = GetGridPropertyNames();
551 	aValues = aGridItem.GetProperties(aNames);
552 	aGridItem.EnableNotification(aNames);
553 	pValues = aValues.getConstArray();
554 	DBG_ASSERT(aValues.getLength() == aNames.getLength(), "GetProperties failed");
555 	if(aValues.getLength() == aNames.getLength())
556 	{
557 		for(int nProp = 0; nProp < aNames.getLength(); nProp++)
558 		{
559 			DBG_ASSERT(pValues[nProp].hasValue(), "property value missing");
560 			if(pValues[nProp].hasValue())
561 			{
562 				switch(nProp)
563 				{
564 					case SCGRIDOPT_RESOLU_X:
565 						if (pValues[nProp] >>= nIntVal) aGrid.SetFldDrawX( nIntVal );
566 						break;
567 					case SCGRIDOPT_RESOLU_Y:
568 						if (pValues[nProp] >>= nIntVal) aGrid.SetFldDrawY( nIntVal );
569 						break;
570 					case SCGRIDOPT_SUBDIV_X:
571 						if (pValues[nProp] >>= nIntVal) aGrid.SetFldDivisionX( nIntVal );
572 						break;
573 					case SCGRIDOPT_SUBDIV_Y:
574 						if (pValues[nProp] >>= nIntVal) aGrid.SetFldDivisionY( nIntVal );
575 						break;
576 					case SCGRIDOPT_OPTION_X:
577 						if (pValues[nProp] >>= nIntVal) aGrid.SetFldSnapX( nIntVal );
578 						break;
579 					case SCGRIDOPT_OPTION_Y:
580 						if (pValues[nProp] >>= nIntVal) aGrid.SetFldSnapY( nIntVal );
581 						break;
582 					case SCGRIDOPT_SNAPTOGRID:
583 						aGrid.SetUseGridSnap( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
584 						break;
585 					case SCGRIDOPT_SYNCHRON:
586 						aGrid.SetSynchronize( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
587 						break;
588 					case SCGRIDOPT_VISIBLE:
589 						aGrid.SetGridVisible( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
590 						break;
591 					case SCGRIDOPT_SIZETOGRID:
592 						aGrid.SetEqualGrid( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
593 						break;
594 				}
595 			}
596 		}
597 	}
598 	SetGridOptions( aGrid );
599 	aGridItem.SetCommitLink( LINK( this, ScViewCfg, GridCommitHdl ) );
600 }
601 
602 IMPL_LINK( ScViewCfg, LayoutCommitHdl, void *, EMPTYARG )
603 {
604 	Sequence<OUString> aNames = GetLayoutPropertyNames();
605 	Sequence<Any> aValues(aNames.getLength());
606 	Any* pValues = aValues.getArray();
607 
608 	for(int nProp = 0; nProp < aNames.getLength(); nProp++)
609 	{
610 		switch(nProp)
611 		{
612 			case SCLAYOUTOPT_GRIDCOLOR:
613 				pValues[nProp] <<= (sal_Int32) GetGridColor().GetColor();
614 				break;
615 			case SCLAYOUTOPT_GRIDLINES:
616 				ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetOption( VOPT_GRID ) );
617 				break;
618 			case SCLAYOUTOPT_PAGEBREAK:
619 				ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetOption( VOPT_PAGEBREAKS ) );
620 				break;
621 			case SCLAYOUTOPT_GUIDE:
622 				ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetOption( VOPT_HELPLINES ) );
623 				break;
624 			case SCLAYOUTOPT_SIMPLECONT:
625 				// content is reversed
626 				ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], !GetOption( VOPT_SOLIDHANDLES ) );
627 				break;
628 			case SCLAYOUTOPT_LARGECONT:
629 				ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetOption( VOPT_BIGHANDLES ) );
630 				break;
631 			case SCLAYOUTOPT_COLROWHDR:
632 				ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetOption( VOPT_HEADER ) );
633 				break;
634 			case SCLAYOUTOPT_HORISCROLL:
635 				ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetOption( VOPT_HSCROLL ) );
636 				break;
637 			case SCLAYOUTOPT_VERTSCROLL:
638 				ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetOption( VOPT_VSCROLL ) );
639 				break;
640 			case SCLAYOUTOPT_SHEETTAB:
641 				ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetOption( VOPT_TABCONTROLS ) );
642 				break;
643 			case SCLAYOUTOPT_OUTLINE:
644 				ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetOption( VOPT_OUTLINER ) );
645 				break;
646 		}
647 	}
648 	aLayoutItem.PutProperties(aNames, aValues);
649 
650 	return 0;
651 }
652 
653 IMPL_LINK( ScViewCfg, DisplayCommitHdl, void *, EMPTYARG )
654 {
655 	Sequence<OUString> aNames = GetDisplayPropertyNames();
656 	Sequence<Any> aValues(aNames.getLength());
657 	Any* pValues = aValues.getArray();
658 
659 	for(int nProp = 0; nProp < aNames.getLength(); nProp++)
660 	{
661 		switch(nProp)
662 		{
663 			case SCDISPLAYOPT_FORMULA:
664 				ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetOption( VOPT_FORMULAS ) );
665 				break;
666 			case SCDISPLAYOPT_ZEROVALUE:
667 				ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetOption( VOPT_NULLVALS ) );
668 				break;
669 			case SCDISPLAYOPT_NOTETAG:
670 				ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetOption( VOPT_NOTES ) );
671 				break;
672 			case SCDISPLAYOPT_VALUEHI:
673 				ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetOption( VOPT_SYNTAX ) );
674 				break;
675 			case SCDISPLAYOPT_ANCHOR:
676 				ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetOption( VOPT_ANCHOR ) );
677 				break;
678 			case SCDISPLAYOPT_TEXTOVER:
679 				ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetOption( VOPT_CLIPMARKS ) );
680 				break;
681 			case SCDISPLAYOPT_OBJECTGRA:
682 				pValues[nProp] <<= (sal_Int32) GetObjMode( VOBJ_TYPE_OLE );
683 				break;
684 			case SCDISPLAYOPT_CHART:
685 				pValues[nProp] <<= (sal_Int32) GetObjMode( VOBJ_TYPE_CHART );
686 				break;
687 			case SCDISPLAYOPT_DRAWING:
688 				pValues[nProp] <<= (sal_Int32) GetObjMode( VOBJ_TYPE_DRAW );
689 				break;
690 		}
691 	}
692 	aDisplayItem.PutProperties(aNames, aValues);
693 
694 	return 0;
695 }
696 
697 IMPL_LINK( ScViewCfg, GridCommitHdl, void *, EMPTYARG )
698 {
699 	const ScGridOptions& rGrid = GetGridOptions();
700 
701 	Sequence<OUString> aNames = GetGridPropertyNames();
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 SCGRIDOPT_RESOLU_X:
710 				pValues[nProp] <<= (sal_Int32) rGrid.GetFldDrawX();
711 				break;
712 			case SCGRIDOPT_RESOLU_Y:
713 				pValues[nProp] <<= (sal_Int32) rGrid.GetFldDrawY();
714 				break;
715 			case SCGRIDOPT_SUBDIV_X:
716 				pValues[nProp] <<= (sal_Int32) rGrid.GetFldDivisionX();
717 				break;
718 			case SCGRIDOPT_SUBDIV_Y:
719 				pValues[nProp] <<= (sal_Int32) rGrid.GetFldDivisionY();
720 				break;
721 			case SCGRIDOPT_OPTION_X:
722 				pValues[nProp] <<= (sal_Int32) rGrid.GetFldSnapX();
723 				break;
724 			case SCGRIDOPT_OPTION_Y:
725 				pValues[nProp] <<= (sal_Int32) rGrid.GetFldSnapY();
726 				break;
727 			case SCGRIDOPT_SNAPTOGRID:
728 				ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], rGrid.GetUseGridSnap() );
729 				break;
730 			case SCGRIDOPT_SYNCHRON:
731 				ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], rGrid.GetSynchronize() );
732 				break;
733 			case SCGRIDOPT_VISIBLE:
734 				ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], rGrid.GetGridVisible() );
735 				break;
736 			case SCGRIDOPT_SIZETOGRID:
737 				ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], rGrid.GetEqualGrid() );
738 				break;
739 		}
740 	}
741 	aGridItem.PutProperties(aNames, aValues);
742 
743 	return 0;
744 }
745 
746 void ScViewCfg::SetOptions( const ScViewOptions& rNew )
747 {
748 	*(ScViewOptions*)this = rNew;
749 	aLayoutItem.SetModified();
750 	aDisplayItem.SetModified();
751 	aGridItem.SetModified();
752 }
753 
754 
755