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

Vasily Melenchuk (via logerrit) logerrit at kemper.freedesktop.org
Thu Jun 4 23:11:47 UTC 2020


 sw/qa/extras/ooxmlexport/data/tdf83309.docx      |binary
 sw/qa/extras/ooxmlexport/ooxmlexport14.cxx       |   14 ++++++++++++++
 sw/source/core/text/txttab.cxx                   |   10 +++++++++-
 sw/source/filter/ww8/docxattributeoutput.cxx     |    2 +-
 sw/source/filter/ww8/wrtw8num.cxx                |    2 +-
 writerfilter/source/dmapper/NumberingManager.cxx |    4 ++--
 writerfilter/source/dmapper/NumberingManager.hxx |    3 +--
 7 files changed, 28 insertions(+), 7 deletions(-)

New commits:
commit d2e428d1abb9f2907c0b87d55830e8742f8209b9
Author:     Vasily Melenchuk <vasily.melenchuk at cib.de>
AuthorDate: Fri May 29 14:25:04 2020 +0300
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Fri Jun 5 01:11:11 2020 +0200

    tdf#83309: docx import: allow for lists tabstop at zero position
    
    Zero position is valid value for tabstop, but previously it was
    treated as "no tab stop defined". Right now writer distinguishes
    tab stop at zero postion and no tab stop.
    
    Change-Id: Ie32da3d36a263644ba85a882029a8b29ae0501c8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95132
    Tested-by: Jenkins
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>

diff --git a/sw/qa/extras/ooxmlexport/data/tdf83309.docx b/sw/qa/extras/ooxmlexport/data/tdf83309.docx
new file mode 100644
index 000000000000..8dfddb6ed201
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf83309.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
index b95d0afe4e8f..43cdd62d5b20 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
@@ -578,6 +578,20 @@ DECLARE_OOXMLIMPORT_TEST(testTdf125038c, "tdf125038c.docx")
     CPPUNIT_ASSERT_EQUAL(OUString("email: test at test.test"), aActual);
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf83309, "tdf83309.docx")
+{
+    CPPUNIT_ASSERT_EQUAL(1, getPages());
+    OUString sNodeType;
+
+    // First paragraph does not have tab before
+    sNodeType = parseDump("/root/page/body/txt[1]/Text[1]", "nType");
+    CPPUNIT_ASSERT_EQUAL(OUString("PortionType::Text"), sNodeType);
+
+    // Second paragraph starts with tab
+    sNodeType = parseDump("/root/page/body/txt[2]/Text[1]", "nType");
+    CPPUNIT_ASSERT_EQUAL(OUString("PortionType::TabLeft"), sNodeType);
+}
+
 DECLARE_OOXMLEXPORT_TEST(testTdf121661, "tdf121661.docx")
 {
     xmlDocUniquePtr pXmlSettings = parseExport("word/settings.xml");
diff --git a/sw/source/core/text/txttab.cxx b/sw/source/core/text/txttab.cxx
index a38cbe048d44..616a919eb2e0 100644
--- a/sw/source/core/text/txttab.cxx
+++ b/sw/source/core/text/txttab.cxx
@@ -119,7 +119,7 @@ SwTabPortion *SwTextFormatter::NewTabPortion( SwTextFormatInfo &rInf, bool bAuto
 
         // #i24363# tab stops relative to indent
         // nSearchPos: The current position relative to the tabs origin
-        const SwTwips nSearchPos = bRTL ?
+        SwTwips nSearchPos = bRTL ?
                                    nTabLeft - nCurrentAbsPos :
                                    nCurrentAbsPos - nTabLeft;
 
@@ -127,6 +127,14 @@ SwTabPortion *SwTextFormatter::NewTabPortion( SwTextFormatInfo &rInf, bool bAuto
         // any hard set tab stops:
         // Note: If there are no user defined tab stops, there is always a
         // default tab stop.
+
+        // If search is started from zero position (beginning of line), than
+        // lets do it from -1: this will allow to include into account potential
+        // tab stop at zero position. Yes, it will be zero width tab useless
+        // mostly, but this have sense in case of lists.
+        if (nSearchPos == 0)
+            nSearchPos = -1;
+
         const SvxTabStop* pTabStop = m_aLineInf.GetTabStop( nSearchPos, nMyRight );
         if ( pTabStop )
         {
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index b06cd1461d5a..937906cad902 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -6995,7 +6995,7 @@ void DocxAttributeOutput::NumberingLevel( sal_uInt8 nLevel,
 
     // indentation
     m_pSerializer->startElementNS(XML_w, XML_pPr);
-    if( nListTabPos != 0 )
+    if( nListTabPos >= 0 )
     {
         m_pSerializer->startElementNS(XML_w, XML_tabs);
         m_pSerializer->singleElementNS( XML_w, XML_tab,
diff --git a/sw/source/filter/ww8/wrtw8num.cxx b/sw/source/filter/ww8/wrtw8num.cxx
index 1774c37239e7..df51bb99be36 100644
--- a/sw/source/filter/ww8/wrtw8num.cxx
+++ b/sw/source/filter/ww8/wrtw8num.cxx
@@ -583,7 +583,7 @@ void MSWordExportBase::NumberingLevel(
 
     sal_Int16 nIndentAt = 0;
     sal_Int16 nFirstLineIndex = 0;
-    sal_Int16 nListTabPos = 0;
+    sal_Int16 nListTabPos = -1;
 
     // #i86652#
     if (rFormat.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION)
diff --git a/writerfilter/source/dmapper/NumberingManager.cxx b/writerfilter/source/dmapper/NumberingManager.cxx
index 047d29a065ca..8a17e6ead556 100644
--- a/writerfilter/source/dmapper/NumberingManager.cxx
+++ b/writerfilter/source/dmapper/NumberingManager.cxx
@@ -229,8 +229,8 @@ uno::Sequence<beans::PropertyValue> ListLevel::GetLevelProperties(bool bDefaults
         aNumberingProperties.push_back(lcl_makePropVal(PROP_GRAPHIC_SIZE, m_aGraphicSize));
     }
 
-    if (bDefaults || m_nTabstop != 0)
-        aNumberingProperties.push_back(lcl_makePropVal(PROP_LISTTAB_STOP_POSITION, m_nTabstop));
+    if (m_nTabstop.has_value())
+        aNumberingProperties.push_back(lcl_makePropVal(PROP_LISTTAB_STOP_POSITION, *m_nTabstop));
 
     //TODO: handling of nFLegal?
     //TODO: nFNoRestart lower levels do not restart when higher levels are incremented, like:
diff --git a/writerfilter/source/dmapper/NumberingManager.hxx b/writerfilter/source/dmapper/NumberingManager.hxx
index f2f89eca9f40..070086daa52b 100644
--- a/writerfilter/source/dmapper/NumberingManager.hxx
+++ b/writerfilter/source/dmapper/NumberingManager.hxx
@@ -51,7 +51,7 @@ class ListLevel : public PropertyMap
     OUString                               m_sBulletChar;
     css::awt::Size                         m_aGraphicSize;
     css::uno::Reference<css::awt::XBitmap> m_xGraphicBitmap;
-    sal_Int32                                     m_nTabstop;
+    std::optional<sal_Int32>               m_nTabstop;
     tools::SvRef< StyleSheetEntry >          m_pParaStyle;
     bool                                          m_outline;
     bool m_bHasValues = false;
@@ -65,7 +65,6 @@ public:
         ,m_nStartOverride(-1)
         ,m_nNFC(-1)
         ,m_nXChFollow(SvxNumberFormat::LISTTAB)
-        ,m_nTabstop( 0 )
         ,m_outline(false)
         {}
 


More information about the Libreoffice-commits mailing list