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