1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: inputopt.cxx,v $
10 * $Revision: 1.10.32.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
36 //------------------------------------------------------------------
38 #include <tools/debug.hxx>
40 #include <com/sun/star/uno/Any.hxx>
41 #include <com/sun/star/uno/Sequence.hxx>
44 #include "inputopt.hxx"
45 #include "rechead.hxx"
46 #include "scresid.hxx"
49 #include "miscuno.hxx"
53 using namespace com::sun::star::uno
;
55 //------------------------------------------------------------------
57 // Version, ab der das Item kompatibel ist
58 #define SC_VERSION ((USHORT)351)
61 //========================================================================
62 // ScInputOptions - Eingabe-Optionen
63 //========================================================================
65 ScInputOptions::ScInputOptions()
70 //------------------------------------------------------------------------
72 ScInputOptions::ScInputOptions( const ScInputOptions
& rCpy
)
77 //------------------------------------------------------------------------
79 ScInputOptions::~ScInputOptions()
83 //------------------------------------------------------------------------
85 void ScInputOptions::SetDefaults()
87 nMoveDir
= DIR_BOTTOM
;
88 bMoveSelection
= TRUE
;
90 bExtendFormat
= FALSE
;
96 bReplCellsWarn
= TRUE
;
99 //------------------------------------------------------------------------
101 const ScInputOptions
& ScInputOptions::operator=( const ScInputOptions
& rCpy
)
103 nMoveDir
= rCpy
.nMoveDir
;
104 bMoveSelection
= rCpy
.bMoveSelection
;
105 bEnterEdit
= rCpy
.bEnterEdit
;
106 bExtendFormat
= rCpy
.bExtendFormat
;
107 bRangeFinder
= rCpy
.bRangeFinder
;
108 bExpandRefs
= rCpy
.bExpandRefs
;
109 bMarkHeader
= rCpy
.bMarkHeader
;
110 bUseTabCol
= rCpy
.bUseTabCol
;
111 bTextWysiwyg
= rCpy
.bTextWysiwyg
;
112 bReplCellsWarn
= rCpy
.bReplCellsWarn
;
118 //==================================================================
119 // Config Item containing input options
120 //==================================================================
122 #define CFGPATH_INPUT "Office.Calc/Input"
124 #define SCINPUTOPT_MOVEDIR 0
125 #define SCINPUTOPT_MOVESEL 1
126 #define SCINPUTOPT_EDTEREDIT 2
127 #define SCINPUTOPT_EXTENDFMT 3
128 #define SCINPUTOPT_RANGEFIND 4
129 #define SCINPUTOPT_EXPANDREFS 5
130 #define SCINPUTOPT_MARKHEADER 6
131 #define SCINPUTOPT_USETABCOL 7
132 #define SCINPUTOPT_TEXTWYSIWYG 8
133 #define SCINPUTOPT_REPLCELLSWARN 9
134 #define SCINPUTOPT_COUNT 10
136 Sequence
<OUString
> ScInputCfg::GetPropertyNames()
138 static const char* aPropNames
[] =
140 "MoveSelectionDirection", // SCINPUTOPT_MOVEDIR
141 "MoveSelection", // SCINPUTOPT_MOVESEL
142 "SwitchToEditMode", // SCINPUTOPT_EDTEREDIT
143 "ExpandFormatting", // SCINPUTOPT_EXTENDFMT
144 "ShowReference", // SCINPUTOPT_RANGEFIND
145 "ExpandReference", // SCINPUTOPT_EXPANDREFS
146 "HighlightSelection", // SCINPUTOPT_MARKHEADER
147 "UseTabCol", // SCINPUTOPT_USETABCOL
148 "UsePrinterMetrics", // SCINPUTOPT_TEXTWYSIWYG
149 "ReplaceCellsWarning" // SCINPUTOPT_REPLCELLSWARN
151 Sequence
<OUString
> aNames(SCINPUTOPT_COUNT
);
152 OUString
* pNames
= aNames
.getArray();
153 for(int i
= 0; i
< SCINPUTOPT_COUNT
; i
++)
154 pNames
[i
] = OUString::createFromAscii(aPropNames
[i
]);
159 ScInputCfg::ScInputCfg() :
160 ConfigItem( OUString::createFromAscii( CFGPATH_INPUT
) )
162 sal_Int32 nIntVal
= 0;
164 Sequence
<OUString
> aNames
= GetPropertyNames();
165 Sequence
<Any
> aValues
= GetProperties(aNames
);
166 EnableNotification(aNames
);
167 const Any
* pValues
= aValues
.getConstArray();
168 DBG_ASSERT(aValues
.getLength() == aNames
.getLength(), "GetProperties failed");
169 if(aValues
.getLength() == aNames
.getLength())
171 for(int nProp
= 0; nProp
< aNames
.getLength(); nProp
++)
173 DBG_ASSERT(pValues
[nProp
].hasValue(), "property value missing");
174 if(pValues
[nProp
].hasValue())
178 case SCINPUTOPT_MOVEDIR
:
179 if ( pValues
[nProp
] >>= nIntVal
)
180 SetMoveDir( (USHORT
)nIntVal
);
182 case SCINPUTOPT_MOVESEL
:
183 SetMoveSelection( ScUnoHelpFunctions::GetBoolFromAny( pValues
[nProp
] ) );
185 case SCINPUTOPT_EDTEREDIT
:
186 SetEnterEdit( ScUnoHelpFunctions::GetBoolFromAny( pValues
[nProp
] ) );
188 case SCINPUTOPT_EXTENDFMT
:
189 SetExtendFormat( ScUnoHelpFunctions::GetBoolFromAny( pValues
[nProp
] ) );
191 case SCINPUTOPT_RANGEFIND
:
192 SetRangeFinder( ScUnoHelpFunctions::GetBoolFromAny( pValues
[nProp
] ) );
194 case SCINPUTOPT_EXPANDREFS
:
195 SetExpandRefs( ScUnoHelpFunctions::GetBoolFromAny( pValues
[nProp
] ) );
197 case SCINPUTOPT_MARKHEADER
:
198 SetMarkHeader( ScUnoHelpFunctions::GetBoolFromAny( pValues
[nProp
] ) );
200 case SCINPUTOPT_USETABCOL
:
201 SetUseTabCol( ScUnoHelpFunctions::GetBoolFromAny( pValues
[nProp
] ) );
203 case SCINPUTOPT_TEXTWYSIWYG
:
204 SetTextWysiwyg( ScUnoHelpFunctions::GetBoolFromAny( pValues
[nProp
] ) );
206 case SCINPUTOPT_REPLCELLSWARN
:
207 SetReplaceCellsWarn( ScUnoHelpFunctions::GetBoolFromAny( pValues
[nProp
] ) );
216 void ScInputCfg::Commit()
218 Sequence
<OUString
> aNames
= GetPropertyNames();
219 Sequence
<Any
> aValues(aNames
.getLength());
220 Any
* pValues
= aValues
.getArray();
222 for(int nProp
= 0; nProp
< aNames
.getLength(); nProp
++)
226 case SCINPUTOPT_MOVEDIR
:
227 pValues
[nProp
] <<= (sal_Int32
) GetMoveDir();
229 case SCINPUTOPT_MOVESEL
:
230 ScUnoHelpFunctions::SetBoolInAny( pValues
[nProp
], GetMoveSelection() );
232 case SCINPUTOPT_EDTEREDIT
:
233 ScUnoHelpFunctions::SetBoolInAny( pValues
[nProp
], GetEnterEdit() );
235 case SCINPUTOPT_EXTENDFMT
:
236 ScUnoHelpFunctions::SetBoolInAny( pValues
[nProp
], GetExtendFormat() );
238 case SCINPUTOPT_RANGEFIND
:
239 ScUnoHelpFunctions::SetBoolInAny( pValues
[nProp
], GetRangeFinder() );
241 case SCINPUTOPT_EXPANDREFS
:
242 ScUnoHelpFunctions::SetBoolInAny( pValues
[nProp
], GetExpandRefs() );
244 case SCINPUTOPT_MARKHEADER
:
245 ScUnoHelpFunctions::SetBoolInAny( pValues
[nProp
], GetMarkHeader() );
247 case SCINPUTOPT_USETABCOL
:
248 ScUnoHelpFunctions::SetBoolInAny( pValues
[nProp
], GetUseTabCol() );
250 case SCINPUTOPT_TEXTWYSIWYG
:
251 ScUnoHelpFunctions::SetBoolInAny( pValues
[nProp
], GetTextWysiwyg() );
253 case SCINPUTOPT_REPLCELLSWARN
:
254 ScUnoHelpFunctions::SetBoolInAny( pValues
[nProp
], GetReplaceCellsWarn() );
258 PutProperties(aNames
, aValues
);
261 void ScInputCfg::Notify( const Sequence
<rtl::OUString
>& /* aPropertyNames */ )
263 DBG_ERROR("properties have been changed");
266 void ScInputCfg::SetOptions( const ScInputOptions
& rNew
)
268 *(ScInputOptions
*)this = rNew
;
272 void ScInputCfg::OptionsChanged()