Commits

Ocke Janssen [oj]  committed bae59f7

fs33a: #i113583# handle column names from complex descriptions

  • Participants
  • Parent commits 5927ef1

Comments (0)

Files changed (4)

File dbaccess/source/core/dataaccess/documentdefinition.cxx

 				Reference<XNameContainer> xNC(pDocuSave->getContent(),UNO_QUERY);
 				if ( xNC.is() )
 				{
-                    if ( m_pImpl->m_aProps.aTitle == pDocuSave->getName() )
-                    {
-                        Reference<XEmbedPersist> xPersist(m_xEmbeddedObject,UNO_QUERY);
-		                if ( xPersist.is() )
-		                {
-			                xPersist->storeOwn();
-			                notifyDataSourceModified();
-		                }
-                    }
-                    else
+                    if ( m_pImpl->m_aProps.aTitle != pDocuSave->getName() )
                     {
                         try
                         {
                             DBG_UNHANDLED_EXCEPTION();
 		                }
                     }
+                    Reference<XEmbedPersist> xPersist(m_xEmbeddedObject,UNO_QUERY);
+	                if ( xPersist.is() )
+	                {
+		                xPersist->storeOwn();
+		                notifyDataSourceModified();
+	                }
 				}
 			}
 		}

File dbaccess/source/core/inc/DatabaseDataProvider.hxx

 #include "com/sun/star/lang/XServiceInfo.hpp"
 #include "com/sun/star/chart2/data/XDatabaseDataProvider.hpp"
 #include "com/sun/star/chart2/XInternalDataProvider.hpp"
+#include <com/sun/star/chart/XComplexDescriptionAccess.hpp>
 #include <com/sun/star/sdbc/XRowSet.hpp>
 #include <com/sun/star/sdbc/XParameters.hpp>
 #include <com/sun/star/container/XChild.hpp>
 
-#include "cppuhelper/compbase3.hxx"
+#include "cppuhelper/compbase4.hxx"
 #include "cppuhelper/basemutex.hxx"
 #include "cppuhelper/propertysetmixin.hxx"
 #include <cppuhelper/implementationentry.hxx>
 {
 
 class DatabaseDataSource;
-typedef ::cppu::WeakComponentImplHelper3<   ::com::sun::star::chart2::data::XDatabaseDataProvider
+typedef ::cppu::WeakComponentImplHelper4<   ::com::sun::star::chart2::data::XDatabaseDataProvider
                                           , ::com::sun::star::container::XChild
+                                          , ::com::sun::star::chart::XComplexDescriptionAccess
                                           , ::com::sun::star::lang::XServiceInfo > TDatabaseDataProvider;
 
 class DatabaseDataProvider: private ::cppu::BaseMutex,
     // conatiner::XChild
     virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getParent(  ) throw (::com::sun::star::uno::RuntimeException);
     virtual void SAL_CALL setParent( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& Parent ) throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException);
+
+    // ____ XComplexDescriptionAccess ____
+    virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::rtl::OUString > > SAL_CALL        getComplexRowDescriptions() throw (::com::sun::star::uno::RuntimeException);
+    virtual void SAL_CALL setComplexRowDescriptions(        const ::com::sun::star::uno::Sequence<        ::com::sun::star::uno::Sequence< ::rtl::OUString > >& aRowDescriptions )        throw (::com::sun::star::uno::RuntimeException);
+    virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::rtl::OUString > > SAL_CALL        getComplexColumnDescriptions() throw (::com::sun::star::uno::RuntimeException);
+    virtual void SAL_CALL setComplexColumnDescriptions(         const ::com::sun::star::uno::Sequence<        ::com::sun::star::uno::Sequence< ::rtl::OUString > >& aColumnDescriptions )        throw (::com::sun::star::uno::RuntimeException);
+
+    // ____ XChartDataArray (base of XComplexDescriptionAccess) ____
+    virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > > SAL_CALL getData()        throw (::com::sun::star::uno::RuntimeException);
+    virtual void SAL_CALL setData(        const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > >& aData )        throw (::com::sun::star::uno::RuntimeException);
+    virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getRowDescriptions()        throw (::com::sun::star::uno::RuntimeException);
+    virtual void SAL_CALL setRowDescriptions(        const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aRowDescriptions )        throw (::com::sun::star::uno::RuntimeException);
+    virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getColumnDescriptions()        throw (::com::sun::star::uno::RuntimeException);
+    virtual void SAL_CALL setColumnDescriptions(        const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aColumnDescriptions )        throw (::com::sun::star::uno::RuntimeException);
+
+    // ____ XChartData (base of XChartDataArray) ____
+    virtual void SAL_CALL addChartDataChangeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::chart::XChartDataChangeEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
+    virtual void SAL_CALL removeChartDataChangeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::chart::XChartDataChangeEventListener >& aListener )throw (::com::sun::star::uno::RuntimeException);
+    virtual double SAL_CALL getNotANumber()throw (::com::sun::star::uno::RuntimeException);
+    virtual ::sal_Bool SAL_CALL isNotANumber(double nNumber )throw (::com::sun::star::uno::RuntimeException);
 private:
     DatabaseDataProvider(DatabaseDataProvider &); // not defined
     void operator =(DatabaseDataProvider &); // not defined
     ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >                 m_xActiveConnection;
     ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet >                     m_xRowSet;
     ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XInternalDataProvider >     m_xInternal;
+    ::com::sun::star::uno::Reference< ::com::sun::star::chart::XComplexDescriptionAccess >  m_xComplexDescriptionAccess;
     ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XRangeXMLConversion>  m_xRangeConversion;
     ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler>          m_xHandler;
     // the object doin' most of the work - an SDB-rowset

File dbaccess/source/core/misc/DatabaseDataProvider.cxx

 #include <com/sun/star/sdbc/XResultSet.hpp>
 #include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
 #include <com/sun/star/sdbc/XResultSetMetaData.hpp>
+#include <com/sun/star/sdbc/XColumnLocate.hpp>
 #include <com/sun/star/beans/NamedValue.hpp>
 #include <com/sun/star/chart/ChartDataRowSource.hpp>
 #include <com/sun/star/chart/XChartDataArray.hpp>
 {
     m_xInternal.set( m_xContext->getServiceManager()->createInstanceWithContext(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.chart.InternalDataProvider")),m_xContext ), uno::UNO_QUERY );
     m_xRangeConversion.set(m_xInternal,uno::UNO_QUERY);
+    m_xComplexDescriptionAccess.set(m_xInternal,uno::UNO_QUERY);
 
     osl_incrementInterlockedCount( &m_refCount );
     {
     }
     return xData;
 }
+
+uno::Sequence< uno::Sequence< rtl::OUString > > SAL_CALL DatabaseDataProvider::getComplexRowDescriptions() throw (uno::RuntimeException)
+{
+    return m_xComplexDescriptionAccess->getComplexRowDescriptions();
+}
+void SAL_CALL DatabaseDataProvider::setComplexRowDescriptions( const uno::Sequence< uno::Sequence< ::rtl::OUString > >& aRowDescriptions ) throw (uno::RuntimeException)
+{
+    m_xComplexDescriptionAccess->setComplexRowDescriptions(aRowDescriptions);
+}
+uno::Sequence< uno::Sequence< rtl::OUString > > SAL_CALL DatabaseDataProvider::getComplexColumnDescriptions() throw (uno::RuntimeException)
+{
+    return m_xComplexDescriptionAccess->getComplexColumnDescriptions();
+}
+void SAL_CALL DatabaseDataProvider::setComplexColumnDescriptions( const uno::Sequence< uno::Sequence< rtl::OUString > >& aColumnDescriptions ) throw (uno::RuntimeException)
+{
+    m_xComplexDescriptionAccess->setComplexColumnDescriptions(aColumnDescriptions);
+}
+// ____ XChartDataArray ____
+uno::Sequence< uno::Sequence< double > > SAL_CALL DatabaseDataProvider::getData()    throw (uno::RuntimeException)
+{
+    return m_xComplexDescriptionAccess->getData();
+}
+
+void SAL_CALL DatabaseDataProvider::setData( const uno::Sequence< uno::Sequence< double > >& rDataInRows )    throw (uno::RuntimeException)
+{
+    m_xComplexDescriptionAccess->setData(rDataInRows);
+}
+
+void SAL_CALL DatabaseDataProvider::setRowDescriptions( const uno::Sequence< rtl::OUString >& aRowDescriptions )    throw (uno::RuntimeException)
+{
+    m_xComplexDescriptionAccess->setRowDescriptions(aRowDescriptions);
+}
+
+void SAL_CALL DatabaseDataProvider::setColumnDescriptions( const uno::Sequence< rtl::OUString >& aColumnDescriptions )    throw (uno::RuntimeException)
+{
+    m_xComplexDescriptionAccess->setColumnDescriptions(aColumnDescriptions);
+}
+
+uno::Sequence< rtl::OUString > SAL_CALL DatabaseDataProvider::getRowDescriptions()    throw (uno::RuntimeException)
+{    
+    return m_xComplexDescriptionAccess->getRowDescriptions();
+}
+
+uno::Sequence< rtl::OUString > SAL_CALL DatabaseDataProvider::getColumnDescriptions()    throw (uno::RuntimeException)
+{    
+    return m_xComplexDescriptionAccess->getColumnDescriptions();
+}
+
+// ____ XChartData (base of XChartDataArray) ____
+void SAL_CALL DatabaseDataProvider::addChartDataChangeEventListener(const uno::Reference< ::com::sun::star::chart::XChartDataChangeEventListener >& x)    throw (uno::RuntimeException)
+{
+    m_xComplexDescriptionAccess->addChartDataChangeEventListener(x);
+}
+
+void SAL_CALL DatabaseDataProvider::removeChartDataChangeEventListener(const uno::Reference< ::com::sun::star::chart::XChartDataChangeEventListener >& x)    throw (uno::RuntimeException)
+{
+    m_xComplexDescriptionAccess->removeChartDataChangeEventListener(x);
+}
+
+double SAL_CALL DatabaseDataProvider::getNotANumber()    throw (uno::RuntimeException)
+{
+    return m_xComplexDescriptionAccess->getNotANumber();
+}
+
+::sal_Bool SAL_CALL DatabaseDataProvider::isNotANumber( double nNumber )    throw (uno::RuntimeException)
+{
+    return m_xComplexDescriptionAccess->isNotANumber(nNumber);
+}
+
 // -----------------------------------------------------------------------------
 
 uno::Reference< sheet::XRangeSelection > SAL_CALL DatabaseDataProvider::getRangeSelection() throw (uno::RuntimeException)
     uno::Reference< sdbc::XResultSet> xRes(m_xRowSet,uno::UNO_QUERY_THROW);
     uno::Reference< sdbc::XRow> xRow(m_xRowSet,uno::UNO_QUERY_THROW);
     uno::Reference< sdbc::XResultSetMetaData> xResultSetMetaData = uno::Reference< sdbc::XResultSetMetaDataSupplier>(m_xRowSet,uno::UNO_QUERY)->getMetaData();
+    uno::Reference< sdbc::XColumnLocate> xColumnLocate(m_xRowSet,uno::UNO_QUERY_THROW);
 
     ::std::vector<sal_Int32> aColumnTypes;
     uno::Sequence< uno::Any > aLabelArgs(1);
     const sal_Int32 nCount = aColumns.getLength();
     if ( nCount )
         aColumnTypes.push_back(xResultSetMetaData->getColumnType(1));
-    for (sal_Int32 i = 1; i < nCount; ++i)
-    {
-        aColumnTypes.push_back(xResultSetMetaData->getColumnType(i+1));
-    } // for (sal_Int32 i = 1; i < nCount; ++i)
 
+    ::std::vector< sal_Int32 > aColumnPositions;
     const ::rtl::OUString* pIter = aColumns.getConstArray();
     const ::rtl::OUString* pEnd = pIter + aColumns.getLength();
     for(sal_Int32 k = 0;pIter != pEnd;++pIter,++k)
     {
+        aColumnPositions.push_back(xColumnLocate->findColumn(*pIter));
         uno::Reference< beans::XPropertySet> xColumn(xColumns->getByName(*pIter),uno::UNO_QUERY);
+        sal_Int32 nType = sdbc::DataType::VARCHAR;
         if ( xColumn.is() )
         {
             m_aNumberFormats.insert( ::std::map< ::rtl::OUString,uno::Any>::value_type(::rtl::OUString::valueOf(k),xColumn->getPropertyValue(PROPERTY_NUMBERFORMAT)));
+            xColumn->getPropertyValue(PROPERTY_TYPE) >>= nType;
         }
+        aColumnTypes.push_back(nType);
     }
 
     ::std::vector< ::rtl::OUString > aRowLabels;
         aValue.fill(1,aColumnTypes[0],xRow);
         aRowLabels.push_back(aValue.getString());
         ::std::vector< double > aRow;
-        for (sal_Int32 j = _bHasCategories ? 2 : 1,i = 0; j <= nCount; ++j,++i)
+        ::std::vector< sal_Int32 >::iterator aColumnPosIter = aColumnPositions.begin();
+        ::std::vector< sal_Int32 >::iterator aColumnPosEnd = aColumnPositions.end();
+        sal_Int32 i = 0;
+        if ( _bHasCategories )
         {
-            aValue.fill(j,aColumnTypes[j-1],xRow);
+            ++aColumnPosIter;
+            ++i;
+        }
+        for (; aColumnPosIter != aColumnPosEnd; ++aColumnPosIter,++i)
+        {
+            aValue.fill(*aColumnPosIter,aColumnTypes[i],xRow);
             if ( aValue.isNull() )
             {
                 double nValue;
             }
             else
                 aRow.push_back(aValue.getDouble());
-        } // for (sal_Int32 j = 2,i = 0; j <= nCount; ++j,++i)
+        }
         aDataValues.push_back(aRow);
     } // while( xRes->next() && (!m_RowLimit || nRowCount < m_RowLimit) )
 

