summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOcke Janssen [oj] <Ocke.Janssen@sun.com>2009-12-21 14:42:31 +0100
committerOcke Janssen [oj] <Ocke.Janssen@sun.com>2009-12-21 14:42:31 +0100
commit6f4bc5831ab4bc0be6cd1e01e038b3585770eed6 (patch)
tree47dbe8545441360bee65643b2eab02cbdc0e7ec6
parentdba33e: remove unused header (diff)
downloadcore-6f4bc5831ab4bc0be6cd1e01e038b3585770eed6.tar.gz
core-6f4bc5831ab4bc0be6cd1e01e038b3585770eed6.zip
dba33e: #i107717# allow the command definition to define the column names which should be shown
-rw-r--r--dbaccess/source/core/api/RowSet.cxx4
-rw-r--r--dbaccess/source/core/api/definitioncolumn.cxx11
-rw-r--r--dbaccess/source/core/api/query.cxx27
-rw-r--r--dbaccess/source/core/inc/definitioncolumn.hxx3
4 files changed, 34 insertions, 11 deletions
diff --git a/dbaccess/source/core/api/RowSet.cxx b/dbaccess/source/core/api/RowSet.cxx
index 1adddab143c1..bb500ac94ad2 100644
--- a/dbaccess/source/core/api/RowSet.cxx
+++ b/dbaccess/source/core/api/RowSet.cxx
@@ -1904,6 +1904,8 @@ void ORowSet::execute_NoApprove_NoNewConn(ResettableMutexGuard& _rClearForNotifi
if(!xColumn.is())
{
// no column found so we could look at the position i
+ bReFetchName = sal_True;
+ sColumnLabel = ::rtl::OUString();
Reference<XIndexAccess> xIndexAccess(m_xColumns,UNO_QUERY);
if(xIndexAccess.is() && i <= xIndexAccess->getCount())
{
@@ -1913,7 +1915,9 @@ void ORowSet::execute_NoApprove_NoNewConn(ResettableMutexGuard& _rClearForNotifi
{
Sequence< ::rtl::OUString> aSeq = m_xColumns->getElementNames();
if( i <= aSeq.getLength())
+ {
m_xColumns->getByName(aSeq.getConstArray()[i-1]) >>= xColumn;
+ }
}
}
if(bReFetchName && xColumn.is())
diff --git a/dbaccess/source/core/api/definitioncolumn.cxx b/dbaccess/source/core/api/definitioncolumn.cxx
index 9f9e511fc9b4..77a29812b105 100644
--- a/dbaccess/source/core/api/definitioncolumn.cxx
+++ b/dbaccess/source/core/api/definitioncolumn.cxx
@@ -192,7 +192,7 @@ rtl::OUString OTableColumn::getImplementationName( ) throw (RuntimeException)
DBG_NAME( OQueryColumn );
// -------------------------------------------------------------------------
-OQueryColumn::OQueryColumn( const Reference< XPropertySet >& _rxParserColumn, const Reference< XConnection >& _rxConnection )
+OQueryColumn::OQueryColumn( const Reference< XPropertySet >& _rxParserColumn, const Reference< XConnection >& _rxConnection,const ::rtl::OUString& _sNewName )
:OTableColumnDescriptor( false /* do not act as descriptor */ )
{
const sal_Int32 nPropAttr = PropertyAttribute::READONLY;
@@ -210,7 +210,14 @@ OQueryColumn::OQueryColumn( const Reference< XPropertySet >& _rxParserColumn, co
OSL_VERIFY( _rxParserColumn->getPropertyValue( PROPERTY_TYPE ) >>= m_nType );
OSL_VERIFY( _rxParserColumn->getPropertyValue( PROPERTY_ISAUTOINCREMENT ) >>= m_bAutoIncrement );
OSL_VERIFY( _rxParserColumn->getPropertyValue( PROPERTY_ISCURRENCY ) >>= m_bCurrency );
- OSL_VERIFY( _rxParserColumn->getPropertyValue( PROPERTY_NAME ) >>= m_sName );
+ if ( _sNewName.getLength() )
+ {
+ m_sName = _sNewName;
+ }
+ else
+ {
+ OSL_VERIFY( _rxParserColumn->getPropertyValue( PROPERTY_NAME ) >>= m_sName );
+ }
m_bRowVersion = sal_False;
Reference< XPropertySetInfo > xPSI( _rxParserColumn->getPropertySetInfo(), UNO_SET_THROW );
diff --git a/dbaccess/source/core/api/query.cxx b/dbaccess/source/core/api/query.cxx
index 7468e88f4fff..ccd91f2a312e 100644
--- a/dbaccess/source/core/api/query.cxx
+++ b/dbaccess/source/core/api/query.cxx
@@ -191,9 +191,10 @@ void OQuery::rebuildColumns()
m_pColumnMediator = NULL;
Reference<XColumnsSupplier> xColSup(m_xCommandDefinition,UNO_QUERY);
+ Reference< XNameAccess > xColumnDefinitions;
if ( xColSup.is() )
{
- Reference< XNameAccess > xColumnDefinitions = xColSup->getColumns();
+ xColumnDefinitions = xColSup->getColumns();
if ( xColumnDefinitions.is() )
m_pColumnMediator = new OContainerMediator( m_pColumns, xColumnDefinitions, m_xConnection, OContainerMediator::eColumns );
}
@@ -236,19 +237,29 @@ void OQuery::rebuildColumns()
}
Sequence< ::rtl::OUString> aNames = xColumns->getElementNames();
- const ::rtl::OUString* pBegin = aNames.getConstArray();
- const ::rtl::OUString* pEnd = pBegin + aNames.getLength();
- for ( ;pBegin != pEnd; ++pBegin)
+ Sequence< ::rtl::OUString> aDefintionNames;
+ bool bApplyDefinitionNames = false;
+ if ( xColumnDefinitions.is() )
{
- Reference<XPropertySet> xSource(xColumns->getByName( *pBegin ),UNO_QUERY);
- OQueryColumn* pColumn = new OQueryColumn( xSource, m_xConnection );
+ aDefintionNames = xColumnDefinitions->getElementNames();
+ bApplyDefinitionNames = aDefintionNames.getLength() == aNames.getLength();
+ }
+
+ ::rtl::OUString sEmpty;
+ const ::rtl::OUString* pIter = aNames.getConstArray();
+ const ::rtl::OUString* pEnd = pIter + aNames.getLength();
+ for ( sal_Int32 i = 0;pIter != pEnd; ++pIter,++i)
+ {
+ Reference<XPropertySet> xSource(xColumns->getByName( *pIter ),UNO_QUERY);
+ OQueryColumn* pColumn = new OQueryColumn( xSource, m_xConnection, bApplyDefinitionNames ? aDefintionNames[i] : sEmpty);
Reference< XChild > xChild( *pColumn, UNO_QUERY_THROW );
xChild->setParent( *this );
- implAppendColumn( *pBegin, pColumn );
+ ::rtl::OUString sNewName = bApplyDefinitionNames ? aDefintionNames[i] : *pIter;
+ implAppendColumn( sNewName, pColumn );
Reference< XPropertySet > xDest( *pColumn, UNO_QUERY_THROW );
if ( m_pColumnMediator.is() )
- m_pColumnMediator->notifyElementCreated( *pBegin, xDest );
+ m_pColumnMediator->notifyElementCreated( sNewName, xDest );
}
}
catch( const SQLContext& e )
diff --git a/dbaccess/source/core/inc/definitioncolumn.hxx b/dbaccess/source/core/inc/definitioncolumn.hxx
index c5151e6bffd5..b67b0de70c59 100644
--- a/dbaccess/source/core/inc/definitioncolumn.hxx
+++ b/dbaccess/source/core/inc/definitioncolumn.hxx
@@ -167,7 +167,8 @@ namespace dbaccess
public:
OQueryColumn(
const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxParserColumn,
- const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
+ const ::rtl::OUString& _sNewName
);
// XTypeProvider