1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <sal/config.h>
22 #include <osl/diagnose.h>
23 #include <o3tl/any.hxx>
24 #include <tools/UnitConversion.hxx>
25 #include <unotools/configmgr.hxx>
26 #include <unotools/syslocale.hxx>
28 #include <usrpref.hxx>
29 #include <com/sun/star/uno/Any.hxx>
30 #include <com/sun/star/uno/Sequence.hxx>
31 #include <unotools/localedatawrapper.hxx>
34 using namespace ::com::sun::star
;
35 using namespace ::com::sun::star::uno
;
37 void SwMasterUsrPref::SetUsrPref(const SwViewOption
&rCopy
)
39 *static_cast<SwViewOption
*>(this) = rCopy
;
42 SwMasterUsrPref::SwMasterUsrPref(bool bWeb
) :
43 m_eFieldUpdateFlags(AUTOUPD_OFF
),
45 m_bIsHScrollMetricSet(false),
46 m_bIsVScrollMetricSet(false),
47 m_nDefTabInMm100( 2000 ), // 2 cm
48 m_bIsSquaredPageMode(false),
49 m_bIsAlignMathObjectsToBaseline(false),
50 m_aContentConfig(bWeb
, *this),
51 m_aLayoutConfig(bWeb
, *this),
52 m_aGridConfig(bWeb
, *this),
53 m_aCursorConfig(*this),
54 m_pWebColorConfig(bWeb
? new SwWebColorConfig(*this) : nullptr),
55 m_bApplyCharUnit(false)
57 if (utl::ConfigManager::IsFuzzing())
59 m_eHScrollMetric
= m_eVScrollMetric
= m_eUserMetric
= FieldUnit::CM
;
61 SetCore2Option(true, ViewOptCoreFlags2::CursorInProt
);
62 SetCore2Option(false, ViewOptCoreFlags2::HiddenPara
);
63 m_nDefTabInMm100
= 1250;
66 MeasurementSystem eSystem
= SvtSysLocale().GetLocaleData().getMeasurementSystemEnum();
67 m_eUserMetric
= MeasurementSystem::Metric
== eSystem
? FieldUnit::CM
: FieldUnit::INCH
;
68 m_eHScrollMetric
= m_eVScrollMetric
= m_eUserMetric
;
70 m_aContentConfig
.Load();
71 m_aLayoutConfig
.Load();
73 m_aCursorConfig
.Load();
75 m_pWebColorConfig
->Load();
78 SwMasterUsrPref::~SwMasterUsrPref()
82 const auto g_UpdateLinkIndex
= 17;
83 const auto g_DefaultAnchor
= 25;
85 Sequence
<OUString
> SwContentViewConfig::GetPropertyNames() const
87 static constexpr const char*const aPropNames
[] =
89 "Display/GraphicObject", // 0
91 "Display/DrawingControl", // 2
92 "Display/FieldCode", // 3
94 "Display/ShowContentTips", // 5
95 "NonprintingCharacter/MetaCharacters", // 6
96 "NonprintingCharacter/ParagraphEnd", // 7
97 "NonprintingCharacter/OptionalHyphen", // 8
98 "NonprintingCharacter/Space", // 9
99 "NonprintingCharacter/Break", // 10
100 "NonprintingCharacter/ProtectedSpace", // 11
101 "NonprintingCharacter/Tab", // 12 //not in Writer/Web
102 "NonprintingCharacter/HiddenText", // 13
103 "NonprintingCharacter/HiddenParagraph", // 14
104 "NonprintingCharacter/HiddenCharacter", // 15
105 "NonprintingCharacter/Bookmarks", // 16
107 "Update/Field", // 18
108 "Update/Chart", // 19
109 "Display/ShowInlineTooltips", // 20
110 "Display/UseHeaderFooterMenu", // 21
111 "Display/ShowOutlineContentVisibilityButton", // 22
112 "Display/TreatSubOutlineLevelsAsContent", // 23
113 "Display/ShowChangesInMargin", // 24
114 "Display/DefaultAnchor" // 25
116 #if defined(__GNUC__) && !defined(__clang__)
117 // clang 8.0.0 says strcmp isn't constexpr
118 static_assert(std::strcmp("Update/Link", aPropNames
[g_UpdateLinkIndex
]) == 0);
119 static_assert(std::strcmp("Display/DefaultAnchor", aPropNames
[g_DefaultAnchor
]) == 0);
121 const int nCount
= m_bWeb
? 12 : SAL_N_ELEMENTS(aPropNames
);
122 Sequence
<OUString
> aNames(nCount
);
123 OUString
* pNames
= aNames
.getArray();
124 for(int i
= 0; i
< nCount
; i
++)
126 pNames
[i
] = OUString::createFromAscii(aPropNames
[i
]);
131 SwContentViewConfig::SwContentViewConfig(bool bIsWeb
, SwMasterUsrPref
& rPar
) :
132 ConfigItem(bIsWeb
? OUString("Office.WriterWeb/Content") : OUString("Office.Writer/Content")),
137 EnableNotification( GetPropertyNames() );
140 SwContentViewConfig::~SwContentViewConfig()
144 void SwContentViewConfig::Notify( const Sequence
< OUString
> & /*rPropertyNames*/ )
149 void SwContentViewConfig::ImplCommit()
151 Sequence
<OUString
> aNames
= GetPropertyNames();
153 Sequence
<Any
> aValues(aNames
.getLength());
154 Any
* pValues
= aValues
.getArray();
156 for(int nProp
= 0; nProp
< aNames
.getLength(); nProp
++)
161 case 0: bVal
= m_rParent
.IsGraphic(); break;// "Display/GraphicObject",
162 case 1: bVal
= m_rParent
.IsTable(); break;// "Display/Table",
163 case 2: bVal
= m_rParent
.IsDraw(); break;// "Display/DrawingControl",
164 case 3: bVal
= m_rParent
.IsFieldName(); break;// "Display/FieldCode",
165 case 4: bVal
= m_rParent
.IsPostIts(); break;// "Display/Note",
166 case 5: bVal
= m_rParent
.IsShowContentTips(); break; // "Display/ShowContentTips"
167 case 6: bVal
= m_rParent
.IsViewMetaChars(); break; //"NonprintingCharacter/MetaCharacters"
168 case 7: bVal
= m_rParent
.IsParagraph(true); break;// "NonprintingCharacter/ParagraphEnd",
169 case 8: bVal
= m_rParent
.IsSoftHyph(); break;// "NonprintingCharacter/OptionalHyphen",
170 case 9: bVal
= m_rParent
.IsBlank(true); break;// "NonprintingCharacter/Space",
171 case 10: bVal
= m_rParent
.IsLineBreak(true);break;// "NonprintingCharacter/Break",
172 case 11: bVal
= m_rParent
.IsHardBlank(); break;// "NonprintingCharacter/ProtectedSpace",
173 case 12: bVal
= m_rParent
.IsTab(true); break;// "NonprintingCharacter/Tab",
174 case 13: bVal
= m_rParent
.IsShowHiddenField(); break;// "NonprintingCharacter/Fields: HiddenText",
175 case 14: bVal
= m_rParent
.IsShowHiddenPara(); break;// "NonprintingCharacter/Fields: HiddenParagraph",
176 case 15: bVal
= m_rParent
.IsShowHiddenChar(true); break;// "NonprintingCharacter/HiddenCharacter",
177 case 16: bVal
= m_rParent
.IsShowBookmarks(true); break;// "NonprintingCharacter/Bookmarks",
178 case 17: pValues
[nProp
] <<= m_rParent
.GetUpdateLinkMode(); break;// "Update/Link",
179 case 18: bVal
= m_rParent
.IsUpdateFields(); break;// "Update/Field",
180 case 19: bVal
= m_rParent
.IsUpdateCharts(); break;// "Update/Chart"
181 case 20: bVal
= m_rParent
.IsShowInlineTooltips(); break;// "Display/ShowInlineTooltips"
182 case 21: bVal
= m_rParent
.IsUseHeaderFooterMenu(); break;// "Display/UseHeaderFooterMenu"
183 case 22: bVal
= m_rParent
.IsShowOutlineContentVisibilityButton(); break;// "Display/ShowOutlineContentVisibilityButton"
184 case 23: bVal
= m_rParent
.IsTreatSubOutlineLevelsAsContent(); break;// "Display/TreatSubOutlineLevelsAsContent"
185 case 24: bVal
= m_rParent
.IsShowChangesInMargin(); break;// "Display/ShowChangesInMargin"
186 case 25: pValues
[nProp
] <<= m_rParent
.GetDefaultAnchor(); break;// "Display/DefaultAnchor"
188 if ((nProp
!= g_UpdateLinkIndex
) && (nProp
!= g_DefaultAnchor
))
189 pValues
[nProp
] <<= bVal
;
191 PutProperties(aNames
, aValues
);
194 void SwContentViewConfig::Load()
196 Sequence
<OUString
> aNames
= GetPropertyNames();
197 Sequence
<Any
> aValues
= GetProperties(aNames
);
198 const Any
* pValues
= aValues
.getConstArray();
199 OSL_ENSURE(aValues
.getLength() == aNames
.getLength(), "GetProperties failed");
200 if(aValues
.getLength() != aNames
.getLength())
202 for(int nProp
= 0; nProp
< aNames
.getLength(); nProp
++)
204 if(pValues
[nProp
].hasValue())
206 bool bSet
= ((nProp
!= g_UpdateLinkIndex
) && (nProp
!= g_DefaultAnchor
))
207 && *o3tl::doAccess
<bool>(pValues
[nProp
]);
210 case 0: m_rParent
.SetGraphic(bSet
); break;// "Display/GraphicObject",
211 case 1: m_rParent
.SetTable(bSet
); break;// "Display/Table",
212 case 2: m_rParent
.SetDraw(bSet
); break;// "Display/DrawingControl",
213 case 3: m_rParent
.SetFieldName(bSet
); break;// "Display/FieldCode",
214 case 4: m_rParent
.SetPostIts(bSet
); break;// "Display/Note",
215 case 5: m_rParent
.SetShowContentTips(bSet
); break;// "Display/ShowContentTips",
216 case 6: m_rParent
.SetViewMetaChars(bSet
); break; //"NonprintingCharacter/MetaCharacters"
217 case 7: m_rParent
.SetParagraph(bSet
); break;// "NonprintingCharacter/ParagraphEnd",
218 case 8: m_rParent
.SetSoftHyph(bSet
); break;// "NonprintingCharacter/OptionalHyphen",
219 case 9: m_rParent
.SetBlank(bSet
); break;// "NonprintingCharacter/Space",
220 case 10: m_rParent
.SetLineBreak(bSet
);break;// "NonprintingCharacter/Break",
221 case 11: m_rParent
.SetHardBlank(bSet
); break;// "NonprintingCharacter/ProtectedSpace",
222 case 12: m_rParent
.SetTab(bSet
); break;// "NonprintingCharacter/Tab",
223 case 13: m_rParent
.SetShowHiddenField(bSet
); break;// "NonprintingCharacter/Fields: HiddenText",
224 case 14: m_rParent
.SetShowHiddenPara(bSet
); break;// "NonprintingCharacter/Fields: HiddenParagraph",
225 case 15: m_rParent
.SetShowHiddenChar(bSet
); break;// "NonprintingCharacter/HiddenCharacter",
226 case 16: m_rParent
.SetShowBookmarks(bSet
); break;// "NonprintingCharacter/Bookmarks",
230 pValues
[nProp
] >>= nSet
;
231 m_rParent
.SetUpdateLinkMode(nSet
, true);
233 break;// "Update/Link",
234 case 18: m_rParent
.SetUpdateFields(bSet
); break;// "Update/Field",
235 case 19: m_rParent
.SetUpdateCharts(bSet
); break;// "Update/Chart"
236 case 20: m_rParent
.SetShowInlineTooltips(bSet
); break;// "Display/ShowInlineTooltips"
237 case 21: m_rParent
.SetUseHeaderFooterMenu(bSet
); break;// "Display/UseHeaderFooterMenu"
238 case 22: m_rParent
.SetShowOutlineContentVisibilityButton(bSet
); break;// "Display/ShowOutlineContententVisibilityButton"
239 case 23: m_rParent
.SetTreatSubOutlineLevelsAsContent(bSet
); break;// "Display/TreatSubOutlineLevelsAsContent"
240 case 24: m_rParent
.SetShowChangesInMargin(bSet
); break;// "Display/ShowChangesInMargin"
244 pValues
[nProp
] >>= nSet
;
245 m_rParent
.SetDefaultAnchor(nSet
);
247 break; // "Display/DefaultAnchor"
253 Sequence
<OUString
> SwLayoutViewConfig::GetPropertyNames() const
255 static const char* aPropNames
[] =
258 "Window/HorizontalScroll", // 1
259 "Window/VerticalScroll", // 2
260 "Window/ShowRulers", // 3
261 "Window/HorizontalRuler", // 4
262 "Window/VerticalRuler", // 5
263 "Window/HorizontalRulerUnit", // 6
264 "Window/VerticalRulerUnit", // 7
265 "Window/SmoothScroll", // 8
268 "Other/IsAlignMathObjectsToBaseline", //11
269 "Other/MeasureUnit", //12
270 // below properties are not available in WriterWeb
271 "Other/TabStop", //13
272 "Window/IsVerticalRulerRight", //14
273 "ViewLayout/Columns", //15
274 "ViewLayout/BookMode", //16
275 "Other/IsSquaredPageMode", //17
276 "Other/ApplyCharUnit", //18
277 "Window/ShowScrollBarTips", //19
279 const int nCount
= m_bWeb
? 13 : 20;
280 Sequence
<OUString
> aNames(nCount
);
281 OUString
* pNames
= aNames
.getArray();
282 for(int i
= 0; i
< nCount
; i
++)
284 pNames
[i
] = OUString::createFromAscii(aPropNames
[i
]);
289 SwLayoutViewConfig::SwLayoutViewConfig(bool bIsWeb
, SwMasterUsrPref
& rPar
) :
290 ConfigItem(bIsWeb
? OUString("Office.WriterWeb/Layout") : OUString("Office.Writer/Layout"),
291 ConfigItemMode::ReleaseTree
),
297 SwLayoutViewConfig::~SwLayoutViewConfig()
301 void SwLayoutViewConfig::ImplCommit()
303 Sequence
<OUString
> aNames
= GetPropertyNames();
305 Sequence
<Any
> aValues(aNames
.getLength());
306 Any
* pValues
= aValues
.getArray();
308 for(int nProp
= 0; nProp
< aNames
.getLength(); nProp
++)
310 Any
&rVal
= pValues
[nProp
];
313 case 0: rVal
<<= m_rParent
.IsCrossHair(); break; // "Line/Guide",
314 case 1: rVal
<<= m_rParent
.IsViewHScrollBar(); break; // "Window/HorizontalScroll",
315 case 2: rVal
<<= m_rParent
.IsViewVScrollBar(); break; // "Window/VerticalScroll",
316 case 3: rVal
<<= m_rParent
.IsViewAnyRuler(); break; // "Window/ShowRulers"
317 // #i14593# use IsView*Ruler(true) instead of IsView*Ruler()
318 // this preserves the single ruler states even if "Window/ShowRulers" is off
319 case 4: rVal
<<= m_rParent
.IsViewHRuler(true); break; // "Window/HorizontalRuler",
320 case 5: rVal
<<= m_rParent
.IsViewVRuler(true); break; // "Window/VerticalRuler",
322 if(m_rParent
.m_bIsHScrollMetricSet
)
323 rVal
<<= static_cast<sal_Int32
>(m_rParent
.m_eHScrollMetric
); // "Window/HorizontalRulerUnit"
326 if(m_rParent
.m_bIsVScrollMetricSet
)
327 rVal
<<= static_cast<sal_Int32
>(m_rParent
.m_eVScrollMetric
); // "Window/VerticalRulerUnit"
329 case 8: rVal
<<= m_rParent
.IsSmoothScroll(); break; // "Window/SmoothScroll",
330 case 9: rVal
<<= static_cast<sal_Int32
>(m_rParent
.GetZoom()); break; // "Zoom/Value",
331 case 10: rVal
<<= static_cast<sal_Int32
>(m_rParent
.GetZoomType()); break; // "Zoom/Type",
332 case 11: rVal
<<= m_rParent
.IsAlignMathObjectsToBaseline(); break; // "Other/IsAlignMathObjectsToBaseline"
333 case 12: rVal
<<= static_cast<sal_Int32
>(m_rParent
.GetMetric()); break; // "Other/MeasureUnit",
334 case 13: rVal
<<= m_rParent
.GetDefTabInMm100(); break;// "Other/TabStop",
335 case 14: rVal
<<= m_rParent
.IsVRulerRight(); break; // "Window/IsVerticalRulerRight",
336 case 15: rVal
<<= static_cast<sal_Int32
>(m_rParent
.GetViewLayoutColumns()); break; // "ViewLayout/Columns",
337 case 16: rVal
<<= m_rParent
.IsViewLayoutBookMode(); break; // "ViewLayout/BookMode",
338 case 17: rVal
<<= m_rParent
.IsSquaredPageMode(); break; // "Other/IsSquaredPageMode",
339 case 18: rVal
<<= m_rParent
.IsApplyCharUnit(); break; // "Other/ApplyCharUnit",
340 case 19: rVal
<<= m_rParent
.IsShowScrollBarTips(); break; // "Window/ShowScrollBarTips",
343 PutProperties(aNames
, aValues
);
346 void SwLayoutViewConfig::Load()
348 Sequence
<OUString
> aNames
= GetPropertyNames();
349 Sequence
<Any
> aValues
= GetProperties(aNames
);
350 const Any
* pValues
= aValues
.getConstArray();
351 OSL_ENSURE(aValues
.getLength() == aNames
.getLength(), "GetProperties failed");
352 if(aValues
.getLength() != aNames
.getLength())
355 for(int nProp
= 0; nProp
< aNames
.getLength(); nProp
++)
357 if(pValues
[nProp
].hasValue())
359 sal_Int32 nInt32Val
= 0;
361 pValues
[nProp
] >>= nInt32Val
;
362 pValues
[nProp
] >>= bSet
;
366 case 0: m_rParent
.SetCrossHair(bSet
); break;// "Line/Guide",
367 case 1: m_rParent
.SetViewHScrollBar(bSet
); break;// "Window/HorizontalScroll",
368 case 2: m_rParent
.SetViewVScrollBar(bSet
); break;// "Window/VerticalScroll",
369 case 3: m_rParent
.SetViewAnyRuler(bSet
);break; // "Window/ShowRulers"
370 case 4: m_rParent
.SetViewHRuler(bSet
); break;// "Window/HorizontalRuler",
371 case 5: m_rParent
.SetViewVRuler(bSet
); break;// "Window/VerticalRuler",
374 m_rParent
.m_bIsHScrollMetricSet
= true;
375 m_rParent
.m_eHScrollMetric
= static_cast<FieldUnit
>(nInt32Val
); // "Window/HorizontalRulerUnit"
380 m_rParent
.m_bIsVScrollMetricSet
= true;
381 m_rParent
.m_eVScrollMetric
= static_cast<FieldUnit
>(nInt32Val
); // "Window/VerticalRulerUnit"
384 case 8: m_rParent
.SetSmoothScroll(bSet
); break;// "Window/SmoothScroll",
385 case 9: m_rParent
.SetZoom( static_cast< sal_uInt16
>(nInt32Val
) ); break;// "Zoom/Value",
386 case 10: m_rParent
.SetZoomType( static_cast< SvxZoomType
>(nInt32Val
) ); break;// "Zoom/Type",
387 case 11: m_rParent
.SetAlignMathObjectsToBaseline(bSet
, true); break;// "Other/IsAlignMathObjectsToBaseline"
388 case 12: m_rParent
.SetMetric(static_cast<FieldUnit
>(nInt32Val
), true); break;// "Other/MeasureUnit",
389 case 13: m_rParent
.SetDefTabInMm100(nInt32Val
, true); break;// "Other/TabStop",
390 case 14: m_rParent
.SetVRulerRight(bSet
); break;// "Window/IsVerticalRulerRight",
391 case 15: m_rParent
.SetViewLayoutColumns( o3tl::narrowing
<sal_uInt16
>(nInt32Val
) ); break;// "ViewLayout/Columns",
392 case 16: m_rParent
.SetViewLayoutBookMode(bSet
); break;// "ViewLayout/BookMode",
393 case 17: m_rParent
.SetDefaultPageMode(bSet
,true); break;// "Other/IsSquaredPageMode",
394 case 18: m_rParent
.SetApplyCharUnit(bSet
, true); break;// "Other/ApplyUserChar"
395 case 19: m_rParent
.SetShowScrollBarTips(bSet
); break;// "Window/ShowScrollBarTips",
401 void SwLayoutViewConfig::Notify( const css::uno::Sequence
< OUString
>& ) {}
403 Sequence
<OUString
> SwGridConfig::GetPropertyNames()
405 static const char* aPropNames
[] =
407 "Option/SnapToGrid", // 0
408 "Option/VisibleGrid", // 1
409 "Option/Synchronize", // 2
410 "Resolution/XAxis", // 3
411 "Resolution/YAxis", // 4
412 "Subdivision/XAxis", // 5
413 "Subdivision/YAxis" // 6
415 const int nCount
= 7;
416 Sequence
<OUString
> aNames(nCount
);
417 OUString
* pNames
= aNames
.getArray();
418 for(int i
= 0; i
< nCount
; i
++)
420 pNames
[i
] = OUString::createFromAscii(aPropNames
[i
]);
425 SwGridConfig::SwGridConfig(bool bIsWeb
, SwMasterUsrPref
& rPar
) :
426 ConfigItem(bIsWeb
? OUString("Office.WriterWeb/Grid") : OUString("Office.Writer/Grid"),
427 ConfigItemMode::ReleaseTree
),
432 SwGridConfig::~SwGridConfig()
436 void SwGridConfig::ImplCommit()
438 Sequence
<OUString
> aNames
= GetPropertyNames();
440 Sequence
<Any
> aValues(aNames
.getLength());
441 Any
* pValues
= aValues
.getArray();
443 for(int nProp
= 0; nProp
< aNames
.getLength(); nProp
++)
447 case 0: pValues
[nProp
] <<= m_rParent
.IsSnap(); break;// "Option/SnapToGrid",
448 case 1: pValues
[nProp
] <<= m_rParent
.IsGridVisible(); break;//"Option/VisibleGrid",
449 case 2: pValues
[nProp
] <<= m_rParent
.IsSynchronize(); break;// "Option/Synchronize",
450 case 3: pValues
[nProp
] <<= static_cast<sal_Int32
>(convertTwipToMm100(m_rParent
.GetSnapSize().Width())); break;// "Resolution/XAxis",
451 case 4: pValues
[nProp
] <<= static_cast<sal_Int32
>(convertTwipToMm100(m_rParent
.GetSnapSize().Height())); break;// "Resolution/YAxis",
452 case 5: pValues
[nProp
] <<= static_cast<sal_Int16
>(m_rParent
.GetDivisionX()); break;// "Subdivision/XAxis",
453 case 6: pValues
[nProp
] <<= static_cast<sal_Int16
>(m_rParent
.GetDivisionY()); break;// "Subdivision/YAxis"
456 PutProperties(aNames
, aValues
);
459 void SwGridConfig::Load()
461 Sequence
<OUString
> aNames
= GetPropertyNames();
462 Sequence
<Any
> aValues
= GetProperties(aNames
);
463 const Any
* pValues
= aValues
.getConstArray();
464 OSL_ENSURE(aValues
.getLength() == aNames
.getLength(), "GetProperties failed");
465 if(aValues
.getLength() != aNames
.getLength())
468 Size
aSnap(m_rParent
.GetSnapSize());
469 for(int nProp
= 0; nProp
< aNames
.getLength(); nProp
++)
471 if(pValues
[nProp
].hasValue())
473 bool bSet
= nProp
< 3 && *o3tl::doAccess
<bool>(pValues
[nProp
]);
476 pValues
[nProp
] >>= nSet
;
479 case 0: m_rParent
.SetSnap(bSet
); break;// "Option/SnapToGrid",
480 case 1: m_rParent
.SetGridVisible(bSet
); break;//"Option/VisibleGrid",
481 case 2: m_rParent
.SetSynchronize(bSet
); break;// "Option/Synchronize",
482 case 3: aSnap
.setWidth( o3tl::toTwips(nSet
, o3tl::Length::mm100
) ); break;// "Resolution/XAxis",
483 case 4: aSnap
.setHeight( o3tl::toTwips(nSet
, o3tl::Length::mm100
) ); break;// "Resolution/YAxis",
484 case 5: m_rParent
.SetDivisionX(static_cast<short>(nSet
)); break;// "Subdivision/XAxis",
485 case 6: m_rParent
.SetDivisionY(static_cast<short>(nSet
)); break;// "Subdivision/YAxis"
489 m_rParent
.SetSnapSize(aSnap
);
492 void SwGridConfig::Notify( const css::uno::Sequence
< OUString
>& ) {}
494 Sequence
<OUString
> SwCursorConfig::GetPropertyNames()
496 static const char* aPropNames
[] =
498 "DirectCursor/UseDirectCursor", // 0
499 "DirectCursor/Insert", // 1
500 "Option/ProtectedArea", // 2
502 const int nCount
= SAL_N_ELEMENTS(aPropNames
);
503 Sequence
<OUString
> aNames(nCount
);
504 OUString
* pNames
= aNames
.getArray();
505 for(int i
= 0; i
< nCount
; i
++)
506 pNames
[i
] = OUString::createFromAscii(aPropNames
[i
]);
510 SwCursorConfig::SwCursorConfig(SwMasterUsrPref
& rPar
) :
511 ConfigItem("Office.Writer/Cursor", ConfigItemMode::ReleaseTree
),
516 SwCursorConfig::~SwCursorConfig()
520 void SwCursorConfig::ImplCommit()
522 Sequence
<OUString
> aNames
= GetPropertyNames();
524 Sequence
<Any
> aValues(aNames
.getLength());
525 Any
* pValues
= aValues
.getArray();
527 for(int nProp
= 0; nProp
< aNames
.getLength(); nProp
++)
531 case 0: pValues
[nProp
] <<= m_rParent
.IsShadowCursor(); break; // "DirectCursor/UseDirectCursor",
532 case 1: pValues
[nProp
] <<= static_cast<sal_Int32
>(m_rParent
.GetShdwCursorFillMode()); break; // "DirectCursor/Insert",
533 case 2: pValues
[nProp
] <<= m_rParent
.IsCursorInProtectedArea(); break; // "Option/ProtectedArea"
536 PutProperties(aNames
, aValues
);
539 void SwCursorConfig::Load()
541 Sequence
<OUString
> aNames
= GetPropertyNames();
542 Sequence
<Any
> aValues
= GetProperties(aNames
);
543 const Any
* pValues
= aValues
.getConstArray();
544 OSL_ENSURE(aValues
.getLength() == aNames
.getLength(), "GetProperties failed");
545 if(aValues
.getLength() != aNames
.getLength())
549 for(int nProp
= 0; nProp
< aNames
.getLength(); nProp
++)
551 if(pValues
[nProp
].hasValue())
556 bSet
= *o3tl::doAccess
<bool>(pValues
[nProp
]);
558 pValues
[nProp
] >>= nSet
;
561 case 0: m_rParent
.SetShadowCursor(bSet
); break; // "DirectCursor/UseDirectCursor",
562 case 1: m_rParent
.SetShdwCursorFillMode(static_cast<SwFillMode
>(nSet
)); break; // "DirectCursor/Insert",
563 case 2: m_rParent
.SetCursorInProtectedArea(bSet
); break; // "Option/ProtectedArea"
569 void SwCursorConfig::Notify( const css::uno::Sequence
< OUString
>& ) {}
571 SwWebColorConfig::SwWebColorConfig(SwMasterUsrPref
& rPar
) :
572 ConfigItem("Office.WriterWeb/Background", ConfigItemMode::ReleaseTree
),
576 m_aPropNames
.getArray()[0] = "Color";
579 SwWebColorConfig::~SwWebColorConfig()
583 void SwWebColorConfig::ImplCommit()
585 Sequence
<Any
> aValues(m_aPropNames
.getLength());
586 Any
* pValues
= aValues
.getArray();
587 for(int nProp
= 0; nProp
< m_aPropNames
.getLength(); nProp
++)
591 case 0: pValues
[nProp
] <<= m_rParent
.GetRetoucheColor(); break;// "Color",
594 PutProperties(m_aPropNames
, aValues
);
597 void SwWebColorConfig::Notify( const css::uno::Sequence
< OUString
>& ) {}
599 void SwWebColorConfig::Load()
601 Sequence
<Any
> aValues
= GetProperties(m_aPropNames
);
602 const Any
* pValues
= aValues
.getConstArray();
603 OSL_ENSURE(aValues
.getLength() == m_aPropNames
.getLength(), "GetProperties failed");
604 if(aValues
.getLength() != m_aPropNames
.getLength())
607 for(int nProp
= 0; nProp
< m_aPropNames
.getLength(); nProp
++)
609 if(pValues
[nProp
].hasValue())
615 pValues
[nProp
] >>= nSet
; m_rParent
.SetRetoucheColor(nSet
);
622 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */