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