/* -*- 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 .
*/
sal_Bool SAL_CALL OPropertyBag::has( const Any& /*aElement*/ )
{ // XSet is only a workaround for addProperty not being able to add default-void properties. // So, everything of XSet except insert is implemented empty returnfalse;
}
void SAL_CALL OPropertyBag::insert( const Any& _element )
{ // This is a workaround for addProperty not being able to add default-void properties. // If we ever have a smarter XPropertyContainer::addProperty interface, we can remove this, ehm, well, hack.
Property aProperty; if ( !( _element >>= aProperty ) ) throw IllegalArgumentException( u"element is not Property"_ustr, *this, 1 );
{
osl::MutexGuard g(m_aMutex);
// check whether the type is allowed, everything else will be checked // by m_aDynamicProperties if (!m_aAllowedTypes.empty()
&& m_aAllowedTypes.find(aProperty.Type) == m_aAllowedTypes.end()) throw IllegalArgumentException(u"not in list of allowed types"_ustr, *this, 1);
// our property info is dirty
m_pArrayHelper.reset();
}
setModified(true);
}
void SAL_CALL OPropertyBag::remove( const Any& /*aElement*/ )
{ // XSet is only a workaround for addProperty not being able to add default-void properties. // So, everything of XSet except insert is implemented empty throw NoSuchElementException( OUString(), *this );
}
Reference< XEnumeration > SAL_CALL OPropertyBag::createEnumeration( )
{ // XSet is only a workaround for addProperty not being able to add default-void properties. // So, everything of XSet except insert is implemented empty return nullptr;
}
Type SAL_CALL OPropertyBag::getElementType( )
{ // XSet is only a workaround for addProperty not being able to add default-void properties. // So, everything of XSet except insert is implemented empty return Type();
}
sal_Bool SAL_CALL OPropertyBag::hasElements( )
{ // XSet is only a workaround for addProperty not being able to add default-void properties. // So, everything of XSet except insert is implemented empty returnfalse;
}
if ( nCheck == 1 )
{ // uh ... we already have 1008 handles used up // -> simply count upwards while ( m_aDynamicProperties.hasPropertyByHandle( nCheck ) )
++nCheck;
}
// check whether the type is allowed, everything else will be checked // by m_aDynamicProperties const Type& aPropertyType = _rInitialValue.getValueType(); if (_rInitialValue.hasValue() && !m_aAllowedTypes.empty()
&& m_aAllowedTypes.find(aPropertyType) == m_aAllowedTypes.end()) throw IllegalTypeException(OUString(), *this);
// a sequence of names
Sequence< OUString > aNames( aProperties.getLength() );
std::transform(
std::cbegin(aProperties),
std::cend(aProperties),
aNames.getArray(),
TransformPropertyToName< PropertyValue >()
);
try
{ // check for unknown properties // we cannot simply rely on the XMultiPropertySet::setPropertyValues // implementation of our base class, since it does not throw // an UnknownPropertyException. More precise, XMultiPropertySet::setPropertyValues // does not allow to throw this exception, while XPropertyAccess::setPropertyValues // requires it
sal_Int32 nCount = aNames.getLength();
Sequence< sal_Int32 > aHandles( nCount );
sal_Int32* pHandles = aHandles.getArray(); for (sal_Int32 i = 0; i < nCount; ++i)
{
::cppu::IPropertyArrayHelper& rPropInfo = getInfoHelper();
pHandles[i] = rPropInfo.getHandleByName(aNames[i]); if (pHandles[i] != -1) continue;
// there's a property requested which we do not know if ( m_bAutoAddProperties )
{ // add the property
sal_Int16 const nAttributes = PropertyAttribute::BOUND | PropertyAttribute::REMOVABLE | PropertyAttribute::MAYBEDEFAULT;
addProperty(aNames[i], nAttributes, aProperties[i].Value); continue;
}
// no way out throw UnknownPropertyException(aNames[i], *this);
}
// a sequence of values
Sequence< Any > aValues( aProperties.getLength() );
std::transform(
std::cbegin(aProperties),
std::cend(aProperties),
aValues.getArray(),
ExtractPropertyValue()
);
PropertyState OPropertyBag::getPropertyStateByHandle( sal_Int32 _nHandle )
{ // for properties which do not support the MAYBEDEFAULT attribute, don't rely on the base class, but // assume they're always in DIRECT state. // (Note that this probably would belong into the base class. However, this would mean we would need // to check all existent usages of the base class, where MAYBEDEFAULT is *not* set, but // a default is nonetheless supplied/used. This is hard to accomplish reliably, in the // current phase. #i78593#
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.