sw/qa/extras/ooxmlexport/data/test_msword_hang.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 9 ++++ sw/source/filter/ww8/docxsdrexport.cxx | 37 ++++++++++++++++++-- sw/source/filter/ww8/docxsdrexport.hxx | 2 + 4 files changed, 46 insertions(+), 2 deletions(-)
New commits: commit 7e92d9881f039899262882633712ec0a3de01474 Author: Tushar Bende <tushar.be...@synerzip.com> Date: Wed Feb 26 15:34:58 2014 +0530 fdo#74771 : LibreOffice image captions crash MS Office Word There was a problem if 1)Document is created in MS word 2)then opened in Libreoffice and edited by adding Image and Caption 3)saved back to docx format 4)Attempt to open the DOCX file in Word. Word was crashing. Problem was if any doc is edited in LO by adding image and Caption LO adds image as anchored inside TextBox. Which MS word doesn't support(Anchored image inside TextBox). Verified code changes on both MSWord2007 & MSWord2010 as it was crashing both earlier. Conflicts: sw/qa/extras/ooxmlexport/ooxmlexport.cxx Reviewed on: https://gerrit.libreoffice.org/8354 Change-Id: I621d0c5e3acbf9e1fc8514aa70110aa863748ceb diff --git a/sw/qa/extras/ooxmlexport/data/test_msword_hang.docx b/sw/qa/extras/ooxmlexport/data/test_msword_hang.docx new file mode 100644 index 0000000..cae7814 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/test_msword_hang.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index 4d6e3b7..fb314fd 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -3726,6 +3726,15 @@ DECLARE_OOXMLEXPORT_TEST(testBibliography,"FDO75133.docx") CPPUNIT_ASSERT(contents.match(" BIBLIOGRAPHY ")); } +DECLARE_OOXMLEXPORT_TEST(testMSwordHang,"test_msword_hang.docx") +{ + // fdo#74771: + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if (!pXmlDoc) + return; + assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r[2]/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:txbx/w:txbxContent/w:p/w:r[2]/w:drawing/wp:inline", "distT", "0"); +} + #endif CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/filter/ww8/docxsdrexport.cxx b/sw/source/filter/ww8/docxsdrexport.cxx index bb771c8..94b598e 100644 --- a/sw/source/filter/ww8/docxsdrexport.cxx +++ b/sw/source/filter/ww8/docxsdrexport.cxx @@ -71,6 +71,7 @@ struct DocxSdrExport::Impl sax_fastparser::FastAttributeList* m_pTextboxAttrList; OStringBuffer m_aTextFrameStyle; bool m_bFrameBtLr; + bool m_bFlyFrameGraphic; sax_fastparser::FastAttributeList* m_pFlyFillAttrList; sax_fastparser::FastAttributeList* m_pFlyWrapAttrList; sax_fastparser::FastAttributeList* m_pBodyPrAttrList; @@ -87,6 +88,7 @@ struct DocxSdrExport::Impl m_pFlyAttrList(0), m_pTextboxAttrList(0), m_bFrameBtLr(false), + m_bFlyFrameGraphic(false), m_pFlyFillAttrList(0), m_pFlyWrapAttrList(0), m_pBodyPrAttrList(0), @@ -165,6 +167,16 @@ void DocxSdrExport::setFrameBtLr(bool bFrameBtLr) m_pImpl->m_bFrameBtLr = bFrameBtLr; } +bool DocxSdrExport::getFlyFrameGraphic() +{ + return m_pImpl->m_bFlyFrameGraphic; +} + +void DocxSdrExport::setFlyFrameGraphic(bool bFlyFrameGraphic) +{ + m_pImpl->m_bFlyFrameGraphic = bFlyFrameGraphic; +} + sax_fastparser::FastAttributeList*& DocxSdrExport::getFlyFillAttrList() { return m_pImpl->m_pFlyFillAttrList; @@ -197,7 +209,16 @@ void DocxSdrExport::startDMLAnchorInline(const SwFrmFmt* pFrmFmt, const Size& rS const SvxLRSpaceItem pLRSpaceItem = pFrmFmt->GetLRSpace(false); const SvxULSpaceItem pULSpaceItem = pFrmFmt->GetULSpace(false); - bool isAnchor = pFrmFmt->GetAnchor().GetAnchorId() != FLY_AS_CHAR; + bool isAnchor; + + if (m_pImpl->m_bFlyFrameGraphic) + { + isAnchor = false; // make Graphic object inside DMLTextFrame & VMLTextFrame as Inline + } + else + { + isAnchor = pFrmFmt->GetAnchor().GetAnchorId() != FLY_AS_CHAR; + } if (isAnchor) { ::sax_fastparser::FastAttributeList* attrList = m_pImpl->m_pSerializer->createAttrList(); @@ -415,7 +436,15 @@ void DocxSdrExport::startDMLAnchorInline(const SwFrmFmt* pFrmFmt, const Size& rS void DocxSdrExport::endDMLAnchorInline(const SwFrmFmt* pFrmFmt) { - bool isAnchor = pFrmFmt->GetAnchor().GetAnchorId() != FLY_AS_CHAR; + bool isAnchor; + if (m_pImpl->m_bFlyFrameGraphic) + { + isAnchor = false; // end Inline Graphic object inside DMLTextFrame + } + else + { + isAnchor = pFrmFmt->GetAnchor().GetAnchorId() != FLY_AS_CHAR; + } m_pImpl->m_pSerializer->endElementNS(XML_wp, isAnchor ? XML_anchor : XML_inline); m_pImpl->m_pSerializer->endElementNS(XML_w, XML_drawing); @@ -944,7 +973,9 @@ void DocxSdrExport::writeDMLTextFrame(sw::Frame* pParentFrame, int nAnchorId) pFS->startElementNS(XML_w, XML_txbxContent, FSEND); m_pImpl->m_bFrameBtLr = checkFrameBtlr(m_pImpl->m_rExport.pDoc->GetNodes()[nStt], 0); + m_pImpl->m_bFlyFrameGraphic = true; m_pImpl->m_rExport.WriteText(); + m_pImpl->m_bFlyFrameGraphic = false; m_pImpl->m_bFrameBtLr = false; pFS->endElementNS(XML_w, XML_txbxContent); @@ -1035,7 +1066,9 @@ void DocxSdrExport::writeVMLTextFrame(sw::Frame* pParentFrame) } pFS->startElementNS(XML_v, XML_textbox, xTextboxAttrList); pFS->startElementNS(XML_w, XML_txbxContent, FSEND); + m_pImpl->m_bFlyFrameGraphic = true; m_pImpl->m_rExport.WriteText(); + m_pImpl->m_bFlyFrameGraphic = false; pFS->endElementNS(XML_w, XML_txbxContent); pFS->endElementNS(XML_v, XML_textbox); diff --git a/sw/source/filter/ww8/docxsdrexport.hxx b/sw/source/filter/ww8/docxsdrexport.hxx index 04598f8..25c0ea1 100644 --- a/sw/source/filter/ww8/docxsdrexport.hxx +++ b/sw/source/filter/ww8/docxsdrexport.hxx @@ -64,6 +64,8 @@ public: /// Same, as DocxAttributeOutput::m_bBtLr, but for textframe rotation. bool getFrameBtLr(); void setFrameBtLr(bool bFrameBtLr); + bool getFlyFrameGraphic(); + void setFlyFrameGraphic(bool bFlyFrameGraphic); sax_fastparser::FastAttributeList*& getFlyFillAttrList(); sax_fastparser::FastAttributeList* getFlyWrapAttrList(); void setFlyWrapAttrList(sax_fastparser::FastAttributeList* pAttrList); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits