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 
27 using namespace utl;
28 using namespace com::sun::star::uno;
29 
30 // ScInputOptions - input options
31 
33  : nMoveDir(DIR_BOTTOM)
34  , bMoveSelection(true)
35  , bEnterEdit(false)
36  , bExtendFormat(false)
37  , bRangeFinder(true)
38  , bExpandRefs(false)
39  , mbSortRefUpdate(true)
40  , bMarkHeader(true)
41  , bUseTabCol(false)
42  , bTextWysiwyg(false)
43  , bReplCellsWarn(true)
44  , bLegacyCellSelection(false)
45  , bEnterPasteMode(false)
46 {
47 }
48 
49 // Config Item containing input options
50 
51 constexpr OUStringLiteral CFGPATH_INPUT = u"Office.Calc/Input";
52 
53 #define SCINPUTOPT_MOVEDIR 0
54 #define SCINPUTOPT_MOVESEL 1
55 #define SCINPUTOPT_EDTEREDIT 2
56 #define SCINPUTOPT_EXTENDFMT 3
57 #define SCINPUTOPT_RANGEFIND 4
58 #define SCINPUTOPT_EXPANDREFS 5
59 #define SCINPUTOPT_SORT_REF_UPDATE 6
60 #define SCINPUTOPT_MARKHEADER 7
61 #define SCINPUTOPT_USETABCOL 8
62 #define SCINPUTOPT_TEXTWYSIWYG 9
63 #define SCINPUTOPT_REPLCELLSWARN 10
64 #define SCINPUTOPT_LEGACY_CELL_SELECTION 11
65 #define SCINPUTOPT_ENTER_PASTE_MODE 12
66 
68 {
69  return {"MoveSelectionDirection", // SCINPUTOPT_MOVEDIR
70  "MoveSelection", // SCINPUTOPT_MOVESEL
71  "SwitchToEditMode", // SCINPUTOPT_EDTEREDIT
72  "ExpandFormatting", // SCINPUTOPT_EXTENDFMT
73  "ShowReference", // SCINPUTOPT_RANGEFIND
74  "ExpandReference", // SCINPUTOPT_EXPANDREFS
75  "UpdateReferenceOnSort", // SCINPUTOPT_SORT_REF_UPDATE
76  "HighlightSelection", // SCINPUTOPT_MARKHEADER
77  "UseTabCol", // SCINPUTOPT_USETABCOL
78  "UsePrinterMetrics", // SCINPUTOPT_TEXTWYSIWYG
79  "ReplaceCellsWarning", // SCINPUTOPT_REPLCELLSWARN
80  "LegacyCellSelection", // SCINPUTOPT_LEGACY_CELL_SELECTION
81  "EnterPasteMode"}; // SCINPUTOPT_ENTER_PASTE_MODE
82 }
83 
86 {
88  EnableNotification(aNames);
89  ReadCfg();
90 }
91 
93 {
94  const Sequence<OUString> aNames = GetPropertyNames();
95  const Sequence<Any> aValues = GetProperties(aNames);
96  OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
97  if(aValues.getLength() != aNames.getLength())
98  return;
99 
100  if (sal_Int32 nVal; aValues[SCINPUTOPT_MOVEDIR] >>= nVal)
101  SetMoveDir(static_cast<sal_uInt16>(nVal));
102  if (bool bVal; aValues[SCINPUTOPT_MOVESEL] >>= bVal)
103  SetMoveSelection(bVal);
104  if (bool bVal; aValues[SCINPUTOPT_EDTEREDIT] >>= bVal)
105  SetEnterEdit(bVal);
106  if (bool bVal; aValues[SCINPUTOPT_EXTENDFMT] >>= bVal)
107  SetExtendFormat(bVal);
108  if (bool bVal; aValues[SCINPUTOPT_RANGEFIND] >>= bVal)
109  SetRangeFinder(bVal);
110  if (bool bVal; aValues[SCINPUTOPT_EXPANDREFS] >>= bVal)
111  SetExpandRefs(bVal);
112  if (bool bVal; aValues[SCINPUTOPT_SORT_REF_UPDATE] >>= bVal)
113  SetSortRefUpdate(bVal);
114  if (bool bVal; aValues[SCINPUTOPT_MARKHEADER] >>= bVal)
115  SetMarkHeader(bVal);
116  if (bool bVal; aValues[SCINPUTOPT_USETABCOL] >>= bVal)
117  SetUseTabCol(bVal);
118  if (bool bVal; aValues[SCINPUTOPT_TEXTWYSIWYG] >>= bVal)
119  SetTextWysiwyg(bVal);
120  if (bool bVal; aValues[SCINPUTOPT_REPLCELLSWARN] >>= bVal)
121  SetReplaceCellsWarn(bVal);
122  if (bool bVal; aValues[SCINPUTOPT_LEGACY_CELL_SELECTION] >>= bVal)
124  if (bool bVal; aValues[SCINPUTOPT_ENTER_PASTE_MODE] >>= bVal)
125  SetEnterPasteMode(bVal);
126 }
127 
129 {
131  Sequence<Any> aValues(aNames.getLength());
132  Any* pValues = aValues.getArray();
133 
134  pValues[SCINPUTOPT_MOVEDIR] <<= static_cast<sal_Int32>(GetMoveDir());
135  pValues[SCINPUTOPT_MOVESEL] <<= GetMoveSelection();
136  pValues[SCINPUTOPT_EDTEREDIT] <<= GetEnterEdit();
137  pValues[SCINPUTOPT_EXTENDFMT] <<= GetExtendFormat();
138  pValues[SCINPUTOPT_RANGEFIND] <<= GetRangeFinder();
139  pValues[SCINPUTOPT_EXPANDREFS] <<= GetExpandRefs();
141  pValues[SCINPUTOPT_MARKHEADER] <<= GetMarkHeader();
142  pValues[SCINPUTOPT_USETABCOL] <<= GetUseTabCol();
143  pValues[SCINPUTOPT_TEXTWYSIWYG] <<= GetTextWysiwyg();
147  PutProperties(aNames, aValues);
148 }
149 
150 void ScInputCfg::Notify( const Sequence<OUString>& /* aPropertyNames */ )
151 {
152  ReadCfg();
153 }
154 
156 {
157  *static_cast<ScInputOptions*>(this) = rNew;
158  SetModified();
159  Commit();
160 }
161 
162 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool GetMoveSelection() const
Definition: inputopt.hxx:47
void SetRangeFinder(bool bSet)
Definition: inputopt.hxx:52
constexpr OUStringLiteral CFGPATH_INPUT
Definition: inputopt.cxx:51
#define SCINPUTOPT_MARKHEADER
Definition: inputopt.cxx:60
static css::uno::Sequence< OUString > GetPropertyNames()
Definition: inputopt.cxx:67
#define SCINPUTOPT_EXTENDFMT
Definition: inputopt.cxx:56
virtual void ImplCommit() override
Definition: inputopt.cxx:128
void SetEnterPasteMode(bool bSet)
Definition: inputopt.hxx:68
void SetSortRefUpdate(bool bSet)
Definition: inputopt.hxx:56
bool GetSortRefUpdate() const
Definition: inputopt.hxx:57
void SetEnterEdit(bool bSet)
Definition: inputopt.hxx:48
#define SCINPUTOPT_MOVESEL
Definition: inputopt.cxx:54
#define SCINPUTOPT_ENTER_PASTE_MODE
Definition: inputopt.cxx:65
#define SCINPUTOPT_LEGACY_CELL_SELECTION
Definition: inputopt.cxx:64
bool GetMarkHeader() const
Definition: inputopt.hxx:59
#define SCINPUTOPT_TEXTWYSIWYG
Definition: inputopt.cxx:62
bool EnableNotification(const css::uno::Sequence< OUString > &rNames, bool bEnableInternalNotification=false)
bool GetTextWysiwyg() const
Definition: inputopt.hxx:63
#define SCINPUTOPT_EXPANDREFS
Definition: inputopt.cxx:58
#define SCINPUTOPT_SORT_REF_UPDATE
Definition: inputopt.cxx:59
static bool PutProperties(css::uno::Reference< css::container::XHierarchicalNameAccess > const &xHierarchyAccess, const css::uno::Sequence< OUString > &rNames, const css::uno::Sequence< css::uno::Any > &rValues, bool bAllLocales)
void SetLegacyCellSelection(bool bSet)
Definition: inputopt.hxx:66
static css::uno::Sequence< css::uno::Any > GetProperties(css::uno::Reference< css::container::XHierarchicalNameAccess > const &xHierarchyAccess, const css::uno::Sequence< OUString > &rNames, bool bAllLocales)
bool GetUseTabCol() const
Definition: inputopt.hxx:61
bool GetReplaceCellsWarn() const
Definition: inputopt.hxx:65
bool GetEnterEdit() const
Definition: inputopt.hxx:49
bool GetLegacyCellSelection() const
Definition: inputopt.hxx:67
void SetTextWysiwyg(bool bSet)
Definition: inputopt.hxx:62
float u
#define SCINPUTOPT_RANGEFIND
Definition: inputopt.cxx:57
void SetExpandRefs(bool bSet)
Definition: inputopt.hxx:54
bool GetExtendFormat() const
Definition: inputopt.hxx:51
bool GetExpandRefs() const
Definition: inputopt.hxx:55
#define SCINPUTOPT_EDTEREDIT
Definition: inputopt.cxx:55
const PropertyValue * pValues
void SetMoveDir(sal_uInt16 nNew)
Definition: inputopt.hxx:44
#define SCINPUTOPT_REPLCELLSWARN
Definition: inputopt.cxx:63
bool GetEnterPasteMode() const
Definition: inputopt.hxx:69
#define SCINPUTOPT_USETABCOL
Definition: inputopt.cxx:61
void SetExtendFormat(bool bSet)
Definition: inputopt.hxx:50
void ReadCfg()
Definition: inputopt.cxx:92
sal_uInt16 GetMoveDir() const
Definition: inputopt.hxx:45
void SetUseTabCol(bool bSet)
Definition: inputopt.hxx:60
#define SCINPUTOPT_MOVEDIR
Definition: inputopt.cxx:53
void SetOptions(const ScInputOptions &rNew)
Definition: inputopt.cxx:155
bool GetRangeFinder() const
Definition: inputopt.hxx:53
virtual void Notify(const css::uno::Sequence< OUString > &aPropertyNames) override
Definition: inputopt.cxx:150
void SetReplaceCellsWarn(bool bSet)
Definition: inputopt.hxx:64
void SetMoveSelection(bool bSet)
Definition: inputopt.hxx:46
void SetMarkHeader(bool bSet)
Definition: inputopt.hxx:58
bool m_bDetectedRangeSegmentation false