summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAttila Bakos <bakos.attilakaroly@nisz.hu>2020-08-27 15:42:04 +0200
committerGabor Kelemen <kelemen.gabor2@nisz.hu>2020-10-14 18:05:22 +0200
commit6f28da39e8e6f1326e2755c4c2a375fb2080ebab (patch)
tree139313a012cf0a17daf0bc6f2bc2346566573d59
parent03cd9c42f936b79a2ef149665f319eb34290d85c (diff)
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@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org> (cherry picked from commit 5162647096fa061ae0a4ad5d4e1fd015fbeb9871) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104303 Tested-by: Gabor Kelemen <kelemen.gabor2@nisz.hu> Reviewed-by: Gabor Kelemen <kelemen.gabor2@nisz.hu>
-rw-r--r--sw/qa/core/exportdata/ooxml/pass/tdf135711.odtbin0 -> 54558 bytes
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx50
2 files changed, 44 insertions, 6 deletions
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
--- /dev/null
+++ b/sw/qa/core/exportdata/ooxml/pass/tdf135711.odt
Binary files differ
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 4b8ffce6cb84..dc10dbb69680 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -5900,9 +5900,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)
@@ -5910,9 +5929,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()