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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Feb 12 08:06:03 UTC 2019


 include/svtools/rtfkeywd.hxx                              |    1 
 sw/qa/extras/ooxmlexport/data/para-adjust-distribute.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport13.cxx                |   21 ++++++++++++++
 sw/qa/extras/rtfexport/data/para-adjust-distribute.rtf    |    4 ++
 sw/qa/extras/rtfexport/rtfexport4.cxx                     |   21 ++++++++++++++
 sw/source/filter/ww8/docxattributeoutput.cxx              |    5 ++-
 sw/source/filter/ww8/rtfattributeoutput.cxx               |    5 ++-
 writerfilter/source/dmapper/DomainMapper.cxx              |    2 -
 writerfilter/source/rtftok/rtfdispatchflag.cxx            |    2 -
 9 files changed, 57 insertions(+), 4 deletions(-)

New commits:
commit 29a3d327900eb672b7630eb0b5ddea01a6a0c1a3
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Mon Feb 11 21:16:18 2019 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Tue Feb 12 09:05:37 2019 +0100

    DOCX, RTF filter: handle distributed para adjust
    
    Pointed out by lcov for the RTF import, but all of RTF/DOCX
    import/export was missing.
    
    DOC export is still missing.
    
    Change-Id: I9c48a08c3e951409f59dc1631a6ab39aa95f905d
    Reviewed-on: https://gerrit.libreoffice.org/67700
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>

diff --git a/include/svtools/rtfkeywd.hxx b/include/svtools/rtfkeywd.hxx
index ec6053f14434..8a4a3f6b4c7b 100644
--- a/include/svtools/rtfkeywd.hxx
+++ b/include/svtools/rtfkeywd.hxx
@@ -303,6 +303,7 @@
 #define OOO_STRING_SVTOOLS_RTF_PVPARA "\\pvpara"
 #define OOO_STRING_SVTOOLS_RTF_PVPG "\\pvpg"
 #define OOO_STRING_SVTOOLS_RTF_QC "\\qc"
+#define OOO_STRING_SVTOOLS_RTF_QD "\\qd"
 #define OOO_STRING_SVTOOLS_RTF_QJ "\\qj"
 #define OOO_STRING_SVTOOLS_RTF_QL "\\ql"
 #define OOO_STRING_SVTOOLS_RTF_QR "\\qr"
diff --git a/sw/qa/extras/ooxmlexport/data/para-adjust-distribute.docx b/sw/qa/extras/ooxmlexport/data/para-adjust-distribute.docx
new file mode 100644
index 000000000000..5389a75370e1
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/para-adjust-distribute.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
index a67ced7ed730..4d0d6fa70501 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
@@ -15,6 +15,7 @@
 #include <com/sun/star/text/XTextFrame.hpp>
 #include <com/sun/star/text/XTextFramesSupplier.hpp>
 #include <com/sun/star/drawing/XControlShape.hpp>
+#include <com/sun/star/style/ParagraphAdjust.hpp>
 
 #include <sfx2/docfile.hxx>
 #include <sfx2/docfilt.hxx>
@@ -97,6 +98,26 @@ DECLARE_OOXMLEXPORT_TEST(testTdf121867, "tdf121867.odt")
     CPPUNIT_ASSERT_EQUAL(SvxZoomType::PAGEWIDTH, pEditShell->GetViewOptions()->GetZoomType());
 }
 
