summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Luth <justin_luth@sil.org>2017-09-06 19:29:40 -0400
committerMiklos Vajna <vmiklos@collabora.co.uk>2017-09-18 11:25:43 +0200
commitac1081170c5bc2234b14ce99b7ea8e583bac82b5 (patch)
treedb55ad22ee9fb6d8eb874d99ff5caace5bac87b7
parent79ceef1dd0970055a8de0f0676e1cd992a484ee1 (diff)
tdf#109310 ooxmlexport: write Xnote character style
LibreOffice will just ignore the defined style on import (since that is statically defined by the footnote code). Microsoft Office, however, requires the character style be provided for the footnote number. It doesn't have any built-in formatting for footnotes. So, this patch is strictly for MSO's benefit. Change-Id: I6631dd0eb697589cfd3c13d7838fe14c31a71bbf Reviewed-on: https://gerrit.libreoffice.org/42035 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r--sw/qa/extras/ooxmlexport/data/tdf109310_endnoteStyleForMSO.docxbin0 -> 5109 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport9.cxx7
-rw-r--r--sw/source/filter/ww8/attributeoutputbase.hxx2
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx18
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.hxx2
-rw-r--r--sw/source/filter/ww8/wrtw8nds.cxx8
6 files changed, 32 insertions, 5 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf109310_endnoteStyleForMSO.docx b/sw/qa/extras/ooxmlexport/data/tdf109310_endnoteStyleForMSO.docx
new file mode 100644
index 000000000000..9949b98d5f68
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf109310_endnoteStyleForMSO.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index a89799b87e39..24016d38c43c 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -420,6 +420,13 @@ DECLARE_OOXMLEXPORT_TEST(testTdf103975_notPageBreakE, "tdf103975_notPageBreakE.d
CPPUNIT_ASSERT_EQUAL(style::BreakType_COLUMN_BEFORE, getProperty<style::BreakType>(getParagraph(2), "BreakType"));
}
+DECLARE_OOXMLEXPORT_TEST(testTdf109310_endnoteStyleForMSO, "tdf109310_endnoteStyleForMSO.docx")
+{
+ xmlDocPtr pXmlDoc = parseExport("word/endnotes.xml");
+ if (!pXmlDoc)
+ return;
+ assertXPath(pXmlDoc, "/w:endnotes/w:endnote[@w:id='2']/w:p/w:r[1]/w:rPr/w:rStyle", "w:val");
+}
DECLARE_OOXMLEXPORT_TEST(testTdf103389, "tdf103389.docx")
{
diff --git a/sw/source/filter/ww8/attributeoutputbase.hxx b/sw/source/filter/ww8/attributeoutputbase.hxx
index 21111322b2f2..00ab40dcb88a 100644
--- a/sw/source/filter/ww8/attributeoutputbase.hxx
+++ b/sw/source/filter/ww8/attributeoutputbase.hxx
@@ -181,7 +181,7 @@ public:
virtual void EndRunProperties( const SwRedlineData* pRedlineData ) = 0;
/// docx requires footnoteRef/endnoteRef tag at the beginning of each of them
- virtual void FootnoteEndnoteRefTag() {};
+ virtual bool FootnoteEndnoteRefTag() { return false; };
/// for docx footnotePr/endnotePr inside sectPr
virtual void SectFootnoteEndnotePr() {};
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 1d0a3dfed712..3d7d8b53957e 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -2096,12 +2096,26 @@ void DocxAttributeOutput::WritePostponedDiagram()
m_pPostponedDiagrams.reset(nullptr);
}
-void DocxAttributeOutput::FootnoteEndnoteRefTag()
+bool DocxAttributeOutput::FootnoteEndnoteRefTag()
{
if( m_footnoteEndnoteRefTag == 0 )
- return;
+ return false;
+
+ // output the character style for MS Word's benefit
+ const SwEndNoteInfo& rInfo = m_footnoteEndnoteRefTag == XML_footnoteRef ?
+ m_rExport.m_pDoc->GetFootnoteInfo() : m_rExport.m_pDoc->GetEndNoteInfo();
+ const SwCharFormat* pCharFormat = rInfo.GetCharFormat( *m_rExport.m_pDoc );
+ if ( pCharFormat )
+ {
+ const OString aStyleId(m_rExport.m_pStyles->GetStyleId(m_rExport.GetId(pCharFormat)));
+ m_pSerializer->startElementNS( XML_w, XML_rPr, FSEND );
+ m_pSerializer->singleElementNS( XML_w, XML_rStyle, FSNS( XML_w, XML_val ), aStyleId.getStr(), FSEND );
+ m_pSerializer->endElementNS( XML_w, XML_rPr );
+ }
+
m_pSerializer->singleElementNS( XML_w, m_footnoteEndnoteRefTag, FSEND );
m_footnoteEndnoteRefTag = 0;
+ return true;
}
/** Output sal_Unicode* as a run text (<t>the text</t>).
diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx
index d06486403a07..8024566433f6 100644
--- a/sw/source/filter/ww8/docxattributeoutput.hxx
+++ b/sw/source/filter/ww8/docxattributeoutput.hxx
@@ -174,7 +174,7 @@ public:
/// Called after we end outputting the attributes.
virtual void EndRunProperties( const SwRedlineData* pRedlineData ) override;
- virtual void FootnoteEndnoteRefTag() override;
+ virtual bool FootnoteEndnoteRefTag() override;
virtual void SectFootnoteEndnotePr() override;
diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx
index 4c99f18b1d53..1397526a02d5 100644
--- a/sw/source/filter/ww8/wrtw8nds.cxx
+++ b/sw/source/filter/ww8/wrtw8nds.cxx
@@ -2153,7 +2153,13 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
AttrOutput().StartRun( pRedlineData, bSingleEmptyRun );
if( m_nTextTyp == TXT_FTN || m_nTextTyp == TXT_EDN )
- AttrOutput().FootnoteEndnoteRefTag();
+ {
+ if( AttrOutput().FootnoteEndnoteRefTag() )
+ {
+ AttrOutput().EndRun();
+ AttrOutput().StartRun( pRedlineData, bSingleEmptyRun );
+ }
+ }
if( nNextAttr > nEnd )
nNextAttr = nEnd;