dba33g: #i112213# handle chart import for columns
This commit is contained in:
@@ -158,14 +158,21 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs,
|
||||
try
|
||||
{
|
||||
Reference< XResultSetUpdate> xUp(_xRs,UNO_QUERY_THROW);
|
||||
xUp->moveToInsertRow();
|
||||
xUp->cancelRowUpdates();
|
||||
_xRs->beforeFirst();
|
||||
m_nPrivileges = Privilege::SELECT|Privilege::DELETE|Privilege::INSERT|Privilege::UPDATE;
|
||||
m_pCacheSet = new WrappedResultSet();
|
||||
m_xCacheSet = m_pCacheSet;
|
||||
m_pCacheSet->construct(_xRs,i_sRowSetFilter);
|
||||
return;
|
||||
Reference< XPropertySet> xProp(_xRs,UNO_QUERY);
|
||||
Reference< XPropertySetInfo > xPropInfo = xProp->getPropertySetInfo();
|
||||
sal_Bool bBookmarkable = xPropInfo->hasPropertyByName(PROPERTY_ISBOOKMARKABLE) &&
|
||||
any2bool(xProp->getPropertyValue(PROPERTY_ISBOOKMARKABLE)) && Reference< XRowLocate >(_xRs, UNO_QUERY).is();
|
||||
if ( bBookmarkable )
|
||||
{
|
||||
xUp->moveToInsertRow();
|
||||
xUp->cancelRowUpdates();
|
||||
_xRs->beforeFirst();
|
||||
m_nPrivileges = Privilege::SELECT|Privilege::DELETE|Privilege::INSERT|Privilege::UPDATE;
|
||||
m_pCacheSet = new WrappedResultSet();
|
||||
m_xCacheSet = m_pCacheSet;
|
||||
m_pCacheSet->construct(_xRs,i_sRowSetFilter);
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch(const Exception& ex)
|
||||
{
|
||||
|
||||
@@ -201,7 +201,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);
|
||||
void impl_fillInternalDataProvider_throw(sal_Bool _bHasCategories,const ::com::sun::star::uno::Sequence< ::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;
|
||||
|
||||
|
||||
@@ -204,6 +204,7 @@ uno::Reference< chart2::data::XDataSource > SAL_CALL DatabaseDataProvider::creat
|
||||
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)
|
||||
@@ -211,7 +212,11 @@ uno::Reference< chart2::data::XDataSource > SAL_CALL DatabaseDataProvider::creat
|
||||
if ( pArgIter->Name.equalsAscii("HasCategories") )
|
||||
{
|
||||
pArgIter->Value >>= bHasCategories;
|
||||
break;
|
||||
|
||||
}
|
||||
else if ( pArgIter->Name.equalsAscii("ComplexColumnDescriptions") )
|
||||
{
|
||||
pArgIter->Value >>= aColumnNames;
|
||||
}
|
||||
}
|
||||
bool bRet = false;
|
||||
@@ -221,7 +226,7 @@ uno::Reference< chart2::data::XDataSource > SAL_CALL DatabaseDataProvider::creat
|
||||
{
|
||||
impl_fillRowSet_throw();
|
||||
impl_executeRowSet_throw(aClearForNotifies);
|
||||
impl_fillInternalDataProvider_throw(bHasCategories);
|
||||
impl_fillInternalDataProvider_throw(bHasCategories,aColumnNames);
|
||||
bRet = true;
|
||||
}
|
||||
catch(const uno::Exception& /*e*/)
|
||||
@@ -574,7 +579,7 @@ void DatabaseDataProvider::impl_executeRowSet_throw(::osl::ResettableMutexGuard&
|
||||
m_xRowSet->execute();
|
||||
}
|
||||
// -----------------------------------------------------------------------------
|
||||
void DatabaseDataProvider::impl_fillInternalDataProvider_throw(sal_Bool _bHasCategories)
|
||||
void DatabaseDataProvider::impl_fillInternalDataProvider_throw(sal_Bool _bHasCategories,const uno::Sequence< uno::Sequence< ::rtl::OUString > >& i_aColumnNames)
|
||||
{
|
||||
// clear the data before fill the new one
|
||||
uno::Reference< chart::XChartDataArray> xChartData(m_xInternal,uno::UNO_QUERY);
|
||||
@@ -586,11 +591,30 @@ void DatabaseDataProvider::impl_fillInternalDataProvider_throw(sal_Bool _bHasCat
|
||||
m_xInternal->deleteSequence(0);
|
||||
}
|
||||
|
||||
uno::Sequence< ::rtl::OUString > aColumns;
|
||||
uno::Reference< sdbcx::XColumnsSupplier> xColSup(m_xRowSet,uno::UNO_QUERY_THROW);
|
||||
uno::Reference< container::XNameAccess > xColumns = xColSup->getColumns();
|
||||
if ( xColumns.is() )
|
||||
uno::Sequence< ::rtl::OUString > aColumns;
|
||||
if ( i_aColumnNames.getLength() )
|
||||
{
|
||||
if ( _bHasCategories )
|
||||
{
|
||||
aColumns.realloc(1);
|
||||
aColumns[0] = xColumns->getElementNames()[0];
|
||||
}
|
||||
for(sal_Int32 i = 0 ; i < i_aColumnNames.getLength();++i)
|
||||
{
|
||||
if ( i_aColumnNames[i].getLength() )
|
||||
{
|
||||
sal_Int32 nCount = aColumns.getLength();
|
||||
aColumns.realloc(nCount+1);
|
||||
aColumns[nCount] = i_aColumnNames[i][0];
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
aColumns = xColumns->getElementNames();
|
||||
}
|
||||
// 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);
|
||||
|
||||
@@ -289,7 +289,9 @@ void SAL_CALL ExportDocumentHandler::endElement(const ::rtl::OUString & _sName)
|
||||
void SAL_CALL ExportDocumentHandler::characters(const ::rtl::OUString & aChars) throw (uno::RuntimeException, xml::sax::SAXException)
|
||||
{
|
||||
if ( !(m_bTableRowsStarted || m_bFirstRowExported) )
|
||||
{
|
||||
m_xDelegatee->characters(aChars);
|
||||
}
|
||||
else if ( m_bExportChar )
|
||||
{
|
||||
static const ::rtl::OUString s_sZero(RTL_CONSTASCII_USTRINGPARAM("0"));
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <com/sun/star/sdb/CommandType.hpp>
|
||||
#include <com/sun/star/chart2/data/DatabaseDataProvider.hpp>
|
||||
#include <com/sun/star/chart2/data/XDataReceiver.hpp>
|
||||
#include <com/sun/star/chart/XComplexDescriptionAccess.hpp>
|
||||
#include <com/sun/star/chart/ChartDataRowSource.hpp>
|
||||
#include <com/sun/star/reflection/XProxyFactory.hpp>
|
||||
#include <com/sun/star/sdb/CommandType.hpp>
|
||||
@@ -122,7 +123,6 @@ void SAL_CALL ImportDocumentHandler::endDocument() throw (uno::RuntimeException,
|
||||
uno::Reference< chart2::data::XDataReceiver > xReceiver(m_xModel,uno::UNO_QUERY_THROW);
|
||||
if ( xReceiver.is() )
|
||||
{
|
||||
xReceiver->attachDataProvider(m_xDatabaseDataProvider.get());
|
||||
// this fills the chart again
|
||||
uno::Sequence< beans::PropertyValue > aArgs( 4 );
|
||||
aArgs[0] = beans::PropertyValue(
|
||||
@@ -137,6 +137,18 @@ void SAL_CALL ImportDocumentHandler::endDocument() throw (uno::RuntimeException,
|
||||
aArgs[3] = beans::PropertyValue(
|
||||
::rtl::OUString::createFromAscii("DataRowSource"), -1,
|
||||
uno::makeAny( chart::ChartDataRowSource_COLUMNS ), beans::PropertyState_DIRECT_VALUE );
|
||||
|
||||
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 );
|
||||
}
|
||||
xReceiver->attachDataProvider(m_xDatabaseDataProvider.get());
|
||||
|
||||
xReceiver->setArguments( aArgs );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user