1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <svl/itemprop.hxx>
21 #include <vcl/svapp.hxx>
23 #include <com/sun/star/util/Date.hpp>
26 #include <miscuno.hxx>
27 #include <docoptio.hxx>
29 using namespace com::sun::star
;
31 bool ScDocOptionsHelper::setPropertyValue( ScDocOptions
& rOptions
,
32 const SfxItemPropertyMap
& rPropMap
,
33 const OUString
& aPropertyName
, const uno::Any
& aValue
)
35 //! use map (with new identifiers)
37 const SfxItemPropertyMapEntry
* pEntry
= rPropMap
.getByName(aPropertyName
);
38 if( !pEntry
|| !pEntry
->nWID
)
40 switch( pEntry
->nWID
)
42 case PROP_UNO_CALCASSHOWN
:
43 rOptions
.SetCalcAsShown( ScUnoHelpFunctions::GetBoolFromAny( aValue
) );
45 case PROP_UNO_DEFTABSTOP
:
47 sal_Int16 nIntVal
= 0;
48 if ( aValue
>>= nIntVal
)
49 rOptions
.SetTabDistance( nIntVal
);
52 case PROP_UNO_IGNORECASE
:
53 rOptions
.SetIgnoreCase( ScUnoHelpFunctions::GetBoolFromAny( aValue
) );
55 case PROP_UNO_ITERENABLED
:
56 rOptions
.SetIter( ScUnoHelpFunctions::GetBoolFromAny( aValue
) );
58 case PROP_UNO_ITERCOUNT
:
60 sal_Int32 nIntVal
= 0;
61 if ( aValue
>>= nIntVal
)
62 rOptions
.SetIterCount( static_cast<sal_uInt16
>(nIntVal
) );
65 case PROP_UNO_ITEREPSILON
:
67 double fDoubleVal
= 0;
68 if ( aValue
>>= fDoubleVal
)
69 rOptions
.SetIterEps( fDoubleVal
);
72 case PROP_UNO_LOOKUPLABELS
:
73 rOptions
.SetLookUpColRowNames( ScUnoHelpFunctions::GetBoolFromAny( aValue
) );
75 case PROP_UNO_MATCHWHOLE
:
76 rOptions
.SetMatchWholeCell( ScUnoHelpFunctions::GetBoolFromAny( aValue
) );
78 case PROP_UNO_NULLDATE
:
81 if ( aValue
>>= aDate
)
82 rOptions
.SetDate( aDate
.Day
, aDate
.Month
, aDate
.Year
);
85 case PROP_UNO_STANDARDDEC
:
87 sal_Int16 nIntVal
= 0;
88 if ( aValue
>>= nIntVal
)
89 rOptions
.SetStdPrecision( nIntVal
);
92 case PROP_UNO_REGEXENABLED
:
93 rOptions
.SetFormulaRegexEnabled( ScUnoHelpFunctions::GetBoolFromAny( aValue
) );
95 case PROP_UNO_WILDCARDSENABLED
:
96 rOptions
.SetFormulaWildcardsEnabled( ScUnoHelpFunctions::GetBoolFromAny( aValue
) );
103 uno::Any
ScDocOptionsHelper::getPropertyValue(
104 const ScDocOptions
& rOptions
,
105 const SfxItemPropertyMap
& rPropMap
,
106 const OUString
& aPropertyName
)
109 const SfxItemPropertyMapEntry
* pEntry
= rPropMap
.getByName( aPropertyName
);
110 if( !pEntry
|| !pEntry
->nWID
)
112 switch( pEntry
->nWID
)
114 case PROP_UNO_CALCASSHOWN
:
115 aRet
<<= rOptions
.IsCalcAsShown();
117 case PROP_UNO_DEFTABSTOP
:
118 aRet
<<= static_cast<sal_Int16
>( rOptions
.GetTabDistance() );
120 case PROP_UNO_IGNORECASE
:
121 aRet
<<= rOptions
.IsIgnoreCase();
123 case PROP_UNO_ITERENABLED
:
124 aRet
<<= rOptions
.IsIter();
126 case PROP_UNO_ITERCOUNT
:
127 aRet
<<= static_cast<sal_Int32
>( rOptions
.GetIterCount() );
129 case PROP_UNO_ITEREPSILON
:
130 aRet
<<= rOptions
.GetIterEps();
132 case PROP_UNO_LOOKUPLABELS
:
133 aRet
<<= rOptions
.IsLookUpColRowNames();
135 case PROP_UNO_MATCHWHOLE
:
136 aRet
<<= rOptions
.IsMatchWholeCell();
138 case PROP_UNO_NULLDATE
:
142 rOptions
.GetDate( nD
, nM
, nY
);
143 util::Date
aDate( nD
, nM
, nY
);
147 case PROP_UNO_STANDARDDEC
:
148 aRet
<<= static_cast<sal_Int16
>( rOptions
.GetStdPrecision() );
150 case PROP_UNO_REGEXENABLED
:
151 aRet
<<= rOptions
.IsFormulaRegexEnabled();
153 case PROP_UNO_WILDCARDSENABLED
:
154 aRet
<<= rOptions
.IsFormulaWildcardsEnabled();
161 ScDocOptionsObj::ScDocOptionsObj( const ScDocOptions
& rOpt
) :
162 ScModelObj( nullptr ),
167 ScDocOptionsObj::~ScDocOptionsObj()
171 void SAL_CALL
ScDocOptionsObj::setPropertyValue(
172 const OUString
& aPropertyName
, const uno::Any
& aValue
)
174 SolarMutexGuard aGuard
;
176 bool bDone
= ScDocOptionsHelper::setPropertyValue( aOptions
, GetPropertySet().getPropertyMap(), aPropertyName
, aValue
);
179 ScModelObj::setPropertyValue( aPropertyName
, aValue
);
182 uno::Any SAL_CALL
ScDocOptionsObj::getPropertyValue( const OUString
& aPropertyName
)
184 SolarMutexGuard aGuard
;
186 uno::Any
aRet(ScDocOptionsHelper::getPropertyValue( aOptions
, GetPropertySet().getPropertyMap(), aPropertyName
));
187 if ( !aRet
.hasValue() )
188 aRet
= ScModelObj::getPropertyValue( aPropertyName
);
193 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */