2024-12-25 XLStyles: font strike(through) elements are now evaluated as true when they have no val attribute

This commit is contained in:
Lars Uffmann 2024-12-25 20:32:37 +01:00
parent 8d1bc65bf9
commit 99d53b2b09
2 changed files with 25 additions and 1 deletions

View File

@ -702,7 +702,22 @@ XLColor XLFont::fontColor() const
*/
bool XLFont::bold() const { return appendAndGetNodeAttribute(*m_fontNode, "b", "val", "false").as_bool() ; }
bool XLFont::italic() const { return appendAndGetNodeAttribute(*m_fontNode, "i", "val", "false").as_bool() ; }
bool XLFont::strikethrough() const { return appendAndGetNodeAttribute(*m_fontNode, "strike", "val", "false").as_bool() ; }
bool XLFont::strikethrough() const {
if (m_fontNode->empty()) return false;
XMLNode strikeNode = m_fontNode->child("strike");
if( strikeNode.empty() ) // no strike node: return false
return false;
// if execution gets here: strike node is not empty
XMLAttribute valAttr = strikeNode.attribute("val");
if( valAttr.empty() ) { // if no val attribute exists: default to true as per specification
appendAndSetAttribute(strikeNode, "val", "true" ); // explicitly create & set attribute
return true;
}
// if execution gets here: attribute val exists
return valAttr.as_bool(); // return attribute value
}
XLUnderlineStyle XLFont::underline() const { return XLUnderlineStyleFromString (appendAndGetNodeAttribute(*m_fontNode, "u", "val", "" ).value() ); }
XLFontSchemeStyle XLFont::scheme() const { return XLFontSchemeStyleFromString (appendAndGetNodeAttribute(*m_fontNode, "scheme", "val", "" ).value() ); }
XLVerticalAlignRunStyle XLFont::vertAlign() const { return XLVerticalAlignRunStyleFromString(appendAndGetNodeAttribute(*m_fontNode, "vertAlign", "val", "" ).value() ); }

View File

@ -3,6 +3,15 @@
OpenXLSX is a C++ library for reading, writing, creating and modifying
Microsoft Excel® files, with the .xlsx format.
## (aral-matrix) 25 December 2024 - XLStyles: fixed implementation of ```strike```(through) font property to address issue #314
* XLStyles: if the attribute ```val``` is omitted in the ```<strike>``` XML tag, the value is now interpreted as ```true``` as described in the format specification - previously this was wrongly interpreted as "strikethrough is not set". This addresses issue https://github.com/troldal/OpenXLSX/issues/314
## (aral-matrix) Development note 23 December 2024 - Performance issue: XLSharedStrings is instantiated too much
TODO:
* replace XLSharedStrings instantiations with smart pointers / reference variables
* because of the above, a std::string variable (m_xmlName) in XLSharedStrings is a major performance impact
(3-7 extra seconds on Demo7 runtime - 1m53 vs. 1m56-2m00)
## (aral-matrix) 26 November 2024 - NOTE: "Releases" are severely outdated - do not use them
As the heading says - the latest "Release" that is shown on https://github.com/troldal/OpenXLSX/releases is from 2021-11-06, and severely outdated - please pull / download the latest SW version directly from the repository in its current state. Link for those that do not want to use ```git```: https://github.com/troldal/OpenXLSX/archive/refs/heads/master.zip