summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <Michael.Stahl@cib.de>2019-10-21 18:33:51 +0200
committerMichael Stahl <michael.stahl@cib.de>2019-10-23 13:09:20 +0200
commit94e0b8407b02d76b27324b8b08012eb024aca9e9 (patch)
tree6836e4f35c758e88cb135384f1a2e96d9d90d0c7
parent4f174e66431628fa1343ec44d63cc3f02cc0bb0b (diff)
sw: DOCX export of nested fieldmarks
The DocxAttributeOutput was more or less ignoring FieldFlags::CmdEnd; split CmdField_Impl() into 2 functions to write the command text with the Start like WW8/RTF and the separator with the CmdEnd. Change-Id: I7cfa52e2d786a8c9b427057eadc9ccc271d2f90f Reviewed-on: https://gerrit.libreoffice.org/81263 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@cib.de>
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport12.cxx2
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx2
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx21
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.hxx7
4 files changed, 26 insertions, 6 deletions
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx
index b60c6cd571e6..c48efcb95cc0 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx
@@ -678,7 +678,7 @@ DECLARE_OOXMLEXPORT_TEST(testTdf79435_legacyInputFields, "tdf79435_legacyInputFi
{
//using .doc input file to verify cross-format compatibility.
uno::Reference<text::XFormField> xFormField
- = getProperty<uno::Reference<text::XFormField>>(getRun(getParagraph(5), 2), "Bookmark");
+ = getProperty<uno::Reference<text::XFormField>>(getRun(getParagraph(5), 3), "Bookmark");
uno::Reference<container::XNameContainer> xParameters(xFormField->getParameters());
OUString sTmp;
diff --git a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx
index 3996c634ab8f..15390ccd574c 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx
@@ -537,7 +537,7 @@ DECLARE_OOXMLEXPORT_TEST(testSdtDateDuplicate, "sdt-date-duplicate.docx")
DECLARE_OOXMLEXPORT_TEST(testFdo81492, "fdo81492.docx")
{
if (xmlDocPtr pXmlDoc = parseExport())
- assertXPathContent(pXmlDoc, "/w:document/w:body/w:p[1]/w:r[7]/w:instrText", "ADDIN EN.CITE.DATA");
+ assertXPathContent(pXmlDoc, "/w:document/w:body/w:p[1]/w:r[6]/w:instrText", "ADDIN EN.CITE.DATA");
}
DECLARE_OOXMLEXPORT_TEST(testEditTime, "fdo81341.docx")
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 3eb6cf085b7c..9e5c5aad1784 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -1394,7 +1394,18 @@ void DocxAttributeOutput::EndRun(const SwTextNode* pNode, sal_Int32 nPos, bool /
++m_nFieldsInHyperlink;
// Remove the field if no end needs to be written
- if ( !pIt->bClose ) {
+ if (!pIt->bSep)
+ {
+ pIt = m_Fields.erase( pIt );
+ continue;
+ }
+ }
+ if (pIt->bSep && !pIt->pField)
+ {
+ CmdEndField_Impl(pNode, nPos, true);
+ // Remove the field if no end needs to be written
+ if (!pIt->bClose)
+ {
pIt = m_Fields.erase( pIt );
continue;
}
@@ -2073,9 +2084,12 @@ void DocxAttributeOutput::CmdField_Impl( const SwTextNode* pNode, sal_Int32 nPos
m_pSerializer->endElementNS( XML_w, XML_r );
}
}
+}
+void DocxAttributeOutput::CmdEndField_Impl(SwTextNode const*const pNode,
+ sal_Int32 const nPos, bool const bWriteRun)
+{
// Write the Field separator
- {
if ( bWriteRun )
{
m_pSerializer->startElementNS(XML_w, XML_r);
@@ -2089,7 +2103,6 @@ void DocxAttributeOutput::CmdField_Impl( const SwTextNode* pNode, sal_Int32 nPos
{
m_pSerializer->endElementNS( XML_w, XML_r );
}
- }
}
/// Writes properties for run that is used to separate field implementation.
@@ -2190,6 +2203,7 @@ void DocxAttributeOutput::EndField_Impl( const SwTextNode* pNode, sal_Int32 nPos
if ( rInfos.pField )
{
CmdField_Impl( pNode, nPos, rInfos, true );
+ CmdEndField_Impl( pNode, nPos, true );
}
// Write the bookmark start if any
@@ -7356,6 +7370,7 @@ void DocxAttributeOutput::WriteField_Impl( const SwField* pField, ww::eField eTy
infos.sCmd = rFieldCmd;
infos.eType = eType;
infos.bClose = bool(FieldFlags::Close & nMode);
+ infos.bSep = bool(FieldFlags::CmdEnd & nMode);
infos.bOpen = bool(FieldFlags::Start & nMode);
m_Fields.push_back( infos );
diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx
index df8e10724987..d0f92c1f6fc6 100644
--- a/sw/source/filter/ww8/docxattributeoutput.hxx
+++ b/sw/source/filter/ww8/docxattributeoutput.hxx
@@ -58,9 +58,13 @@ struct FieldInfos
const ::sw::mark::IFieldmark* pFieldmark;
ww::eField eType;
bool bOpen;
+ bool bSep;
bool bClose;
OUString sCmd;
- FieldInfos() : pFieldmark(nullptr), eType(ww::eUNKNOWN), bOpen(false), bClose(false){}
+ FieldInfos()
+ : pFieldmark(nullptr), eType(ww::eUNKNOWN)
+ , bOpen(false), bSep(false), bClose(false)
+ {}
};
enum DocxColBreakStatus
@@ -717,6 +721,7 @@ private:
void StartField_Impl( const SwTextNode* pNode, sal_Int32 nPos, FieldInfos const & rInfos, bool bWriteRun = false );
void DoWriteCmd( const OUString& rCmd );
void CmdField_Impl( const SwTextNode* pNode, sal_Int32 nPos, FieldInfos const & rInfos, bool bWriteRun );
+ void CmdEndField_Impl( const SwTextNode* pNode, sal_Int32 nPos, bool bWriteRun );
void EndField_Impl( const SwTextNode* pNode, sal_Int32 nPos, FieldInfos& rInfos );
void DoWriteFieldRunProperties( const SwTextNode* pNode, sal_Int32 nPos, bool bWriteCombChars = false );