1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <svl/itemprop.hxx>
#include <vcl/svapp.hxx>
#include <com/sun/star/util/Date.hpp>
#include <optuno.hxx>
#include <miscuno.hxx>
#include <unonames.hxx>
#include <docoptio.hxx>
using namespace com::sun::star;
const SfxItemPropertyMapEntry* ScDocOptionsHelper::GetPropertyMap()
{
static const SfxItemPropertyMapEntry aMap[] =
{
{OUString(SC_UNO_CALCASSHOWN), PROP_UNO_CALCASSHOWN , cppu::UnoType<bool>::get(), 0, 0},
{OUString(SC_UNO_DEFTABSTOP), PROP_UNO_DEFTABSTOP , cppu::UnoType<sal_Int16>::get(), 0, 0},
{OUString(SC_UNO_IGNORECASE), PROP_UNO_IGNORECASE , cppu::UnoType<bool>::get(), 0, 0},
{OUString(SC_UNO_ITERENABLED), PROP_UNO_ITERENABLED , cppu::UnoType<bool>::get(), 0, 0},
{OUString(SC_UNO_ITERCOUNT), PROP_UNO_ITERCOUNT , cppu::UnoType<sal_Int32>::get(), 0, 0},
{OUString(SC_UNO_ITEREPSILON), PROP_UNO_ITEREPSILON , cppu::UnoType<double>::get(), 0, 0},
{OUString(SC_UNO_LOOKUPLABELS), PROP_UNO_LOOKUPLABELS, cppu::UnoType<bool>::get(), 0, 0},
{OUString(SC_UNO_MATCHWHOLE), PROP_UNO_MATCHWHOLE , cppu::UnoType<bool>::get(), 0, 0},
{OUString(SC_UNO_NULLDATE), PROP_UNO_NULLDATE , cppu::UnoType<util::Date>::get(), 0, 0},
{OUString(SC_UNO_SPELLONLINE), PROP_UNO_SPELLONLINE , cppu::UnoType<bool>::get(), 0, 0},
{OUString(SC_UNO_STANDARDDEC), PROP_UNO_STANDARDDEC , cppu::UnoType<sal_Int16>::get(), 0, 0},
{OUString(SC_UNO_REGEXENABLED), PROP_UNO_REGEXENABLED, cppu::UnoType<bool>::get(), 0, 0},
{OUString(SC_UNO_WILDCARDSENABLED), PROP_UNO_WILDCARDSENABLED, cppu::UnoType<bool>::get(), 0, 0},
{ OUString(), 0, css::uno::Type(), 0, 0 }
};
return aMap;
}
bool ScDocOptionsHelper::setPropertyValue( ScDocOptions& rOptions,
const SfxItemPropertyMap& rPropMap,
const OUString& aPropertyName, const uno::Any& aValue )
{
//! use map (with new identifiers)
const SfxItemPropertySimpleEntry* pEntry = rPropMap.getByName(aPropertyName );
if( !pEntry || !pEntry->nWID )
return false;
switch( pEntry->nWID )
{
case PROP_UNO_CALCASSHOWN :
rOptions.SetCalcAsShown( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
break;
case PROP_UNO_DEFTABSTOP :
{
sal_Int16 nIntVal = 0;
if ( aValue >>= nIntVal )
rOptions.SetTabDistance( nIntVal );
}
break;
case PROP_UNO_IGNORECASE :
rOptions.SetIgnoreCase( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
break;
case PROP_UNO_ITERENABLED:
rOptions.SetIter( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
break;
case PROP_UNO_ITERCOUNT :
{
sal_Int32 nIntVal = 0;
if ( aValue >>= nIntVal )
rOptions.SetIterCount( static_cast<sal_uInt16>(nIntVal) );
}
break;
case PROP_UNO_ITEREPSILON :
{
double fDoubleVal = 0;
if ( aValue >>= fDoubleVal )
rOptions.SetIterEps( fDoubleVal );
}
break;
case PROP_UNO_LOOKUPLABELS :
rOptions.SetLookUpColRowNames( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
break;
case PROP_UNO_MATCHWHOLE :
rOptions.SetMatchWholeCell( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
break;
case PROP_UNO_NULLDATE:
{
util::Date aDate;
if ( aValue >>= aDate )
rOptions.SetDate( aDate.Day, aDate.Month, aDate.Year );
}
break;
case PROP_UNO_SPELLONLINE:
rOptions.SetAutoSpell( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
break;
case PROP_UNO_STANDARDDEC:
{
sal_Int16 nIntVal = 0;
if ( aValue >>= nIntVal )
rOptions.SetStdPrecision( nIntVal );
}
break;
case PROP_UNO_REGEXENABLED:
rOptions.SetFormulaRegexEnabled( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
break;
case PROP_UNO_WILDCARDSENABLED:
rOptions.SetFormulaWildcardsEnabled( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
break;
default:;
}
return true;
}
uno::Any ScDocOptionsHelper::getPropertyValue(
const ScDocOptions& rOptions,
const SfxItemPropertyMap& rPropMap,
const OUString& aPropertyName )
{
uno::Any aRet;
const SfxItemPropertySimpleEntry* pEntry = rPropMap.getByName( aPropertyName );
if( !pEntry || !pEntry->nWID )
return aRet;
switch( pEntry->nWID )
{
case PROP_UNO_CALCASSHOWN :
aRet <<= rOptions.IsCalcAsShown();
break;
case PROP_UNO_DEFTABSTOP :
aRet <<= static_cast<sal_Int16>( rOptions.GetTabDistance() );
break;
case PROP_UNO_IGNORECASE :
aRet <<= rOptions.IsIgnoreCase();
break;
case PROP_UNO_ITERENABLED:
aRet <<= rOptions.IsIter();
break;
case PROP_UNO_ITERCOUNT:
aRet <<= static_cast<sal_Int32>( rOptions.GetIterCount() );
break;
case PROP_UNO_ITEREPSILON:
aRet <<= rOptions.GetIterEps();
break;
case PROP_UNO_LOOKUPLABELS:
aRet <<= rOptions.IsLookUpColRowNames();
break;
case PROP_UNO_MATCHWHOLE:
aRet <<= rOptions.IsMatchWholeCell();
break;
case PROP_UNO_NULLDATE:
{
sal_uInt16 nD, nM;
sal_Int16 nY;
rOptions.GetDate( nD, nM, nY );
util::Date aDate( nD, nM, nY );
aRet <<= aDate;
}
break;
case PROP_UNO_SPELLONLINE:
aRet <<= rOptions.IsAutoSpell();
break;
case PROP_UNO_STANDARDDEC :
aRet <<= static_cast<sal_Int16>( rOptions.GetStdPrecision() );
break;
case PROP_UNO_REGEXENABLED:
aRet <<= rOptions.IsFormulaRegexEnabled();
break;
case PROP_UNO_WILDCARDSENABLED:
aRet <<= rOptions.IsFormulaWildcardsEnabled();
break;
default:;
}
return aRet;
}
ScDocOptionsObj::ScDocOptionsObj( const ScDocOptions& rOpt ) :
ScModelObj( nullptr ),
aOptions( rOpt )
{
}
ScDocOptionsObj::~ScDocOptionsObj()
{
}
void SAL_CALL ScDocOptionsObj::setPropertyValue(
const OUString& aPropertyName, const uno::Any& aValue )
{
SolarMutexGuard aGuard;
bool bDone = ScDocOptionsHelper::setPropertyValue( aOptions, GetPropertySet().getPropertyMap(), aPropertyName, aValue );
if (!bDone)
ScModelObj::setPropertyValue( aPropertyName, aValue );
}
uno::Any SAL_CALL ScDocOptionsObj::getPropertyValue( const OUString& aPropertyName )
{
SolarMutexGuard aGuard;
uno::Any aRet(ScDocOptionsHelper::getPropertyValue( aOptions, GetPropertySet().getPropertyMap(), aPropertyName ));
if ( !aRet.hasValue() )
aRet = ScModelObj::getPropertyValue( aPropertyName );
return aRet;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|