Stop leaking all ScPostIt instances.
[LibreOffice.git] / sc / source / core / tool / viewopti.cxx
blob5d3877ebbfbcc5ada4c75df8cb596d1aac20e3aa
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <vcl/svapp.hxx>
22 #include <com/sun/star/uno/Any.hxx>
23 #include <com/sun/star/uno/Sequence.hxx>
25 #include "global.hxx"
26 #include "globstr.hrc"
27 #include "cfgids.hxx"
28 #include "viewopti.hxx"
29 #include "rechead.hxx"
30 #include "scresid.hxx"
31 #include "sc.hrc"
32 #include "miscuno.hxx"
34 using namespace utl;
35 using namespace com::sun::star::uno;
37 TYPEINIT1(ScTpViewItem, SfxPoolItem);
39 // class ScGridOptions
41 void ScGridOptions::SetDefaults()
43 *this = ScGridOptions();
45 // Raster-Defaults sind jetzt zwischen den Apps unterschiedlich
46 // darum hier selber eintragen (alles in 1/100mm)
48 if ( ScOptionsUtil::IsMetricSystem() )
50 nFldDrawX = 1000; // 1cm
51 nFldDrawY = 1000;
52 nFldSnapX = 1000;
53 nFldSnapY = 1000;
55 else
57 nFldDrawX = 1270; // 0,5"
58 nFldDrawY = 1270;
59 nFldSnapX = 1270;
60 nFldSnapY = 1270;
62 nFldDivisionX = 1;
63 nFldDivisionY = 1;
66 const ScGridOptions& ScGridOptions::operator=( const ScGridOptions& rCpy )
68 nFldDrawX = rCpy.nFldDrawX; // UINT32
69 nFldDivisionX = rCpy.nFldDivisionX;
70 nFldDrawY = rCpy.nFldDrawY;
71 nFldDivisionY = rCpy.nFldDivisionY;
72 nFldSnapX = rCpy.nFldSnapX;
73 nFldSnapY = rCpy.nFldSnapY;
74 bUseGridsnap = rCpy.bUseGridsnap; // BitBool
75 bSynchronize = rCpy.bSynchronize;
76 bGridVisible = rCpy.bGridVisible;
77 bEqualGrid = rCpy.bEqualGrid;
79 return *this;
82 bool ScGridOptions::operator==( const ScGridOptions& rCpy ) const
84 return ( nFldDrawX == rCpy.nFldDrawX
85 && nFldDivisionX == rCpy.nFldDivisionX
86 && nFldDrawY == rCpy.nFldDrawY
87 && nFldDivisionY == rCpy.nFldDivisionY
88 && nFldSnapX == rCpy.nFldSnapX
89 && nFldSnapY == rCpy.nFldSnapY
90 && bUseGridsnap == rCpy.bUseGridsnap
91 && bSynchronize == rCpy.bSynchronize
92 && bGridVisible == rCpy.bGridVisible
93 && bEqualGrid == rCpy.bEqualGrid );
96 // class ScViewOptions
98 ScViewOptions::ScViewOptions()
100 SetDefaults();
103 ScViewOptions::ScViewOptions( const ScViewOptions& rCpy )
105 *this = rCpy;
108 ScViewOptions::~ScViewOptions()
112 void ScViewOptions::SetDefaults()
114 aOptArr[ VOPT_FORMULAS ] = false;
115 aOptArr[ VOPT_SYNTAX ] = false;
116 aOptArr[ VOPT_HELPLINES ] = false;
117 aOptArr[ VOPT_GRID_ONTOP ] = false;
118 aOptArr[ VOPT_NOTES ] = true;
119 aOptArr[ VOPT_NULLVALS ] = true;
120 aOptArr[ VOPT_VSCROLL ] = true;
121 aOptArr[ VOPT_HSCROLL ] = true;
122 aOptArr[ VOPT_TABCONTROLS ] = true;
123 aOptArr[ VOPT_OUTLINER ] = true;
124 aOptArr[ VOPT_HEADER ] = true;
125 aOptArr[ VOPT_GRID ] = true;
126 aOptArr[ VOPT_ANCHOR ] = true;
127 aOptArr[ VOPT_PAGEBREAKS ] = true;
128 aOptArr[ VOPT_CLIPMARKS ] = true;
130 aModeArr[VOBJ_TYPE_OLE ] = VOBJ_MODE_SHOW;
131 aModeArr[VOBJ_TYPE_CHART] = VOBJ_MODE_SHOW;
132 aModeArr[VOBJ_TYPE_DRAW ] = VOBJ_MODE_SHOW;
134 aGridCol = Color( SC_STD_GRIDCOLOR );
135 aGridColName = ScGlobal::GetRscString( STR_GRIDCOLOR );
137 aGridOpt.SetDefaults();
140 Color ScViewOptions::GetGridColor( OUString* pStrName ) const
142 if ( pStrName )
143 *pStrName = aGridColName;
145 return aGridCol;
148 const ScViewOptions& ScViewOptions::operator=( const ScViewOptions& rCpy )
150 sal_uInt16 i;
152 for ( i=0; i<MAX_OPT; i++ ) aOptArr [i] = rCpy.aOptArr[i];
153 for ( i=0; i<MAX_TYPE; i++ ) aModeArr[i] = rCpy.aModeArr[i];
155 aGridCol = rCpy.aGridCol;
156 aGridColName = rCpy.aGridColName;
157 aGridOpt = rCpy.aGridOpt;
159 return *this;
162 int ScViewOptions::operator==( const ScViewOptions& rOpt ) const
164 sal_Bool bEqual = sal_True;
165 sal_uInt16 i;
167 for ( i=0; i<MAX_OPT && bEqual; i++ ) bEqual = (aOptArr [i] == rOpt.aOptArr[i]);
168 for ( i=0; i<MAX_TYPE && bEqual; i++ ) bEqual = (aModeArr[i] == rOpt.aModeArr[i]);
170 bEqual = bEqual && (aGridCol == rOpt.aGridCol);
171 bEqual = bEqual && (aGridColName == rOpt.aGridColName);
172 bEqual = bEqual && (aGridOpt == rOpt.aGridOpt);
174 return bEqual;
177 SvxGridItem* ScViewOptions::CreateGridItem( sal_uInt16 nId /* = SID_ATTR_GRID_OPTIONS */ ) const
179 SvxGridItem* pItem = new SvxGridItem( nId );
181 pItem->SetFldDrawX ( aGridOpt.GetFldDrawX() );
182 pItem->SetFldDivisionX ( aGridOpt.GetFldDivisionX() );
183 pItem->SetFldDrawY ( aGridOpt.GetFldDrawY() );
184 pItem->SetFldDivisionY ( aGridOpt.GetFldDivisionY() );
185 pItem->SetFldSnapX ( aGridOpt.GetFldSnapX() );
186 pItem->SetFldSnapY ( aGridOpt.GetFldSnapY() );
187 pItem->SetUseGridSnap ( aGridOpt.GetUseGridSnap() );
188 pItem->SetSynchronize ( aGridOpt.GetSynchronize() );
189 pItem->SetGridVisible ( aGridOpt.GetGridVisible() );
190 pItem->SetEqualGrid ( aGridOpt.GetEqualGrid() );
192 return pItem;
195 // ScTpViewItem - Daten fuer die ViewOptions-TabPage
197 ScTpViewItem::ScTpViewItem( sal_uInt16 nWhichP, const ScViewOptions& rOpt )
198 : SfxPoolItem ( nWhichP ),
199 theOptions ( rOpt )
203 ScTpViewItem::ScTpViewItem( const ScTpViewItem& rItem )
204 : SfxPoolItem ( rItem ),
205 theOptions ( rItem.theOptions )
209 ScTpViewItem::~ScTpViewItem()
213 OUString ScTpViewItem::GetValueText() const
215 return OUString("ScTpViewItem");
218 int ScTpViewItem::operator==( const SfxPoolItem& rItem ) const
220 OSL_ENSURE( SfxPoolItem::operator==( rItem ), "unequal Which or Type" );
222 const ScTpViewItem& rPItem = (const ScTpViewItem&)rItem;
224 return ( theOptions == rPItem.theOptions );
227 SfxPoolItem* ScTpViewItem::Clone( SfxItemPool * ) const
229 return new ScTpViewItem( *this );
232 // Config Item containing view options
234 #define CFGPATH_LAYOUT "Office.Calc/Layout"
236 #define SCLAYOUTOPT_GRIDLINES 0
237 #define SCLAYOUTOPT_GRIDCOLOR 1
238 #define SCLAYOUTOPT_PAGEBREAK 2
239 #define SCLAYOUTOPT_GUIDE 3
240 #define SCLAYOUTOPT_COLROWHDR 4
241 #define SCLAYOUTOPT_HORISCROLL 5
242 #define SCLAYOUTOPT_VERTSCROLL 6
243 #define SCLAYOUTOPT_SHEETTAB 7
244 #define SCLAYOUTOPT_OUTLINE 8
245 #define SCLAYOUTOPT_GRID_ONCOLOR 9
246 #define SCLAYOUTOPT_COUNT 10
248 #define CFGPATH_DISPLAY "Office.Calc/Content/Display"
250 #define SCDISPLAYOPT_FORMULA 0
251 #define SCDISPLAYOPT_ZEROVALUE 1
252 #define SCDISPLAYOPT_NOTETAG 2
253 #define SCDISPLAYOPT_VALUEHI 3
254 #define SCDISPLAYOPT_ANCHOR 4
255 #define SCDISPLAYOPT_TEXTOVER 5
256 #define SCDISPLAYOPT_OBJECTGRA 6
257 #define SCDISPLAYOPT_CHART 7
258 #define SCDISPLAYOPT_DRAWING 8
259 #define SCDISPLAYOPT_COUNT 9
261 #define CFGPATH_GRID "Office.Calc/Grid"
263 #define SCGRIDOPT_RESOLU_X 0
264 #define SCGRIDOPT_RESOLU_Y 1
265 #define SCGRIDOPT_SUBDIV_X 2
266 #define SCGRIDOPT_SUBDIV_Y 3
267 #define SCGRIDOPT_OPTION_X 4
268 #define SCGRIDOPT_OPTION_Y 5
269 #define SCGRIDOPT_SNAPTOGRID 6
270 #define SCGRIDOPT_SYNCHRON 7
271 #define SCGRIDOPT_VISIBLE 8
272 #define SCGRIDOPT_SIZETOGRID 9
273 #define SCGRIDOPT_COUNT 10
275 Sequence<OUString> ScViewCfg::GetLayoutPropertyNames()
277 static const char* aPropNames[] =
279 "Line/GridLine", // SCLAYOUTOPT_GRIDLINES
280 "Line/GridLineColor", // SCLAYOUTOPT_GRIDCOLOR
281 "Line/PageBreak", // SCLAYOUTOPT_PAGEBREAK
282 "Line/Guide", // SCLAYOUTOPT_GUIDE
283 "Window/ColumnRowHeader", // SCLAYOUTOPT_COLROWHDR
284 "Window/HorizontalScroll", // SCLAYOUTOPT_HORISCROLL
285 "Window/VerticalScroll", // SCLAYOUTOPT_VERTSCROLL
286 "Window/SheetTab", // SCLAYOUTOPT_SHEETTAB
287 "Window/OutlineSymbol", // SCLAYOUTOPT_OUTLINE
288 "Line/GridOnColoredCells" // SCLAYOUTOPT_GRID_ONCOLOR
290 Sequence<OUString> aNames(SCLAYOUTOPT_COUNT);
291 OUString* pNames = aNames.getArray();
292 for(int i = 0; i < SCLAYOUTOPT_COUNT; i++)
293 pNames[i] = OUString::createFromAscii(aPropNames[i]);
295 return aNames;
298 Sequence<OUString> ScViewCfg::GetDisplayPropertyNames()
300 static const char* aPropNames[] =
302 "Formula", // SCDISPLAYOPT_FORMULA
303 "ZeroValue", // SCDISPLAYOPT_ZEROVALUE
304 "NoteTag", // SCDISPLAYOPT_NOTETAG
305 "ValueHighlighting", // SCDISPLAYOPT_VALUEHI
306 "Anchor", // SCDISPLAYOPT_ANCHOR
307 "TextOverflow", // SCDISPLAYOPT_TEXTOVER
308 "ObjectGraphic", // SCDISPLAYOPT_OBJECTGRA
309 "Chart", // SCDISPLAYOPT_CHART
310 "DrawingObject" // SCDISPLAYOPT_DRAWING
312 Sequence<OUString> aNames(SCDISPLAYOPT_COUNT);
313 OUString* pNames = aNames.getArray();
314 for(int i = 0; i < SCDISPLAYOPT_COUNT; i++)
315 pNames[i] = OUString::createFromAscii(aPropNames[i]);
317 return aNames;
320 Sequence<OUString> ScViewCfg::GetGridPropertyNames()
322 static const char* aPropNames[] =
324 "Resolution/XAxis/NonMetric", // SCGRIDOPT_RESOLU_X
325 "Resolution/YAxis/NonMetric", // SCGRIDOPT_RESOLU_Y
326 "Subdivision/XAxis", // SCGRIDOPT_SUBDIV_X
327 "Subdivision/YAxis", // SCGRIDOPT_SUBDIV_Y
328 "Option/XAxis/NonMetric", // SCGRIDOPT_OPTION_X
329 "Option/YAxis/NonMetric", // SCGRIDOPT_OPTION_Y
330 "Option/SnapToGrid", // SCGRIDOPT_SNAPTOGRID
331 "Option/Synchronize", // SCGRIDOPT_SYNCHRON
332 "Option/VisibleGrid", // SCGRIDOPT_VISIBLE
333 "Option/SizeToGrid" // SCGRIDOPT_SIZETOGRID
335 Sequence<OUString> aNames(SCGRIDOPT_COUNT);
336 OUString* pNames = aNames.getArray();
337 for(int i = 0; i < SCGRIDOPT_COUNT; i++)
338 pNames[i] = OUString::createFromAscii(aPropNames[i]);
340 // adjust for metric system
341 if (ScOptionsUtil::IsMetricSystem())
343 pNames[SCGRIDOPT_RESOLU_X] = "Resolution/XAxis/Metric";
344 pNames[SCGRIDOPT_RESOLU_Y] = "Resolution/YAxis/Metric";
345 pNames[SCGRIDOPT_OPTION_X] = "Option/XAxis/Metric";
346 pNames[SCGRIDOPT_OPTION_Y] = "Option/YAxis/Metric";
349 return aNames;
352 ScViewCfg::ScViewCfg() :
353 aLayoutItem( OUString( CFGPATH_LAYOUT ) ),
354 aDisplayItem( OUString( CFGPATH_DISPLAY ) ),
355 aGridItem( OUString( CFGPATH_GRID ) )
357 sal_Int32 nIntVal = 0;
359 Sequence<OUString> aNames = GetLayoutPropertyNames();
360 Sequence<Any> aValues = aLayoutItem.GetProperties(aNames);
361 aLayoutItem.EnableNotification(aNames);
362 const Any* pValues = aValues.getConstArray();
363 OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
364 if(aValues.getLength() == aNames.getLength())
366 for(int nProp = 0; nProp < aNames.getLength(); nProp++)
368 OSL_ENSURE(pValues[nProp].hasValue(), "property value missing");
369 if(pValues[nProp].hasValue())
371 switch(nProp)
373 case SCLAYOUTOPT_GRIDCOLOR:
374 if ( pValues[nProp] >>= nIntVal )
375 SetGridColor( Color(nIntVal), EMPTY_OUSTRING );
376 break;
377 case SCLAYOUTOPT_GRIDLINES:
378 SetOption( VOPT_GRID, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
379 break;
380 case SCLAYOUTOPT_GRID_ONCOLOR:
381 SetOption( VOPT_GRID_ONTOP, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
382 break;
383 case SCLAYOUTOPT_PAGEBREAK:
384 SetOption( VOPT_PAGEBREAKS, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
385 break;
386 case SCLAYOUTOPT_GUIDE:
387 SetOption( VOPT_HELPLINES, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
388 break;
389 case SCLAYOUTOPT_COLROWHDR:
390 SetOption( VOPT_HEADER, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
391 break;
392 case SCLAYOUTOPT_HORISCROLL:
393 SetOption( VOPT_HSCROLL, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
394 break;
395 case SCLAYOUTOPT_VERTSCROLL:
396 SetOption( VOPT_VSCROLL, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
397 break;
398 case SCLAYOUTOPT_SHEETTAB:
399 SetOption( VOPT_TABCONTROLS, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
400 break;
401 case SCLAYOUTOPT_OUTLINE:
402 SetOption( VOPT_OUTLINER, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
403 break;
408 aLayoutItem.SetCommitLink( LINK( this, ScViewCfg, LayoutCommitHdl ) );
410 aNames = GetDisplayPropertyNames();
411 aValues = aDisplayItem.GetProperties(aNames);
412 aDisplayItem.EnableNotification(aNames);
413 pValues = aValues.getConstArray();
414 OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
415 if(aValues.getLength() == aNames.getLength())
417 for(int nProp = 0; nProp < aNames.getLength(); nProp++)
419 OSL_ENSURE(pValues[nProp].hasValue(), "property value missing");
420 if(pValues[nProp].hasValue())
422 switch(nProp)
424 case SCDISPLAYOPT_FORMULA:
425 SetOption( VOPT_FORMULAS, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
426 break;
427 case SCDISPLAYOPT_ZEROVALUE:
428 SetOption( VOPT_NULLVALS, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
429 break;
430 case SCDISPLAYOPT_NOTETAG:
431 SetOption( VOPT_NOTES, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
432 break;
433 case SCDISPLAYOPT_VALUEHI:
434 SetOption( VOPT_SYNTAX, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
435 break;
436 case SCDISPLAYOPT_ANCHOR:
437 SetOption( VOPT_ANCHOR, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
438 break;
439 case SCDISPLAYOPT_TEXTOVER:
440 SetOption( VOPT_CLIPMARKS, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
441 break;
442 case SCDISPLAYOPT_OBJECTGRA:
443 if ( pValues[nProp] >>= nIntVal )
445 //#i80528# adapt to new range eventually
446 if((sal_Int32)VOBJ_MODE_HIDE < nIntVal) nIntVal = (sal_Int32)VOBJ_MODE_SHOW;
448 SetObjMode( VOBJ_TYPE_OLE, (ScVObjMode)nIntVal);
450 break;
451 case SCDISPLAYOPT_CHART:
452 if ( pValues[nProp] >>= nIntVal )
454 //#i80528# adapt to new range eventually
455 if((sal_Int32)VOBJ_MODE_HIDE < nIntVal) nIntVal = (sal_Int32)VOBJ_MODE_SHOW;
457 SetObjMode( VOBJ_TYPE_CHART, (ScVObjMode)nIntVal);
459 break;
460 case SCDISPLAYOPT_DRAWING:
461 if ( pValues[nProp] >>= nIntVal )
463 //#i80528# adapt to new range eventually
464 if((sal_Int32)VOBJ_MODE_HIDE < nIntVal) nIntVal = (sal_Int32)VOBJ_MODE_SHOW;
466 SetObjMode( VOBJ_TYPE_DRAW, (ScVObjMode)nIntVal);
468 break;
473 aDisplayItem.SetCommitLink( LINK( this, ScViewCfg, DisplayCommitHdl ) );
475 ScGridOptions aGrid = GetGridOptions(); //! initialization necessary?
476 aNames = GetGridPropertyNames();
477 aValues = aGridItem.GetProperties(aNames);
478 aGridItem.EnableNotification(aNames);
479 pValues = aValues.getConstArray();
480 OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
481 if(aValues.getLength() == aNames.getLength())
483 for(int nProp = 0; nProp < aNames.getLength(); nProp++)
485 OSL_ENSURE(pValues[nProp].hasValue(), "property value missing");
486 if(pValues[nProp].hasValue())
488 switch(nProp)
490 case SCGRIDOPT_RESOLU_X:
491 if (pValues[nProp] >>= nIntVal) aGrid.SetFldDrawX( nIntVal );
492 break;
493 case SCGRIDOPT_RESOLU_Y:
494 if (pValues[nProp] >>= nIntVal) aGrid.SetFldDrawY( nIntVal );
495 break;
496 case SCGRIDOPT_SUBDIV_X:
497 if (pValues[nProp] >>= nIntVal) aGrid.SetFldDivisionX( nIntVal );
498 break;
499 case SCGRIDOPT_SUBDIV_Y:
500 if (pValues[nProp] >>= nIntVal) aGrid.SetFldDivisionY( nIntVal );
501 break;
502 case SCGRIDOPT_OPTION_X:
503 if (pValues[nProp] >>= nIntVal) aGrid.SetFldSnapX( nIntVal );
504 break;
505 case SCGRIDOPT_OPTION_Y:
506 if (pValues[nProp] >>= nIntVal) aGrid.SetFldSnapY( nIntVal );
507 break;
508 case SCGRIDOPT_SNAPTOGRID:
509 aGrid.SetUseGridSnap( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
510 break;
511 case SCGRIDOPT_SYNCHRON:
512 aGrid.SetSynchronize( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
513 break;
514 case SCGRIDOPT_VISIBLE:
515 aGrid.SetGridVisible( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
516 break;
517 case SCGRIDOPT_SIZETOGRID:
518 aGrid.SetEqualGrid( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
519 break;
524 SetGridOptions( aGrid );
525 aGridItem.SetCommitLink( LINK( this, ScViewCfg, GridCommitHdl ) );
528 IMPL_LINK_NOARG(ScViewCfg, LayoutCommitHdl)
530 Sequence<OUString> aNames = GetLayoutPropertyNames();
531 Sequence<Any> aValues(aNames.getLength());
532 Any* pValues = aValues.getArray();
534 for(int nProp = 0; nProp < aNames.getLength(); nProp++)
536 switch(nProp)
538 case SCLAYOUTOPT_GRIDCOLOR:
539 pValues[nProp] <<= (sal_Int32) GetGridColor().GetColor();
540 break;
541 case SCLAYOUTOPT_GRIDLINES:
542 ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetOption( VOPT_GRID ) );
543 break;
544 case SCLAYOUTOPT_GRID_ONCOLOR:
545 ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetOption( VOPT_GRID_ONTOP ) );
546 break;
547 case SCLAYOUTOPT_PAGEBREAK:
548 ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetOption( VOPT_PAGEBREAKS ) );
549 break;
550 case SCLAYOUTOPT_GUIDE:
551 ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetOption( VOPT_HELPLINES ) );
552 break;
553 case SCLAYOUTOPT_COLROWHDR:
554 ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetOption( VOPT_HEADER ) );
555 break;
556 case SCLAYOUTOPT_HORISCROLL:
557 ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetOption( VOPT_HSCROLL ) );
558 break;
559 case SCLAYOUTOPT_VERTSCROLL:
560 ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetOption( VOPT_VSCROLL ) );
561 break;
562 case SCLAYOUTOPT_SHEETTAB:
563 ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetOption( VOPT_TABCONTROLS ) );
564 break;
565 case SCLAYOUTOPT_OUTLINE:
566 ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetOption( VOPT_OUTLINER ) );
567 break;
570 aLayoutItem.PutProperties(aNames, aValues);
572 return 0;
575 IMPL_LINK_NOARG(ScViewCfg, DisplayCommitHdl)
577 Sequence<OUString> aNames = GetDisplayPropertyNames();
578 Sequence<Any> aValues(aNames.getLength());
579 Any* pValues = aValues.getArray();
581 for(int nProp = 0; nProp < aNames.getLength(); nProp++)
583 switch(nProp)
585 case SCDISPLAYOPT_FORMULA:
586 ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetOption( VOPT_FORMULAS ) );
587 break;
588 case SCDISPLAYOPT_ZEROVALUE:
589 ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetOption( VOPT_NULLVALS ) );
590 break;
591 case SCDISPLAYOPT_NOTETAG:
592 ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetOption( VOPT_NOTES ) );
593 break;
594 case SCDISPLAYOPT_VALUEHI:
595 ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetOption( VOPT_SYNTAX ) );
596 break;
597 case SCDISPLAYOPT_ANCHOR:
598 ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetOption( VOPT_ANCHOR ) );
599 break;
600 case SCDISPLAYOPT_TEXTOVER:
601 ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetOption( VOPT_CLIPMARKS ) );
602 break;
603 case SCDISPLAYOPT_OBJECTGRA:
604 pValues[nProp] <<= (sal_Int32) GetObjMode( VOBJ_TYPE_OLE );
605 break;
606 case SCDISPLAYOPT_CHART:
607 pValues[nProp] <<= (sal_Int32) GetObjMode( VOBJ_TYPE_CHART );
608 break;
609 case SCDISPLAYOPT_DRAWING:
610 pValues[nProp] <<= (sal_Int32) GetObjMode( VOBJ_TYPE_DRAW );
611 break;
614 aDisplayItem.PutProperties(aNames, aValues);
616 return 0;
619 IMPL_LINK_NOARG(ScViewCfg, GridCommitHdl)
621 const ScGridOptions& rGrid = GetGridOptions();
623 Sequence<OUString> aNames = GetGridPropertyNames();
624 Sequence<Any> aValues(aNames.getLength());
625 Any* pValues = aValues.getArray();
627 for(int nProp = 0; nProp < aNames.getLength(); nProp++)
629 switch(nProp)
631 case SCGRIDOPT_RESOLU_X:
632 pValues[nProp] <<= (sal_Int32) rGrid.GetFldDrawX();
633 break;
634 case SCGRIDOPT_RESOLU_Y:
635 pValues[nProp] <<= (sal_Int32) rGrid.GetFldDrawY();
636 break;
637 case SCGRIDOPT_SUBDIV_X:
638 pValues[nProp] <<= (sal_Int32) rGrid.GetFldDivisionX();
639 break;
640 case SCGRIDOPT_SUBDIV_Y:
641 pValues[nProp] <<= (sal_Int32) rGrid.GetFldDivisionY();
642 break;
643 case SCGRIDOPT_OPTION_X:
644 pValues[nProp] <<= (sal_Int32) rGrid.GetFldSnapX();
645 break;
646 case SCGRIDOPT_OPTION_Y:
647 pValues[nProp] <<= (sal_Int32) rGrid.GetFldSnapY();
648 break;
649 case SCGRIDOPT_SNAPTOGRID:
650 ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], rGrid.GetUseGridSnap() );
651 break;
652 case SCGRIDOPT_SYNCHRON:
653 ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], rGrid.GetSynchronize() );
654 break;
655 case SCGRIDOPT_VISIBLE:
656 ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], rGrid.GetGridVisible() );
657 break;
658 case SCGRIDOPT_SIZETOGRID:
659 ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], rGrid.GetEqualGrid() );
660 break;
663 aGridItem.PutProperties(aNames, aValues);
665 return 0;
668 void ScViewCfg::SetOptions( const ScViewOptions& rNew )
670 *(ScViewOptions*)this = rNew;
671 aLayoutItem.SetModified();
672 aDisplayItem.SetModified();
673 aGridItem.SetModified();
676 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */