sc/source/filter/excel/xestyle.cxx | 20 ++++++++++++++------ sc/source/filter/inc/xestyle.hxx | 1 + 2 files changed, 15 insertions(+), 6 deletions(-)
New commits: commit 244821c0df2baca727d0e770ed9906be713b0be1 Author: Akash Shetye <shetyeak...@gmail.com> Date: Sun Jul 28 17:53:04 2013 +0530 Patch adds check for ensuring atleast one table style exists Earlier code just added a new style and did not perform any checks to ensure atleast one style was present, this stops excel from creating empty table style tags. Change-Id: Ib83e8001410b65aa129fb22b032956c9bd7e1ddd diff --git a/sc/source/filter/excel/xestyle.cxx b/sc/source/filter/excel/xestyle.cxx index 11c3faf..2e0a74e 100644 --- a/sc/source/filter/excel/xestyle.cxx +++ b/sc/source/filter/excel/xestyle.cxx @@ -3212,6 +3212,9 @@ void XclExpTableStyle::SaveXml( XclExpXmlStream& rStrm ) XclExpTableStyles::XclExpTableStyles( const XclExpRoot& rRoot, XclExpDxfs& rDxfs ) :XclExpRoot( rRoot ) { + //Set the has table styles member to false, for conditions when there is not + //table style defined. + mbHasTableStyles = false; //Search through the collection of ScDBData (Database Ranges) //checking for any table styles associated with them miCount = 0; @@ -3232,10 +3235,12 @@ XclExpTableStyles::XclExpTableStyles( const XclExpRoot& rRoot, XclExpDxfs& rDxfs */ ScDBDataFormatting aDBFormatting; (*itr).GetTableFormatting( aDBFormatting ); - if( &(aDBFormatting) )//Probably non-standard? + if( &(aDBFormatting)!=NULL )//Probably non-standard? { miCount++; maStyleContainer.push_back( new XclExpTableStyle( rRoot, aDBFormatting, rDxfs ) ); + //We have atleast one style so mbHasTableStyles needs to be set + mbHasTableStyles = true; } } } @@ -3247,13 +3252,16 @@ XclExpTableStyles::~XclExpTableStyles() void XclExpTableStyles::SaveXml( XclExpXmlStream& rStrm ) { - sax_fastparser::FSHelperPtr& rStyleSheet = rStrm.GetCurrentStream(); - rStyleSheet->startElement( XML_tableStyles, XML_count, OString::number(miCount).getStr(), FSEND ); - for ( StyleContainer::iterator itr = maStyleContainer.begin(); itr != maStyleContainer.end(); ++itr ) + if( mbHasTableStyles ) //If it has table styles only then start the element { - itr->SaveXml( rStrm ); + sax_fastparser::FSHelperPtr& rStyleSheet = rStrm.GetCurrentStream(); + rStyleSheet->startElement( XML_tableStyles, XML_count, OString::number(miCount).getStr(), FSEND ); + for ( StyleContainer::iterator itr = maStyleContainer.begin(); itr != maStyleContainer.end(); ++itr ) + { + itr->SaveXml( rStrm ); + } + rStyleSheet->endElement( XML_tableStyles ); } - rStyleSheet->endElement( XML_tableStyles ); } // ============================================================================ diff --git a/sc/source/filter/inc/xestyle.hxx b/sc/source/filter/inc/xestyle.hxx index a4e6017..d8d3031 100644 --- a/sc/source/filter/inc/xestyle.hxx +++ b/sc/source/filter/inc/xestyle.hxx @@ -804,6 +804,7 @@ private: typedef boost::ptr_vector< XclExpTableStyle > StyleContainer; StyleContainer maStyleContainer; int miCount; + bool mbHasTableStyles; }; // ============================================================================ _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits