dba34b: #i109580#: addd TableName property to OrderColumns (created by the parser)

This commit is contained in:
Frank Schoenheit [fs]
2010-09-30 08:53:15 +02:00
parent c8c5ba6a21
commit cac0954027
3 changed files with 87 additions and 31 deletions

View File

@@ -125,15 +125,27 @@ namespace connectivity
class OOO_DLLPUBLIC_DBTOOLS OOrderColumn :
public OOrderColumn_BASE, public OOrderColumn_PROP
{
sal_Bool m_bAscending;
sal_Bool m_bOrder;
const sal_Bool m_bAscending;
const ::rtl::OUString m_sTableName;
protected:
virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const;
virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
virtual ~OOrderColumn();
public:
OOrderColumn(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xColumn,sal_Bool _bCase,sal_Bool _bAscending);
OOrderColumn(
const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xColumn,
const ::rtl::OUString& i_rOriginatingTableName,
sal_Bool _bCase,
sal_Bool _bAscending
);
OOrderColumn(
const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xColumn,
sal_Bool _bCase,
sal_Bool _bAscending
);
virtual void construct();

View File

@@ -28,12 +28,12 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_connectivity.hxx"
#ifndef _CONNECTIVITY_SDBCX_COLUMN_HXX_
#include "connectivity/PColumn.hxx"
#endif
#include "connectivity/dbtools.hxx"
#include "TConnection.hxx"
#include <comphelper/types.hxx>
#include <tools/diagnose_ex.h>
using namespace ::comphelper;
using namespace connectivity;
@@ -191,38 +191,85 @@ void OParseColumn::construct()
// -----------------------------------------------------------------------------
::cppu::IPropertyArrayHelper & SAL_CALL OParseColumn::getInfoHelper()
{
OSL_ENSURE( !isNew(), "OParseColumn::OOrderColumn: a *new* OrderColumn?" );
OSL_ENSURE( !isNew(), "OParseColumn::getInfoHelper: a *new* ParseColumn?" );
return *OParseColumn_PROP::getArrayHelper();
}
// -----------------------------------------------------------------------------
OOrderColumn::OOrderColumn( const Reference<XPropertySet>& _xColumn
,sal_Bool _bCase
,sal_Bool _bAscending)
: connectivity::sdbcx::OColumn( getString(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)))
, getString(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME)))
, getString(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE)))
, getString(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DESCRIPTION)))
, getINT32(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE)))
, getINT32(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION)))
, getINT32(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE)))
, getINT32(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)))
, getBOOL(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISAUTOINCREMENT)))
, sal_False
, getBOOL(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCURRENCY)))
, _bCase
)
, m_bAscending(_bAscending)
namespace
{
::rtl::OUString lcl_getColumnTableName( const Reference< XPropertySet >& i_parseColumn )
{
::rtl::OUString sColumnTableName;
try
{
OSL_VERIFY( i_parseColumn->getPropertyValue( OMetaConnection::getPropMap().getNameByIndex( PROPERTY_ID_TABLENAME ) ) >>= sColumnTableName );
}
catch( const Exception& )
{
DBG_UNHANDLED_EXCEPTION();
}
return sColumnTableName;
}
}
// -----------------------------------------------------------------------------
OOrderColumn::OOrderColumn( const Reference<XPropertySet>& _xColumn, const ::rtl::OUString& i_rOriginatingTableName,
sal_Bool _bCase, sal_Bool _bAscending )
: connectivity::sdbcx::OColumn(
getString(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME))),
getString(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME))),
getString(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE))),
getString(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DESCRIPTION))),
getINT32(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE))),
getINT32(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION))),
getINT32(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE))),
getINT32(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE))),
getBOOL(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISAUTOINCREMENT))),
sal_False,
getBOOL(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCURRENCY))),
_bCase
)
,m_bAscending(_bAscending)
,m_sTableName( i_rOriginatingTableName )
{
construct();
}
// -----------------------------------------------------------------------------
OOrderColumn::OOrderColumn( const Reference<XPropertySet>& _xColumn, sal_Bool _bCase, sal_Bool _bAscending )
: connectivity::sdbcx::OColumn(
getString(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME))),
getString(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME))),
getString(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE))),
getString(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DESCRIPTION))),
getINT32(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE))),
getINT32(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION))),
getINT32(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE))),
getINT32(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE))),
getBOOL(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISAUTOINCREMENT))),
sal_False,
getBOOL(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCURRENCY))),
_bCase
)
,m_bAscending(_bAscending)
,m_sTableName( lcl_getColumnTableName( _xColumn ) )
{
construct();
}
// -------------------------------------------------------------------------
OOrderColumn::~OOrderColumn()
{
}
// -------------------------------------------------------------------------
void OOrderColumn::construct()
{
registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISASCENDING),PROPERTY_ID_ISASCENDING,0,&m_bAscending, ::getCppuType(reinterpret_cast< sal_Bool*>(NULL)));
registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISASCENDING), PROPERTY_ID_ISASCENDING,
PropertyAttribute::READONLY, const_cast< sal_Bool* >( &m_bAscending ), ::getCppuType( reinterpret_cast< sal_Bool* >( NULL ) ) );
registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TABLENAME), PROPERTY_ID_TABLENAME,
PropertyAttribute::READONLY, const_cast< ::rtl::OUString* >( &m_sTableName ), ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
}
// -----------------------------------------------------------------------------
::cppu::IPropertyArrayHelper* OOrderColumn::createArrayHelper() const
@@ -232,17 +279,14 @@ void OOrderColumn::construct()
// -----------------------------------------------------------------------------
::cppu::IPropertyArrayHelper & SAL_CALL OOrderColumn::getInfoHelper()
{
OSL_ENSURE( !isNew(), "OOrderColumn::OOrderColumn: a *new* OrderColumn?" );
OSL_ENSURE( !isNew(), "OOrderColumn::getInfoHelper: a *new* OrderColumn?" );
return *OOrderColumn_PROP::getArrayHelper();
}
// -----------------------------------------------------------------------------
::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL OOrderColumn::getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException)
{
::com::sun::star::uno::Sequence< ::rtl::OUString > aSupported(1);
if ( m_bOrder )
aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdb.OrderColumn");
else
aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdb.GroupColumn");
aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdb.OrderColumn");
return aSupported;
}

View File

@@ -1910,12 +1910,12 @@ void OSQLParseTreeIterator::setOrderByColumnName(const ::rtl::OUString & rColumn
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::setOrderByColumnName" );
Reference<XPropertySet> xColumn = findColumn( rColumnName, rTableRange, false );
if ( xColumn.is() )
m_aOrderColumns->get().push_back(new OOrderColumn(xColumn,isCaseSensitive(),bAscending));
m_aOrderColumns->get().push_back(new OOrderColumn( xColumn, rTableRange, isCaseSensitive(), bAscending ) );
else
{
sal_Int32 nId = rColumnName.toInt32();
if ( nId > 0 && nId < static_cast<sal_Int32>(m_aSelectColumns->get().size()) )
m_aOrderColumns->get().push_back(new OOrderColumn((m_aSelectColumns->get())[nId-1],isCaseSensitive(),bAscending));
m_aOrderColumns->get().push_back( new OOrderColumn( ( m_aSelectColumns->get() )[nId-1], isCaseSensitive(), bAscending ) );
}
#ifdef SQL_TEST_PARSETREEITERATOR