[Libreoffice-commits] core.git: Branch 'distro/nisz/libreoffice-6-4' - sw/qa sw/source

Attila Bakos (via logerrit) logerrit at kemper.freedesktop.org
Wed Oct 14 16:05:56 UTC 2020


 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 6f28da39e8e6f1326e2755c4c2a375fb2080ebab
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 Oct 14 18:05:22 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 <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/+/104303
    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 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()


More information about the Libreoffice-commits mailing list