From ccce242c3a8892f1bc5b649ca43a544cdced28d9 Mon Sep 17 00:00:00 2001 From: Daniel Bankston Date: Tue, 7 Aug 2012 04:21:54 -0500 Subject: [PATCH] Convert xlsx unnamed database range import to direct sc Will evaluate later if further conversion is useful here Change-Id: I6af5296b95075066335783e371d87be15f09f112 --- sc/inc/datauno.hxx | 2 +- sc/source/filter/oox/workbookhelper.cxx | 20 ++++++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/sc/inc/datauno.hxx b/sc/inc/datauno.hxx index afe59fd98b42..75bd8938b1df 100644 --- a/sc/inc/datauno.hxx +++ b/sc/inc/datauno.hxx @@ -494,7 +494,7 @@ public: }; -class ScDatabaseRangeObj : public cppu::WeakImplHelper6< +class SC_DLLPUBLIC ScDatabaseRangeObj : public cppu::WeakImplHelper6< com::sun::star::sheet::XDatabaseRange, com::sun::star::util::XRefreshable, com::sun::star::container::XNamed, diff --git a/sc/source/filter/oox/workbookhelper.cxx b/sc/source/filter/oox/workbookhelper.cxx index 701b2b8075e0..7d6aa77d7974 100644 --- a/sc/source/filter/oox/workbookhelper.cxx +++ b/sc/source/filter/oox/workbookhelper.cxx @@ -76,6 +76,10 @@ #include "rangenam.hxx" #include "tokenarray.hxx" #include "tokenuno.hxx" +#include "convuno.hxx" +#include "dbdata.hxx" +#include "datauno.hxx" +#include "globalnames.hxx" #include "formulabuffer.hxx" namespace oox { @@ -464,12 +468,20 @@ Reference< XDatabaseRange > WorkbookGlobals::createUnnamedDatabaseRangeObject( c // create database range and insert it into the Calc document Reference< XDatabaseRange > xDatabaseRange; - PropertySet aDocProps( mxDoc ); - Reference< XUnnamedDatabaseRanges > xDatabaseRanges( aDocProps.getAnyProperty( PROP_UnnamedDatabaseRanges ), UNO_QUERY_THROW ); if( bValidRange ) try { - xDatabaseRanges->setByTable( aDestRange ); - xDatabaseRange.set( xDatabaseRanges->getByTable( aDestRange.Sheet ), UNO_QUERY ); + ScDocument& rDoc = getScDocument(); + if( rDoc.GetTableCount() <= aDestRange.Sheet ) + throw ::com::sun::star::lang::IndexOutOfBoundsException(); + ScRange aScRange; + ScUnoConversion::FillScRange(aScRange, aDestRange); + ScDBData* pNewDBData = new ScDBData( STR_DB_LOCAL_NONAME, aScRange.aStart.Tab(), + aScRange.aStart.Col(), aScRange.aStart.Row(), + aScRange.aEnd.Col(), aScRange.aEnd.Row() ); + rDoc.SetAnonymousDBData( aScRange.aStart.Tab() , pNewDBData ); + ScDocShell* pDocSh = static_cast< ScDocShell* >(rDoc.GetDocumentShell()); + ScDatabaseRangeObj* pDBRangeObj = new ScDatabaseRangeObj( pDocSh, aScRange.aStart.Tab() ); + xDatabaseRange.set( pDBRangeObj ); } catch( Exception& ) {