summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkash Shetye <shetyeakash@gmail.com>2013-08-01 08:14:25 +0530
committerKohei Yoshida <kohei.yoshida@gmail.com>2013-08-05 14:30:24 -0400
commitee1a8cd42dc271f469b3d698627cabe565f59235 (patch)
tree8809c02db66c8ecbd55c7170b9bbfebd4609bbac
parentd3fbf3bebfaf75d94f08a6560d5f916932440280 (diff)
Completed the export of DBData ranges to xlsx.
All tags covered except auto filter tag. Need to add code to decide which DBData need to be exported by looking only for the ones that implement table style instead of exporting each one of them. Change-Id: I2655b62a33b516c6ba5516cf90fcc2627604770e
-rw-r--r--sc/Library_scfilt.mk1
-rw-r--r--sc/source/filter/excel/excdoc.cxx2
-rw-r--r--sc/source/filter/excel/xedbdata.cxx77
-rw-r--r--sc/source/filter/excel/xeroot.cxx9
-rw-r--r--sc/source/filter/inc/xedbdata.hxx15
-rw-r--r--sc/source/filter/inc/xeroot.hxx6
6 files changed, 103 insertions, 7 deletions
diff --git a/sc/Library_scfilt.mk b/sc/Library_scfilt.mk
index 89b96ed9017c..e14c48ac112e 100644
--- a/sc/Library_scfilt.mk
+++ b/sc/Library_scfilt.mk
@@ -89,6 +89,7 @@ $(eval $(call gb_Library_add_exception_objects,scfilt,\
sc/source/filter/excel/tokstack \
sc/source/filter/excel/xechart \
sc/source/filter/excel/xecontent \
+ sc/source/filter/excel/xedbdata \
sc/source/filter/excel/xeescher \
sc/source/filter/excel/xeextlst \
sc/source/filter/excel/xeformula \
diff --git a/sc/source/filter/excel/excdoc.cxx b/sc/source/filter/excel/excdoc.cxx
index 89dcce8cb1cb..b002f3cf9466 100644
--- a/sc/source/filter/excel/excdoc.cxx
+++ b/sc/source/filter/excel/excdoc.cxx
@@ -68,6 +68,7 @@
#include "xeescher.hxx"
#include "xepivot.hxx"
#include "XclExpChangeTrack.hxx"
+#include "xedbdata.hxx"
#include <math.h>
@@ -313,6 +314,7 @@ void ExcTable::FillAsHeader( ExcBoundsheetList& rBoundsheetList )
if( GetOutput() != EXC_OUTPUT_BINARY )
{
aRecList.AppendNewRecord( new XclExpXmlStyleSheet( *this ) );
+ aRecList.AppendNewRecord( new XclExpXmlDBDataTables( *this ) );
}
else
{
diff --git a/sc/source/filter/excel/xedbdata.cxx b/sc/source/filter/excel/xedbdata.cxx
index ebce789f3f35..0b178ac97a0e 100644
--- a/sc/source/filter/excel/xedbdata.cxx
+++ b/sc/source/filter/excel/xedbdata.cxx
@@ -19,53 +19,100 @@
#include "xedbdata.hxx"
#include "document.hxx"
+#include "address.hxx"
+#include "globstr.hrc"
+
+#include <oox/token/tokens.hxx>
+
+using namespace oox;
XclExpXmlDBDataStyleInfo::XclExpXmlDBDataStyleInfo( const XclExpRoot& rRoot, ScDBDataFormatting& rDBDataFormatting )
- : XclExpRoot( rRoot )
+ : XclExpRoot( rRoot ),
+ maDBDataFormatting( rDBDataFormatting )
{
}
void XclExpXmlDBDataStyleInfo::SaveXml( XclExpXmlStream& rStrm )
{
+ sax_fastparser::FSHelperPtr& rDBDataTable = rStrm.GetCurrentStream();
+ rDBDataTable->singleElement( XML_tableStyleInfo, XML_name, OUStringToOString(maDBDataFormatting.GetTableStyleName(), RTL_TEXTENCODING_UTF8 ).getStr(), XML_showFirstColumn, XclXmlUtils::ToPsz( false ), XML_showLastColumn, XclXmlUtils::ToPsz( false ), XML_showRowStripes, XclXmlUtils::ToPsz( maDBDataFormatting.GetBandedRows() ), XML_showColumnStripes, XclXmlUtils::ToPsz( maDBDataFormatting.GetBandedColumns() ),FSEND );// hardcoded two values for functions not supported yet
}
// ============================================================================
XclExpXmlDBDataColumn::XclExpXmlDBDataColumn( const XclExpRoot& rRoot, int iID, OUString& rName )
- : XclExpRoot( rRoot )
+ : XclExpRoot( rRoot ),
+ maName( rName ),
+ miID( iID )
{
}
void XclExpXmlDBDataColumn::SaveXml( XclExpXmlStream& rStrm )
{
+ sax_fastparser::FSHelperPtr& rDBDataTable = rStrm.GetCurrentStream();
+ rDBDataTable->singleElement( XML_tableColumn, XML_id, OString::number( miID ).getStr(), XML_name, OUStringToOString( maName, RTL_TEXTENCODING_UTF8 ), FSEND );
}
// ============================================================================
XclExpXmlDBDataColumns::XclExpXmlDBDataColumns( const XclExpRoot& rRoot, ScDBData& rDBData )
: XclExpRoot( rRoot )
{
+ ScRange aRange;
+ rDBData.GetArea( aRange );
+ SCROW anRow1, anRow2;
+ SCCOL anCol1, anCol2, anTotalCols;
+ SCTAB anTab1, anTab2;
+ aRange.GetVars( anCol1, anRow1, anTab1, anCol2, anRow2, anTab2 );
+ anTotalCols = (anCol2 - anCol1) + 1; //addressing starts from 0
+ // Needs special handling for different tab ranges
+ miCount = anTotalCols;
+ OUString aColName = "Column";
+ for( int i = 1; i <= anTotalCols; i++ )
+ {
+ OUString aStri = aColName + OUString::number( i );
+ maDBDataColumnContainer.push_back( new XclExpXmlDBDataColumn( rRoot, i, aStri ) );
+ }
}
void XclExpXmlDBDataColumns::SaveXml( XclExpXmlStream& rStrm )
{
+ sax_fastparser::FSHelperPtr& rDBDataTable = rStrm.GetCurrentStream();
+ rDBDataTable->startElement( XML_tableColumns, XML_count, OString::number( miCount ).getStr(), FSEND );
+ for ( DBDataColumnContainer::iterator itr = maDBDataColumnContainer.begin(); itr != maDBDataColumnContainer.end(); ++itr )
+ {
+ itr->SaveXml( rStrm );
+ }
+ rDBDataTable->endElement( XML_tableColumns );
}
// ============================================================================
-XclExpXmlDBDataTable::XclExpXmlDBDataTable(const XclExpRoot& rRoot, ScDBData& rDBData )
- : XclExpRoot( rRoot )
+XclExpXmlDBDataTable::XclExpXmlDBDataTable(const XclExpRoot& rRoot, ScDBData& rDBData, int nTableId )
+ : XclExpRoot( rRoot ),
+ mnTableId( nTableId )
{
maTableColumns.reset( new XclExpXmlDBDataColumns( rRoot, rDBData ) );
ScDBDataFormatting aDBFormatting;
rDBData.GetTableFormatting( aDBFormatting );
+ maName = OUString("Table") + OUString::number( mnTableId );
+ maDisplayName = rDBData.GetName();
+ mbTotalsRowShown = false; // Not supported yet in ScDBData
+ rDBData.GetArea( maRange );
maStyleInfo.reset( new XclExpXmlDBDataStyleInfo( rRoot, aDBFormatting) );
}
void XclExpXmlDBDataTable::SaveXml( XclExpXmlStream& rStrm )
{
+ sax_fastparser::FSHelperPtr& rDBDataTable = rStrm.GetCurrentStream();
+ rDBDataTable->startElement( XML_table, XML_id, OString::number( mnTableId ).getStr(), XML_name, OUStringToOString( maName, RTL_TEXTENCODING_UTF8 ).getStr(), XML_displayName, OUStringToOString( maDisplayName, RTL_TEXTENCODING_UTF8 ).getStr(), XML_ref, XclXmlUtils::ToOString( maRange ).getStr() ,FSEND);
+ maTableColumns->SaveXml( rStrm );
+ maStyleInfo->SaveXml( rStrm );
+ rDBDataTable->endElement( XML_table );
+
}
// =============================================================================
XclExpXmlDBDataTables::XclExpXmlDBDataTables( const XclExpRoot& rRoot )
: XclExpRoot( rRoot )
{
+ miCount = 0;
ScDBCollection* pDBCollection = rRoot.GetDoc().GetDBCollection();
if( pDBCollection )
{
@@ -74,13 +121,33 @@ XclExpXmlDBDataTables::XclExpXmlDBDataTables( const XclExpRoot& rRoot )
ScDBCollection::NamedDBs::iterator itrEnd = aNamedDBs.end();
for(; itr!= itrEnd; ++itr)
{
- maDBDataTableContainer.push_back( new XclExpXmlDBDataTable( rRoot, *itr ) );
++miCount;
+ maDBDataTableContainer.push_back( new XclExpXmlDBDataTable( rRoot, *itr, miCount ) );
}
}
}
void XclExpXmlDBDataTables::SaveXml( XclExpXmlStream& rStrm )
{
+ // We only make the table folder is we do have any DB Data to write in
+ if( miCount != 0 )
+ {
+ //Now parse through each of the DB Datas making an xml for each.
+ int i = 1;
+ for ( DBDataTableContainer::iterator itr = maDBDataTableContainer.begin(); itr != maDBDataTableContainer.end(); ++itr)
+ {
+ sax_fastparser::FSHelperPtr aDBDataTable = rStrm.CreateOutputStream(
+ OUString( "xl/tables/table" )+ OUString::number( i ) + OUString(".xml" ),
+ OUString( "table" ) + OUString::number( i ) + OUString( ".xml" ),
+ rStrm.GetCurrentStream()->getOutputStream(),
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml",
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" );// Last two parameters are a mystery
+ rStrm.PushStream( aDBDataTable );
+ //Now the table#.xml file is created, need to pass the stream to that table
+ itr->SaveXml( rStrm );
+ ++i;// increment counter
+ rStrm.PopStream();
+ }
+ }
}
// =============================================================================
diff --git a/sc/source/filter/excel/xeroot.cxx b/sc/source/filter/excel/xeroot.cxx
index 31ad08bbd678..74adc67bf96b 100644
--- a/sc/source/filter/excel/xeroot.cxx
+++ b/sc/source/filter/excel/xeroot.cxx
@@ -37,6 +37,7 @@
#include "xename.hxx"
#include "xepivot.hxx"
#include "xestyle.hxx"
+#include "xedbdata.hxx"
#include "xeroot.hxx"
#include "excrecds.hxx" // for filter manager
@@ -167,6 +168,12 @@ XclExpTableStyles& XclExpRoot::GetTableStyles() const
return *mrExpData.mxTableStyles;
}
+XclExpXmlDBDataTables& XclExpRoot::GetDBDataTables() const
+{
+ OSL_ENSURE( mrExpData.mxDBDataTables, "XclExpRoot::GetDBDataTables - missingobject (wrong BIFF)");
+ return *mrExpData.mxDBDataTables;
+}
+
XclExpPivotTableManager& XclExpRoot::GetPivotTableManager() const
{
OSL_ENSURE( mrExpData.mxPTableMgr, "XclExpRoot::GetPivotTableManager - missing object (wrong BIFF?)" );
@@ -213,6 +220,7 @@ void XclExpRoot::InitializeGlobals()
mrExpData.mxLocLinkMgr = mrExpData.mxGlobLinkMgr;
mrExpData.mxDxfs.reset( new XclExpDxfs( GetRoot() ) );
mrExpData.mxTableStyles.reset( new XclExpTableStyles( GetRoot(), GetDxfs() ) );
+ mrExpData.mxDBDataTables.reset( new XclExpXmlDBDataTables( GetRoot() ) );
}
if( GetOutput() == EXC_OUTPUT_XML_2007 )
@@ -291,6 +299,7 @@ XclExpRecordRef XclExpRoot::CreateRecord( sal_uInt16 nRecId ) const
case EXC_ID_NAME: xRec = mrExpData.mxNameMgr; break;
case EXC_ID_DXFS: xRec = mrExpData.mxDxfs; break;
case EXC_ID_TABLESTYLES: xRec = mrExpData.mxTableStyles; break;
+ case EXC_ID_DBDATATABLES: xRec = mrExpData.mxDBDataTables;break;
}
OSL_ENSURE( xRec, "XclExpRoot::CreateRecord - unknown record ID or missing object" );
return xRec;
diff --git a/sc/source/filter/inc/xedbdata.hxx b/sc/source/filter/inc/xedbdata.hxx
index d05b6836bd6a..187e8c346804 100644
--- a/sc/source/filter/inc/xedbdata.hxx
+++ b/sc/source/filter/inc/xedbdata.hxx
@@ -23,15 +23,20 @@
#include "dbdata.hxx"
#include "xeroot.hxx"
#include "xerecord.hxx"
+#include "address.hxx"
#include <boost/shared_ptr.hpp>
#include <boost/scoped_ptr.hpp>
#include <boost/ptr_container/ptr_vector.hpp>
+const sal_uInt16 EXC_ID_DBDATATABLES = 0x11A01;
+
class XclExpXmlDBDataStyleInfo : public XclExpRecordBase, protected XclExpRoot
{
public:
XclExpXmlDBDataStyleInfo( const XclExpRoot& rRoot, ScDBDataFormatting& rDBDataFormatting );
virtual void SaveXml( XclExpXmlStream& rStrm );
+private:
+ ScDBDataFormatting maDBDataFormatting;
};
// ===========================================================================
class XclExpXmlDBDataColumn : public XclExpRecordBase, protected XclExpRoot
@@ -39,6 +44,9 @@ class XclExpXmlDBDataColumn : public XclExpRecordBase, protected XclExpRoot
public:
XclExpXmlDBDataColumn( const XclExpRoot& rRoot, int iID, OUString& rName );
virtual void SaveXml( XclExpXmlStream& rStrm );
+private:
+ OUString maName;
+ int miID;
};
// ===========================================================================
@@ -57,13 +65,18 @@ private:
class XclExpXmlDBDataTable : public XclExpRecordBase, protected XclExpRoot
{
public:
- XclExpXmlDBDataTable( const XclExpRoot& rRoot, ScDBData& rDBData );
+ XclExpXmlDBDataTable( const XclExpRoot& rRoot, ScDBData& rDBData, int nTableId );
virtual void SaveXml( XclExpXmlStream& rStrm );
private:
typedef boost::scoped_ptr < XclExpXmlDBDataColumns > DBDataTableColumns;
typedef boost::scoped_ptr < XclExpXmlDBDataStyleInfo > DBDataStyleInfo;
DBDataTableColumns maTableColumns;
DBDataStyleInfo maStyleInfo;
+ int mnTableId;
+ OUString maName;
+ OUString maDisplayName;
+ ScRange maRange;
+ bool mbTotalsRowShown;
};
// ============================================================================
diff --git a/sc/source/filter/inc/xeroot.hxx b/sc/source/filter/inc/xeroot.hxx
index 44952f088f45..205d0f0612c5 100644
--- a/sc/source/filter/inc/xeroot.hxx
+++ b/sc/source/filter/inc/xeroot.hxx
@@ -52,6 +52,7 @@ class XclExpFilterManager;
class XclExpPivotTableManager;
class XclExpDxfs;
class XclExpTableStyles;
+class XclExpXmlDBDataTables;
/** Stores global buffers and data needed for Excel export filter. */
struct XclExpRootData : public XclRootData
@@ -73,7 +74,7 @@ struct XclExpRootData : public XclRootData
typedef boost::shared_ptr< XclExpPivotTableManager > XclExpPTableMgrRef;
typedef boost::shared_ptr< XclExpDxfs > XclExpDxfsRef;
typedef boost::shared_ptr< XclExpTableStyles > XclExpTableStylesRef;
-
+ typedef boost::shared_ptr< XclExpXmlDBDataTables > XclExpXmlDBDataTablesRef;
XclExpTabInfoRef mxTabInfo; /// Calc->Excel sheet index conversion.
XclExpAddrConvRef mxAddrConv; /// The address converter.
XclExpFmlaCompRef mxFmlaComp; /// The formula compiler.
@@ -92,6 +93,7 @@ struct XclExpRootData : public XclRootData
XclExpPTableMgrRef mxPTableMgr; /// All pivot tables and pivot caches.
XclExpDxfsRef mxDxfs; /// All delta formatting entries
XclExpTableStylesRef mxTableStyles; /// All table styles for table formatting
+ XclExpXmlDBDataTablesRef mxDBDataTables; /// All DBData exported as tables
ScCompiler::OpCodeMapPtr mxOpCodeMap; /// mapping between op-codes and names
@@ -150,6 +152,8 @@ public:
XclExpDxfs& GetDxfs() const;
/** Returns the Table styles list*/
XclExpTableStyles& GetTableStyles() const;
+ /** Returns the tables i.e, DBData */
+ XclExpXmlDBDataTables& GetDBDataTables() const;
/** Returns the op-code mapping */
ScCompiler::OpCodeMapPtr GetOpCodeMap() const;