summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2017-03-07 22:40:55 +0200
committerTor Lillqvist <tml@collabora.com>2017-03-08 00:44:01 +0200
commit7ceda09f6780c954fedc49764d5457aa2616b39a (patch)
tree130eecc474bbd107bfb723ed26aeff5c30d4250a
parent27e34a7dbb9aa2ce52ca529ec835d54c6a5508fc (diff)
A 'CondFmt' record can have a maximum of three CF records following (eek)
What an odd restriction. Oh well. Don't export the conditional formats for the cell(s) in that case then. See https://msdn.microsoft.com/en-us/library/03AE6098-BDC2-475B-BA2C-B8AEF7882174 Change-Id: I4eeec8d33f9fbc572a02f727f38564d6c43b4f10
-rw-r--r--sc/source/filter/excel/xecontent.cxx19
-rw-r--r--sc/source/filter/inc/xecontent.hxx3
2 files changed, 16 insertions, 6 deletions
diff --git a/sc/source/filter/excel/xecontent.cxx b/sc/source/filter/excel/xecontent.cxx
index 126e139595ed..ce70978b29c2 100644
--- a/sc/source/filter/excel/xecontent.cxx
+++ b/sc/source/filter/excel/xecontent.cxx
@@ -1278,14 +1278,24 @@ XclExpCondfmt::~XclExpCondfmt()
{
}
-bool XclExpCondfmt::IsValid() const
+bool XclExpCondfmt::IsValidForBinary() const
+{
+ // ccf (2 bytes): An unsigned integer that specifies the count of CF records that follow this
+ // record. MUST be greater than or equal to 0x0001, and less than or equal to 0x0003.
+
+ SAL_WARN_IF( maCFList.GetSize() > 3, "sc.filter", "More than 3 conditional filters for cell(s), won't export");
+
+ return !maCFList.IsEmpty() && maCFList.GetSize() <= 3 && !maXclRanges.empty();
+}
+
+bool XclExpCondfmt::IsValidForXml() const
{
return !maCFList.IsEmpty() && !maXclRanges.empty();
}
void XclExpCondfmt::Save( XclExpStream& rStrm )
{
- if( IsValid() )
+ if( IsValidForBinary() )
{
XclExpRecord::Save( rStrm );
maCFList.Save( rStrm );
@@ -1305,7 +1315,7 @@ void XclExpCondfmt::WriteBody( XclExpStream& rStrm )
void XclExpCondfmt::SaveXml( XclExpXmlStream& rStrm )
{
- if( !IsValid() )
+ if( !IsValidForXml() )
return;
sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream();
@@ -1476,8 +1486,7 @@ XclExpCondFormatBuffer::XclExpCondFormatBuffer( const XclExpRoot& rRoot, XclExtL
itr != pCondFmtList->end(); ++itr)
{
XclExpCondfmtList::RecordRefType xCondfmtRec( new XclExpCondfmt( GetRoot(), **itr, xExtLst, nIndex ));
- if( xCondfmtRec->IsValid() )
- maCondfmtList.AppendRecord( xCondfmtRec );
+ maCondfmtList.AppendRecord( xCondfmtRec );
}
}
}
diff --git a/sc/source/filter/inc/xecontent.hxx b/sc/source/filter/inc/xecontent.hxx
index 1b8d00253d3a..78eec282e0b6 100644
--- a/sc/source/filter/inc/xecontent.hxx
+++ b/sc/source/filter/inc/xecontent.hxx
@@ -230,7 +230,8 @@ public:
virtual ~XclExpCondfmt() override;
/** Returns true, if this conditional format contains at least one cell range and CF record. */
- bool IsValid() const;
+ bool IsValidForBinary() const;
+ bool IsValidForXml() const;
/** Writes the CONDFMT record with following CF records, if there is valid data. */
virtual void Save( XclExpStream& rStrm ) override;