[Libreoffice-commits] core.git: Branch 'distro/nisz/libreoffice-7-0' - sw/qa sw/source
Attila Bakos (via logerrit)
logerrit at kemper.freedesktop.org
Wed Jan 6 14:27:37 UTC 2021
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 fb96d90afc6028729dce9c0d8d53a45897e44d91
Author: Attila Bakos <bakos.attilakaroly at nisz.hu>
AuthorDate: Thu Aug 27 15:42:04 2020 +0200
Commit: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
CommitDate: Wed Jan 6 15:27:02 2021 +0100
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 <nemeth at numbertext.org>
Reviewed-by: László Németh <nemeth at numbertext.org>
(cherry picked from commit 5162647096fa061ae0a4ad5d4e1fd015fbeb9871)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108868
Tested-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
Reviewed-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
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 c7191ab8161a..f592bcd7c981 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -5997,9 +5997,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)
@@ -6007,9 +6026,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()
More information about the Libreoffice-commits
mailing list