[Libreoffice-commits] core.git: sw/qa sw/source

Miklos Vajna vmiklos at collabora.co.uk
Tue Jun 19 07:03:38 UTC 2018


 sw/qa/extras/ooxmlexport/data/tdf117805.odt |binary
 sw/qa/extras/ooxmlexport/ooxmlexport11.cxx  |   13 +++++++++++++
 sw/source/filter/ww8/docxsdrexport.cxx      |   11 +++++++++--
 3 files changed, 22 insertions(+), 2 deletions(-)

New commits:
commit 853350787df9a8d92c269ef1b6e764863e74ec2a
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon Jun 18 21:06:30 2018 +0200

    tdf#117805 DOCX export: fix lost header with at-page anchored frames
    
    The bug has two parts: on one hand, the header was not completely lost,
    just was written inside a shape. This is not valid, but at least our own
    import understood that. This commit restores that old behavior, focusing
    on just the regression part of the bugreport.
    
    On the other hand the exported header is still referenced at an
    incorrect location: the correct location would be the end of the
    document. But that is follow-up work, it seems that never worked.
    
    Change-Id: I468df9013c65ec581e3a474a5bf2f773fcb4f990
    Reviewed-on: https://gerrit.libreoffice.org/56058
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/sw/qa/extras/ooxmlexport/data/tdf117805.odt b/sw/qa/extras/ooxmlexport/data/tdf117805.odt
new file mode 100644
index 000000000000..828384b3613d
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf117805.odt differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
index 87d35f8a300c..730765a8c9ff 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
@@ -191,6 +191,19 @@ DECLARE_OOXMLEXPORT_TEST(testSignatureLineShape, "signature-line-all-props-set.d
     CPPUNIT_ASSERT_EQUAL(OUString("Check the machines!"), aSigningInstructions);
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf117805, "tdf117805.odt")
+{
+    if (!mbExported)
+        return;
+
+    uno::Reference<packages::zip::XZipFileAccess2> xNameAccess
+        = packages::zip::ZipFileAccess::createWithURL(comphelper::getComponentContext(m_xSFactory),
+                                                      maTempFile.GetURL());
+    // This failed, the header was lost. It's still referenced at an incorrect
+    // location in document.xml, though.
+    CPPUNIT_ASSERT(xNameAccess->hasByName("word/header1.xml"));
+}
+
 DECLARE_OOXMLEXPORT_TEST(testTdf113183, "tdf113183.docx")
 {
     // The horizontal positioning of the star shape affected the positioning of
diff --git a/sw/source/filter/ww8/docxsdrexport.cxx b/sw/source/filter/ww8/docxsdrexport.cxx
index 8acb92e3e9ac..b714481d0043 100644
--- a/sw/source/filter/ww8/docxsdrexport.cxx
+++ b/sw/source/filter/ww8/docxsdrexport.cxx
@@ -117,6 +117,13 @@ void lclMovePositionWithRotation(awt::Point& aPos, const Size& rSize, sal_Int64
     aPos.X += nXDiff;
     aPos.Y += nYDiff;
 }
+
+/// Determines if the anchor is inside a paragraph.
+bool IsAnchorTypeInsideParagraph(const ww8::Frame* pFrame)
+{
+    const SwFormatAnchor& rAnchor = pFrame->GetFrameFormat().GetAttrSet().GetAnchor();
+    return rAnchor.GetAnchorId() != RndStdIds::FLY_AT_PAGE;
+}
 }
 
 ExportDataSaveRestore::ExportDataSaveRestore(DocxExport& rExport, sal_uLong nStt, sal_uLong nEnd,
@@ -1395,7 +1402,7 @@ void DocxSdrExport::writeDMLTextFrame(ww8::Frame const* pParentFrame, int nAncho
                                       bool bTextBoxOnly)
 {
     bool bDMLAndVMLDrawingOpen = m_pImpl->m_bDMLAndVMLDrawingOpen;
-    m_pImpl->m_bDMLAndVMLDrawingOpen = true;
+    m_pImpl->m_bDMLAndVMLDrawingOpen = IsAnchorTypeInsideParagraph(pParentFrame);
 
     sax_fastparser::FSHelperPtr pFS = m_pImpl->m_pSerializer;
     const SwFrameFormat& rFrameFormat = pParentFrame->GetFrameFormat();
@@ -1690,7 +1697,7 @@ void DocxSdrExport::writeDMLTextFrame(ww8::Frame const* pParentFrame, int nAncho
 void DocxSdrExport::writeVMLTextFrame(ww8::Frame const* pParentFrame, bool bTextBoxOnly)
 {
     bool bDMLAndVMLDrawingOpen = m_pImpl->m_bDMLAndVMLDrawingOpen;
-    m_pImpl->m_bDMLAndVMLDrawingOpen = true;
+    m_pImpl->m_bDMLAndVMLDrawingOpen = IsAnchorTypeInsideParagraph(pParentFrame);
 
     sax_fastparser::FSHelperPtr pFS = m_pImpl->m_pSerializer;
     const SwFrameFormat& rFrameFormat = pParentFrame->GetFrameFormat();


More information about the Libreoffice-commits mailing list