File reportdesign/source/filter/xml/xmlExportDocumentHandler.cxx

 #include "xmlExportDocumentHandler.hxx"
 #include <com/sun/star/sdb/CommandType.hpp>
 #include <com/sun/star/chart2/data/XDatabaseDataProvider.hpp>
+#include <com/sun/star/chart/XComplexDescriptionAccess.hpp>
 #include <com/sun/star/reflection/XProxyFactory.hpp>
 #include <com/sun/star/sdb/CommandType.hpp>
 #include <comphelper/sequence.hxx>
 	// set ourself as delegator
 	m_xProxy->setDelegator( *this );
 
-    const ::rtl::OUString sCommand = m_xDatabaseDataProvider->getCommand();
-    if ( sCommand.getLength() )
-        m_aColumns = ::dbtools::getFieldNamesByCommandDescriptor(m_xDatabaseDataProvider->getActiveConnection()
-                    ,m_xDatabaseDataProvider->getCommandType()
-                    ,sCommand);
+    uno::Reference< chart::XComplexDescriptionAccess > xDataProvider(m_xDatabaseDataProvider,uno::UNO_QUERY);
+    if ( xDataProvider.is() )
+    {
+        uno::Sequence< uno::Sequence< ::rtl::OUString > > aColumnNames = xDataProvider->getComplexColumnDescriptions();
+        for(sal_Int32 i = 0 ; i < aColumnNames.getLength();++i)
+        {
+            if ( aColumnNames[i].getLength() )
+            {
+                sal_Int32 nCount = m_aColumns.getLength();
+                m_aColumns.realloc(nCount+1);
+                m_aColumns[nCount] = aColumnNames[i][0];
+            }
+        }
+    }
+    else
+    {
+        const ::rtl::OUString sCommand = m_xDatabaseDataProvider->getCommand();
+        if ( sCommand.getLength() )
+            m_aColumns = ::dbtools::getFieldNamesByCommandDescriptor(m_xDatabaseDataProvider->getActiveConnection()
+                        ,m_xDatabaseDataProvider->getCommandType()
+                        ,sCommand);
+    }
 }
 // --------------------------------------------------------------------------------
 uno::Any SAL_CALL ExportDocumentHandler::queryInterface( const uno::Type& _rType ) throw (uno::RuntimeException)