diff options
author | Kohei Yoshida <kyoshida@novell.com> | 2011-06-10 01:07:24 -0400 |
---|---|---|
committer | Kohei Yoshida <kyoshida@novell.com> | 2011-06-10 01:10:37 -0400 |
commit | 099fd0fd91485797362259e45b1a971dda0511a3 (patch) | |
tree | f9a452f67d4a9caf9ba47f001e6dc83771b791e7 | |
parent | e89169562aa48ed38f3e4c91a9d79346c7602bf9 (diff) |
fdo#37622: Fix incorrect font attribute lookup during XLS import.
Font IDs in XF records are
* 0-based when it's less than 4, but
* 1-based when it's greater than 4.
That's what the spec says. And apparently the font ID of 4 is still
used in BIFF5 format, but not in BIFF8.
-rw-r--r-- | sc/source/filter/excel/xistyle.cxx | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/sc/source/filter/excel/xistyle.cxx b/sc/source/filter/excel/xistyle.cxx index 1fe26fd27..31bb0e8f9 100644 --- a/sc/source/filter/excel/xistyle.cxx +++ b/sc/source/filter/excel/xistyle.cxx @@ -549,10 +549,14 @@ const XclImpFont* XclImpFontBuffer::GetFont( sal_uInt16 nFontIndex ) const if (nFontIndex == 4) return &maFont4; - if (nFontIndex >= maFontList.size()) - return NULL; + if (nFontIndex < 4) + { + // Font ID is zero-based when it's less than 4. + return nFontIndex >= maFontList.size() ? NULL : &maFontList[nFontIndex]; + } - return (nFontIndex < 4) ? &(maFontList[nFontIndex]) : &(maFontList[nFontIndex - 1]); + // Font ID is greater than 4. It is now 1-based. + return nFontIndex > maFontList.size() ? NULL : &maFontList[nFontIndex-1]; } void XclImpFontBuffer::ReadFont( XclImpStream& rStrm ) |