2010-10-14 08:27:31 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-06-29 14:02:24 +01:00
|
|
|
/*
|
|
|
|
* 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 .
|
|
|
|
*/
|
2006-09-17 16:17:01 +00:00
|
|
|
|
2001-07-24 19:36:11 +00:00
|
|
|
#include <comphelper/ChainablePropertySetInfo.hxx>
|
2015-04-22 09:42:28 +02:00
|
|
|
#include <sal/log.hxx>
|
2001-07-24 19:36:11 +00:00
|
|
|
|
|
|
|
using ::comphelper::PropertyInfo;
|
|
|
|
using ::comphelper::ChainablePropertySetInfo;
|
|
|
|
using ::com::sun::star::uno::Any;
|
|
|
|
using ::com::sun::star::uno::Type;
|
|
|
|
using ::com::sun::star::uno::Sequence;
|
|
|
|
using ::com::sun::star::uno::Reference;
|
|
|
|
using ::com::sun::star::uno::XInterface;
|
|
|
|
using ::com::sun::star::uno::RuntimeException;
|
|
|
|
using ::com::sun::star::beans::Property;
|
|
|
|
using ::com::sun::star::beans::XPropertySetInfo;
|
|
|
|
using ::com::sun::star::beans::UnknownPropertyException;
|
|
|
|
|
2013-12-12 12:31:38 +01:00
|
|
|
ChainablePropertySetInfo::ChainablePropertySetInfo( PropertyInfo const * pMap )
|
2001-07-24 19:36:11 +00:00
|
|
|
{
|
2013-12-12 12:48:55 +01:00
|
|
|
for( ; !pMap->maName.isEmpty(); ++pMap )
|
|
|
|
{
|
|
|
|
SAL_WARN_IF(
|
|
|
|
maMap.find(pMap->maName) != maMap.end(),
|
|
|
|
"comphelper", "Duplicate property name \"" << pMap->maName << "\"");
|
|
|
|
maMap[pMap->maName] = pMap;
|
|
|
|
}
|
2001-07-24 19:36:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ChainablePropertySetInfo::~ChainablePropertySetInfo()
|
|
|
|
throw()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
void ChainablePropertySetInfo::remove( const OUString& aName )
|
2001-07-24 19:36:11 +00:00
|
|
|
{
|
|
|
|
maMap.erase ( aName );
|
|
|
|
if ( maProperties.getLength() )
|
|
|
|
maProperties.realloc( 0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
Sequence< ::Property > SAL_CALL ChainablePropertySetInfo::getProperties()
|
2014-02-25 21:31:58 +01:00
|
|
|
throw(::com::sun::star::uno::RuntimeException, std::exception)
|
2001-07-24 19:36:11 +00:00
|
|
|
{
|
|
|
|
sal_Int32 nSize = maMap.size();
|
|
|
|
if( maProperties.getLength() != nSize )
|
|
|
|
{
|
|
|
|
maProperties.realloc ( nSize );
|
|
|
|
Property* pProperties = maProperties.getArray();
|
|
|
|
|
2013-03-29 07:12:02 +01:00
|
|
|
for (PropertyInfoHash::const_iterator aIter(maMap.begin()), aEnd(maMap.end()); aIter != aEnd; ++aIter, ++pProperties)
|
2001-07-24 19:36:11 +00:00
|
|
|
{
|
2013-12-12 12:31:38 +01:00
|
|
|
PropertyInfo const * pInfo = (*aIter).second;
|
2001-07-24 19:36:11 +00:00
|
|
|
|
2013-12-12 12:31:38 +01:00
|
|
|
pProperties->Name = pInfo->maName;
|
2001-07-24 19:36:11 +00:00
|
|
|
pProperties->Handle = pInfo->mnHandle;
|
2013-12-12 12:31:38 +01:00
|
|
|
pProperties->Type = pInfo->maType;
|
2001-07-24 19:36:11 +00:00
|
|
|
pProperties->Attributes = pInfo->mnAttributes;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return maProperties;
|
|
|
|
}
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
Property SAL_CALL ChainablePropertySetInfo::getPropertyByName( const OUString& rName )
|
2014-02-25 21:31:58 +01:00
|
|
|
throw(::UnknownPropertyException, ::com::sun::star::uno::RuntimeException, std::exception)
|
2001-07-24 19:36:11 +00:00
|
|
|
{
|
2004-09-08 14:48:49 +00:00
|
|
|
PropertyInfoHash::iterator aIter = maMap.find( rName );
|
2001-07-24 19:36:11 +00:00
|
|
|
|
|
|
|
if ( maMap.end() == aIter )
|
2008-12-01 12:31:27 +00:00
|
|
|
throw UnknownPropertyException( rName, *this );
|
2001-07-24 19:36:11 +00:00
|
|
|
|
2013-12-12 12:31:38 +01:00
|
|
|
PropertyInfo const *pInfo = (*aIter).second;
|
2001-07-24 19:36:11 +00:00
|
|
|
Property aProperty;
|
2013-12-12 12:31:38 +01:00
|
|
|
aProperty.Name = pInfo->maName;
|
2001-07-24 19:36:11 +00:00
|
|
|
aProperty.Handle = pInfo->mnHandle;
|
2013-12-12 12:31:38 +01:00
|
|
|
aProperty.Type = pInfo->maType;
|
2001-07-24 19:36:11 +00:00
|
|
|
aProperty.Attributes = pInfo->mnAttributes;
|
|
|
|
return aProperty;
|
|
|
|
}
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
sal_Bool SAL_CALL ChainablePropertySetInfo::hasPropertyByName( const OUString& rName )
|
2014-02-25 21:31:58 +01:00
|
|
|
throw(::com::sun::star::uno::RuntimeException, std::exception)
|
2001-07-24 19:36:11 +00:00
|
|
|
{
|
2014-02-16 22:51:15 +01:00
|
|
|
return maMap.find ( rName ) != maMap.end();
|
2001-07-24 19:36:11 +00:00
|
|
|
}
|
2010-10-14 08:27:31 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|