/src/libreoffice/sc/source/ui/unoobj/optuno.cxx
Line | Count | Source |
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 <docoptio.hxx> |
28 | | |
29 | | using namespace com::sun::star; |
30 | | |
31 | | bool ScDocOptionsHelper::setPropertyValue( ScDocOptions& rOptions, |
32 | | const SfxItemPropertyMap& rPropMap, |
33 | | std::u16string_view aPropertyName, const uno::Any& aValue ) |
34 | 259k | { |
35 | | //! use map (with new identifiers) |
36 | | |
37 | 259k | const SfxItemPropertyMapEntry* pEntry = rPropMap.getByName(aPropertyName ); |
38 | 259k | if( !pEntry || !pEntry->nWID ) |
39 | 27.8k | return false; |
40 | 231k | switch( static_cast<ScPropUnoId>(pEntry->nWID) ) |
41 | 231k | { |
42 | 23.5k | case ScPropUnoId::CalcAsShown: |
43 | 23.5k | rOptions.SetCalcAsShown( ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); |
44 | 23.5k | break; |
45 | 0 | case ScPropUnoId::DefTabStop: |
46 | 0 | { |
47 | 0 | sal_Int16 nIntVal = 0; |
48 | 0 | if ( aValue >>= nIntVal ) |
49 | 0 | rOptions.SetTabDistance( nIntVal ); |
50 | 0 | } |
51 | 0 | break; |
52 | 23.5k | case ScPropUnoId::IgnoreCase: |
53 | 23.5k | rOptions.SetIgnoreCase( ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); |
54 | 23.5k | break; |
55 | 23.5k | case ScPropUnoId::IterEnabled: |
56 | 23.5k | rOptions.SetIter( ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); |
57 | 23.5k | break; |
58 | 23.5k | case ScPropUnoId::IterCount: |
59 | 23.5k | { |
60 | 23.5k | sal_Int32 nIntVal = 0; |
61 | 23.5k | if ( aValue >>= nIntVal ) |
62 | 23.5k | rOptions.SetIterCount( static_cast<sal_uInt16>(nIntVal) ); |
63 | 23.5k | } |
64 | 23.5k | break; |
65 | 23.5k | case ScPropUnoId::IterEpsilon: |
66 | 23.5k | { |
67 | 23.5k | double fDoubleVal = 0; |
68 | 23.5k | if ( aValue >>= fDoubleVal ) |
69 | 23.5k | rOptions.SetIterEps( fDoubleVal ); |
70 | 23.5k | } |
71 | 23.5k | break; |
72 | 23.5k | case ScPropUnoId::LookupLabels: |
73 | 23.5k | rOptions.SetLookUpColRowNames( ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); |
74 | 23.5k | break; |
75 | 19.6k | case ScPropUnoId::MatchWhole: |
76 | 19.6k | rOptions.SetMatchWholeCell( ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); |
77 | 19.6k | break; |
78 | 23.5k | case ScPropUnoId::NullDate: |
79 | 23.5k | { |
80 | 23.5k | util::Date aDate; |
81 | 23.5k | if ( aValue >>= aDate ) |
82 | 23.5k | rOptions.SetDate( aDate.Day, aDate.Month, aDate.Year ); |
83 | 23.5k | } |
84 | 23.5k | break; |
85 | 0 | case ScPropUnoId::StandardDec: |
86 | 0 | { |
87 | 0 | sal_Int16 nIntVal = 0; |
88 | 0 | if ( aValue >>= nIntVal ) |
89 | 0 | rOptions.SetStdPrecision( nIntVal ); |
90 | 0 | } |
91 | 0 | break; |
92 | 23.5k | case ScPropUnoId::RegexEnabled: |
93 | 23.5k | rOptions.SetFormulaRegexEnabled( ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); |
94 | 23.5k | break; |
95 | 23.5k | case ScPropUnoId::WildcardsEnabled: |
96 | 23.5k | rOptions.SetFormulaWildcardsEnabled( ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); |
97 | 23.5k | break; |
98 | 0 | default:; |
99 | 231k | } |
100 | 231k | return true; |
101 | 231k | } |
102 | | |
103 | | uno::Any ScDocOptionsHelper::getPropertyValue( |
104 | | const ScDocOptions& rOptions, |
105 | | const SfxItemPropertyMap& rPropMap, |
106 | | std::u16string_view aPropertyName ) |
107 | 15.4k | { |
108 | 15.4k | uno::Any aRet; |
109 | 15.4k | const SfxItemPropertyMapEntry* pEntry = rPropMap.getByName( aPropertyName ); |
110 | 15.4k | if( !pEntry || !pEntry->nWID ) |
111 | 15.4k | return aRet; |
112 | 23 | switch( static_cast<ScPropUnoId>(pEntry->nWID) ) |
113 | 23 | { |
114 | 0 | case ScPropUnoId::CalcAsShown: |
115 | 0 | aRet <<= rOptions.IsCalcAsShown(); |
116 | 0 | break; |
117 | 0 | case ScPropUnoId::DefTabStop: |
118 | 0 | aRet <<= static_cast<sal_Int16>( rOptions.GetTabDistance() ); |
119 | 0 | break; |
120 | 0 | case ScPropUnoId::IgnoreCase: |
121 | 0 | aRet <<= rOptions.IsIgnoreCase(); |
122 | 0 | break; |
123 | 0 | case ScPropUnoId::IterEnabled: |
124 | 0 | aRet <<= rOptions.IsIter(); |
125 | 0 | break; |
126 | 0 | case ScPropUnoId::IterCount: |
127 | 0 | aRet <<= static_cast<sal_Int32>( rOptions.GetIterCount() ); |
128 | 0 | break; |
129 | 0 | case ScPropUnoId::IterEpsilon: |
130 | 0 | aRet <<= rOptions.GetIterEps(); |
131 | 0 | break; |
132 | 0 | case ScPropUnoId::LookupLabels: |
133 | 0 | aRet <<= rOptions.IsLookUpColRowNames(); |
134 | 0 | break; |
135 | 0 | case ScPropUnoId::MatchWhole: |
136 | 0 | aRet <<= rOptions.IsMatchWholeCell(); |
137 | 0 | break; |
138 | 23 | case ScPropUnoId::NullDate: |
139 | 23 | { |
140 | 23 | sal_uInt16 nD, nM; |
141 | 23 | sal_Int16 nY; |
142 | 23 | rOptions.GetDate( nD, nM, nY ); |
143 | 23 | util::Date aDate( nD, nM, nY ); |
144 | 23 | aRet <<= aDate; |
145 | 23 | } |
146 | 23 | break; |
147 | 0 | case ScPropUnoId::StandardDec: |
148 | 0 | aRet <<= static_cast<sal_Int16>( rOptions.GetStdPrecision() ); |
149 | 0 | break; |
150 | 0 | case ScPropUnoId::RegexEnabled: |
151 | 0 | aRet <<= rOptions.IsFormulaRegexEnabled(); |
152 | 0 | break; |
153 | 0 | case ScPropUnoId::WildcardsEnabled: |
154 | 0 | aRet <<= rOptions.IsFormulaWildcardsEnabled(); |
155 | 0 | break; |
156 | 0 | default:; |
157 | 23 | } |
158 | 23 | return aRet; |
159 | 23 | } |
160 | | |
161 | | ScDocOptionsObj::ScDocOptionsObj( const ScDocOptions& rOpt ) : |
162 | 0 | ScModelObj( nullptr ), |
163 | 0 | aOptions( rOpt ) |
164 | 0 | { |
165 | 0 | } |
166 | | |
167 | | ScDocOptionsObj::~ScDocOptionsObj() |
168 | 0 | { |
169 | 0 | } |
170 | | |
171 | | void SAL_CALL ScDocOptionsObj::setPropertyValue( |
172 | | const OUString& aPropertyName, const uno::Any& aValue ) |
173 | 0 | { |
174 | 0 | SolarMutexGuard aGuard; |
175 | |
|
176 | 0 | bool bDone = ScDocOptionsHelper::setPropertyValue( aOptions, GetPropertySet().getPropertyMap(), aPropertyName, aValue ); |
177 | |
|
178 | 0 | if (!bDone) |
179 | 0 | ScModelObj::setPropertyValue( aPropertyName, aValue ); |
180 | 0 | } |
181 | | |
182 | | uno::Any SAL_CALL ScDocOptionsObj::getPropertyValue( const OUString& aPropertyName ) |
183 | 0 | { |
184 | 0 | SolarMutexGuard aGuard; |
185 | |
|
186 | 0 | uno::Any aRet(ScDocOptionsHelper::getPropertyValue( aOptions, GetPropertySet().getPropertyMap(), aPropertyName )); |
187 | 0 | if ( !aRet.hasValue() ) |
188 | 0 | aRet = ScModelObj::getPropertyValue( aPropertyName ); |
189 | |
|
190 | 0 | return aRet; |
191 | 0 | } |
192 | | |
193 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |