summaryrefslogtreecommitdiff
path: root/sw/source/filter/ww8/docxattributeoutput.cxx
diff options
context:
space:
mode:
authorAttila Bakos <bakos.attilakaroly@nisz.hu>2020-08-27 15:42:04 +0200
committerLászló Németh <nemeth@numbertext.org>2020-08-31 11:10:28 +0200
commit5162647096fa061ae0a4ad5d4e1fd015fbeb9871 (patch)
tree7b2065d079170b3d5617ef862a0912b809719433 /sw/source/filter/ww8/docxattributeoutput.cxx
parent48289c37d73e7780ef3ea6a98aa5e214be0fde92 (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>
Diffstat (limited to 'sw/source/filter/ww8/docxattributeoutput.cxx')
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx50
1 files changed, 44 insertions, 6 deletions
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()