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 <com/sun/star/uno/Any.hxx>
30 : : #include <com/sun/star/uno/Sequence.hxx>
31 : :
32 : : #include "cfgids.hxx"
33 : : #include "inputopt.hxx"
34 : : #include "rechead.hxx"
35 : : #include "scresid.hxx"
36 : : #include "global.hxx"
37 : : #include "sc.hrc"
38 : : #include "miscuno.hxx"
39 : :
40 : : using namespace utl;
41 : : using namespace com::sun::star::uno;
42 : :
43 : : using ::rtl::OUString;
44 : :
45 : : //------------------------------------------------------------------
46 : :
47 : : // Version, ab der das Item kompatibel ist
48 : : #define SC_VERSION ((sal_uInt16)351)
49 : :
50 : :
51 : : //========================================================================
52 : : // ScInputOptions - Eingabe-Optionen
53 : : //========================================================================
54 : :
55 : 51 : ScInputOptions::ScInputOptions()
56 : : {
57 : 51 : SetDefaults();
58 : 51 : }
59 : :
60 : : //------------------------------------------------------------------------
61 : :
62 : 202 : ScInputOptions::ScInputOptions( const ScInputOptions& rCpy )
63 : : {
64 : 202 : *this = rCpy;
65 : 202 : }
66 : :
67 : : //------------------------------------------------------------------------
68 : :
69 : 220 : ScInputOptions::~ScInputOptions()
70 : : {
71 : 220 : }
72 : :
73 : : //------------------------------------------------------------------------
74 : :
75 : 51 : void ScInputOptions::SetDefaults()
76 : : {
77 : 51 : nMoveDir = DIR_BOTTOM;
78 : 51 : bMoveSelection = sal_True;
79 : 51 : bEnterEdit = false;
80 : 51 : bExtendFormat = false;
81 : 51 : bRangeFinder = sal_True;
82 : 51 : bExpandRefs = false;
83 : 51 : bMarkHeader = sal_True;
84 : 51 : bUseTabCol = false;
85 : 51 : bTextWysiwyg = false;
86 : 51 : bReplCellsWarn = sal_True;
87 : 51 : }
88 : :
89 : : //------------------------------------------------------------------------
90 : :
91 : 232 : const ScInputOptions& ScInputOptions::operator=( const ScInputOptions& rCpy )
92 : : {
93 : 232 : nMoveDir = rCpy.nMoveDir;
94 : 232 : bMoveSelection = rCpy.bMoveSelection;
95 : 232 : bEnterEdit = rCpy.bEnterEdit;
96 : 232 : bExtendFormat = rCpy.bExtendFormat;
97 : 232 : bRangeFinder = rCpy.bRangeFinder;
98 : 232 : bExpandRefs = rCpy.bExpandRefs;
99 : 232 : bMarkHeader = rCpy.bMarkHeader;
100 : 232 : bUseTabCol = rCpy.bUseTabCol;
101 : 232 : bTextWysiwyg = rCpy.bTextWysiwyg;
102 : 232 : bReplCellsWarn = rCpy.bReplCellsWarn;
103 : :
104 : 232 : return *this;
105 : : }
106 : :
107 : :
108 : : //==================================================================
109 : : // Config Item containing input options
110 : : //==================================================================
111 : :
112 : : #define CFGPATH_INPUT "Office.Calc/Input"
113 : :
114 : : #define SCINPUTOPT_MOVEDIR 0
115 : : #define SCINPUTOPT_MOVESEL 1
116 : : #define SCINPUTOPT_EDTEREDIT 2
117 : : #define SCINPUTOPT_EXTENDFMT 3
118 : : #define SCINPUTOPT_RANGEFIND 4
119 : : #define SCINPUTOPT_EXPANDREFS 5
120 : : #define SCINPUTOPT_MARKHEADER 6
121 : : #define SCINPUTOPT_USETABCOL 7
122 : : #define SCINPUTOPT_TEXTWYSIWYG 8
123 : : #define SCINPUTOPT_REPLCELLSWARN 9
124 : : #define SCINPUTOPT_COUNT 10
125 : :
126 : 52 : Sequence<OUString> ScInputCfg::GetPropertyNames()
127 : : {
128 : : static const char* aPropNames[] =
129 : : {
130 : : "MoveSelectionDirection", // SCINPUTOPT_MOVEDIR
131 : : "MoveSelection", // SCINPUTOPT_MOVESEL
132 : : "SwitchToEditMode", // SCINPUTOPT_EDTEREDIT
133 : : "ExpandFormatting", // SCINPUTOPT_EXTENDFMT
134 : : "ShowReference", // SCINPUTOPT_RANGEFIND
135 : : "ExpandReference", // SCINPUTOPT_EXPANDREFS
136 : : "HighlightSelection", // SCINPUTOPT_MARKHEADER
137 : : "UseTabCol", // SCINPUTOPT_USETABCOL
138 : : "UsePrinterMetrics", // SCINPUTOPT_TEXTWYSIWYG
139 : : "ReplaceCellsWarning" // SCINPUTOPT_REPLCELLSWARN
140 : : };
141 : 52 : Sequence<OUString> aNames(SCINPUTOPT_COUNT);
142 [ + - ]: 52 : OUString* pNames = aNames.getArray();
143 [ + + ]: 572 : for(int i = 0; i < SCINPUTOPT_COUNT; i++)
144 : 520 : pNames[i] = OUString::createFromAscii(aPropNames[i]);
145 : :
146 : 52 : return aNames;
147 : : }
148 : :
149 : 51 : ScInputCfg::ScInputCfg() :
150 [ + - ][ + - ]: 51 : ConfigItem( OUString(RTL_CONSTASCII_USTRINGPARAM( CFGPATH_INPUT )) )
151 : : {
152 [ + - ]: 51 : Sequence<OUString> aNames = GetPropertyNames();
153 [ + - ]: 51 : Sequence<Any> aValues = GetProperties(aNames);
154 [ + - ]: 51 : EnableNotification(aNames);
155 : 51 : const Any* pValues = aValues.getConstArray();
156 : : OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
157 [ + - ]: 51 : if(aValues.getLength() == aNames.getLength())
158 : : {
159 [ + + ]: 561 : for(int nProp = 0; nProp < aNames.getLength(); nProp++)
160 : : {
161 : : OSL_ENSURE(pValues[nProp].hasValue(), "property value missing");
162 [ + - ]: 510 : if(pValues[nProp].hasValue())
163 : : {
164 : 510 : sal_Int32 nIntVal = 0;
165 [ + + + + : 510 : switch(nProp)
+ + + + +
+ - ]
166 : : {
167 : : case SCINPUTOPT_MOVEDIR:
168 [ + - ]: 51 : if ( pValues[nProp] >>= nIntVal )
169 : 51 : SetMoveDir( (sal_uInt16)nIntVal );
170 : 51 : break;
171 : : case SCINPUTOPT_MOVESEL:
172 [ + - ]: 51 : SetMoveSelection( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
173 : 51 : break;
174 : : case SCINPUTOPT_EDTEREDIT:
175 [ + - ]: 51 : SetEnterEdit( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
176 : 51 : break;
177 : : case SCINPUTOPT_EXTENDFMT:
178 [ + - ]: 51 : SetExtendFormat( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
179 : 51 : break;
180 : : case SCINPUTOPT_RANGEFIND:
181 [ + - ]: 51 : SetRangeFinder( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
182 : 51 : break;
183 : : case SCINPUTOPT_EXPANDREFS:
184 [ + - ]: 51 : SetExpandRefs( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
185 : 51 : break;
186 : : case SCINPUTOPT_MARKHEADER:
187 [ + - ]: 51 : SetMarkHeader( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
188 : 51 : break;
189 : : case SCINPUTOPT_USETABCOL:
190 [ + - ]: 51 : SetUseTabCol( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
191 : 51 : break;
192 : : case SCINPUTOPT_TEXTWYSIWYG:
193 [ + - ]: 51 : SetTextWysiwyg( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
194 : 51 : break;
195 : : case SCINPUTOPT_REPLCELLSWARN:
196 [ + - ]: 51 : SetReplaceCellsWarn( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
197 : 510 : break;
198 : : }
199 : : }
200 : : }
201 [ + - ][ + - ]: 51 : }
202 : 51 : }
203 : :
204 : :
205 : 1 : void ScInputCfg::Commit()
206 : : {
207 [ + - ]: 1 : Sequence<OUString> aNames = GetPropertyNames();
208 [ + - ]: 1 : Sequence<Any> aValues(aNames.getLength());
209 [ + - ]: 1 : Any* pValues = aValues.getArray();
210 : :
211 [ + + ]: 11 : for(int nProp = 0; nProp < aNames.getLength(); nProp++)
212 : : {
213 [ + + + + : 10 : switch(nProp)
+ + + + +
+ - ]
214 : : {
215 : : case SCINPUTOPT_MOVEDIR:
216 [ + - ]: 1 : pValues[nProp] <<= (sal_Int32) GetMoveDir();
217 : 1 : break;
218 : : case SCINPUTOPT_MOVESEL:
219 [ + - ]: 1 : ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetMoveSelection() );
220 : 1 : break;
221 : : case SCINPUTOPT_EDTEREDIT:
222 [ + - ]: 1 : ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetEnterEdit() );
223 : 1 : break;
224 : : case SCINPUTOPT_EXTENDFMT:
225 [ + - ]: 1 : ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetExtendFormat() );
226 : 1 : break;
227 : : case SCINPUTOPT_RANGEFIND:
228 [ + - ]: 1 : ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetRangeFinder() );
229 : 1 : break;
230 : : case SCINPUTOPT_EXPANDREFS:
231 [ + - ]: 1 : ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetExpandRefs() );
232 : 1 : break;
233 : : case SCINPUTOPT_MARKHEADER:
234 [ + - ]: 1 : ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetMarkHeader() );
235 : 1 : break;
236 : : case SCINPUTOPT_USETABCOL:
237 [ + - ]: 1 : ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetUseTabCol() );
238 : 1 : break;
239 : : case SCINPUTOPT_TEXTWYSIWYG:
240 [ + - ]: 1 : ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetTextWysiwyg() );
241 : 1 : break;
242 : : case SCINPUTOPT_REPLCELLSWARN:
243 [ + - ]: 1 : ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetReplaceCellsWarn() );
244 : 1 : break;
245 : : }
246 : : }
247 [ + - ][ + - ]: 1 : PutProperties(aNames, aValues);
[ + - ]
248 : 1 : }
249 : :
250 : 0 : void ScInputCfg::Notify( const Sequence<OUString>& /* aPropertyNames */ )
251 : : {
252 : : OSL_FAIL("properties have been changed");
253 : 0 : }
254 : :
255 : 30 : void ScInputCfg::SetOptions( const ScInputOptions& rNew )
256 : : {
257 : 30 : *(ScInputOptions*)this = rNew;
258 : 30 : SetModified();
259 : 30 : }
260 : :
261 : 0 : void ScInputCfg::OptionsChanged()
262 : : {
263 : 0 : SetModified();
264 : 0 : }
265 : :
266 : :
267 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|