Line data Source code
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 :
22 : #include <com/sun/star/util/Date.hpp>
23 :
24 : #include "optuno.hxx"
25 : #include "miscuno.hxx"
26 : #include "unonames.hxx"
27 : #include "docoptio.hxx"
28 :
29 : using namespace com::sun::star;
30 :
31 : //------------------------------------------------------------------------
32 0 : const SfxItemPropertyMapEntry* ScDocOptionsHelper::GetPropertyMap()
33 : {
34 : static SfxItemPropertyMapEntry aMap[] =
35 : {
36 0 : {MAP_CHAR_LEN(SC_UNO_CALCASSHOWN), PROP_UNO_CALCASSHOWN , &getBooleanCppuType(), 0, 0},
37 0 : {MAP_CHAR_LEN(SC_UNO_DEFTABSTOP), PROP_UNO_DEFTABSTOP , &getCppuType((sal_Int16*)0), 0, 0},
38 0 : {MAP_CHAR_LEN(SC_UNO_IGNORECASE), PROP_UNO_IGNORECASE , &getBooleanCppuType(), 0, 0},
39 0 : {MAP_CHAR_LEN(SC_UNO_ITERENABLED), PROP_UNO_ITERENABLED , &getBooleanCppuType(), 0, 0},
40 0 : {MAP_CHAR_LEN(SC_UNO_ITERCOUNT), PROP_UNO_ITERCOUNT , &getCppuType((sal_Int32*)0), 0, 0},
41 0 : {MAP_CHAR_LEN(SC_UNO_ITEREPSILON), PROP_UNO_ITEREPSILON , &getCppuType((double*)0), 0, 0},
42 0 : {MAP_CHAR_LEN(SC_UNO_LOOKUPLABELS), PROP_UNO_LOOKUPLABELS, &getBooleanCppuType(), 0, 0},
43 0 : {MAP_CHAR_LEN(SC_UNO_MATCHWHOLE), PROP_UNO_MATCHWHOLE , &getBooleanCppuType(), 0, 0},
44 0 : {MAP_CHAR_LEN(SC_UNO_NULLDATE), PROP_UNO_NULLDATE , &getCppuType((util::Date*)0), 0, 0},
45 0 : {MAP_CHAR_LEN(SC_UNO_SPELLONLINE), PROP_UNO_SPELLONLINE , &getBooleanCppuType(), 0, 0},
46 0 : {MAP_CHAR_LEN(SC_UNO_STANDARDDEC), PROP_UNO_STANDARDDEC , &getCppuType((sal_Int16*)0), 0, 0},
47 0 : {MAP_CHAR_LEN(SC_UNO_REGEXENABLED), PROP_UNO_REGEXENABLED, &getBooleanCppuType(), 0, 0},
48 : {0,0,0,0,0,0}
49 0 : };
50 0 : return aMap;
51 : }
52 :
53 473 : sal_Bool ScDocOptionsHelper::setPropertyValue( ScDocOptions& rOptions,
54 : const SfxItemPropertyMap& rPropMap,
55 : const rtl::OUString& aPropertyName, const uno::Any& aValue )
56 : {
57 : //! use map (with new identifiers)
58 :
59 473 : const SfxItemPropertySimpleEntry* pEntry = rPropMap.getByName(aPropertyName );
60 473 : if( !pEntry || !pEntry->nWID )
61 187 : return false;
62 286 : switch( pEntry->nWID )
63 : {
64 : case PROP_UNO_CALCASSHOWN :
65 33 : rOptions.SetCalcAsShown( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
66 33 : break;
67 : case PROP_UNO_DEFTABSTOP :
68 : {
69 0 : sal_Int16 nIntVal = 0;
70 0 : if ( aValue >>= nIntVal )
71 0 : rOptions.SetTabDistance( nIntVal );
72 : }
73 0 : break;
74 : case PROP_UNO_IGNORECASE :
75 33 : rOptions.SetIgnoreCase( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
76 33 : break;
77 : case PROP_UNO_ITERENABLED:
78 33 : rOptions.SetIter( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
79 33 : break;
80 : case PROP_UNO_ITERCOUNT :
81 : {
82 33 : sal_Int32 nIntVal = 0;
83 33 : if ( aValue >>= nIntVal )
84 33 : rOptions.SetIterCount( (sal_uInt16)nIntVal );
85 : }
86 33 : break;
87 : case PROP_UNO_ITEREPSILON :
88 : {
89 33 : double fDoubleVal = 0;
90 33 : if ( aValue >>= fDoubleVal )
91 33 : rOptions.SetIterEps( fDoubleVal );
92 : }
93 33 : break;
94 : case PROP_UNO_LOOKUPLABELS :
95 33 : rOptions.SetLookUpColRowNames( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
96 33 : break;
97 : case PROP_UNO_MATCHWHOLE :
98 22 : rOptions.SetMatchWholeCell( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
99 22 : break;
100 : case PROP_UNO_NULLDATE:
101 : {
102 33 : util::Date aDate;
103 33 : if ( aValue >>= aDate )
104 33 : rOptions.SetDate( aDate.Day, aDate.Month, aDate.Year );
105 : }
106 33 : break;
107 : case PROP_UNO_SPELLONLINE:
108 0 : rOptions.SetAutoSpell( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
109 0 : break;
110 : case PROP_UNO_STANDARDDEC:
111 : {
112 0 : sal_Int16 nIntVal = 0;
113 0 : if ( aValue >>= nIntVal )
114 0 : rOptions.SetStdPrecision( nIntVal );
115 : }
116 0 : break;
117 : case PROP_UNO_REGEXENABLED:
118 33 : rOptions.SetFormulaRegexEnabled( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
119 33 : break;
120 : default:;
121 : }
122 286 : return sal_True;
123 : }
124 :
125 345 : uno::Any ScDocOptionsHelper::getPropertyValue(
126 : const ScDocOptions& rOptions,
127 : const SfxItemPropertyMap& rPropMap,
128 : const rtl::OUString& aPropertyName )
129 : {
130 345 : uno::Any aRet;
131 345 : const SfxItemPropertySimpleEntry* pEntry = rPropMap.getByName( aPropertyName );
132 345 : if( !pEntry || !pEntry->nWID )
133 327 : return aRet;
134 18 : switch( pEntry->nWID )
135 : {
136 : case PROP_UNO_CALCASSHOWN :
137 2 : ScUnoHelpFunctions::SetBoolInAny( aRet, rOptions.IsCalcAsShown() );
138 2 : break;
139 : case PROP_UNO_DEFTABSTOP :
140 0 : aRet <<= (sal_Int16)( rOptions.GetTabDistance() );
141 0 : break;
142 : case PROP_UNO_IGNORECASE :
143 2 : ScUnoHelpFunctions::SetBoolInAny( aRet, rOptions.IsIgnoreCase() );
144 2 : break;
145 : case PROP_UNO_ITERENABLED:
146 2 : ScUnoHelpFunctions::SetBoolInAny( aRet, rOptions.IsIter() );
147 2 : break;
148 : case PROP_UNO_ITERCOUNT:
149 2 : aRet <<= (sal_Int32)( rOptions.GetIterCount() );
150 2 : break;
151 : case PROP_UNO_ITEREPSILON:
152 2 : aRet <<= (double)( rOptions.GetIterEps() );
153 2 : break;
154 : case PROP_UNO_LOOKUPLABELS:
155 2 : ScUnoHelpFunctions::SetBoolInAny( aRet, rOptions.IsLookUpColRowNames() );
156 2 : break;
157 : case PROP_UNO_MATCHWHOLE:
158 2 : ScUnoHelpFunctions::SetBoolInAny( aRet, rOptions.IsMatchWholeCell() );
159 2 : break;
160 : case PROP_UNO_NULLDATE:
161 : {
162 : sal_uInt16 nD, nM, nY;
163 2 : rOptions.GetDate( nD, nM, nY );
164 2 : util::Date aDate( nD, nM, nY );
165 2 : aRet <<= aDate;
166 : }
167 2 : break;
168 : case PROP_UNO_SPELLONLINE:
169 0 : ScUnoHelpFunctions::SetBoolInAny( aRet, rOptions.IsAutoSpell() );
170 0 : break;
171 : case PROP_UNO_STANDARDDEC :
172 0 : aRet <<= (sal_Int16)( rOptions.GetStdPrecision() );
173 0 : break;
174 : case PROP_UNO_REGEXENABLED:
175 2 : ScUnoHelpFunctions::SetBoolInAny( aRet, rOptions.IsFormulaRegexEnabled() );
176 2 : break;
177 : default:;
178 : }
179 18 : return aRet;
180 : }
181 :
182 : //------------------------------------------------------------------------
183 :
184 0 : ScDocOptionsObj::ScDocOptionsObj( const ScDocOptions& rOpt ) :
185 : ScModelObj( NULL ),
186 0 : aOptions( rOpt )
187 : {
188 0 : }
189 :
190 0 : ScDocOptionsObj::~ScDocOptionsObj()
191 : {
192 0 : }
193 :
194 0 : void SAL_CALL ScDocOptionsObj::setPropertyValue(
195 : const rtl::OUString& aPropertyName, const uno::Any& aValue )
196 : throw(beans::UnknownPropertyException, beans::PropertyVetoException,
197 : lang::IllegalArgumentException, lang::WrappedTargetException,
198 : uno::RuntimeException)
199 : {
200 0 : SolarMutexGuard aGuard;
201 :
202 0 : sal_Bool bDone = ScDocOptionsHelper::setPropertyValue( aOptions, GetPropertySet().getPropertyMap(), aPropertyName, aValue );
203 :
204 0 : if (!bDone)
205 0 : ScModelObj::setPropertyValue( aPropertyName, aValue );
206 0 : }
207 :
208 0 : uno::Any SAL_CALL ScDocOptionsObj::getPropertyValue( const rtl::OUString& aPropertyName )
209 : throw(beans::UnknownPropertyException, lang::WrappedTargetException,
210 : uno::RuntimeException)
211 : {
212 0 : SolarMutexGuard aGuard;
213 :
214 0 : uno::Any aRet(ScDocOptionsHelper::getPropertyValue( aOptions, GetPropertySet().getPropertyMap(), aPropertyName ));
215 0 : if ( !aRet.hasValue() )
216 0 : aRet = ScModelObj::getPropertyValue( aPropertyName );
217 :
218 0 : return aRet;
219 : }
220 :
221 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|