Line data Source code
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 <tools/stream.hxx>
21 : #include <unotools/syslocale.hxx>
22 :
23 : #include "swtypes.hxx"
24 : #include "hintids.hxx"
25 : #include "uitool.hxx"
26 : #include "usrpref.hxx"
27 : #include "crstate.hxx"
28 : #include <linguistic/lngprops.hxx>
29 : #include <com/sun/star/beans/XPropertySet.hpp>
30 : #include <com/sun/star/uno/Any.hxx>
31 : #include <com/sun/star/uno/Sequence.hxx>
32 : #include <unotools/localedatawrapper.hxx>
33 :
34 : #include <unomid.h>
35 :
36 : using namespace utl;
37 : using namespace ::com::sun::star;
38 : using namespace ::com::sun::star::uno;
39 :
40 0 : void SwMasterUsrPref::SetUsrPref(const SwViewOption &rCopy)
41 : {
42 0 : *static_cast<SwViewOption*>(this) = rCopy;
43 0 : }
44 :
45 59 : SwMasterUsrPref::SwMasterUsrPref(bool bWeb) :
46 : eFieldUpdateFlags(AUTOUPD_OFF),
47 : nLinkUpdateMode(0),
48 : bIsHScrollMetricSet(false),
49 : bIsVScrollMetricSet(false),
50 : nDefTab( MM50 * 4 ),
51 : bIsSquaredPageMode(false),
52 : bIsAlignMathObjectsToBaseline(false),
53 : aContentConfig(bWeb, *this),
54 : aLayoutConfig(bWeb, *this),
55 : aGridConfig(bWeb, *this),
56 : aCursorConfig(*this),
57 1 : pWebColorConfig(bWeb ? new SwWebColorConfig(*this) : 0),
58 60 : bApplyCharUnit(false)
59 : {
60 59 : MeasurementSystem eSystem = SvtSysLocale().GetLocaleData().getMeasurementSystemEnum();
61 59 : eUserMetric = MEASURE_METRIC == eSystem ? FUNIT_CM : FUNIT_INCH;
62 59 : eHScrollMetric = eVScrollMetric = eUserMetric;
63 :
64 59 : aContentConfig.Load();
65 59 : aLayoutConfig.Load();
66 59 : aGridConfig.Load();
67 59 : aCursorConfig.Load();
68 59 : if(pWebColorConfig)
69 1 : pWebColorConfig->Load();
70 59 : }
71 :
72 54 : SwMasterUsrPref::~SwMasterUsrPref()
73 : {
74 27 : delete pWebColorConfig;
75 27 : }
76 :
77 177 : Sequence<OUString> SwContentViewConfig::GetPropertyNames()
78 : {
79 : static const char* aPropNames[] =
80 : {
81 : "Display/GraphicObject", // 0
82 : "Display/Table", // 1
83 : "Display/DrawingControl", // 2
84 : "Display/FieldCode", // 3
85 : "Display/Note", // 4
86 : "Display/ShowContentTips", // 5
87 : "NonprintingCharacter/MetaCharacters", // 6
88 : "NonprintingCharacter/ParagraphEnd", // 7
89 : "NonprintingCharacter/OptionalHyphen", // 8
90 : "NonprintingCharacter/Space", // 9
91 : "NonprintingCharacter/Break", // 10
92 : "NonprintingCharacter/ProtectedSpace", // 11
93 : "NonprintingCharacter/Tab", // 12 //not in Writer/Web
94 : "NonprintingCharacter/HiddenText", // 13
95 : "NonprintingCharacter/HiddenParagraph", // 14
96 : "NonprintingCharacter/HiddenCharacter", // 15
97 : "Update/Link", // 16
98 : "Update/Field", // 17
99 : "Update/Chart" // 18
100 :
101 : };
102 177 : const int nCount = bWeb ? 12 : 19;
103 177 : Sequence<OUString> aNames(nCount);
104 177 : OUString* pNames = aNames.getArray();
105 3519 : for(int i = 0; i < nCount; i++)
106 : {
107 3342 : pNames[i] = OUString::createFromAscii(aPropNames[i]);
108 : }
109 177 : return aNames;
110 : }
111 :
112 59 : SwContentViewConfig::SwContentViewConfig(bool bIsWeb, SwMasterUsrPref& rPar) :
113 : ConfigItem(bIsWeb ? OUString("Office.WriterWeb/Content") : OUString("Office.Writer/Content")),
114 : rParent(rPar),
115 59 : bWeb(bIsWeb)
116 : {
117 59 : Load();
118 59 : EnableNotification( GetPropertyNames() );
119 59 : }
120 :
121 27 : SwContentViewConfig::~SwContentViewConfig()
122 : {
123 27 : }
124 :
125 0 : void SwContentViewConfig::Notify( const Sequence< OUString > & /*rPropertyNames*/ )
126 : {
127 0 : Load();
128 0 : }
129 :
130 0 : void SwContentViewConfig::ImplCommit()
131 : {
132 0 : Sequence<OUString> aNames = GetPropertyNames();
133 :
134 0 : Sequence<Any> aValues(aNames.getLength());
135 0 : Any* pValues = aValues.getArray();
136 :
137 0 : for(int nProp = 0; nProp < aNames.getLength(); nProp++)
138 : {
139 0 : bool bVal = false;
140 0 : switch(nProp)
141 : {
142 0 : case 0: bVal = rParent.IsGraphic(); break;// "Display/GraphicObject",
143 0 : case 1: bVal = rParent.IsTable(); break;// "Display/Table",
144 0 : case 2: bVal = rParent.IsDraw(); break;// "Display/DrawingControl",
145 0 : case 3: bVal = rParent.IsFieldName(); break;// "Display/FieldCode",
146 0 : case 4: bVal = rParent.IsPostIts(); break;// "Display/Note",
147 0 : case 5: bVal = rParent.IsShowContentTips(); break; // "Display/ShowContentTips"
148 0 : case 6: bVal = rParent.IsViewMetaChars(); break; //"NonprintingCharacter/MetaCharacters"
149 0 : case 7: bVal = rParent.IsParagraph(true); break;// "NonprintingCharacter/ParagraphEnd",
150 0 : case 8: bVal = rParent.IsSoftHyph(); break;// "NonprintingCharacter/OptionalHyphen",
151 0 : case 9: bVal = rParent.IsBlank(true); break;// "NonprintingCharacter/Space",
152 0 : case 10: bVal = rParent.IsLineBreak(true);break;// "NonprintingCharacter/Break",
153 0 : case 11: bVal = rParent.IsHardBlank(); break;// "NonprintingCharacter/ProtectedSpace",
154 0 : case 12: bVal = rParent.IsTab(true); break;// "NonprintingCharacter/Tab",
155 0 : case 13: bVal = rParent.IsShowHiddenField(); break;// "NonprintingCharacter/Fields: HiddenText",
156 0 : case 14: bVal = rParent.IsShowHiddenPara(); break;// "NonprintingCharacter/Fields: HiddenParagraph",
157 0 : case 15: bVal = rParent.IsShowHiddenChar(true); break;// "NonprintingCharacter/HiddenCharacter",
158 0 : case 16: pValues[nProp] <<= rParent.GetUpdateLinkMode(); break;// "Update/Link",
159 0 : case 17: bVal = rParent.IsUpdateFields(); break;// "Update/Field",
160 0 : case 18: bVal = rParent.IsUpdateCharts(); break;// "Update/Chart"
161 : }
162 0 : if(nProp != 16)
163 0 : pValues[nProp] <<= bVal;
164 : }
165 0 : PutProperties(aNames, aValues);
166 0 : }
167 :
168 118 : void SwContentViewConfig::Load()
169 : {
170 118 : Sequence<OUString> aNames = GetPropertyNames();
171 236 : Sequence<Any> aValues = GetProperties(aNames);
172 118 : const Any* pValues = aValues.getConstArray();
173 : OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
174 118 : if(aValues.getLength() == aNames.getLength())
175 : {
176 2346 : for(int nProp = 0; nProp < aNames.getLength(); nProp++)
177 : {
178 2228 : if(pValues[nProp].hasValue())
179 : {
180 2226 : bool bSet = nProp != 16 && *static_cast<sal_Bool const *>(pValues[nProp].getValue());
181 2226 : switch(nProp)
182 : {
183 118 : case 0: rParent.SetGraphic(bSet); break;// "Display/GraphicObject",
184 118 : case 1: rParent.SetTable(bSet); break;// "Display/Table",
185 118 : case 2: rParent.SetDraw(bSet); break;// "Display/DrawingControl",
186 118 : case 3: rParent.SetFieldName(bSet); break;// "Display/FieldCode",
187 118 : case 4: rParent.SetPostIts(bSet); break;// "Display/Note",
188 116 : case 5: rParent.SetShowContentTips(bSet); break;// "Display/ShowContentTips",
189 118 : case 6: rParent.SetViewMetaChars(bSet); break; //"NonprintingCharacter/MetaCharacters"
190 118 : case 7: rParent.SetParagraph(bSet); break;// "NonprintingCharacter/ParagraphEnd",
191 118 : case 8: rParent.SetSoftHyph(bSet); break;// "NonprintingCharacter/OptionalHyphen",
192 118 : case 9: rParent.SetBlank(bSet); break;// "NonprintingCharacter/Space",
193 118 : case 10: rParent.SetLineBreak(bSet);break;// "NonprintingCharacter/Break",
194 118 : case 11: rParent.SetHardBlank(bSet); break;// "NonprintingCharacter/ProtectedSpace",
195 116 : case 12: rParent.SetTab(bSet); break;// "NonprintingCharacter/Tab",
196 116 : case 13: rParent.SetShowHiddenField(bSet); break;// "NonprintingCharacter/Fields: HiddenText",
197 116 : case 14: rParent.SetShowHiddenPara(bSet); break;// "NonprintingCharacter/Fields: HiddenParagraph",
198 116 : case 15: rParent.SetShowHiddenChar(bSet); break;// "NonprintingCharacter/HiddenCharacter",
199 : case 16:
200 : {
201 116 : sal_Int32 nSet = 0;
202 116 : pValues[nProp] >>= nSet;
203 116 : rParent.SetUpdateLinkMode(nSet, true);
204 : }
205 116 : break;// "Update/Link",
206 116 : case 17: rParent.SetUpdateFields(bSet, true); break;// "Update/Field",
207 116 : case 18: rParent.SetUpdateCharts(bSet, true); break;// "Update/Chart"
208 : }
209 : }
210 : }
211 118 : }
212 118 : }
213 :
214 117 : Sequence<OUString> SwLayoutViewConfig::GetPropertyNames()
215 : {
216 : static const char* aPropNames[] =
217 : {
218 : "Line/Guide", // 0
219 : "Window/HorizontalScroll", // 1
220 : "Window/VerticalScroll", // 2
221 : "Window/ShowRulers", // 3
222 : "Window/HorizontalRuler", // 4
223 : "Window/VerticalRuler", // 5
224 : "Window/HorizontalRulerUnit", // 6
225 : "Window/VerticalRulerUnit", // 7
226 : "Window/SmoothScroll", // 8
227 : "Zoom/Value", // 9
228 : "Zoom/Type", //10
229 : "Other/IsAlignMathObjectsToBaseline", //11
230 : "Other/MeasureUnit", //12
231 : // below properties are not available in WriterWeb
232 : "Other/TabStop", //13
233 : "Window/IsVerticalRulerRight", //14
234 : "ViewLayout/Columns", //15
235 : "ViewLayout/BookMode", //16
236 : "Other/IsSquaredPageMode", //17
237 : "Other/ApplyCharUnit", //18
238 : "Window/ShowScrollBarTips" //19
239 : };
240 117 : const int nCount = bWeb ? 13 : 20;
241 117 : Sequence<OUString> aNames(nCount);
242 117 : OUString* pNames = aNames.getArray();
243 2443 : for(int i = 0; i < nCount; i++)
244 : {
245 2326 : pNames[i] = OUString::createFromAscii(aPropNames[i]);
246 : }
247 117 : return aNames;
248 : }
249 :
250 59 : SwLayoutViewConfig::SwLayoutViewConfig(bool bIsWeb, SwMasterUsrPref& rPar) :
251 : ConfigItem(bIsWeb ? OUString("Office.WriterWeb/Layout") : OUString("Office.Writer/Layout"),
252 118 : ConfigItemMode::DelayedUpdate|ConfigItemMode::ReleaseTree),
253 : rParent(rPar),
254 118 : bWeb(bIsWeb)
255 : {
256 59 : }
257 :
258 27 : SwLayoutViewConfig::~SwLayoutViewConfig()
259 : {
260 27 : }
261 :
262 58 : void SwLayoutViewConfig::ImplCommit()
263 : {
264 58 : Sequence<OUString> aNames = GetPropertyNames();
265 :
266 116 : Sequence<Any> aValues(aNames.getLength());
267 58 : Any* pValues = aValues.getArray();
268 :
269 1211 : for(int nProp = 0; nProp < aNames.getLength(); nProp++)
270 : {
271 1153 : Any &rVal = pValues[nProp];
272 1153 : switch(nProp)
273 : {
274 58 : case 0: rVal <<= rParent.IsCrossHair(); break; // "Line/Guide",
275 58 : case 1: rVal <<= rParent.IsViewHScrollBar(); break; // "Window/HorizontalScroll",
276 58 : case 2: rVal <<= rParent.IsViewVScrollBar(); break; // "Window/VerticalScroll",
277 58 : case 3: rVal <<= rParent.IsViewAnyRuler(); break; // "Window/ShowRulers"
278 : // #i14593# use IsView*Ruler(true) instead of IsView*Ruler()
279 : // this preserves the single ruler states even if "Window/ShowRulers" is off
280 58 : case 4: rVal <<= rParent.IsViewHRuler(true); break; // "Window/HorizontalRuler",
281 58 : case 5: rVal <<= rParent.IsViewVRuler(true); break; // "Window/VerticalRuler",
282 : case 6:
283 58 : if(rParent.bIsHScrollMetricSet)
284 0 : rVal <<= (sal_Int32)rParent.eHScrollMetric; // "Window/HorizontalRulerUnit"
285 58 : break;
286 : case 7:
287 58 : if(rParent.bIsVScrollMetricSet)
288 0 : rVal <<= (sal_Int32)rParent.eVScrollMetric; // "Window/VerticalRulerUnit"
289 58 : break;
290 58 : case 8: rVal <<= rParent.IsSmoothScroll(); break; // "Window/SmoothScroll",
291 58 : case 9: rVal <<= (sal_Int32)rParent.GetZoom(); break; // "Zoom/Value",
292 58 : case 10: rVal <<= (sal_Int32)rParent.GetZoomType(); break; // "Zoom/Type",
293 58 : case 11: rVal <<= rParent.IsAlignMathObjectsToBaseline(); break; // "Other/IsAlignMathObjectsToBaseline"
294 58 : case 12: rVal <<= (sal_Int32)rParent.GetMetric(); break; // "Other/MeasureUnit",
295 57 : case 13: rVal <<= static_cast<sal_Int32>(convertTwipToMm100(rParent.GetDefTab())); break;// "Other/TabStop",
296 57 : case 14: rVal <<= rParent.IsVRulerRight(); break; // "Window/IsVerticalRulerRight",
297 57 : case 15: rVal <<= (sal_Int32)rParent.GetViewLayoutColumns(); break; // "ViewLayout/Columns",
298 57 : case 16: rVal <<= rParent.IsViewLayoutBookMode(); break; // "ViewLayout/BookMode",
299 57 : case 17: rVal <<= rParent.IsSquaredPageMode(); break; // "Other/IsSquaredPageMode",
300 57 : case 18: rVal <<= rParent.IsApplyCharUnit(); break; // "Other/ApplyCharUnit",
301 57 : case 19: rVal <<= rParent.IsShowScrollBarTips(); break; // "Window/ShowScrollBarTips",
302 : }
303 : }
304 116 : PutProperties(aNames, aValues);
305 58 : }
306 :
307 59 : void SwLayoutViewConfig::Load()
308 : {
309 59 : Sequence<OUString> aNames = GetPropertyNames();
310 118 : Sequence<Any> aValues = GetProperties(aNames);
311 59 : const Any* pValues = aValues.getConstArray();
312 : OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
313 59 : if(aValues.getLength() == aNames.getLength())
314 : {
315 1232 : for(int nProp = 0; nProp < aNames.getLength(); nProp++)
316 : {
317 1173 : if(pValues[nProp].hasValue())
318 : {
319 1004 : sal_Int32 nInt32Val = 0;
320 1004 : bool bSet = false;
321 1004 : pValues[nProp] >>= nInt32Val;
322 1004 : pValues[nProp] >>= bSet;
323 :
324 1004 : switch(nProp)
325 : {
326 59 : case 0: rParent.SetCrossHair(bSet); break;// "Line/Guide",
327 59 : case 1: rParent.SetViewHScrollBar(bSet); break;// "Window/HorizontalScroll",
328 59 : case 2: rParent.SetViewVScrollBar(bSet); break;// "Window/VerticalScroll",
329 59 : case 3: rParent.SetViewAnyRuler(bSet);break; // "Window/ShowRulers"
330 59 : case 4: rParent.SetViewHRuler(bSet); break;// "Window/HorizontalRuler",
331 59 : case 5: rParent.SetViewVRuler(bSet); break;// "Window/VerticalRuler",
332 : case 6:
333 : {
334 0 : rParent.bIsHScrollMetricSet = true;
335 0 : rParent.eHScrollMetric = ((FieldUnit)nInt32Val); // "Window/HorizontalRulerUnit"
336 : }
337 0 : break;
338 : case 7:
339 : {
340 0 : rParent.bIsVScrollMetricSet = true;
341 0 : rParent.eVScrollMetric = ((FieldUnit)nInt32Val); // "Window/VerticalRulerUnit"
342 : }
343 0 : break;
344 59 : case 8: rParent.SetSmoothScroll(bSet); break;// "Window/SmoothScroll",
345 59 : case 9: rParent.SetZoom( static_cast< sal_uInt16 >(nInt32Val) ); break;// "Zoom/Value",
346 59 : case 10: rParent.SetZoomType( static_cast< SvxZoomType >(nInt32Val) ); break;// "Zoom/Type",
347 59 : case 11: rParent.SetAlignMathObjectsToBaseline(bSet); break;// "Other/IsAlignMathObjectsToBaseline"
348 8 : case 12: rParent.SetMetric((FieldUnit)nInt32Val, true); break;// "Other/MeasureUnit",
349 58 : case 13: rParent.SetDefTab(convertMm100ToTwip(nInt32Val), true); break;// "Other/TabStop",
350 58 : case 14: rParent.SetVRulerRight(bSet); break;// "Window/IsVerticalRulerRight",
351 58 : case 15: rParent.SetViewLayoutColumns( static_cast<sal_uInt16>(nInt32Val) ); break;// "ViewLayout/Columns",
352 58 : case 16: rParent.SetViewLayoutBookMode(bSet); break;// "ViewLayout/BookMode",
353 58 : case 17: rParent.SetDefaultPageMode(bSet,true); break;// "Other/IsSquaredPageMode",
354 58 : case 18: rParent.SetApplyCharUnit(bSet); break;// "Other/ApplyUserChar"
355 58 : case 19: rParent.SetShowScrollBarTips(bSet); break;// "Window/ShowScrollBarTips",
356 : }
357 : }
358 : }
359 59 : }
360 59 : }
361 :
362 0 : void SwLayoutViewConfig::Notify( const ::com::sun::star::uno::Sequence< OUString >& ) {}
363 :
364 59 : Sequence<OUString> SwGridConfig::GetPropertyNames()
365 : {
366 : static const char* aPropNames[] =
367 : {
368 : "Option/SnapToGrid", // 0
369 : "Option/VisibleGrid", // 1
370 : "Option/Synchronize", // 2
371 : "Resolution/XAxis", // 3
372 : "Resolution/YAxis", // 4
373 : "Subdivision/XAxis", // 5
374 : "Subdivision/YAxis" // 6
375 : };
376 59 : const int nCount = 7;
377 59 : Sequence<OUString> aNames(nCount);
378 59 : OUString* pNames = aNames.getArray();
379 472 : for(int i = 0; i < nCount; i++)
380 : {
381 413 : pNames[i] = OUString::createFromAscii(aPropNames[i]);
382 : }
383 59 : return aNames;
384 : }
385 :
386 59 : SwGridConfig::SwGridConfig(bool bIsWeb, SwMasterUsrPref& rPar) :
387 : ConfigItem(bIsWeb ? OUString("Office.WriterWeb/Grid") : OUString("Office.Writer/Grid"),
388 118 : ConfigItemMode::DelayedUpdate|ConfigItemMode::ReleaseTree),
389 118 : rParent(rPar)
390 : {
391 59 : }
392 :
393 27 : SwGridConfig::~SwGridConfig()
394 : {
395 27 : }
396 :
397 0 : void SwGridConfig::ImplCommit()
398 : {
399 0 : Sequence<OUString> aNames = GetPropertyNames();
400 :
401 0 : Sequence<Any> aValues(aNames.getLength());
402 0 : Any* pValues = aValues.getArray();
403 :
404 0 : for(int nProp = 0; nProp < aNames.getLength(); nProp++)
405 : {
406 0 : switch(nProp)
407 : {
408 0 : case 0: pValues[nProp] <<= rParent.IsSnap(); break;// "Option/SnapToGrid",
409 0 : case 1: pValues[nProp] <<= rParent.IsGridVisible(); break;//"Option/VisibleGrid",
410 0 : case 2: pValues[nProp] <<= rParent.IsSynchronize(); break;// "Option/Synchronize",
411 0 : case 3: pValues[nProp] <<= (sal_Int32)convertTwipToMm100(rParent.GetSnapSize().Width()); break;// "Resolution/XAxis",
412 0 : case 4: pValues[nProp] <<= (sal_Int32)convertTwipToMm100(rParent.GetSnapSize().Height()); break;// "Resolution/YAxis",
413 0 : case 5: pValues[nProp] <<= (sal_Int16)rParent.GetDivisionX(); break;// "Subdivision/XAxis",
414 0 : case 6: pValues[nProp] <<= (sal_Int16)rParent.GetDivisionY(); break;// "Subdivision/YAxis"
415 : }
416 : }
417 0 : PutProperties(aNames, aValues);
418 0 : }
419 :
420 59 : void SwGridConfig::Load()
421 : {
422 59 : Sequence<OUString> aNames = GetPropertyNames();
423 118 : Sequence<Any> aValues = GetProperties(aNames);
424 59 : const Any* pValues = aValues.getConstArray();
425 : OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
426 59 : if(aValues.getLength() == aNames.getLength())
427 : {
428 59 : Size aSnap(rParent.GetSnapSize());
429 472 : for(int nProp = 0; nProp < aNames.getLength(); nProp++)
430 : {
431 413 : if(pValues[nProp].hasValue())
432 : {
433 413 : bool bSet = nProp < 3 && *static_cast<sal_Bool const *>(pValues[nProp].getValue());
434 413 : sal_Int32 nSet = 0;
435 413 : if(nProp >= 3)
436 236 : pValues[nProp] >>= nSet;
437 413 : switch(nProp)
438 : {
439 59 : case 0: rParent.SetSnap(bSet); break;// "Option/SnapToGrid",
440 59 : case 1: rParent.SetGridVisible(bSet); break;//"Option/VisibleGrid",
441 59 : case 2: rParent.SetSynchronize(bSet); break;// "Option/Synchronize",
442 59 : case 3: aSnap.Width() = convertMm100ToTwip(nSet); break;// "Resolution/XAxis",
443 59 : case 4: aSnap.Height() = convertMm100ToTwip(nSet); break;// "Resolution/YAxis",
444 59 : case 5: rParent.SetDivisionX((short)nSet); break;// "Subdivision/XAxis",
445 59 : case 6: rParent.SetDivisionY((short)nSet); break;// "Subdivision/YAxis"
446 : }
447 : }
448 : }
449 59 : rParent.SetSnapSize(aSnap);
450 59 : }
451 59 : }
452 :
453 0 : void SwGridConfig::Notify( const ::com::sun::star::uno::Sequence< OUString >& ) {}
454 :
455 59 : Sequence<OUString> SwCursorConfig::GetPropertyNames()
456 : {
457 : static const char* aPropNames[] =
458 : {
459 : "DirectCursor/UseDirectCursor", // 0
460 : "DirectCursor/Insert", // 1
461 : "Option/ProtectedArea", // 2
462 : "Option/IgnoreProtectedArea" // 3
463 : };
464 59 : const int nCount = SAL_N_ELEMENTS(aPropNames);
465 59 : Sequence<OUString> aNames(nCount);
466 59 : OUString* pNames = aNames.getArray();
467 295 : for(int i = 0; i < nCount; i++)
468 236 : pNames[i] = OUString::createFromAscii(aPropNames[i]);
469 59 : return aNames;
470 : }
471 :
472 59 : SwCursorConfig::SwCursorConfig(SwMasterUsrPref& rPar) :
473 : ConfigItem("Office.Writer/Cursor",
474 118 : ConfigItemMode::DelayedUpdate|ConfigItemMode::ReleaseTree),
475 118 : rParent(rPar)
476 : {
477 59 : }
478 :
479 27 : SwCursorConfig::~SwCursorConfig()
480 : {
481 27 : }
482 :
483 0 : void SwCursorConfig::ImplCommit()
484 : {
485 0 : Sequence<OUString> aNames = GetPropertyNames();
486 :
487 0 : Sequence<Any> aValues(aNames.getLength());
488 0 : Any* pValues = aValues.getArray();
489 :
490 0 : for(int nProp = 0; nProp < aNames.getLength(); nProp++)
491 : {
492 0 : switch(nProp)
493 : {
494 0 : case 0: pValues[nProp] <<= rParent.IsShadowCursor(); break;// "DirectCursor/UseDirectCursor",
495 0 : case 1: pValues[nProp] <<= (sal_Int32)rParent.GetShdwCrsrFillMode(); break;// "DirectCursor/Insert",
496 0 : case 2: pValues[nProp] <<= rParent.IsCursorInProtectedArea(); break;// "Option/ProtectedArea"
497 0 : case 3: pValues[nProp] <<= rParent.IsIgnoreProtectedArea(); break; // "Option/IgnoreProtectedArea"
498 : }
499 : }
500 0 : PutProperties(aNames, aValues);
501 0 : }
502 :
503 59 : void SwCursorConfig::Load()
504 : {
505 59 : Sequence<OUString> aNames = GetPropertyNames();
506 118 : Sequence<Any> aValues = GetProperties(aNames);
507 59 : const Any* pValues = aValues.getConstArray();
508 : OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
509 59 : if(aValues.getLength() == aNames.getLength())
510 : {
511 :
512 295 : for(int nProp = 0; nProp < aNames.getLength(); nProp++)
513 : {
514 236 : if(pValues[nProp].hasValue())
515 : {
516 236 : bool bSet = false;
517 236 : sal_Int32 nSet = 0;
518 236 : if(nProp != 1 )
519 177 : bSet = *static_cast<sal_Bool const *>(pValues[nProp].getValue());
520 : else
521 59 : pValues[nProp] >>= nSet;
522 236 : switch(nProp)
523 : {
524 59 : case 0: rParent.SetShadowCursor(bSet); break;// "DirectCursor/UseDirectCursor",
525 59 : case 1: rParent.SetShdwCrsrFillMode((sal_uInt8)nSet); break;// "DirectCursor/Insert",
526 59 : case 2: rParent.SetCursorInProtectedArea(bSet); break;// "Option/ProtectedArea"
527 59 : case 3: rParent.SetIgnoreProtectedArea(bSet); break; // "Option/IgnoreProtectedArea"
528 : }
529 : }
530 : }
531 :
532 59 : }
533 59 : }
534 :
535 0 : void SwCursorConfig::Notify( const ::com::sun::star::uno::Sequence< OUString >& ) {}
536 :
537 1 : SwWebColorConfig::SwWebColorConfig(SwMasterUsrPref& rPar) :
538 : ConfigItem("Office.WriterWeb/Background",
539 2 : ConfigItemMode::DelayedUpdate|ConfigItemMode::ReleaseTree),
540 : rParent(rPar),
541 2 : aPropNames(1)
542 : {
543 1 : aPropNames.getArray()[0] = "Color";
544 1 : }
545 :
546 2 : SwWebColorConfig::~SwWebColorConfig()
547 : {
548 2 : }
549 :
550 0 : void SwWebColorConfig::ImplCommit()
551 : {
552 0 : Sequence<Any> aValues(aPropNames.getLength());
553 0 : Any* pValues = aValues.getArray();
554 0 : for(int nProp = 0; nProp < aPropNames.getLength(); nProp++)
555 : {
556 0 : switch(nProp)
557 : {
558 0 : case 0: pValues[nProp] <<= (sal_Int32)rParent.GetRetoucheColor().GetColor(); break;// "Color",
559 : }
560 : }
561 0 : PutProperties(aPropNames, aValues);
562 0 : }
563 :
564 0 : void SwWebColorConfig::Notify( const ::com::sun::star::uno::Sequence< OUString >& ) {}
565 :
566 1 : void SwWebColorConfig::Load()
567 : {
568 1 : Sequence<Any> aValues = GetProperties(aPropNames);
569 1 : const Any* pValues = aValues.getConstArray();
570 : OSL_ENSURE(aValues.getLength() == aPropNames.getLength(), "GetProperties failed");
571 1 : if(aValues.getLength() == aPropNames.getLength())
572 : {
573 2 : for(int nProp = 0; nProp < aPropNames.getLength(); nProp++)
574 : {
575 1 : if(pValues[nProp].hasValue())
576 : {
577 0 : switch(nProp)
578 : {
579 : case 0:
580 0 : sal_Int32 nSet = 0;
581 0 : pValues[nProp] >>= nSet; rParent.SetRetoucheColor(nSet);
582 0 : break;// "Color",
583 : }
584 : }
585 : }
586 1 : }
587 178 : }
588 :
589 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|