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

Michael Stahl (via logerrit) logerrit at kemper.freedesktop.org
Tue Feb 25 14:35:05 UTC 2020


 sw/inc/pagedesc.hxx                          |    2 ++
 sw/qa/extras/ooxmlexport/ooxmlexport5.cxx    |    3 +++
 sw/source/core/layout/ftnfrm.cxx             |   12 ++++++++++--
 sw/source/filter/ww8/docxattributeoutput.cxx |   24 +++++++++++++++++++++++-
 4 files changed, 38 insertions(+), 3 deletions(-)

New commits:
commit d2b590614c71f195a5ea14c4e950e0129ca4e120
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Fri Feb 21 16:34:56 2020 +0100
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Tue Feb 25 15:34:28 2020 +0100

    sw: improve DOCX export of footnote separator a little more
    
    The Writer footnote separator has configurable line thickness and
    spacing above and below; let's abuse the font size of the paragraph to
    approximate the height of the separator (in the bugdoc that's currently
    interesting there isn't a separator line so if it works in that case
    it's good enough).
    
    Change-Id: I7f33e5a226ecaa9f9ab233e003c71aaed145b638
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89228
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.stahl at cib.de>
    (cherry picked from commit 12d88808fbde933c0498c895ddb74700c263bf0f)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89138
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>

diff --git a/sw/inc/pagedesc.hxx b/sw/inc/pagedesc.hxx
index 86e3fc075a7c..684bd040820d 100644
--- a/sw/inc/pagedesc.hxx
+++ b/sw/inc/pagedesc.hxx
@@ -377,6 +377,8 @@ public:
 
 namespace sw {
     class PageFootnoteHint final : public SfxHint {};
+
+    SW_DLLPUBLIC SwTwips FootnoteSeparatorHeight(SwPageFootnoteInfo const&);
 }
 
 typedef boost::multi_index_container<
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
index 9dfd7da47ecf..cb4b0ad2e3e7 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
@@ -339,9 +339,12 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testFootnoteSeparator, "footnotesep.fodt")
     assertXPath(pXmlFootnotes, "/w:footnotes[1]/w:footnote[1]", "id", "0");
     assertXPath(pXmlFootnotes, "/w:footnotes[1]/w:footnote[1]", "type", "separator");
     assertXPath(pXmlFootnotes, "/w:footnotes[1]/w:footnote[1]/w:p[1]/w:r[1]/w:separator", 0);
+    // use paragraph font size to simulate height
+    assertXPath(pXmlFootnotes, "/w:footnotes[1]/w:footnote[1]/w:p[1]/w:pPr[1]/w:rPr[1]/w:sz", "val", "12");
     assertXPath(pXmlFootnotes, "/w:footnotes[1]/w:footnote[2]", "id", "1");
     assertXPath(pXmlFootnotes, "/w:footnotes[1]/w:footnote[2]", "type", "continuationSeparator");
     assertXPath(pXmlFootnotes, "/w:footnotes[1]/w:footnote[2]/w:p[1]/w:r[1]/w:continuationSeparator", 0);
+    assertXPath(pXmlFootnotes, "/w:footnotes[1]/w:footnote[2]/w:p[1]/w:pPr[1]/w:rPr[1]/w:sz", "val", "12");
 
     xmlDocPtr pXmlSettings = parseExport("word/settings.xml");
     assertXPath(pXmlSettings, "/w:settings[1]/w:footnotePr[1]/w:footnote[1]", "id", "0");
diff --git a/sw/source/core/layout/ftnfrm.cxx b/sw/source/core/layout/ftnfrm.cxx
index da0cf0334de5..767ead4c6ef1 100644
--- a/sw/source/core/layout/ftnfrm.cxx
+++ b/sw/source/core/layout/ftnfrm.cxx
@@ -184,14 +184,22 @@ static long lcl_Undersize( const SwFrame* pFrame )
     return nRet;
 }
 
+namespace sw {
+
+SwTwips FootnoteSeparatorHeight(SwPageFootnoteInfo const& rInf)
+{
+    return rInf.GetTopDist() + rInf.GetBottomDist() + rInf.GetLineWidth();
+}
+
+} // namespace sw
+
 /// "format" the frame (Fixsize is not set here).
 void SwFootnoteContFrame::Format( vcl::RenderContext* /*pRenderContext*/, const SwBorderAttrs * )
 {
     // calculate total border, only one distance to the top
     const SwPageFrame* pPage = FindPageFrame();
     const SwPageFootnoteInfo &rInf = pPage->GetPageDesc()->GetFootnoteInfo();
-    const SwTwips nBorder = rInf.GetTopDist() + rInf.GetBottomDist() +
-                            rInf.GetLineWidth();
+    const SwTwips nBorder = sw::FootnoteSeparatorHeight(rInf);
     SwRectFnSet aRectFnSet(this);
 
     if ( !isFramePrintAreaValid() )
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 553d4b907583..d41691d39d59 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -7546,6 +7546,21 @@ void DocxAttributeOutput::FootnoteEndnoteReference()
     }
 }
 
+static void WriteFootnoteSeparatorHeight(
+    ::sax_fastparser::FSHelperPtr const& pSerializer, SwTwips const nHeight)
+{
+    // try to get the height by setting font size of the paragraph
+    if (nHeight != 0)
+    {
+        pSerializer->startElementNS(XML_w, XML_pPr);
+        pSerializer->startElementNS(XML_w, XML_rPr);
+        pSerializer->singleElementNS(XML_w, XML_sz, FSNS(XML_w, XML_val),
+            OString::number((nHeight + 5) / 10));
+        pSerializer->endElementNS(XML_w, XML_rPr);
+        pSerializer->endElementNS(XML_w, XML_pPr);
+    }
+}
+
 void DocxAttributeOutput::FootnotesEndnotes( bool bFootnotes )
 {
     m_setFootnote = true;
@@ -7564,9 +7579,9 @@ void DocxAttributeOutput::FootnotesEndnotes( bool bFootnotes )
             FSNS( XML_w, XML_id ), OString::number(nIndex++),
             FSNS( XML_w, XML_type ), "separator" );
     m_pSerializer->startElementNS(XML_w, XML_p);
-    m_pSerializer->startElementNS(XML_w, XML_r);
 
     bool bSeparator = true;
+    SwTwips nHeight(0);
     if (bFootnotes)
     {
         const SwPageFootnoteInfo& rFootnoteInfo = m_rExport.m_pDoc->GetPageDesc(0).GetFootnoteInfo();
@@ -7574,8 +7589,12 @@ void DocxAttributeOutput::FootnotesEndnotes( bool bFootnotes )
         bSeparator = rFootnoteInfo.GetLineStyle() != SvxBorderLineStyle::NONE
                   && rFootnoteInfo.GetLineWidth() > 0
                   && double(rFootnoteInfo.GetWidth()) > 0;
+        nHeight = sw::FootnoteSeparatorHeight(rFootnoteInfo);
     }
 
+    WriteFootnoteSeparatorHeight(m_pSerializer, nHeight);
+
+    m_pSerializer->startElementNS(XML_w, XML_r);
     if (bSeparator)
         m_pSerializer->singleElementNS(XML_w, XML_separator);
     m_pSerializer->endElementNS( XML_w, XML_r );
@@ -7587,6 +7606,9 @@ void DocxAttributeOutput::FootnotesEndnotes( bool bFootnotes )
             FSNS( XML_w, XML_id ), OString::number(nIndex++),
             FSNS( XML_w, XML_type ), "continuationSeparator" );
     m_pSerializer->startElementNS(XML_w, XML_p);
+
+    WriteFootnoteSeparatorHeight(m_pSerializer, nHeight);
+
     m_pSerializer->startElementNS(XML_w, XML_r);
     if (bSeparator)
     {


More information about the Libreoffice-commits mailing list