1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_sw.hxx" 30 31 32 #include <tools/stream.hxx> 33 #include <unotools/syslocale.hxx> 34 35 #include "swtypes.hxx" 36 #include "hintids.hxx" 37 #include "uitool.hxx" 38 #include "usrpref.hxx" 39 #include "crstate.hxx" 40 #include <linguistic/lngprops.hxx> 41 #include <com/sun/star/beans/XPropertySet.hpp> 42 #include <com/sun/star/uno/Any.hxx> 43 #include <com/sun/star/uno/Sequence.hxx> 44 #include <unotools/localedatawrapper.hxx> 45 46 #include <unomid.h> 47 48 using namespace utl; 49 using namespace rtl; 50 using namespace ::com::sun::star; 51 using namespace ::com::sun::star::uno; 52 53 54 void SwMasterUsrPref::SetUsrPref(const SwViewOption &rCopy) 55 { 56 *((SwViewOption*)this) = rCopy; 57 } 58 59 SwMasterUsrPref::SwMasterUsrPref(sal_Bool bWeb) : 60 eFldUpdateFlags(AUTOUPD_OFF), 61 nLinkUpdateMode(0), 62 bIsHScrollMetricSet(sal_False), 63 bIsVScrollMetricSet(sal_False), 64 nDefTab( MM50 * 4 ), 65 bIsSquaredPageMode(sal_False), 66 aContentConfig(bWeb, *this), 67 aLayoutConfig(bWeb, *this), 68 aGridConfig(bWeb, *this), 69 aCursorConfig(*this), 70 pWebColorConfig(bWeb ? new SwWebColorConfig(*this) : 0) 71 { 72 MeasurementSystem eSystem = SvtSysLocale().GetLocaleData().getMeasurementSystemEnum(); 73 eUserMetric = MEASURE_METRIC == eSystem ? FUNIT_CM : FUNIT_INCH; 74 eHScrollMetric = eUserMetric; 75 eVScrollMetric = eUserMetric; 76 77 aContentConfig.Load(); 78 aLayoutConfig.Load(); 79 aGridConfig.Load(); 80 aCursorConfig.Load(); 81 if(pWebColorConfig) 82 pWebColorConfig->Load(); 83 } 84 /* -----------------------------13.02.01 09:48-------------------------------- 85 86 ---------------------------------------------------------------------------*/ 87 SwMasterUsrPref::~SwMasterUsrPref() 88 { 89 delete pWebColorConfig; 90 } 91 /*-- 28.09.00 09:55:32--------------------------------------------------- 92 93 -----------------------------------------------------------------------*/ 94 Sequence<OUString> SwContentViewConfig::GetPropertyNames() 95 { 96 static const char* aPropNames[] = 97 { 98 "Display/GraphicObject", // 0 99 "Display/Table", // 1 100 "Display/DrawingControl", // 2 101 "Display/FieldCode", // 3 102 "Display/Note", // 4 103 "Display/PreventTips", // 5 104 "NonprintingCharacter/MetaCharacters", // 6 105 "NonprintingCharacter/ParagraphEnd", // 7 106 "NonprintingCharacter/OptionalHyphen", // 8 107 "NonprintingCharacter/Space", // 9 108 "NonprintingCharacter/Break", // 10 109 "NonprintingCharacter/ProtectedSpace", // 11 110 "NonprintingCharacter/Tab", // 12 //not in Writer/Web 111 "NonprintingCharacter/HiddenText", // 13 112 "NonprintingCharacter/HiddenParagraph", // 14 113 "NonprintingCharacter/HiddenCharacter", // 15 114 "Update/Link", // 16 115 "Update/Field", // 17 116 "Update/Chart" // 18 117 118 119 }; 120 const int nCount = bWeb ? 12 : 19; 121 Sequence<OUString> aNames(nCount); 122 OUString* pNames = aNames.getArray(); 123 for(int i = 0; i < nCount; i++) 124 { 125 pNames[i] = OUString::createFromAscii(aPropNames[i]); 126 } 127 return aNames; 128 } 129 /*-- 28.09.00 09:55:33--------------------------------------------------- 130 131 -----------------------------------------------------------------------*/ 132 SwContentViewConfig::SwContentViewConfig(sal_Bool bIsWeb, SwMasterUsrPref& rPar) : 133 ConfigItem(bIsWeb ? C2U("Office.WriterWeb/Content") : C2U("Office.Writer/Content")), 134 rParent(rPar), 135 bWeb(bIsWeb) 136 { 137 Load(); 138 EnableNotification( GetPropertyNames() ); 139 } 140 /*-- 28.09.00 09:55:33--------------------------------------------------- 141 142 -----------------------------------------------------------------------*/ 143 SwContentViewConfig::~SwContentViewConfig() 144 { 145 } 146 /*-- 09.02.07 09:55:33--------------------------------------------------- 147 148 -----------------------------------------------------------------------*/ 149 void SwContentViewConfig::Notify( const Sequence< OUString > & /*rPropertyNames*/ ) 150 { 151 Load(); 152 } 153 /*-- 28.09.00 09:55:33--------------------------------------------------- 154 155 -----------------------------------------------------------------------*/ 156 void SwContentViewConfig::Commit() 157 { 158 Sequence<OUString> aNames = GetPropertyNames(); 159 160 Sequence<Any> aValues(aNames.getLength()); 161 Any* pValues = aValues.getArray(); 162 163 for(int nProp = 0; nProp < aNames.getLength(); nProp++) 164 { 165 sal_Bool bVal = sal_False; 166 switch(nProp) 167 { 168 case 0: bVal = rParent.IsGraphic(); break;// "Display/GraphicObject", 169 case 1: bVal = rParent.IsTable(); break;// "Display/Table", 170 case 2: bVal = rParent.IsDraw(); break;// "Display/DrawingControl", 171 case 3: bVal = rParent.IsFldName(); break;// "Display/FieldCode", 172 case 4: bVal = rParent.IsPostIts(); break;// "Display/Note", 173 case 5: bVal = rParent.IsPreventTips(); break; // "Display/PreventTips" 174 case 6: bVal = rParent.IsViewMetaChars(); break; //"NonprintingCharacter/MetaCharacters" 175 case 7: bVal = rParent.IsParagraph(sal_True); break;// "NonprintingCharacter/ParagraphEnd", 176 case 8: bVal = rParent.IsSoftHyph(); break;// "NonprintingCharacter/OptionalHyphen", 177 case 9: bVal = rParent.IsBlank(sal_True); break;// "NonprintingCharacter/Space", 178 case 10: bVal = rParent.IsLineBreak(sal_True);break;// "NonprintingCharacter/Break", 179 case 11: bVal = rParent.IsHardBlank(); break;// "NonprintingCharacter/ProtectedSpace", 180 case 12: bVal = rParent.IsTab(sal_True); break;// "NonprintingCharacter/Tab", 181 case 13: bVal = rParent.IsShowHiddenField(); break;// "NonprintingCharacter/Fields: HiddenText", 182 case 14: bVal = rParent.IsShowHiddenPara(); break;// "NonprintingCharacter/Fields: HiddenParagraph", 183 case 15: bVal = rParent.IsShowHiddenChar(sal_True); break;// "NonprintingCharacter/HiddenCharacter", 184 case 16: pValues[nProp] <<= rParent.GetUpdateLinkMode(); break;// "Update/Link", 185 case 17: bVal = rParent.IsUpdateFields(); break;// "Update/Field", 186 case 18: bVal = rParent.IsUpdateCharts(); break;// "Update/Chart" 187 } 188 if(nProp != 16) 189 pValues[nProp].setValue(&bVal, ::getBooleanCppuType()); 190 } 191 PutProperties(aNames, aValues); 192 } 193 /*-- 28.09.00 09:55:34--------------------------------------------------- 194 195 -----------------------------------------------------------------------*/ 196 void SwContentViewConfig::Load() 197 { 198 Sequence<OUString> aNames = GetPropertyNames(); 199 Sequence<Any> aValues = GetProperties(aNames); 200 const Any* pValues = aValues.getConstArray(); 201 DBG_ASSERT(aValues.getLength() == aNames.getLength(), "GetProperties failed"); 202 if(aValues.getLength() == aNames.getLength()) 203 { 204 for(int nProp = 0; nProp < aNames.getLength(); nProp++) 205 { 206 if(pValues[nProp].hasValue()) 207 { 208 sal_Bool bSet = nProp != 16 ? *(sal_Bool*)pValues[nProp].getValue() : sal_False; 209 switch(nProp) 210 { 211 case 0: rParent.SetGraphic(bSet); break;// "Display/GraphicObject", 212 case 1: rParent.SetTable(bSet); break;// "Display/Table", 213 case 2: rParent.SetDraw(bSet); break;// "Display/DrawingControl", 214 case 3: rParent.SetFldName(bSet); break;// "Display/FieldCode", 215 case 4: rParent.SetPostIts(bSet); break;// "Display/Note", 216 case 5: rParent.SetPreventTips(bSet); break;// "Display/PreventTips", 217 case 6: rParent.SetViewMetaChars(bSet); break; //"NonprintingCharacter/MetaCharacters" 218 case 7: rParent.SetParagraph(bSet); break;// "NonprintingCharacter/ParagraphEnd", 219 case 8: rParent.SetSoftHyph(bSet); break;// "NonprintingCharacter/OptionalHyphen", 220 case 9: rParent.SetBlank(bSet); break;// "NonprintingCharacter/Space", 221 case 10: rParent.SetLineBreak(bSet);break;// "NonprintingCharacter/Break", 222 case 11: rParent.SetHardBlank(bSet); break;// "NonprintingCharacter/ProtectedSpace", 223 case 12: rParent.SetTab(bSet); break;// "NonprintingCharacter/Tab", 224 case 13: rParent.SetShowHiddenField(bSet); break;// "NonprintingCharacter/Fields: HiddenText", 225 case 14: rParent.SetShowHiddenPara(bSet); break;// "NonprintingCharacter/Fields: HiddenParagraph", 226 case 15: rParent.SetShowHiddenChar(bSet); break;// "NonprintingCharacter/HiddenCharacter", 227 case 16: 228 { 229 sal_Int32 nSet = 0; 230 pValues[nProp] >>= nSet; 231 rParent.SetUpdateLinkMode(nSet, sal_True); 232 } 233 break;// "Update/Link", 234 case 17: rParent.SetUpdateFields(bSet, sal_True); break;// "Update/Field", 235 case 18: rParent.SetUpdateCharts(bSet, sal_True); break;// "Update/Chart" 236 } 237 } 238 } 239 } 240 } 241 /*-- 28.09.00 09:55:34--------------------------------------------------- 242 243 -----------------------------------------------------------------------*/ 244 Sequence<OUString> SwLayoutViewConfig::GetPropertyNames() 245 { 246 static const char* aPropNames[] = 247 { 248 "Line/Guide", // 0 249 "Line/SimpleControlPoint", // 1 250 "Line/LargeControlPoint", // 2 251 "Window/HorizontalScroll", // 3 252 "Window/VerticalScroll", // 4 253 "Window/ShowRulers", // 5 254 "Window/HorizontalRuler", // 6 255 "Window/VerticalRuler", // 7 256 "Window/HorizontalRulerUnit", // 8 257 "Window/VerticalRulerUnit", // 9 258 "Window/SmoothScroll", //10 259 "Zoom/Value", //11 260 "Zoom/Type", //12 261 "Other/IsAlignMathObjectsToBaseline", //13 262 "Other/MeasureUnit", //14 263 // below properties are not available in WriterWeb 264 "Other/TabStop", //15 265 "Window/IsVerticalRulerRight", //16 266 "ViewLayout/Columns", //17 267 "ViewLayout/BookMode", //18 268 "Other/IsSquaredPageMode" //19 269 }; 270 const int nCount = bWeb ? 15 : 20; 271 Sequence<OUString> aNames(nCount); 272 OUString* pNames = aNames.getArray(); 273 for(int i = 0; i < nCount; i++) 274 { 275 pNames[i] = OUString::createFromAscii(aPropNames[i]); 276 } 277 return aNames; 278 } 279 /*-- 28.09.00 09:55:34--------------------------------------------------- 280 281 -----------------------------------------------------------------------*/ 282 SwLayoutViewConfig::SwLayoutViewConfig(sal_Bool bIsWeb, SwMasterUsrPref& rPar) : 283 ConfigItem(bIsWeb ? C2U("Office.WriterWeb/Layout") : C2U("Office.Writer/Layout"), 284 CONFIG_MODE_DELAYED_UPDATE|CONFIG_MODE_RELEASE_TREE), 285 rParent(rPar), 286 bWeb(bIsWeb) 287 { 288 } 289 /*-- 28.09.00 09:55:35--------------------------------------------------- 290 291 -----------------------------------------------------------------------*/ 292 SwLayoutViewConfig::~SwLayoutViewConfig() 293 { 294 } 295 /*-- 28.09.00 09:55:36--------------------------------------------------- 296 297 -----------------------------------------------------------------------*/ 298 void SwLayoutViewConfig::Commit() 299 { 300 Sequence<OUString> aNames = GetPropertyNames(); 301 302 Sequence<Any> aValues(aNames.getLength()); 303 Any* pValues = aValues.getArray(); 304 305 for(int nProp = 0; nProp < aNames.getLength(); nProp++) 306 { 307 Any &rVal = pValues[nProp]; 308 switch(nProp) 309 { 310 case 0: rVal <<= (sal_Bool) rParent.IsCrossHair(); break; // "Line/Guide", 311 case 1: rVal <<= (sal_Bool) rParent.IsSolidMarkHdl(); break; // "Line/SimpleControlPoint", 312 case 2: rVal <<= (sal_Bool) rParent.IsBigMarkHdl(); break; // "Line/LargeControlPoint", 313 case 3: rVal <<= (sal_Bool) rParent.IsViewHScrollBar(); break; // "Window/HorizontalScroll", 314 case 4: rVal <<= (sal_Bool) rParent.IsViewVScrollBar(); break; // "Window/VerticalScroll", 315 case 5: rVal <<= (sal_Bool) rParent.IsViewAnyRuler(); break; // "Window/ShowRulers" 316 // #i14593# use IsView*Ruler(sal_True) instead of IsView*Ruler() 317 // this preserves the single ruler states even if "Window/ShowRulers" is off 318 case 6: rVal <<= (sal_Bool) rParent.IsViewHRuler(sal_True); break; // "Window/HorizontalRuler", 319 case 7: rVal <<= (sal_Bool) rParent.IsViewVRuler(sal_True); break; // "Window/VerticalRuler", 320 case 8: 321 if(rParent.bIsHScrollMetricSet) 322 rVal <<= (sal_Int32)rParent.eHScrollMetric; // "Window/HorizontalRulerUnit" 323 break; 324 case 9: 325 if(rParent.bIsVScrollMetricSet) 326 rVal <<= (sal_Int32)rParent.eVScrollMetric; // "Window/VerticalRulerUnit" 327 break; 328 case 10: rVal <<= (sal_Bool) rParent.IsSmoothScroll(); break; // "Window/SmoothScroll", 329 case 11: rVal <<= (sal_Int32)rParent.GetZoom(); break; // "Zoom/Value", 330 case 12: rVal <<= (sal_Int32)rParent.GetZoomType(); break; // "Zoom/Type", 331 case 13: rVal <<= (sal_Bool) rParent.IsAlignMathObjectsToBaseline(); break; // "Other/IsAlignMathObjectsToBaseline" 332 case 14: rVal <<= (sal_Int32)rParent.GetMetric(); break; // "Other/MeasureUnit", 333 case 15: rVal <<= static_cast<sal_Int32>(TWIP_TO_MM100(rParent.GetDefTab())); break;// "Other/TabStop", 334 case 16: rVal <<= (sal_Bool) rParent.IsVRulerRight(); break; // "Window/IsVerticalRulerRight", 335 case 17: rVal <<= (sal_Int32)rParent.GetViewLayoutColumns(); break; // "ViewLayout/Columns", 336 case 18: rVal <<= (sal_Bool) rParent.IsViewLayoutBookMode(); break; // "ViewLayout/BookMode", 337 case 19: rVal <<= (sal_Bool) rParent.IsSquaredPageMode(); break; // "Other/IsSquaredPageMode", 338 } 339 } 340 PutProperties(aNames, aValues); 341 } 342 /*-- 28.09.00 09:55:36--------------------------------------------------- 343 344 -----------------------------------------------------------------------*/ 345 void SwLayoutViewConfig::Load() 346 { 347 Sequence<OUString> aNames = GetPropertyNames(); 348 Sequence<Any> aValues = GetProperties(aNames); 349 const Any* pValues = aValues.getConstArray(); 350 DBG_ASSERT(aValues.getLength() == aNames.getLength(), "GetProperties failed"); 351 if(aValues.getLength() == aNames.getLength()) 352 { 353 for(int nProp = 0; nProp < aNames.getLength(); nProp++) 354 { 355 if(pValues[nProp].hasValue()) 356 { 357 sal_Int32 nInt32Val = 0; 358 sal_Bool bSet = sal_False; 359 pValues[nProp] >>= nInt32Val; 360 pValues[nProp] >>= bSet; 361 362 switch(nProp) 363 { 364 case 0: rParent.SetCrossHair(bSet); break;// "Line/Guide", 365 case 1: rParent.SetSolidMarkHdl(bSet); break;// "Line/SimpleControlPoint", 366 case 2: rParent.SetBigMarkHdl(bSet); break;// "Line/LargeControlPoint", 367 case 3: rParent.SetViewHScrollBar(bSet); break;// "Window/HorizontalScroll", 368 case 4: rParent.SetViewVScrollBar(bSet); break;// "Window/VerticalScroll", 369 case 5: rParent.SetViewAnyRuler(bSet);break; // "Window/ShowRulers" 370 case 6: rParent.SetViewHRuler(bSet); break;// "Window/HorizontalRuler", 371 case 7: rParent.SetViewVRuler(bSet); break;// "Window/VerticalRuler", 372 case 8: 373 { 374 rParent.bIsHScrollMetricSet = sal_True; 375 rParent.eHScrollMetric = ((FieldUnit)nInt32Val); // "Window/HorizontalRulerUnit" 376 } 377 break; 378 case 9: 379 { 380 rParent.bIsVScrollMetricSet = sal_True; 381 rParent.eVScrollMetric = ((FieldUnit)nInt32Val); // "Window/VerticalRulerUnit" 382 } 383 break; 384 case 10: rParent.SetSmoothScroll(bSet); break;// "Window/SmoothScroll", 385 case 11: rParent.SetZoom( static_cast< sal_uInt16 >(nInt32Val) ); break;// "Zoom/Value", 386 case 12: rParent.SetZoomType( static_cast< SvxZoomType >(nInt32Val) ); break;// "Zoom/Type", 387 case 13: rParent.SetAlignMathObjectsToBaseline(bSet); break;// "Other/IsAlignMathObjectsToBaseline" 388 case 14: rParent.SetMetric((FieldUnit)nInt32Val, sal_True); break;// "Other/MeasureUnit", 389 case 15: rParent.SetDefTab(MM100_TO_TWIP(nInt32Val), sal_True); break;// "Other/TabStop", 390 case 16: rParent.SetVRulerRight(bSet); break;// "Window/IsVerticalRulerRight", 391 case 17: rParent.SetViewLayoutColumns( static_cast<sal_uInt16>(nInt32Val) ); break;// "ViewLayout/Columns", 392 case 18: rParent.SetViewLayoutBookMode(bSet); break;// "ViewLayout/BookMode", 393 case 19: rParent.SetDefaultPageMode(bSet,sal_True); break;// "Other/IsSquaredPageMode", 394 } 395 } 396 } 397 } 398 } 399 400 void SwLayoutViewConfig::Notify( const ::com::sun::star::uno::Sequence< rtl::OUString >& ) {} 401 402 /* -----------------------------19.01.01 13:07-------------------------------- 403 404 ---------------------------------------------------------------------------*/ 405 Sequence<OUString> SwGridConfig::GetPropertyNames() 406 { 407 static const char* aPropNames[] = 408 { 409 "Option/SnapToGrid", // 0 410 "Option/VisibleGrid", // 1 411 "Option/Synchronize", // 2 412 "Resolution/XAxis", // 3 413 "Resolution/YAxis", // 4 414 "Subdivision/XAxis", // 5 415 "Subdivision/YAxis" // 6 416 }; 417 const int nCount = 7; 418 Sequence<OUString> aNames(nCount); 419 OUString* pNames = aNames.getArray(); 420 for(int i = 0; i < nCount; i++) 421 { 422 pNames[i] = OUString::createFromAscii(aPropNames[i]); 423 } 424 return aNames; 425 } 426 /* -----------------------------19.01.01 13:07-------------------------------- 427 428 ---------------------------------------------------------------------------*/ 429 SwGridConfig::SwGridConfig(sal_Bool bIsWeb, SwMasterUsrPref& rPar) : 430 ConfigItem(bIsWeb ? C2U("Office.WriterWeb/Grid") : C2U("Office.Writer/Grid"), 431 CONFIG_MODE_DELAYED_UPDATE|CONFIG_MODE_RELEASE_TREE), 432 rParent(rPar), 433 bWeb(bIsWeb) 434 { 435 } 436 /* -----------------------------19.01.01 13:07-------------------------------- 437 438 ---------------------------------------------------------------------------*/ 439 SwGridConfig::~SwGridConfig() 440 { 441 } 442 /* -----------------------------19.01.01 13:07-------------------------------- 443 444 ---------------------------------------------------------------------------*/ 445 void SwGridConfig::Commit() 446 { 447 Sequence<OUString> aNames = GetPropertyNames(); 448 449 Sequence<Any> aValues(aNames.getLength()); 450 Any* pValues = aValues.getArray(); 451 452 for(int nProp = 0; nProp < aNames.getLength(); nProp++) 453 { 454 sal_Bool bSet; 455 switch(nProp) 456 { 457 case 0: bSet = rParent.IsSnap(); break;// "Option/SnapToGrid", 458 case 1: bSet = rParent.IsGridVisible(); break;//"Option/VisibleGrid", 459 case 2: bSet = rParent.IsSynchronize(); break;// "Option/Synchronize", 460 case 3: pValues[nProp] <<= (sal_Int32)TWIP_TO_MM100(rParent.GetSnapSize().Width()); break;// "Resolution/XAxis", 461 case 4: pValues[nProp] <<= (sal_Int32)TWIP_TO_MM100(rParent.GetSnapSize().Height()); break;// "Resolution/YAxis", 462 case 5: pValues[nProp] <<= (sal_Int16)rParent.GetDivisionX(); break;// "Subdivision/XAxis", 463 case 6: pValues[nProp] <<= (sal_Int16)rParent.GetDivisionY(); break;// "Subdivision/YAxis" 464 } 465 if(nProp < 3) 466 pValues[nProp].setValue(&bSet, ::getBooleanCppuType()); 467 } 468 PutProperties(aNames, aValues); 469 } 470 /* -----------------------------19.01.01 13:07-------------------------------- 471 472 ---------------------------------------------------------------------------*/ 473 void SwGridConfig::Load() 474 { 475 Sequence<OUString> aNames = GetPropertyNames(); 476 Sequence<Any> aValues = GetProperties(aNames); 477 const Any* pValues = aValues.getConstArray(); 478 DBG_ASSERT(aValues.getLength() == aNames.getLength(), "GetProperties failed"); 479 if(aValues.getLength() == aNames.getLength()) 480 { 481 Size aSnap(rParent.GetSnapSize()); 482 for(int nProp = 0; nProp < aNames.getLength(); nProp++) 483 { 484 if(pValues[nProp].hasValue()) 485 { 486 sal_Bool bSet = nProp < 3 ? *(sal_Bool*)pValues[nProp].getValue() : sal_False; 487 sal_Int32 nSet = 0; 488 if(nProp >= 3) 489 pValues[nProp] >>= nSet; 490 switch(nProp) 491 { 492 case 0: rParent.SetSnap(bSet); break;// "Option/SnapToGrid", 493 case 1: rParent.SetGridVisible(bSet); break;//"Option/VisibleGrid", 494 case 2: rParent.SetSynchronize(bSet); break;// "Option/Synchronize", 495 case 3: aSnap.Width() = MM100_TO_TWIP(nSet); break;// "Resolution/XAxis", 496 case 4: aSnap.Height() = MM100_TO_TWIP(nSet); break;// "Resolution/YAxis", 497 case 5: rParent.SetDivisionX((short)nSet); break;// "Subdivision/XAxis", 498 case 6: rParent.SetDivisionY((short)nSet); break;// "Subdivision/YAxis" 499 } 500 } 501 } 502 rParent.SetSnapSize(aSnap); 503 } 504 } 505 506 void SwGridConfig::Notify( const ::com::sun::star::uno::Sequence< rtl::OUString >& ) {} 507 508 /* -----------------------------19.01.01 13:07-------------------------------- 509 510 ---------------------------------------------------------------------------*/ 511 Sequence<OUString> SwCursorConfig::GetPropertyNames() 512 { 513 static const char* aPropNames[] = 514 { 515 "DirectCursor/UseDirectCursor", // 0 516 "DirectCursor/Insert", // 1 517 "Option/ProtectedArea" // 2 518 }; 519 const int nCount = 3; 520 Sequence<OUString> aNames(nCount); 521 OUString* pNames = aNames.getArray(); 522 for(int i = 0; i < nCount; i++) 523 pNames[i] = C2U(aPropNames[i]); 524 return aNames; 525 } 526 /* -----------------------------19.01.01 13:07-------------------------------- 527 528 ---------------------------------------------------------------------------*/ 529 SwCursorConfig::SwCursorConfig(SwMasterUsrPref& rPar) : 530 ConfigItem(C2U("Office.Writer/Cursor"), 531 CONFIG_MODE_DELAYED_UPDATE|CONFIG_MODE_RELEASE_TREE), 532 rParent(rPar) 533 { 534 } 535 /* -----------------------------19.01.01 13:07-------------------------------- 536 537 ---------------------------------------------------------------------------*/ 538 SwCursorConfig::~SwCursorConfig() 539 { 540 } 541 /* -----------------------------19.01.01 13:07-------------------------------- 542 543 ---------------------------------------------------------------------------*/ 544 void SwCursorConfig::Commit() 545 { 546 Sequence<OUString> aNames = GetPropertyNames(); 547 548 Sequence<Any> aValues(aNames.getLength()); 549 Any* pValues = aValues.getArray(); 550 551 for(int nProp = 0; nProp < aNames.getLength(); nProp++) 552 { 553 sal_Bool bSet; 554 switch(nProp) 555 { 556 case 0: bSet = rParent.IsShadowCursor(); break;// "DirectCursor/UseDirectCursor", 557 case 1: pValues[nProp] <<= (sal_Int32)rParent.GetShdwCrsrFillMode(); break;// "DirectCursor/Insert", 558 case 2: bSet = rParent.IsCursorInProtectedArea(); break;// "Option/ProtectedArea" 559 } 560 if(nProp != 1 ) 561 pValues[nProp].setValue(&bSet, ::getBooleanCppuType()); 562 } 563 PutProperties(aNames, aValues); 564 } 565 /* -----------------------------19.01.01 13:07-------------------------------- 566 567 ---------------------------------------------------------------------------*/ 568 void SwCursorConfig::Load() 569 { 570 Sequence<OUString> aNames = GetPropertyNames(); 571 Sequence<Any> aValues = GetProperties(aNames); 572 const Any* pValues = aValues.getConstArray(); 573 DBG_ASSERT(aValues.getLength() == aNames.getLength(), "GetProperties failed"); 574 if(aValues.getLength() == aNames.getLength()) 575 { 576 577 for(int nProp = 0; nProp < aNames.getLength(); nProp++) 578 { 579 if(pValues[nProp].hasValue()) 580 { 581 sal_Bool bSet = sal_False; 582 sal_Int32 nSet = 0; 583 if(nProp != 1 ) 584 bSet = *(sal_Bool*)pValues[nProp].getValue(); 585 else 586 pValues[nProp] >>= nSet; 587 switch(nProp) 588 { 589 case 0: rParent.SetShadowCursor(bSet); break;// "DirectCursor/UseDirectCursor", 590 case 1: rParent.SetShdwCrsrFillMode((sal_uInt8)nSet); break;// "DirectCursor/Insert", 591 case 2: rParent.SetCursorInProtectedArea(bSet); break;// "Option/ProtectedArea" 592 } 593 } 594 } 595 596 } 597 } 598 599 void SwCursorConfig::Notify( const ::com::sun::star::uno::Sequence< rtl::OUString >& ) {} 600 601 /*-- 28.09.00 09:55:33--------------------------------------------------- 602 603 -----------------------------------------------------------------------*/ 604 SwWebColorConfig::SwWebColorConfig(SwMasterUsrPref& rPar) : 605 ConfigItem(C2U("Office.WriterWeb/Background"), 606 CONFIG_MODE_DELAYED_UPDATE|CONFIG_MODE_RELEASE_TREE), 607 rParent(rPar), 608 aPropNames(1) 609 { 610 aPropNames.getArray()[0] = C2U("Color"); 611 } 612 /*-- 28.09.00 09:55:33--------------------------------------------------- 613 614 -----------------------------------------------------------------------*/ 615 SwWebColorConfig::~SwWebColorConfig() 616 { 617 } 618 /*-- 28.09.00 09:55:33--------------------------------------------------- 619 620 -----------------------------------------------------------------------*/ 621 void SwWebColorConfig::Commit() 622 { 623 Sequence<Any> aValues(aPropNames.getLength()); 624 Any* pValues = aValues.getArray(); 625 for(int nProp = 0; nProp < aPropNames.getLength(); nProp++) 626 { 627 switch(nProp) 628 { 629 case 0: pValues[nProp] <<= (sal_Int32)rParent.GetRetoucheColor().GetColor(); break;// "Color", 630 } 631 } 632 PutProperties(aPropNames, aValues); 633 } 634 635 void SwWebColorConfig::Notify( const ::com::sun::star::uno::Sequence< rtl::OUString >& ) {} 636 637 /*-- 28.09.00 09:55:34--------------------------------------------------- 638 639 -----------------------------------------------------------------------*/ 640 void SwWebColorConfig::Load() 641 { 642 Sequence<Any> aValues = GetProperties(aPropNames); 643 const Any* pValues = aValues.getConstArray(); 644 DBG_ASSERT(aValues.getLength() == aPropNames.getLength(), "GetProperties failed"); 645 if(aValues.getLength() == aPropNames.getLength()) 646 { 647 for(int nProp = 0; nProp < aPropNames.getLength(); nProp++) 648 { 649 if(pValues[nProp].hasValue()) 650 { 651 switch(nProp) 652 { 653 case 0: 654 sal_Int32 nSet = 0; 655 pValues[nProp] >>= nSet; rParent.SetRetoucheColor(nSet); 656 break;// "Color", 657 } 658 } 659 } 660 } 661 } 662 663 664