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 <vcl/svapp.hxx>
21 :
22 : #include <com/sun/star/uno/Any.hxx>
23 : #include <com/sun/star/uno/Sequence.hxx>
24 : #include "cfgids.hxx"
25 : #include "appoptio.hxx"
26 : #include "rechead.hxx"
27 : #include "scresid.hxx"
28 : #include "global.hxx"
29 : #include "userlist.hxx"
30 : #include "sc.hrc"
31 : #include <formula/compiler.hrc>
32 : #include "miscuno.hxx"
33 :
34 : using namespace utl;
35 : using namespace com::sun::star::uno;
36 :
37 : // ScAppOptions - Applikations-Optionen
38 :
39 34 : ScAppOptions::ScAppOptions() : pLRUList( NULL )
40 : {
41 34 : SetDefaults();
42 34 : }
43 :
44 293 : ScAppOptions::ScAppOptions( const ScAppOptions& rCpy ) : pLRUList( NULL )
45 : {
46 293 : *this = rCpy;
47 293 : }
48 :
49 302 : ScAppOptions::~ScAppOptions()
50 : {
51 302 : delete [] pLRUList;
52 302 : }
53 :
54 34 : void ScAppOptions::SetDefaults()
55 : {
56 34 : if ( ScOptionsUtil::IsMetricSystem() )
57 0 : eMetric = FUNIT_CM; // default for countries with metric system
58 : else
59 34 : eMetric = FUNIT_INCH; // default for others
60 :
61 34 : nZoom = 100;
62 34 : eZoomType = SVX_ZOOM_PERCENT;
63 34 : bSynchronizeZoom = true;
64 34 : nStatusFunc = SUBTOTAL_FUNC_SUM;
65 34 : bAutoComplete = true;
66 34 : bDetectiveAuto = true;
67 :
68 34 : delete [] pLRUList;
69 34 : pLRUList = new sal_uInt16[5]; // sinnvoll vorbelegen
70 34 : pLRUList[0] = SC_OPCODE_SUM;
71 34 : pLRUList[1] = SC_OPCODE_AVERAGE;
72 34 : pLRUList[2] = SC_OPCODE_MIN;
73 34 : pLRUList[3] = SC_OPCODE_MAX;
74 34 : pLRUList[4] = SC_OPCODE_IF;
75 34 : nLRUFuncCount = 5;
76 :
77 34 : nTrackContentColor = COL_TRANSPARENT;
78 34 : nTrackInsertColor = COL_TRANSPARENT;
79 34 : nTrackDeleteColor = COL_TRANSPARENT;
80 34 : nTrackMoveColor = COL_TRANSPARENT;
81 34 : eLinkMode = LM_ON_DEMAND;
82 :
83 34 : nDefaultObjectSizeWidth = 8000;
84 34 : nDefaultObjectSizeHeight = 5000;
85 :
86 34 : mbShowSharedDocumentWarning = true;
87 :
88 34 : meKeyBindingType = ScOptionsUtil::KEY_DEFAULT;
89 34 : }
90 :
91 313 : const ScAppOptions& ScAppOptions::operator=( const ScAppOptions& rCpy )
92 : {
93 313 : eMetric = rCpy.eMetric;
94 313 : eZoomType = rCpy.eZoomType;
95 313 : bSynchronizeZoom = rCpy.bSynchronizeZoom;
96 313 : nZoom = rCpy.nZoom;
97 313 : SetLRUFuncList( rCpy.pLRUList, rCpy.nLRUFuncCount );
98 313 : nStatusFunc = rCpy.nStatusFunc;
99 313 : bAutoComplete = rCpy.bAutoComplete;
100 313 : bDetectiveAuto = rCpy.bDetectiveAuto;
101 313 : nTrackContentColor = rCpy.nTrackContentColor;
102 313 : nTrackInsertColor = rCpy.nTrackInsertColor;
103 313 : nTrackDeleteColor = rCpy.nTrackDeleteColor;
104 313 : nTrackMoveColor = rCpy.nTrackMoveColor;
105 313 : eLinkMode = rCpy.eLinkMode;
106 313 : nDefaultObjectSizeWidth = rCpy.nDefaultObjectSizeWidth;
107 313 : nDefaultObjectSizeHeight = rCpy.nDefaultObjectSizeHeight;
108 313 : mbShowSharedDocumentWarning = rCpy.mbShowSharedDocumentWarning;
109 313 : meKeyBindingType = rCpy.meKeyBindingType;
110 313 : return *this;
111 : }
112 :
113 347 : void ScAppOptions::SetLRUFuncList( const sal_uInt16* pList, const sal_uInt16 nCount )
114 : {
115 347 : delete [] pLRUList;
116 :
117 347 : nLRUFuncCount = nCount;
118 :
119 347 : if ( nLRUFuncCount > 0 )
120 : {
121 347 : pLRUList = new sal_uInt16[nLRUFuncCount];
122 :
123 2082 : for ( sal_uInt16 i=0; i<nLRUFuncCount; i++ )
124 1735 : pLRUList[i] = pList[i];
125 : }
126 : else
127 0 : pLRUList = NULL;
128 347 : }
129 :
130 : // Config Item containing app options
131 :
132 34 : static void lcl_SetLastFunctions( ScAppOptions& rOpt, const Any& rValue )
133 : {
134 34 : Sequence<sal_Int32> aSeq;
135 34 : if ( rValue >>= aSeq )
136 : {
137 34 : long nCount = aSeq.getLength();
138 34 : if ( nCount < USHRT_MAX )
139 : {
140 34 : const sal_Int32* pArray = aSeq.getConstArray();
141 34 : sal_uInt16* pUShorts = new sal_uInt16[nCount];
142 204 : for (long i=0; i<nCount; i++)
143 170 : pUShorts[i] = (sal_uInt16) pArray[i];
144 :
145 34 : rOpt.SetLRUFuncList( pUShorts, sal::static_int_cast<sal_uInt16>(nCount) );
146 :
147 34 : delete[] pUShorts;
148 : }
149 34 : }
150 34 : }
151 :
152 1 : static void lcl_GetLastFunctions( Any& rDest, const ScAppOptions& rOpt )
153 : {
154 1 : long nCount = rOpt.GetLRUFuncListCount();
155 1 : sal_uInt16* pUShorts = rOpt.GetLRUFuncList();
156 1 : if ( nCount && pUShorts )
157 : {
158 1 : Sequence<sal_Int32> aSeq( nCount );
159 1 : sal_Int32* pArray = aSeq.getArray();
160 6 : for (long i=0; i<nCount; i++)
161 5 : pArray[i] = pUShorts[i];
162 1 : rDest <<= aSeq;
163 : }
164 : else
165 0 : rDest <<= Sequence<sal_Int32>(0); // empty
166 1 : }
167 :
168 34 : static void lcl_SetSortList( const Any& rValue )
169 : {
170 34 : Sequence<OUString> aSeq;
171 34 : if ( rValue >>= aSeq )
172 : {
173 34 : long nCount = aSeq.getLength();
174 34 : const OUString* pArray = aSeq.getConstArray();
175 34 : ScUserList aList;
176 :
177 : // if setting is "default", keep default values from ScUserList ctor
178 : //! mark "default" in a safe way
179 34 : sal_Bool bDefault = ( nCount == 1 && pArray[0] == "NULL" );
180 :
181 34 : if (!bDefault)
182 : {
183 0 : aList.clear();
184 :
185 0 : for (long i=0; i<nCount; i++)
186 : {
187 0 : ScUserListData* pNew = new ScUserListData( pArray[i] );
188 0 : aList.push_back(pNew);
189 : }
190 : }
191 :
192 34 : ScGlobal::SetUserList( &aList );
193 34 : }
194 34 : }
195 :
196 1 : static void lcl_GetSortList( Any& rDest )
197 : {
198 1 : const ScUserList* pUserList = ScGlobal::GetUserList();
199 1 : if (pUserList)
200 : {
201 1 : size_t nCount = pUserList->size();
202 1 : Sequence<OUString> aSeq( nCount );
203 1 : OUString* pArray = aSeq.getArray();
204 10 : for (size_t i=0; i<nCount; ++i)
205 9 : pArray[i] = (*pUserList)[sal::static_int_cast<sal_uInt16>(i)]->GetString();
206 1 : rDest <<= aSeq;
207 : }
208 : else
209 0 : rDest <<= Sequence<OUString>(0); // empty
210 1 : }
211 :
212 : #define CFGPATH_LAYOUT "Office.Calc/Layout"
213 :
214 : #define SCLAYOUTOPT_MEASURE 0
215 : #define SCLAYOUTOPT_STATUSBAR 1
216 : #define SCLAYOUTOPT_ZOOMVAL 2
217 : #define SCLAYOUTOPT_ZOOMTYPE 3
218 : #define SCLAYOUTOPT_SYNCZOOM 4
219 : #define SCLAYOUTOPT_COUNT 5
220 :
221 : #define CFGPATH_INPUT "Office.Calc/Input"
222 :
223 : #define SCINPUTOPT_LASTFUNCS 0
224 : #define SCINPUTOPT_AUTOINPUT 1
225 : #define SCINPUTOPT_DET_AUTO 2
226 : #define SCINPUTOPT_COUNT 3
227 :
228 : #define CFGPATH_REVISION "Office.Calc/Revision/Color"
229 :
230 : #define SCREVISOPT_CHANGE 0
231 : #define SCREVISOPT_INSERTION 1
232 : #define SCREVISOPT_DELETION 2
233 : #define SCREVISOPT_MOVEDENTRY 3
234 : #define SCREVISOPT_COUNT 4
235 :
236 : #define CFGPATH_CONTENT "Office.Calc/Content/Update"
237 :
238 : #define SCCONTENTOPT_LINK 0
239 : #define SCCONTENTOPT_COUNT 1
240 :
241 : #define CFGPATH_SORTLIST "Office.Calc/SortList"
242 :
243 : #define SCSORTLISTOPT_LIST 0
244 : #define SCSORTLISTOPT_COUNT 1
245 :
246 : #define CFGPATH_MISC "Office.Calc/Misc"
247 :
248 : #define SCMISCOPT_DEFOBJWIDTH 0
249 : #define SCMISCOPT_DEFOBJHEIGHT 1
250 : #define SCMISCOPT_SHOWSHAREDDOCWARN 2
251 : #define SCMISCOPT_COUNT 3
252 :
253 : #define CFGPATH_COMPAT "Office.Calc/Compatibility"
254 :
255 : #define SCCOMPATOPT_KEY_BINDING 0
256 : #define SCCOMPATOPT_COUNT 1
257 :
258 35 : Sequence<OUString> ScAppCfg::GetLayoutPropertyNames()
259 : {
260 : static const char* aPropNames[] =
261 : {
262 : "Other/MeasureUnit/NonMetric", // SCLAYOUTOPT_MEASURE
263 : "Other/StatusbarFunction", // SCLAYOUTOPT_STATUSBAR
264 : "Zoom/Value", // SCLAYOUTOPT_ZOOMVAL
265 : "Zoom/Type", // SCLAYOUTOPT_ZOOMTYPE
266 : "Zoom/Synchronize" // SCLAYOUTOPT_SYNCZOOM
267 : };
268 35 : Sequence<OUString> aNames(SCLAYOUTOPT_COUNT);
269 35 : OUString* pNames = aNames.getArray();
270 210 : for(int i = 0; i < SCLAYOUTOPT_COUNT; i++)
271 175 : pNames[i] = OUString::createFromAscii(aPropNames[i]);
272 :
273 : // adjust for metric system
274 35 : if (ScOptionsUtil::IsMetricSystem())
275 0 : pNames[SCLAYOUTOPT_MEASURE] = "Other/MeasureUnit/Metric";
276 :
277 35 : return aNames;
278 : }
279 :
280 35 : Sequence<OUString> ScAppCfg::GetInputPropertyNames()
281 : {
282 : static const char* aPropNames[] =
283 : {
284 : "LastFunctions", // SCINPUTOPT_LASTFUNCS
285 : "AutoInput", // SCINPUTOPT_AUTOINPUT
286 : "DetectiveAuto" // SCINPUTOPT_DET_AUTO
287 : };
288 35 : Sequence<OUString> aNames(SCINPUTOPT_COUNT);
289 35 : OUString* pNames = aNames.getArray();
290 140 : for(int i = 0; i < SCINPUTOPT_COUNT; i++)
291 105 : pNames[i] = OUString::createFromAscii(aPropNames[i]);
292 :
293 35 : return aNames;
294 : }
295 :
296 35 : Sequence<OUString> ScAppCfg::GetRevisionPropertyNames()
297 : {
298 : static const char* aPropNames[] =
299 : {
300 : "Change", // SCREVISOPT_CHANGE
301 : "Insertion", // SCREVISOPT_INSERTION
302 : "Deletion", // SCREVISOPT_DELETION
303 : "MovedEntry" // SCREVISOPT_MOVEDENTRY
304 : };
305 35 : Sequence<OUString> aNames(SCREVISOPT_COUNT);
306 35 : OUString* pNames = aNames.getArray();
307 175 : for(int i = 0; i < SCREVISOPT_COUNT; i++)
308 140 : pNames[i] = OUString::createFromAscii(aPropNames[i]);
309 :
310 35 : return aNames;
311 : }
312 :
313 35 : Sequence<OUString> ScAppCfg::GetContentPropertyNames()
314 : {
315 : static const char* aPropNames[] =
316 : {
317 : "Link" // SCCONTENTOPT_LINK
318 : };
319 35 : Sequence<OUString> aNames(SCCONTENTOPT_COUNT);
320 35 : OUString* pNames = aNames.getArray();
321 70 : for(int i = 0; i < SCCONTENTOPT_COUNT; i++)
322 35 : pNames[i] = OUString::createFromAscii(aPropNames[i]);
323 :
324 35 : return aNames;
325 : }
326 :
327 35 : Sequence<OUString> ScAppCfg::GetSortListPropertyNames()
328 : {
329 : static const char* aPropNames[] =
330 : {
331 : "List" // SCSORTLISTOPT_LIST
332 : };
333 35 : Sequence<OUString> aNames(SCSORTLISTOPT_COUNT);
334 35 : OUString* pNames = aNames.getArray();
335 70 : for(int i = 0; i < SCSORTLISTOPT_COUNT; i++)
336 35 : pNames[i] = OUString::createFromAscii(aPropNames[i]);
337 :
338 35 : return aNames;
339 : }
340 :
341 35 : Sequence<OUString> ScAppCfg::GetMiscPropertyNames()
342 : {
343 : static const char* aPropNames[] =
344 : {
345 : "DefaultObjectSize/Width", // SCMISCOPT_DEFOBJWIDTH
346 : "DefaultObjectSize/Height", // SCMISCOPT_DEFOBJHEIGHT
347 : "SharedDocument/ShowWarning" // SCMISCOPT_SHOWSHAREDDOCWARN
348 : };
349 35 : Sequence<OUString> aNames(SCMISCOPT_COUNT);
350 35 : OUString* pNames = aNames.getArray();
351 140 : for(int i = 0; i < SCMISCOPT_COUNT; i++)
352 105 : pNames[i] = OUString::createFromAscii(aPropNames[i]);
353 :
354 35 : return aNames;
355 : }
356 :
357 35 : Sequence<OUString> ScAppCfg::GetCompatPropertyNames()
358 : {
359 : static const char* aPropNames[] =
360 : {
361 : "KeyBindings/BaseGroup" // SCCOMPATOPT_KEY_BINDING
362 : };
363 35 : Sequence<OUString> aNames(SCCOMPATOPT_COUNT);
364 35 : OUString* pNames = aNames.getArray();
365 70 : for (int i = 0; i < SCCOMPATOPT_COUNT; ++i)
366 35 : pNames[i] = OUString::createFromAscii(aPropNames[i]);
367 :
368 35 : return aNames;
369 : }
370 :
371 34 : ScAppCfg::ScAppCfg() :
372 : aLayoutItem( OUString( CFGPATH_LAYOUT ) ),
373 : aInputItem( OUString( CFGPATH_INPUT ) ),
374 : aRevisionItem( OUString( CFGPATH_REVISION ) ),
375 : aContentItem( OUString( CFGPATH_CONTENT ) ),
376 : aSortListItem( OUString( CFGPATH_SORTLIST ) ),
377 : aMiscItem( OUString( CFGPATH_MISC ) ),
378 34 : aCompatItem( OUString(CFGPATH_COMPAT ) )
379 : {
380 34 : sal_Int32 nIntVal = 0;
381 :
382 34 : Sequence<OUString> aNames;
383 68 : Sequence<Any> aValues;
384 34 : const Any* pValues = NULL;
385 :
386 34 : aNames = GetLayoutPropertyNames();
387 34 : aValues = aLayoutItem.GetProperties(aNames);
388 34 : aLayoutItem.EnableNotification(aNames);
389 34 : pValues = aValues.getConstArray();
390 : OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
391 34 : if(aValues.getLength() == aNames.getLength())
392 : {
393 204 : for(int nProp = 0; nProp < aNames.getLength(); nProp++)
394 : {
395 : OSL_ENSURE(pValues[nProp].hasValue(), "property value missing");
396 170 : if(pValues[nProp].hasValue())
397 : {
398 170 : switch(nProp)
399 : {
400 : case SCLAYOUTOPT_MEASURE:
401 34 : if (pValues[nProp] >>= nIntVal) SetAppMetric( (FieldUnit) nIntVal );
402 34 : break;
403 : case SCLAYOUTOPT_STATUSBAR:
404 34 : if (pValues[nProp] >>= nIntVal) SetStatusFunc( (sal_uInt16) nIntVal );
405 34 : break;
406 : case SCLAYOUTOPT_ZOOMVAL:
407 34 : if (pValues[nProp] >>= nIntVal) SetZoom( (sal_uInt16) nIntVal );
408 34 : break;
409 : case SCLAYOUTOPT_ZOOMTYPE:
410 34 : if (pValues[nProp] >>= nIntVal) SetZoomType( (SvxZoomType) nIntVal );
411 34 : break;
412 : case SCLAYOUTOPT_SYNCZOOM:
413 34 : SetSynchronizeZoom( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
414 34 : break;
415 : }
416 : }
417 : }
418 : }
419 34 : aLayoutItem.SetCommitLink( LINK( this, ScAppCfg, LayoutCommitHdl ) );
420 :
421 34 : aNames = GetInputPropertyNames();
422 34 : aValues = aInputItem.GetProperties(aNames);
423 34 : aInputItem.EnableNotification(aNames);
424 34 : pValues = aValues.getConstArray();
425 : OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
426 34 : if(aValues.getLength() == aNames.getLength())
427 : {
428 136 : for(int nProp = 0; nProp < aNames.getLength(); nProp++)
429 : {
430 : OSL_ENSURE(pValues[nProp].hasValue(), "property value missing");
431 102 : if(pValues[nProp].hasValue())
432 : {
433 102 : switch(nProp)
434 : {
435 : case SCINPUTOPT_LASTFUNCS:
436 34 : lcl_SetLastFunctions( *this, pValues[nProp] );
437 34 : break;
438 : case SCINPUTOPT_AUTOINPUT:
439 34 : SetAutoComplete( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
440 34 : break;
441 : case SCINPUTOPT_DET_AUTO:
442 34 : SetDetectiveAuto( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
443 34 : break;
444 : }
445 : }
446 : }
447 : }
448 34 : aInputItem.SetCommitLink( LINK( this, ScAppCfg, InputCommitHdl ) );
449 :
450 34 : aNames = GetRevisionPropertyNames();
451 34 : aValues = aRevisionItem.GetProperties(aNames);
452 34 : aRevisionItem.EnableNotification(aNames);
453 34 : pValues = aValues.getConstArray();
454 : OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
455 34 : if(aValues.getLength() == aNames.getLength())
456 : {
457 170 : for(int nProp = 0; nProp < aNames.getLength(); nProp++)
458 : {
459 : OSL_ENSURE(pValues[nProp].hasValue(), "property value missing");
460 136 : if(pValues[nProp].hasValue())
461 : {
462 136 : switch(nProp)
463 : {
464 : case SCREVISOPT_CHANGE:
465 34 : if (pValues[nProp] >>= nIntVal) SetTrackContentColor( (sal_uInt32) nIntVal );
466 34 : break;
467 : case SCREVISOPT_INSERTION:
468 34 : if (pValues[nProp] >>= nIntVal) SetTrackInsertColor( (sal_uInt32) nIntVal );
469 34 : break;
470 : case SCREVISOPT_DELETION:
471 34 : if (pValues[nProp] >>= nIntVal) SetTrackDeleteColor( (sal_uInt32) nIntVal );
472 34 : break;
473 : case SCREVISOPT_MOVEDENTRY:
474 34 : if (pValues[nProp] >>= nIntVal) SetTrackMoveColor( (sal_uInt32) nIntVal );
475 34 : break;
476 : }
477 : }
478 : }
479 : }
480 34 : aRevisionItem.SetCommitLink( LINK( this, ScAppCfg, RevisionCommitHdl ) );
481 :
482 34 : aNames = GetContentPropertyNames();
483 34 : aValues = aContentItem.GetProperties(aNames);
484 34 : aContentItem.EnableNotification(aNames);
485 34 : pValues = aValues.getConstArray();
486 : OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
487 34 : if(aValues.getLength() == aNames.getLength())
488 : {
489 68 : for(int nProp = 0; nProp < aNames.getLength(); nProp++)
490 : {
491 : OSL_ENSURE(pValues[nProp].hasValue(), "property value missing");
492 34 : if(pValues[nProp].hasValue())
493 : {
494 34 : switch(nProp)
495 : {
496 : case SCCONTENTOPT_LINK:
497 34 : if (pValues[nProp] >>= nIntVal) SetLinkMode( (ScLkUpdMode) nIntVal );
498 34 : break;
499 : }
500 : }
501 : }
502 : }
503 34 : aContentItem.SetCommitLink( LINK( this, ScAppCfg, ContentCommitHdl ) );
504 :
505 34 : aNames = GetSortListPropertyNames();
506 34 : aValues = aSortListItem.GetProperties(aNames);
507 34 : aSortListItem.EnableNotification(aNames);
508 34 : pValues = aValues.getConstArray();
509 : OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
510 34 : if(aValues.getLength() == aNames.getLength())
511 : {
512 68 : for(int nProp = 0; nProp < aNames.getLength(); nProp++)
513 : {
514 : OSL_ENSURE(pValues[nProp].hasValue(), "property value missing");
515 34 : if(pValues[nProp].hasValue())
516 : {
517 34 : switch(nProp)
518 : {
519 : case SCSORTLISTOPT_LIST:
520 34 : lcl_SetSortList( pValues[nProp] );
521 34 : break;
522 : }
523 : }
524 : }
525 : }
526 34 : aSortListItem.SetCommitLink( LINK( this, ScAppCfg, SortListCommitHdl ) );
527 :
528 34 : aNames = GetMiscPropertyNames();
529 34 : aValues = aMiscItem.GetProperties(aNames);
530 34 : aMiscItem.EnableNotification(aNames);
531 34 : pValues = aValues.getConstArray();
532 : OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
533 34 : if(aValues.getLength() == aNames.getLength())
534 : {
535 136 : for(int nProp = 0; nProp < aNames.getLength(); nProp++)
536 : {
537 : OSL_ENSURE(pValues[nProp].hasValue(), "property value missing");
538 102 : if(pValues[nProp].hasValue())
539 : {
540 102 : switch(nProp)
541 : {
542 : case SCMISCOPT_DEFOBJWIDTH:
543 34 : if (pValues[nProp] >>= nIntVal) SetDefaultObjectSizeWidth( nIntVal );
544 34 : break;
545 : case SCMISCOPT_DEFOBJHEIGHT:
546 34 : if (pValues[nProp] >>= nIntVal) SetDefaultObjectSizeHeight( nIntVal );
547 34 : break;
548 : case SCMISCOPT_SHOWSHAREDDOCWARN:
549 34 : SetShowSharedDocumentWarning( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
550 34 : break;
551 : }
552 : }
553 : }
554 : }
555 34 : aMiscItem.SetCommitLink( LINK( this, ScAppCfg, MiscCommitHdl ) );
556 :
557 34 : aNames = GetCompatPropertyNames();
558 34 : aValues = aCompatItem.GetProperties(aNames);
559 34 : aCompatItem.EnableNotification(aNames);
560 34 : pValues = aValues.getConstArray();
561 34 : if (aValues.getLength() == aNames.getLength())
562 : {
563 68 : for (int nProp = 0; nProp < aNames.getLength(); ++nProp)
564 : {
565 34 : switch (nProp)
566 : {
567 : case SCCOMPATOPT_KEY_BINDING:
568 : {
569 34 : nIntVal = 0; // 0 = 'Default'
570 34 : pValues[nProp] >>= nIntVal;
571 34 : SetKeyBindingType(static_cast<ScOptionsUtil::KeyBindingType>(nIntVal));
572 : }
573 34 : break;
574 : }
575 : }
576 : }
577 68 : aCompatItem.SetCommitLink( LINK(this, ScAppCfg, CompatCommitHdl) );
578 34 : }
579 2 : IMPL_LINK_NOARG(ScAppCfg, LayoutCommitHdl)
580 : {
581 1 : Sequence<OUString> aNames = GetLayoutPropertyNames();
582 2 : Sequence<Any> aValues(aNames.getLength());
583 1 : Any* pValues = aValues.getArray();
584 :
585 6 : for(int nProp = 0; nProp < aNames.getLength(); nProp++)
586 : {
587 5 : switch(nProp)
588 : {
589 : case SCLAYOUTOPT_MEASURE:
590 1 : pValues[nProp] <<= (sal_Int32) GetAppMetric();
591 1 : break;
592 : case SCLAYOUTOPT_STATUSBAR:
593 1 : pValues[nProp] <<= (sal_Int32) GetStatusFunc();
594 1 : break;
595 : case SCLAYOUTOPT_ZOOMVAL:
596 1 : pValues[nProp] <<= (sal_Int32) GetZoom();
597 1 : break;
598 : case SCLAYOUTOPT_ZOOMTYPE:
599 1 : pValues[nProp] <<= (sal_Int32) GetZoomType();
600 1 : break;
601 : case SCLAYOUTOPT_SYNCZOOM:
602 1 : ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetSynchronizeZoom() );
603 1 : break;
604 : }
605 : }
606 1 : aLayoutItem.PutProperties(aNames, aValues);
607 :
608 2 : return 0;
609 : }
610 :
611 2 : IMPL_LINK_NOARG(ScAppCfg, InputCommitHdl)
612 : {
613 1 : Sequence<OUString> aNames = GetInputPropertyNames();
614 2 : Sequence<Any> aValues(aNames.getLength());
615 1 : Any* pValues = aValues.getArray();
616 :
617 4 : for(int nProp = 0; nProp < aNames.getLength(); nProp++)
618 : {
619 3 : switch(nProp)
620 : {
621 : case SCINPUTOPT_LASTFUNCS:
622 1 : lcl_GetLastFunctions( pValues[nProp], *this );
623 1 : break;
624 : case SCINPUTOPT_AUTOINPUT:
625 1 : ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetAutoComplete() );
626 1 : break;
627 : case SCINPUTOPT_DET_AUTO:
628 1 : ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetDetectiveAuto() );
629 1 : break;
630 : }
631 : }
632 1 : aInputItem.PutProperties(aNames, aValues);
633 :
634 2 : return 0;
635 : }
636 :
637 2 : IMPL_LINK_NOARG(ScAppCfg, RevisionCommitHdl)
638 : {
639 1 : Sequence<OUString> aNames = GetRevisionPropertyNames();
640 2 : Sequence<Any> aValues(aNames.getLength());
641 1 : Any* pValues = aValues.getArray();
642 :
643 5 : for(int nProp = 0; nProp < aNames.getLength(); nProp++)
644 : {
645 4 : switch(nProp)
646 : {
647 : case SCREVISOPT_CHANGE:
648 1 : pValues[nProp] <<= (sal_Int32) GetTrackContentColor();
649 1 : break;
650 : case SCREVISOPT_INSERTION:
651 1 : pValues[nProp] <<= (sal_Int32) GetTrackInsertColor();
652 1 : break;
653 : case SCREVISOPT_DELETION:
654 1 : pValues[nProp] <<= (sal_Int32) GetTrackDeleteColor();
655 1 : break;
656 : case SCREVISOPT_MOVEDENTRY:
657 1 : pValues[nProp] <<= (sal_Int32) GetTrackMoveColor();
658 1 : break;
659 : }
660 : }
661 1 : aRevisionItem.PutProperties(aNames, aValues);
662 :
663 2 : return 0;
664 : }
665 :
666 2 : IMPL_LINK_NOARG(ScAppCfg, ContentCommitHdl)
667 : {
668 1 : Sequence<OUString> aNames = GetContentPropertyNames();
669 2 : Sequence<Any> aValues(aNames.getLength());
670 1 : Any* pValues = aValues.getArray();
671 :
672 2 : for(int nProp = 0; nProp < aNames.getLength(); nProp++)
673 : {
674 1 : switch(nProp)
675 : {
676 : case SCCONTENTOPT_LINK:
677 1 : pValues[nProp] <<= (sal_Int32) GetLinkMode();
678 1 : break;
679 : }
680 : }
681 1 : aContentItem.PutProperties(aNames, aValues);
682 :
683 2 : return 0;
684 : }
685 :
686 2 : IMPL_LINK_NOARG(ScAppCfg, SortListCommitHdl)
687 : {
688 1 : Sequence<OUString> aNames = GetSortListPropertyNames();
689 2 : Sequence<Any> aValues(aNames.getLength());
690 1 : Any* pValues = aValues.getArray();
691 :
692 2 : for(int nProp = 0; nProp < aNames.getLength(); nProp++)
693 : {
694 1 : switch(nProp)
695 : {
696 : case SCSORTLISTOPT_LIST:
697 1 : lcl_GetSortList( pValues[nProp] );
698 1 : break;
699 : }
700 : }
701 1 : aSortListItem.PutProperties(aNames, aValues);
702 :
703 2 : return 0;
704 : }
705 :
706 2 : IMPL_LINK_NOARG(ScAppCfg, MiscCommitHdl)
707 : {
708 1 : Sequence<OUString> aNames = GetMiscPropertyNames();
709 2 : Sequence<Any> aValues(aNames.getLength());
710 1 : Any* pValues = aValues.getArray();
711 :
712 4 : for(int nProp = 0; nProp < aNames.getLength(); nProp++)
713 : {
714 3 : switch(nProp)
715 : {
716 : case SCMISCOPT_DEFOBJWIDTH:
717 1 : pValues[nProp] <<= (sal_Int32) GetDefaultObjectSizeWidth();
718 1 : break;
719 : case SCMISCOPT_DEFOBJHEIGHT:
720 1 : pValues[nProp] <<= (sal_Int32) GetDefaultObjectSizeHeight();
721 1 : break;
722 : case SCMISCOPT_SHOWSHAREDDOCWARN:
723 1 : ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetShowSharedDocumentWarning() );
724 1 : break;
725 : }
726 : }
727 1 : aMiscItem.PutProperties(aNames, aValues);
728 :
729 2 : return 0;
730 : }
731 :
732 2 : IMPL_LINK_NOARG(ScAppCfg, CompatCommitHdl)
733 : {
734 1 : Sequence<OUString> aNames = GetCompatPropertyNames();
735 2 : Sequence<Any> aValues(aNames.getLength());
736 1 : Any* pValues = aValues.getArray();
737 :
738 2 : for (int nProp = 0; nProp < aNames.getLength(); ++nProp)
739 : {
740 1 : switch(nProp)
741 : {
742 : case SCCOMPATOPT_KEY_BINDING:
743 1 : pValues[nProp] <<= static_cast<sal_Int32>(GetKeyBindingType());
744 1 : break;
745 : }
746 : }
747 1 : aCompatItem.PutProperties(aNames, aValues);
748 2 : return 0;
749 : }
750 :
751 20 : void ScAppCfg::SetOptions( const ScAppOptions& rNew )
752 : {
753 20 : *(ScAppOptions*)this = rNew;
754 20 : OptionsChanged();
755 20 : }
756 :
757 20 : void ScAppCfg::OptionsChanged()
758 : {
759 20 : aLayoutItem.SetModified();
760 20 : aInputItem.SetModified();
761 20 : aRevisionItem.SetModified();
762 20 : aContentItem.SetModified();
763 20 : aSortListItem.SetModified();
764 20 : aMiscItem.SetModified();
765 20 : aCompatItem.SetModified();
766 20 : }
767 :
768 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|