From 43f49b7a9d342468fee865711e2bb18f1319201b Mon Sep 17 00:00:00 2001 From: Elena Subbotina Date: Wed, 21 Aug 2024 12:14:48 +0300 Subject: [PATCH] fix bug #69775 --- MsBinaryFile/DocFile/DocumentMapping.cpp | 2 +- MsBinaryFile/DocFile/OleObjectMapping.cpp | 70 +++++++++++------------ 2 files changed, 35 insertions(+), 37 deletions(-) diff --git a/MsBinaryFile/DocFile/DocumentMapping.cpp b/MsBinaryFile/DocFile/DocumentMapping.cpp index c232e31efd..ea426540b7 100644 --- a/MsBinaryFile/DocFile/DocumentMapping.cpp +++ b/MsBinaryFile/DocFile/DocumentMapping.cpp @@ -668,7 +668,7 @@ namespace DocFileFormat _skipRuns = 5; //with separator } } - else if ( bEMBED || (bLINK && !bHYPERLINK)|| bQUOTE) + else if ( bEMBED || (bLINK && !bHYPERLINK)/*|| bQUOTE*/) { int cpPic = searchNextTextMark(m_document->Text, cpFieldStart, TextMark::Picture); int cpFieldSep = searchNextTextMark(m_document->Text, cpFieldStart, TextMark::FieldSeparator); diff --git a/MsBinaryFile/DocFile/OleObjectMapping.cpp b/MsBinaryFile/DocFile/OleObjectMapping.cpp index 5b6695c2a6..29b74e17b8 100644 --- a/MsBinaryFile/DocFile/OleObjectMapping.cpp +++ b/MsBinaryFile/DocFile/OleObjectMapping.cpp @@ -45,49 +45,47 @@ namespace DocFileFormat void OleObjectMapping::Apply(IVisitable* visited) { - OleObject* ole = static_cast(visited); + OleObject* ole = dynamic_cast(visited); + if (!ole) return; + + if (ole->isEmbedded || ole->isPackage) + { + if (ole->isEquation) ole->ClipboardFormat = L"Equation"; + else if (ole->ClipboardFormat.empty()) ole->ClipboardFormat = L"MSWordDocx"; - if ( ole != NULL ) + ole->Program = L"Word.Document"; + } + m_pXmlWriter->WriteNodeBegin(L"o:OLEObject", TRUE); + + int relID = -1; + + if (ole->isLinked) + { + relID = m_context->_docx->RegisterExternalOLEObject(_caller, ole->ClipboardFormat, ole->Link); + + m_pXmlWriter->WriteAttribute(L"Type", L"Link"); + m_pXmlWriter->WriteAttribute(L"UpdateMode", ole->UpdateMode); + } + else { if (ole->isEmbedded || ole->isPackage) - { - if (ole->isEquation) ole->ClipboardFormat = L"Equation"; - else if (ole->ClipboardFormat.empty()) ole->ClipboardFormat = L"MSWordDocx"; - - ole->Program = L"Word.Document"; - } - m_pXmlWriter->WriteNodeBegin( L"o:OLEObject", TRUE ); - - int relID = -1; - - if ( ole->isLinked) - { - relID = m_context->_docx->RegisterExternalOLEObject(_caller, ole->ClipboardFormat, ole->Link); - - m_pXmlWriter->WriteAttribute( L"Type", L"Link" ); - m_pXmlWriter->WriteAttribute( L"UpdateMode", ole->UpdateMode); - } + relID = m_context->_docx->RegisterPackage(_caller, ole->ClipboardFormat); else - { - if (ole->isEmbedded || ole->isPackage) - relID = m_context->_docx->RegisterPackage(_caller, ole->ClipboardFormat); - else - relID = m_context->_docx->RegisterOLEObject(_caller, ole->ClipboardFormat); + relID = m_context->_docx->RegisterOLEObject(_caller, ole->ClipboardFormat); - m_pXmlWriter->WriteAttribute( L"Type", L"Embed" ); + m_pXmlWriter->WriteAttribute(L"Type", L"Embed"); - copyEmbeddedObject( ole ); - } - - m_pXmlWriter->WriteAttribute( L"ProgID", ole->Program); - m_pXmlWriter->WriteAttribute( L"ShapeID", _shapeId); - m_pXmlWriter->WriteAttribute( L"DrawAspect", L"Content" ); - m_pXmlWriter->WriteAttribute( L"ObjectID", ole->ObjectId); - m_pXmlWriter->WriteAttribute( L"r:id", L"rId"+ FormatUtils::IntToWideString( relID ) ); - m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE ); - - m_pXmlWriter->WriteNodeEnd( L"o:OLEObject" ); + copyEmbeddedObject(ole); } + + m_pXmlWriter->WriteAttribute(L"ProgID", ole->Program); + m_pXmlWriter->WriteAttribute(L"ShapeID", _shapeId); + m_pXmlWriter->WriteAttribute(L"DrawAspect", L"Content"); + m_pXmlWriter->WriteAttribute(L"ObjectID", ole->ObjectId); + m_pXmlWriter->WriteAttribute(L"r:id", L"rId" + FormatUtils::IntToWideString(relID)); + m_pXmlWriter->WriteNodeEnd(L"", TRUE, FALSE); + + m_pXmlWriter->WriteNodeEnd(L"o:OLEObject"); } std::wstring OleObjectMapping::GetTargetExt(const std::wstring& objectType)