[Libreoffice-commits] core.git: 2 commits - sw/qa sw/source

Michael Stahl (via logerrit) logerrit at kemper.freedesktop.org
Wed Oct 23 11:10:01 UTC 2019


 sw/qa/extras/ooxmlexport/ooxmlexport5.cxx |    2 +-
 sw/qa/extras/ooxmlexport/ooxmlexport9.cxx |    2 +-
 sw/source/filter/ww8/wrtw8nds.cxx         |   21 +++++++++++++++++++--
 sw/source/filter/ww8/ww8par3.cxx          |    5 +++--
 sw/source/filter/ww8/ww8par5.cxx          |    1 +
 5 files changed, 25 insertions(+), 6 deletions(-)

New commits:
commit dd179e9c8f6f98268e204c0672be31bf008475cd
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Fri Oct 18 16:54:21 2019 +0200
Commit:     Michael Stahl <michael.stahl at cib.de>
CommitDate: Wed Oct 23 13:08:39 2019 +0200

    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 at cib.de>

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)
commit 4212803e08052af2c1b3618f52fefb651c429345
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Fri Oct 18 16:50:31 2019 +0200
Commit:     Michael Stahl <michael.stahl at cib.de>
CommitDate: Wed Oct 23 13:08:22 2019 +0200

    sw: WW8 import: be a little more flexible with FORMTEXT fields
    
    The subsequent export change will somehow create things like
    
    (rr) p pF->nLCode
    $1 = 13
    (rr) p rStr
    $2 = " FORMTEXT \001\062\060"
    
    ... so be a little less strict with the 0x01.
    
    Change-Id: Ie99002d099a3803989b71ae8c26b7f4bfe61c943
    Reviewed-on: https://gerrit.libreoffice.org/81083
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.stahl at cib.de>

diff --git a/sw/source/filter/ww8/ww8par3.cxx b/sw/source/filter/ww8/ww8par3.cxx
index 97701b5a2ea6..e62e13f6572d 100644
--- a/sw/source/filter/ww8/ww8par3.cxx
+++ b/sw/source/filter/ww8/ww8par3.cxx
@@ -91,8 +91,9 @@ eF_ResT SwWW8ImplReader::Read_F_FormTextBox( WW8FieldDesc* pF, OUString& rStr )
 {
     WW8FormulaEditBox aFormula(*this);
 
-    if (pF->nLCode && rStr[pF->nLCode-1]==0x01) {
-        ImportFormulaControl(aFormula,pF->nSCode+pF->nLCode-1, WW8_CT_EDIT);
+    sal_Int32 const nPos(rStr.indexOf(0x01));
+    if (pF->nLCode && nPos != -1 && nPos < pF->nLCode) {
+        ImportFormulaControl(aFormula, pF->nSCode + nPos, WW8_CT_EDIT);
     }
 
     /*
diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx
index 1ddbb49c3823..4089c42a665f 100644
--- a/sw/source/filter/ww8/ww8par5.cxx
+++ b/sw/source/filter/ww8/ww8par5.cxx
@@ -895,6 +895,7 @@ long SwWW8ImplReader::Read_Field(WW8PLCFManResult* pRes)
     if (aF.nId == 33) aF.bCodeNest=false; // do not recurse into nested page fields
     bool bCodeNest = aF.bCodeNest;
     if ( aF.nId == 6 ) bCodeNest = false; // We can handle them and lose the inner data
+    if (aF.nId == 70) bCodeNest = false; // need to import 0x01 in FORMTEXT
 
     m_aFieldStack.emplace_back(*m_pPaM->GetPoint(), aF.nId);
 


More information about the Libreoffice-commits mailing list