diff options
author | Michael Stahl <Michael.Stahl@cib.de> | 2020-02-21 16:34:56 +0100 |
---|---|---|
committer | Michael Stahl <michael.stahl@cib.de> | 2020-02-21 17:23:21 +0100 |
commit | 12d88808fbde933c0498c895ddb74700c263bf0f (patch) | |
tree | 60d73e50dda0561c398a86402daaca1b5c37ee25 /sw | |
parent | 0540b098b7dab73c32947ed4b52cf3068eaa5125 (diff) |
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@cib.de>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/pagedesc.hxx | 2 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport5.cxx | 3 | ||||
-rw-r--r-- | sw/source/core/layout/ftnfrm.cxx | 12 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 24 |
4 files changed, 38 insertions, 3 deletions
diff --git a/sw/inc/pagedesc.hxx b/sw/inc/pagedesc.hxx index 632861e84d02..8d8c77d1c6e0 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 2e9aa7aabcae..2e7fa5962fb8 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx @@ -293,9 +293,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 6e1d3edb6e52..90aa3bf989dc 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 4b46844e0e6e..b4f137b67f0c 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -7564,6 +7564,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; @@ -7582,9 +7597,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(); @@ -7592,8 +7607,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 ); @@ -7605,6 +7624,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) { |