Fix rudimentary Emscripten Qt6 copy -> paste support
[LibreOffice.git] / sc / source / core / tool / viewopti.cxx
blobbd2f110640d332639662dcf908140b48943a8f6b
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 <osl/diagnose.h>
22 #include <com/sun/star/uno/Any.hxx>
23 #include <com/sun/star/uno/Sequence.hxx>
25 #include <svtools/colorcfg.hxx>
27 #include <global.hxx>
28 #include <viewopti.hxx>
29 #include <sc.hrc>
30 #include <scmod.hxx>
31 #include <miscuno.hxx>
33 using namespace utl;
34 using namespace com::sun::star::uno;
38 void ScGridOptions::SetDefaults()
40 *this = ScGridOptions();
42 // grid defaults differ now between the apps
43 // therefore, enter here in its own right (all in 1/100mm)
45 if ( ScOptionsUtil::IsMetricSystem() )
47 nFldDrawX = 1000; // 1cm
48 nFldDrawY = 1000;
50 else
52 nFldDrawX = 1270; // 0,5"
53 nFldDrawY = 1270;
55 nFldDivisionX = 1;
56 nFldDivisionY = 1;
59 bool ScGridOptions::operator==( const ScGridOptions& rCpy ) const
61 return ( nFldDrawX == rCpy.nFldDrawX
62 && nFldDivisionX == rCpy.nFldDivisionX
63 && nFldDrawY == rCpy.nFldDrawY
64 && nFldDivisionY == rCpy.nFldDivisionY
65 && bUseGridsnap == rCpy.bUseGridsnap
66 && bSynchronize == rCpy.bSynchronize
67 && bGridVisible == rCpy.bGridVisible
68 && bEqualGrid == rCpy.bEqualGrid );
71 ScViewRenderingOptions::ScViewRenderingOptions()
72 : sColorSchemeName(u"Default"_ustr)
73 , aDocCol(ScModule::get()->GetColorConfig().GetColorValue(svtools::DOCCOLOR).nColor)
77 bool ScViewRenderingOptions::operator==(const ScViewRenderingOptions& rOther) const
79 return sColorSchemeName == rOther.sColorSchemeName &&
80 aDocCol == rOther.aDocCol;
83 ScViewOptions::ScViewOptions()
85 SetDefaults();
88 ScViewOptions::ScViewOptions( const ScViewOptions& rCpy )
90 *this = rCpy;
93 ScViewOptions::~ScViewOptions()
97 void ScViewOptions::SetDefaults()
99 aOptArr[ VOPT_FORMULAS ] = false;
100 aOptArr[ VOPT_SYNTAX ] = false;
101 aOptArr[ VOPT_HELPLINES ] = false;
102 aOptArr[ VOPT_GRID_ONTOP ] = false;
103 aOptArr[ VOPT_NOTES ] = true;
104 aOptArr[ VOPT_NOTEAUTHOR ] = true;
105 aOptArr[ VOPT_FORMULAS_MARKS ] = false;
106 aOptArr[ VOPT_NULLVALS ] = true;
107 aOptArr[ VOPT_VSCROLL ] = true;
108 aOptArr[ VOPT_HSCROLL ] = true;
109 aOptArr[ VOPT_TABCONTROLS ] = true;
110 aOptArr[ VOPT_OUTLINER ] = true;
111 aOptArr[ VOPT_HEADER ] = true;
112 aOptArr[ VOPT_GRID ] = true;
113 aOptArr[ VOPT_ANCHOR ] = true;
114 aOptArr[ VOPT_PAGEBREAKS ] = true;
115 aOptArr[ VOPT_SUMMARY ] = true;
116 aOptArr[ VOPT_COPY_SHEET ] = false;
117 aOptArr[ VOPT_THEMEDCURSOR ] = false;
119 aModeArr[VOBJ_TYPE_OLE ] = VOBJ_MODE_SHOW;
120 aModeArr[VOBJ_TYPE_CHART] = VOBJ_MODE_SHOW;
121 aModeArr[VOBJ_TYPE_DRAW ] = VOBJ_MODE_SHOW;
123 aGridCol = svtools::ColorConfig().GetColorValue( svtools::CALCGRID ).nColor;
125 aGridOpt.SetDefaults();
128 Color const & ScViewOptions::GetGridColor( OUString* pStrName ) const
130 if ( pStrName )
131 *pStrName = aGridColName;
133 return aGridCol;
136 ScViewOptions& ScViewOptions::operator=(const ScViewOptions& rCpy) = default;
138 bool ScViewOptions::operator==( const ScViewOptions& rOpt ) const
140 bool bEqual = true;
141 sal_uInt16 i;
143 for ( i=0; i<MAX_OPT && bEqual; i++ ) bEqual = (aOptArr [i] == rOpt.aOptArr[i]);
144 for ( i=0; i<MAX_TYPE && bEqual; i++ ) bEqual = (aModeArr[i] == rOpt.aModeArr[i]);
146 bEqual = bEqual && (aGridCol == rOpt.aGridCol);
147 bEqual = bEqual && (aGridColName == rOpt.aGridColName);
148 bEqual = bEqual && (aGridOpt == rOpt.aGridOpt);
150 return bEqual;
153 std::unique_ptr<SvxGridItem> ScViewOptions::CreateGridItem() const
155 std::unique_ptr<SvxGridItem> pItem(new SvxGridItem( SID_ATTR_GRID_OPTIONS ));
157 pItem->SetFieldDrawX ( aGridOpt.GetFieldDrawX() );
158 pItem->SetFieldDivisionX ( aGridOpt.GetFieldDivisionX() );
159 pItem->SetFieldDrawY ( aGridOpt.GetFieldDrawY() );
160 pItem->SetFieldDivisionY ( aGridOpt.GetFieldDivisionY() );
161 pItem->SetUseGridSnap ( aGridOpt.GetUseGridSnap() );
162 pItem->SetSynchronize ( aGridOpt.GetSynchronize() );
163 pItem->SetGridVisible ( aGridOpt.GetGridVisible() );
164 pItem->SetEqualGrid ( aGridOpt.GetEqualGrid() );
166 return pItem;
169 // ScTpViewItem - data for the ViewOptions TabPage
171 ScTpViewItem::ScTpViewItem( const ScViewOptions& rOpt )
172 : SfxPoolItem ( SID_SCVIEWOPTIONS, SfxItemType::ScTpViewItemType ),
173 theOptions ( rOpt )
177 ScTpViewItem::~ScTpViewItem()
181 bool ScTpViewItem::operator==( const SfxPoolItem& rItem ) const
183 assert(SfxPoolItem::operator==(rItem));
185 const ScTpViewItem& rPItem = static_cast<const ScTpViewItem&>(rItem);
187 return ( theOptions == rPItem.theOptions );
190 ScTpViewItem* ScTpViewItem::Clone( SfxItemPool * ) const
192 return new ScTpViewItem( *this );
195 // Config Item containing view options
197 constexpr OUStringLiteral CFGPATH_LAYOUT = u"Office.Calc/Layout";
199 #define SCLAYOUTOPT_GRIDLINES 0
200 #define SCLAYOUTOPT_GRIDCOLOR 1
201 #define SCLAYOUTOPT_PAGEBREAK 2
202 #define SCLAYOUTOPT_GUIDE 3
203 #define SCLAYOUTOPT_COLROWHDR 4
204 #define SCLAYOUTOPT_HORISCROLL 5
205 #define SCLAYOUTOPT_VERTSCROLL 6
206 #define SCLAYOUTOPT_SHEETTAB 7
207 #define SCLAYOUTOPT_OUTLINE 8
208 #define SCLAYOUTOPT_GRID_ONCOLOR 9
209 #define SCLAYOUTOPT_SUMMARY 10
210 #define SCLAYOUTOPT_THEMEDCURSOR 11
212 constexpr OUStringLiteral CFGPATH_DISPLAY = u"Office.Calc/Content/Display";
214 #define SCDISPLAYOPT_FORMULA 0
215 #define SCDISPLAYOPT_ZEROVALUE 1
216 #define SCDISPLAYOPT_NOTETAG 2
217 #define SCDISPLAYOPT_NOTEAUTHOR 3
218 #define SCDISPLAYOPT_FORMULAMARK 4
219 #define SCDISPLAYOPT_VALUEHI 5
220 #define SCDISPLAYOPT_ANCHOR 6
221 #define SCDISPLAYOPT_OBJECTGRA 7
222 #define SCDISPLAYOPT_CHART 8
223 #define SCDISPLAYOPT_DRAWING 9
225 constexpr OUStringLiteral CFGPATH_GRID = u"Office.Calc/Grid";
227 #define SCGRIDOPT_RESOLU_X 0
228 #define SCGRIDOPT_RESOLU_Y 1
229 #define SCGRIDOPT_SUBDIV_X 2
230 #define SCGRIDOPT_SUBDIV_Y 3
231 #define SCGRIDOPT_SNAPTOGRID 4
232 #define SCGRIDOPT_SYNCHRON 5
233 #define SCGRIDOPT_VISIBLE 6
234 #define SCGRIDOPT_SIZETOGRID 7
236 Sequence<OUString> ScViewCfg::GetLayoutPropertyNames()
238 return {u"Line/GridLine"_ustr, // SCLAYOUTOPT_GRIDLINES
239 u"Line/GridLineColor"_ustr, // SCLAYOUTOPT_GRIDCOLOR
240 u"Line/PageBreak"_ustr, // SCLAYOUTOPT_PAGEBREAK
241 u"Line/Guide"_ustr, // SCLAYOUTOPT_GUIDE
242 u"Window/ColumnRowHeader"_ustr, // SCLAYOUTOPT_COLROWHDR
243 u"Window/HorizontalScroll"_ustr, // SCLAYOUTOPT_HORISCROLL
244 u"Window/VerticalScroll"_ustr, // SCLAYOUTOPT_VERTSCROLL
245 u"Window/SheetTab"_ustr, // SCLAYOUTOPT_SHEETTAB
246 u"Window/OutlineSymbol"_ustr, // SCLAYOUTOPT_OUTLINE
247 u"Line/GridOnColoredCells"_ustr, // SCLAYOUTOPT_GRID_ONCOLOR;
248 u"Window/SearchSummary"_ustr, // SCLAYOUTOPT_SUMMARY
249 u"Window/ThemedCursor"_ustr}; // SCLAYOUTOPT_THEMEDCURSOR
252 Sequence<OUString> ScViewCfg::GetDisplayPropertyNames()
254 return {u"Formula"_ustr, // SCDISPLAYOPT_FORMULA
255 u"ZeroValue"_ustr, // SCDISPLAYOPT_ZEROVALUE
256 u"NoteTag"_ustr, // SCDISPLAYOPT_NOTETAG
257 u"NoteAuthor"_ustr, // SCDISPLAYOPT_NOTEAUTHOR
258 u"FormulaMark"_ustr, // SCDISPLAYOPT_FORMULAMARK
259 u"ValueHighlighting"_ustr, // SCDISPLAYOPT_VALUEHI
260 u"Anchor"_ustr, // SCDISPLAYOPT_ANCHOR
261 u"ObjectGraphic"_ustr, // SCDISPLAYOPT_OBJECTGRA
262 u"Chart"_ustr, // SCDISPLAYOPT_CHART
263 u"DrawingObject"_ustr}; // SCDISPLAYOPT_DRAWING;
266 Sequence<OUString> ScViewCfg::GetGridPropertyNames()
268 const bool bIsMetric = ScOptionsUtil::IsMetricSystem();
270 return {(bIsMetric ? u"Resolution/XAxis/Metric"_ustr
271 : u"Resolution/XAxis/NonMetric"_ustr), // SCGRIDOPT_RESOLU_X
272 (bIsMetric ? u"Resolution/YAxis/Metric"_ustr
273 : u"Resolution/YAxis/NonMetric"_ustr), // SCGRIDOPT_RESOLU_Y
274 u"Subdivision/XAxis"_ustr, // SCGRIDOPT_SUBDIV_X
275 u"Subdivision/YAxis"_ustr, // SCGRIDOPT_SUBDIV_Y
276 u"Option/SnapToGrid"_ustr, // SCGRIDOPT_SNAPTOGRID
277 u"Option/Synchronize"_ustr, // SCGRIDOPT_SYNCHRON
278 u"Option/VisibleGrid"_ustr, // SCGRIDOPT_VISIBLE
279 u"Option/SizeToGrid"_ustr}; // SCGRIDOPT_SIZETOGRID;
282 ScViewCfg::ScViewCfg() :
283 aLayoutItem( CFGPATH_LAYOUT ),
284 aDisplayItem( CFGPATH_DISPLAY ),
285 aGridItem( CFGPATH_GRID )
287 sal_Int32 nIntVal = 0;
289 Sequence<OUString> aNames = GetLayoutPropertyNames();
290 Sequence<Any> aValues = aLayoutItem.GetProperties(aNames);
291 aLayoutItem.EnableNotification(aNames);
292 const Any* pValues = aValues.getConstArray();
293 OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
294 if(aValues.getLength() == aNames.getLength())
296 for(int nProp = 0; nProp < aNames.getLength(); nProp++)
298 OSL_ENSURE(pValues[nProp].hasValue(), "property value missing");
299 if(pValues[nProp].hasValue())
301 switch(nProp)
303 case SCLAYOUTOPT_GRIDCOLOR:
305 Color aColor;
306 if ( pValues[nProp] >>= aColor )
307 SetGridColor( aColor, OUString() );
308 break;
310 case SCLAYOUTOPT_GRIDLINES:
311 SetOption( VOPT_GRID, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
312 break;
313 case SCLAYOUTOPT_GRID_ONCOLOR:
314 SetOption( VOPT_GRID_ONTOP, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
315 break;
316 case SCLAYOUTOPT_PAGEBREAK:
317 SetOption( VOPT_PAGEBREAKS, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
318 break;
319 case SCLAYOUTOPT_GUIDE:
320 SetOption( VOPT_HELPLINES, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
321 break;
322 case SCLAYOUTOPT_COLROWHDR:
323 SetOption( VOPT_HEADER, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
324 break;
325 case SCLAYOUTOPT_HORISCROLL:
326 SetOption( VOPT_HSCROLL, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
327 break;
328 case SCLAYOUTOPT_VERTSCROLL:
329 SetOption( VOPT_VSCROLL, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
330 break;
331 case SCLAYOUTOPT_SHEETTAB:
332 SetOption( VOPT_TABCONTROLS, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
333 break;
334 case SCLAYOUTOPT_OUTLINE:
335 SetOption( VOPT_OUTLINER, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
336 break;
337 case SCLAYOUTOPT_SUMMARY:
338 SetOption( VOPT_SUMMARY, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
339 break;
340 case SCLAYOUTOPT_THEMEDCURSOR:
341 SetOption( VOPT_THEMEDCURSOR, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
342 break;
347 aLayoutItem.SetCommitLink( LINK( this, ScViewCfg, LayoutCommitHdl ) );
349 aNames = GetDisplayPropertyNames();
350 aValues = aDisplayItem.GetProperties(aNames);
351 aDisplayItem.EnableNotification(aNames);
352 pValues = aValues.getConstArray();
353 OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
354 if(aValues.getLength() == aNames.getLength())
356 for(int nProp = 0; nProp < aNames.getLength(); nProp++)
358 OSL_ENSURE(pValues[nProp].hasValue(), "property value missing");
359 if(pValues[nProp].hasValue())
361 switch(nProp)
363 case SCDISPLAYOPT_FORMULA:
364 SetOption( VOPT_FORMULAS, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
365 break;
366 case SCDISPLAYOPT_ZEROVALUE:
367 SetOption( VOPT_NULLVALS, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
368 break;
369 case SCDISPLAYOPT_NOTETAG:
370 SetOption( VOPT_NOTES, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
371 break;
372 case SCDISPLAYOPT_NOTEAUTHOR:
373 SetOption( VOPT_NOTEAUTHOR, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
374 break;
375 case SCDISPLAYOPT_FORMULAMARK:
376 SetOption( VOPT_FORMULAS_MARKS, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
377 break;
378 case SCDISPLAYOPT_VALUEHI:
379 SetOption( VOPT_SYNTAX, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
380 break;
381 case SCDISPLAYOPT_ANCHOR:
382 SetOption( VOPT_ANCHOR, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
383 break;
384 case SCDISPLAYOPT_OBJECTGRA:
385 if ( pValues[nProp] >>= nIntVal )
387 //#i80528# adapt to new range eventually
388 if(sal_Int32(VOBJ_MODE_HIDE) < nIntVal) nIntVal = sal_Int32(VOBJ_MODE_SHOW);
390 SetObjMode( VOBJ_TYPE_OLE, static_cast<ScVObjMode>(nIntVal));
392 break;
393 case SCDISPLAYOPT_CHART:
394 if ( pValues[nProp] >>= nIntVal )
396 //#i80528# adapt to new range eventually
397 if(sal_Int32(VOBJ_MODE_HIDE) < nIntVal) nIntVal = sal_Int32(VOBJ_MODE_SHOW);
399 SetObjMode( VOBJ_TYPE_CHART, static_cast<ScVObjMode>(nIntVal));
401 break;
402 case SCDISPLAYOPT_DRAWING:
403 if ( pValues[nProp] >>= nIntVal )
405 //#i80528# adapt to new range eventually
406 if(sal_Int32(VOBJ_MODE_HIDE) < nIntVal) nIntVal = sal_Int32(VOBJ_MODE_SHOW);
408 SetObjMode( VOBJ_TYPE_DRAW, static_cast<ScVObjMode>(nIntVal));
410 break;
415 aDisplayItem.SetCommitLink( LINK( this, ScViewCfg, DisplayCommitHdl ) );
417 aGridItem.EnableNotification(GetGridPropertyNames());
418 ReadGridCfg();
419 aGridItem.SetCommitLink( LINK( this, ScViewCfg, GridCommitHdl ) );
420 aGridItem.SetNotifyLink( LINK( this, ScViewCfg, GridNotifyHdl ) );
423 IMPL_LINK_NOARG(ScViewCfg, LayoutCommitHdl, ScLinkConfigItem&, void)
425 Sequence<OUString> aNames = GetLayoutPropertyNames();
426 Sequence<Any> aValues(aNames.getLength());
427 Any* pValues = aValues.getArray();
429 for(int nProp = 0; nProp < aNames.getLength(); nProp++)
431 switch(nProp)
433 case SCLAYOUTOPT_GRIDCOLOR:
434 pValues[nProp] <<= GetGridColor();
435 break;
436 case SCLAYOUTOPT_GRIDLINES:
437 pValues[nProp] <<= GetOption( VOPT_GRID );
438 break;
439 case SCLAYOUTOPT_GRID_ONCOLOR:
440 pValues[nProp] <<= GetOption( VOPT_GRID_ONTOP );
441 break;
442 case SCLAYOUTOPT_PAGEBREAK:
443 pValues[nProp] <<= GetOption( VOPT_PAGEBREAKS );
444 break;
445 case SCLAYOUTOPT_GUIDE:
446 pValues[nProp] <<= GetOption( VOPT_HELPLINES );
447 break;
448 case SCLAYOUTOPT_COLROWHDR:
449 pValues[nProp] <<= GetOption( VOPT_HEADER );
450 break;
451 case SCLAYOUTOPT_HORISCROLL:
452 pValues[nProp] <<= GetOption( VOPT_HSCROLL );
453 break;
454 case SCLAYOUTOPT_VERTSCROLL:
455 pValues[nProp] <<= GetOption( VOPT_VSCROLL );
456 break;
457 case SCLAYOUTOPT_SHEETTAB:
458 pValues[nProp] <<= GetOption( VOPT_TABCONTROLS );
459 break;
460 case SCLAYOUTOPT_OUTLINE:
461 pValues[nProp] <<= GetOption( VOPT_OUTLINER );
462 break;
463 case SCLAYOUTOPT_SUMMARY:
464 pValues[nProp] <<= GetOption( VOPT_SUMMARY );
465 break;
466 case SCLAYOUTOPT_THEMEDCURSOR:
467 pValues[nProp] <<= GetOption( VOPT_THEMEDCURSOR );
468 break;
471 aLayoutItem.PutProperties(aNames, aValues);
474 IMPL_LINK_NOARG(ScViewCfg, DisplayCommitHdl, ScLinkConfigItem&, void)
476 Sequence<OUString> aNames = GetDisplayPropertyNames();
477 Sequence<Any> aValues(aNames.getLength());
478 Any* pValues = aValues.getArray();
480 for(int nProp = 0; nProp < aNames.getLength(); nProp++)
482 switch(nProp)
484 case SCDISPLAYOPT_FORMULA:
485 pValues[nProp] <<= GetOption( VOPT_FORMULAS );
486 break;
487 case SCDISPLAYOPT_ZEROVALUE:
488 pValues[nProp] <<= GetOption( VOPT_NULLVALS );
489 break;
490 case SCDISPLAYOPT_NOTETAG:
491 pValues[nProp] <<= GetOption( VOPT_NOTES );
492 break;
493 case SCDISPLAYOPT_NOTEAUTHOR:
494 pValues[nProp] <<= GetOption( VOPT_NOTEAUTHOR );
495 break;
496 case SCDISPLAYOPT_FORMULAMARK:
497 pValues[nProp] <<= GetOption( VOPT_FORMULAS_MARKS );
498 break;
499 case SCDISPLAYOPT_VALUEHI:
500 pValues[nProp] <<= GetOption( VOPT_SYNTAX );
501 break;
502 case SCDISPLAYOPT_ANCHOR:
503 pValues[nProp] <<= GetOption( VOPT_ANCHOR );
504 break;
505 case SCDISPLAYOPT_OBJECTGRA:
506 pValues[nProp] <<= static_cast<sal_Int32>(GetObjMode( VOBJ_TYPE_OLE ));
507 break;
508 case SCDISPLAYOPT_CHART:
509 pValues[nProp] <<= static_cast<sal_Int32>(GetObjMode( VOBJ_TYPE_CHART ));
510 break;
511 case SCDISPLAYOPT_DRAWING:
512 pValues[nProp] <<= static_cast<sal_Int32>(GetObjMode( VOBJ_TYPE_DRAW ));
513 break;
516 aDisplayItem.PutProperties(aNames, aValues);
519 void ScViewCfg::ReadGridCfg()
521 const Sequence<OUString> aNames = GetGridPropertyNames();
522 const Sequence<Any> aValues = aGridItem.GetProperties(aNames);
523 OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
524 if (aValues.getLength() != aNames.getLength())
525 return;
527 sal_Int32 nIntVal = 0;
529 ScGridOptions aGrid = GetGridOptions(); //TODO: initialization necessary?
530 const Any* pValues = aValues.getConstArray();
532 for(int nProp = 0; nProp < aNames.getLength(); nProp++)
534 OSL_ENSURE(pValues[nProp].hasValue(), "property value missing");
535 if(pValues[nProp].hasValue())
537 switch(nProp)
539 case SCGRIDOPT_RESOLU_X:
540 if (pValues[nProp] >>= nIntVal) aGrid.SetFieldDrawX( nIntVal );
541 break;
542 case SCGRIDOPT_RESOLU_Y:
543 if (pValues[nProp] >>= nIntVal) aGrid.SetFieldDrawY( nIntVal );
544 break;
545 case SCGRIDOPT_SUBDIV_X:
546 if (pValues[nProp] >>= nIntVal) aGrid.SetFieldDivisionX( nIntVal );
547 break;
548 case SCGRIDOPT_SUBDIV_Y:
549 if (pValues[nProp] >>= nIntVal) aGrid.SetFieldDivisionY( nIntVal );
550 break;
551 case SCGRIDOPT_SNAPTOGRID:
552 aGrid.SetUseGridSnap( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
553 break;
554 case SCGRIDOPT_SYNCHRON:
555 aGrid.SetSynchronize( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
556 break;
557 case SCGRIDOPT_VISIBLE:
558 aGrid.SetGridVisible( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
559 break;
560 case SCGRIDOPT_SIZETOGRID:
561 aGrid.SetEqualGrid( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
562 break;
567 SetGridOptions( aGrid );
570 IMPL_LINK_NOARG(ScViewCfg, GridNotifyHdl, ScLinkConfigItem&, void) { ReadGridCfg(); }
572 IMPL_LINK_NOARG(ScViewCfg, GridCommitHdl, ScLinkConfigItem&, void)
574 const ScGridOptions& rGrid = GetGridOptions();
576 Sequence<OUString> aNames = GetGridPropertyNames();
577 Sequence<Any> aValues(aNames.getLength());
578 Any* pValues = aValues.getArray();
580 for(int nProp = 0; nProp < aNames.getLength(); nProp++)
582 switch(nProp)
584 case SCGRIDOPT_RESOLU_X:
585 pValues[nProp] <<= static_cast<sal_Int32>(rGrid.GetFieldDrawX());
586 break;
587 case SCGRIDOPT_RESOLU_Y:
588 pValues[nProp] <<= static_cast<sal_Int32>(rGrid.GetFieldDrawY());
589 break;
590 case SCGRIDOPT_SUBDIV_X:
591 pValues[nProp] <<= static_cast<sal_Int32>(rGrid.GetFieldDivisionX());
592 break;
593 case SCGRIDOPT_SUBDIV_Y:
594 pValues[nProp] <<= static_cast<sal_Int32>(rGrid.GetFieldDivisionY());
595 break;
596 case SCGRIDOPT_SNAPTOGRID:
597 pValues[nProp] <<= rGrid.GetUseGridSnap();
598 break;
599 case SCGRIDOPT_SYNCHRON:
600 pValues[nProp] <<= rGrid.GetSynchronize();
601 break;
602 case SCGRIDOPT_VISIBLE:
603 pValues[nProp] <<= rGrid.GetGridVisible();
604 break;
605 case SCGRIDOPT_SIZETOGRID:
606 pValues[nProp] <<= rGrid.GetEqualGrid();
607 break;
610 aGridItem.PutProperties(aNames, aValues);
613 void ScViewCfg::SetOptions( const ScViewOptions& rNew )
615 *static_cast<ScViewOptions*>(this) = rNew;
616 aLayoutItem.SetModified();
617 aDisplayItem.SetModified();
618 aGridItem.SetModified();
621 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */