diff options
author | Akash Shetye <shetyeakash@gmail.com> | 2013-07-28 17:53:04 +0530 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-08-05 14:30:24 -0400 |
commit | ac4c81f7b9c4e927419f7d42307f684ef6174478 (patch) | |
tree | 8992807d6a342bbf8f125789b0a2ff295b80839b | |
parent | 165114a4b0f17f38e9b90998891ac878e306e470 (diff) |
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
-rw-r--r-- | sc/source/filter/excel/xestyle.cxx | 20 | ||||
-rw-r--r-- | sc/source/filter/inc/xestyle.hxx | 1 |
2 files changed, 15 insertions, 6 deletions
diff --git a/sc/source/filter/excel/xestyle.cxx b/sc/source/filter/excel/xestyle.cxx index 028678c6e248..a6587336a6e4 100644 --- a/sc/source/filter/excel/xestyle.cxx +++ b/sc/source/filter/excel/xestyle.cxx @@ -3213,6 +3213,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; @@ -3233,10 +3236,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; } } } @@ -3248,13 +3253,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 a4e6017dedd3..d8d3031aca16 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; }; // ============================================================================ |