sc/source/filter/inc/tablecolumnsbuffer.hxx | 12 ++++++---- sc/source/filter/inc/workbookhelper.hxx | 4 +++ sc/source/filter/oox/tablebuffer.cxx | 10 ++++++++ sc/source/filter/oox/tablecolumnsbuffer.cxx | 33 ++++++++++++++++------------ sc/source/filter/oox/workbookhelper.cxx | 15 ++++++++++++ sc/source/filter/oox/worksheethelper.cxx | 1 6 files changed, 58 insertions(+), 17 deletions(-)
New commits: commit dac06eac81b84fe88f38ba0bb2e4873da1c114b7 Author: Eike Rathke <er...@redhat.com> Date: Wed Jun 24 19:40:54 2015 +0200 TableRef: import OOXML table column names to ScDBData Change-Id: I5fa32922fffcd027ddf1c61fe0b122fa2d320d98 (cherry picked from commit 715b4bbca56ca3cb1f26184a0461ea07c485b8f3) diff --git a/sc/source/filter/inc/tablecolumnsbuffer.hxx b/sc/source/filter/inc/tablecolumnsbuffer.hxx index dc8e427f..2ccfcbc 100644 --- a/sc/source/filter/inc/tablecolumnsbuffer.hxx +++ b/sc/source/filter/inc/tablecolumnsbuffer.hxx @@ -23,6 +23,8 @@ #include <oox/helper/refvector.hxx> #include "workbookhelper.hxx" +class ScDBData; + namespace oox { namespace xls { @@ -37,6 +39,8 @@ public: void importTableColumn( const AttributeList& rAttribs ); /** Imports table column settings from the TABLECOLUMN (?) record. */ void importTableColumn( SequenceInputStream& rStrm ); + /** Gets the name of this column. */ + const OUString& getName() const; private: OUString maName; @@ -57,8 +61,8 @@ public: /** Creates a new table column and stores it internally. */ TableColumn& createTableColumn(); - /** Applies the columns to the passed database range descriptor. */ - bool finalizeImport( const ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XDatabaseRange >& rxDatabaseRange ); + /** Applies the columns to the passed database range. */ + bool finalizeImport( ScDBData* pDBData ); private: typedef RefVector< TableColumn > TableColumnVector; @@ -75,9 +79,9 @@ public: /** Creates a new table columns object and stores it internally. */ TableColumns& createTableColumns(); - /** Applies the table columns to the passed database range object. + /** Applies the table columns to the passed database range. @return True = this buffer contains valid table column settings. */ - bool finalizeImport( const ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XDatabaseRange >& rxDatabaseRange ); + bool finalizeImport( ScDBData* pDBData ); private: /** Returns the table columns object used. */ diff --git a/sc/source/filter/inc/workbookhelper.hxx b/sc/source/filter/inc/workbookhelper.hxx index e2d26a5..f4a82ea 100644 --- a/sc/source/filter/inc/workbookhelper.hxx +++ b/sc/source/filter/inc/workbookhelper.hxx @@ -60,6 +60,7 @@ class ScDocument; class ScDocShell; class ScDocumentImport; class ScEditEngineDefaulter; +class ScDBData; namespace oox { namespace xls { @@ -207,6 +208,9 @@ public: createUnnamedDatabaseRangeObject( const ::com::sun::star::table::CellRangeAddress& rRangeAddr ) const; + /** Finds the (already existing) database range of the given formula token index. */ + ScDBData* findDatabaseRangeByIndex( sal_uInt16 nIndex ) const; + /** Creates and returns a com.sun.star.style.Style object for cells or pages. */ ::com::sun::star::uno::Reference< ::com::sun::star::style::XStyle > createStyleObject( diff --git a/sc/source/filter/oox/tablebuffer.cxx b/sc/source/filter/oox/tablebuffer.cxx index b1fddcc..779b784 100644 --- a/sc/source/filter/oox/tablebuffer.cxx +++ b/sc/source/filter/oox/tablebuffer.cxx @@ -130,6 +130,11 @@ void Table::applyAutoFilters() } } +void Table::applyTableColumns() +{ + maTableColumns.finalizeImport( findDatabaseRangeByIndex( mnTokenIndex )); +} + TableBuffer::TableBuffer( const WorkbookHelper& rHelper ) : WorkbookHelper( rHelper ) { @@ -156,6 +161,11 @@ void TableBuffer::applyAutoFilters() maIdTables.forEachMem( &Table::applyAutoFilters ); } +void TableBuffer::applyTableColumns() +{ + maIdTables.forEachMem( &Table::applyTableColumns ); +} + TableRef TableBuffer::getTable( sal_Int32 nTableId ) const { return maIdTables.get( nTableId ); diff --git a/sc/source/filter/oox/tablecolumnsbuffer.cxx b/sc/source/filter/oox/tablecolumnsbuffer.cxx index 5879fc3..c6bf8d3 100644 --- a/sc/source/filter/oox/tablecolumnsbuffer.cxx +++ b/sc/source/filter/oox/tablecolumnsbuffer.cxx @@ -29,6 +29,7 @@ #include "addressconverter.hxx" #include "biffinputstream.hxx" #include "defnamesbuffer.hxx" +#include "dbdata.hxx" namespace oox { namespace xls { @@ -56,6 +57,11 @@ void TableColumn::importTableColumn( SequenceInputStream& /*rStrm*/ ) /* XXX not implemented */ } +const OUString& TableColumn::getName() const +{ + return maName; +} + TableColumns::TableColumns( const WorkbookHelper& rHelper ) : WorkbookHelper( rHelper ), mnCount(0) @@ -79,13 +85,21 @@ TableColumn& TableColumns::createTableColumn() return *xTableColumn; } -bool TableColumns::finalizeImport( const Reference< XDatabaseRange >& rxDatabaseRange ) +bool TableColumns::finalizeImport( ScDBData* pDBData ) { SAL_WARN_IF( static_cast<size_t>(mnCount) != maTableColumnVector.size(), "sc.filter", "TableColumns::finalizeImport - count attribute doesn't match number of tableColumn elements"); - if( rxDatabaseRange.is() ) + if ( pDBData ) { - /* TODO: implementation */ + /* TODO: use svl::SharedString for names */ + ::std::vector< OUString > aNames( maTableColumnVector.size()); + size_t i = 0; + for (TableColumnVector::const_iterator aIt = maTableColumnVector.begin(), aEnd = maTableColumnVector.end(); + aIt != aEnd; ++aIt, ++i) + { + aNames[i] = (*aIt)->getName(); + } + pDBData->SetTableColumnNames( aNames); return true; } return false; @@ -103,18 +117,11 @@ TableColumns& TableColumnsBuffer::createTableColumns() return *xTableColumns; } -bool TableColumnsBuffer::finalizeImport( const Reference< XDatabaseRange >& rxDatabaseRange ) +bool TableColumnsBuffer::finalizeImport( ScDBData* pDBData ) { TableColumns* pTableColumns = getActiveTableColumns(); - if( pTableColumns && rxDatabaseRange.is() ) try - { - pTableColumns->finalizeImport( rxDatabaseRange ); - // return true to indicate available table columns - return true; - } - catch( Exception& ) - { - } + if ( pTableColumns ) + return pTableColumns->finalizeImport( pDBData ); return false; } diff --git a/sc/source/filter/oox/workbookhelper.cxx b/sc/source/filter/oox/workbookhelper.cxx index f34332a..d264e56 100644 --- a/sc/source/filter/oox/workbookhelper.cxx +++ b/sc/source/filter/oox/workbookhelper.cxx @@ -167,6 +167,8 @@ public: Reference< XDatabaseRange > createDatabaseRangeObject( OUString& orName, const CellRangeAddress& rRangeAddr ); /** Creates and returns an unnamed database range on-the-fly in the Calc document. */ Reference< XDatabaseRange > createUnnamedDatabaseRangeObject( const CellRangeAddress& rRangeAddr ); + /** Finds the (already existing) database range of the given formula token index. */ + ScDBData* findDatabaseRangeByIndex( sal_uInt16 nIndex ); /** Creates and returns a com.sun.star.style.Style object for cells or pages. */ Reference< XStyle > createStyleObject( OUString& orStyleName, bool bPageStyle ); /** Helper to switch chart data table - specifically for xlsx imports */ @@ -495,6 +497,14 @@ Reference< XDatabaseRange > WorkbookGlobals::createUnnamedDatabaseRangeObject( c return xDatabaseRange; } +ScDBData* WorkbookGlobals::findDatabaseRangeByIndex( sal_uInt16 nIndex ) +{ + ScDBCollection* pDBCollection = getScDocument().GetDBCollection(); + if (!pDBCollection) + return nullptr; + return pDBCollection->getNamedDBs().findByIndex( nIndex ); +} + Reference< XStyle > WorkbookGlobals::createStyleObject( OUString& orStyleName, bool bPageStyle ) { Reference< XStyle > xStyle; @@ -901,6 +911,11 @@ Reference< XDatabaseRange > WorkbookHelper::createUnnamedDatabaseRangeObject( co return mrBookGlob.createUnnamedDatabaseRangeObject( rRangeAddr ); } +ScDBData* WorkbookHelper::findDatabaseRangeByIndex( sal_uInt16 nIndex ) const +{ + return mrBookGlob.findDatabaseRangeByIndex( nIndex ); +} + Reference< XStyle > WorkbookHelper::createStyleObject( OUString& orStyleName, bool bPageStyle ) const { return mrBookGlob.createStyleObject( orStyleName, bPageStyle ); diff --git a/sc/source/filter/oox/worksheethelper.cxx b/sc/source/filter/oox/worksheethelper.cxx index d74f344..9875f0e 100644 --- a/sc/source/filter/oox/worksheethelper.cxx +++ b/sc/source/filter/oox/worksheethelper.cxx @@ -943,6 +943,7 @@ void WorksheetGlobals::finalizeWorksheetImport() // assumes getTables().finalizeImport ( which creates the DatabaseRanges ) // has been called already getTables().applyAutoFilters(); + getTables().applyTableColumns(); getCondFormats().finalizeImport(); lclUpdateProgressBar( mxFinalProgress, 0.25 ); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits