From a5495c97b5b2e4b9b5ee2c116ab0b57abbfbe551 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Sat, 9 Aug 2014 11:14:22 +0000 Subject: [PATCH] fpspreadsheet: More robust evaluation of xf style attributes but the OOXML reader (check "applyXXXX" against "<>'0'" instead of "='1'") git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3459 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- .../examples/spready/spready.lpi | 61 ++++++++++++++++++- components/fpspreadsheet/xlsxooxml.pas | 14 +++-- 2 files changed, 68 insertions(+), 7 deletions(-) diff --git a/components/fpspreadsheet/examples/spready/spready.lpi b/components/fpspreadsheet/examples/spready/spready.lpi index 55aa499e8..28c472d11 100644 --- a/components/fpspreadsheet/examples/spready/spready.lpi +++ b/components/fpspreadsheet/examples/spready/spready.lpi @@ -15,8 +15,67 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/components/fpspreadsheet/xlsxooxml.pas b/components/fpspreadsheet/xlsxooxml.pas index f28c8efa3..f5380b814 100755 --- a/components/fpspreadsheet/xlsxooxml.pas +++ b/components/fpspreadsheet/xlsxooxml.pas @@ -721,24 +721,26 @@ begin if nodeName = 'xf' then begin xf := TXfListData.Create; + // strange: sometimes the "apply*" are missing. Therefore, it may be better + // to check against "<>0" instead of "=1" s1 := GetAttrValue(node, 'numFmtId'); s2 := GetAttrValue(node, 'applyNumberFormat'); - if s2 = '1' then xf.NumFmtIndex := StrToInt(s1); + if s2 <> '0' then xf.NumFmtIndex := StrToInt(s1); s1 := GetAttrValue(node, 'fontId'); s2 := GetAttrValue(node, 'applyFont'); - if s2 = '1' then xf.FontIndex := StrToInt(s1); + if s2 <> '0' then xf.FontIndex := StrToInt(s1); s1 := GetAttrValue(node, 'fillId'); s2 := GetAttrValue(node, 'applyFill'); - if s2 = '1' then xf.FillIndex := StrToInt(s1); + if s2 <> '0' then xf.FillIndex := StrToInt(s1); s1 := GetAttrValue(node, 'borderId'); s2 := GetAttrValue(node, 'applyBorder'); - if s2 = '1' then xf.BorderIndex := StrToInt(s1); + if s2 <> '0' then xf.BorderIndex := StrToInt(s1); s2 := GetAttrValue(node, 'applyAlignment'); - if s2 = '1' then begin + if s2 <> '0' then begin childNode := node.FirstChild; while Assigned(childNode) do begin nodeName := childNode.NodeName; @@ -764,7 +766,7 @@ begin xf.VertAlignment := vaBottom; s1 := GetAttrValue(childNode, 'wrapText'); - if s1 = '1' then + if s1 <> '0' then xf.WordWrap := true; s1 := GetAttrValue(childNode, 'textRotation');