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 
30 using namespace com::sun::star;
31 
33 {
34  static const SfxItemPropertyMapEntry aMap[] =
35  {
49  { OUString(), 0, css::uno::Type(), 0, 0 }
50  };
51  return aMap;
52 }
53 
55  const SfxItemPropertyMap& rPropMap,
56  const OUString& aPropertyName, const uno::Any& aValue )
57 {
59 
60  const SfxItemPropertySimpleEntry* pEntry = rPropMap.getByName(aPropertyName );
61  if( !pEntry || !pEntry->nWID )
62  return false;
63  switch( pEntry->nWID )
64  {
67  break;
68  case PROP_UNO_DEFTABSTOP :
69  {
70  sal_Int16 nIntVal = 0;
71  if ( aValue >>= nIntVal )
72  rOptions.SetTabDistance( nIntVal );
73  }
74  break;
75  case PROP_UNO_IGNORECASE :
77  break;
79  rOptions.SetIter( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
80  break;
81  case PROP_UNO_ITERCOUNT :
82  {
83  sal_Int32 nIntVal = 0;
84  if ( aValue >>= nIntVal )
85  rOptions.SetIterCount( static_cast<sal_uInt16>(nIntVal) );
86  }
87  break;
89  {
90  double fDoubleVal = 0;
91  if ( aValue >>= fDoubleVal )
92  rOptions.SetIterEps( fDoubleVal );
93  }
94  break;
97  break;
98  case PROP_UNO_MATCHWHOLE :
100  break;
101  case PROP_UNO_NULLDATE:
102  {
103  util::Date aDate;
104  if ( aValue >>= aDate )
105  rOptions.SetDate( aDate.Day, aDate.Month, aDate.Year );
106  }
107  break;
109  rOptions.SetAutoSpell( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
110  break;
112  {
113  sal_Int16 nIntVal = 0;
114  if ( aValue >>= nIntVal )
115  rOptions.SetStdPrecision( nIntVal );
116  }
117  break;
120  break;
123  break;
124  default:;
125  }
126  return true;
127 }
128 
130  const ScDocOptions& rOptions,
131  const SfxItemPropertyMap& rPropMap,
132  const OUString& aPropertyName )
133 {
134  uno::Any aRet;
135  const SfxItemPropertySimpleEntry* pEntry = rPropMap.getByName( aPropertyName );
136  if( !pEntry || !pEntry->nWID )
137  return aRet;
138  switch( pEntry->nWID )
139  {
140  case PROP_UNO_CALCASSHOWN :
141  aRet <<= rOptions.IsCalcAsShown();
142  break;
143  case PROP_UNO_DEFTABSTOP :
144  aRet <<= static_cast<sal_Int16>( rOptions.GetTabDistance() );
145  break;
146  case PROP_UNO_IGNORECASE :
147  aRet <<= rOptions.IsIgnoreCase();
148  break;
150  aRet <<= rOptions.IsIter();
151  break;
152  case PROP_UNO_ITERCOUNT:
153  aRet <<= static_cast<sal_Int32>( rOptions.GetIterCount() );
154  break;
156  aRet <<= rOptions.GetIterEps();
157  break;
159  aRet <<= rOptions.IsLookUpColRowNames();
160  break;
161  case PROP_UNO_MATCHWHOLE:
162  aRet <<= rOptions.IsMatchWholeCell();
163  break;
164  case PROP_UNO_NULLDATE:
165  {
166  sal_uInt16 nD, nM;
167  sal_Int16 nY;
168  rOptions.GetDate( nD, nM, nY );
169  util::Date aDate( nD, nM, nY );
170  aRet <<= aDate;
171  }
172  break;
174  aRet <<= rOptions.IsAutoSpell();
175  break;
176  case PROP_UNO_STANDARDDEC :
177  aRet <<= static_cast<sal_Int16>( rOptions.GetStdPrecision() );
178  break;
180  aRet <<= rOptions.IsFormulaRegexEnabled();
181  break;
183  aRet <<= rOptions.IsFormulaWildcardsEnabled();
184  break;
185  default:;
186  }
187  return aRet;
188 }
189 
191  ScModelObj( nullptr ),
192  aOptions( rOpt )
193 {
194 }
195 
197 {
198 }
199 
201  const OUString& aPropertyName, const uno::Any& aValue )
202 {
203  SolarMutexGuard aGuard;
204 
205  bool bDone = ScDocOptionsHelper::setPropertyValue( aOptions, GetPropertySet().getPropertyMap(), aPropertyName, aValue );
206 
207  if (!bDone)
208  ScModelObj::setPropertyValue( aPropertyName, aValue );
209 }
210 
211 uno::Any SAL_CALL ScDocOptionsObj::getPropertyValue( const OUString& aPropertyName )
212 {
213  SolarMutexGuard aGuard;
214 
215  uno::Any aRet(ScDocOptionsHelper::getPropertyValue( aOptions, GetPropertySet().getPropertyMap(), aPropertyName ));
216  if ( !aRet.hasValue() )
217  aRet = ScModelObj::getPropertyValue( aPropertyName );
218 
219  return aRet;
220 }
221 
222 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define SC_UNO_IGNORECASE
Definition: unonames.hxx:502
#define SC_UNO_SPELLONLINE
Definition: unonames.hxx:509
bool hasValue()
#define PROP_UNO_CALCASSHOWN
Definition: optuno.hxx:26
#define SC_UNO_ITERENABLED
Definition: unonames.hxx:504
ScDocOptions aOptions
Definition: optuno.hxx:60
#define SC_UNO_ITERCOUNT
Definition: unonames.hxx:503
void SetFormulaWildcardsEnabled(bool bVal)
Definition: docoptio.cxx:94
#define PROP_UNO_ITEREPSILON
Definition: optuno.hxx:31
#define PROP_UNO_IGNORECASE
Definition: optuno.hxx:28
#define PROP_UNO_REGEXENABLED
Definition: optuno.hxx:37
#define PROP_UNO_NULLDATE
Definition: optuno.hxx:34
void SetTabDistance(sal_uInt16 nTabDist)
Definition: docoptio.hxx:72
bool IsIter() const
Definition: docoptio.hxx:60
bool IsLookUpColRowNames() const
Definition: docoptio.hxx:52
sal_uInt16 GetIterCount() const
Definition: docoptio.hxx:62
static const SfxItemPropertyMapEntry * GetPropertyMap()
Definition: optuno.cxx:32
static css::uno::Any getPropertyValue(const ScDocOptions &rOptions, const SfxItemPropertyMap &rPropMap, const OUString &PropertyName)
Definition: optuno.cxx:129
HashMap_OWString_Interface aMap
#define SC_UNO_NULLDATE
Definition: unonames.hxx:508
void SetLookUpColRowNames(bool bVal)
Definition: docoptio.hxx:53
void SetIgnoreCase(bool bVal)
Definition: docoptio.hxx:59
#define PROP_UNO_LOOKUPLABELS
Definition: optuno.hxx:32
#define PROP_UNO_WILDCARDSENABLED
Definition: optuno.hxx:38
bool IsMatchWholeCell() const
Definition: docoptio.hxx:56
void SetCalcAsShown(bool bVal)
Definition: docoptio.hxx:83
static bool setPropertyValue(ScDocOptions &rOptions, const SfxItemPropertyMap &rPropMap, const OUString &aPropertyName, const css::uno::Any &aValue)
Definition: optuno.cxx:54
#define SC_UNO_MATCHWHOLE
Definition: unonames.hxx:507
#define SC_UNO_DEFTABSTOP
Definition: unonames.hxx:500
sal_uInt16 GetTabDistance() const
Definition: docoptio.hxx:71
#define SC_UNO_WILDCARDSENABLED
Definition: unonames.hxx:512
#define SC_UNO_REGEXENABLED
Definition: unonames.hxx:511
virtual ~ScDocOptionsObj() override
Definition: optuno.cxx:196
void SetIter(bool bVal)
Definition: docoptio.hxx:61
void SetDate(sal_uInt16 nD, sal_uInt16 nM, sal_Int16 nY)
Definition: docoptio.hxx:69
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
Definition: docuno.cxx:2592
css::uno::Type const & get()
#define PROP_UNO_MATCHWHOLE
Definition: optuno.hxx:33
void SetIterCount(sal_uInt16 nCount)
Definition: docoptio.hxx:63
#define PROP_UNO_ITERCOUNT
Definition: optuno.hxx:30
#define PROP_UNO_SPELLONLINE
Definition: optuno.hxx:35
const SfxItemPropertySimpleEntry * getByName(const OUString &rName) const
#define SC_UNO_LOOKUPLABELS
Definition: unonames.hxx:506
#define SC_UNO_STANDARDDEC
Definition: unonames.hxx:510
void SetStdPrecision(sal_uInt16 n)
Definition: docoptio.hxx:80
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: docuno.cxx:2740
bool IsFormulaWildcardsEnabled() const
Definition: docoptio.hxx:99
#define SC_UNO_CALCASSHOWN
Definition: unonames.hxx:499
bool IsCalcAsShown() const
Definition: docoptio.hxx:82
ScDocOptionsObj(const ScDocOptions &rOpt)
Definition: optuno.cxx:190
double GetIterEps() const
Definition: docoptio.hxx:64
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
Definition: optuno.cxx:200
bool IsAutoSpell() const
Definition: docoptio.hxx:54
#define PROP_UNO_DEFTABSTOP
Definition: optuno.hxx:27
sal_uInt16 GetStdPrecision() const
Definition: docoptio.hxx:79
void SetMatchWholeCell(bool bVal)
Definition: docoptio.hxx:57
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: optuno.cxx:211
#define PROP_UNO_STANDARDDEC
Definition: optuno.hxx:36
const SfxItemPropertySet & GetPropertySet() const
Definition: docuno.hxx:130
bool IsFormulaRegexEnabled() const
Definition: docoptio.hxx:96
void SetAutoSpell(bool bVal)
Definition: docoptio.hxx:55
static bool GetBoolFromAny(const css::uno::Any &aAny)
Definition: miscuno.cxx:138
bool IsIgnoreCase() const
Definition: docoptio.hxx:58
#define PROP_UNO_ITERENABLED
Definition: optuno.hxx:29
void SetFormulaRegexEnabled(bool bVal)
Definition: docoptio.cxx:77
void GetDate(sal_uInt16 &rD, sal_uInt16 &rM, sal_Int16 &rY) const
Definition: docoptio.hxx:67
#define SC_UNO_ITEREPSILON
Definition: unonames.hxx:505
void SetIterEps(double fEps)
Definition: docoptio.hxx:65