sw/qa/core/exportdata/ooxml/pass/tdf135711.odt |binary sw/source/filter/ww8/docxattributeoutput.cxx | 50 ++++++++++++++++++++++--- 2 files changed, 44 insertions(+), 6 deletions(-)
New commits: commit 5162647096fa061ae0a4ad5d4e1fd015fbeb9871 Author: Attila Bakos <bakos.attilakar...@nisz.hu> AuthorDate: Thu Aug 27 15:42:04 2020 +0200 Commit: László Németh <nem...@numbertext.org> CommitDate: Mon Aug 31 11:10:28 2020 +0200 tdf#135711: DOCX export: fix crash on page anchored textboxes Page anchored objects didn't have the address what is needed for the exporter for positioning. Fixed by using another address. Regression from commit fd88bb81236ad6d1a63436b7ce20f2f93410d359 (tdf#107225 tdf#122887 sw: fix reanchoring of textboxes). Change-Id: I0e41468148e96e1323b9f502aa1f8ca326c5de29 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101480 Tested-by: László Németh <nem...@numbertext.org> Reviewed-by: László Németh <nem...@numbertext.org> diff --git a/sw/qa/core/exportdata/ooxml/pass/tdf135711.odt b/sw/qa/core/exportdata/ooxml/pass/tdf135711.odt new file mode 100644 index 000000000000..7110ce2909da Binary files /dev/null and b/sw/qa/core/exportdata/ooxml/pass/tdf135711.odt differ diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 014ba6f96cd8..4bd72ebf247a 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -5985,9 +5985,28 @@ void DocxAttributeOutput::WriteTextBox(uno::Reference<drawing::XShape> xShape) DocxTableExportContext aTableExportContext(*this); SwFrameFormat* pTextBox = SwTextBoxHelper::getOtherTextBoxFormat(xShape); - const SwPosition* pAnchor = pTextBox->GetAnchor().GetContentAnchor(); - ww8::Frame aFrame(*pTextBox, *pAnchor); - m_rExport.SdrExporter().writeDMLTextFrame(&aFrame, m_anchorId++, /*bTextBoxOnly=*/true); + assert(pTextBox); + const SwPosition* pAnchor = nullptr; + if (pTextBox->GetAnchor().GetAnchorId() == RndStdIds::FLY_AT_PAGE) //tdf135711 + { + auto pNdIdx = pTextBox->GetContent().GetContentIdx(); + if (pNdIdx) //Is that possible it is null? + pAnchor = new SwPosition(*pNdIdx); + } + else + { + pAnchor = pTextBox->GetAnchor().GetContentAnchor();//This might be null + } + + if (pAnchor) //pAnchor can be null, so that's why not assert here. + { + ww8::Frame aFrame(*pTextBox, *pAnchor); + m_rExport.SdrExporter().writeDMLTextFrame(&aFrame, m_anchorId++, /*bTextBoxOnly=*/true); + if (pTextBox->GetAnchor().GetAnchorId() == RndStdIds::FLY_AT_PAGE) + { + delete pAnchor; + } + } } void DocxAttributeOutput::WriteVMLTextBox(uno::Reference<drawing::XShape> xShape) @@ -5995,9 +6014,28 @@ void DocxAttributeOutput::WriteVMLTextBox(uno::Reference<drawing::XShape> xShape DocxTableExportContext aTableExportContext(*this); SwFrameFormat* pTextBox = SwTextBoxHelper::getOtherTextBoxFormat(xShape); - const SwPosition* pAnchor = pTextBox->GetAnchor().GetContentAnchor(); - ww8::Frame aFrame(*pTextBox, *pAnchor); - m_rExport.SdrExporter().writeVMLTextFrame(&aFrame, /*bTextBoxOnly=*/true); + assert(pTextBox); + const SwPosition* pAnchor = nullptr; + if (pTextBox->GetAnchor().GetAnchorId() == RndStdIds::FLY_AT_PAGE) //tdf135711 + { + auto pNdIdx = pTextBox->GetContent().GetContentIdx(); + if (pNdIdx) //Is that possible it is null? + pAnchor = new SwPosition(*pNdIdx); + } + else + { + pAnchor = pTextBox->GetAnchor().GetContentAnchor();//This might be null + } + + if (pAnchor) //pAnchor can be null, so that's why not assert here. + { + ww8::Frame aFrame(*pTextBox, *pAnchor); + m_rExport.SdrExporter().writeVMLTextFrame(&aFrame, /*bTextBoxOnly=*/true); + if (pTextBox->GetAnchor().GetAnchorId() == RndStdIds::FLY_AT_PAGE) + { + delete pAnchor; + } + } } oox::drawingml::DrawingML& DocxAttributeOutput::GetDrawingML() _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits