LibreOffice Module sc (master)  1
inputopt.cxx
Go to the documentation of this file.
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 <com/sun/star/uno/Any.hxx>
21 #include <com/sun/star/uno/Sequence.hxx>
22 #include <osl/diagnose.h>
23 
24 #include <inputopt.hxx>
25 #include <global.hxx>
26 #include <miscuno.hxx>
27 
28 using namespace utl;
29 using namespace com::sun::star::uno;
30 
31 // ScInputOptions - input options
32 
34 {
35  SetDefaults();
36 }
37 
39 {
40  nMoveDir = DIR_BOTTOM;
41  bMoveSelection = true;
42  bEnterEdit = false;
43  bExtendFormat = false;
44  bRangeFinder = true;
45  bExpandRefs = false;
46  mbSortRefUpdate = true;
47  bMarkHeader = true;
48  bUseTabCol = false;
49  bTextWysiwyg = false;
50  bReplCellsWarn = true;
51  bLegacyCellSelection = false;
52  bEnterPasteMode = false;
53 }
54 
55 // Config Item containing input options
56 
57 #define CFGPATH_INPUT "Office.Calc/Input"
58 
59 #define SCINPUTOPT_MOVEDIR 0
60 #define SCINPUTOPT_MOVESEL 1
61 #define SCINPUTOPT_EDTEREDIT 2
62 #define SCINPUTOPT_EXTENDFMT 3
63 #define SCINPUTOPT_RANGEFIND 4
64 #define SCINPUTOPT_EXPANDREFS 5
65 #define SCINPUTOPT_SORT_REF_UPDATE 6
66 #define SCINPUTOPT_MARKHEADER 7
67 #define SCINPUTOPT_USETABCOL 8
68 #define SCINPUTOPT_TEXTWYSIWYG 9
69 #define SCINPUTOPT_REPLCELLSWARN 10
70 #define SCINPUTOPT_LEGACY_CELL_SELECTION 11
71 #define SCINPUTOPT_ENTER_PASTE_MODE 12
72 
74 {
75  return {"MoveSelectionDirection", // SCINPUTOPT_MOVEDIR
76  "MoveSelection", // SCINPUTOPT_MOVESEL
77  "SwitchToEditMode", // SCINPUTOPT_EDTEREDIT
78  "ExpandFormatting", // SCINPUTOPT_EXTENDFMT
79  "ShowReference", // SCINPUTOPT_RANGEFIND
80  "ExpandReference", // SCINPUTOPT_EXPANDREFS
81  "UpdateReferenceOnSort", // SCINPUTOPT_SORT_REF_UPDATE
82  "HighlightSelection", // SCINPUTOPT_MARKHEADER
83  "UseTabCol", // SCINPUTOPT_USETABCOL
84  "UsePrinterMetrics", // SCINPUTOPT_TEXTWYSIWYG
85  "ReplaceCellsWarning", // SCINPUTOPT_REPLCELLSWARN
86  "LegacyCellSelection", // SCINPUTOPT_LEGACY_CELL_SELECTION
87  "EnterPasteMode"}; // SCINPUTOPT_ENTER_PASTE_MODE
88 }
89 
92 {
94  Sequence<Any> aValues = GetProperties(aNames);
95  EnableNotification(aNames);
96  const Any* pValues = aValues.getConstArray();
97  OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
98  if(aValues.getLength() != aNames.getLength())
99  return;
100 
101  for(int nProp = 0; nProp < aNames.getLength(); nProp++)
102  {
103  OSL_ENSURE(pValues[nProp].hasValue(), "property value missing");
104  if(pValues[nProp].hasValue())
105  {
106  sal_Int32 nIntVal = 0;
107  switch(nProp)
108  {
109  case SCINPUTOPT_MOVEDIR:
110  if ( pValues[nProp] >>= nIntVal )
111  SetMoveDir( static_cast<sal_uInt16>(nIntVal) );
112  break;
113  case SCINPUTOPT_MOVESEL:
115  break;
118  break;
121  break;
124  break;
127  break;
130  break;
133  break;
136  break;
139  break;
142  break;
145  break;
148  break;
149  }
150  }
151  }
152 }
153 
155 {
157  Sequence<Any> aValues(aNames.getLength());
158  Any* pValues = aValues.getArray();
159 
160  for(int nProp = 0; nProp < aNames.getLength(); nProp++)
161  {
162  switch(nProp)
163  {
164  case SCINPUTOPT_MOVEDIR:
165  pValues[nProp] <<= static_cast<sal_Int32>(GetMoveDir());
166  break;
167  case SCINPUTOPT_MOVESEL:
168  pValues[nProp] <<= GetMoveSelection();
169  break;
171  pValues[nProp] <<= GetEnterEdit();
172  break;
174  pValues[nProp] <<= GetExtendFormat();
175  break;
177  pValues[nProp] <<= GetRangeFinder();
178  break;
180  pValues[nProp] <<= GetExpandRefs();
181  break;
183  pValues[nProp] <<= GetSortRefUpdate();
184  break;
186  pValues[nProp] <<= GetMarkHeader();
187  break;
189  pValues[nProp] <<= GetUseTabCol();
190  break;
192  pValues[nProp] <<= GetTextWysiwyg();
193  break;
195  pValues[nProp] <<= GetReplaceCellsWarn();
196  break;
198  pValues[nProp] <<= GetLegacyCellSelection();
199  break;
201  pValues[nProp] <<= GetEnterPasteMode();
202  break;
203  }
204  }
205  PutProperties(aNames, aValues);
206 }
207 
208 void ScInputCfg::Notify( const Sequence<OUString>& /* aPropertyNames */ )
209 {
210  OSL_FAIL("properties have been changed");
211 }
212 
214 {
215  *static_cast<ScInputOptions*>(this) = rNew;
216  SetModified();
217 }
218 
220 {
221  SetModified();
222 }
223 
224 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool GetMoveSelection() const
Definition: inputopt.hxx:50
void SetRangeFinder(bool bSet)
Definition: inputopt.hxx:55
#define SCINPUTOPT_MARKHEADER
Definition: inputopt.cxx:66
static css::uno::Sequence< OUString > GetPropertyNames()
Definition: inputopt.cxx:73
#define SCINPUTOPT_EXTENDFMT
Definition: inputopt.cxx:62
virtual void ImplCommit() override
Definition: inputopt.cxx:154
void SetEnterPasteMode(bool bSet)
Definition: inputopt.hxx:71
void SetSortRefUpdate(bool bSet)
Definition: inputopt.hxx:59
bool GetSortRefUpdate() const
Definition: inputopt.hxx:60
void SetEnterEdit(bool bSet)
Definition: inputopt.hxx:51
#define SCINPUTOPT_MOVESEL
Definition: inputopt.cxx:60
#define SCINPUTOPT_ENTER_PASTE_MODE
Definition: inputopt.cxx:71
#define SCINPUTOPT_LEGACY_CELL_SELECTION
Definition: inputopt.cxx:70
bool GetMarkHeader() const
Definition: inputopt.hxx:62
void SetDefaults()
Definition: inputopt.cxx:38
#define SCINPUTOPT_TEXTWYSIWYG
Definition: inputopt.cxx:68
bool EnableNotification(const css::uno::Sequence< OUString > &rNames, bool bEnableInternalNotification=false)
bool GetTextWysiwyg() const
Definition: inputopt.hxx:66
#define SCINPUTOPT_EXPANDREFS
Definition: inputopt.cxx:64
#define SCINPUTOPT_SORT_REF_UPDATE
Definition: inputopt.cxx:65
void SetLegacyCellSelection(bool bSet)
Definition: inputopt.hxx:69
bool GetUseTabCol() const
Definition: inputopt.hxx:64
bool GetReplaceCellsWarn() const
Definition: inputopt.hxx:68
bool GetEnterEdit() const
Definition: inputopt.hxx:52
bool PutProperties(const css::uno::Sequence< OUString > &rNames, const css::uno::Sequence< css::uno::Any > &rValues)
bool GetLegacyCellSelection() const
Definition: inputopt.hxx:70
void SetTextWysiwyg(bool bSet)
Definition: inputopt.hxx:65
css::uno::Sequence< css::uno::Any > GetProperties(const css::uno::Sequence< OUString > &rNames)
#define SCINPUTOPT_RANGEFIND
Definition: inputopt.cxx:63
void SetExpandRefs(bool bSet)
Definition: inputopt.hxx:57
bool GetExtendFormat() const
Definition: inputopt.hxx:54
bool GetExpandRefs() const
Definition: inputopt.hxx:58
#define SCINPUTOPT_EDTEREDIT
Definition: inputopt.cxx:61
const PropertyValue * pValues
#define CFGPATH_INPUT
Definition: inputopt.cxx:57
void SetMoveDir(sal_uInt16 nNew)
Definition: inputopt.hxx:47
#define SCINPUTOPT_REPLCELLSWARN
Definition: inputopt.cxx:69
bool GetEnterPasteMode() const
Definition: inputopt.hxx:72
#define SCINPUTOPT_USETABCOL
Definition: inputopt.cxx:67
void SetExtendFormat(bool bSet)
Definition: inputopt.hxx:53
void OptionsChanged()
Definition: inputopt.cxx:219
sal_uInt16 GetMoveDir() const
Definition: inputopt.hxx:48
void SetUseTabCol(bool bSet)
Definition: inputopt.hxx:63
#define SCINPUTOPT_MOVEDIR
Definition: inputopt.cxx:59
void SetOptions(const ScInputOptions &rNew)
Definition: inputopt.cxx:213
bool GetRangeFinder() const
Definition: inputopt.hxx:56
virtual void Notify(const css::uno::Sequence< OUString > &aPropertyNames) override
Definition: inputopt.cxx:208
static bool GetBoolFromAny(const css::uno::Any &aAny)
Definition: miscuno.cxx:138
void SetReplaceCellsWarn(bool bSet)
Definition: inputopt.hxx:67
void SetMoveSelection(bool bSet)
Definition: inputopt.hxx:49
void SetMarkHeader(bool bSet)
Definition: inputopt.hxx:61