Kaydet (Commit) 7e92d988 authored tarafından Tushar Bende's avatar Tushar Bende Kaydeden (comit) Miklos Vajna

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
üst bf4352f0
......@@ -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();
......
......@@ -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);
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment