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