Convert xlsx unnamed database range import to direct sc

Will evaluate later if further conversion is useful here

Change-Id: I6af5296b95075066335783e371d87be15f09f112
This commit is contained in:
Daniel Bankston
2012-08-07 04:21:54 -05:00
committed by Kohei Yoshida
parent 5d906574f2
commit ccce242c3a
2 changed files with 17 additions and 5 deletions

View File

@@ -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,

View File

@@ -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& )
{