22#include <com/sun/star/xsd/DataTypeClass.hpp>
23#include <com/sun/star/xsd/XDataType.hpp>
24#include <com/sun/star/beans/XPropertySet.hpp>
26#include <osl/diagnose.h>
38 template<
typename INTERFACE,
typename ARGUMENT >
39 static ARGUMENT
getSave( INTERFACE* pObject, ARGUMENT ( SAL_CALL INTERFACE::*pGetter )( ) )
41 ARGUMENT aReturn = ARGUMENT();
44 aReturn = (
pObject->*pGetter)( );
54 :m_xDataType( _rxDataType )
56 DBG_ASSERT( m_xDataType.is(),
"XSDDataType::XSDDataType: invalid UNO object!" );
57 if ( m_xDataType.is() )
58 m_xFacetInfo = m_xDataType->getPropertySetInfo();
62 XSDDataType::~XSDDataType()
67 sal_Int16 XSDDataType::classify()
const
69 sal_Int16 nTypeClass = DataTypeClass::STRING;
72 if ( m_xDataType.is() )
73 nTypeClass = m_xDataType->getTypeClass();
83 bool XSDDataType::isBasicType()
const
85 return getSave( m_xDataType.get(), &XDataType::getIsBasic );
89 OUString XSDDataType::getName()
const
91 return getSave( m_xDataType.get(), &XDataType::getName );
95 void XSDDataType::setFacet(
const OUString& _rFacetName,
const Any& _rValue )
99 m_xDataType->setPropertyValue( _rFacetName, _rValue );
103 TOOLS_WARN_EXCEPTION(
"extensions.propctrlr",
"XSDDataType::setFacet: caught an exception - sure this is the right data type class for this property?" );
108 bool XSDDataType::hasFacet(
const OUString& _rFacetName )
const
110 bool bReturn =
false;
113 bReturn = m_xFacetInfo.is() && m_xFacetInfo->hasPropertyByName( _rFacetName );
122 Any XSDDataType::getFacet(
const OUString& _rFacetName )
127 aReturn = m_xDataType->getPropertyValue( _rFacetName );
131 TOOLS_WARN_EXCEPTION(
"extensions.propctrlr",
"XSDDataType::getFacet: caught an exception - sure this is the right data type class for this property?" );
139 void lcl_copyProperties(
const Reference< XPropertySet >& _rxSource,
const Reference< XPropertySet >& _rxDest )
141 Reference< XPropertySetInfo > xSourceInfo;
142 if ( _rxSource.is() )
143 xSourceInfo = _rxSource->getPropertySetInfo();
144 Reference< XPropertySetInfo > xDestInfo;
146 xDestInfo = _rxDest->getPropertySetInfo();
147 OSL_ENSURE( xSourceInfo.is() && xDestInfo.is(),
"lcl_copyProperties: invalid property set( info)s!" );
148 if ( !xSourceInfo.is() || !xDestInfo.is() )
151 Sequence< Property >
aProperties( xSourceInfo->getProperties() );
154 for ( ; pProperties != pPropertiesEnd; ++pProperties )
156 if ( xDestInfo->hasPropertyByName( pProperties->Name ) )
157 _rxDest->setPropertyValue( pProperties->Name, _rxSource->getPropertyValue( pProperties->Name ) );
163 void XSDDataType::copyFacetsFrom( const ::rtl::Reference< XSDDataType >& _pSourceType )
165 OSL_ENSURE( _pSourceType.is(),
"XSDDataType::copyFacetsFrom: invalid source type!" );
166 if ( !_pSourceType.is() )
171 Reference< XPropertySet > xSource = _pSourceType->getUnoDataType();
172 Reference< XPropertySet > xDest = getUnoDataType();
173 lcl_copyProperties( xSource, xDest );
PropertiesInfo aProperties
XSDDataType(const css::uno::Reference< css::xsd::XDataType > &_rxDataType)
#define DBG_ASSERT(sCon, aError)
#define TOOLS_WARN_EXCEPTION(area, stream)
EmbeddedObjectRef * pObject
a property handler for any virtual string properties
static ARGUMENT getSave(INTERFACE *pObject, ARGUMENT(SAL_CALL INTERFACE::*pGetter)())