[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-5-2+backports' - sw/qa sw/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Mon Nov 26 12:40:48 UTC 2018


 sw/qa/extras/ooxmlexport/data/tdf121456_tabsOffset.odt |binary
 sw/qa/extras/ooxmlexport/ooxmlexport11.cxx             |   11 ++++++
 sw/source/filter/ww8/docxattributeoutput.cxx           |   27 +++++++++++------
 3 files changed, 29 insertions(+), 9 deletions(-)

New commits:
commit 24eff43ac009558121f15d188b1d1ab6ffc81372
Author:     Serge Krot <Serge.Krot at cib.de>
AuthorDate: Fri Nov 16 09:53:37 2018 +0100
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Mon Nov 26 13:40:27 2018 +0100

    tdf#121456: sw: DOCX: tabs export and TABS_RELATIVE_TO_INDENT prop
    
    In DOCX, w:pos specifies the position of the current custom tab stop
    with respect to the current page margins.
    But in ODT, zero position could be page margins or paragraph indent
    according to used settings DocumentSettingId::TABS_RELATIVE_TO_INDENT
    
    Added new unit test.
    
    Change-Id: Ic56a8527380b6562f4239df1edce0c9b4649af24
    Reviewed-on: https://gerrit.libreoffice.org/63460
    Tested-by: Jenkins
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
    Tested-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
    Reviewed-on: https://gerrit.libreoffice.org/64035

diff --git a/sw/qa/extras/ooxmlexport/data/tdf121456_tabsOffset.odt b/sw/qa/extras/ooxmlexport/data/tdf121456_tabsOffset.odt
new file mode 100755
index 000000000000..ff8d5400950b
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf121456_tabsOffset.odt differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
index 4da51b6b87a1..b3ba248cc210 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
@@ -53,6 +53,17 @@ DECLARE_OOXMLEXPORT_TEST(testTdf46938_clearTabStop, "tdf46938_clearTabStop.docx"
     CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty< uno::Sequence<style::TabStop> >(getParagraph(1), "ParaTabStops").getLength());
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf121456_tabsOffset, "tdf121456_tabsOffset.odt")
+{
+    for (int i=2; i<8; i++)
+    {
+        uno::Sequence< style::TabStop > stops = getProperty< uno::Sequence<style::TabStop> >(getParagraph( i ), "ParaTabStops");
+        CPPUNIT_ASSERT_EQUAL( sal_Int32(1), stops.getLength());
+        CPPUNIT_ASSERT_EQUAL( css::style::TabAlign_RIGHT, stops[ 0 ].Alignment );
+        CPPUNIT_ASSERT_EQUAL( sal_Int32(17000), stops[ 0 ].Position );
+    }
+}
+
 DECLARE_OOXMLEXPORT_TEST(testTdf82065_Ind_start_strict, "tdf82065_Ind_start_strict.docx")
 {
     uno::Reference<beans::XPropertySet> xPropertySet(getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY);
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index fcd5bcf5f498..8ba68c790338 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -7443,8 +7443,8 @@ void DocxAttributeOutput::ParaWidows( const SvxWidowsItem& rWidows )
         m_pSerializer->singleElementNS( XML_w, XML_widowControl, FSNS( XML_w, XML_val ), "false", FSEND );
 }
 
-static void impl_WriteTabElement( FSHelperPtr pSerializer,
-                                  const SvxTabStop& rTab, long /* nCurrentLeft */ )
+static void impl_WriteTabElement( FSHelperPtr const & pSerializer,
+                                  const SvxTabStop& rTab, long tabsOffset )
 {
     FastAttributeList *pTabElementAttrList = FastSerializerHelper::createAttrList();
 
@@ -7466,9 +7466,11 @@ static void impl_WriteTabElement( FSHelperPtr pSerializer,
         break;
     }
 
-    // Because GetTabPos already includes indent, we don't need to add nCurrentLeft (CurrentLeft is indentation information)
-    //pTabElementAttrList->add( FSNS( XML_w, XML_pos ), OString::valueOf( rTab.GetTabPos() + nCurrentLeft ) );
-    pTabElementAttrList->add( FSNS( XML_w, XML_pos ), OString::number( rTab.GetTabPos()                ) );
+    // Write position according to used offset of the whole paragraph.
+    // In DOCX, w:pos specifies the position of the current custom tab stop with respect to the current page margins.
+    // But in ODT, zero position could be page margins or paragraph indent according to used settings.
+    // This is handled outside of this method and provided for us in tabsOffset parameter.
+    pTabElementAttrList->add( FSNS( XML_w, XML_pos ), OString::number( rTab.GetTabPos() + tabsOffset ) );
 
     sal_Unicode cFillChar = rTab.GetFill();
 
@@ -7488,9 +7490,6 @@ static void impl_WriteTabElement( FSHelperPtr pSerializer,
 
 void DocxAttributeOutput::ParaTabStop( const SvxTabStopItem& rTabStop )
 {
-    const SfxPoolItem* pLR = m_rExport.HasItem( RES_LR_SPACE );
-    long nCurrentLeft = pLR ? static_cast<const SvxLRSpaceItem*>(pLR)->GetTextLeft() : 0;
-
     sal_uInt16 nCount = rTabStop.Count();
 
     // <w:tabs> must contain at least one <w:tab>, so don't write it empty
@@ -7504,10 +7503,20 @@ void DocxAttributeOutput::ParaTabStop( const SvxTabStopItem& rTabStop )
 
     m_pSerializer->startElementNS( XML_w, XML_tabs, FSEND );
 
+    // Get offset for tabs
+    // In DOCX, w:pos specifies the position of the current custom tab stop with respect to the current page margins.
+    // But in ODT, zero position could be page margins or paragraph indent according to used settings.
+    long tabsOffset = 0;
+    if (m_rExport.m_pDoc->getIDocumentSettingAccess().get(DocumentSettingId::TABS_RELATIVE_TO_INDENT))
+    {
+        const SfxPoolItem* pLR = m_rExport.HasItem( RES_LR_SPACE );
+        tabsOffset = pLR ? static_cast<const SvxLRSpaceItem*>(pLR)->GetTextLeft() : 0;
+    }
+
     for (sal_uInt16 i = 0; i < nCount; i++ )
     {
         if( rTabStop[i].GetAdjustment() != SVX_TAB_ADJUST_DEFAULT )
-            impl_WriteTabElement( m_pSerializer, rTabStop[i], nCurrentLeft );
+            impl_WriteTabElement( m_pSerializer, rTabStop[i], tabsOffset );
         else
             GetExport().setDefaultTabStop( rTabStop[i].GetTabPos());
     }


More information about the Libreoffice-commits mailing list