From 03b568ad49c6dd2c7169d14a4a606fd5b675f95b Mon Sep 17 00:00:00 2001 From: "Elena.Subbotina" Date: Sat, 27 Apr 2024 12:24:30 +0300 Subject: [PATCH] fix bug #67673 --- OOXML/Common/ComplexTypes.cpp | 9 ++ OOXML/Common/ComplexTypes.h | 30 ++--- OOXML/Common/SimpleTypes_Word.cpp | 22 ++-- OOXML/DocxFormat/HeaderFooter.cpp | 187 +++++++++++++++++------------- OOXML/DocxFormat/HeaderFooter.h | 2 + 5 files changed, 143 insertions(+), 107 deletions(-) diff --git a/OOXML/Common/ComplexTypes.cpp b/OOXML/Common/ComplexTypes.cpp index 6fd06ffebe..e31d7ad1b1 100644 --- a/OOXML/Common/ComplexTypes.cpp +++ b/OOXML/Common/ComplexTypes.cpp @@ -2366,6 +2366,15 @@ namespace Word WritingElement_ReadAttributes_Read_else_if(oReader, L"w:xAlign", m_oXAlign) WritingElement_ReadAttributes_Read_else_if(oReader, L"w:y", m_oY) WritingElement_ReadAttributes_Read_else_if(oReader, L"w:yAlign", m_oYAlign) +//2003 + WritingElement_ReadAttributes_Read_else_if(oReader, L"w:x-align", m_oXAlign) + WritingElement_ReadAttributes_Read_else_if(oReader, L"w:y-align", m_oYAlign) + WritingElement_ReadAttributes_Read_else_if(oReader, L"w:hanchor", m_oHAnchor) + WritingElement_ReadAttributes_Read_else_if(oReader, L"w:vanchor", m_oVAnchor) + WritingElement_ReadAttributes_Read_else_if(oReader, L"w:hspace", m_oHSpace) + WritingElement_ReadAttributes_Read_else_if(oReader, L"w:vspace", m_oVSpace) + WritingElement_ReadAttributes_Read_else_if(oReader, L"w:hrule", m_oHRule) + WritingElement_ReadAttributes_End(oReader) } diff --git a/OOXML/Common/ComplexTypes.h b/OOXML/Common/ComplexTypes.h index 885118e001..b8e3b5dd2f 100644 --- a/OOXML/Common/ComplexTypes.h +++ b/OOXML/Common/ComplexTypes.h @@ -1073,21 +1073,21 @@ namespace ComplexTypes void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); public: - nullable m_oAnchorLock; - nullable m_oDropCap; - nullable m_oH; - nullable m_oHAnchor; - nullable m_oHRule; - nullable m_oHSpace; - nullable m_oLines; - nullable m_oVAnchor; - nullable m_oVSpace; - nullable m_oW; - nullable m_oWrap; - nullable m_oX; - nullable m_oXAlign; - nullable m_oY; - nullable m_oYAlign; + nullable m_oAnchorLock; + nullable m_oDropCap; + nullable m_oH; + nullable m_oHAnchor; + nullable m_oHRule; + nullable m_oHSpace; + nullable m_oLines; + nullable m_oVAnchor; + nullable m_oVSpace; + nullable m_oW; + nullable m_oWrap; + nullable m_oX; + nullable m_oXAlign; + nullable m_oY; + nullable m_oYAlign; }; //-------------------------------------------------------------------------------- diff --git a/OOXML/Common/SimpleTypes_Word.cpp b/OOXML/Common/SimpleTypes_Word.cpp index 334169dd67..9f8c41aba0 100644 --- a/OOXML/Common/SimpleTypes_Word.cpp +++ b/OOXML/Common/SimpleTypes_Word.cpp @@ -1680,10 +1680,11 @@ namespace SimpleTypes EHeightRule CHeightRule::FromString(const std::wstring &sValue) { - if ( (L"atLeast") == sValue ) this->m_eValue = heightruleAtLeast; - else if ( (L"auto") == sValue ) this->m_eValue = heightruleAuto; - else if ( (L"exact") == sValue ) this->m_eValue = heightruleExact; - else this->m_eValue = heightruleAuto; + if (L"atLeast" == sValue) this->m_eValue = heightruleAtLeast; + else if (L"at-least" == sValue) this->m_eValue = heightruleAtLeast; + else if (L"auto" == sValue) this->m_eValue = heightruleAuto; + else if (L"exact" == sValue) this->m_eValue = heightruleExact; + else this->m_eValue = heightruleAuto; return this->m_eValue; } @@ -4333,12 +4334,13 @@ namespace SimpleTypes EWrap CWrap::FromString(const std::wstring &sValue) { - if ( (L"around") == sValue ) this->m_eValue = wrapAround; - else if ( (L"auto") == sValue ) this->m_eValue = wrapAuto; - else if ( (L"none") == sValue ) this->m_eValue = wrapNone; - else if ( (L"notBeside") == sValue ) this->m_eValue = wrapNotBeside; - else if ( (L"through") == sValue ) this->m_eValue = wrapThrough; - else if ( (L"tight") == sValue ) this->m_eValue = wrapTight; + if (L"around" == sValue ) this->m_eValue = wrapAround; + else if (L"auto" == sValue ) this->m_eValue = wrapAuto; + else if (L"none" == sValue ) this->m_eValue = wrapNone; + else if (L"notBeside" == sValue ) this->m_eValue = wrapNotBeside; + else if (L"not-beside" == sValue) this->m_eValue = wrapNotBeside; + else if (L"through" == sValue ) this->m_eValue = wrapThrough; + else if (L"tight" == sValue ) this->m_eValue = wrapTight; else this->m_eValue = wrapAuto; return this->m_eValue; diff --git a/OOXML/DocxFormat/HeaderFooter.cpp b/OOXML/DocxFormat/HeaderFooter.cpp index cb2ceb7702..7bfc0f950d 100644 --- a/OOXML/DocxFormat/HeaderFooter.cpp +++ b/OOXML/DocxFormat/HeaderFooter.cpp @@ -91,93 +91,116 @@ namespace OOX } void CHdrFtr::fromXML(XmlUtils::CXmlLiteReader& oReader) { - std::wstring sName = oReader.GetName(); + std::wstring sName = XmlUtils::GetNameNoNS(oReader.GetName()); - if ( _T("w:ftr") == sName ) + if (L"ftr" == sName) m_eType = et_w_ftr; - else if ( _T("w:hdr") == sName ) + else if (L"hdr" == sName) m_eType = et_w_hdr; else return; - OOX::Document* document = WritingElement::m_pMainDocument; - ReadAttributes(oReader); - if ( !oReader.IsEmptyNode() ) + if (oReader.IsEmptyNode()) + return; + + int nHdrFtrDepth = oReader.GetDepth(); + CreateElements(oReader, nHdrFtrDepth); + } + void CHdrFtr::CreateElements(XmlUtils::CXmlLiteReader& oReader, int Depth) + { + OOX::Document* document = WritingElement::m_pMainDocument; + + while (oReader.ReadNextSiblingNode(Depth)) { - int nDocumentDepth = oReader.GetDepth(); - while ( oReader.ReadNextSiblingNode( nDocumentDepth ) ) + std::wstring sName = XmlUtils::GetNameNoNS(oReader.GetName()); + WritingElement* pItem = NULL; + + if (L"altChunk" == sName) + pItem = new Logic::CAltChunk(document); + else if (L"bookmarkEnd" == sName) + pItem = new Logic::CBookmarkEnd(document); + else if (L"bookmarkStart" == sName) + pItem = new Logic::CBookmarkStart(document); + else if (L"commentRangeEnd" == sName) + pItem = new Logic::CCommentRangeEnd(document); + else if (L"commentRangeStart" == sName) + pItem = new Logic::CCommentRangeStart(document); + //else if ( L"customXml") == sName ) + // pItem = new Logic::CCustomXml( document ); + else if (L"customXmlDelRangeEnd" == sName) + pItem = new Logic::CCustomXmlDelRangeEnd(document); + else if (L"customXmlDelRangeStart" == sName) + pItem = new Logic::CCustomXmlDelRangeStart(document); + else if (L"customXmlInsRangeEnd" == sName) + pItem = new Logic::CCustomXmlInsRangeEnd(document); + else if (L"customXmlInsRangeStart" == sName) + pItem = new Logic::CCustomXmlInsRangeStart(document); + else if (L"customXmlMoveFromRangeEnd" == sName) + pItem = new Logic::CCustomXmlMoveFromRangeEnd(document); + else if (L"customXmlMoveFromRangeStart" == sName) + pItem = new Logic::CCustomXmlMoveFromRangeStart(document); + else if (L"customXmlMoveToRangeEnd" == sName) + pItem = new Logic::CCustomXmlMoveToRangeEnd(document); + else if (L"customXmlMoveToRangeStart" == sName) + pItem = new Logic::CCustomXmlMoveToRangeStart(document); + else if (L"del" == sName) + pItem = new Logic::CDel(document); + else if (L"ins" == sName) + pItem = new Logic::CIns(document); + else if (L"moveFrom" == sName) + pItem = new Logic::CMoveFrom(document); + else if (L"moveFromRangeEnd" == sName) + pItem = new Logic::CMoveFromRangeEnd(document); + else if (L"moveFromRangeStart" == sName) + pItem = new Logic::CMoveFromRangeStart(document); + else if (L"moveTo" == sName) + pItem = new Logic::CMoveTo(document); + else if (L"moveToRangeEnd" == sName) + pItem = new Logic::CMoveToRangeEnd(document); + else if (L"moveToRangeStart" == sName) + pItem = new Logic::CMoveToRangeStart(document); + else if (L"oMath" == sName) + pItem = new Logic::COMath(document); + else if (L"oMathPara" == sName) + pItem = new Logic::COMathPara(document); + else if (L"p" == sName) + pItem = new Logic::CParagraph(document, this); + else if (L"permEnd" == sName) + pItem = new Logic::CPermEnd(document); + else if (L"permStart" == sName) + pItem = new Logic::CPermStart(document); + else if (L"proofErr" == sName) + pItem = new Logic::CProofErr(document); + else if (L"sdt" == sName) + pItem = new Logic::CSdt(document); + else if (L"tbl" == sName) + pItem = new Logic::CTbl(document); + else if (L"body" == sName && !oReader.IsEmptyNode()) { - std::wstring sName = oReader.GetName(); - WritingElement *pItem = NULL; - - if ( _T("w:altChunk") == sName ) - pItem = new Logic::CAltChunk( document ); - else if ( _T("w:bookmarkEnd") == sName ) - pItem = new Logic::CBookmarkEnd( document ); - else if ( _T("w:bookmarkStart") == sName ) - pItem = new Logic::CBookmarkStart( document ); - else if ( _T("w:commentRangeEnd") == sName ) - pItem = new Logic::CCommentRangeEnd( document ); - else if ( _T("w:commentRangeStart") == sName ) - pItem = new Logic::CCommentRangeStart( document ); - //else if ( _T("w:customXml") == sName ) - // pItem = new Logic::CCustomXml( document ); - else if ( _T("w:customXmlDelRangeEnd") == sName ) - pItem = new Logic::CCustomXmlDelRangeEnd( document ); - else if ( _T("w:customXmlDelRangeStart") == sName ) - pItem = new Logic::CCustomXmlDelRangeStart( document ); - else if ( _T("w:customXmlInsRangeEnd") == sName ) - pItem = new Logic::CCustomXmlInsRangeEnd( document ); - else if ( _T("w:customXmlInsRangeStart") == sName ) - pItem = new Logic::CCustomXmlInsRangeStart( document ); - else if ( _T("w:customXmlMoveFromRangeEnd") == sName ) - pItem = new Logic::CCustomXmlMoveFromRangeEnd( document ); - else if ( _T("w:customXmlMoveFromRangeStart") == sName ) - pItem = new Logic::CCustomXmlMoveFromRangeStart( document ); - else if ( _T("w:customXmlMoveToRangeEnd") == sName ) - pItem = new Logic::CCustomXmlMoveToRangeEnd( document ); - else if ( _T("w:customXmlMoveToRangeStart") == sName ) - pItem = new Logic::CCustomXmlMoveToRangeStart( document ); - else if ( _T("w:del") == sName ) - pItem = new Logic::CDel( document ); - else if ( _T("w:ins") == sName ) - pItem = new Logic::CIns( document ); - else if ( _T("w:moveFrom") == sName ) - pItem = new Logic::CMoveFrom( document ); - else if ( _T("w:moveFromRangeEnd") == sName ) - pItem = new Logic::CMoveFromRangeEnd( document ); - else if ( _T("w:moveFromRangeStart") == sName ) - pItem = new Logic::CMoveFromRangeStart( document ); - else if ( _T("w:moveTo") == sName ) - pItem = new Logic::CMoveTo( document ); - else if ( _T("w:moveToRangeEnd") == sName ) - pItem = new Logic::CMoveToRangeEnd( document ); - else if ( _T("w:moveToRangeStart") == sName ) - pItem = new Logic::CMoveToRangeStart( document ); - else if ( _T("m:oMath") == sName ) - pItem = new Logic::COMath( document ); - else if ( _T("m:oMathPara") == sName ) - pItem = new Logic::COMathPara( document ); - else if ( _T("w:p") == sName ) - pItem = new Logic::CParagraph( document, this ); - else if ( _T("w:permEnd") == sName ) - pItem = new Logic::CPermEnd( document ); - else if ( _T("w:permStart") == sName ) - pItem = new Logic::CPermStart( document ); - else if ( _T("w:proofErr") == sName ) - pItem = new Logic::CProofErr( document ); - else if ( _T("w:sdt") == sName ) - pItem = new Logic::CSdt( document ); - else if ( _T("w:tbl") == sName ) - pItem = new Logic::CTbl( document ); - - if ( pItem ) - { - pItem->fromXML(oReader); - m_arrItems.push_back( pItem ); - } + int nWBodyDepth = oReader.GetDepth(); + CreateElements(oReader, nWBodyDepth); + } + else if (L"sect" == sName && !oReader.IsEmptyNode()) + { + int nWxSectDepth = oReader.GetDepth(); + CreateElements(oReader, nWxSectDepth); + } + else if (L"sub-section" == sName && !oReader.IsEmptyNode()) + { + int nWxSubSectDepth = oReader.GetDepth(); + CreateElements(oReader, nWxSubSectDepth); + } + else if (L"pBdrGroup" == sName && !oReader.IsEmptyNode()) + { + int nWxBdrGroupDepth = oReader.GetDepth(); + CreateElements(oReader, nWxBdrGroupDepth); + } + if (pItem) + { + pItem->fromXML(oReader); + m_arrItems.push_back(pItem); } } } @@ -278,10 +301,10 @@ mc:Ignorable=\"w14 w15 wp14\">"); return m_eType; } void CHdrFtr::ReadAttributes(XmlUtils::CXmlLiteReader& oReader) -{ - WritingElement_ReadAttributes_Start( oReader ) - WritingElement_ReadAttributes_ReadSingle( oReader, _T("w:type"), m_oType ) - WritingElement_ReadAttributes_End( oReader ) -} + { + WritingElement_ReadAttributes_Start_No_NS(oReader) + WritingElement_ReadAttributes_ReadSingle(oReader, L"type", m_oType ) + WritingElement_ReadAttributes_End_No_NS(oReader) + } } // namespace OOX diff --git a/OOXML/DocxFormat/HeaderFooter.h b/OOXML/DocxFormat/HeaderFooter.h index ac893eedd7..53991cbcd0 100644 --- a/OOXML/DocxFormat/HeaderFooter.h +++ b/OOXML/DocxFormat/HeaderFooter.h @@ -63,6 +63,8 @@ namespace OOX virtual void fromXML(XmlUtils::CXmlNode& oNode); virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); + void CreateElements(XmlUtils::CXmlLiteReader& oReader, int Depth); + virtual std::wstring toXML() const; virtual void write(const CPath& oFilePath, const CPath& oDirectory, CContentTypes& oContent) const;