/src/libreoffice/sw/source/uibase/config/usrpref.cxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
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/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
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 . |
18 | | */ |
19 | | |
20 | | #include <sal/config.h> |
21 | | |
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> |
27 | | |
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> |
32 | | |
33 | | #if defined(__GNUC__) && !defined(__clang__) |
34 | | #include <cstring> |
35 | | #endif |
36 | | |
37 | | using namespace utl; |
38 | | using namespace ::com::sun::star; |
39 | | using namespace ::com::sun::star::uno; |
40 | | |
41 | | void SwMasterUsrPref::SetUsrPref(const SwViewOption &rCopy) |
42 | 0 | { |
43 | 0 | *static_cast<SwViewOption*>(this) = rCopy; |
44 | 0 | } |
45 | | |
46 | | static FieldUnit lclGetFieldUnit() |
47 | 10 | { |
48 | 10 | if (comphelper::IsFuzzing()) |
49 | 10 | return FieldUnit::CM; |
50 | 0 | MeasurementSystem eSystem = SvtSysLocale().GetLocaleData().getMeasurementSystemEnum(); |
51 | 0 | return MeasurementSystem::Metric == eSystem ? FieldUnit::CM : FieldUnit::INCH; |
52 | 10 | } |
53 | | |
54 | | SwMasterUsrPref::SwMasterUsrPref(bool bWeb) : |
55 | 10 | m_eFieldUpdateFlags(AUTOUPD_OFF), |
56 | 10 | m_nLinkUpdateMode(0), |
57 | 10 | m_eUserMetric(lclGetFieldUnit()), |
58 | 10 | m_eHScrollMetric(m_eUserMetric), |
59 | 10 | m_bIsHScrollMetricSet(false), |
60 | 10 | m_eVScrollMetric(m_eUserMetric), |
61 | 10 | m_bIsVScrollMetricSet(false), |
62 | 10 | m_nDefTabInMm100( 2000 ), // 2 cm |
63 | 10 | m_bIsSquaredPageMode(false), |
64 | 10 | m_bIsAlignMathObjectsToBaseline(false), |
65 | 10 | m_bApplyCharUnit(false), |
66 | 10 | m_bUseDefaultZoom(true), |
67 | 10 | m_nDefaultZoomValue(100), |
68 | 10 | m_eDefaultZoomType(SvxZoomType::PERCENT), |
69 | 10 | m_aContentConfig(bWeb, *this), |
70 | 10 | m_aLayoutConfig(bWeb, *this), |
71 | 10 | m_aGridConfig(bWeb, *this), |
72 | 10 | m_aCursorConfig(*this), |
73 | 10 | m_pWebColorConfig(bWeb ? new SwWebColorConfig(*this) : nullptr), |
74 | 10 | m_aFmtAidsAutoComplConfig(*this), |
75 | 10 | m_aBaselineGridConfig(bWeb ? nullptr : std::make_unique<SwBaselineGridConfig>(*this)) |
76 | 10 | { |
77 | 10 | if (comphelper::IsFuzzing()) |
78 | 10 | { |
79 | | // match defaults |
80 | 10 | SetCore2Option(true, ViewOptCoreFlags2::CursorInProt); |
81 | 10 | SetCore2Option(false, ViewOptCoreFlags2::HiddenPara); |
82 | 10 | m_nDefTabInMm100 = 1250; |
83 | 10 | return; |
84 | 10 | } |
85 | 10 | } |
86 | | |
87 | | SwMasterUsrPref::~SwMasterUsrPref() |
88 | 0 | { |
89 | 0 | } |
90 | | |
91 | | const auto g_UpdateLinkIndex = 17; |
92 | | const auto g_DefaultAnchor = 25; |
93 | | const auto g_ZoomType = 27; |
94 | | const auto g_ZoomValue = 28; |
95 | | |
96 | | Sequence<OUString> SwContentViewConfig::GetPropertyNames() const |
97 | 20 | { |
98 | 20 | static constexpr const char*const aPropNames[] = |
99 | 20 | { |
100 | 20 | "Display/GraphicObject", // 0 |
101 | 20 | "Display/Table", // 1 |
102 | 20 | "Display/DrawingControl", // 2 |
103 | 20 | "Display/FieldCode", // 3 |
104 | 20 | "Display/Note", // 4 |
105 | 20 | "Display/ShowContentTips", // 5 |
106 | 20 | "NonprintingCharacter/MetaCharacters", // 6 |
107 | 20 | "NonprintingCharacter/ParagraphEnd", // 7 |
108 | 20 | "NonprintingCharacter/OptionalHyphen", // 8 |
109 | 20 | "NonprintingCharacter/Space", // 9 |
110 | 20 | "NonprintingCharacter/Break", // 10 |
111 | 20 | "NonprintingCharacter/ProtectedSpace", // 11 |
112 | 20 | "NonprintingCharacter/Tab", // 12 //not in Writer/Web |
113 | 20 | "NonprintingCharacter/HiddenText", // 13 |
114 | 20 | "NonprintingCharacter/HiddenParagraph", // 14 |
115 | 20 | "NonprintingCharacter/HiddenCharacter", // 15 |
116 | 20 | "NonprintingCharacter/Bookmarks", // 16 |
117 | 20 | "Update/Link", // 17 |
118 | 20 | "Update/Field", // 18 |
119 | 20 | "Update/Chart", // 19 |
120 | 20 | "Display/ShowInlineTooltips", // 20 |
121 | 20 | "Display/UseHeaderFooterMenu", // 21 |
122 | 20 | "Display/ShowOutlineContentVisibilityButton", // 22 |
123 | 20 | "Display/TreatSubOutlineLevelsAsContent", // 23 |
124 | 20 | "Display/ShowChangesInMargin", // 24 |
125 | 20 | "Display/DefaultAnchor", // 25 |
126 | 20 | "Zoom/DefaultZoom", // 26 |
127 | 20 | "Zoom/ZoomType", // 27 |
128 | 20 | "Zoom/ZoomValue", // 28 |
129 | 20 | "Display/TextBoundaries", // 29 |
130 | 20 | "Display/TextBoundariesFull", // 30 |
131 | 20 | "Display/SectionBoundaries", // 31 |
132 | 20 | "Display/TableBoundaries", // 32 |
133 | 20 | "Display/ShowBoundaries", // 33 |
134 | 20 | "Draw/ClickChangeRotation" // 34 |
135 | 20 | }; |
136 | | #if defined(__GNUC__) && !defined(__clang__) |
137 | | // clang 8.0.0 says strcmp isn't constexpr |
138 | | static_assert(std::strcmp("Update/Link", aPropNames[g_UpdateLinkIndex]) == 0); |
139 | | static_assert(std::strcmp("Display/DefaultAnchor", aPropNames[g_DefaultAnchor]) == 0); |
140 | | static_assert(std::strcmp("Zoom/ZoomType", aPropNames[g_ZoomType]) == 0); |
141 | | static_assert(std::strcmp("Zoom/ZoomValue", aPropNames[g_ZoomValue]) == 0); |
142 | | #endif |
143 | 20 | const int nCount = m_bWeb ? 12 : std::size(aPropNames); |
144 | 20 | Sequence<OUString> aNames(nCount); |
145 | 20 | OUString* pNames = aNames.getArray(); |
146 | 674 | for(int i = 0; i < nCount; i++) |
147 | 654 | { |
148 | 654 | pNames[i] = OUString::createFromAscii(aPropNames[i]); |
149 | 654 | } |
150 | 20 | return aNames; |
151 | 20 | } |
152 | | |
153 | | SwContentViewConfig::SwContentViewConfig(bool bIsWeb, SwMasterUsrPref& rPar) : |
154 | 10 | ConfigItem(bIsWeb ? u"Office.WriterWeb/Content"_ustr : u"Office.Writer/Content"_ustr), |
155 | 10 | m_rParent(rPar), |
156 | 10 | m_bWeb(bIsWeb) |
157 | 10 | { |
158 | 10 | Load(); |
159 | 10 | EnableNotification( GetPropertyNames() ); |
160 | 10 | } |
161 | | |
162 | | SwContentViewConfig::~SwContentViewConfig() |
163 | 0 | { |
164 | 0 | } |
165 | | |
166 | | void SwContentViewConfig::Notify( const Sequence< OUString > & /*rPropertyNames*/ ) |
167 | 0 | { |
168 | 0 | Load(); |
169 | 0 | } |
170 | | |
171 | | void SwContentViewConfig::ImplCommit() |
172 | 0 | { |
173 | 0 | Sequence<OUString> aNames = GetPropertyNames(); |
174 | |
|
175 | 0 | Sequence<Any> aValues(aNames.getLength()); |
176 | 0 | Any* pValues = aValues.getArray(); |
177 | |
|
178 | 0 | for(int nProp = 0; nProp < aNames.getLength(); nProp++) |
179 | 0 | { |
180 | 0 | bool bVal = false; |
181 | 0 | switch(nProp) |
182 | 0 | { |
183 | 0 | case 0: bVal = m_rParent.IsGraphic(); break;// "Display/GraphicObject", |
184 | 0 | case 1: bVal = m_rParent.IsTable(); break;// "Display/Table", |
185 | 0 | case 2: bVal = m_rParent.IsDraw(); break;// "Display/DrawingControl", |
186 | 0 | case 3: bVal = m_rParent.IsFieldName(); break;// "Display/FieldCode", |
187 | 0 | case 4: bVal = m_rParent.IsPostIts(); break;// "Display/Note", |
188 | 0 | case 5: bVal = m_rParent.IsShowContentTips(); break; // "Display/ShowContentTips" |
189 | 0 | case 6: bVal = m_rParent.IsViewMetaChars(); break; //"NonprintingCharacter/MetaCharacters" |
190 | 0 | case 7: bVal = m_rParent.IsParagraph(true); break;// "NonprintingCharacter/ParagraphEnd", |
191 | 0 | case 8: bVal = m_rParent.IsSoftHyph(); break;// "NonprintingCharacter/OptionalHyphen", |
192 | 0 | case 9: bVal = m_rParent.IsBlank(true); break;// "NonprintingCharacter/Space", |
193 | 0 | case 10: bVal = m_rParent.IsLineBreak(true);break;// "NonprintingCharacter/Break", |
194 | 0 | case 11: bVal = m_rParent.IsHardBlank(); break;// "NonprintingCharacter/ProtectedSpace", |
195 | 0 | case 12: bVal = m_rParent.IsTab(true); break;// "NonprintingCharacter/Tab", |
196 | 0 | case 13: bVal = m_rParent.IsShowHiddenField(); break;// "NonprintingCharacter/Fields: HiddenText", |
197 | 0 | case 14: bVal = m_rParent.IsShowHiddenPara(); break;// "NonprintingCharacter/Fields: HiddenParagraph", |
198 | 0 | case 15: bVal = m_rParent.IsShowHiddenChar(true); break;// "NonprintingCharacter/HiddenCharacter", |
199 | 0 | case 16: bVal = m_rParent.IsShowBookmarks(true); break;// "NonprintingCharacter/Bookmarks", |
200 | 0 | case 17: pValues[nProp] <<= m_rParent.GetUpdateLinkMode(); break;// "Update/Link", |
201 | 0 | case 18: bVal = m_rParent.IsUpdateFields(); break;// "Update/Field", |
202 | 0 | case 19: bVal = m_rParent.IsUpdateCharts(); break;// "Update/Chart" |
203 | 0 | case 20: bVal = m_rParent.IsShowInlineTooltips(); break;// "Display/ShowInlineTooltips" |
204 | 0 | case 21: bVal = m_rParent.IsUseHeaderFooterMenu(); break;// "Display/UseHeaderFooterMenu" |
205 | 0 | case 22: bVal = m_rParent.IsShowOutlineContentVisibilityButton(); break;// "Display/ShowOutlineContentVisibilityButton" |
206 | 0 | case 23: bVal = m_rParent.IsTreatSubOutlineLevelsAsContent(); break;// "Display/TreatSubOutlineLevelsAsContent" |
207 | 0 | case 24: bVal = m_rParent.IsShowChangesInMargin(); break;// "Display/ShowChangesInMargin" |
208 | 0 | case 25: pValues[nProp] <<= m_rParent.GetDefaultAnchor(); break;// "Display/DefaultAnchor" |
209 | | //TODO: Save zoom preferred, zoom type, zoom value |
210 | 0 | case 26: bVal = m_rParent.IsDefaultZoom(); break;// "Zoom/DefaultZoom" |
211 | 0 | case 27:pValues[nProp] <<= static_cast<sal_Int32>(m_rParent.GetDefaultZoomType()); break; // "Zoom/ZoomType" |
212 | 0 | case 28: pValues[nProp] <<= static_cast<sal_Int32>(m_rParent.GetDefaultZoomValue()); break; // "Zoom/ZoomValue" |
213 | 0 | case 29: bVal = m_rParent.IsTextBoundaries(); break; // "Display/TextBoundaries" |
214 | 0 | case 30: bVal = m_rParent.IsTextBoundariesFull(); break; // "Display/TextBoundariesFull" |
215 | 0 | case 31: bVal = m_rParent.IsSectionBoundaries(); break; // "Display/SectionBoundaries" |
216 | 0 | case 32: bVal = m_rParent.IsTableBoundaries(); break; // "Display/TableBoundaries" |
217 | 0 | case 33: bVal = m_rParent.IsShowBoundaries(); break; // "Display/ShowBoundaries" |
218 | 0 | case 34: bVal = m_rParent.IsClickChangeRotation(); break; // "Draw/ClickChangeRotation" |
219 | 0 | } |
220 | 0 | if ((nProp != g_UpdateLinkIndex) && (nProp != g_DefaultAnchor) && |
221 | 0 | (nProp != g_ZoomType) && (nProp != g_ZoomValue)) |
222 | 0 | pValues[nProp] <<= bVal; |
223 | 0 | } |
224 | 0 | PutProperties(aNames, aValues); |
225 | 0 | } |
226 | | |
227 | | void SwContentViewConfig::Load() |
228 | 10 | { |
229 | 10 | Sequence<OUString> aNames = GetPropertyNames(); |
230 | 10 | Sequence<Any> aValues = GetProperties(aNames); |
231 | 10 | const Any* pValues = aValues.getConstArray(); |
232 | 10 | OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed"); |
233 | 10 | if(aValues.getLength() != aNames.getLength()) |
234 | 0 | return; |
235 | 337 | for(int nProp = 0; nProp < aNames.getLength(); nProp++) |
236 | 327 | { |
237 | 327 | if(pValues[nProp].hasValue()) |
238 | 0 | { |
239 | 0 | bool bSet = ((nProp != g_UpdateLinkIndex) && (nProp != g_DefaultAnchor) && (nProp != g_ZoomType)&& (nProp != g_ZoomValue)) |
240 | 0 | && *o3tl::doAccess<bool>(pValues[nProp]); |
241 | 0 | switch(nProp) |
242 | 0 | { |
243 | 0 | case 0: m_rParent.SetGraphic(bSet); break;// "Display/GraphicObject", |
244 | 0 | case 1: m_rParent.SetTable(bSet); break;// "Display/Table", |
245 | 0 | case 2: m_rParent.SetDraw(bSet); break;// "Display/DrawingControl", |
246 | 0 | case 3: m_rParent.SetFieldName(bSet); break;// "Display/FieldCode", |
247 | 0 | case 4: m_rParent.SetPostIts(bSet); break;// "Display/Note", |
248 | 0 | case 5: m_rParent.SetShowContentTips(bSet); break;// "Display/ShowContentTips", |
249 | 0 | case 6: m_rParent.SetViewMetaChars(bSet); break; //"NonprintingCharacter/MetaCharacters" |
250 | 0 | case 7: m_rParent.SetParagraph(bSet); break;// "NonprintingCharacter/ParagraphEnd", |
251 | 0 | case 8: m_rParent.SetSoftHyph(bSet); break;// "NonprintingCharacter/OptionalHyphen", |
252 | 0 | case 9: m_rParent.SetBlank(bSet); break;// "NonprintingCharacter/Space", |
253 | 0 | case 10: m_rParent.SetLineBreak(bSet);break;// "NonprintingCharacter/Break", |
254 | 0 | case 11: m_rParent.SetHardBlank(bSet); break;// "NonprintingCharacter/ProtectedSpace", |
255 | 0 | case 12: m_rParent.SetTab(bSet); break;// "NonprintingCharacter/Tab", |
256 | 0 | case 13: m_rParent.SetShowHiddenField(bSet); break;// "NonprintingCharacter/Fields: HiddenText", |
257 | 0 | case 14: m_rParent.SetShowHiddenPara(bSet); break;// "NonprintingCharacter/Fields: HiddenParagraph", |
258 | 0 | case 15: m_rParent.SetShowHiddenChar(bSet); break;// "NonprintingCharacter/HiddenCharacter", |
259 | 0 | case 16: m_rParent.SetShowBookmarks(bSet); break;// "NonprintingCharacter/Bookmarks", |
260 | 0 | case 17: |
261 | 0 | { |
262 | 0 | sal_Int32 nSet = 0; |
263 | 0 | pValues[nProp] >>= nSet; |
264 | 0 | m_rParent.SetUpdateLinkMode(nSet, true); |
265 | 0 | } |
266 | 0 | break;// "Update/Link", |
267 | 0 | case 18: m_rParent.SetUpdateFields(bSet); break;// "Update/Field", |
268 | 0 | case 19: m_rParent.SetUpdateCharts(bSet); break;// "Update/Chart" |
269 | 0 | case 20: m_rParent.SetShowInlineTooltips(bSet); break;// "Display/ShowInlineTooltips" |
270 | 0 | case 21: m_rParent.SetUseHeaderFooterMenu(bSet); break;// "Display/UseHeaderFooterMenu" |
271 | 0 | case 22: m_rParent.SetShowOutlineContentVisibilityButton(bSet); break;// "Display/ShowOutlineContententVisibilityButton" |
272 | 0 | case 23: m_rParent.SetTreatSubOutlineLevelsAsContent(bSet); break;// "Display/TreatSubOutlineLevelsAsContent" |
273 | 0 | case 24: m_rParent.SetShowChangesInMargin(bSet); break;// "Display/ShowChangesInMargin" |
274 | 0 | case 25: |
275 | 0 | { |
276 | 0 | sal_Int32 nSet = 0; |
277 | 0 | pValues[nProp] >>= nSet; |
278 | 0 | m_rParent.SetDefaultAnchor(nSet); |
279 | 0 | } |
280 | 0 | break; // "Display/DefaultAnchor" |
281 | 0 | case 26: m_rParent.SetDefaultZoom(bSet); break; // "Zoom/DefaultZoom" |
282 | 0 | case 27: |
283 | 0 | { |
284 | 0 | sal_Int32 nSet = 0; |
285 | 0 | pValues[nProp] >>= nSet; |
286 | 0 | m_rParent.SetDefaultZoomType(static_cast<SvxZoomType>(nSet), true); |
287 | 0 | } |
288 | 0 | break; //"Zoom/ZoomType", // 27 |
289 | 0 | case 28: |
290 | 0 | { |
291 | 0 | sal_Int32 nSet = 0; |
292 | 0 | pValues[nProp] >>= nSet; |
293 | 0 | m_rParent.SetDefaultZoomValue(static_cast<sal_uInt16>(nSet), true); |
294 | 0 | } |
295 | 0 | break; //"Zoom/ZoomValue" // 28 |
296 | 0 | case 29: m_rParent.SetTextBoundaries(bSet); break; //"Display/TextBoundaries" |
297 | 0 | case 30: m_rParent.SetTextBoundariesFull(bSet); break; //"Display/TextBoundariesFull" |
298 | 0 | case 31: m_rParent.SetSectionBoundaries(bSet); break; //"Display/SectionBoundaries" |
299 | 0 | case 32: m_rParent.SetTableBoundaries(bSet); break; //"Display/TableBoundaries" |
300 | 0 | case 33: m_rParent.SetShowBoundaries(bSet); break; //"Display/ShowBoundaries" |
301 | 0 | case 34: m_rParent.SetClickChangeRotation(bSet); break; // "Draw/ClickChangeRotation" |
302 | 0 | } |
303 | 0 | } |
304 | 327 | } |
305 | 10 | } |
306 | | |
307 | | Sequence<OUString> SwLayoutViewConfig::GetPropertyNames() const |
308 | 20 | { |
309 | 20 | static const char* const aPropNames[] = |
310 | 20 | { |
311 | 20 | "Line/Guide", // 0 |
312 | 20 | "Window/HorizontalScroll", // 1 |
313 | 20 | "Window/VerticalScroll", // 2 |
314 | 20 | "Window/ShowRulers", // 3 |
315 | 20 | "Window/HorizontalRuler", // 4 |
316 | 20 | "Window/VerticalRuler", // 5 |
317 | 20 | "Window/HorizontalRulerUnit", // 6 |
318 | 20 | "Window/VerticalRulerUnit", // 7 |
319 | 20 | "Window/SmoothScroll", // 8 |
320 | 20 | "Zoom/Value", // 9 |
321 | 20 | "Zoom/Type", //10 |
322 | 20 | "Other/IsAlignMathObjectsToBaseline", //11 |
323 | 20 | "Other/MeasureUnit", //12 |
324 | | // below properties are not available in WriterWeb |
325 | 20 | "Other/TabStop", //13 |
326 | 20 | "Window/IsVerticalRulerRight", //14 |
327 | 20 | "ViewLayout/Columns", //15 |
328 | 20 | "ViewLayout/BookMode", //16 |
329 | 20 | "Other/IsSquaredPageMode", //17 |
330 | 20 | "Other/ApplyCharUnit", //18 |
331 | 20 | "Window/ShowScrollBarTips", //19 |
332 | 20 | }; |
333 | 20 | const int nCount = m_bWeb ? 13 : 20; |
334 | 20 | Sequence<OUString> aNames(nCount); |
335 | 20 | OUString* pNames = aNames.getArray(); |
336 | 406 | for(int i = 0; i < nCount; i++) |
337 | 386 | { |
338 | 386 | pNames[i] = OUString::createFromAscii(aPropNames[i]); |
339 | 386 | } |
340 | 20 | return aNames; |
341 | 20 | } |
342 | | |
343 | | SwLayoutViewConfig::SwLayoutViewConfig(bool bIsWeb, SwMasterUsrPref& rPar) |
344 | 10 | : ConfigItem(bIsWeb ? u"Office.WriterWeb/Layout"_ustr : u"Office.Writer/Layout"_ustr) |
345 | 10 | , m_rParent(rPar) |
346 | 10 | , m_bWeb(bIsWeb) |
347 | 10 | { |
348 | 10 | Load(); |
349 | 10 | EnableNotification(GetPropertyNames()); |
350 | 10 | } |
351 | | |
352 | | SwLayoutViewConfig::~SwLayoutViewConfig() |
353 | 0 | { |
354 | 0 | } |
355 | | |
356 | | void SwLayoutViewConfig::ImplCommit() |
357 | 0 | { |
358 | 0 | Sequence<OUString> aNames = GetPropertyNames(); |
359 | |
|
360 | 0 | Sequence<Any> aValues(aNames.getLength()); |
361 | 0 | Any* pValues = aValues.getArray(); |
362 | |
|
363 | 0 | for(int nProp = 0; nProp < aNames.getLength(); nProp++) |
364 | 0 | { |
365 | 0 | Any &rVal = pValues[nProp]; |
366 | 0 | switch(nProp) |
367 | 0 | { |
368 | 0 | case 0: rVal <<= m_rParent.IsCrossHair(); break; // "Line/Guide", |
369 | 0 | case 1: rVal <<= m_rParent.IsViewHScrollBar(); break; // "Window/HorizontalScroll", |
370 | 0 | case 2: rVal <<= m_rParent.IsViewVScrollBar(); break; // "Window/VerticalScroll", |
371 | 0 | case 3: rVal <<= m_rParent.IsViewAnyRuler(); break; // "Window/ShowRulers" |
372 | | // #i14593# use IsView*Ruler(true) instead of IsView*Ruler() |
373 | | // this preserves the single ruler states even if "Window/ShowRulers" is off |
374 | 0 | case 4: rVal <<= m_rParent.IsViewHRuler(true); break; // "Window/HorizontalRuler", |
375 | 0 | case 5: rVal <<= m_rParent.IsViewVRuler(true); break; // "Window/VerticalRuler", |
376 | 0 | case 6: |
377 | 0 | if(m_rParent.m_bIsHScrollMetricSet) |
378 | 0 | rVal <<= static_cast<sal_Int32>(m_rParent.m_eHScrollMetric); // "Window/HorizontalRulerUnit" |
379 | 0 | break; |
380 | 0 | case 7: |
381 | 0 | if(m_rParent.m_bIsVScrollMetricSet) |
382 | 0 | rVal <<= static_cast<sal_Int32>(m_rParent.m_eVScrollMetric); // "Window/VerticalRulerUnit" |
383 | 0 | break; |
384 | 0 | case 8: rVal <<= m_rParent.IsSmoothScroll(); break; // "Window/SmoothScroll", |
385 | 0 | case 9: rVal <<= static_cast<sal_Int32>(m_rParent.GetZoom()); break; // "Zoom/Value", |
386 | 0 | case 10: rVal <<= static_cast<sal_Int32>(m_rParent.GetZoomType()); break; // "Zoom/Type", |
387 | 0 | case 11: rVal <<= m_rParent.IsAlignMathObjectsToBaseline(); break; // "Other/IsAlignMathObjectsToBaseline" |
388 | 0 | case 12: rVal <<= static_cast<sal_Int32>(m_rParent.GetMetric()); break; // "Other/MeasureUnit", |
389 | 0 | case 13: rVal <<= m_rParent.GetDefTabInMm100(); break;// "Other/TabStop", |
390 | 0 | case 14: rVal <<= m_rParent.IsVRulerRight(); break; // "Window/IsVerticalRulerRight", |
391 | 0 | case 15: rVal <<= static_cast<sal_Int32>(m_rParent.GetViewLayoutColumns()); break; // "ViewLayout/Columns", |
392 | 0 | case 16: rVal <<= m_rParent.IsViewLayoutBookMode(); break; // "ViewLayout/BookMode", |
393 | 0 | case 17: rVal <<= m_rParent.IsSquaredPageMode(); break; // "Other/IsSquaredPageMode", |
394 | 0 | case 18: rVal <<= m_rParent.IsApplyCharUnit(); break; // "Other/ApplyCharUnit", |
395 | 0 | case 19: rVal <<= m_rParent.IsShowScrollBarTips(); break; // "Window/ShowScrollBarTips", |
396 | 0 | } |
397 | 0 | } |
398 | 0 | PutProperties(aNames, aValues); |
399 | 0 | } |
400 | | |
401 | | void SwLayoutViewConfig::Load() |
402 | 10 | { |
403 | 10 | Sequence<OUString> aNames = GetPropertyNames(); |
404 | 10 | Sequence<Any> aValues = GetProperties(aNames); |
405 | 10 | const Any* pValues = aValues.getConstArray(); |
406 | 10 | OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed"); |
407 | 10 | if(aValues.getLength() != aNames.getLength()) |
408 | 0 | return; |
409 | | |
410 | 203 | for(int nProp = 0; nProp < aNames.getLength(); nProp++) |
411 | 193 | { |
412 | 193 | if(pValues[nProp].hasValue()) |
413 | 0 | { |
414 | 0 | sal_Int32 nInt32Val = 0; |
415 | 0 | bool bSet = false; |
416 | 0 | pValues[nProp] >>= nInt32Val; |
417 | 0 | pValues[nProp] >>= bSet; |
418 | |
|
419 | 0 | switch(nProp) |
420 | 0 | { |
421 | 0 | case 0: m_rParent.SetCrossHair(bSet); break;// "Line/Guide", |
422 | 0 | case 1: m_rParent.SetViewHScrollBar(bSet); break;// "Window/HorizontalScroll", |
423 | 0 | case 2: m_rParent.SetViewVScrollBar(bSet); break;// "Window/VerticalScroll", |
424 | 0 | case 3: m_rParent.SetViewAnyRuler(bSet);break; // "Window/ShowRulers" |
425 | 0 | case 4: m_rParent.SetViewHRuler(bSet); break;// "Window/HorizontalRuler", |
426 | 0 | case 5: m_rParent.SetViewVRuler(bSet); break;// "Window/VerticalRuler", |
427 | 0 | case 6: |
428 | 0 | { |
429 | 0 | m_rParent.m_bIsHScrollMetricSet = true; |
430 | 0 | m_rParent.m_eHScrollMetric = static_cast<FieldUnit>(nInt32Val); // "Window/HorizontalRulerUnit" |
431 | 0 | } |
432 | 0 | break; |
433 | 0 | case 7: |
434 | 0 | { |
435 | 0 | m_rParent.m_bIsVScrollMetricSet = true; |
436 | 0 | m_rParent.m_eVScrollMetric = static_cast<FieldUnit>(nInt32Val); // "Window/VerticalRulerUnit" |
437 | 0 | } |
438 | 0 | break; |
439 | 0 | case 8: m_rParent.SetSmoothScroll(bSet); break;// "Window/SmoothScroll", |
440 | 0 | case 9: m_rParent.SetZoom( static_cast< sal_uInt16 >(nInt32Val) ); break;// "Zoom/Value", |
441 | 0 | case 10: m_rParent.SetZoomType( static_cast< SvxZoomType >(nInt32Val) ); break;// "Zoom/Type", |
442 | 0 | case 11: m_rParent.SetAlignMathObjectsToBaseline(bSet, true); break;// "Other/IsAlignMathObjectsToBaseline" |
443 | 0 | case 12: m_rParent.SetMetric(static_cast<FieldUnit>(nInt32Val), true); break;// "Other/MeasureUnit", |
444 | 0 | case 13: m_rParent.SetDefTabInMm100(nInt32Val, true); break;// "Other/TabStop", |
445 | 0 | case 14: m_rParent.SetVRulerRight(bSet); break;// "Window/IsVerticalRulerRight", |
446 | 0 | case 15: m_rParent.SetViewLayoutColumns( o3tl::narrowing<sal_uInt16>(nInt32Val) ); break;// "ViewLayout/Columns", |
447 | 0 | case 16: m_rParent.SetViewLayoutBookMode(bSet); break;// "ViewLayout/BookMode", |
448 | 0 | case 17: m_rParent.SetDefaultPageMode(bSet,true); break;// "Other/IsSquaredPageMode", |
449 | 0 | case 18: m_rParent.SetApplyCharUnit(bSet, true); break;// "Other/ApplyUserChar" |
450 | 0 | case 19: m_rParent.SetShowScrollBarTips(bSet); break;// "Window/ShowScrollBarTips", |
451 | 0 | } |
452 | 0 | } |
453 | 193 | } |
454 | 10 | } |
455 | | |
456 | | void SwLayoutViewConfig::Notify(const css::uno::Sequence<OUString>&) |
457 | 0 | { |
458 | 0 | Load(); |
459 | 0 | } |
460 | | |
461 | | Sequence<OUString> SwGridConfig::GetPropertyNames() |
462 | 20 | { |
463 | 20 | static const char* const aPropNames[] = |
464 | 20 | { |
465 | 20 | "Option/SnapToGrid", // 0 |
466 | 20 | "Option/VisibleGrid", // 1 |
467 | 20 | "Option/Synchronize", // 2 |
468 | 20 | "Resolution/XAxis", // 3 |
469 | 20 | "Resolution/YAxis", // 4 |
470 | 20 | "Subdivision/XAxis", // 5 |
471 | 20 | "Subdivision/YAxis" // 6 |
472 | 20 | }; |
473 | 20 | const int nCount = 7; |
474 | 20 | Sequence<OUString> aNames(nCount); |
475 | 20 | OUString* pNames = aNames.getArray(); |
476 | 160 | for(int i = 0; i < nCount; i++) |
477 | 140 | { |
478 | 140 | pNames[i] = OUString::createFromAscii(aPropNames[i]); |
479 | 140 | } |
480 | 20 | return aNames; |
481 | 20 | } |
482 | | |
483 | | SwGridConfig::SwGridConfig(bool bIsWeb, SwMasterUsrPref& rPar) : |
484 | 10 | ConfigItem(bIsWeb ? u"Office.WriterWeb/Grid"_ustr : u"Office.Writer/Grid"_ustr), |
485 | 10 | m_rParent(rPar) |
486 | 10 | { |
487 | 10 | Load(); |
488 | 10 | EnableNotification(GetPropertyNames()); |
489 | 10 | } |
490 | | |
491 | | SwGridConfig::~SwGridConfig() |
492 | 0 | { |
493 | 0 | } |
494 | | |
495 | | void SwGridConfig::ImplCommit() |
496 | 0 | { |
497 | 0 | Sequence<OUString> aNames = GetPropertyNames(); |
498 | |
|
499 | 0 | Sequence<Any> aValues(aNames.getLength()); |
500 | 0 | Any* pValues = aValues.getArray(); |
501 | |
|
502 | 0 | for(int nProp = 0; nProp < aNames.getLength(); nProp++) |
503 | 0 | { |
504 | 0 | switch(nProp) |
505 | 0 | { |
506 | 0 | case 0: pValues[nProp] <<= m_rParent.IsSnap(); break;// "Option/SnapToGrid", |
507 | 0 | case 1: pValues[nProp] <<= m_rParent.IsGridVisible(); break;//"Option/VisibleGrid", |
508 | 0 | case 2: pValues[nProp] <<= m_rParent.IsSynchronize(); break;// "Option/Synchronize", |
509 | 0 | case 3: pValues[nProp] <<= static_cast<sal_Int32>(convertTwipToMm100(m_rParent.GetSnapSize().Width())); break;// "Resolution/XAxis", |
510 | 0 | case 4: pValues[nProp] <<= static_cast<sal_Int32>(convertTwipToMm100(m_rParent.GetSnapSize().Height())); break;// "Resolution/YAxis", |
511 | 0 | case 5: pValues[nProp] <<= static_cast<sal_Int16>(m_rParent.GetDivisionX()); break;// "Subdivision/XAxis", |
512 | 0 | case 6: pValues[nProp] <<= static_cast<sal_Int16>(m_rParent.GetDivisionY()); break;// "Subdivision/YAxis" |
513 | 0 | } |
514 | 0 | } |
515 | 0 | PutProperties(aNames, aValues); |
516 | 0 | } |
517 | | |
518 | | void SwGridConfig::Load() |
519 | 10 | { |
520 | 10 | Sequence<OUString> aNames = GetPropertyNames(); |
521 | 10 | Sequence<Any> aValues = GetProperties(aNames); |
522 | 10 | const Any* pValues = aValues.getConstArray(); |
523 | 10 | OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed"); |
524 | 10 | if(aValues.getLength() != aNames.getLength()) |
525 | 0 | return; |
526 | | |
527 | 10 | Size aSnap(m_rParent.GetSnapSize()); |
528 | 80 | for(int nProp = 0; nProp < aNames.getLength(); nProp++) |
529 | 70 | { |
530 | 70 | if(pValues[nProp].hasValue()) |
531 | 0 | { |
532 | 0 | bool bSet = nProp < 3 && *o3tl::doAccess<bool>(pValues[nProp]); |
533 | 0 | sal_Int32 nSet = 0; |
534 | 0 | if(nProp >= 3) |
535 | 0 | pValues[nProp] >>= nSet; |
536 | 0 | switch(nProp) |
537 | 0 | { |
538 | 0 | case 0: m_rParent.SetSnap(bSet); break;// "Option/SnapToGrid", |
539 | 0 | case 1: m_rParent.SetGridVisible(bSet); break;//"Option/VisibleGrid", |
540 | 0 | case 2: m_rParent.SetSynchronize(bSet); break;// "Option/Synchronize", |
541 | 0 | case 3: aSnap.setWidth( o3tl::toTwips(nSet, o3tl::Length::mm100) ); break;// "Resolution/XAxis", |
542 | 0 | case 4: aSnap.setHeight( o3tl::toTwips(nSet, o3tl::Length::mm100) ); break;// "Resolution/YAxis", |
543 | 0 | case 5: m_rParent.SetDivisionX(static_cast<short>(nSet)); break;// "Subdivision/XAxis", |
544 | 0 | case 6: m_rParent.SetDivisionY(static_cast<short>(nSet)); break;// "Subdivision/YAxis" |
545 | 0 | } |
546 | 0 | } |
547 | 70 | } |
548 | 10 | m_rParent.SetSnapSize(aSnap); |
549 | 10 | } |
550 | | |
551 | | void SwGridConfig::Notify( const css::uno::Sequence< OUString >& ) |
552 | 0 | { |
553 | 0 | Load(); |
554 | 0 | } |
555 | | |
556 | | Sequence<OUString> SwCursorConfig::GetPropertyNames() |
557 | 20 | { |
558 | 20 | static const char* const aPropNames[] = |
559 | 20 | { |
560 | 20 | "DirectCursor/UseDirectCursor", // 0 |
561 | 20 | "DirectCursor/Insert", // 1 |
562 | 20 | "Option/ProtectedArea", // 2 |
563 | 20 | }; |
564 | 20 | const int nCount = std::size(aPropNames); |
565 | 20 | Sequence<OUString> aNames(nCount); |
566 | 20 | OUString* pNames = aNames.getArray(); |
567 | 80 | for(int i = 0; i < nCount; i++) |
568 | 60 | pNames[i] = OUString::createFromAscii(aPropNames[i]); |
569 | 20 | return aNames; |
570 | 20 | } |
571 | | |
572 | | SwCursorConfig::SwCursorConfig(SwMasterUsrPref& rPar) |
573 | 10 | : ConfigItem(u"Office.Writer/Cursor"_ustr) |
574 | 10 | , m_rParent(rPar) |
575 | 10 | { |
576 | 10 | Load(); |
577 | 10 | EnableNotification(GetPropertyNames()); |
578 | 10 | } |
579 | | |
580 | | SwCursorConfig::~SwCursorConfig() |
581 | 0 | { |
582 | 0 | } |
583 | | |
584 | | void SwCursorConfig::ImplCommit() |
585 | 0 | { |
586 | 0 | Sequence<OUString> aNames = GetPropertyNames(); |
587 | |
|
588 | 0 | Sequence<Any> aValues(aNames.getLength()); |
589 | 0 | Any* pValues = aValues.getArray(); |
590 | |
|
591 | 0 | for(int nProp = 0; nProp < aNames.getLength(); nProp++) |
592 | 0 | { |
593 | 0 | switch(nProp) |
594 | 0 | { |
595 | 0 | case 0: pValues[nProp] <<= m_rParent.IsShadowCursor(); break; // "DirectCursor/UseDirectCursor", |
596 | 0 | case 1: pValues[nProp] <<= static_cast<sal_Int32>(m_rParent.GetShdwCursorFillMode()); break; // "DirectCursor/Insert", |
597 | 0 | case 2: pValues[nProp] <<= m_rParent.IsCursorInProtectedArea(); break; // "Option/ProtectedArea" |
598 | 0 | } |
599 | 0 | } |
600 | 0 | PutProperties(aNames, aValues); |
601 | 0 | } |
602 | | |
603 | | void SwCursorConfig::Load() |
604 | 10 | { |
605 | 10 | Sequence<OUString> aNames = GetPropertyNames(); |
606 | 10 | Sequence<Any> aValues = GetProperties(aNames); |
607 | 10 | const Any* pValues = aValues.getConstArray(); |
608 | 10 | OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed"); |
609 | 10 | if(aValues.getLength() != aNames.getLength()) |
610 | 0 | return; |
611 | | |
612 | | |
613 | 40 | for(int nProp = 0; nProp < aNames.getLength(); nProp++) |
614 | 30 | { |
615 | 30 | if(pValues[nProp].hasValue()) |
616 | 0 | { |
617 | 0 | bool bSet = false; |
618 | 0 | sal_Int32 nSet = 0; |
619 | 0 | if(nProp != 1 ) |
620 | 0 | bSet = *o3tl::doAccess<bool>(pValues[nProp]); |
621 | 0 | else |
622 | 0 | pValues[nProp] >>= nSet; |
623 | 0 | switch(nProp) |
624 | 0 | { |
625 | 0 | case 0: m_rParent.SetShadowCursor(bSet); break; // "DirectCursor/UseDirectCursor", |
626 | 0 | case 1: m_rParent.SetShdwCursorFillMode(static_cast<SwFillMode>(nSet)); break; // "DirectCursor/Insert", |
627 | 0 | case 2: m_rParent.SetCursorInProtectedArea(bSet); break; // "Option/ProtectedArea" |
628 | 0 | } |
629 | 0 | } |
630 | 30 | } |
631 | 10 | } |
632 | | |
633 | | void SwCursorConfig::Notify(const css::uno::Sequence<OUString>& ) |
634 | 0 | { |
635 | 0 | Load(); |
636 | 0 | } |
637 | | |
638 | | Sequence<OUString> SwFmtAidsAutoComplConfig::GetPropertyNames() |
639 | 20 | { |
640 | 20 | static const char* const aPropNames[] = { |
641 | 20 | "EncloseWithCharacters", // 0 |
642 | 20 | }; |
643 | 20 | const int nCount = std::size(aPropNames); |
644 | 20 | Sequence<OUString> aNames(nCount); |
645 | 20 | OUString* pNames = aNames.getArray(); |
646 | 40 | for (int i = 0; i < nCount; i++) |
647 | 20 | pNames[i] = OUString::createFromAscii(aPropNames[i]); |
648 | 20 | return aNames; |
649 | 20 | } |
650 | | |
651 | | SwFmtAidsAutoComplConfig::SwFmtAidsAutoComplConfig(SwMasterUsrPref& rPar) |
652 | 10 | : ConfigItem(u"Office.Writer/FmtAidsAutocomplete"_ustr) |
653 | 10 | , m_rParent(rPar) |
654 | 10 | { |
655 | 10 | Load(); |
656 | 10 | EnableNotification(GetPropertyNames()); |
657 | 10 | } |
658 | | |
659 | 0 | SwFmtAidsAutoComplConfig::~SwFmtAidsAutoComplConfig() {} |
660 | | |
661 | | void SwFmtAidsAutoComplConfig::ImplCommit() |
662 | 0 | { |
663 | 0 | Sequence<OUString> aNames = GetPropertyNames(); |
664 | |
|
665 | 0 | Sequence<Any> aValues(aNames.getLength()); |
666 | 0 | Any* pValues = aValues.getArray(); |
667 | |
|
668 | 0 | for (int nProp = 0; nProp < aNames.getLength(); nProp++) |
669 | 0 | { |
670 | 0 | switch (nProp) |
671 | 0 | { |
672 | 0 | case 0: |
673 | 0 | pValues[nProp] <<= m_rParent.IsEncloseWithCharactersOn(); |
674 | 0 | break; // "FmtAidsAutocomplete/EncloseWithCharacters" |
675 | 0 | } |
676 | 0 | } |
677 | 0 | PutProperties(aNames, aValues); |
678 | 0 | } |
679 | | |
680 | | void SwFmtAidsAutoComplConfig::Load() |
681 | 10 | { |
682 | 10 | Sequence<OUString> aNames = GetPropertyNames(); |
683 | 10 | Sequence<Any> aValues = GetProperties(aNames); |
684 | 10 | const Any* pValues = aValues.getConstArray(); |
685 | 10 | OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed"); |
686 | 10 | if (aValues.getLength() != aNames.getLength()) |
687 | 0 | return; |
688 | | |
689 | 20 | for (int nProp = 0; nProp < aNames.getLength(); nProp++) |
690 | 10 | { |
691 | 10 | if (pValues[nProp].hasValue()) |
692 | 0 | { |
693 | 0 | switch (nProp) |
694 | 0 | { |
695 | 0 | case 0: |
696 | 0 | { |
697 | 0 | bool bSet = false; |
698 | 0 | pValues[nProp] >>= bSet; |
699 | 0 | m_rParent.SetEncloseWithCharactersOn(bSet); |
700 | 0 | break; // "FmtAidsAutocomplete/EncloseWithCharacters" |
701 | 0 | } |
702 | 0 | } |
703 | 0 | } |
704 | 10 | } |
705 | 10 | } |
706 | | |
707 | | void SwFmtAidsAutoComplConfig::Notify(const css::uno::Sequence<OUString>&) |
708 | 0 | { |
709 | 0 | Load(); |
710 | 0 | } |
711 | | |
712 | | SwWebColorConfig::SwWebColorConfig(SwMasterUsrPref& rPar) |
713 | 1 | : ConfigItem(u"Office.WriterWeb/Background"_ustr) |
714 | 1 | , m_rParent(rPar) |
715 | 1 | , m_aPropNames(1) |
716 | 1 | { |
717 | 1 | m_aPropNames.getArray()[0] = "Color"; |
718 | 1 | Load(); |
719 | 1 | EnableNotification(m_aPropNames); |
720 | 1 | } |
721 | | |
722 | | SwWebColorConfig::~SwWebColorConfig() |
723 | 0 | { |
724 | 0 | } |
725 | | |
726 | | void SwWebColorConfig::ImplCommit() |
727 | 0 | { |
728 | 0 | Sequence<Any> aValues(m_aPropNames.getLength()); |
729 | 0 | Any* pValues = aValues.getArray(); |
730 | 0 | for(int nProp = 0; nProp < m_aPropNames.getLength(); nProp++) |
731 | 0 | { |
732 | 0 | switch(nProp) |
733 | 0 | { |
734 | 0 | case 0: pValues[nProp] <<= m_rParent.GetRetoucheColor(); break;// "Color", |
735 | 0 | } |
736 | 0 | } |
737 | 0 | PutProperties(m_aPropNames, aValues); |
738 | 0 | } |
739 | | |
740 | | void SwWebColorConfig::Notify(const css::uno::Sequence<OUString>&) |
741 | 0 | { |
742 | 0 | Load(); |
743 | 0 | } |
744 | | |
745 | | void SwWebColorConfig::Load() |
746 | 1 | { |
747 | 1 | Sequence<Any> aValues = GetProperties(m_aPropNames); |
748 | 1 | const Any* pValues = aValues.getConstArray(); |
749 | 1 | OSL_ENSURE(aValues.getLength() == m_aPropNames.getLength(), "GetProperties failed"); |
750 | 1 | if(aValues.getLength() != m_aPropNames.getLength()) |
751 | 0 | return; |
752 | | |
753 | 2 | for(int nProp = 0; nProp < m_aPropNames.getLength(); nProp++) |
754 | 1 | { |
755 | 1 | if(pValues[nProp].hasValue()) |
756 | 0 | { |
757 | 0 | switch(nProp) |
758 | 0 | { |
759 | 0 | case 0: |
760 | 0 | Color nSet; |
761 | 0 | pValues[nProp] >>= nSet; m_rParent.SetRetoucheColor(nSet); |
762 | 0 | break;// "Color", |
763 | 0 | } |
764 | 0 | } |
765 | 1 | } |
766 | 1 | } |
767 | | |
768 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |