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 <comphelper/configuration.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>
33 #if defined(__GNUC__) && !defined(__clang__)
38 using namespace ::com::sun::star
;
39 using namespace ::com::sun::star::uno
;
41 void SwMasterUsrPref::SetUsrPref(const SwViewOption
&rCopy
)
43 *static_cast<SwViewOption
*>(this) = rCopy
;
46 static FieldUnit
lclGetFieldUnit()
48 if (comphelper::IsFuzzing())
50 MeasurementSystem eSystem
= SvtSysLocale().GetLocaleData().getMeasurementSystemEnum();
51 return MeasurementSystem::Metric
== eSystem
? FieldUnit::CM
: FieldUnit::INCH
;
54 SwMasterUsrPref::SwMasterUsrPref(bool bWeb
) :
55 m_eFieldUpdateFlags(AUTOUPD_OFF
),
57 m_eUserMetric(lclGetFieldUnit()),
58 m_eHScrollMetric(m_eUserMetric
),
59 m_bIsHScrollMetricSet(false),
60 m_eVScrollMetric(m_eUserMetric
),
61 m_bIsVScrollMetricSet(false),
62 m_nDefTabInMm100( 2000 ), // 2 cm
63 m_bIsSquaredPageMode(false),
64 m_bIsAlignMathObjectsToBaseline(false),
65 m_aContentConfig(bWeb
, *this),
66 m_aLayoutConfig(bWeb
, *this),
67 m_aGridConfig(bWeb
, *this),
68 m_aCursorConfig(*this),
69 m_pWebColorConfig(bWeb
? new SwWebColorConfig(*this) : nullptr),
70 m_aFmtAidsAutoComplConfig(*this),
71 m_bApplyCharUnit(false),
72 m_bUseDefaultZoom(true),
73 m_nDefaultZoomValue(100),
74 m_eDefaultZoomType(SvxZoomType::PERCENT
)
76 if (comphelper::IsFuzzing())
79 SetCore2Option(true, ViewOptCoreFlags2::CursorInProt
);
80 SetCore2Option(false, ViewOptCoreFlags2::HiddenPara
);
81 m_nDefTabInMm100
= 1250;
86 SwMasterUsrPref::~SwMasterUsrPref()
90 const auto g_UpdateLinkIndex
= 17;
91 const auto g_DefaultAnchor
= 25;
92 const auto g_ZoomType
= 27;
93 const auto g_ZoomValue
= 28;
95 Sequence
<OUString
> SwContentViewConfig::GetPropertyNames() const
97 static constexpr const char*const aPropNames
[] =
99 "Display/GraphicObject", // 0
100 "Display/Table", // 1
101 "Display/DrawingControl", // 2
102 "Display/FieldCode", // 3
104 "Display/ShowContentTips", // 5
105 "NonprintingCharacter/MetaCharacters", // 6
106 "NonprintingCharacter/ParagraphEnd", // 7
107 "NonprintingCharacter/OptionalHyphen", // 8
108 "NonprintingCharacter/Space", // 9
109 "NonprintingCharacter/Break", // 10
110 "NonprintingCharacter/ProtectedSpace", // 11
111 "NonprintingCharacter/Tab", // 12 //not in Writer/Web
112 "NonprintingCharacter/HiddenText", // 13
113 "NonprintingCharacter/HiddenParagraph", // 14
114 "NonprintingCharacter/HiddenCharacter", // 15
115 "NonprintingCharacter/Bookmarks", // 16
117 "Update/Field", // 18
118 "Update/Chart", // 19
119 "Display/ShowInlineTooltips", // 20
120 "Display/UseHeaderFooterMenu", // 21
121 "Display/ShowOutlineContentVisibilityButton", // 22
122 "Display/TreatSubOutlineLevelsAsContent", // 23
123 "Display/ShowChangesInMargin", // 24
124 "Display/DefaultAnchor", // 25
125 "Zoom/DefaultZoom", // 26
126 "Zoom/ZoomType", // 27
127 "Zoom/ZoomValue", // 28
128 "Display/TextBoundaries", // 29
129 "Display/TextBoundariesFull", // 30
130 "Display/SectionBoundaries", // 31
131 "Display/TableBoundaries", // 32
132 "Display/ShowBoundaries" // 33
134 #if defined(__GNUC__) && !defined(__clang__)
135 // clang 8.0.0 says strcmp isn't constexpr
136 static_assert(std::strcmp("Update/Link", aPropNames
[g_UpdateLinkIndex
]) == 0);
137 static_assert(std::strcmp("Display/DefaultAnchor", aPropNames
[g_DefaultAnchor
]) == 0);
138 static_assert(std::strcmp("Zoom/ZoomType", aPropNames
[g_ZoomType
]) == 0);
139 static_assert(std::strcmp("Zoom/ZoomValue", aPropNames
[g_ZoomValue
]) == 0);
141 const int nCount
= m_bWeb
? 12 : SAL_N_ELEMENTS(aPropNames
);
142 Sequence
<OUString
> aNames(nCount
);
143 OUString
* pNames
= aNames
.getArray();
144 for(int i
= 0; i
< nCount
; i
++)
146 pNames
[i
] = OUString::createFromAscii(aPropNames
[i
]);
151 SwContentViewConfig::SwContentViewConfig(bool bIsWeb
, SwMasterUsrPref
& rPar
) :
152 ConfigItem(bIsWeb
? u
"Office.WriterWeb/Content"_ustr
: u
"Office.Writer/Content"_ustr
),
157 EnableNotification( GetPropertyNames() );
160 SwContentViewConfig::~SwContentViewConfig()
164 void SwContentViewConfig::Notify( const Sequence
< OUString
> & /*rPropertyNames*/ )
169 void SwContentViewConfig::ImplCommit()
171 Sequence
<OUString
> aNames
= GetPropertyNames();
173 Sequence
<Any
> aValues(aNames
.getLength());
174 Any
* pValues
= aValues
.getArray();
176 for(int nProp
= 0; nProp
< aNames
.getLength(); nProp
++)
181 case 0: bVal
= m_rParent
.IsGraphic(); break;// "Display/GraphicObject",
182 case 1: bVal
= m_rParent
.IsTable(); break;// "Display/Table",
183 case 2: bVal
= m_rParent
.IsDraw(); break;// "Display/DrawingControl",
184 case 3: bVal
= m_rParent
.IsFieldName(); break;// "Display/FieldCode",
185 case 4: bVal
= m_rParent
.IsPostIts(); break;// "Display/Note",
186 case 5: bVal
= m_rParent
.IsShowContentTips(); break; // "Display/ShowContentTips"
187 case 6: bVal
= m_rParent
.IsViewMetaChars(); break; //"NonprintingCharacter/MetaCharacters"
188 case 7: bVal
= m_rParent
.IsParagraph(true); break;// "NonprintingCharacter/ParagraphEnd",
189 case 8: bVal
= m_rParent
.IsSoftHyph(); break;// "NonprintingCharacter/OptionalHyphen",
190 case 9: bVal
= m_rParent
.IsBlank(true); break;// "NonprintingCharacter/Space",
191 case 10: bVal
= m_rParent
.IsLineBreak(true);break;// "NonprintingCharacter/Break",
192 case 11: bVal
= m_rParent
.IsHardBlank(); break;// "NonprintingCharacter/ProtectedSpace",
193 case 12: bVal
= m_rParent
.IsTab(true); break;// "NonprintingCharacter/Tab",
194 case 13: bVal
= m_rParent
.IsShowHiddenField(); break;// "NonprintingCharacter/Fields: HiddenText",
195 case 14: bVal
= m_rParent
.IsShowHiddenPara(); break;// "NonprintingCharacter/Fields: HiddenParagraph",
196 case 15: bVal
= m_rParent
.IsShowHiddenChar(true); break;// "NonprintingCharacter/HiddenCharacter",
197 case 16: bVal
= m_rParent
.IsShowBookmarks(true); break;// "NonprintingCharacter/Bookmarks",
198 case 17: pValues
[nProp
] <<= m_rParent
.GetUpdateLinkMode(); break;// "Update/Link",
199 case 18: bVal
= m_rParent
.IsUpdateFields(); break;// "Update/Field",
200 case 19: bVal
= m_rParent
.IsUpdateCharts(); break;// "Update/Chart"
201 case 20: bVal
= m_rParent
.IsShowInlineTooltips(); break;// "Display/ShowInlineTooltips"
202 case 21: bVal
= m_rParent
.IsUseHeaderFooterMenu(); break;// "Display/UseHeaderFooterMenu"
203 case 22: bVal
= m_rParent
.IsShowOutlineContentVisibilityButton(); break;// "Display/ShowOutlineContentVisibilityButton"
204 case 23: bVal
= m_rParent
.IsTreatSubOutlineLevelsAsContent(); break;// "Display/TreatSubOutlineLevelsAsContent"
205 case 24: bVal
= m_rParent
.IsShowChangesInMargin(); break;// "Display/ShowChangesInMargin"
206 case 25: pValues
[nProp
] <<= m_rParent
.GetDefaultAnchor(); break;// "Display/DefaultAnchor"
207 //TODO: Save zoom preferred, zoom type, zoom value
208 case 26: bVal
= m_rParent
.IsDefaultZoom(); break;// "Zoom/DefaultZoom"
209 case 27:pValues
[nProp
] <<= static_cast<sal_Int32
>(m_rParent
.GetDefaultZoomType()); break; // "Zoom/ZoomType"
210 case 28: pValues
[nProp
] <<= static_cast<sal_Int32
>(m_rParent
.GetDefaultZoomValue()); break; // "Zoom/ZoomValue"
211 case 29: bVal
= m_rParent
.IsTextBoundaries(); break; // "Display/TextBoundaries"
212 case 30: bVal
= m_rParent
.IsTextBoundariesFull(); break; // "Display/TextBoundariesFull"
213 case 31: bVal
= m_rParent
.IsSectionBoundaries(); break; // "Display/SectionBoundaries"
214 case 32: bVal
= m_rParent
.IsTableBoundaries(); break; // "Display/TableBoundaries"
215 case 33: bVal
= m_rParent
.IsShowBoundaries(); break; // "Display/ShowBoundaries"
217 if ((nProp
!= g_UpdateLinkIndex
) && (nProp
!= g_DefaultAnchor
) &&
218 (nProp
!= g_ZoomType
) && (nProp
!= g_ZoomValue
))
219 pValues
[nProp
] <<= bVal
;
221 PutProperties(aNames
, aValues
);
224 void SwContentViewConfig::Load()
226 Sequence
<OUString
> aNames
= GetPropertyNames();
227 Sequence
<Any
> aValues
= GetProperties(aNames
);
228 const Any
* pValues
= aValues
.getConstArray();
229 OSL_ENSURE(aValues
.getLength() == aNames
.getLength(), "GetProperties failed");
230 if(aValues
.getLength() != aNames
.getLength())
232 for(int nProp
= 0; nProp
< aNames
.getLength(); nProp
++)
234 if(pValues
[nProp
].hasValue())
236 bool bSet
= ((nProp
!= g_UpdateLinkIndex
) && (nProp
!= g_DefaultAnchor
) && (nProp
!= g_ZoomType
)&& (nProp
!= g_ZoomValue
))
237 && *o3tl::doAccess
<bool>(pValues
[nProp
]);
240 case 0: m_rParent
.SetGraphic(bSet
); break;// "Display/GraphicObject",
241 case 1: m_rParent
.SetTable(bSet
); break;// "Display/Table",
242 case 2: m_rParent
.SetDraw(bSet
); break;// "Display/DrawingControl",
243 case 3: m_rParent
.SetFieldName(bSet
); break;// "Display/FieldCode",
244 case 4: m_rParent
.SetPostIts(bSet
); break;// "Display/Note",
245 case 5: m_rParent
.SetShowContentTips(bSet
); break;// "Display/ShowContentTips",
246 case 6: m_rParent
.SetViewMetaChars(bSet
); break; //"NonprintingCharacter/MetaCharacters"
247 case 7: m_rParent
.SetParagraph(bSet
); break;// "NonprintingCharacter/ParagraphEnd",
248 case 8: m_rParent
.SetSoftHyph(bSet
); break;// "NonprintingCharacter/OptionalHyphen",
249 case 9: m_rParent
.SetBlank(bSet
); break;// "NonprintingCharacter/Space",
250 case 10: m_rParent
.SetLineBreak(bSet
);break;// "NonprintingCharacter/Break",
251 case 11: m_rParent
.SetHardBlank(bSet
); break;// "NonprintingCharacter/ProtectedSpace",
252 case 12: m_rParent
.SetTab(bSet
); break;// "NonprintingCharacter/Tab",
253 case 13: m_rParent
.SetShowHiddenField(bSet
); break;// "NonprintingCharacter/Fields: HiddenText",
254 case 14: m_rParent
.SetShowHiddenPara(bSet
); break;// "NonprintingCharacter/Fields: HiddenParagraph",
255 case 15: m_rParent
.SetShowHiddenChar(bSet
); break;// "NonprintingCharacter/HiddenCharacter",
256 case 16: m_rParent
.SetShowBookmarks(bSet
); break;// "NonprintingCharacter/Bookmarks",
260 pValues
[nProp
] >>= nSet
;
261 m_rParent
.SetUpdateLinkMode(nSet
, true);
263 break;// "Update/Link",
264 case 18: m_rParent
.SetUpdateFields(bSet
); break;// "Update/Field",
265 case 19: m_rParent
.SetUpdateCharts(bSet
); break;// "Update/Chart"
266 case 20: m_rParent
.SetShowInlineTooltips(bSet
); break;// "Display/ShowInlineTooltips"
267 case 21: m_rParent
.SetUseHeaderFooterMenu(bSet
); break;// "Display/UseHeaderFooterMenu"
268 case 22: m_rParent
.SetShowOutlineContentVisibilityButton(bSet
); break;// "Display/ShowOutlineContententVisibilityButton"
269 case 23: m_rParent
.SetTreatSubOutlineLevelsAsContent(bSet
); break;// "Display/TreatSubOutlineLevelsAsContent"
270 case 24: m_rParent
.SetShowChangesInMargin(bSet
); break;// "Display/ShowChangesInMargin"
274 pValues
[nProp
] >>= nSet
;
275 m_rParent
.SetDefaultAnchor(nSet
);
277 break; // "Display/DefaultAnchor"
278 case 26: m_rParent
.SetDefaultZoom(bSet
); break; // "Zoom/DefaultZoom"
282 pValues
[nProp
] >>= nSet
;
283 m_rParent
.SetDefaultZoomType(static_cast<SvxZoomType
>(nSet
), true);
285 break; //"Zoom/ZoomType", // 27
289 pValues
[nProp
] >>= nSet
;
290 m_rParent
.SetDefaultZoomValue(static_cast<sal_uInt16
>(nSet
), true);
292 break; //"Zoom/ZoomValue" // 28
293 case 29: m_rParent
.SetTextBoundaries(bSet
); break; //"Display/TextBoundaries"
294 case 30: m_rParent
.SetTextBoundariesFull(bSet
); break; //"Display/TextBoundariesFull"
295 case 31: m_rParent
.SetSectionBoundaries(bSet
); break; //"Display/SectionBoundaries"
296 case 32: m_rParent
.SetTableBoundaries(bSet
); break; //"Display/TableBoundaries"
297 case 33: m_rParent
.SetShowBoundaries(bSet
); break; //"Display/ShowBoundaries"
303 Sequence
<OUString
> SwLayoutViewConfig::GetPropertyNames() const
305 static const char* aPropNames
[] =
308 "Window/HorizontalScroll", // 1
309 "Window/VerticalScroll", // 2
310 "Window/ShowRulers", // 3
311 "Window/HorizontalRuler", // 4
312 "Window/VerticalRuler", // 5
313 "Window/HorizontalRulerUnit", // 6
314 "Window/VerticalRulerUnit", // 7
315 "Window/SmoothScroll", // 8
318 "Other/IsAlignMathObjectsToBaseline", //11
319 "Other/MeasureUnit", //12
320 // below properties are not available in WriterWeb
321 "Other/TabStop", //13
322 "Window/IsVerticalRulerRight", //14
323 "ViewLayout/Columns", //15
324 "ViewLayout/BookMode", //16
325 "Other/IsSquaredPageMode", //17
326 "Other/ApplyCharUnit", //18
327 "Window/ShowScrollBarTips", //19
329 const int nCount
= m_bWeb
? 13 : 20;
330 Sequence
<OUString
> aNames(nCount
);
331 OUString
* pNames
= aNames
.getArray();
332 for(int i
= 0; i
< nCount
; i
++)
334 pNames
[i
] = OUString::createFromAscii(aPropNames
[i
]);
339 SwLayoutViewConfig::SwLayoutViewConfig(bool bIsWeb
, SwMasterUsrPref
& rPar
)
340 : ConfigItem(bIsWeb
? u
"Office.WriterWeb/Layout"_ustr
: u
"Office.Writer/Layout"_ustr
)
345 EnableNotification(GetPropertyNames());
348 SwLayoutViewConfig::~SwLayoutViewConfig()
352 void SwLayoutViewConfig::ImplCommit()
354 Sequence
<OUString
> aNames
= GetPropertyNames();
356 Sequence
<Any
> aValues(aNames
.getLength());
357 Any
* pValues
= aValues
.getArray();
359 for(int nProp
= 0; nProp
< aNames
.getLength(); nProp
++)
361 Any
&rVal
= pValues
[nProp
];
364 case 0: rVal
<<= m_rParent
.IsCrossHair(); break; // "Line/Guide",
365 case 1: rVal
<<= m_rParent
.IsViewHScrollBar(); break; // "Window/HorizontalScroll",
366 case 2: rVal
<<= m_rParent
.IsViewVScrollBar(); break; // "Window/VerticalScroll",
367 case 3: rVal
<<= m_rParent
.IsViewAnyRuler(); break; // "Window/ShowRulers"
368 // #i14593# use IsView*Ruler(true) instead of IsView*Ruler()
369 // this preserves the single ruler states even if "Window/ShowRulers" is off
370 case 4: rVal
<<= m_rParent
.IsViewHRuler(true); break; // "Window/HorizontalRuler",
371 case 5: rVal
<<= m_rParent
.IsViewVRuler(true); break; // "Window/VerticalRuler",
373 if(m_rParent
.m_bIsHScrollMetricSet
)
374 rVal
<<= static_cast<sal_Int32
>(m_rParent
.m_eHScrollMetric
); // "Window/HorizontalRulerUnit"
377 if(m_rParent
.m_bIsVScrollMetricSet
)
378 rVal
<<= static_cast<sal_Int32
>(m_rParent
.m_eVScrollMetric
); // "Window/VerticalRulerUnit"
380 case 8: rVal
<<= m_rParent
.IsSmoothScroll(); break; // "Window/SmoothScroll",
381 case 9: rVal
<<= static_cast<sal_Int32
>(m_rParent
.GetZoom()); break; // "Zoom/Value",
382 case 10: rVal
<<= static_cast<sal_Int32
>(m_rParent
.GetZoomType()); break; // "Zoom/Type",
383 case 11: rVal
<<= m_rParent
.IsAlignMathObjectsToBaseline(); break; // "Other/IsAlignMathObjectsToBaseline"
384 case 12: rVal
<<= static_cast<sal_Int32
>(m_rParent
.GetMetric()); break; // "Other/MeasureUnit",
385 case 13: rVal
<<= m_rParent
.GetDefTabInMm100(); break;// "Other/TabStop",
386 case 14: rVal
<<= m_rParent
.IsVRulerRight(); break; // "Window/IsVerticalRulerRight",
387 case 15: rVal
<<= static_cast<sal_Int32
>(m_rParent
.GetViewLayoutColumns()); break; // "ViewLayout/Columns",
388 case 16: rVal
<<= m_rParent
.IsViewLayoutBookMode(); break; // "ViewLayout/BookMode",
389 case 17: rVal
<<= m_rParent
.IsSquaredPageMode(); break; // "Other/IsSquaredPageMode",
390 case 18: rVal
<<= m_rParent
.IsApplyCharUnit(); break; // "Other/ApplyCharUnit",
391 case 19: rVal
<<= m_rParent
.IsShowScrollBarTips(); break; // "Window/ShowScrollBarTips",
394 PutProperties(aNames
, aValues
);
397 void SwLayoutViewConfig::Load()
399 Sequence
<OUString
> aNames
= GetPropertyNames();
400 Sequence
<Any
> aValues
= GetProperties(aNames
);
401 const Any
* pValues
= aValues
.getConstArray();
402 OSL_ENSURE(aValues
.getLength() == aNames
.getLength(), "GetProperties failed");
403 if(aValues
.getLength() != aNames
.getLength())
406 for(int nProp
= 0; nProp
< aNames
.getLength(); nProp
++)
408 if(pValues
[nProp
].hasValue())
410 sal_Int32 nInt32Val
= 0;
412 pValues
[nProp
] >>= nInt32Val
;
413 pValues
[nProp
] >>= bSet
;
417 case 0: m_rParent
.SetCrossHair(bSet
); break;// "Line/Guide",
418 case 1: m_rParent
.SetViewHScrollBar(bSet
); break;// "Window/HorizontalScroll",
419 case 2: m_rParent
.SetViewVScrollBar(bSet
); break;// "Window/VerticalScroll",
420 case 3: m_rParent
.SetViewAnyRuler(bSet
);break; // "Window/ShowRulers"
421 case 4: m_rParent
.SetViewHRuler(bSet
); break;// "Window/HorizontalRuler",
422 case 5: m_rParent
.SetViewVRuler(bSet
); break;// "Window/VerticalRuler",
425 m_rParent
.m_bIsHScrollMetricSet
= true;
426 m_rParent
.m_eHScrollMetric
= static_cast<FieldUnit
>(nInt32Val
); // "Window/HorizontalRulerUnit"
431 m_rParent
.m_bIsVScrollMetricSet
= true;
432 m_rParent
.m_eVScrollMetric
= static_cast<FieldUnit
>(nInt32Val
); // "Window/VerticalRulerUnit"
435 case 8: m_rParent
.SetSmoothScroll(bSet
); break;// "Window/SmoothScroll",
436 case 9: m_rParent
.SetZoom( static_cast< sal_uInt16
>(nInt32Val
) ); break;// "Zoom/Value",
437 case 10: m_rParent
.SetZoomType( static_cast< SvxZoomType
>(nInt32Val
) ); break;// "Zoom/Type",
438 case 11: m_rParent
.SetAlignMathObjectsToBaseline(bSet
, true); break;// "Other/IsAlignMathObjectsToBaseline"
439 case 12: m_rParent
.SetMetric(static_cast<FieldUnit
>(nInt32Val
), true); break;// "Other/MeasureUnit",
440 case 13: m_rParent
.SetDefTabInMm100(nInt32Val
, true); break;// "Other/TabStop",
441 case 14: m_rParent
.SetVRulerRight(bSet
); break;// "Window/IsVerticalRulerRight",
442 case 15: m_rParent
.SetViewLayoutColumns( o3tl::narrowing
<sal_uInt16
>(nInt32Val
) ); break;// "ViewLayout/Columns",
443 case 16: m_rParent
.SetViewLayoutBookMode(bSet
); break;// "ViewLayout/BookMode",
444 case 17: m_rParent
.SetDefaultPageMode(bSet
,true); break;// "Other/IsSquaredPageMode",
445 case 18: m_rParent
.SetApplyCharUnit(bSet
, true); break;// "Other/ApplyUserChar"
446 case 19: m_rParent
.SetShowScrollBarTips(bSet
); break;// "Window/ShowScrollBarTips",
452 void SwLayoutViewConfig::Notify(const css::uno::Sequence
<OUString
>&)
457 Sequence
<OUString
> SwGridConfig::GetPropertyNames()
459 static const char* aPropNames
[] =
461 "Option/SnapToGrid", // 0
462 "Option/VisibleGrid", // 1
463 "Option/Synchronize", // 2
464 "Resolution/XAxis", // 3
465 "Resolution/YAxis", // 4
466 "Subdivision/XAxis", // 5
467 "Subdivision/YAxis" // 6
469 const int nCount
= 7;
470 Sequence
<OUString
> aNames(nCount
);
471 OUString
* pNames
= aNames
.getArray();
472 for(int i
= 0; i
< nCount
; i
++)
474 pNames
[i
] = OUString::createFromAscii(aPropNames
[i
]);
479 SwGridConfig::SwGridConfig(bool bIsWeb
, SwMasterUsrPref
& rPar
) :
480 ConfigItem(bIsWeb
? u
"Office.WriterWeb/Grid"_ustr
: u
"Office.Writer/Grid"_ustr
),
484 EnableNotification(GetPropertyNames());
487 SwGridConfig::~SwGridConfig()
491 void SwGridConfig::ImplCommit()
493 Sequence
<OUString
> aNames
= GetPropertyNames();
495 Sequence
<Any
> aValues(aNames
.getLength());
496 Any
* pValues
= aValues
.getArray();
498 for(int nProp
= 0; nProp
< aNames
.getLength(); nProp
++)
502 case 0: pValues
[nProp
] <<= m_rParent
.IsSnap(); break;// "Option/SnapToGrid",
503 case 1: pValues
[nProp
] <<= m_rParent
.IsGridVisible(); break;//"Option/VisibleGrid",
504 case 2: pValues
[nProp
] <<= m_rParent
.IsSynchronize(); break;// "Option/Synchronize",
505 case 3: pValues
[nProp
] <<= static_cast<sal_Int32
>(convertTwipToMm100(m_rParent
.GetSnapSize().Width())); break;// "Resolution/XAxis",
506 case 4: pValues
[nProp
] <<= static_cast<sal_Int32
>(convertTwipToMm100(m_rParent
.GetSnapSize().Height())); break;// "Resolution/YAxis",
507 case 5: pValues
[nProp
] <<= static_cast<sal_Int16
>(m_rParent
.GetDivisionX()); break;// "Subdivision/XAxis",
508 case 6: pValues
[nProp
] <<= static_cast<sal_Int16
>(m_rParent
.GetDivisionY()); break;// "Subdivision/YAxis"
511 PutProperties(aNames
, aValues
);
514 void SwGridConfig::Load()
516 Sequence
<OUString
> aNames
= GetPropertyNames();
517 Sequence
<Any
> aValues
= GetProperties(aNames
);
518 const Any
* pValues
= aValues
.getConstArray();
519 OSL_ENSURE(aValues
.getLength() == aNames
.getLength(), "GetProperties failed");
520 if(aValues
.getLength() != aNames
.getLength())
523 Size
aSnap(m_rParent
.GetSnapSize());
524 for(int nProp
= 0; nProp
< aNames
.getLength(); nProp
++)
526 if(pValues
[nProp
].hasValue())
528 bool bSet
= nProp
< 3 && *o3tl::doAccess
<bool>(pValues
[nProp
]);
531 pValues
[nProp
] >>= nSet
;
534 case 0: m_rParent
.SetSnap(bSet
); break;// "Option/SnapToGrid",
535 case 1: m_rParent
.SetGridVisible(bSet
); break;//"Option/VisibleGrid",
536 case 2: m_rParent
.SetSynchronize(bSet
); break;// "Option/Synchronize",
537 case 3: aSnap
.setWidth( o3tl::toTwips(nSet
, o3tl::Length::mm100
) ); break;// "Resolution/XAxis",
538 case 4: aSnap
.setHeight( o3tl::toTwips(nSet
, o3tl::Length::mm100
) ); break;// "Resolution/YAxis",
539 case 5: m_rParent
.SetDivisionX(static_cast<short>(nSet
)); break;// "Subdivision/XAxis",
540 case 6: m_rParent
.SetDivisionY(static_cast<short>(nSet
)); break;// "Subdivision/YAxis"
544 m_rParent
.SetSnapSize(aSnap
);
547 void SwGridConfig::Notify( const css::uno::Sequence
< OUString
>& )
552 Sequence
<OUString
> SwCursorConfig::GetPropertyNames()
554 static const char* aPropNames
[] =
556 "DirectCursor/UseDirectCursor", // 0
557 "DirectCursor/Insert", // 1
558 "Option/ProtectedArea", // 2
560 const int nCount
= SAL_N_ELEMENTS(aPropNames
);
561 Sequence
<OUString
> aNames(nCount
);
562 OUString
* pNames
= aNames
.getArray();
563 for(int i
= 0; i
< nCount
; i
++)
564 pNames
[i
] = OUString::createFromAscii(aPropNames
[i
]);
568 SwCursorConfig::SwCursorConfig(SwMasterUsrPref
& rPar
)
569 : ConfigItem(u
"Office.Writer/Cursor"_ustr
)
573 EnableNotification(GetPropertyNames());
576 SwCursorConfig::~SwCursorConfig()
580 void SwCursorConfig::ImplCommit()
582 Sequence
<OUString
> aNames
= GetPropertyNames();
584 Sequence
<Any
> aValues(aNames
.getLength());
585 Any
* pValues
= aValues
.getArray();
587 for(int nProp
= 0; nProp
< aNames
.getLength(); nProp
++)
591 case 0: pValues
[nProp
] <<= m_rParent
.IsShadowCursor(); break; // "DirectCursor/UseDirectCursor",
592 case 1: pValues
[nProp
] <<= static_cast<sal_Int32
>(m_rParent
.GetShdwCursorFillMode()); break; // "DirectCursor/Insert",
593 case 2: pValues
[nProp
] <<= m_rParent
.IsCursorInProtectedArea(); break; // "Option/ProtectedArea"
596 PutProperties(aNames
, aValues
);
599 void SwCursorConfig::Load()
601 Sequence
<OUString
> aNames
= GetPropertyNames();
602 Sequence
<Any
> aValues
= GetProperties(aNames
);
603 const Any
* pValues
= aValues
.getConstArray();
604 OSL_ENSURE(aValues
.getLength() == aNames
.getLength(), "GetProperties failed");
605 if(aValues
.getLength() != aNames
.getLength())
609 for(int nProp
= 0; nProp
< aNames
.getLength(); nProp
++)
611 if(pValues
[nProp
].hasValue())
616 bSet
= *o3tl::doAccess
<bool>(pValues
[nProp
]);
618 pValues
[nProp
] >>= nSet
;
621 case 0: m_rParent
.SetShadowCursor(bSet
); break; // "DirectCursor/UseDirectCursor",
622 case 1: m_rParent
.SetShdwCursorFillMode(static_cast<SwFillMode
>(nSet
)); break; // "DirectCursor/Insert",
623 case 2: m_rParent
.SetCursorInProtectedArea(bSet
); break; // "Option/ProtectedArea"
629 void SwCursorConfig::Notify(const css::uno::Sequence
<OUString
>& )
634 Sequence
<OUString
> SwFmtAidsAutoComplConfig::GetPropertyNames()
636 static const char* aPropNames
[] = {
637 "EncloseWithCharacters", // 0
639 const int nCount
= SAL_N_ELEMENTS(aPropNames
);
640 Sequence
<OUString
> aNames(nCount
);
641 OUString
* pNames
= aNames
.getArray();
642 for (int i
= 0; i
< nCount
; i
++)
643 pNames
[i
] = OUString::createFromAscii(aPropNames
[i
]);
647 SwFmtAidsAutoComplConfig::SwFmtAidsAutoComplConfig(SwMasterUsrPref
& rPar
)
648 : ConfigItem(u
"Office.Writer/FmtAidsAutocomplete"_ustr
)
652 EnableNotification(GetPropertyNames());
655 SwFmtAidsAutoComplConfig::~SwFmtAidsAutoComplConfig() {}
657 void SwFmtAidsAutoComplConfig::ImplCommit()
659 Sequence
<OUString
> aNames
= GetPropertyNames();
661 Sequence
<Any
> aValues(aNames
.getLength());
662 Any
* pValues
= aValues
.getArray();
664 for (int nProp
= 0; nProp
< aNames
.getLength(); nProp
++)
669 pValues
[nProp
] <<= m_rParent
.IsEncloseWithCharactersOn();
670 break; // "FmtAidsAutocomplete/EncloseWithCharacters"
673 PutProperties(aNames
, aValues
);
676 void SwFmtAidsAutoComplConfig::Load()
678 Sequence
<OUString
> aNames
= GetPropertyNames();
679 Sequence
<Any
> aValues
= GetProperties(aNames
);
680 const Any
* pValues
= aValues
.getConstArray();
681 OSL_ENSURE(aValues
.getLength() == aNames
.getLength(), "GetProperties failed");
682 if (aValues
.getLength() != aNames
.getLength())
685 for (int nProp
= 0; nProp
< aNames
.getLength(); nProp
++)
687 if (pValues
[nProp
].hasValue())
694 pValues
[nProp
] >>= bSet
;
695 m_rParent
.SetEncloseWithCharactersOn(bSet
);
696 break; // "FmtAidsAutocomplete/EncloseWithCharacters"
703 void SwFmtAidsAutoComplConfig::Notify(const css::uno::Sequence
<OUString
>&)
708 SwWebColorConfig::SwWebColorConfig(SwMasterUsrPref
& rPar
)
709 : ConfigItem(u
"Office.WriterWeb/Background"_ustr
)
713 m_aPropNames
.getArray()[0] = "Color";
715 EnableNotification(m_aPropNames
);
718 SwWebColorConfig::~SwWebColorConfig()
722 void SwWebColorConfig::ImplCommit()
724 Sequence
<Any
> aValues(m_aPropNames
.getLength());
725 Any
* pValues
= aValues
.getArray();
726 for(int nProp
= 0; nProp
< m_aPropNames
.getLength(); nProp
++)
730 case 0: pValues
[nProp
] <<= m_rParent
.GetRetoucheColor(); break;// "Color",
733 PutProperties(m_aPropNames
, aValues
);
736 void SwWebColorConfig::Notify(const css::uno::Sequence
<OUString
>&)
741 void SwWebColorConfig::Load()
743 Sequence
<Any
> aValues
= GetProperties(m_aPropNames
);
744 const Any
* pValues
= aValues
.getConstArray();
745 OSL_ENSURE(aValues
.getLength() == m_aPropNames
.getLength(), "GetProperties failed");
746 if(aValues
.getLength() != m_aPropNames
.getLength())
749 for(int nProp
= 0; nProp
< m_aPropNames
.getLength(); nProp
++)
751 if(pValues
[nProp
].hasValue())
757 pValues
[nProp
] >>= nSet
; m_rParent
.SetRetoucheColor(nSet
);
764 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */