diff options
author | Bartosz Kosiorek <gang65@poczta.onet.pl> | 2016-07-26 18:14:30 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2016-07-28 21:19:46 +0200 |
commit | ad121df71ad463bed8caf147d27f020b548f0862 (patch) | |
tree | ff84414975e4f3515d62441a27d426cad1e853ca | |
parent | fed8226315b08078a0101785f12693f5a3daa6f7 (diff) |
tdf#101135 FILESAVE .xlsx Save XML_outlineLevelRow, XML_outlineLevelCol keys
In .xlsx, the XML_outlineLevelRow and XML_outlineLevelCol keys
are required for Microsoft Office365 application
to properly displaying Outline values.
Change-Id: If4184ddc4fbfaa409732ddb0fb4ca85b4a27b024
-rw-r--r-- | sc/qa/unit/subsequent_export-test.cxx | 5 | ||||
-rw-r--r-- | sc/source/filter/excel/xetable.cxx | 27 | ||||
-rw-r--r-- | sc/source/filter/inc/xetable.hxx | 6 | ||||
-rw-r--r-- | sc/source/filter/oox/worksheetfragment.cxx | 5 |
4 files changed, 39 insertions, 4 deletions
diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx index 3fca21766dc8..068d9e4ef270 100644 --- a/sc/qa/unit/subsequent_export-test.cxx +++ b/sc/qa/unit/subsequent_export-test.cxx @@ -490,6 +490,11 @@ void ScExportTest::testOutlineExportXLSX() xmlDocPtr pSheet = XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/worksheets/sheet1.xml"); CPPUNIT_ASSERT(pSheet); + // Maximum Outline Row is 4 for this document + assertXPath(pSheet, "/x:worksheet/x:sheetFormatPr", "outlineLevelRow", "4"); + // Maximum Outline Column is 4 for this document + assertXPath(pSheet, "/x:worksheet/x:sheetFormatPr", "outlineLevelCol", "4"); + // First XML node, creates two columns (from min=1 to max=2) assertXPath(pSheet, "/x:worksheet/x:cols/x:col[1]", "hidden", "false"); assertXPath(pSheet, "/x:worksheet/x:cols/x:col[1]", "outlineLevel", "1"); diff --git a/sc/source/filter/excel/xetable.cxx b/sc/source/filter/excel/xetable.cxx index b88021fb089a..d1b731e9cd19 100644 --- a/sc/source/filter/excel/xetable.cxx +++ b/sc/source/filter/excel/xetable.cxx @@ -1669,7 +1669,8 @@ void XclExpColinfo::SaveXml( XclExpXmlStream& rStrm ) XclExpColinfoBuffer::XclExpColinfoBuffer( const XclExpRoot& rRoot ) : XclExpRoot( rRoot ), maDefcolwidth( rRoot ), - maOutlineBfr( rRoot ) + maOutlineBfr( rRoot ), + maHighestOutlineLevel( 0 ) { } @@ -1677,7 +1678,13 @@ void XclExpColinfoBuffer::Initialize( SCROW nLastScRow ) { for( sal_uInt16 nScCol = 0, nLastScCol = GetMaxPos().Col(); nScCol <= nLastScCol; ++nScCol ) + { maColInfos.AppendNewRecord( new XclExpColinfo( GetRoot(), nScCol, nLastScRow, maOutlineBfr ) ); + if( maOutlineBfr.GetLevel() > maHighestOutlineLevel ) + { + maHighestOutlineLevel = maOutlineBfr.GetLevel(); + } + } } void XclExpColinfoBuffer::Finalize( ScfUInt16Vec& rXFIndexes ) @@ -2094,7 +2101,8 @@ void XclExpRow::SaveXml( XclExpXmlStream& rStrm ) XclExpRowBuffer::XclExpRowBuffer( const XclExpRoot& rRoot ) : XclExpRoot( rRoot ), maOutlineBfr( rRoot ), - maDimensions( rRoot ) + maDimensions( rRoot ), + maHighestOutlineLevel( 0 ) { } @@ -2343,6 +2351,10 @@ XclExpRow& XclExpRowBuffer::GetOrCreateRow( sal_uInt32 nXclRow, bool bRowAlwaysE ( maOutlineBfr.GetLevel() != 0 ) || ( rDoc.RowHidden(nFrom, nScTab) ) ) { + if( maOutlineBfr.GetLevel() > maHighestOutlineLevel ) + { + maHighestOutlineLevel = maOutlineBfr.GetLevel(); + } RowRef p(new XclExpRow(GetRoot(), nFrom, maOutlineBfr, bRowAlwaysEmpty)); maRowMap.insert(RowMap::value_type(nFrom, p)); } @@ -2627,7 +2639,16 @@ void XclExpCellTable::SaveXml( XclExpXmlStream& rStrm ) XclExpDefaultRowData& rDefData = mxDefrowheight->GetDefaultData(); sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream(); rWorksheet->startElement( XML_sheetFormatPr, - XML_defaultRowHeight, OString::number( (double) rDefData.mnHeight / 20.0 ).getStr(), FSEND ); + // OOXTODO: XML_baseColWidth + // OOXTODO: XML_defaultColWidth + // OOXTODO: XML_customHeight + // OOXTODO: XML_zeroHeight + // OOXTODO: XML_thickTop + // OOXTODO: XML_thickBottom + XML_defaultRowHeight, OString::number( static_cast< double> ( rDefData.mnHeight ) / 20.0 ).getStr(), + XML_outlineLevelRow, OString::number( maRowBfr.GetHighestOutlineLevel() ).getStr(), + XML_outlineLevelCol, OString::number( maColInfoBfr.GetHighestOutlineLevel() ).getStr(), + FSEND ); rWorksheet->endElement( XML_sheetFormatPr ); maColInfoBfr.SaveXml( rStrm ); diff --git a/sc/source/filter/inc/xetable.hxx b/sc/source/filter/inc/xetable.hxx index e0f236af95d2..25ad27844095 100644 --- a/sc/source/filter/inc/xetable.hxx +++ b/sc/source/filter/inc/xetable.hxx @@ -770,6 +770,7 @@ public: /** Writes all COLINFO records of this buffer. */ virtual void Save( XclExpStream& rStrm ) override; virtual void SaveXml( XclExpXmlStream& rStrm ) override; + sal_uInt8 GetHighestOutlineLevel() { return maHighestOutlineLevel; } private: typedef XclExpRecordList< XclExpColinfo > XclExpColinfoList; @@ -778,6 +779,7 @@ private: XclExpColinfoList maColInfos; /// List of COLINFO records. XclExpDefcolwidth maDefcolwidth; /// The DEFCOLWIDTH record. XclExpColOutlineBuffer maOutlineBfr; /// Buffer for column outline groups. + sal_uInt8 maHighestOutlineLevel; /// Highest number of outline levels for columns in sheet. }; class XclExpRow; @@ -928,7 +930,8 @@ public: virtual void Save( XclExpStream& rStrm ) override; virtual void SaveXml( XclExpXmlStream& rStrm ) override; - XclExpDimensions& GetDimensions() { return maDimensions;} + XclExpDimensions& GetDimensions() { return maDimensions; } + sal_uInt8 GetHighestOutlineLevel() { return maHighestOutlineLevel; } private: /** Returns access to the specified ROW record. Inserts preceding missing ROW records. @@ -943,6 +946,7 @@ private: RowMap maRowMap; XclExpRowOutlineBuffer maOutlineBfr; /// Buffer for row outline groups. XclExpDimensions maDimensions; /// DIMENSIONS record for used area. + sal_uInt8 maHighestOutlineLevel; /// Highest number of outline levels for rows in sheet. }; // Cell Table diff --git a/sc/source/filter/oox/worksheetfragment.cxx b/sc/source/filter/oox/worksheetfragment.cxx index 7984ae6c325c..ad9837a084a0 100644 --- a/sc/source/filter/oox/worksheetfragment.cxx +++ b/sc/source/filter/oox/worksheetfragment.cxx @@ -518,6 +518,11 @@ void WorksheetFragment::importSheetFormatPr( const AttributeList& rAttribs ) setBaseColumnWidth( rAttribs.getInteger( XML_baseColWidth, 8 ) ); setDefaultColumnWidth( rAttribs.getDouble( XML_defaultColWidth, 0.0 ) ); // default row settings + + // We don't need to import: + // XML_outlineLevelRow + // XML_outlineLevelCol + // as it will be updated during export to OOXML setDefaultRowSettings( rAttribs.getDouble( XML_defaultRowHeight, 0.0 ), rAttribs.getBool( XML_customHeight, false ), |