+DECLARE_OOXMLEXPORT_TEST(testParaAdjustDistribute, "para-adjust-distribute.docx")
+{
+    // Without the accompanying fix in place, this test would have failed with
+    // 'Expected: 2; Actual  : 0', i.e. the first paragraph's ParaAdjust was
+    // left, not block.
+    CPPUNIT_ASSERT_EQUAL(
+        style::ParagraphAdjust_BLOCK,
+        static_cast<style::ParagraphAdjust>(getProperty<sal_Int16>(getParagraph(1), "ParaAdjust")));
+    CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_BLOCK,
+                         static_cast<style::ParagraphAdjust>(
+                             getProperty<sal_Int16>(getParagraph(1), "ParaLastLineAdjust")));
+
+    CPPUNIT_ASSERT_EQUAL(
+        style::ParagraphAdjust_BLOCK,
+        static_cast<style::ParagraphAdjust>(getProperty<sal_Int16>(getParagraph(2), "ParaAdjust")));
+    CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_LEFT,
+                         static_cast<style::ParagraphAdjust>(
+                             getProperty<sal_Int16>(getParagraph(2), "ParaLastLineAdjust")));
+}
+
 DECLARE_OOXMLEXPORT_TEST(testInputListExport, "tdf122186_input_list.odt")
 {
     // We need to make sure we don't export the text itself next to the input list field
diff --git a/sw/qa/extras/rtfexport/data/para-adjust-distribute.rtf b/sw/qa/extras/rtfexport/data/para-adjust-distribute.rtf
new file mode 100644
index 000000000000..3921ad9c9c7f
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/para-adjust-distribute.rtf
@@ -0,0 +1,4 @@
+{\rtf1
+\pard\plain\qd This is qd.\par
+\pard\plain\qj This is qj.\par
+}
diff --git a/sw/qa/extras/rtfexport/rtfexport4.cxx b/sw/qa/extras/rtfexport/rtfexport4.cxx
index 31a4de91676a..4fb9eb3daeb5 100644
--- a/sw/qa/extras/rtfexport/rtfexport4.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport4.cxx
@@ -31,6 +31,7 @@
 #include <com/sun/star/text/RubyPosition.hpp>
 #include <com/sun/star/text/XTextColumns.hpp>
 #include <com/sun/star/text/HoriOrientation.hpp>
+#include <com/sun/star/style/ParagraphAdjust.hpp>
 
 /**
   Split these tests into their own file because they are really really slow
@@ -99,6 +100,26 @@ DECLARE_RTFEXPORT_TEST(testCjklist31, "cjklist31.rtf")
     CPPUNIT_ASSERT_EQUAL(style::NumberingType::DI_ZI_ZH, numFormat);
 }
 
+DECLARE_RTFEXPORT_TEST(testParaAdjustDistribute, "para-adjust-distribute.rtf")
+{
+    // Without the accompanying fix in place, this test would have failed with
+    // 'Expected: 2; Actual  : 0', i.e. the first paragraph's ParaAdjust was
+    // left, not block.
+    CPPUNIT_ASSERT_EQUAL(
+        style::ParagraphAdjust_BLOCK,
+        static_cast<style::ParagraphAdjust>(getProperty<sal_Int16>(getParagraph(1), "ParaAdjust")));
+    CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_BLOCK,
+                         static_cast<style::ParagraphAdjust>(
+                             getProperty<sal_Int16>(getParagraph(1), "ParaLastLineAdjust")));
+
+    CPPUNIT_ASSERT_EQUAL(
+        style::ParagraphAdjust_BLOCK,
+        static_cast<style::ParagraphAdjust>(getProperty<sal_Int16>(getParagraph(2), "ParaAdjust")));
+    CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_LEFT,
+                         static_cast<style::ParagraphAdjust>(
+                             getProperty<sal_Int16>(getParagraph(2), "ParaLastLineAdjust")));
+}
+
 DECLARE_RTFEXPORT_TEST(testCjklist34, "cjklist34.rtf")
 {
     sal_Int16 numFormat = getNumberingTypeOfParagraph(1);
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 2b5bc45528b8..4fbfef4aa374 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -7823,7 +7823,10 @@ void DocxAttributeOutput::ParaAdjust( const SvxAdjustItem& rAdjust )
             break;
         case SvxAdjust::BlockLine:
         case SvxAdjust::Block:
-            pAdjustString = "both";
+            if (rAdjust.GetLastBlock() == SvxAdjust::Block)
+                pAdjustString = "distribute";
+            else
+                pAdjustString = "both";
             break;
         case SvxAdjust::Center:
             pAdjustString = "center";
diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx
index 232c9fa969fb..0b169f9c5336 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.cxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.cxx
@@ -2754,7 +2754,10 @@ void RtfAttributeOutput::ParaAdjust(const SvxAdjustItem& rAdjust)
             break;
         case SvxAdjust::BlockLine:
         case SvxAdjust::Block:
-            m_aStyles.append(OOO_STRING_SVTOOLS_RTF_QJ);
+            if (rAdjust.GetLastBlock() == SvxAdjust::Block)
+                m_aStyles.append(OOO_STRING_SVTOOLS_RTF_QD);
+            else
+                m_aStyles.append(OOO_STRING_SVTOOLS_RTF_QJ);
             break;
         case SvxAdjust::Center:
             m_aStyles.append(OOO_STRING_SVTOOLS_RTF_QC);
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 6a1b4e7dbc99..8a3b0d10cfdd 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -3541,7 +3541,7 @@ void DomainMapper::handleParaJustification(const sal_Int32 nIntValue, const ::to
         nAdjust = bExchangeLeftRight ? style::ParagraphAdjust_LEFT : style::ParagraphAdjust_RIGHT;
         aStringValue = "right";
         break;
-    case 4:
+    case NS_ooxml::LN_Value_ST_Jc_distribute:
         nLastLineAdjust = style::ParagraphAdjust_BLOCK;
         [[fallthrough]];
     case NS_ooxml::LN_Value_ST_Jc_both:
diff --git a/writerfilter/source/rtftok/rtfdispatchflag.cxx b/writerfilter/source/rtftok/rtfdispatchflag.cxx
index a69d044c119c..ea57b385aa44 100644
--- a/writerfilter/source/rtftok/rtfdispatchflag.cxx
+++ b/writerfilter/source/rtftok/rtfdispatchflag.cxx
@@ -73,7 +73,7 @@ RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
             nParam = NS_ooxml::LN_Value_ST_Jc_right;
             break;
         case RTF_QD:
-            nParam = NS_ooxml::LN_Value_ST_Jc_both;
+            nParam = NS_ooxml::LN_Value_ST_Jc_distribute;
             break;
         default:
             break;


More information about the Libreoffice-commits mailing list