summaryrefslogtreecommitdiff
path: root/oox/source/xls
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2011-05-05 18:17:52 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2011-05-08 22:47:18 +0200
commitb386d3b6895b4c9110b42077b41e6f5cb1992638 (patch)
tree26ed780290c791ac5df6322052cb757081f49e4c /oox/source/xls
parent3a7668b2a7ffda1877b92e9a988486bd920ee425 (diff)
make OOXML import use sheet local db data
Diffstat (limited to 'oox/source/xls')
-rw-r--r--oox/source/xls/autofilterbuffer.cxx3
-rw-r--r--oox/source/xls/tablebuffer.cxx2
-rw-r--r--oox/source/xls/workbookhelper.cxx32
3 files changed, 33 insertions, 4 deletions
diff --git a/oox/source/xls/autofilterbuffer.cxx b/oox/source/xls/autofilterbuffer.cxx
index 7cf359f6d3c9..e7b6f321f9b0 100644
--- a/oox/source/xls/autofilterbuffer.cxx
+++ b/oox/source/xls/autofilterbuffer.cxx
@@ -772,8 +772,7 @@ void AutoFilterBuffer::finalizeImport( sal_Int16 nSheet )
if( pFilterDBName->getAbsoluteRange( aFilterRange ) && (aFilterRange.Sheet == nSheet) )
{
// use the same name for the database range as used for the defined name '_FilterDatabase'
- OUString aDBRangeName = pFilterDBName->getCalcName();
- Reference< XDatabaseRange > xDatabaseRange = createDatabaseRangeObject( aDBRangeName, aFilterRange );
+ Reference< XDatabaseRange > xDatabaseRange = createUnnamedDatabaseRangeObject( aFilterRange );
// first, try to create an auto filter
bool bHasAutoFilter = finalizeImport( xDatabaseRange );
// no success: try to create an advanced filter
diff --git a/oox/source/xls/tablebuffer.cxx b/oox/source/xls/tablebuffer.cxx
index a0ad1144b152..d3390204bce7 100644
--- a/oox/source/xls/tablebuffer.cxx
+++ b/oox/source/xls/tablebuffer.cxx
@@ -94,7 +94,7 @@ void Table::finalizeImport()
if( (maModel.mnId > 0) && (maModel.maDisplayName.getLength() > 0) ) try
{
maDBRangeName = maModel.maDisplayName;
- Reference< XDatabaseRange > xDatabaseRange( createDatabaseRangeObject( maDBRangeName, maModel.maRange ), UNO_SET_THROW );
+ Reference< XDatabaseRange > xDatabaseRange( createUnnamedDatabaseRangeObject( maModel.maRange ), UNO_SET_THROW );
maDestRange = xDatabaseRange->getDataArea();
// get formula token index of the database range
diff --git a/oox/source/xls/workbookhelper.cxx b/oox/source/xls/workbookhelper.cxx
index ed13bddadfa7..b7533d3f7a2e 100644
--- a/oox/source/xls/workbookhelper.cxx
+++ b/oox/source/xls/workbookhelper.cxx
@@ -33,6 +33,7 @@
#include <com/sun/star/document/XActionLockable.hpp>
#include <com/sun/star/sheet/XDatabaseRange.hpp>
#include <com/sun/star/sheet/XDatabaseRanges.hpp>
+#include <com/sun/star/sheet/XUnnamedDatabaseRanges.hpp>
#include <com/sun/star/sheet/XNamedRange.hpp>
#include <com/sun/star/sheet/XNamedRanges.hpp>
#include <com/sun/star/sheet/XSpreadsheet.hpp>
@@ -140,6 +141,8 @@ public:
Reference< XNamedRange > createNamedRangeObject( OUString& orName, sal_Int32 nNameFlags ) const;
/** Creates and returns a database range on-the-fly in the Calc document. */
Reference< XDatabaseRange > createDatabaseRangeObject( OUString& orName, const CellRangeAddress& rRangeAddr ) const;
+ /** Creates and returns an unnamed database range on-the-fly in the Calc document. */
+ Reference< XDatabaseRange > createUnnamedDatabaseRangeObject( const CellRangeAddress& rRangeAddr ) const;
/** Creates and returns a com.sun.star.style.Style object for cells or pages. */
Reference< XStyle > createStyleObject( OUString& orStyleName, bool bPageStyle ) const;
@@ -400,6 +403,28 @@ Reference< XDatabaseRange > WorkbookData::createDatabaseRangeObject( OUString& o
return xDatabaseRange;
}
+Reference< XDatabaseRange > WorkbookData::createUnnamedDatabaseRangeObject( const CellRangeAddress& rRangeAddr ) const
+{
+ // validate cell range
+ CellRangeAddress aDestRange = rRangeAddr;
+ bool bValidRange = getAddressConverter().validateCellRange( aDestRange, true, true );
+
+ // 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 );
+ }
+ catch( Exception& )
+ {
+ }
+ OSL_ENSURE( xDatabaseRange.is(), "WorkbookData::createDatabaseRangeObject - cannot create database range" );
+ return xDatabaseRange;
+}
+
Reference< XStyle > WorkbookData::createStyleObject( OUString& orStyleName, bool bPageStyle ) const
{
Reference< XStyle > xStyle;
@@ -748,6 +773,11 @@ Reference< XDatabaseRange > WorkbookHelper::createDatabaseRangeObject( OUString&
return mrBookData.createDatabaseRangeObject( orName, rRangeAddr );
}
+Reference< XDatabaseRange > WorkbookHelper::createUnnamedDatabaseRangeObject( const CellRangeAddress& rRangeAddr ) const
+{
+ return mrBookData.createUnnamedDatabaseRangeObject( rRangeAddr );
+}
+
Reference< XStyle > WorkbookHelper::createStyleObject( OUString& orStyleName, bool bPageStyle ) const
{
return mrBookData.createStyleObject( orStyleName, bPageStyle );
@@ -947,4 +977,4 @@ bool WorkbookHelperRoot::isValid() const
} // namespace xls
} // namespace oox
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ \ No newline at end of file
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */