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
27using namespace utl;
28using 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
51constexpr 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_REPLCELLSWARN 9
63#define SCINPUTOPT_LEGACY_CELL_SELECTION 10
64#define SCINPUTOPT_ENTER_PASTE_MODE 11
65
67{
68 return {"MoveSelectionDirection", // SCINPUTOPT_MOVEDIR
69 "MoveSelection", // SCINPUTOPT_MOVESEL
70 "SwitchToEditMode", // SCINPUTOPT_EDTEREDIT
71 "ExpandFormatting", // SCINPUTOPT_EXTENDFMT
72 "ShowReference", // SCINPUTOPT_RANGEFIND
73 "ExpandReference", // SCINPUTOPT_EXPANDREFS
74 "UpdateReferenceOnSort", // SCINPUTOPT_SORT_REF_UPDATE
75 "HighlightSelection", // SCINPUTOPT_MARKHEADER
76 "UseTabCol", // SCINPUTOPT_USETABCOL
77 "ReplaceCellsWarning", // SCINPUTOPT_REPLCELLSWARN
78 "LegacyCellSelection", // SCINPUTOPT_LEGACY_CELL_SELECTION
79 "EnterPasteMode"}; // SCINPUTOPT_ENTER_PASTE_MODE
80}
81
84{
86 EnableNotification(aNames);
87 ReadCfg();
88}
89
91{
92 const Sequence<OUString> aNames = GetPropertyNames();
93 const Sequence<Any> aValues = GetProperties(aNames);
94 OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
95 if(aValues.getLength() != aNames.getLength())
96 return;
97
98 if (sal_Int32 nVal; aValues[SCINPUTOPT_MOVEDIR] >>= nVal)
99 SetMoveDir(static_cast<sal_uInt16>(nVal));
100 if (bool bVal; aValues[SCINPUTOPT_MOVESEL] >>= bVal)
101 SetMoveSelection(bVal);
102 if (bool bVal; aValues[SCINPUTOPT_EDTEREDIT] >>= bVal)
103 SetEnterEdit(bVal);
104 if (bool bVal; aValues[SCINPUTOPT_EXTENDFMT] >>= bVal)
105 SetExtendFormat(bVal);
106 if (bool bVal; aValues[SCINPUTOPT_RANGEFIND] >>= bVal)
107 SetRangeFinder(bVal);
108 if (bool bVal; aValues[SCINPUTOPT_EXPANDREFS] >>= bVal)
109 SetExpandRefs(bVal);
110 if (bool bVal; aValues[SCINPUTOPT_SORT_REF_UPDATE] >>= bVal)
111 SetSortRefUpdate(bVal);
112 if (bool bVal; aValues[SCINPUTOPT_MARKHEADER] >>= bVal)
113 SetMarkHeader(bVal);
114 if (bool bVal; aValues[SCINPUTOPT_USETABCOL] >>= bVal)
115 SetUseTabCol(bVal);
116 if (bool bVal; aValues[SCINPUTOPT_REPLCELLSWARN] >>= bVal)
118 if (bool bVal; aValues[SCINPUTOPT_LEGACY_CELL_SELECTION] >>= bVal)
120 if (bool bVal; aValues[SCINPUTOPT_ENTER_PASTE_MODE] >>= bVal)
121 SetEnterPasteMode(bVal);
122}
123
125{
127 Sequence<Any> aValues(aNames.getLength());
128 Any* pValues = aValues.getArray();
129
130 pValues[SCINPUTOPT_MOVEDIR] <<= static_cast<sal_Int32>(GetMoveDir());
142 PutProperties(aNames, aValues);
143}
144
145void ScInputCfg::Notify( const Sequence<OUString>& /* aPropertyNames */ )
146{
147 ReadCfg();
148}
149
151{
152 *static_cast<ScInputOptions*>(this) = rNew;
153 SetModified();
154 Commit();
155}
156
157/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const PropertyValue * pValues
virtual void ImplCommit() override
Definition: inputopt.cxx:124
void ReadCfg()
Definition: inputopt.cxx:90
void SetOptions(const ScInputOptions &rNew)
Definition: inputopt.cxx:150
virtual void Notify(const css::uno::Sequence< OUString > &aPropertyNames) override
Definition: inputopt.cxx:145
static css::uno::Sequence< OUString > GetPropertyNames()
Definition: inputopt.cxx:66
sal_uInt16 GetMoveDir() const
Definition: inputopt.hxx:45
void SetExpandRefs(bool bSet)
Definition: inputopt.hxx:54
void SetEnterEdit(bool bSet)
Definition: inputopt.hxx:48
void SetExtendFormat(bool bSet)
Definition: inputopt.hxx:50
bool GetUseTabCol() const
Definition: inputopt.hxx:61
void SetMarkHeader(bool bSet)
Definition: inputopt.hxx:58
void SetMoveDir(sal_uInt16 nNew)
Definition: inputopt.hxx:44
bool GetSortRefUpdate() const
Definition: inputopt.hxx:57
void SetRangeFinder(bool bSet)
Definition: inputopt.hxx:52
bool GetMarkHeader() const
Definition: inputopt.hxx:59
void SetUseTabCol(bool bSet)
Definition: inputopt.hxx:60
void SetReplaceCellsWarn(bool bSet)
Definition: inputopt.hxx:64
void SetMoveSelection(bool bSet)
Definition: inputopt.hxx:46
bool GetEnterEdit() const
Definition: inputopt.hxx:49
bool GetReplaceCellsWarn() const
Definition: inputopt.hxx:65
void SetSortRefUpdate(bool bSet)
Definition: inputopt.hxx:56
bool GetLegacyCellSelection() const
Definition: inputopt.hxx:67
void SetEnterPasteMode(bool bSet)
Definition: inputopt.hxx:68
bool GetExtendFormat() const
Definition: inputopt.hxx:51
bool GetRangeFinder() const
Definition: inputopt.hxx:53
void SetLegacyCellSelection(bool bSet)
Definition: inputopt.hxx:66
bool GetExpandRefs() const
Definition: inputopt.hxx:55
bool GetEnterPasteMode() const
Definition: inputopt.hxx:69
bool GetMoveSelection() const
Definition: inputopt.hxx:47
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)
bool EnableNotification(const css::uno::Sequence< OUString > &rNames, bool bEnableInternalNotification=false)
static css::uno::Sequence< css::uno::Any > GetProperties(css::uno::Reference< css::container::XHierarchicalNameAccess > const &xHierarchyAccess, const css::uno::Sequence< OUString > &rNames, bool bAllLocales)
float u
@ DIR_BOTTOM
Definition: global.hxx:344
#define SCINPUTOPT_MOVESEL
Definition: inputopt.cxx:54
#define SCINPUTOPT_ENTER_PASTE_MODE
Definition: inputopt.cxx:64
#define SCINPUTOPT_MOVEDIR
Definition: inputopt.cxx:53
#define SCINPUTOPT_EXPANDREFS
Definition: inputopt.cxx:58
#define SCINPUTOPT_USETABCOL
Definition: inputopt.cxx:61
#define SCINPUTOPT_RANGEFIND
Definition: inputopt.cxx:57
#define SCINPUTOPT_MARKHEADER
Definition: inputopt.cxx:60
#define SCINPUTOPT_LEGACY_CELL_SELECTION
Definition: inputopt.cxx:63
constexpr OUStringLiteral CFGPATH_INPUT
Definition: inputopt.cxx:51
#define SCINPUTOPT_EDTEREDIT
Definition: inputopt.cxx:55
#define SCINPUTOPT_SORT_REF_UPDATE
Definition: inputopt.cxx:59
#define SCINPUTOPT_EXTENDFMT
Definition: inputopt.cxx:56
#define SCINPUTOPT_REPLCELLSWARN
Definition: inputopt.cxx:62