tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / sc / source / ui / unoobj / optuno.cxx
blob3d475f74ef8c507c684a5b1be5daea1d49099650
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
25 #include <optuno.hxx>
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 )
39 return false;
40 switch( pEntry->nWID )
42 case PROP_UNO_CALCASSHOWN :
43 rOptions.SetCalcAsShown( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
44 break;
45 case PROP_UNO_DEFTABSTOP :
47 sal_Int16 nIntVal = 0;
48 if ( aValue >>= nIntVal )
49 rOptions.SetTabDistance( nIntVal );
51 break;
52 case PROP_UNO_IGNORECASE :
53 rOptions.SetIgnoreCase( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
54 break;
55 case PROP_UNO_ITERENABLED:
56 rOptions.SetIter( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
57 break;
58 case PROP_UNO_ITERCOUNT :
60 sal_Int32 nIntVal = 0;
61 if ( aValue >>= nIntVal )
62 rOptions.SetIterCount( static_cast<sal_uInt16>(nIntVal) );
64 break;
65 case PROP_UNO_ITEREPSILON :
67 double fDoubleVal = 0;
68 if ( aValue >>= fDoubleVal )
69 rOptions.SetIterEps( fDoubleVal );
71 break;
72 case PROP_UNO_LOOKUPLABELS :
73 rOptions.SetLookUpColRowNames( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
74 break;
75 case PROP_UNO_MATCHWHOLE :
76 rOptions.SetMatchWholeCell( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
77 break;
78 case PROP_UNO_NULLDATE:
80 util::Date aDate;
81 if ( aValue >>= aDate )
82 rOptions.SetDate( aDate.Day, aDate.Month, aDate.Year );
84 break;
85 case PROP_UNO_STANDARDDEC:
87 sal_Int16 nIntVal = 0;
88 if ( aValue >>= nIntVal )
89 rOptions.SetStdPrecision( nIntVal );
91 break;
92 case PROP_UNO_REGEXENABLED:
93 rOptions.SetFormulaRegexEnabled( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
94 break;
95 case PROP_UNO_WILDCARDSENABLED:
96 rOptions.SetFormulaWildcardsEnabled( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
97 break;
98 default:;
100 return true;
103 uno::Any ScDocOptionsHelper::getPropertyValue(
104 const ScDocOptions& rOptions,
105 const SfxItemPropertyMap& rPropMap,
106 const OUString& aPropertyName )
108 uno::Any aRet;
109 const SfxItemPropertyMapEntry* pEntry = rPropMap.getByName( aPropertyName );
110 if( !pEntry || !pEntry->nWID )
111 return aRet;
112 switch( pEntry->nWID )
114 case PROP_UNO_CALCASSHOWN :
115 aRet <<= rOptions.IsCalcAsShown();
116 break;
117 case PROP_UNO_DEFTABSTOP :
118 aRet <<= static_cast<sal_Int16>( rOptions.GetTabDistance() );
119 break;
120 case PROP_UNO_IGNORECASE :
121 aRet <<= rOptions.IsIgnoreCase();
122 break;
123 case PROP_UNO_ITERENABLED:
124 aRet <<= rOptions.IsIter();
125 break;
126 case PROP_UNO_ITERCOUNT:
127 aRet <<= static_cast<sal_Int32>( rOptions.GetIterCount() );
128 break;
129 case PROP_UNO_ITEREPSILON:
130 aRet <<= rOptions.GetIterEps();
131 break;
132 case PROP_UNO_LOOKUPLABELS:
133 aRet <<= rOptions.IsLookUpColRowNames();
134 break;
135 case PROP_UNO_MATCHWHOLE:
136 aRet <<= rOptions.IsMatchWholeCell();
137 break;
138 case PROP_UNO_NULLDATE:
140 sal_uInt16 nD, nM;
141 sal_Int16 nY;
142 rOptions.GetDate( nD, nM, nY );
143 util::Date aDate( nD, nM, nY );
144 aRet <<= aDate;
146 break;
147 case PROP_UNO_STANDARDDEC :
148 aRet <<= static_cast<sal_Int16>( rOptions.GetStdPrecision() );
149 break;
150 case PROP_UNO_REGEXENABLED:
151 aRet <<= rOptions.IsFormulaRegexEnabled();
152 break;
153 case PROP_UNO_WILDCARDSENABLED:
154 aRet <<= rOptions.IsFormulaWildcardsEnabled();
155 break;
156 default:;
158 return aRet;
161 ScDocOptionsObj::ScDocOptionsObj( const ScDocOptions& rOpt ) :
162 ScModelObj( nullptr ),
163 aOptions( rOpt )
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 );
178 if (!bDone)
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 );
190 return aRet;
193 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */