sw/qa/extras/odfexport/data/tdf131025_noZerosInTable.odt |binary
 sw/qa/extras/odfexport/odfexport2.cxx                    |   12 ++++++++++++
 sw/source/filter/xml/xmltbli.cxx                         |    2 +-
 3 files changed, 13 insertions(+), 1 deletion(-)

New commits:
commit d3b4ef0f7726ef1619717d9e3327963ceb4c065a
Author:     Justin Luth <justin_l...@sil.org>
AuthorDate: Fri Oct 22 21:11:59 2021 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Mon Oct 25 10:16:53 2021 +0200

    tdf#131025 ODF import: recognize SV_COUNTRY_LANGUAGE_OFFSET
    
    File import was making an exception for "float value 0"
    if the accompanying text had no resemblance to the value 0,
    but that only applied to GENERAL number format.
    
    It should apply to any language's default number format.
    
    REGRESSION warning: as we can see, this has been handled
    inconsistently in the past. But from the coding exception to overcome
    losing text to a zero (and the huge number of duplicate bugs)
    the best choice seems to be ignore the spec that says that
    a number value overrides the text value - at least in
    the case where the number value is zero.
    
    Change-Id: I701e72c6a5dad42c7799ab501255a4859adf61d4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124080
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <justin_l...@sil.org>
    Reviewed-by: Eike Rathke <er...@redhat.com>
    (cherry picked from commit 3e1d316734354c6b49696c8904e0fc431cfb5143)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124014
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sw/qa/extras/odfexport/data/tdf131025_noZerosInTable.odt 
b/sw/qa/extras/odfexport/data/tdf131025_noZerosInTable.odt
new file mode 100644
index 000000000000..f2bffb050ac4
Binary files /dev/null and 
b/sw/qa/extras/odfexport/data/tdf131025_noZerosInTable.odt differ
diff --git a/sw/qa/extras/odfexport/odfexport2.cxx 
b/sw/qa/extras/odfexport/odfexport2.cxx
index 3b1a7b8c527d..e58c460f0f7e 100644
--- a/sw/qa/extras/odfexport/odfexport2.cxx
+++ b/sw/qa/extras/odfexport/odfexport2.cxx
@@ -8,7 +8,9 @@
  */
 
 #include <swmodeltestbase.hxx>
+#include <unotxdoc.hxx>
 
+#include <com/sun/star/text/XTextTable.hpp>
 
 class Test : public SwModelTestBase
 {
@@ -49,6 +51,16 @@ DECLARE_ODFEXPORT_TEST(testTdf104254_noHeaderWrapping, 
"tdf104254_noHeaderWrappi
     CPPUNIT_ASSERT_MESSAGE("Paragraph should fit on a single line", 
nParaHeight < 600);
 }
 
+DECLARE_ODFEXPORT_TEST(testTdf131025_noZerosInTable, 
"tdf131025_noZerosInTable.odt")
+{
+    uno::Reference<text::XTextTablesSupplier> xSupplier(mxComponent, 
uno::UNO_QUERY);
+    uno::Reference<container::XNameAccess> xTables = 
xSupplier->getTextTables();
+    uno::Reference<text::XTextTable> xTable(xTables->getByName("Table1"), 
uno::UNO_QUERY);
+
+    uno::Reference<text::XTextRange> xCell(xTable->getCellByName("C3"), 
uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(OUString("5 gp"), xCell->getString());
+}
+
 DECLARE_ODFEXPORT_TEST(testTdf137199, "tdf137199.docx")
 {
     CPPUNIT_ASSERT_EQUAL(OUString(">1<"), 
getProperty<OUString>(getParagraph(1), "ListLabelString"));
diff --git a/sw/source/filter/xml/xmltbli.cxx b/sw/source/filter/xml/xmltbli.cxx
index 560fe1c81e1f..fc61659c5972 100644
--- a/sw/source/filter/xml/xmltbli.cxx
+++ b/sw/source/filter/xml/xmltbli.cxx
@@ -1928,7 +1928,7 @@ SwTableBox *SwXMLTableContext::MakeTableBox(
             {
                 const SwTableBoxNumFormat* pNumFormat =
                     static_cast<const SwTableBoxNumFormat*>( pItem );
-                if( ( pNumFormat != nullptr ) && ( pNumFormat->GetValue() == 0 
) )
+                if (pNumFormat && (pNumFormat->GetValue() % 
SV_COUNTRY_LANGUAGE_OFFSET) == 0)
                 {
                     // only one text node?
                     SwNodeIndex aNodeIndex( *(pCell->GetStartNode()), 1 );

Reply via email to