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 : *((SwViewOption*)this) = rCopy;
43 0 : }
44 :
45 0 : SwMasterUsrPref::SwMasterUsrPref(sal_Bool bWeb) :
46 : eFldUpdateFlags(AUTOUPD_OFF),
47 : nLinkUpdateMode(0),
48 : bIsHScrollMetricSet(sal_False),
49 : bIsVScrollMetricSet(sal_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 0 : pWebColorConfig(bWeb ? new SwWebColorConfig(*this) : 0),
58 0 : bApplyCharUnit(sal_False)
59 : {
60 0 : MeasurementSystem eSystem = SvtSysLocale().GetLocaleData().getMeasurementSystemEnum();
61 0 : eUserMetric = MEASURE_METRIC == eSystem ? FUNIT_CM : FUNIT_INCH;
62 0 : eHScrollMetric = eVScrollMetric = eUserMetric;
63 :
64 0 : aContentConfig.Load();
65 0 : aLayoutConfig.Load();
66 0 : aGridConfig.Load();
67 0 : aCursorConfig.Load();
68 0 : if(pWebColorConfig)
69 0 : pWebColorConfig->Load();
70 0 : }
71 :
72 0 : SwMasterUsrPref::~SwMasterUsrPref()
73 : {
74 0 : delete pWebColorConfig;
75 0 : }
76 :
77 0 : 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 0 : const int nCount = bWeb ? 12 : 19;
103 0 : Sequence<OUString> aNames(nCount);
104 0 : OUString* pNames = aNames.getArray();
105 0 : for(int i = 0; i < nCount; i++)
106 : {
107 0 : pNames[i] = OUString::createFromAscii(aPropNames[i]);
108 : }
109 0 : return aNames;
110 : }
111 :
112 0 : SwContentViewConfig::SwContentViewConfig(sal_Bool bIsWeb, SwMasterUsrPref& rPar) :
113 : ConfigItem(bIsWeb ? OUString("Office.WriterWeb/Content") : OUString("Office.Writer/Content")),
114 : rParent(rPar),
115 0 : bWeb(bIsWeb)
116 : {
117 0 : Load();
118 0 : EnableNotification( GetPropertyNames() );
119 0 : }
120 :
121 0 : SwContentViewConfig::~SwContentViewConfig()
122 : {
123 0 : }
124 :
125 0 : void SwContentViewConfig::Notify( const Sequence< OUString > & /*rPropertyNames*/ )
126 : {
127 0 : Load();
128 0 : }
129 :
130 0 : void SwContentViewConfig::Commit()
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 : sal_Bool bVal = sal_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.IsFldName(); 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(sal_True); break;// "NonprintingCharacter/ParagraphEnd",
150 0 : case 8: bVal = rParent.IsSoftHyph(); break;// "NonprintingCharacter/OptionalHyphen",
151 0 : case 9: bVal = rParent.IsBlank(sal_True); break;// "NonprintingCharacter/Space",
152 0 : case 10: bVal = rParent.IsLineBreak(sal_True);break;// "NonprintingCharacter/Break",
153 0 : case 11: bVal = rParent.IsHardBlank(); break;// "NonprintingCharacter/ProtectedSpace",
154 0 : case 12: bVal = rParent.IsTab(sal_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(sal_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].setValue(&bVal, ::getBooleanCppuType());
164 : }
165 0 : PutProperties(aNames, aValues);
166 0 : }
167 :
168 0 : void SwContentViewConfig::Load()
169 : {
170 0 : Sequence<OUString> aNames = GetPropertyNames();
171 0 : Sequence<Any> aValues = GetProperties(aNames);
172 0 : const Any* pValues = aValues.getConstArray();
173 : OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
174 0 : if(aValues.getLength() == aNames.getLength())
175 : {
176 0 : for(int nProp = 0; nProp < aNames.getLength(); nProp++)
177 : {
178 0 : if(pValues[nProp].hasValue())
179 : {
180 0 : sal_Bool bSet = nProp != 16 ? *(sal_Bool*)pValues[nProp].getValue() : sal_False;
181 0 : switch(nProp)
182 : {
183 0 : case 0: rParent.SetGraphic(bSet); break;// "Display/GraphicObject",
184 0 : case 1: rParent.SetTable(bSet); break;// "Display/Table",
185 0 : case 2: rParent.SetDraw(bSet); break;// "Display/DrawingControl",
186 0 : case 3: rParent.SetFldName(bSet); break;// "Display/FieldCode",
187 0 : case 4: rParent.SetPostIts(bSet); break;// "Display/Note",
188 0 : case 5: rParent.SetShowContentTips(bSet); break;// "Display/ShowContentTips",
189 0 : case 6: rParent.SetViewMetaChars(bSet); break; //"NonprintingCharacter/MetaCharacters"
190 0 : case 7: rParent.SetParagraph(bSet); break;// "NonprintingCharacter/ParagraphEnd",
191 0 : case 8: rParent.SetSoftHyph(bSet); break;// "NonprintingCharacter/OptionalHyphen",
192 0 : case 9: rParent.SetBlank(bSet); break;// "NonprintingCharacter/Space",
193 0 : case 10: rParent.SetLineBreak(bSet);break;// "NonprintingCharacter/Break",
194 0 : case 11: rParent.SetHardBlank(bSet); break;// "NonprintingCharacter/ProtectedSpace",
195 0 : case 12: rParent.SetTab(bSet); break;// "NonprintingCharacter/Tab",
196 0 : case 13: rParent.SetShowHiddenField(bSet); break;// "NonprintingCharacter/Fields: HiddenText",
197 0 : case 14: rParent.SetShowHiddenPara(bSet); break;// "NonprintingCharacter/Fields: HiddenParagraph",
198 0 : case 15: rParent.SetShowHiddenChar(bSet); break;// "NonprintingCharacter/HiddenCharacter",
199 : case 16:
200 : {
201 0 : sal_Int32 nSet = 0;
202 0 : pValues[nProp] >>= nSet;
203 0 : rParent.SetUpdateLinkMode(nSet, sal_True);
204 : }
205 0 : break;// "Update/Link",
206 0 : case 17: rParent.SetUpdateFields(bSet, sal_True); break;// "Update/Field",
207 0 : case 18: rParent.SetUpdateCharts(bSet, sal_True); break;// "Update/Chart"
208 : }
209 : }
210 : }
211 0 : }
212 0 : }
213 :
214 0 : 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 0 : const int nCount = bWeb ? 13 : 20;
241 0 : Sequence<OUString> aNames(nCount);
242 0 : OUString* pNames = aNames.getArray();
243 0 : for(int i = 0; i < nCount; i++)
244 : {
245 0 : pNames[i] = OUString::createFromAscii(aPropNames[i]);
246 : }
247 0 : return aNames;
248 : }
249 :
250 0 : SwLayoutViewConfig::SwLayoutViewConfig(sal_Bool bIsWeb, SwMasterUsrPref& rPar) :
251 : ConfigItem(bIsWeb ? OUString("Office.WriterWeb/Layout") : OUString("Office.Writer/Layout"),
252 : CONFIG_MODE_DELAYED_UPDATE|CONFIG_MODE_RELEASE_TREE),
253 : rParent(rPar),
254 0 : bWeb(bIsWeb)
255 : {
256 0 : }
257 :
258 0 : SwLayoutViewConfig::~SwLayoutViewConfig()
259 : {
260 0 : }
261 :
262 0 : void SwLayoutViewConfig::Commit()
263 : {
264 0 : Sequence<OUString> aNames = GetPropertyNames();
265 :
266 0 : Sequence<Any> aValues(aNames.getLength());
267 0 : Any* pValues = aValues.getArray();
268 :
269 0 : for(int nProp = 0; nProp < aNames.getLength(); nProp++)
270 : {
271 0 : Any &rVal = pValues[nProp];
272 0 : switch(nProp)
273 : {
274 0 : case 0: rVal <<= (sal_Bool) rParent.IsCrossHair(); break; // "Line/Guide",
275 0 : case 1: rVal <<= (sal_Bool) rParent.IsViewHScrollBar(); break; // "Window/HorizontalScroll",
276 0 : case 2: rVal <<= (sal_Bool) rParent.IsViewVScrollBar(); break; // "Window/VerticalScroll",
277 0 : case 3: rVal <<= (sal_Bool) rParent.IsViewAnyRuler(); break; // "Window/ShowRulers"
278 : // #i14593# use IsView*Ruler(sal_True) instead of IsView*Ruler()
279 : // this preserves the single ruler states even if "Window/ShowRulers" is off
280 0 : case 4: rVal <<= (sal_Bool) rParent.IsViewHRuler(sal_True); break; // "Window/HorizontalRuler",
281 0 : case 5: rVal <<= (sal_Bool) rParent.IsViewVRuler(sal_True); break; // "Window/VerticalRuler",
282 : case 6:
283 0 : if(rParent.bIsHScrollMetricSet)
284 0 : rVal <<= (sal_Int32)rParent.eHScrollMetric; // "Window/HorizontalRulerUnit"
285 0 : break;
286 : case 7:
287 0 : if(rParent.bIsVScrollMetricSet)
288 0 : rVal <<= (sal_Int32)rParent.eVScrollMetric; // "Window/VerticalRulerUnit"
289 0 : break;
290 0 : case 8: rVal <<= (sal_Bool) rParent.IsSmoothScroll(); break; // "Window/SmoothScroll",
291 0 : case 9: rVal <<= (sal_Int32)rParent.GetZoom(); break; // "Zoom/Value",
292 0 : case 10: rVal <<= (sal_Int32)rParent.GetZoomType(); break; // "Zoom/Type",
293 0 : case 11: rVal <<= (sal_Bool) rParent.IsAlignMathObjectsToBaseline(); break; // "Other/IsAlignMathObjectsToBaseline"
294 0 : case 12: rVal <<= (sal_Int32)rParent.GetMetric(); break; // "Other/MeasureUnit",
295 0 : case 13: rVal <<= static_cast<sal_Int32>(convertTwipToMm100(rParent.GetDefTab())); break;// "Other/TabStop",
296 0 : case 14: rVal <<= (sal_Bool) rParent.IsVRulerRight(); break; // "Window/IsVerticalRulerRight",
297 0 : case 15: rVal <<= (sal_Int32)rParent.GetViewLayoutColumns(); break; // "ViewLayout/Columns",
298 0 : case 16: rVal <<= (sal_Bool) rParent.IsViewLayoutBookMode(); break; // "ViewLayout/BookMode",
299 0 : case 17: rVal <<= (sal_Bool) rParent.IsSquaredPageMode(); break; // "Other/IsSquaredPageMode",
300 0 : case 18: rVal <<= (sal_Bool) rParent.IsApplyCharUnit(); break; // "Other/ApplyCharUnit",
301 0 : case 19: rVal <<= (sal_Bool) rParent.IsShowScrollBarTips(); break; // "Window/ShowScrollBarTips",
302 : }
303 : }
304 0 : PutProperties(aNames, aValues);
305 0 : }
306 :
307 0 : void SwLayoutViewConfig::Load()
308 : {
309 0 : Sequence<OUString> aNames = GetPropertyNames();
310 0 : Sequence<Any> aValues = GetProperties(aNames);
311 0 : const Any* pValues = aValues.getConstArray();
312 : OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
313 0 : if(aValues.getLength() == aNames.getLength())
314 : {
315 0 : for(int nProp = 0; nProp < aNames.getLength(); nProp++)
316 : {
317 0 : if(pValues[nProp].hasValue())
318 : {
319 0 : sal_Int32 nInt32Val = 0;
320 0 : sal_Bool bSet = sal_False;
321 0 : pValues[nProp] >>= nInt32Val;
322 0 : pValues[nProp] >>= bSet;
323 :
324 0 : switch(nProp)
325 : {
326 0 : case 0: rParent.SetCrossHair(bSet); break;// "Line/Guide",
327 0 : case 1: rParent.SetViewHScrollBar(bSet); break;// "Window/HorizontalScroll",
328 0 : case 2: rParent.SetViewVScrollBar(bSet); break;// "Window/VerticalScroll",
329 0 : case 3: rParent.SetViewAnyRuler(bSet);break; // "Window/ShowRulers"
330 0 : case 4: rParent.SetViewHRuler(bSet); break;// "Window/HorizontalRuler",
331 0 : case 5: rParent.SetViewVRuler(bSet); break;// "Window/VerticalRuler",
332 : case 6:
333 : {
334 0 : rParent.bIsHScrollMetricSet = sal_True;
335 0 : rParent.eHScrollMetric = ((FieldUnit)nInt32Val); // "Window/HorizontalRulerUnit"
336 : }
337 0 : break;
338 : case 7:
339 : {
340 0 : rParent.bIsVScrollMetricSet = sal_True;
341 0 : rParent.eVScrollMetric = ((FieldUnit)nInt32Val); // "Window/VerticalRulerUnit"
342 : }
343 0 : break;
344 0 : case 8: rParent.SetSmoothScroll(bSet); break;// "Window/SmoothScroll",
345 0 : case 9: rParent.SetZoom( static_cast< sal_uInt16 >(nInt32Val) ); break;// "Zoom/Value",
346 0 : case 10: rParent.SetZoomType( static_cast< SvxZoomType >(nInt32Val) ); break;// "Zoom/Type",
347 0 : case 11: rParent.SetAlignMathObjectsToBaseline(bSet); break;// "Other/IsAlignMathObjectsToBaseline"
348 0 : case 12: rParent.SetMetric((FieldUnit)nInt32Val, sal_True); break;// "Other/MeasureUnit",
349 0 : case 13: rParent.SetDefTab(convertMm100ToTwip(nInt32Val), sal_True); break;// "Other/TabStop",
350 0 : case 14: rParent.SetVRulerRight(bSet); break;// "Window/IsVerticalRulerRight",
351 0 : case 15: rParent.SetViewLayoutColumns( static_cast<sal_uInt16>(nInt32Val) ); break;// "ViewLayout/Columns",
352 0 : case 16: rParent.SetViewLayoutBookMode(bSet); break;// "ViewLayout/BookMode",
353 0 : case 17: rParent.SetDefaultPageMode(bSet,sal_True); break;// "Other/IsSquaredPageMode",
354 0 : case 18: rParent.SetApplyCharUnit(bSet); break;// "Other/ApplyUserChar"
355 0 : case 19: rParent.SetShowScrollBarTips(bSet); break;// "Window/ShowScrollBarTips",
356 : }
357 : }
358 : }
359 0 : }
360 0 : }
361 :
362 0 : void SwLayoutViewConfig::Notify( const ::com::sun::star::uno::Sequence< OUString >& ) {}
363 :
364 0 : 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 0 : const int nCount = 7;
377 0 : Sequence<OUString> aNames(nCount);
378 0 : OUString* pNames = aNames.getArray();
379 0 : for(int i = 0; i < nCount; i++)
380 : {
381 0 : pNames[i] = OUString::createFromAscii(aPropNames[i]);
382 : }
383 0 : return aNames;
384 : }
385 :
386 0 : SwGridConfig::SwGridConfig(sal_Bool bIsWeb, SwMasterUsrPref& rPar) :
387 : ConfigItem(bIsWeb ? OUString("Office.WriterWeb/Grid") : OUString("Office.Writer/Grid"),
388 : CONFIG_MODE_DELAYED_UPDATE|CONFIG_MODE_RELEASE_TREE),
389 0 : rParent(rPar)
390 : {
391 0 : }
392 :
393 0 : SwGridConfig::~SwGridConfig()
394 : {
395 0 : }
396 :
397 0 : void SwGridConfig::Commit()
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 : sal_Bool bSet;
407 0 : switch(nProp)
408 : {
409 0 : case 0: bSet = rParent.IsSnap(); break;// "Option/SnapToGrid",
410 0 : case 1: bSet = rParent.IsGridVisible(); break;//"Option/VisibleGrid",
411 0 : case 2: bSet = rParent.IsSynchronize(); break;// "Option/Synchronize",
412 0 : case 3: pValues[nProp] <<= (sal_Int32)convertTwipToMm100(rParent.GetSnapSize().Width()); break;// "Resolution/XAxis",
413 0 : case 4: pValues[nProp] <<= (sal_Int32)convertTwipToMm100(rParent.GetSnapSize().Height()); break;// "Resolution/YAxis",
414 0 : case 5: pValues[nProp] <<= (sal_Int16)rParent.GetDivisionX(); break;// "Subdivision/XAxis",
415 0 : case 6: pValues[nProp] <<= (sal_Int16)rParent.GetDivisionY(); break;// "Subdivision/YAxis"
416 : }
417 0 : if(nProp < 3)
418 0 : pValues[nProp].setValue(&bSet, ::getBooleanCppuType());
419 : }
420 0 : PutProperties(aNames, aValues);
421 0 : }
422 :
423 0 : void SwGridConfig::Load()
424 : {
425 0 : Sequence<OUString> aNames = GetPropertyNames();
426 0 : Sequence<Any> aValues = GetProperties(aNames);
427 0 : const Any* pValues = aValues.getConstArray();
428 : OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
429 0 : if(aValues.getLength() == aNames.getLength())
430 : {
431 0 : Size aSnap(rParent.GetSnapSize());
432 0 : for(int nProp = 0; nProp < aNames.getLength(); nProp++)
433 : {
434 0 : if(pValues[nProp].hasValue())
435 : {
436 0 : sal_Bool bSet = nProp < 3 ? *(sal_Bool*)pValues[nProp].getValue() : sal_False;
437 0 : sal_Int32 nSet = 0;
438 0 : if(nProp >= 3)
439 0 : pValues[nProp] >>= nSet;
440 0 : switch(nProp)
441 : {
442 0 : case 0: rParent.SetSnap(bSet); break;// "Option/SnapToGrid",
443 0 : case 1: rParent.SetGridVisible(bSet); break;//"Option/VisibleGrid",
444 0 : case 2: rParent.SetSynchronize(bSet); break;// "Option/Synchronize",
445 0 : case 3: aSnap.Width() = convertMm100ToTwip(nSet); break;// "Resolution/XAxis",
446 0 : case 4: aSnap.Height() = convertMm100ToTwip(nSet); break;// "Resolution/YAxis",
447 0 : case 5: rParent.SetDivisionX((short)nSet); break;// "Subdivision/XAxis",
448 0 : case 6: rParent.SetDivisionY((short)nSet); break;// "Subdivision/YAxis"
449 : }
450 : }
451 : }
452 0 : rParent.SetSnapSize(aSnap);
453 0 : }
454 0 : }
455 :
456 0 : void SwGridConfig::Notify( const ::com::sun::star::uno::Sequence< OUString >& ) {}
457 :
458 0 : Sequence<OUString> SwCursorConfig::GetPropertyNames()
459 : {
460 : static const char* aPropNames[] =
461 : {
462 : "DirectCursor/UseDirectCursor", // 0
463 : "DirectCursor/Insert", // 1
464 : "Option/ProtectedArea" // 2
465 : };
466 0 : const int nCount = 3;
467 0 : Sequence<OUString> aNames(nCount);
468 0 : OUString* pNames = aNames.getArray();
469 0 : for(int i = 0; i < nCount; i++)
470 0 : pNames[i] = OUString::createFromAscii(aPropNames[i]);
471 0 : return aNames;
472 : }
473 :
474 0 : SwCursorConfig::SwCursorConfig(SwMasterUsrPref& rPar) :
475 : ConfigItem("Office.Writer/Cursor",
476 : CONFIG_MODE_DELAYED_UPDATE|CONFIG_MODE_RELEASE_TREE),
477 0 : rParent(rPar)
478 : {
479 0 : }
480 :
481 0 : SwCursorConfig::~SwCursorConfig()
482 : {
483 0 : }
484 :
485 0 : void SwCursorConfig::Commit()
486 : {
487 0 : Sequence<OUString> aNames = GetPropertyNames();
488 :
489 0 : Sequence<Any> aValues(aNames.getLength());
490 0 : Any* pValues = aValues.getArray();
491 :
492 0 : for(int nProp = 0; nProp < aNames.getLength(); nProp++)
493 : {
494 : sal_Bool bSet;
495 0 : switch(nProp)
496 : {
497 0 : case 0: bSet = rParent.IsShadowCursor(); break;// "DirectCursor/UseDirectCursor",
498 0 : case 1: pValues[nProp] <<= (sal_Int32)rParent.GetShdwCrsrFillMode(); break;// "DirectCursor/Insert",
499 0 : case 2: bSet = rParent.IsCursorInProtectedArea(); break;// "Option/ProtectedArea"
500 : }
501 0 : if(nProp != 1 )
502 0 : pValues[nProp].setValue(&bSet, ::getBooleanCppuType());
503 : }
504 0 : PutProperties(aNames, aValues);
505 0 : }
506 :
507 0 : void SwCursorConfig::Load()
508 : {
509 0 : Sequence<OUString> aNames = GetPropertyNames();
510 0 : Sequence<Any> aValues = GetProperties(aNames);
511 0 : const Any* pValues = aValues.getConstArray();
512 : OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
513 0 : if(aValues.getLength() == aNames.getLength())
514 : {
515 :
516 0 : for(int nProp = 0; nProp < aNames.getLength(); nProp++)
517 : {
518 0 : if(pValues[nProp].hasValue())
519 : {
520 0 : sal_Bool bSet = sal_False;
521 0 : sal_Int32 nSet = 0;
522 0 : if(nProp != 1 )
523 0 : bSet = *(sal_Bool*)pValues[nProp].getValue();
524 : else
525 0 : pValues[nProp] >>= nSet;
526 0 : switch(nProp)
527 : {
528 0 : case 0: rParent.SetShadowCursor(bSet); break;// "DirectCursor/UseDirectCursor",
529 0 : case 1: rParent.SetShdwCrsrFillMode((sal_uInt8)nSet); break;// "DirectCursor/Insert",
530 0 : case 2: rParent.SetCursorInProtectedArea(bSet); break;// "Option/ProtectedArea"
531 : }
532 : }
533 : }
534 :
535 0 : }
536 0 : }
537 :
538 0 : void SwCursorConfig::Notify( const ::com::sun::star::uno::Sequence< OUString >& ) {}
539 :
540 0 : SwWebColorConfig::SwWebColorConfig(SwMasterUsrPref& rPar) :
541 : ConfigItem("Office.WriterWeb/Background",
542 : CONFIG_MODE_DELAYED_UPDATE|CONFIG_MODE_RELEASE_TREE),
543 : rParent(rPar),
544 0 : aPropNames(1)
545 : {
546 0 : aPropNames.getArray()[0] = "Color";
547 0 : }
548 :
549 0 : SwWebColorConfig::~SwWebColorConfig()
550 : {
551 0 : }
552 :
553 0 : void SwWebColorConfig::Commit()
554 : {
555 0 : Sequence<Any> aValues(aPropNames.getLength());
556 0 : Any* pValues = aValues.getArray();
557 0 : for(int nProp = 0; nProp < aPropNames.getLength(); nProp++)
558 : {
559 0 : switch(nProp)
560 : {
561 0 : case 0: pValues[nProp] <<= (sal_Int32)rParent.GetRetoucheColor().GetColor(); break;// "Color",
562 : }
563 : }
564 0 : PutProperties(aPropNames, aValues);
565 0 : }
566 :
567 0 : void SwWebColorConfig::Notify( const ::com::sun::star::uno::Sequence< OUString >& ) {}
568 :
569 0 : void SwWebColorConfig::Load()
570 : {
571 0 : Sequence<Any> aValues = GetProperties(aPropNames);
572 0 : const Any* pValues = aValues.getConstArray();
573 : OSL_ENSURE(aValues.getLength() == aPropNames.getLength(), "GetProperties failed");
574 0 : if(aValues.getLength() == aPropNames.getLength())
575 : {
576 0 : for(int nProp = 0; nProp < aPropNames.getLength(); nProp++)
577 : {
578 0 : if(pValues[nProp].hasValue())
579 : {
580 0 : switch(nProp)
581 : {
582 : case 0:
583 0 : sal_Int32 nSet = 0;
584 0 : pValues[nProp] >>= nSet; rParent.SetRetoucheColor(nSet);
585 0 : break;// "Color",
586 : }
587 : }
588 : }
589 0 : }
590 0 : }
591 :
592 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|