summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <Michael.Stahl@cib.de>2019-10-18 16:54:21 +0200
committerMichael Stahl <michael.stahl@cib.de>2019-10-23 13:08:39 +0200
commitdd179e9c8f6f98268e204c0672be31bf008475cd (patch)
treee3c67aac7efe8d595cfad92956132efc86acc6c1
parent4212803e08052af2c1b3618f52fefb651c429345 (diff)
sw: WW8/RTF/DOCX export: handle CH_TXT_ATR_FIELDSEP
Move second part of the fieldmark export later, where the separator dummy character is. Somehow this may result in an additional empty run, but that shouldn't matter, other than to a few tests. Change-Id: If6967e91721ae5ad51dc42ff1ba98625018eae84 Reviewed-on: https://gerrit.libreoffice.org/81084 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@cib.de>
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport5.cxx2
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport9.cxx2
-rw-r--r--sw/source/filter/ww8/wrtw8nds.cxx21
3 files changed, 21 insertions, 4 deletions
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
index 99044821e1ee..14ba1cde9683 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
@@ -896,7 +896,7 @@ DECLARE_OOXMLEXPORT_TEST(testfdo83048, "fdo83048.docx")
// Make sure Date is inside SDT tag.
// This will happen only if right SDT properties are exported.
- assertXPathContent(pXmlDoc, "/w:ftr/w:sdt/w:sdtContent/w:p[1]/w:sdt/w:sdtContent/w:r[1]/w:t",
+ assertXPathContent(pXmlDoc, "/w:ftr/w:sdt/w:sdtContent/w:p[1]/w:sdt/w:sdtContent/w:r[2]/w:t",
"1/2/2013");
}
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index 2dda95ca0bce..ece282f437aa 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -1142,7 +1142,7 @@ DECLARE_OOXMLEXPORT_TEST(testTdf111964, "tdf111964.docx")
return;
// Unicode spaces that are not XML whitespace must not be trimmed
const sal_Unicode sWSReference [] { 0x2002, 0x2002, 0x2002, 0x2002, 0x2002, 0 };
- assertXPathContent(pXmlDoc, "/w:document/w:body/w:p/w:r[5]/w:t", sWSReference);
+ assertXPathContent(pXmlDoc, "/w:document/w:body/w:p/w:r[6]/w:t", sWSReference);
}
DECLARE_OOXMLEXPORT_TEST(testWatermark, "watermark-shapetype.docx")
diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx
index aa70daf65738..924ed9fbd5ee 100644
--- a/sw/source/filter/ww8/wrtw8nds.cxx
+++ b/sw/source/filter/ww8/wrtw8nds.cxx
@@ -256,11 +256,12 @@ sal_Int32 SwWW8AttrIter::SearchNext( sal_Int32 nStartPos )
{
++fieldEndPos;
}
+ sal_Int32 fieldSepPos = aText.indexOf(CH_TXT_ATR_FIELDSEP, nStartPos);
sal_Int32 fieldStartPos = aText.indexOf(CH_TXT_ATR_FIELDSTART, nStartPos);
sal_Int32 formElementPos = aText.indexOf(CH_TXT_ATR_FORMELEMENT, nStartPos);
const sal_Int32 pos = lcl_getMinPos(
- lcl_getMinPos( fieldEndPos, fieldStartPos ),
+ lcl_getMinPos(lcl_getMinPos(fieldEndPos, fieldSepPos), fieldStartPos),
formElementPos );
sal_Int32 nMinPos = (pos>=0) ? pos : SAL_MAX_INT32;
@@ -2326,7 +2327,12 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
if ( !bTextAtr && nLen )
{
sal_Unicode ch = aStr[nCurrentPos];
- const sal_Int32 ofs = ( ch == CH_TXT_ATR_FIELDSTART || ch == CH_TXT_ATR_FIELDEND || ch == CH_TXT_ATR_FORMELEMENT? 1 : 0 );
+
+ const sal_Int32 ofs = (ch == CH_TXT_ATR_FIELDSTART
+ || ch == CH_TXT_ATR_FIELDSEP
+ || ch == CH_TXT_ATR_FIELDEND
+ || ch == CH_TXT_ATR_FORMELEMENT)
+ ? 1 : 0;
IDocumentMarkAccess* const pMarkAccess = m_pDoc->getIDocumentMarkAccess();
if ( ch == CH_TXT_ATR_FIELDSTART )
@@ -2379,6 +2385,17 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
WriteFormData( *pFieldmark );
else if (pFieldmark->GetFieldname() == ODF_HYPERLINK)
WriteHyperlinkData( *pFieldmark );
+ }
+ }
+ else if (ch == CH_TXT_ATR_FIELDSEP)
+ {
+ SwPosition aPosition(rNode, SwIndex(&rNode, nCurrentPos));
+ // the innermost field is the correct one
+ ::sw::mark::IFieldmark const*const pFieldmark = pMarkAccess->getFieldmarkFor(aPosition);
+ assert(pFieldmark);
+ // DateFieldmark / ODF_FORMDATE is not a field...
+ if (pFieldmark->GetFieldname() != ODF_FORMDATE)
+ {
OutputField( nullptr, lcl_getFieldId( pFieldmark ), OUString(), FieldFlags::CmdEnd );
if (pFieldmark->GetFieldname() == ODF_UNHANDLED)