Kaydet (Commit) 3a3ead44 authored tarafından Jens-Heiner Rechtien's avatar Jens-Heiner Rechtien

INTEGRATION: CWS warnings01 (1.13.220); FILE MERGED

2006/03/07 08:16:08 fs 1.13.220.3: warning-free code
2006/02/16 12:13:46 fs 1.13.220.2: #i55991# warning-free code (unxsols4)
2006/01/05 12:02:24 fs 1.13.220.1: #i55991# warning-free code
üst 268bdae1
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
* *
* $RCSfile: dataaccessdescriptor.cxx,v $ * $RCSfile: dataaccessdescriptor.cxx,v $
* *
* $Revision: 1.13 $ * $Revision: 1.14 $
* *
* last change: $Author: rt $ $Date: 2005-09-08 22:48:30 $ * last change: $Author: hr $ $Date: 2006-06-19 15:51:30 $
* *
* The Contents of this file are made available subject to * The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1. * the terms of GNU Lesser General Public License Version 2.1.
...@@ -72,9 +72,6 @@ namespace svx ...@@ -72,9 +72,6 @@ namespace svx
using namespace ::com::sun::star::ucb; using namespace ::com::sun::star::ucb;
using namespace ::comphelper; using namespace ::comphelper;
//====================================================================
//=
//====================================================================
#define CONST_CHAR( propname ) propname, sizeof(propname) - 1 #define CONST_CHAR( propname ) propname, sizeof(propname) - 1
#ifndef SVX_LIGHT #ifndef SVX_LIGHT
...@@ -88,11 +85,13 @@ namespace svx ...@@ -88,11 +85,13 @@ namespace svx
sal_Bool m_bSequenceOutOfDate : 1; sal_Bool m_bSequenceOutOfDate : 1;
public: public:
DECLARE_STL_STDKEY_MAP( DataAccessDescriptorProperty, Any, DescriptorValues ); typedef ::std::map< DataAccessDescriptorProperty, Any > DescriptorValues;
DescriptorValues m_aValues; DescriptorValues m_aValues;
Sequence< PropertyValue > m_aAsSequence; Sequence< PropertyValue > m_aAsSequence;
Reference< XPropertySet > m_xAsSet; Reference< XPropertySet > m_xAsSet;
typedef ::std::map< ::rtl::OUString, PropertyMapEntry* > MapString2PropertyEntry;
public: public:
ODADescriptorImpl(); ODADescriptorImpl();
ODADescriptorImpl(const ODADescriptorImpl& _rSource); ODADescriptorImpl(const ODADescriptorImpl& _rSource);
...@@ -115,9 +114,9 @@ namespace svx ...@@ -115,9 +114,9 @@ namespace svx
sal_Bool buildFrom( const Reference< XPropertySet >& _rValues ); sal_Bool buildFrom( const Reference< XPropertySet >& _rValues );
protected: protected:
PropertyValue buildPropertyValue( const ConstDescriptorValuesIterator& _rPos ); static PropertyValue buildPropertyValue( const DescriptorValues::const_iterator& _rPos );
PropertyMapEntry* getPropertyMap( ) const; static const MapString2PropertyEntry& getPropertyMap( );
PropertyMapEntry* getPropertyMapEntry( const ConstDescriptorValuesIterator& _rPos ) const; static PropertyMapEntry* getPropertyMapEntry( const DescriptorValues::const_iterator& _rPos );
}; };
//-------------------------------------------------------------------- //--------------------------------------------------------------------
...@@ -129,9 +128,9 @@ namespace svx ...@@ -129,9 +128,9 @@ namespace svx
//-------------------------------------------------------------------- //--------------------------------------------------------------------
ODADescriptorImpl::ODADescriptorImpl(const ODADescriptorImpl& _rSource) ODADescriptorImpl::ODADescriptorImpl(const ODADescriptorImpl& _rSource)
:m_aValues( _rSource.m_aValues ) :m_bSetOutOfDate( _rSource.m_bSetOutOfDate )
,m_bSetOutOfDate( _rSource.m_bSetOutOfDate )
,m_bSequenceOutOfDate( _rSource.m_bSequenceOutOfDate ) ,m_bSequenceOutOfDate( _rSource.m_bSequenceOutOfDate )
,m_aValues( _rSource.m_aValues )
{ {
if (!m_bSetOutOfDate) if (!m_bSetOutOfDate)
m_xAsSet = _rSource.m_xAsSet; m_xAsSet = _rSource.m_xAsSet;
...@@ -139,32 +138,10 @@ namespace svx ...@@ -139,32 +138,10 @@ namespace svx
m_aAsSequence = _rSource.m_aAsSequence; m_aAsSequence = _rSource.m_aAsSequence;
} }
//--------------------------------------------------------------------
// Vergleichen von Strings
static int
#if defined( WNT )
__cdecl
#endif
#if defined( ICC ) && defined( OS2 )
_Optlink
#endif
PropertySearch(const void* pFirst, const void* pSecond)
{
return static_cast<const PropertyValue*>(pFirst)->Name.compareToAscii(
static_cast<const PropertyMapEntry*>(pSecond)->mpName);
}
//-------------------------------------------------------------------- //--------------------------------------------------------------------
sal_Bool ODADescriptorImpl::buildFrom( const Sequence< PropertyValue >& _rValues ) sal_Bool ODADescriptorImpl::buildFrom( const Sequence< PropertyValue >& _rValues )
{ {
PropertyMapEntry* pPropertyMap = getPropertyMap(); const MapString2PropertyEntry& rProperties = getPropertyMap();
// determine the size of the map
sal_Int32 nMapSize = 0;
PropertyMapEntry* pMapLoop = pPropertyMap;
while (pMapLoop->mpName)
{
++nMapSize; ++pMapLoop;
}
sal_Bool bValidPropsOnly = sal_True; sal_Bool bValidPropsOnly = sal_True;
...@@ -173,10 +150,10 @@ namespace svx ...@@ -173,10 +150,10 @@ namespace svx
const PropertyValue* pValuesEnd = pValues + _rValues.getLength(); const PropertyValue* pValuesEnd = pValues + _rValues.getLength();
for (;pValues != pValuesEnd; ++pValues) for (;pValues != pValuesEnd; ++pValues)
{ {
PropertyMapEntry* pPropPos = static_cast<PropertyMapEntry*>(bsearch(pValues, pPropertyMap, nMapSize, sizeof(*pPropertyMap), PropertySearch)); MapString2PropertyEntry::const_iterator aPropPos = rProperties.find( pValues->Name );
if (pPropPos) if ( aPropPos != rProperties.end() )
{ {
DataAccessDescriptorProperty eProperty = (DataAccessDescriptorProperty)pPropPos->mnHandle; DataAccessDescriptorProperty eProperty = (DataAccessDescriptorProperty)aPropPos->second->mnHandle;
m_aValues[eProperty] = pValues->Value; m_aValues[eProperty] = pValues->Value;
} }
else else
...@@ -241,95 +218,73 @@ namespace svx ...@@ -241,95 +218,73 @@ namespace svx
} }
//-------------------------------------------------------------------- //--------------------------------------------------------------------
PropertyMapEntry* ODADescriptorImpl::getPropertyMap( ) const const ODADescriptorImpl::MapString2PropertyEntry& ODADescriptorImpl::getPropertyMap( )
{ {
// the properties we know // the properties we know
static PropertyMapEntry s_aDesriptorProperties[] = static MapString2PropertyEntry s_aProperties;
{ if ( s_aProperties.empty() )
{ CONST_CHAR("ActiveConnection"), daConnection, &::getCppuType( static_cast< Reference< XConnection >* >(NULL) ), PropertyAttribute::TRANSIENT, 0 },
{ CONST_CHAR("BookmarkSelection"), daBookmarkSelection, &::getBooleanCppuType( ), PropertyAttribute::TRANSIENT, 0 },
{ CONST_CHAR("Column"), daColumnObject, &::getCppuType( static_cast< Reference< XPropertySet >* >(NULL) ), PropertyAttribute::TRANSIENT, 0 },
{ CONST_CHAR("ColumnName"), daColumnName, &::getCppuType( static_cast< ::rtl::OUString* >(NULL) ), PropertyAttribute::TRANSIENT, 0 },
{ CONST_CHAR("Command"), daCommand, &::getCppuType( static_cast< ::rtl::OUString* >(NULL) ), PropertyAttribute::TRANSIENT, 0 },
{ CONST_CHAR("CommandType"), daCommandType, &::getCppuType( static_cast< sal_Int32* >(NULL) ), PropertyAttribute::TRANSIENT, 0 },
{ CONST_CHAR("Component"), daComponent, &::getCppuType( static_cast< Reference< XContent >* >(NULL) ), PropertyAttribute::TRANSIENT, 0 },
{ CONST_CHAR("ConnectionResource"), daConnectionResource, &::getCppuType( static_cast< ::rtl::OUString* >(NULL) ), PropertyAttribute::TRANSIENT, 0 },
{ CONST_CHAR("Cursor"), daCursor, &::getCppuType( static_cast< Reference< XResultSet>* >(NULL) ), PropertyAttribute::TRANSIENT, 0 },
{ CONST_CHAR("DataSourceName"), daDataSource, &::getCppuType( static_cast< ::rtl::OUString* >(NULL) ), PropertyAttribute::TRANSIENT, 0 },
{ CONST_CHAR("DatabaseLocation"), daDatabaseLocation, &::getCppuType( static_cast< ::rtl::OUString* >(NULL) ), PropertyAttribute::TRANSIENT, 0 },
{ CONST_CHAR("EscapeProcessing"), daEscapeProcessing, &::getBooleanCppuType( ), PropertyAttribute::TRANSIENT, 0 },
{ CONST_CHAR("Filter"), daFilter, &::getCppuType( static_cast< ::rtl::OUString* >(NULL) ), PropertyAttribute::TRANSIENT, 0 },
{ CONST_CHAR("Selection"), daSelection, &::getCppuType( static_cast< Sequence< Any >* >(NULL) ), PropertyAttribute::TRANSIENT, 0 },
{ NULL, 0, 0, NULL, 0, 0 }
};
// MUST be sorted !!
#if OSL_DEBUG_LEVEL > 0
PropertyMapEntry* pLoop = s_aDesriptorProperties;
if (pLoop->mpName)
{ {
::rtl::OUString sLeft = ::rtl::OUString::createFromAscii(pLoop->mpName); static PropertyMapEntry s_aDesriptorProperties[] =
::rtl::OUString sRight;
while ((++pLoop)->mpName)
{ {
sRight = ::rtl::OUString::createFromAscii(pLoop->mpName); { CONST_CHAR("ActiveConnection"), daConnection, &::getCppuType( static_cast< Reference< XConnection >* >(NULL) ), PropertyAttribute::TRANSIENT, 0 },
OSL_ENSURE(sLeft < sRight, "ODADescriptorImpl::getPropertyMap: property map not sorted!"); { CONST_CHAR("BookmarkSelection"), daBookmarkSelection, &::getBooleanCppuType( ), PropertyAttribute::TRANSIENT, 0 },
sLeft = sRight; { CONST_CHAR("Column"), daColumnObject, &::getCppuType( static_cast< Reference< XPropertySet >* >(NULL) ), PropertyAttribute::TRANSIENT, 0 },
{ CONST_CHAR("ColumnName"), daColumnName, &::getCppuType( static_cast< ::rtl::OUString* >(NULL) ), PropertyAttribute::TRANSIENT, 0 },
{ CONST_CHAR("Command"), daCommand, &::getCppuType( static_cast< ::rtl::OUString* >(NULL) ), PropertyAttribute::TRANSIENT, 0 },
{ CONST_CHAR("CommandType"), daCommandType, &::getCppuType( static_cast< sal_Int32* >(NULL) ), PropertyAttribute::TRANSIENT, 0 },
{ CONST_CHAR("Component"), daComponent, &::getCppuType( static_cast< Reference< XContent >* >(NULL) ), PropertyAttribute::TRANSIENT, 0 },
{ CONST_CHAR("ConnectionResource"), daConnectionResource, &::getCppuType( static_cast< ::rtl::OUString* >(NULL) ), PropertyAttribute::TRANSIENT, 0 },
{ CONST_CHAR("Cursor"), daCursor, &::getCppuType( static_cast< Reference< XResultSet>* >(NULL) ), PropertyAttribute::TRANSIENT, 0 },
{ CONST_CHAR("DataSourceName"), daDataSource, &::getCppuType( static_cast< ::rtl::OUString* >(NULL) ), PropertyAttribute::TRANSIENT, 0 },
{ CONST_CHAR("DatabaseLocation"), daDatabaseLocation, &::getCppuType( static_cast< ::rtl::OUString* >(NULL) ), PropertyAttribute::TRANSIENT, 0 },
{ CONST_CHAR("EscapeProcessing"), daEscapeProcessing, &::getBooleanCppuType( ), PropertyAttribute::TRANSIENT, 0 },
{ CONST_CHAR("Filter"), daFilter, &::getCppuType( static_cast< ::rtl::OUString* >(NULL) ), PropertyAttribute::TRANSIENT, 0 },
{ CONST_CHAR("Selection"), daSelection, &::getCppuType( static_cast< Sequence< Any >* >(NULL) ), PropertyAttribute::TRANSIENT, 0 },
{ NULL, 0, 0, NULL, 0, 0 }
};
PropertyMapEntry* pEntry = s_aDesriptorProperties;
while ( pEntry->mpName )
{
s_aProperties[ ::rtl::OUString::createFromAscii( pEntry->mpName ) ] = pEntry;
++pEntry;
} }
} }
#endif
return s_aDesriptorProperties; return s_aProperties;
} }
//-------------------------------------------------------------------- //--------------------------------------------------------------------
PropertyMapEntry* ODADescriptorImpl::getPropertyMapEntry( const ConstDescriptorValuesIterator& _rPos ) const PropertyMapEntry* ODADescriptorImpl::getPropertyMapEntry( const DescriptorValues::const_iterator& _rPos )
{ {
PropertyMapEntry* pMap = getPropertyMap(); const MapString2PropertyEntry& rProperties = getPropertyMap();
// the index in the map above (depends on the property requested)
sal_Int32 nNeededHandle = (sal_Int32)(_rPos->first); sal_Int32 nNeededHandle = (sal_Int32)(_rPos->first);
PropertyMapEntry* pSearchHandle = pMap; for ( MapString2PropertyEntry::const_iterator loop = rProperties.begin();
while (pSearchHandle->mpName) loop != rProperties.end();
++loop
)
{ {
if (nNeededHandle == pSearchHandle->mnHandle) if ( nNeededHandle == loop->second->mnHandle )
return pSearchHandle; return loop->second;
++pSearchHandle;
} }
OSL_ENSURE(sal_False, "ODADescriptorImpl::getPropertyMapEntry: could not find the property!"); throw RuntimeException();
return NULL;
} }
//-------------------------------------------------------------------- //--------------------------------------------------------------------
PropertyValue ODADescriptorImpl::buildPropertyValue( const ConstDescriptorValuesIterator& _rPos ) PropertyValue ODADescriptorImpl::buildPropertyValue( const DescriptorValues::const_iterator& _rPos )
{ {
// the map entry // the map entry
PropertyMapEntry* pProp = getPropertyMapEntry(_rPos); PropertyMapEntry* pProperty = getPropertyMapEntry( _rPos );
// build the property value // build the property value
PropertyValue aReturn; PropertyValue aReturn;
aReturn.Name = ::rtl::OUString::createFromAscii(pProp->mpName); aReturn.Name = ::rtl::OUString( pProperty->mpName, pProperty->mnNameLen, RTL_TEXTENCODING_ASCII_US );
aReturn.Handle = pProp->mnHandle; aReturn.Handle = pProperty->mnHandle;
aReturn.Value = _rPos->second; aReturn.Value = _rPos->second;
aReturn.State = PropertyState_DIRECT_VALUE; aReturn.State = PropertyState_DIRECT_VALUE;
#if OSL_DEBUG_LEVEL > 0
// check for type consistency
if (TypeClass_INTERFACE == pProp->mpType->getTypeClass())
{
Reference< XInterface > xCurrentValue;
_rPos->second >>= xCurrentValue;
Any aRequestedIFace;
if (xCurrentValue.is())
aRequestedIFace = xCurrentValue->queryInterface(*pProp->mpType);
OSL_ENSURE(aRequestedIFace.hasValue(), "ODADescriptorImpl::buildPropertyValue: invalid property value type (missing the requested interface)!");
}
else
OSL_ENSURE(pProp->mpType->equals(_rPos->second.getValueType()), "ODADescriptorImpl::buildPropertyValue: invalid property value type!");
#endif
// outta here // outta here
return aReturn; return aReturn;
} }
...@@ -344,7 +299,7 @@ namespace svx ...@@ -344,7 +299,7 @@ namespace svx
PropertyValue* pValue = m_aAsSequence.getArray(); PropertyValue* pValue = m_aAsSequence.getArray();
// loop through all our values // loop through all our values
for ( ConstDescriptorValuesIterator aLoop = m_aValues.begin(); for ( DescriptorValues::const_iterator aLoop = m_aValues.begin();
aLoop != m_aValues.end(); aLoop != m_aValues.end();
++aLoop, ++pValue ++aLoop, ++pValue
) )
...@@ -370,12 +325,12 @@ namespace svx ...@@ -370,12 +325,12 @@ namespace svx
PropertySetInfo* pPropSetInfo = new PropertySetInfo; PropertySetInfo* pPropSetInfo = new PropertySetInfo;
// loop through all our values // loop through all our values
for ( ConstDescriptorValuesIterator aLoop = m_aValues.begin(); for ( DescriptorValues::const_iterator aLoop = m_aValues.begin();
aLoop != m_aValues.end(); aLoop != m_aValues.end();
++aLoop, ++pValuesToSet ++aLoop, ++pValuesToSet
) )
{ {
PropertyMapEntry* pMapEntry = getPropertyMapEntry(aLoop); PropertyMapEntry* pMapEntry = getPropertyMapEntry( aLoop );
pPropSetInfo->add( pMapEntry, 1 ); pPropSetInfo->add( pMapEntry, 1 );
*pValuesToSet = buildPropertyValue(aLoop); *pValuesToSet = buildPropertyValue(aLoop);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment