diff options
Diffstat (limited to 'sw/source/filter/ww8/docxattributeoutput.cxx')
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 50 |
1 files changed, 44 insertions, 6 deletions
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() |