diff options
author | Frank Schoenheit [fs] <frank.schoenheit@sun.com> | 2010-09-30 08:53:15 +0200 |
---|---|---|
committer | Frank Schoenheit [fs] <frank.schoenheit@sun.com> | 2010-09-30 08:53:15 +0200 |
commit | cac09540278a3e5b16406a508f7bb731d9dd4c7d (patch) | |
tree | 581e62ebaaaac116f0cd9cd695e4bb7f4075fd4f /connectivity | |
parent | c8c5ba6a21754c0fd28dcc8a9d2322c3e30d545e (diff) |
dba34b: #i109580#: addd TableName property to OrderColumns (created by the parser)
Diffstat (limited to 'connectivity')
-rw-r--r-- | connectivity/inc/connectivity/PColumn.hxx | 18 | ||||
-rw-r--r-- | connectivity/source/parse/PColumn.cxx | 96 | ||||
-rw-r--r-- | connectivity/source/parse/sqliterator.cxx | 4 |
3 files changed, 87 insertions, 31 deletions
diff --git a/connectivity/inc/connectivity/PColumn.hxx b/connectivity/inc/connectivity/PColumn.hxx index 547cc8fb9970..1e9dc8b560f1 100644 --- a/connectivity/inc/connectivity/PColumn.hxx +++ b/connectivity/inc/connectivity/PColumn.hxx @@ -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(); diff --git a/connectivity/source/parse/PColumn.cxx b/connectivity/source/parse/PColumn.cxx index 43e38f5a1674..abcac583dfbc 100644 --- a/connectivity/source/parse/PColumn.cxx +++ b/connectivity/source/parse/PColumn.cxx @@ -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; } diff --git a/connectivity/source/parse/sqliterator.cxx b/connectivity/source/parse/sqliterator.cxx index e1d805e9a1e5..5a72736fecde 100644 --- a/connectivity/source/parse/sqliterator.cxx +++ b/connectivity/source/parse/sqliterator.cxx @@ -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 |