[Libreoffice-commits] core.git: 3 commits - sc/source
Kohei Yoshida
kohei.yoshida at collabora.com
Fri Aug 22 19:14:52 PDT 2014
sc/source/filter/excel/excdoc.cxx | 263 ++++++++++++++++++++++----------------
sc/source/filter/inc/excdoc.hxx | 10 -
2 files changed, 164 insertions(+), 109 deletions(-)
New commits:
commit 10851dff98846c94ccc14ee58d993362c82734c9
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Fri Aug 22 18:58:51 2014 -0400
Split FillAsTable into Binary and Xml variants in the same manner.
And remove BIFF-only records from the Xml variant.
Change-Id: Ia18cc079d9a9249fbbe0c328b14b719fba8d6bbf
diff --git a/sc/source/filter/excel/excdoc.cxx b/sc/source/filter/excel/excdoc.cxx
index 5fff7c8..490d7d4 100644
--- a/sc/source/filter/excel/excdoc.cxx
+++ b/sc/source/filter/excel/excdoc.cxx
@@ -453,7 +453,7 @@ void ExcTable::FillAsHeaderXml( ExcBoundsheetList& rBoundsheetList )
aRecList.AppendRecord( CreateRecord( EXC_ID_SST ) );
}
-void ExcTable::FillAsTable( SCTAB nCodeNameIdx )
+void ExcTable::FillAsTableBinary( SCTAB nCodeNameIdx )
{
InitializeTable( mnScTab );
@@ -482,12 +482,6 @@ void ExcTable::FillAsTable( SCTAB nCodeNameIdx )
mxNoteList->AppendNewRecord(new XclExpNote(GetRoot(), it->maPos, it->mpNote, OUString()));
}
- if( GetOutput() != EXC_OUTPUT_BINARY )
- {
- FillAsXmlTable( nCodeNameIdx );
- return;
- }
-
// WSBOOL needs data from page settings, create it here, add it later
boost::shared_ptr< XclExpPageSettings > xPageSett( new XclExpPageSettings( GetRoot() ) );
bool bFitToPages = xPageSett->GetPageData().mbFitToPages;
@@ -603,17 +597,37 @@ void ExcTable::FillAsTable( SCTAB nCodeNameIdx )
Add( new ExcEof );
}
-void ExcTable::FillAsXmlTable( SCTAB nCodeNameIdx )
+void ExcTable::FillAsTableXml()
{
- RootData& rR = GetOldRoot();
+ InitializeTable( mnScTab );
+
+ ScDocument& rDoc = GetDoc();
+
+ OSL_ENSURE( (mnScTab >= 0L) && (mnScTab <= MAXTAB), "-ExcTable::Table(): mnScTab - no ordinary table!" );
+ OSL_ENSURE( nExcTab <= static_cast<sal_uInt16>(MAXTAB), "-ExcTable::Table(): nExcTab - no ordinary table!" );
+
+ // create a new OBJ list for this sheet (may be used by notes, autofilter, data validation)
+ GetObjectManager().StartSheet();
+
+ // cell table: DEFROWHEIGHT, DEFCOLWIDTH, COLINFO, DIMENSIONS, ROW, cell records
+ mxCellTable.reset( new XclExpCellTable( GetRoot() ) );
+
+ //export cell notes
+ std::vector<sc::NoteEntry> aNotes;
+ rDoc.GetAllNoteEntries(aNotes);
+ for (std::vector<sc::NoteEntry>::const_iterator it = aNotes.begin(), itEnd = aNotes.end(); it != itEnd; ++it)
+ {
+ if (it->maPos.Tab() != mnScTab)
+ continue;
+
+ mxNoteList->AppendNewRecord(new XclExpNote(GetRoot(), it->maPos, it->mpNote, OUString()));
+ }
// WSBOOL needs data from page settings, create it here, add it later
boost::shared_ptr< XclExpPageSettings > xPageSett( new XclExpPageSettings( GetRoot() ) );
XclExtLstRef xExtLst( new XclExtLst( GetRoot() ) );
bool bFitToPages = xPageSett->GetPageData().mbFitToPages;
- Add( new ExcBof8 );
-
Color aTabColor = GetRoot().GetDoc().GetTabBgColor(mnScTab);
Add(new XclExpXmlSheetPr(bFitToPages, mnScTab, aTabColor, &GetFilterManager()));
@@ -630,18 +644,6 @@ void ExcTable::FillAsXmlTable( SCTAB nCodeNameIdx )
// cell table: DEFCOLWIDTH, COLINFO, DIMENSIONS, ROW, cell records
aRecList.AppendRecord( mxCellTable );
- // label ranges
- // missing SaveXML
- Add( new XclExpLabelranges( GetRoot() ) );
-
- // DFF not needed in MSOOXML export
-// GetObjectManager().AddSdrPage();
-// //! close Escher group shape and ESCHER_DgContainer
-// //! opened by XclExpObjList ctor MSODRAWING
-// rR.pObjRecs->EndSheet();
-// // all MSODRAWING and OBJ stuff of this sheet goes here
-// Add( rR.pObjRecs );
-
// pivot tables
// not in the worksheet file
aRecList.AppendRecord( GetPivotTableManager().CreatePivotTablesRecord( mnScTab ) );
@@ -651,11 +653,6 @@ void ExcTable::FillAsXmlTable( SCTAB nCodeNameIdx )
if( mxNoteList != 0 && !mxNoteList->IsEmpty() )
aRecList.AppendNewRecord( new XclExpComments( mnScTab, *mxNoteList ) );
- // web queries
- // missing SaveXML implementation
- Add( new XclExpWebQueryBuffer( GetRoot() ) );
-
- ScDocument& rDoc = GetDoc();
const ScTableProtection* pTabProtect = rDoc.GetTabProtection(mnScTab);
if (pTabProtect && pTabProtect->isProtected())
Add( new XclExpSheetProtection(true, mnScTab) );
@@ -668,10 +665,6 @@ void ExcTable::FillAsXmlTable( SCTAB nCodeNameIdx )
// conditional formats
Add( new XclExpCondFormatBuffer( GetRoot(), xExtLst ) );
- if( HasVbaStorage() )
- if( nCodeNameIdx < GetExtDocOptions().GetCodeNameCount() )
- Add( new XclCodename( GetExtDocOptions().GetCodeName( nCodeNameIdx ) ) );
-
// data validation (DVAL and list of DV records), generated by the cell table
aRecList.AppendRecord( mxCellTable->CreateRecord( EXC_ID_DVAL ) );
@@ -687,24 +680,10 @@ void ExcTable::FillAsXmlTable( SCTAB nCodeNameIdx )
aRecList.AppendRecord( xPageSett );
- // change tracking
- if( rR.pUserBViewList )
- {
- XclExpUserBViewList::const_iterator iter;
- for ( iter = rR.pUserBViewList->begin(); iter != rR.pUserBViewList->end(); ++iter )
- {
- Add( new XclExpUsersViewBegin( (*iter)->GetGUID(), nExcTab ) );
- Add( new XclExpUsersViewEnd );
- }
- }
-
// all MSODRAWING and OBJ stuff of this sheet goes here
aRecList.AppendRecord( GetObjectManager().ProcessDrawing( GetSdrPage( mnScTab ) ) );
aRecList.AppendRecord( xExtLst );
-
- // EOF
- Add( new ExcEof );
}
void ExcTable::FillAsEmptyTable( SCTAB nCodeNameIdx )
@@ -801,7 +780,11 @@ void ExcDocument::ReadDoc( void )
{
ExcTableList::RecordRefType xTab( new ExcTable( GetRoot(), nScTab ) );
maTableList.AppendRecord( xTab );
- xTab->FillAsTable( nCodeNameIdx );
+ if (GetOutput() == EXC_OUTPUT_BINARY)
+ xTab->FillAsTableBinary(nCodeNameIdx);
+ else
+ xTab->FillAsTableXml();
+
++nCodeNameIdx;
}
}
diff --git a/sc/source/filter/inc/excdoc.hxx b/sc/source/filter/inc/excdoc.hxx
index 3d17d9d..dc606b6 100644
--- a/sc/source/filter/inc/excdoc.hxx
+++ b/sc/source/filter/inc/excdoc.hxx
@@ -59,8 +59,6 @@ private:
// pRec mit new anlegen und vergessen, delete macht ExcTable selber!
void Add( XclExpRecordBase* pRec );
- void FillAsXmlTable( SCTAB nCodeNameIdx );
-
public:
ExcTable( const XclExpRoot& rRoot );
ExcTable( const XclExpRoot& rRoot, SCTAB nScTab );
@@ -69,7 +67,9 @@ public:
void FillAsHeaderBinary( ExcBoundsheetList& rBoundsheetList );
void FillAsHeaderXml( ExcBoundsheetList& rBoundsheetList );
- void FillAsTable( SCTAB nCodeNameIdx );
+ void FillAsTableBinary( SCTAB nCodeNameIdx );
+ void FillAsTableXml();
+
void FillAsEmptyTable( SCTAB nCodeNameIdx );
void Write( XclExpStream& );
commit 44e68c897ee8ec160618b16d684c832564162213
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Fri Aug 22 16:14:31 2014 -0400
Split FillAsHeader into FillAsHeaderBinary and FillAsHeaderXml.
To reduce complexity in each method, and remove records that are
specific to binary export form the Xml variant.
Change-Id: I6c66054b99dd8cded5767610f2390952b59caf23
diff --git a/sc/source/filter/excel/excdoc.cxx b/sc/source/filter/excel/excdoc.cxx
index d683d46..5fff7c8 100644
--- a/sc/source/filter/excel/excdoc.cxx
+++ b/sc/source/filter/excel/excdoc.cxx
@@ -159,7 +159,7 @@ void ExcTable::Add( XclExpRecordBase* pRec )
aRecList.AppendNewRecord( pRec );
}
-void ExcTable::FillAsHeader( ExcBoundsheetList& rBoundsheetList )
+void ExcTable::FillAsHeaderBinary( ExcBoundsheetList& rBoundsheetList )
{
InitializeGlobals();
@@ -283,38 +283,13 @@ void ExcTable::FillAsHeader( ExcBoundsheetList& rBoundsheetList )
Add( new XclExpBoolRecord( 0x000E, !rDoc.GetDocOptions().IsCalcAsShown() ) );
Add( new XclExpBoolRecord(0x01B7, false) ); // REFRESHALL
Add( new XclExpBoolRecord(0x00DA, false) ); // BOOKBOOL
- // OOXTODO: The following /workbook/workbookPr attributes are mapped
- // to various BIFF records that are not currently supported:
- //
- // XML_allowRefreshQuery: QSISTAG 802h: fEnableRefresh
- // XML_autoCompressPictures: COMPRESSPICTURES 89Bh: fAutoCompressPictures
- // XML_checkCompatibility: COMPAT12 88Ch: fNoCompatChk
- // XML_codeName: "Calc"
- // XML_defaultThemeVersion: ???
- // XML_filterPrivacy: BOOKEXT 863h: fFilterPrivacy
- // XML_hidePivotFieldList: BOOKBOOL DAh: fHidePivotTableFList
- // XML_promptedSolutions: BOOKEXT 863h: fBuggedUserAboutSolution
- // XML_publishItems: NAMEPUBLISH 893h: fPublished
- // XML_saveExternalLinkValues: BOOKBOOL DAh: fNoSavSupp
- // XML_showBorderUnselectedTables: BOOKBOOL DAh: fHideBorderUnsels
- // XML_showInkAnnotation: BOOKEXT 863h: fShowInkAnnotation
- // XML_showPivotChart: PIVOTCHARTBITS 859h: fGXHide??
- // XML_updateLinks: BOOKBOOL DAh: grbitUpdateLinks
}
- Add( new XclExpXmlEndSingleElementRecord() ); // XML_workbookPr
// Formatting: FONT, FORMAT, XF, STYLE, PALETTE
- if( GetOutput() != EXC_OUTPUT_BINARY )
- {
- aRecList.AppendNewRecord( new XclExpXmlStyleSheet( *this ) );
- }
- else
- {
- aRecList.AppendRecord( CreateRecord( EXC_ID_FONTLIST ) );
- aRecList.AppendRecord( CreateRecord( EXC_ID_FORMATLIST ) );
- aRecList.AppendRecord( CreateRecord( EXC_ID_XFLIST ) );
- aRecList.AppendRecord( CreateRecord( EXC_ID_PALETTE ) );
- }
+ aRecList.AppendRecord( CreateRecord( EXC_ID_FONTLIST ) );
+ aRecList.AppendRecord( CreateRecord( EXC_ID_FORMATLIST ) );
+ aRecList.AppendRecord( CreateRecord( EXC_ID_XFLIST ) );
+ aRecList.AppendRecord( CreateRecord( EXC_ID_PALETTE ) );
if( GetBiff() <= EXC_BIFF5 )
{
@@ -343,14 +318,7 @@ void ExcTable::FillAsHeader( ExcBoundsheetList& rBoundsheetList )
// Natural Language Formulas Flag
aRecList.AppendNewRecord( new XclExpBoolRecord( EXC_ID_USESELFS, GetDoc().GetDocOptions().IsLookUpColRowNames() ) );
- if( GetOutput() != EXC_OUTPUT_BINARY )
- {
- lcl_AddWorkbookProtection( aRecList, *this );
- lcl_AddBookviews( aRecList, *this );
- }
-
// Bundlesheet
- aRecList.AppendNewRecord( new XclExpXmlStartElementRecord( XML_sheets ) );
for( nC = 0 ; nC < nScTabCount ; nC++ )
if( rTabInfo.IsExportTab( nC ) )
{
@@ -358,7 +326,6 @@ void ExcTable::FillAsHeader( ExcBoundsheetList& rBoundsheetList )
aRecList.AppendRecord( xBoundsheet );
rBoundsheetList.AppendRecord( xBoundsheet );
}
- aRecList.AppendNewRecord( new XclExpXmlEndElementRecord( XML_sheets ) );
for( SCTAB nAdd = 0; nC < static_cast<SCTAB>(nCodenames) ; nC++, nAdd++ )
{
@@ -375,9 +342,6 @@ void ExcTable::FillAsHeader( ExcBoundsheetList& rBoundsheetList )
aRecList.AppendRecord( CreateRecord( EXC_ID_EXTERNSHEET ) );
aRecList.AppendRecord( CreateRecord( EXC_ID_NAME ) );
- if( GetOutput() != EXC_OUTPUT_BINARY )
- lcl_AddCalcPr( aRecList, *this );
-
Add( new XclExpRecalcId );
// MSODRAWINGGROUP per-document data
@@ -391,6 +355,104 @@ void ExcTable::FillAsHeader( ExcBoundsheetList& rBoundsheetList )
Add( new ExcEof );
}
+void ExcTable::FillAsHeaderXml( ExcBoundsheetList& rBoundsheetList )
+{
+ InitializeGlobals();
+
+ RootData& rR = GetOldRoot();
+ ScDocument& rDoc = GetDoc();
+ XclExpTabInfo& rTabInfo = GetTabInfo();
+
+ SCTAB nC;
+ OUString aTmpString;
+ SCTAB nScTabCount = rTabInfo.GetScTabCount();
+ sal_uInt16 nExcTabCount = rTabInfo.GetXclTabCount();
+ sal_uInt16 nCodenames = static_cast< sal_uInt16 >( GetExtDocOptions().GetCodeNameCount() );
+
+ rR.pTabId = new XclExpChTrTabId( std::max( nExcTabCount, nCodenames ) );
+ Add( rR.pTabId );
+
+ // erst Namen- und Tabellen-Eintraege aufbauen
+
+ for( nC = 0 ; nC < nScTabCount ; nC++ )
+ if( rTabInfo.IsExportTab( nC ) )
+ {
+ rDoc.GetName( nC, aTmpString );
+ *pTabNames << aTmpString;
+ }
+
+ Add( new XclExpXmlStartSingleElementRecord( XML_workbookPr ) );
+ Add( new XclExpBoolRecord(0x0040, false, XML_backupFile ) ); // BACKUP
+ Add( new XclExpBoolRecord(0x008D, false, XML_showObjects ) ); // HIDEOBJ
+
+ Add( new Exc1904( rDoc ) );
+ // OOXTODO: The following /workbook/workbookPr attributes are mapped
+ // to various BIFF records that are not currently supported:
+ //
+ // XML_allowRefreshQuery: QSISTAG 802h: fEnableRefresh
+ // XML_autoCompressPictures: COMPRESSPICTURES 89Bh: fAutoCompressPictures
+ // XML_checkCompatibility: COMPAT12 88Ch: fNoCompatChk
+ // XML_codeName: "Calc"
+ // XML_defaultThemeVersion: ???
+ // XML_filterPrivacy: BOOKEXT 863h: fFilterPrivacy
+ // XML_hidePivotFieldList: BOOKBOOL DAh: fHidePivotTableFList
+ // XML_promptedSolutions: BOOKEXT 863h: fBuggedUserAboutSolution
+ // XML_publishItems: NAMEPUBLISH 893h: fPublished
+ // XML_saveExternalLinkValues: BOOKBOOL DAh: fNoSavSupp
+ // XML_showBorderUnselectedTables: BOOKBOOL DAh: fHideBorderUnsels
+ // XML_showInkAnnotation: BOOKEXT 863h: fShowInkAnnotation
+ // XML_showPivotChart: PIVOTCHARTBITS 859h: fGXHide??
+ // XML_updateLinks: BOOKBOOL DAh: grbitUpdateLinks
+ Add( new XclExpXmlEndSingleElementRecord() ); // XML_workbookPr
+
+ // Formatting: FONT, FORMAT, XF, STYLE, PALETTE
+ aRecList.AppendNewRecord( new XclExpXmlStyleSheet( *this ) );
+
+ // Pivot Cache
+ GetPivotTableManager().CreatePivotTables();
+ aRecList.AppendRecord( GetPivotTableManager().CreatePivotCachesRecord() );
+
+ // Change tracking
+ if( rDoc.GetChangeTrack() )
+ {
+ rR.pUserBViewList = new XclExpUserBViewList( *rDoc.GetChangeTrack() );
+ Add( rR.pUserBViewList );
+ }
+
+ lcl_AddWorkbookProtection( aRecList, *this );
+ lcl_AddBookviews( aRecList, *this );
+
+ // Bundlesheet
+ aRecList.AppendNewRecord( new XclExpXmlStartElementRecord( XML_sheets ) );
+ for( nC = 0 ; nC < nScTabCount ; nC++ )
+ if( rTabInfo.IsExportTab( nC ) )
+ {
+ ExcBoundsheetList::RecordRefType xBoundsheet( new ExcBundlesheet8( rR, nC ) );
+ aRecList.AppendRecord( xBoundsheet );
+ rBoundsheetList.AppendRecord( xBoundsheet );
+ }
+ aRecList.AppendNewRecord( new XclExpXmlEndElementRecord( XML_sheets ) );
+
+ for( SCTAB nAdd = 0; nC < static_cast<SCTAB>(nCodenames) ; nC++, nAdd++ )
+ {
+ aTmpString = lcl_GetVbaTabName( nAdd );
+ ExcBoundsheetList::RecordRefType xBoundsheet( new ExcBundlesheet8( aTmpString ) );
+ aRecList.AppendRecord( xBoundsheet );
+ rBoundsheetList.AppendRecord( xBoundsheet );
+ }
+
+ // link table: SUPBOOK, XCT, CRN, EXTERNNAME, EXTERNSHEET, NAME
+ aRecList.AppendRecord( CreateRecord( EXC_ID_EXTERNSHEET ) );
+ aRecList.AppendRecord( CreateRecord( EXC_ID_NAME ) );
+
+ lcl_AddCalcPr( aRecList, *this );
+
+ // MSODRAWINGGROUP per-document data
+ aRecList.AppendRecord( GetObjectManager().CreateDrawingGroup() );
+ // Shared string table: SST, EXTSST
+ aRecList.AppendRecord( CreateRecord( EXC_ID_SST ) );
+}
+
void ExcTable::FillAsTable( SCTAB nCodeNameIdx )
{
InitializeTable( mnScTab );
@@ -725,7 +787,10 @@ void ExcDocument::ReadDoc( void )
{
InitializeConvert();
- aHeader.FillAsHeader( maBoundsheetList );
+ if (GetOutput() == EXC_OUTPUT_BINARY)
+ aHeader.FillAsHeaderBinary(maBoundsheetList);
+ else
+ aHeader.FillAsHeaderXml(maBoundsheetList);
SCTAB nScTab = 0, nScTabCount = GetTabInfo().GetScTabCount();
SCTAB nCodeNameIdx = 0, nCodeNameCount = GetExtDocOptions().GetCodeNameCount();
diff --git a/sc/source/filter/inc/excdoc.hxx b/sc/source/filter/inc/excdoc.hxx
index 61e0c8d..3d17d9d 100644
--- a/sc/source/filter/inc/excdoc.hxx
+++ b/sc/source/filter/inc/excdoc.hxx
@@ -66,7 +66,9 @@ public:
ExcTable( const XclExpRoot& rRoot, SCTAB nScTab );
virtual ~ExcTable();
- void FillAsHeader( ExcBoundsheetList& rBoundsheetList );
+ void FillAsHeaderBinary( ExcBoundsheetList& rBoundsheetList );
+ void FillAsHeaderXml( ExcBoundsheetList& rBoundsheetList );
+
void FillAsTable( SCTAB nCodeNameIdx );
void FillAsEmptyTable( SCTAB nCodeNameIdx );
commit 16f9011c9c8d9835997cc7c800c3f289dfcb9719
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Thu Aug 21 16:24:47 2014 -0400
Make header (workbook) export and worksheet export clearer.
Change-Id: I9540fa32ca6a4ce041e15b272a049fcdf267fb0c
diff --git a/sc/source/filter/excel/excdoc.cxx b/sc/source/filter/excel/excdoc.cxx
index 416e411..d683d46 100644
--- a/sc/source/filter/excel/excdoc.cxx
+++ b/sc/source/filter/excel/excdoc.cxx
@@ -676,31 +676,36 @@ void ExcTable::Write( XclExpStream& rStrm )
void ExcTable::WriteXml( XclExpXmlStream& rStrm )
{
- if (GetTabInfo().IsExportTab( mnScTab ) )
+ if (!GetTabInfo().IsExportTab(mnScTab))
{
- // worksheet export
- OUString sSheetName = XclXmlUtils::GetStreamName( "xl/", "worksheets/sheet", mnScTab+1 );
+ // header export.
+ SetCurrScTab(mnScTab);
+ if (mxCellTable)
+ mxCellTable->Finalize();
+ aRecList.SaveXml(rStrm);
- sax_fastparser::FSHelperPtr pWorksheet = rStrm.GetStreamForPath( sSheetName );
+ return;
+ }
- rStrm.PushStream( pWorksheet );
+ // worksheet export
+ OUString sSheetName = XclXmlUtils::GetStreamName( "xl/", "worksheets/sheet", mnScTab+1 );
- pWorksheet->startElement( XML_worksheet,
- XML_xmlns, "http://schemas.openxmlformats.org/spreadsheetml/2006/main",
- FSNS( XML_xmlns, XML_r ), "http://schemas.openxmlformats.org/officeDocument/2006/relationships",
- FSEND );
- }
+ sax_fastparser::FSHelperPtr pWorksheet = rStrm.GetStreamForPath( sSheetName );
+
+ rStrm.PushStream( pWorksheet );
+
+ pWorksheet->startElement( XML_worksheet,
+ XML_xmlns, "http://schemas.openxmlformats.org/spreadsheetml/2006/main",
+ FSNS( XML_xmlns, XML_r ), "http://schemas.openxmlformats.org/officeDocument/2006/relationships",
+ FSEND );
SetCurrScTab( mnScTab );
- if( mxCellTable.get() )
+ if (mxCellTable)
mxCellTable->Finalize();
aRecList.SaveXml( rStrm );
- if (GetTabInfo().IsExportTab( mnScTab ) )
- {
- rStrm.GetCurrentStream()->endElement( XML_worksheet );
- rStrm.PopStream();
- }
+ rStrm.GetCurrentStream()->endElement( XML_worksheet );
+ rStrm.PopStream();
}
ExcDocument::ExcDocument( const XclExpRoot& rRoot ) :
More information about the Libreoffice-commits
mailing list