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 <rechead.hxx>
26 #include <global.hxx>
27 #include <sc.hrc>
28 #include <miscuno.hxx>
29 
30 using namespace utl;
31 using namespace com::sun::star::uno;
32 
33 // ScInputOptions - input options
34 
36 {
37  SetDefaults();
38 }
39 
41 {
42  nMoveDir = DIR_BOTTOM;
43  bMoveSelection = true;
44  bEnterEdit = false;
45  bExtendFormat = false;
46  bRangeFinder = true;
47  bExpandRefs = false;
48  mbSortRefUpdate = true;
49  bMarkHeader = true;
50  bUseTabCol = false;
51  bTextWysiwyg = false;
52  bReplCellsWarn = true;
53  bLegacyCellSelection = false;
54 }
55 
56 // Config Item containing input options
57 
58 #define CFGPATH_INPUT "Office.Calc/Input"
59 
60 #define SCINPUTOPT_MOVEDIR 0
61 #define SCINPUTOPT_MOVESEL 1
62 #define SCINPUTOPT_EDTEREDIT 2
63 #define SCINPUTOPT_EXTENDFMT 3
64 #define SCINPUTOPT_RANGEFIND 4
65 #define SCINPUTOPT_EXPANDREFS 5
66 #define SCINPUTOPT_SORT_REF_UPDATE 6
67 #define SCINPUTOPT_MARKHEADER 7
68 #define SCINPUTOPT_USETABCOL 8
69 #define SCINPUTOPT_TEXTWYSIWYG 9
70 #define SCINPUTOPT_REPLCELLSWARN 10
71 #define SCINPUTOPT_LEGACY_CELL_SELECTION 11
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 }
88 
91 {
93  Sequence<Any> aValues = GetProperties(aNames);
94  EnableNotification(aNames);
95  const Any* pValues = aValues.getConstArray();
96  OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
97  if(aValues.getLength() != aNames.getLength())
98  return;
99 
100  for(int nProp = 0; nProp < aNames.getLength(); nProp++)
101  {
102  OSL_ENSURE(pValues[nProp].hasValue(), "property value missing");
103  if(pValues[nProp].hasValue())
104  {
105  sal_Int32 nIntVal = 0;
106  switch(nProp)
107  {
108  case SCINPUTOPT_MOVEDIR:
109  if ( pValues[nProp] >>= nIntVal )
110  SetMoveDir( static_cast<sal_uInt16>(nIntVal) );
111  break;
112  case SCINPUTOPT_MOVESEL:
114  break;
117  break;
120  break;
123  break;
126  break;
129  break;
132  break;
135  break;
138  break;
141  break;
144  break;
145  }
146  }
147  }
148 }
149 
151 {
153  Sequence<Any> aValues(aNames.getLength());
154  Any* pValues = aValues.getArray();
155 
156  for(int nProp = 0; nProp < aNames.getLength(); nProp++)
157  {
158  switch(nProp)
159  {
160  case SCINPUTOPT_MOVEDIR:
161  pValues[nProp] <<= static_cast<sal_Int32>(GetMoveDir());
162  break;
163  case SCINPUTOPT_MOVESEL:
164  pValues[nProp] <<= GetMoveSelection();
165  break;
167  pValues[nProp] <<= GetEnterEdit();
168  break;
170  pValues[nProp] <<= GetExtendFormat();
171  break;
173  pValues[nProp] <<= GetRangeFinder();
174  break;
176  pValues[nProp] <<= GetExpandRefs();
177  break;
179  pValues[nProp] <<= GetSortRefUpdate();
180  break;
182  pValues[nProp] <<= GetMarkHeader();
183  break;
185  pValues[nProp] <<= GetUseTabCol();
186  break;
188  pValues[nProp] <<= GetTextWysiwyg();
189  break;
191  pValues[nProp] <<= GetReplaceCellsWarn();
192  break;
194  pValues[nProp] <<= GetLegacyCellSelection();
195  break;
196  }
197  }
198  PutProperties(aNames, aValues);
199 }
200 
201 void ScInputCfg::Notify( const Sequence<OUString>& /* aPropertyNames */ )
202 {
203  OSL_FAIL("properties have been changed");
204 }
205 
207 {
208  *static_cast<ScInputOptions*>(this) = rNew;
209  SetModified();
210 }
211 
213 {
214  SetModified();
215 }
216 
217 /* 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:67
static css::uno::Sequence< OUString > GetPropertyNames()
Definition: inputopt.cxx:73
#define SCINPUTOPT_EXTENDFMT
Definition: inputopt.cxx:63
virtual void ImplCommit() override
Definition: inputopt.cxx:150
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:61
#define SCINPUTOPT_LEGACY_CELL_SELECTION
Definition: inputopt.cxx:71
bool GetMarkHeader() const
Definition: inputopt.hxx:62
void SetDefaults()
Definition: inputopt.cxx:40
#define SCINPUTOPT_TEXTWYSIWYG
Definition: inputopt.cxx:69
bool EnableNotification(const css::uno::Sequence< OUString > &rNames, bool bEnableInternalNotification=false)
bool GetTextWysiwyg() const
Definition: inputopt.hxx:66
#define SCINPUTOPT_EXPANDREFS
Definition: inputopt.cxx:65
#define SCINPUTOPT_SORT_REF_UPDATE
Definition: inputopt.cxx:66
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:64
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:62
const PropertyValue * pValues
#define CFGPATH_INPUT
Definition: inputopt.cxx:58
void SetMoveDir(sal_uInt16 nNew)
Definition: inputopt.hxx:47
#define SCINPUTOPT_REPLCELLSWARN
Definition: inputopt.cxx:70
#define SCINPUTOPT_USETABCOL
Definition: inputopt.cxx:68
void SetExtendFormat(bool bSet)
Definition: inputopt.hxx:53
void OptionsChanged()
Definition: inputopt.cxx:212
sal_uInt16 GetMoveDir() const
Definition: inputopt.hxx:48
void SetUseTabCol(bool bSet)
Definition: inputopt.hxx:63
#define SCINPUTOPT_MOVEDIR
Definition: inputopt.cxx:60
void SetOptions(const ScInputOptions &rNew)
Definition: inputopt.cxx:206
bool GetRangeFinder() const
Definition: inputopt.hxx:56
virtual void Notify(const css::uno::Sequence< OUString > &aPropertyNames) override
Definition: inputopt.cxx:201
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