[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - writerfilter/qa writerfilter/source

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Mon Nov 16 14:55:20 UTC 2020


 writerfilter/qa/cppunittests/dmapper/DomainMapper_Impl.cxx        |    9 +++++++++
 writerfilter/qa/cppunittests/dmapper/data/field-if-inside-if.docx |binary
 writerfilter/source/dmapper/DomainMapper_Impl.cxx                 |   10 +++++++++-
 3 files changed, 18 insertions(+), 1 deletion(-)

New commits:
commit e1826cabdbb8f8c177f10497aec55539e523c268
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Fri Nov 13 09:45:47 2020 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Mon Nov 16 15:54:45 2020 +0100

    DOCX import: lost cached result of fields: fix leading whitespace
    
    " IF " and "IF " is the same, but "IFF " is something different.
    
    (cherry picked from commit 65d6173152deab49f9c9ed138f6d9fa56008b800)
    
    Conflicts:
            writerfilter/source/dmapper/DomainMapper_Impl.cxx
    
    Change-Id: Ieb2d128d28ed3daa3df73128804bcc40dda9878d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105942
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>

diff --git a/writerfilter/qa/cppunittests/dmapper/DomainMapper_Impl.cxx b/writerfilter/qa/cppunittests/dmapper/DomainMapper_Impl.cxx
index 6eba76b0fd6a..78fa3efa5483 100644
--- a/writerfilter/qa/cppunittests/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/qa/cppunittests/dmapper/DomainMapper_Impl.cxx
@@ -164,6 +164,15 @@ CPPUNIT_TEST_FIXTURE(Test, testFieldIfInsideIf)
     // - Actual  : 0** Expression is faulty **2
     // i.e. some of the inner fields escaped outside the outer field.
     CPPUNIT_ASSERT_EQUAL(OUString("2"), xCell->getString());
+
+    // Test the second cell: it contains "IF ", not the usual " IF ".
+    xCell.set(xTable->getCellByName("A2"), uno::UNO_QUERY);
+
+    // Without the accompanying fix in place, this test would have failed with:
+    // - Expected: 25
+    // - Actual  : 025
+    // i.e. some of the inner fields escaped outside the outer field.
+    CPPUNIT_ASSERT_EQUAL(OUString("25"), xCell->getString());
 }
 }
 
diff --git a/writerfilter/qa/cppunittests/dmapper/data/field-if-inside-if.docx b/writerfilter/qa/cppunittests/dmapper/data/field-if-inside-if.docx
index 93aaab52d497..65e238869b1b 100644
Binary files a/writerfilter/qa/cppunittests/dmapper/data/field-if-inside-if.docx and b/writerfilter/qa/cppunittests/dmapper/data/field-if-inside-if.docx differ
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index eb4c73762eef..12e4205096b4 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -205,7 +205,15 @@ static FieldContextPtr GetParentFieldContext(const std::deque<FieldContextPtr>&
 static bool IsFieldNestingAllowed(const FieldContextPtr& pOuter, const FieldContextPtr& pInner)
 {
     boost::optional<FieldId> oOuterFieldId = pOuter->GetFieldId();
-    if (!oOuterFieldId && pOuter->GetCommand().startsWith(" IF "))
+    OUString aCommand = pOuter->GetCommand();
+
+    // Ignore leading space before the field name, but don't accept IFF when we check for IF.
+    if (!aCommand.isEmpty() && aCommand[0] == ' ')
+    {
+        aCommand = aCommand.copy(1);
+    }
+
+    if (!oOuterFieldId && aCommand.startsWith("IF "))
     {
         // This will be FIELD_IF once the command is closed.
         oOuterFieldId = FIELD_IF;


More information about the Libreoffice-commits mailing list