LibreOffice Module sc (master) 1
optuno.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 <svl/itemprop.hxx>
21#include <vcl/svapp.hxx>
22
23#include <com/sun/star/util/Date.hpp>
24
25#include <optuno.hxx>
26#include <miscuno.hxx>
27#include <unonames.hxx>
28#include <docoptio.hxx>
29
30using namespace com::sun::star;
31
33{
34 static const SfxItemPropertyMapEntry aMap[] =
35 {
49 };
50 return aMap;
51}
52
54 const SfxItemPropertyMap& rPropMap,
55 std::u16string_view aPropertyName, const uno::Any& aValue )
56{
58
59 const SfxItemPropertyMapEntry* pEntry = rPropMap.getByName(aPropertyName );
60 if( !pEntry || !pEntry->nWID )
61 return false;
62 switch( pEntry->nWID )
63 {
66 break;
68 {
69 sal_Int16 nIntVal = 0;
70 if ( aValue >>= nIntVal )
71 rOptions.SetTabDistance( nIntVal );
72 }
73 break;
76 break;
78 rOptions.SetIter( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
79 break;
81 {
82 sal_Int32 nIntVal = 0;
83 if ( aValue >>= nIntVal )
84 rOptions.SetIterCount( static_cast<sal_uInt16>(nIntVal) );
85 }
86 break;
88 {
89 double fDoubleVal = 0;
90 if ( aValue >>= fDoubleVal )
91 rOptions.SetIterEps( fDoubleVal );
92 }
93 break;
96 break;
99 break;
101 {
102 util::Date aDate;
103 if ( aValue >>= aDate )
104 rOptions.SetDate( aDate.Day, aDate.Month, aDate.Year );
105 }
106 break;
109 break;
111 {
112 sal_Int16 nIntVal = 0;
113 if ( aValue >>= nIntVal )
114 rOptions.SetStdPrecision( nIntVal );
115 }
116 break;
119 break;
122 break;
123 default:;
124 }
125 return true;
126}
127
129 const ScDocOptions& rOptions,
130 const SfxItemPropertyMap& rPropMap,
131 std::u16string_view aPropertyName )
132{
133 uno::Any aRet;
134 const SfxItemPropertyMapEntry* pEntry = rPropMap.getByName( aPropertyName );
135 if( !pEntry || !pEntry->nWID )
136 return aRet;
137 switch( pEntry->nWID )
138 {
140 aRet <<= rOptions.IsCalcAsShown();
141 break;
143 aRet <<= static_cast<sal_Int16>( rOptions.GetTabDistance() );
144 break;
146 aRet <<= rOptions.IsIgnoreCase();
147 break;
149 aRet <<= rOptions.IsIter();
150 break;
152 aRet <<= static_cast<sal_Int32>( rOptions.GetIterCount() );
153 break;
155 aRet <<= rOptions.GetIterEps();
156 break;
158 aRet <<= rOptions.IsLookUpColRowNames();
159 break;
161 aRet <<= rOptions.IsMatchWholeCell();
162 break;
164 {
165 sal_uInt16 nD, nM;
166 sal_Int16 nY;
167 rOptions.GetDate( nD, nM, nY );
168 util::Date aDate( nD, nM, nY );
169 aRet <<= aDate;
170 }
171 break;
173 aRet <<= rOptions.IsAutoSpell();
174 break;
176 aRet <<= static_cast<sal_Int16>( rOptions.GetStdPrecision() );
177 break;
179 aRet <<= rOptions.IsFormulaRegexEnabled();
180 break;
182 aRet <<= rOptions.IsFormulaWildcardsEnabled();
183 break;
184 default:;
185 }
186 return aRet;
187}
188
190 ScModelObj( nullptr ),
191 aOptions( rOpt )
192{
193}
194
196{
197}
198
200 const OUString& aPropertyName, const uno::Any& aValue )
201{
202 SolarMutexGuard aGuard;
203
204 bool bDone = ScDocOptionsHelper::setPropertyValue( aOptions, GetPropertySet().getPropertyMap(), aPropertyName, aValue );
205
206 if (!bDone)
207 ScModelObj::setPropertyValue( aPropertyName, aValue );
208}
209
210uno::Any SAL_CALL ScDocOptionsObj::getPropertyValue( const OUString& aPropertyName )
211{
212 SolarMutexGuard aGuard;
213
214 uno::Any aRet(ScDocOptionsHelper::getPropertyValue( aOptions, GetPropertySet().getPropertyMap(), aPropertyName ));
215 if ( !aRet.hasValue() )
216 aRet = ScModelObj::getPropertyValue( aPropertyName );
217
218 return aRet;
219}
220
221/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static o3tl::span< const SfxItemPropertyMapEntry > GetPropertyMap()
Definition: optuno.cxx:32
static bool setPropertyValue(ScDocOptions &rOptions, const SfxItemPropertyMap &rPropMap, std::u16string_view aPropertyName, const css::uno::Any &aValue)
Definition: optuno.cxx:53
static css::uno::Any getPropertyValue(const ScDocOptions &rOptions, const SfxItemPropertyMap &rPropMap, std::u16string_view PropertyName)
Definition: optuno.cxx:128
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: optuno.cxx:210
ScDocOptions aOptions
Definition: optuno.hxx:59
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
Definition: optuno.cxx:199
ScDocOptionsObj(const ScDocOptions &rOpt)
Definition: optuno.cxx:189
virtual ~ScDocOptionsObj() override
Definition: optuno.cxx:195
void GetDate(sal_uInt16 &rD, sal_uInt16 &rM, sal_Int16 &rY) const
Definition: docoptio.hxx:66
bool IsFormulaWildcardsEnabled() const
Definition: docoptio.hxx:98
bool IsIgnoreCase() const
Definition: docoptio.hxx:57
void SetTabDistance(sal_uInt16 nTabDist)
Definition: docoptio.hxx:71
void SetFormulaRegexEnabled(bool bVal)
Definition: docoptio.cxx:73
void SetCalcAsShown(bool bVal)
Definition: docoptio.hxx:82
sal_uInt16 GetIterCount() const
Definition: docoptio.hxx:61
void SetIgnoreCase(bool bVal)
Definition: docoptio.hxx:58
void SetAutoSpell(bool bVal)
Definition: docoptio.hxx:54
void SetLookUpColRowNames(bool bVal)
Definition: docoptio.hxx:52
sal_uInt16 GetTabDistance() const
Definition: docoptio.hxx:70
void SetIter(bool bVal)
Definition: docoptio.hxx:60
bool IsAutoSpell() const
Definition: docoptio.hxx:53
void SetFormulaWildcardsEnabled(bool bVal)
Definition: docoptio.cxx:90
void SetIterEps(double fEps)
Definition: docoptio.hxx:64
void SetMatchWholeCell(bool bVal)
Definition: docoptio.hxx:56
sal_uInt16 GetStdPrecision() const
Definition: docoptio.hxx:78
void SetStdPrecision(sal_uInt16 n)
Definition: docoptio.hxx:79
bool IsIter() const
Definition: docoptio.hxx:59
bool IsLookUpColRowNames() const
Definition: docoptio.hxx:51
void SetDate(sal_uInt16 nD, sal_uInt16 nM, sal_Int16 nY)
Definition: docoptio.hxx:68
bool IsMatchWholeCell() const
Definition: docoptio.hxx:55
bool IsFormulaRegexEnabled() const
Definition: docoptio.hxx:95
void SetIterCount(sal_uInt16 nCount)
Definition: docoptio.hxx:62
bool IsCalcAsShown() const
Definition: docoptio.hxx:81
double GetIterEps() const
Definition: docoptio.hxx:63
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
Definition: docuno.cxx:2697
const SfxItemPropertySet & GetPropertySet() const
Definition: docuno.hxx:129
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: docuno.cxx:2845
static bool GetBoolFromAny(const css::uno::Any &aAny)
Definition: miscuno.cxx:139
const SfxItemPropertyMapEntry * getByName(std::u16string_view rName) const
css::uno::Type const & get()
HashMap_OWString_Interface aMap
#define PROP_UNO_WILDCARDSENABLED
Definition: optuno.hxx:37
#define PROP_UNO_ITEREPSILON
Definition: optuno.hxx:30
#define PROP_UNO_LOOKUPLABELS
Definition: optuno.hxx:31
#define PROP_UNO_MATCHWHOLE
Definition: optuno.hxx:32
#define PROP_UNO_ITERCOUNT
Definition: optuno.hxx:29
#define PROP_UNO_REGEXENABLED
Definition: optuno.hxx:36
#define PROP_UNO_DEFTABSTOP
Definition: optuno.hxx:26
#define PROP_UNO_STANDARDDEC
Definition: optuno.hxx:35
#define PROP_UNO_NULLDATE
Definition: optuno.hxx:33
#define PROP_UNO_IGNORECASE
Definition: optuno.hxx:27
#define PROP_UNO_ITERENABLED
Definition: optuno.hxx:28
#define PROP_UNO_SPELLONLINE
Definition: optuno.hxx:34
#define PROP_UNO_CALCASSHOWN
Definition: optuno.hxx:25
bool hasValue()
constexpr OUStringLiteral SC_UNO_CALCASSHOWN
Definition: unonames.hxx:512
constexpr OUStringLiteral SC_UNO_ITERCOUNT
Definition: unonames.hxx:516
constexpr OUStringLiteral SC_UNO_NULLDATE
Definition: unonames.hxx:521
constexpr OUStringLiteral SC_UNO_STANDARDDEC
Definition: unonames.hxx:523
constexpr OUStringLiteral SC_UNO_DEFTABSTOP
Definition: unonames.hxx:513
constexpr OUStringLiteral SC_UNO_ITEREPSILON
Definition: unonames.hxx:518
constexpr OUStringLiteral SC_UNO_IGNORECASE
Definition: unonames.hxx:515
constexpr OUStringLiteral SC_UNO_LOOKUPLABELS
Definition: unonames.hxx:519
constexpr OUStringLiteral SC_UNO_WILDCARDSENABLED
Definition: unonames.hxx:525
constexpr OUStringLiteral SC_UNO_REGEXENABLED
Definition: unonames.hxx:524
constexpr OUStringLiteral SC_UNO_SPELLONLINE
Definition: unonames.hxx:522
constexpr OUStringLiteral SC_UNO_MATCHWHOLE
Definition: unonames.hxx:520
constexpr OUStringLiteral SC_UNO_ITERENABLED
Definition: unonames.hxx:517