1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #include <vcl/svapp.hxx>
21 #include <osl/diagnose.h>
22 
23 #include <com/sun/star/uno/Any.hxx>
24 #include <com/sun/star/uno/Sequence.hxx>
25 
26 #include <global.hxx>
27 #include <globstr.hrc>
28 #include <scresid.hxx>
29 #include <viewopti.hxx>
30 #include <rechead.hxx>
31 #include <sc.hrc>
32 #include <miscuno.hxx>
33 
34 using namespace utl;
35 using namespace com::sun::star::uno;
36 
37 
38 // class ScGridOptions
39 
SetDefaults()40 void ScGridOptions::SetDefaults()
41 {
42     *this = ScGridOptions();
43 
44     //  grid defaults differ now between the apps
45     //  therefore, enter here in its own right (all in 1/100mm)
46 
47     if ( ScOptionsUtil::IsMetricSystem() )
48     {
49         nFldDrawX = 1000;   // 1cm
50         nFldDrawY = 1000;
51         nFldSnapX = 1000;
52         nFldSnapY = 1000;
53     }
54     else
55     {
56         nFldDrawX = 1270;   // 0,5"
57         nFldDrawY = 1270;
58         nFldSnapX = 1270;
59         nFldSnapY = 1270;
60     }
61     nFldDivisionX = 1;
62     nFldDivisionY = 1;
63 }
64 
operator ==(const ScGridOptions & rCpy) const65 bool ScGridOptions::operator==( const ScGridOptions& rCpy ) const
66 {
67     return (   nFldDrawX        == rCpy.nFldDrawX
68             && nFldDivisionX    == rCpy.nFldDivisionX
69             && nFldDrawY        == rCpy.nFldDrawY
70             && nFldDivisionY    == rCpy.nFldDivisionY
71             && nFldSnapX        == rCpy.nFldSnapX
72             && nFldSnapY        == rCpy.nFldSnapY
73             && bUseGridsnap     == rCpy.bUseGridsnap
74             && bSynchronize     == rCpy.bSynchronize
75             && bGridVisible     == rCpy.bGridVisible
76             && bEqualGrid       == rCpy.bEqualGrid );
77 }
78 
79 // class ScViewOptions
80 
ScViewOptions()81 ScViewOptions::ScViewOptions()
82 {
83     SetDefaults();
84 }
85 
ScViewOptions(const ScViewOptions & rCpy)86 ScViewOptions::ScViewOptions( const ScViewOptions& rCpy )
87 {
88     *this = rCpy;
89 }
90 
~ScViewOptions()91 ScViewOptions::~ScViewOptions()
92 {
93 }
94 
SetDefaults()95 void ScViewOptions::SetDefaults()
96 {
97     aOptArr[ VOPT_FORMULAS    ] = false;
98     aOptArr[ VOPT_SYNTAX      ] = false;
99     aOptArr[ VOPT_HELPLINES   ] = false;
100     aOptArr[ VOPT_GRID_ONTOP  ] = false;
101     aOptArr[ VOPT_NOTES       ] = true;
102     aOptArr[ VOPT_NULLVALS    ] = true;
103     aOptArr[ VOPT_VSCROLL     ] = true;
104     aOptArr[ VOPT_HSCROLL     ] = true;
105     aOptArr[ VOPT_TABCONTROLS ] = true;
106     aOptArr[ VOPT_OUTLINER    ] = true;
107     aOptArr[ VOPT_HEADER      ] = true;
108     aOptArr[ VOPT_GRID        ] = true;
109     aOptArr[ VOPT_ANCHOR      ] = true;
110     aOptArr[ VOPT_PAGEBREAKS  ] = true;
111     aOptArr[ VOPT_CLIPMARKS   ] = true;
112     aOptArr[ VOPT_SUMMARY     ] = true;
113 
114     aModeArr[VOBJ_TYPE_OLE ]  = VOBJ_MODE_SHOW;
115     aModeArr[VOBJ_TYPE_CHART] = VOBJ_MODE_SHOW;
116     aModeArr[VOBJ_TYPE_DRAW ] = VOBJ_MODE_SHOW;
117 
118     aGridCol     = SC_STD_GRIDCOLOR;
119 
120     aGridOpt.SetDefaults();
121 }
122 
GetGridColor(OUString * pStrName) const123 Color const & ScViewOptions::GetGridColor( OUString* pStrName ) const
124 {
125     if ( pStrName )
126         *pStrName = aGridColName;
127 
128     return aGridCol;
129 }
130 
operator =(const ScViewOptions & rCpy)131 ScViewOptions& ScViewOptions::operator=( const ScViewOptions& rCpy )
132 {
133     sal_uInt16 i;
134 
135     for ( i=0; i<MAX_OPT; i++ )  aOptArr [i] = rCpy.aOptArr[i];
136     for ( i=0; i<MAX_TYPE; i++ ) aModeArr[i] = rCpy.aModeArr[i];
137 
138     aGridCol        = rCpy.aGridCol;
139     aGridColName    = rCpy.aGridColName;
140     aGridOpt        = rCpy.aGridOpt;
141 
142     return *this;
143 }
144 
operator ==(const ScViewOptions & rOpt) const145 bool ScViewOptions::operator==( const ScViewOptions& rOpt ) const
146 {
147     bool bEqual = true;
148     sal_uInt16  i;
149 
150     for ( i=0; i<MAX_OPT && bEqual; i++ )  bEqual = (aOptArr [i] == rOpt.aOptArr[i]);
151     for ( i=0; i<MAX_TYPE && bEqual; i++ ) bEqual = (aModeArr[i] == rOpt.aModeArr[i]);
152 
153     bEqual = bEqual && (aGridCol       == rOpt.aGridCol);
154     bEqual = bEqual && (aGridColName   == rOpt.aGridColName);
155     bEqual = bEqual && (aGridOpt       == rOpt.aGridOpt);
156 
157     return bEqual;
158 }
159 
CreateGridItem() const160 std::unique_ptr<SvxGridItem> ScViewOptions::CreateGridItem() const
161 {
162     std::unique_ptr<SvxGridItem> pItem(new SvxGridItem( SID_ATTR_GRID_OPTIONS ));
163 
164     pItem->SetFieldDrawX      ( aGridOpt.GetFieldDrawX() );
165     pItem->SetFieldDivisionX  ( aGridOpt.GetFieldDivisionX() );
166     pItem->SetFieldDrawY      ( aGridOpt.GetFieldDrawY() );
167     pItem->SetFieldDivisionY  ( aGridOpt.GetFieldDivisionY() );
168     pItem->SetFieldSnapX      ( aGridOpt.GetFieldSnapX() );
169     pItem->SetFieldSnapY      ( aGridOpt.GetFieldSnapY() );
170     pItem->SetUseGridSnap   ( aGridOpt.GetUseGridSnap() );
171     pItem->SetSynchronize   ( aGridOpt.GetSynchronize() );
172     pItem->SetGridVisible   ( aGridOpt.GetGridVisible() );
173     pItem->SetEqualGrid     ( aGridOpt.GetEqualGrid() );
174 
175     return pItem;
176 }
177 
178 //      ScTpViewItem - data for the ViewOptions TabPage
179 
ScTpViewItem(const ScViewOptions & rOpt)180 ScTpViewItem::ScTpViewItem( const ScViewOptions& rOpt )
181     :   SfxPoolItem ( SID_SCVIEWOPTIONS ),
182         theOptions  ( rOpt )
183 {
184 }
185 
~ScTpViewItem()186 ScTpViewItem::~ScTpViewItem()
187 {
188 }
189 
operator ==(const SfxPoolItem & rItem) const190 bool ScTpViewItem::operator==( const SfxPoolItem& rItem ) const
191 {
192     assert(SfxPoolItem::operator==(rItem));
193 
194     const ScTpViewItem& rPItem = static_cast<const ScTpViewItem&>(rItem);
195 
196     return ( theOptions == rPItem.theOptions );
197 }
198 
Clone(SfxItemPool *) const199 SfxPoolItem* ScTpViewItem::Clone( SfxItemPool * ) const
200 {
201     return new ScTpViewItem( *this );
202 }
203 
204 //  Config Item containing view options
205 
206 #define CFGPATH_LAYOUT      "Office.Calc/Layout"
207 
208 #define SCLAYOUTOPT_GRIDLINES       0
209 #define SCLAYOUTOPT_GRIDCOLOR       1
210 #define SCLAYOUTOPT_PAGEBREAK       2
211 #define SCLAYOUTOPT_GUIDE           3
212 #define SCLAYOUTOPT_COLROWHDR       4
213 #define SCLAYOUTOPT_HORISCROLL      5
214 #define SCLAYOUTOPT_VERTSCROLL      6
215 #define SCLAYOUTOPT_SHEETTAB        7
216 #define SCLAYOUTOPT_OUTLINE         8
217 #define SCLAYOUTOPT_GRID_ONCOLOR    9
218 #define SCLAYOUTOPT_SUMMARY         10
219 
220 #define CFGPATH_DISPLAY     "Office.Calc/Content/Display"
221 
222 #define SCDISPLAYOPT_FORMULA        0
223 #define SCDISPLAYOPT_ZEROVALUE      1
224 #define SCDISPLAYOPT_NOTETAG        2
225 #define SCDISPLAYOPT_VALUEHI        3
226 #define SCDISPLAYOPT_ANCHOR         4
227 #define SCDISPLAYOPT_TEXTOVER       5
228 #define SCDISPLAYOPT_OBJECTGRA      6
229 #define SCDISPLAYOPT_CHART          7
230 #define SCDISPLAYOPT_DRAWING        8
231 
232 #define CFGPATH_GRID        "Office.Calc/Grid"
233 
234 #define SCGRIDOPT_RESOLU_X          0
235 #define SCGRIDOPT_RESOLU_Y          1
236 #define SCGRIDOPT_SUBDIV_X          2
237 #define SCGRIDOPT_SUBDIV_Y          3
238 #define SCGRIDOPT_OPTION_X          4
239 #define SCGRIDOPT_OPTION_Y          5
240 #define SCGRIDOPT_SNAPTOGRID        6
241 #define SCGRIDOPT_SYNCHRON          7
242 #define SCGRIDOPT_VISIBLE           8
243 #define SCGRIDOPT_SIZETOGRID        9
244 
GetLayoutPropertyNames()245 Sequence<OUString> ScViewCfg::GetLayoutPropertyNames()
246 {
247     return {"Line/GridLine",            // SCLAYOUTOPT_GRIDLINES
248             "Line/GridLineColor",       // SCLAYOUTOPT_GRIDCOLOR
249             "Line/PageBreak",           // SCLAYOUTOPT_PAGEBREAK
250             "Line/Guide",               // SCLAYOUTOPT_GUIDE
251             "Window/ColumnRowHeader",   // SCLAYOUTOPT_COLROWHDR
252             "Window/HorizontalScroll",  // SCLAYOUTOPT_HORISCROLL
253             "Window/VerticalScroll",    // SCLAYOUTOPT_VERTSCROLL
254             "Window/SheetTab",          // SCLAYOUTOPT_SHEETTAB
255             "Window/OutlineSymbol",     // SCLAYOUTOPT_OUTLINE
256             "Line/GridOnColoredCells",  // SCLAYOUTOPT_GRID_ONCOLOR;
257             "Window/SearchSummary"};    // SCLAYOUTOPT_SUMMARY
258 }
259 
GetDisplayPropertyNames()260 Sequence<OUString> ScViewCfg::GetDisplayPropertyNames()
261 {
262     return {"Formula",                  // SCDISPLAYOPT_FORMULA
263             "ZeroValue",                // SCDISPLAYOPT_ZEROVALUE
264             "NoteTag",                  // SCDISPLAYOPT_NOTETAG
265             "ValueHighlighting",        // SCDISPLAYOPT_VALUEHI
266             "Anchor",                   // SCDISPLAYOPT_ANCHOR
267             "TextOverflow",             // SCDISPLAYOPT_TEXTOVER
268             "ObjectGraphic",            // SCDISPLAYOPT_OBJECTGRA
269             "Chart",                    // SCDISPLAYOPT_CHART
270             "DrawingObject"};           // SCDISPLAYOPT_DRAWING;
271 }
272 
GetGridPropertyNames()273 Sequence<OUString> ScViewCfg::GetGridPropertyNames()
274 {
275     const bool bIsMetric = ScOptionsUtil::IsMetricSystem();
276 
277     return {(bIsMetric ? OUString("Resolution/XAxis/Metric")
278                        : OUString("Resolution/XAxis/NonMetric")),   // SCGRIDOPT_RESOLU_X
279             (bIsMetric ? OUString("Resolution/YAxis/Metric")
280                        : OUString("Resolution/YAxis/NonMetric")),   // SCGRIDOPT_RESOLU_Y
281              "Subdivision/XAxis",                                   // SCGRIDOPT_SUBDIV_X
282              "Subdivision/YAxis",                                   // SCGRIDOPT_SUBDIV_Y
283             (bIsMetric ? OUString("Option/XAxis/Metric")
284                        : OUString("Option/XAxis/NonMetric")),       // SCGRIDOPT_OPTION_X
285             (bIsMetric ? OUString("Option/YAxis/Metric")
286                        : OUString("Option/YAxis/NonMetric")),       // SCGRIDOPT_OPTION_Y
287              "Option/SnapToGrid",                                   // SCGRIDOPT_SNAPTOGRID
288              "Option/Synchronize",                                  // SCGRIDOPT_SYNCHRON
289              "Option/VisibleGrid",                                  // SCGRIDOPT_VISIBLE
290              "Option/SizeToGrid"};                                  // SCGRIDOPT_SIZETOGRID;
291 }
292 
ScViewCfg()293 ScViewCfg::ScViewCfg() :
294     aLayoutItem( CFGPATH_LAYOUT ),
295     aDisplayItem( CFGPATH_DISPLAY ),
296     aGridItem( CFGPATH_GRID )
297 {
298     sal_Int32 nIntVal = 0;
299 
300     Sequence<OUString> aNames = GetLayoutPropertyNames();
301     Sequence<Any> aValues = aLayoutItem.GetProperties(aNames);
302     aLayoutItem.EnableNotification(aNames);
303     const Any* pValues = aValues.getConstArray();
304     OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
305     if(aValues.getLength() == aNames.getLength())
306     {
307         for(int nProp = 0; nProp < aNames.getLength(); nProp++)
308         {
309             OSL_ENSURE(pValues[nProp].hasValue(), "property value missing");
310             if(pValues[nProp].hasValue())
311             {
312                 switch(nProp)
313                 {
314                     case SCLAYOUTOPT_GRIDCOLOR:
315                         if ( pValues[nProp] >>= nIntVal )
316                             SetGridColor( Color(nIntVal), EMPTY_OUSTRING );
317                         break;
318                     case SCLAYOUTOPT_GRIDLINES:
319                         SetOption( VOPT_GRID, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
320                         break;
321                     case SCLAYOUTOPT_GRID_ONCOLOR:
322                         SetOption( VOPT_GRID_ONTOP, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
323                         break;
324                     case SCLAYOUTOPT_PAGEBREAK:
325                         SetOption( VOPT_PAGEBREAKS, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
326                         break;
327                     case SCLAYOUTOPT_GUIDE:
328                         SetOption( VOPT_HELPLINES, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
329                         break;
330                     case SCLAYOUTOPT_COLROWHDR:
331                         SetOption( VOPT_HEADER, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
332                         break;
333                     case SCLAYOUTOPT_HORISCROLL:
334                         SetOption( VOPT_HSCROLL, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
335                         break;
336                     case SCLAYOUTOPT_VERTSCROLL:
337                         SetOption( VOPT_VSCROLL, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
338                         break;
339                     case SCLAYOUTOPT_SHEETTAB:
340                         SetOption( VOPT_TABCONTROLS, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
341                         break;
342                     case SCLAYOUTOPT_OUTLINE:
343                         SetOption( VOPT_OUTLINER, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
344                         break;
345                     case SCLAYOUTOPT_SUMMARY:
346                         SetOption( VOPT_SUMMARY, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
347                         break;
348                 }
349             }
350         }
351     }
352     aLayoutItem.SetCommitLink( LINK( this, ScViewCfg, LayoutCommitHdl ) );
353 
354     aNames = GetDisplayPropertyNames();
355     aValues = aDisplayItem.GetProperties(aNames);
356     aDisplayItem.EnableNotification(aNames);
357     pValues = aValues.getConstArray();
358     OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
359     if(aValues.getLength() == aNames.getLength())
360     {
361         for(int nProp = 0; nProp < aNames.getLength(); nProp++)
362         {
363             OSL_ENSURE(pValues[nProp].hasValue(), "property value missing");
364             if(pValues[nProp].hasValue())
365             {
366                 switch(nProp)
367                 {
368                     case SCDISPLAYOPT_FORMULA:
369                         SetOption( VOPT_FORMULAS, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
370                         break;
371                     case SCDISPLAYOPT_ZEROVALUE:
372                         SetOption( VOPT_NULLVALS, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
373                         break;
374                     case SCDISPLAYOPT_NOTETAG:
375                         SetOption( VOPT_NOTES, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
376                         break;
377                     case SCDISPLAYOPT_VALUEHI:
378                         SetOption( VOPT_SYNTAX, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
379                         break;
380                     case SCDISPLAYOPT_ANCHOR:
381                         SetOption( VOPT_ANCHOR, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
382                         break;
383                     case SCDISPLAYOPT_TEXTOVER:
384                         SetOption( VOPT_CLIPMARKS, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
385                         break;
386                     case SCDISPLAYOPT_OBJECTGRA:
387                         if ( pValues[nProp] >>= nIntVal )
388                         {
389                             //#i80528# adapt to new range eventually
390                             if(sal_Int32(VOBJ_MODE_HIDE) < nIntVal) nIntVal = sal_Int32(VOBJ_MODE_SHOW);
391 
392                             SetObjMode( VOBJ_TYPE_OLE, static_cast<ScVObjMode>(nIntVal));
393                         }
394                         break;
395                     case SCDISPLAYOPT_CHART:
396                         if ( pValues[nProp] >>= nIntVal )
397                         {
398                             //#i80528# adapt to new range eventually
399                             if(sal_Int32(VOBJ_MODE_HIDE) < nIntVal) nIntVal = sal_Int32(VOBJ_MODE_SHOW);
400 
401                             SetObjMode( VOBJ_TYPE_CHART, static_cast<ScVObjMode>(nIntVal));
402                         }
403                         break;
404                     case SCDISPLAYOPT_DRAWING:
405                         if ( pValues[nProp] >>= nIntVal )
406                         {
407                             //#i80528# adapt to new range eventually
408                             if(sal_Int32(VOBJ_MODE_HIDE) < nIntVal) nIntVal = sal_Int32(VOBJ_MODE_SHOW);
409 
410                             SetObjMode( VOBJ_TYPE_DRAW, static_cast<ScVObjMode>(nIntVal));
411                         }
412                         break;
413                 }
414             }
415         }
416     }
417     aDisplayItem.SetCommitLink( LINK( this, ScViewCfg, DisplayCommitHdl ) );
418 
419     ScGridOptions aGrid = GetGridOptions();     //TODO: initialization necessary?
420     aNames = GetGridPropertyNames();
421     aValues = aGridItem.GetProperties(aNames);
422     aGridItem.EnableNotification(aNames);
423     pValues = aValues.getConstArray();
424     OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
425     if(aValues.getLength() == aNames.getLength())
426     {
427         for(int nProp = 0; nProp < aNames.getLength(); nProp++)
428         {
429             OSL_ENSURE(pValues[nProp].hasValue(), "property value missing");
430             if(pValues[nProp].hasValue())
431             {
432                 switch(nProp)
433                 {
434                     case SCGRIDOPT_RESOLU_X:
435                         if (pValues[nProp] >>= nIntVal) aGrid.SetFieldDrawX( nIntVal );
436                         break;
437                     case SCGRIDOPT_RESOLU_Y:
438                         if (pValues[nProp] >>= nIntVal) aGrid.SetFieldDrawY( nIntVal );
439                         break;
440                     case SCGRIDOPT_SUBDIV_X:
441                         if (pValues[nProp] >>= nIntVal) aGrid.SetFieldDivisionX( nIntVal );
442                         break;
443                     case SCGRIDOPT_SUBDIV_Y:
444                         if (pValues[nProp] >>= nIntVal) aGrid.SetFieldDivisionY( nIntVal );
445                         break;
446                     case SCGRIDOPT_OPTION_X:
447                         if (pValues[nProp] >>= nIntVal) aGrid.SetFieldSnapX( nIntVal );
448                         break;
449                     case SCGRIDOPT_OPTION_Y:
450                         if (pValues[nProp] >>= nIntVal) aGrid.SetFieldSnapY( nIntVal );
451                         break;
452                     case SCGRIDOPT_SNAPTOGRID:
453                         aGrid.SetUseGridSnap( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
454                         break;
455                     case SCGRIDOPT_SYNCHRON:
456                         aGrid.SetSynchronize( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
457                         break;
458                     case SCGRIDOPT_VISIBLE:
459                         aGrid.SetGridVisible( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
460                         break;
461                     case SCGRIDOPT_SIZETOGRID:
462                         aGrid.SetEqualGrid( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
463                         break;
464                 }
465             }
466         }
467     }
468     SetGridOptions( aGrid );
469     aGridItem.SetCommitLink( LINK( this, ScViewCfg, GridCommitHdl ) );
470 }
471 
IMPL_LINK_NOARG(ScViewCfg,LayoutCommitHdl,ScLinkConfigItem &,void)472 IMPL_LINK_NOARG(ScViewCfg, LayoutCommitHdl, ScLinkConfigItem&, void)
473 {
474     Sequence<OUString> aNames = GetLayoutPropertyNames();
475     Sequence<Any> aValues(aNames.getLength());
476     Any* pValues = aValues.getArray();
477 
478     for(int nProp = 0; nProp < aNames.getLength(); nProp++)
479     {
480         switch(nProp)
481         {
482             case SCLAYOUTOPT_GRIDCOLOR:
483                 pValues[nProp] <<= GetGridColor();
484                 break;
485             case SCLAYOUTOPT_GRIDLINES:
486                 pValues[nProp] <<= GetOption( VOPT_GRID );
487                 break;
488             case SCLAYOUTOPT_GRID_ONCOLOR:
489                 pValues[nProp] <<= GetOption( VOPT_GRID_ONTOP );
490                 break;
491             case SCLAYOUTOPT_PAGEBREAK:
492                 pValues[nProp] <<= GetOption( VOPT_PAGEBREAKS );
493                 break;
494             case SCLAYOUTOPT_GUIDE:
495                 pValues[nProp] <<= GetOption( VOPT_HELPLINES );
496                 break;
497             case SCLAYOUTOPT_COLROWHDR:
498                 pValues[nProp] <<= GetOption( VOPT_HEADER );
499                 break;
500             case SCLAYOUTOPT_HORISCROLL:
501                 pValues[nProp] <<= GetOption( VOPT_HSCROLL );
502                 break;
503             case SCLAYOUTOPT_VERTSCROLL:
504                 pValues[nProp] <<= GetOption( VOPT_VSCROLL );
505                 break;
506             case SCLAYOUTOPT_SHEETTAB:
507                 pValues[nProp] <<= GetOption( VOPT_TABCONTROLS );
508                 break;
509             case SCLAYOUTOPT_OUTLINE:
510                 pValues[nProp] <<= GetOption( VOPT_OUTLINER );
511                 break;
512             case SCLAYOUTOPT_SUMMARY:
513                 pValues[nProp] <<= GetOption( VOPT_SUMMARY );
514                 break;
515         }
516     }
517     aLayoutItem.PutProperties(aNames, aValues);
518 }
519 
IMPL_LINK_NOARG(ScViewCfg,DisplayCommitHdl,ScLinkConfigItem &,void)520 IMPL_LINK_NOARG(ScViewCfg, DisplayCommitHdl, ScLinkConfigItem&, void)
521 {
522     Sequence<OUString> aNames = GetDisplayPropertyNames();
523     Sequence<Any> aValues(aNames.getLength());
524     Any* pValues = aValues.getArray();
525 
526     for(int nProp = 0; nProp < aNames.getLength(); nProp++)
527     {
528         switch(nProp)
529         {
530             case SCDISPLAYOPT_FORMULA:
531                 pValues[nProp] <<= GetOption( VOPT_FORMULAS );
532                 break;
533             case SCDISPLAYOPT_ZEROVALUE:
534                 pValues[nProp] <<= GetOption( VOPT_NULLVALS );
535                 break;
536             case SCDISPLAYOPT_NOTETAG:
537                 pValues[nProp] <<= GetOption( VOPT_NOTES );
538                 break;
539             case SCDISPLAYOPT_VALUEHI:
540                 pValues[nProp] <<= GetOption( VOPT_SYNTAX );
541                 break;
542             case SCDISPLAYOPT_ANCHOR:
543                 pValues[nProp] <<= GetOption( VOPT_ANCHOR );
544                 break;
545             case SCDISPLAYOPT_TEXTOVER:
546                 pValues[nProp] <<= GetOption( VOPT_CLIPMARKS );
547                 break;
548             case SCDISPLAYOPT_OBJECTGRA:
549                 pValues[nProp] <<= static_cast<sal_Int32>(GetObjMode( VOBJ_TYPE_OLE ));
550                 break;
551             case SCDISPLAYOPT_CHART:
552                 pValues[nProp] <<= static_cast<sal_Int32>(GetObjMode( VOBJ_TYPE_CHART ));
553                 break;
554             case SCDISPLAYOPT_DRAWING:
555                 pValues[nProp] <<= static_cast<sal_Int32>(GetObjMode( VOBJ_TYPE_DRAW ));
556                 break;
557         }
558     }
559     aDisplayItem.PutProperties(aNames, aValues);
560 }
561 
IMPL_LINK_NOARG(ScViewCfg,GridCommitHdl,ScLinkConfigItem &,void)562 IMPL_LINK_NOARG(ScViewCfg, GridCommitHdl, ScLinkConfigItem&, void)
563 {
564     const ScGridOptions& rGrid = GetGridOptions();
565 
566     Sequence<OUString> aNames = GetGridPropertyNames();
567     Sequence<Any> aValues(aNames.getLength());
568     Any* pValues = aValues.getArray();
569 
570     for(int nProp = 0; nProp < aNames.getLength(); nProp++)
571     {
572         switch(nProp)
573         {
574             case SCGRIDOPT_RESOLU_X:
575                 pValues[nProp] <<= static_cast<sal_Int32>(rGrid.GetFieldDrawX());
576                 break;
577             case SCGRIDOPT_RESOLU_Y:
578                 pValues[nProp] <<= static_cast<sal_Int32>(rGrid.GetFieldDrawY());
579                 break;
580             case SCGRIDOPT_SUBDIV_X:
581                 pValues[nProp] <<= static_cast<sal_Int32>(rGrid.GetFieldDivisionX());
582                 break;
583             case SCGRIDOPT_SUBDIV_Y:
584                 pValues[nProp] <<= static_cast<sal_Int32>(rGrid.GetFieldDivisionY());
585                 break;
586             case SCGRIDOPT_OPTION_X:
587                 pValues[nProp] <<= static_cast<sal_Int32>(rGrid.GetFieldSnapX());
588                 break;
589             case SCGRIDOPT_OPTION_Y:
590                 pValues[nProp] <<= static_cast<sal_Int32>(rGrid.GetFieldSnapY());
591                 break;
592             case SCGRIDOPT_SNAPTOGRID:
593                 pValues[nProp] <<= rGrid.GetUseGridSnap();
594                 break;
595             case SCGRIDOPT_SYNCHRON:
596                 pValues[nProp] <<= rGrid.GetSynchronize();
597                 break;
598             case SCGRIDOPT_VISIBLE:
599                 pValues[nProp] <<= rGrid.GetGridVisible();
600                 break;
601             case SCGRIDOPT_SIZETOGRID:
602                 pValues[nProp] <<= rGrid.GetEqualGrid();
603                 break;
604         }
605     }
606     aGridItem.PutProperties(aNames, aValues);
607 }
608 
SetOptions(const ScViewOptions & rNew)609 void ScViewCfg::SetOptions( const ScViewOptions& rNew )
610 {
611     *static_cast<ScViewOptions*>(this) = rNew;
612     aLayoutItem.SetModified();
613     aDisplayItem.SetModified();
614     aGridItem.SetModified();
615 }
616 
617 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
618