diff options
author | Frank Schoenheit [fs] <frank.schoenheit@sun.com> | 2010-09-20 22:53:54 +0200 |
---|---|---|
committer | Frank Schoenheit [fs] <frank.schoenheit@sun.com> | 2010-09-20 22:53:54 +0200 |
commit | 2c7baf6bb58a4901289195c5405e9f938a9dee89 (patch) | |
tree | 96aff2becb09f9e90bcd8e24ff68cc93d98f91f8 | |
parent | 013b4fb1df6a8de80d1be42d47c68ef26c665047 (diff) |
dba33j: #i114438#
7 files changed, 220 insertions, 163 deletions
diff --git a/dbaccess/source/core/inc/DatabaseDataProvider.hxx b/dbaccess/source/core/inc/DatabaseDataProvider.hxx index dae466e92..85f956a0b 100644 --- a/dbaccess/source/core/inc/DatabaseDataProvider.hxx +++ b/dbaccess/source/core/inc/DatabaseDataProvider.hxx @@ -223,7 +223,7 @@ private: void impl_fillRowSet_throw(); void impl_executeRowSet_throw(::osl::ResettableMutexGuard& _rClearForNotifies); bool impl_fillParameters_nothrow( ::osl::ResettableMutexGuard& _rClearForNotifies); - void impl_fillInternalDataProvider_throw(sal_Bool _bHasCategories,const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::rtl::OUString > >& i_aColumnNames); + void impl_fillInternalDataProvider_throw(sal_Bool _bHasCategories,const ::com::sun::star::uno::Sequence< ::rtl::OUString >& i_aColumnNames); void impl_invalidateParameter_nothrow(); ::com::sun::star::uno::Any impl_getNumberFormatKey_nothrow(const ::rtl::OUString & _sRangeRepresentation) const; diff --git a/dbaccess/source/core/misc/DatabaseDataProvider.cxx b/dbaccess/source/core/misc/DatabaseDataProvider.cxx index 0ede9ff23..30c2193da 100644 --- a/dbaccess/source/core/misc/DatabaseDataProvider.cxx +++ b/dbaccess/source/core/misc/DatabaseDataProvider.cxx @@ -31,10 +31,12 @@ #include "dbastrings.hrc" #include "cppuhelper/implbase1.hxx" #include <comphelper/types.hxx> +#include <comphelper/namedvaluecollection.hxx> #include <connectivity/FValue.hxx> #include <connectivity/dbtools.hxx> #include <rtl/ustrbuf.hxx> #include <rtl/math.hxx> +#include <tools/diagnose_ex.h> #include <com/sun/star/task/XInteractionHandler.hpp> #include <com/sun/star/sdb/XCompletedExecution.hpp> @@ -205,22 +207,24 @@ uno::Reference< chart2::data::XDataSource > SAL_CALL DatabaseDataProvider::creat osl::ResettableMutexGuard aClearForNotifies(m_aMutex); if ( createDataSourcePossible(_aArguments) ) { - sal_Bool bHasCategories = sal_True; - uno::Sequence< uno::Sequence< ::rtl::OUString > > aColumnNames; - const beans::PropertyValue* pArgIter = _aArguments.getConstArray(); - const beans::PropertyValue* pArgEnd = pArgIter + _aArguments.getLength(); - for(;pArgIter != pArgEnd;++pArgIter) + try { - if ( pArgIter->Name.equalsAscii("HasCategories") ) - { - pArgIter->Value >>= bHasCategories; - - } - else if ( pArgIter->Name.equalsAscii("ComplexColumnDescriptions") ) - { - pArgIter->Value >>= aColumnNames; - } + uno::Reference< chart::XChartDataArray> xChartData( m_xInternal, uno::UNO_QUERY_THROW ); + xChartData->setData( uno::Sequence< uno::Sequence< double > >() ); + xChartData->setColumnDescriptions( uno::Sequence< ::rtl::OUString >() ); + if ( m_xInternal->hasDataByRangeRepresentation( ::rtl::OUString::valueOf( sal_Int32(0) ) ) ) + m_xInternal->deleteSequence(0); } + catch( const uno::Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + + ::comphelper::NamedValueCollection aArgs( _aArguments ); + const sal_Bool bHasCategories = aArgs.getOrDefault( "HasCategories", sal_True ); + uno::Sequence< ::rtl::OUString > aColumnNames = + aArgs.getOrDefault( "ColumnDescriptions", uno::Sequence< ::rtl::OUString >() ); + bool bRet = false; if ( m_Command.getLength() != 0 && m_xActiveConnection.is() ) { @@ -254,41 +258,36 @@ uno::Reference< chart2::data::XDataSource > SAL_CALL DatabaseDataProvider::creat uno::Sequence< beans::PropertyValue > SAL_CALL DatabaseDataProvider::detectArguments(const uno::Reference< chart2::data::XDataSource > & _xDataSource) throw (uno::RuntimeException) { - uno::Sequence< beans::PropertyValue > aArguments( 4 ); - aArguments[0] = beans::PropertyValue( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CellRangeRepresentation")), -1, uno::Any(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("all")) ), - beans::PropertyState_DIRECT_VALUE ); - aArguments[1] = beans::PropertyValue( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataRowSource")), -1, uno::makeAny( chart::ChartDataRowSource_COLUMNS ), - beans::PropertyState_DIRECT_VALUE ); + ::comphelper::NamedValueCollection aArguments; + aArguments.put( "CellRangeRepresentation", uno::Any( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "all" ) ) ) ); + aArguments.put( "DataRowSource", uno::makeAny( chart::ChartDataRowSource_COLUMNS ) ); // internal data always contains labels and categories - aArguments[2] = beans::PropertyValue( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FirstCellAsLabel")), -1, uno::makeAny( true ), beans::PropertyState_DIRECT_VALUE ); + aArguments.put( "FirstCellAsLabel", uno::makeAny( sal_True ) ); + sal_Bool bHasCategories = sal_False; if( _xDataSource.is()) { - uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > > aSequences(_xDataSource->getDataSequences()); - const sal_Int32 nCount( aSequences.getLength()); - for( sal_Int32 nIdx=0; nIdx<nCount; ++nIdx ) - { - if( aSequences[nIdx].is() ) - { - uno::Reference< beans::XPropertySet > xSeqProp( aSequences[nIdx]->getValues(), uno::UNO_QUERY ); - ::rtl::OUString aRole; - if( xSeqProp.is() && - (xSeqProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Role"))) >>= aRole) && - aRole.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("categories")) ) - { - bHasCategories = sal_True; - break; - } - } - } + uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > > aSequences(_xDataSource->getDataSequences()); + const sal_Int32 nCount( aSequences.getLength()); + for( sal_Int32 nIdx=0; nIdx<nCount; ++nIdx ) + { + if( aSequences[nIdx].is() ) + { + uno::Reference< beans::XPropertySet > xSeqProp( aSequences[nIdx]->getValues(), uno::UNO_QUERY ); + ::rtl::OUString aRole; + if ( xSeqProp.is() + && ( xSeqProp->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Role" ) ) ) >>= aRole ) + && aRole.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "categories" ) ) + ) + { + bHasCategories = sal_True; + break; + } + } + } } - - aArguments[3] = beans::PropertyValue( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HasCategories")), -1, uno::makeAny( bHasCategories ), beans::PropertyState_DIRECT_VALUE ); - return aArguments; + aArguments.put( "HasCategories", uno::makeAny( bHasCategories ) ); + return aArguments.getPropertyValues(); } // ----------------------------------------------------------------------------- @@ -649,66 +648,136 @@ void DatabaseDataProvider::impl_executeRowSet_throw(::osl::ResettableMutexGuard& if ( impl_fillParameters_nothrow(_rClearForNotifies) ) m_xRowSet->execute(); } + // ----------------------------------------------------------------------------- -void DatabaseDataProvider::impl_fillInternalDataProvider_throw(sal_Bool _bHasCategories,const uno::Sequence< uno::Sequence< ::rtl::OUString > >& i_aColumnNames) +namespace { - // clear the data before fill the new one - uno::Reference< chart::XChartDataArray> xChartData(m_xInternal,uno::UNO_QUERY); - if ( xChartData.is() ) + struct ColumnDescription { - xChartData->setData(uno::Sequence< uno::Sequence<double> >()); - xChartData->setColumnDescriptions(uno::Sequence< ::rtl::OUString >()); - if ( m_xInternal->hasDataByRangeRepresentation(::rtl::OUString::valueOf(sal_Int32(0))) ) - m_xInternal->deleteSequence(0); - } + ::rtl::OUString sName; + sal_Int32 nResultSetPosition; + sal_Int32 nDataType; + + ColumnDescription() + :sName() + ,nResultSetPosition( 0 ) + ,nDataType( sdbc::DataType::VARCHAR ) + { + } + explicit ColumnDescription( const ::rtl::OUString& i_rName ) + :sName( i_rName ) + ,nResultSetPosition( 0 ) + ,nDataType( sdbc::DataType::VARCHAR ) + { + } + }; + + struct CreateColumnDescription : public ::std::unary_function< ::rtl::OUString, ColumnDescription > + { + ColumnDescription operator()( const ::rtl::OUString& i_rName ) + { + return ColumnDescription( i_rName ); + } + }; + + struct SelectColumnName : public ::std::unary_function< ColumnDescription, ::rtl::OUString > + { + const ::rtl::OUString& operator()( const ColumnDescription& i_rColumn ) + { + return i_rColumn.sName; + } + }; +} + +// ----------------------------------------------------------------------------- +void DatabaseDataProvider::impl_fillInternalDataProvider_throw(sal_Bool _bHasCategories,const uno::Sequence< ::rtl::OUString >& i_aColumnNames) +{ + // clear the data before fill the new one + uno::Reference< sdbcx::XColumnsSupplier > xColSup(m_xRowSet,uno::UNO_QUERY_THROW); + uno::Reference< container::XNameAccess > xColumns( xColSup->getColumns(), uno::UNO_SET_THROW ); + const uno::Sequence< ::rtl::OUString > aRowSetColumnNames( xColumns->getElementNames() ); - uno::Reference< sdbcx::XColumnsSupplier> xColSup(m_xRowSet,uno::UNO_QUERY_THROW); - uno::Reference< container::XNameAccess > xColumns = xColSup->getColumns(); - uno::Sequence< ::rtl::OUString > aColumns; + typedef ::std::vector< ColumnDescription > ColumnDescriptions; + ColumnDescriptions aColumns; + bool bFirstColumnIsCategory = _bHasCategories; if ( i_aColumnNames.getLength() ) { - aColumns.realloc(1); - aColumns[0] = xColumns->getElementNames()[0]; - for(sal_Int32 i = 0 ; i < i_aColumnNames.getLength();++i) + // some normalizations ... + uno::Sequence< ::rtl::OUString > aImposedColumnNames( i_aColumnNames ); + + // strangely, there exist documents where the ColumnDescriptions end with a number of empty strings. /me + // thinks they're generated when you have a chart based on a result set with n columns, but remove some + // of those columns from the chart - it looks like a bug in the report XML export to me. + // So, get rid of the "trailing" empty columns + sal_Int32 nLastNonEmptyColName = aImposedColumnNames.getLength() - 1; + for ( ; nLastNonEmptyColName >= 0; --nLastNonEmptyColName ) { - if ( i_aColumnNames[i].getLength() ) + if ( aImposedColumnNames[ nLastNonEmptyColName ].getLength() != 0 ) + break; + } + aImposedColumnNames.realloc( nLastNonEmptyColName + 1 ); + + // second, for X-Y-charts the ColumnDescriptions exported by chart miss the name of the first (non-category) + // column. This, this results in a ColumnDescriptions array like <"", "col2", "col3">, where you'd expect + // <"col1", "col2", "col3">. + // Fix this with some heuristics: + if ( ( aImposedColumnNames.getLength() > 0 ) && ( aImposedColumnNames[0].getLength() == 0 ) ) + { + const sal_Int32 nAssumedRowSetColumnIndex = _bHasCategories ? 1 : 0; + if ( nAssumedRowSetColumnIndex < aRowSetColumnNames.getLength() ) + aImposedColumnNames[0] = aRowSetColumnNames[ nAssumedRowSetColumnIndex ]; + } + + const sal_Int32 nCount = aImposedColumnNames.getLength(); + for ( sal_Int32 i = 0 ; i < nCount; ++i ) + { + const ::rtl::OUString sColumnName( aImposedColumnNames[i] ); + if ( !xColumns->hasByName( sColumnName ) ) + continue; + + if ( _bHasCategories && aColumns.empty() ) { - sal_Int32 nCount = aColumns.getLength(); - aColumns.realloc(nCount+1); - aColumns[nCount] = i_aColumnNames[i][0]; + if ( aRowSetColumnNames.getLength() ) + aColumns.push_back( ColumnDescription( aRowSetColumnNames[0] ) ); + else + aColumns.push_back( ColumnDescription( sColumnName ) ); + bFirstColumnIsCategory = true; } + aColumns.push_back( ColumnDescription( sColumnName ) ); } } - else + if ( aColumns.empty() ) { - aColumns = xColumns->getElementNames(); + aColumns.resize( aRowSetColumnNames.getLength() ); + ::std::transform( + aRowSetColumnNames.getConstArray(), + aRowSetColumnNames.getConstArray() + aRowSetColumnNames.getLength(), + aColumns.begin(), + CreateColumnDescription() + ); } + // fill the data - 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)); - - ::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) + 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::XResultSetMetaDataSupplier > xSuppMeta( m_xRowSet,uno::UNO_QUERY_THROW ); + uno::Reference< sdbc::XResultSetMetaData > xResultSetMetaData( xSuppMeta->getMetaData(), uno::UNO_SET_THROW ); + uno::Reference< sdbc::XColumnLocate > xColumnLocate( m_xRowSet, uno::UNO_QUERY_THROW ); + + for ( ColumnDescriptions::iterator col = aColumns.begin(); + col != aColumns.end(); + ++col + ) { - 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); + col->nResultSetPosition = xColumnLocate->findColumn( col->sName ); + + const uno::Reference< beans::XPropertySet > xColumn( xColumns->getByName( col->sName ), uno::UNO_QUERY_THROW ); + const uno::Any aNumberFormat( xColumn->getPropertyValue( PROPERTY_NUMBERFORMAT ) ); + OSL_VERIFY( xColumn->getPropertyValue( PROPERTY_TYPE ) >>= col->nDataType ); + + const sal_Int32 columnIndex = col - aColumns.begin(); + const ::rtl::OUString sRangeName = ::rtl::OUString::valueOf( columnIndex ); + m_aNumberFormats.insert( ::std::map< ::rtl::OUString, uno::Any >::value_type( sRangeName, aNumberFormat ) ); } ::std::vector< ::rtl::OUString > aRowLabels; @@ -719,31 +788,31 @@ void DatabaseDataProvider::impl_fillInternalDataProvider_throw(sal_Bool _bHasCat { ++nRowCount; - aValue.fill(1,aColumnTypes[0],xRow); - aRowLabels.push_back(aValue.getString()); + aValue.fill( aColumns[0].nResultSetPosition, aColumns[0].nDataType, xRow ); + aRowLabels.push_back( aValue.getString() ); + ::std::vector< double > aRow; - ::std::vector< sal_Int32 >::iterator aColumnPosIter = aColumnPositions.begin(); - ::std::vector< sal_Int32 >::iterator aColumnPosEnd = aColumnPositions.end(); - sal_Int32 i = 0; - if ( _bHasCategories ) + for ( ColumnDescriptions::const_iterator col = aColumns.begin(); + col != aColumns.end(); + ++col + ) { - ++aColumnPosIter; - ++i; - } - for (; aColumnPosIter != aColumnPosEnd; ++aColumnPosIter,++i) - { - aValue.fill(*aColumnPosIter,aColumnTypes[i],xRow); + if ( bFirstColumnIsCategory && ( col == aColumns.begin() ) ) + continue; + + aValue.fill( col->nResultSetPosition, col->nDataType, xRow ); if ( aValue.isNull() ) { double nValue; ::rtl::math::setNan( &nValue ); - aRow.push_back(nValue); + aRow.push_back( nValue ); } else - aRow.push_back(aValue.getDouble()); + aRow.push_back( aValue.getDouble() ); } - aDataValues.push_back(aRow); - } // while( xRes->next() && (!m_RowLimit || nRowCount < m_RowLimit) ) + + aDataValues.push_back( aRow ); + } // insert default data when no rows exist if ( !nRowCount ) @@ -759,19 +828,29 @@ void DatabaseDataProvider::impl_fillInternalDataProvider_throw(sal_Bool _bHasCat aRowLabels.push_back(::rtl::OUString::valueOf(h+1)); ::std::vector< double > aRow; const sal_Int32 nSize = sizeof(fDefaultData)/sizeof(fDefaultData[0]); - for (sal_Int32 j = 0; j < (nCount-1); ++j,++k) + for (size_t j = 0; j < (aColumns.size()-1); ++j,++k) { if ( k >= nSize ) k = 0; aRow.push_back(fDefaultData[k]); - } // for (sal_Int32 j = 0,k = 0; j < (nCount-1); ++j,++k) + } // for (sal_Int32 j = 0,k = 0; j < (aColumns.size()-1); ++j,++k) aDataValues.push_back(aRow); } } // if ( !nRowCount ) uno::Reference< chart::XChartDataArray> xData(m_xInternal,uno::UNO_QUERY); xData->setRowDescriptions(uno::Sequence< ::rtl::OUString >(&(*aRowLabels.begin()),aRowLabels.size())); - xData->setColumnDescriptions(uno::Sequence< ::rtl::OUString >(aColumns.getArray()+ (_bHasCategories ? 1 : 0),aColumns.getLength() - (_bHasCategories ? 1 : 0) )); + + const size_t nOffset = bFirstColumnIsCategory ? 1 : 0; + uno::Sequence< ::rtl::OUString > aColumnDescriptions( aColumns.size() - nOffset ); + ::std::transform( + aColumns.begin() + nOffset, + aColumns.end(), + aColumnDescriptions.getArray(), + SelectColumnName() + ); + xData->setColumnDescriptions( aColumnDescriptions ); + uno::Sequence< uno::Sequence< double > > aData(aDataValues.size()); uno::Sequence< double >* pDataIter = aData.getArray(); uno::Sequence< double >* pDataEnd = pDataIter + aData.getLength(); diff --git a/reportdesign/source/core/sdr/RptObject.cxx b/reportdesign/source/core/sdr/RptObject.cxx index be6473135..17a5452ff 100644 --- a/reportdesign/source/core/sdr/RptObject.cxx +++ b/reportdesign/source/core/sdr/RptObject.cxx @@ -1221,20 +1221,12 @@ void OOle2Obj::initializeChart( const uno::Reference< frame::XModel>& _xModel) OReportModel* pRptModel = static_cast<OReportModel*>(GetModel()); pRptModel->GetUndoEnv().AddElement(lcl_getDataProvider(xObj)); - uno::Sequence< beans::PropertyValue > aArgs( 4 ); - aArgs[0] = beans::PropertyValue( - ::rtl::OUString::createFromAscii("CellRangeRepresentation"), -1, - uno::makeAny( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("all")) ), beans::PropertyState_DIRECT_VALUE ); - aArgs[1] = beans::PropertyValue( - ::rtl::OUString::createFromAscii("HasCategories"), -1, - uno::makeAny( sal_True ), beans::PropertyState_DIRECT_VALUE ); - aArgs[2] = beans::PropertyValue( - ::rtl::OUString::createFromAscii("FirstCellAsLabel"), -1, - uno::makeAny( sal_True ), beans::PropertyState_DIRECT_VALUE ); - aArgs[3] = beans::PropertyValue( - ::rtl::OUString::createFromAscii("DataRowSource"), -1, - uno::makeAny( chart::ChartDataRowSource_COLUMNS ), beans::PropertyState_DIRECT_VALUE ); - xReceiver->setArguments( aArgs ); + ::comphelper::NamedValueCollection aArgs; + aArgs.put( "CellRangeRepresentation", uno::makeAny( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "all" ) ) ) ); + aArgs.put( "HasCategories", uno::makeAny( sal_True ) ); + aArgs.put( "FirstCellAsLabel", uno::makeAny( sal_True ) ); + aArgs.put( "DataRowSource", uno::makeAny( chart::ChartDataRowSource_COLUMNS ) ); + xReceiver->setArguments( aArgs.getPropertyValues() ); if( xChartModel.is() ) xChartModel->unlockControllers(); diff --git a/reportdesign/source/filter/xml/xmlExportDocumentHandler.cxx b/reportdesign/source/filter/xml/xmlExportDocumentHandler.cxx index 40f211ecf..3127a07f3 100644 --- a/reportdesign/source/filter/xml/xmlExportDocumentHandler.cxx +++ b/reportdesign/source/filter/xml/xmlExportDocumentHandler.cxx @@ -349,14 +349,14 @@ void SAL_CALL ExportDocumentHandler::initialize( const uno::Sequence< uno::Any > if ( xDataProvider.is() ) { m_aColumns.realloc(1); - uno::Sequence< uno::Sequence< ::rtl::OUString > > aColumnNames = xDataProvider->getComplexColumnDescriptions(); + uno::Sequence< ::rtl::OUString > aColumnNames = xDataProvider->getColumnDescriptions(); 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]; + m_aColumns[nCount] = aColumnNames[i]; } } } diff --git a/reportdesign/source/filter/xml/xmlImportDocumentHandler.cxx b/reportdesign/source/filter/xml/xmlImportDocumentHandler.cxx index ef79ec3ee..91b699f7b 100644 --- a/reportdesign/source/filter/xml/xmlImportDocumentHandler.cxx +++ b/reportdesign/source/filter/xml/xmlImportDocumentHandler.cxx @@ -37,6 +37,7 @@ #include <comphelper/sequence.hxx> #include <comphelper/sequenceashashmap.hxx> #include <comphelper/documentconstants.hxx> +#include <comphelper/namedvaluecollection.hxx> #include <xmloff/attrlist.hxx> #include <xmloff/xmltoken.hxx> #include <xmloff/xmlement.hxx> @@ -56,8 +57,9 @@ using namespace ::xmloff::token; ::rtl::OUString lcl_createAttribute(const xmloff::token::XMLTokenEnum& _eNamespace,const xmloff::token::XMLTokenEnum& _eAttribute); -ImportDocumentHandler::ImportDocumentHandler(uno::Reference< uno::XComponentContext > const & context) : - m_xContext(context) +ImportDocumentHandler::ImportDocumentHandler(uno::Reference< uno::XComponentContext > const & context) + :m_xContext(context) + ,m_bImportedChart( false ) { } // ----------------------------------------------------------------------------- @@ -121,35 +123,24 @@ void SAL_CALL ImportDocumentHandler::endDocument() throw (uno::RuntimeException, { m_xDelegatee->endDocument(); uno::Reference< chart2::data::XDataReceiver > xReceiver(m_xModel,uno::UNO_QUERY_THROW); - if ( xReceiver.is() ) + if ( xReceiver.is() && m_bImportedChart ) { // this fills the chart again - uno::Sequence< beans::PropertyValue > aArgs( 4 ); - aArgs[0] = beans::PropertyValue( - ::rtl::OUString::createFromAscii("CellRangeRepresentation"), -1, - uno::makeAny( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("all")) ), beans::PropertyState_DIRECT_VALUE ); - aArgs[1] = beans::PropertyValue( - ::rtl::OUString::createFromAscii("HasCategories"), -1, - uno::makeAny( sal_True ), beans::PropertyState_DIRECT_VALUE ); - aArgs[2] = beans::PropertyValue( - ::rtl::OUString::createFromAscii("FirstCellAsLabel"), -1, - uno::makeAny( sal_True ), beans::PropertyState_DIRECT_VALUE ); - aArgs[3] = beans::PropertyValue( - ::rtl::OUString::createFromAscii("DataRowSource"), -1, - uno::makeAny( chart::ChartDataRowSource_COLUMNS ), beans::PropertyState_DIRECT_VALUE ); + ::comphelper::NamedValueCollection aArgs; + aArgs.put( "CellRangeRepresentation", ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("all")) ); + aArgs.put( "HasCategories", uno::makeAny( sal_True ) ); + aArgs.put( "FirstCellAsLabel", uno::makeAny( sal_True ) ); + aArgs.put( "DataRowSource", uno::makeAny( chart::ChartDataRowSource_COLUMNS ) ); uno::Reference< chart::XComplexDescriptionAccess > xDataProvider(m_xModel->getDataProvider(),uno::UNO_QUERY); if ( xDataProvider.is() ) { - aArgs.realloc(5); - uno::Sequence< uno::Sequence< ::rtl::OUString > > aColumnNames = xDataProvider->getComplexColumnDescriptions(); - aArgs[4] = beans::PropertyValue( - ::rtl::OUString::createFromAscii("ComplexColumnDescriptions"), -1, - uno::makeAny( aColumnNames ), beans::PropertyState_DIRECT_VALUE ); + const uno::Sequence< ::rtl::OUString > aColumnNames = xDataProvider->getColumnDescriptions(); + aArgs.put( "ColumnDescriptions", uno::makeAny( aColumnNames ) ); } - xReceiver->attachDataProvider(m_xDatabaseDataProvider.get()); - - xReceiver->setArguments( aArgs ); + + xReceiver->attachDataProvider( m_xDatabaseDataProvider.get() ); + xReceiver->setArguments( aArgs.getPropertyValues() ); } } @@ -204,6 +195,7 @@ void SAL_CALL ImportDocumentHandler::startElement(const ::rtl::OUString & _sName } m_xDelegatee->startElement(lcl_createAttribute(XML_NP_OFFICE,XML_CHART),NULL); bExport = false; + m_bImportedChart = true; } else if ( _sName.equalsAscii("rpt:master-detail-field") ) { diff --git a/reportdesign/source/filter/xml/xmlImportDocumentHandler.hxx b/reportdesign/source/filter/xml/xmlImportDocumentHandler.hxx index 3d5dd97c4..3066e537a 100644 --- a/reportdesign/source/filter/xml/xmlImportDocumentHandler.hxx +++ b/reportdesign/source/filter/xml/xmlImportDocumentHandler.hxx @@ -85,6 +85,7 @@ private: virtual ~ImportDocumentHandler(); ::osl::Mutex m_aMutex; + bool m_bImportedChart; ::std::vector< ::rtl::OUString> m_aMasterFields; ::std::vector< ::rtl::OUString> m_aDetailFields; ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > m_aArguments; diff --git a/reportdesign/source/ui/inspection/DataProviderHandler.cxx b/reportdesign/source/ui/inspection/DataProviderHandler.cxx index df42cdb8a..01635fe76 100644 --- a/reportdesign/source/ui/inspection/DataProviderHandler.cxx +++ b/reportdesign/source/ui/inspection/DataProviderHandler.cxx @@ -27,6 +27,7 @@ #include "precompiled_reportdesign.hxx" #include "DataProviderHandler.hxx" #include <com/sun/star/lang/XInitialization.hpp> +#include <comphelper/namedvaluecollection.hxx> #include <comphelper/sequence.hxx> #include <comphelper/property.hxx> #include <comphelper/types.hxx> @@ -469,21 +470,13 @@ void SAL_CALL DataProviderHandler::actuatingPropertyChanged(const ::rtl::OUStrin sal_Bool bModified = xReport->isModified(); // this fills the chart again - uno::Sequence< beans::PropertyValue > aArgs( 4 ); - aArgs[0] = beans::PropertyValue( - ::rtl::OUString::createFromAscii("CellRangeRepresentation"), -1, - uno::makeAny( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("all")) ), beans::PropertyState_DIRECT_VALUE ); - aArgs[1] = beans::PropertyValue( - ::rtl::OUString::createFromAscii("HasCategories"), -1, - uno::makeAny( sal_True ), beans::PropertyState_DIRECT_VALUE ); - aArgs[2] = beans::PropertyValue( - ::rtl::OUString::createFromAscii("FirstCellAsLabel"), -1, - uno::makeAny( sal_True ), beans::PropertyState_DIRECT_VALUE ); - aArgs[3] = beans::PropertyValue( - ::rtl::OUString::createFromAscii("DataRowSource"), -1, - uno::makeAny( chart::ChartDataRowSource_COLUMNS ), beans::PropertyState_DIRECT_VALUE ); + ::comphelper::NamedValueCollection aArgs; + aArgs.put( "CellRangeRepresentation", uno::makeAny( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "all" ) ) ) ); + aArgs.put( "HasCategories", uno::makeAny( sal_True ) ); + aArgs.put( "FirstCellAsLabel", uno::makeAny( sal_True ) ); + aArgs.put( "DataRowSource", uno::makeAny( chart::ChartDataRowSource_COLUMNS ) ); uno::Reference< chart2::data::XDataReceiver > xReceiver(m_xChartModel,uno::UNO_QUERY_THROW); - xReceiver->setArguments( aArgs ); + xReceiver->setArguments( aArgs.getPropertyValues() ); if ( !bModified ) xReport->setModified(sal_False); } // if ( NewValue != OldValue ) |