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

Faisal M. Al-Otaibi fmalotaibi at kacst.edu.sa
Sun Jun 16 03:27:45 PDT 2013


 sw/qa/extras/ooxmlexport/data/fdo43093.docx  |binary
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx     |   37 +++++++++++++++++++++++++++
 sw/source/filter/ww8/docxattributeoutput.cxx |   12 ++++++--
 writerfilter/source/dmapper/DomainMapper.cxx |   23 +++++++++++++---
 4 files changed, 65 insertions(+), 7 deletions(-)

New commits:
commit e9911f12d1e124d1910ac2310c224e66ab365ed4
Author: Faisal M. Al-Otaibi <fmalotaibi at kacst.edu.sa>
Date:   Sat Jun 15 12:55:14 2013 +0200

    docx: fdo#43093 fdo#44029 fix the alignment when the paragraph are RTL
    
    this will fix the alignment for RTL paragraph when import/export MS docx file.
    the alignment should be exchange when the paragraph are RTL.
    it will also fix text direction export for RTL paragraph.
    
    Change-Id: I5fe55205677d6e12142e398570cba78094705692

diff --git a/sw/qa/extras/ooxmlexport/data/fdo43093.docx b/sw/qa/extras/ooxmlexport/data/fdo43093.docx
new file mode 100644
index 0000000..9d5de58
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/fdo43093.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index d6812f0..1cfc0ae 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -27,6 +27,7 @@
 #include <com/sun/star/awt/FontWeight.hpp>
 #include <com/sun/star/awt/FontUnderline.hpp>
 #include <com/sun/star/awt/FontSlant.hpp>
+#include <com/sun/star/text/WritingMode2.hpp>
 
 #include <unotools/tempfile.hxx>
 #include <unotools/ucbstreamhelper.hxx>
@@ -79,6 +80,7 @@ public:
     void testFdo65655();
     void testFDO63053();
     void testWatermark();
+    void testFdo43093();
 
     CPPUNIT_TEST_SUITE(Test);
 #if !defined(MACOSX) && !defined(WNT)
@@ -133,6 +135,7 @@ void Test::run()
         {"fdo65655.docx", &Test::testFdo65655},
         {"fdo63053.docx" , &Test::testFDO63053},
         {"watermark.docx", &Test::testWatermark},
+        {"fdo43093.docx", &Test::testFdo43093},
     };
     // Don't test the first import of these, for some reason those tests fail
     const char* aBlacklist[] = {
@@ -771,6 +774,40 @@ void Test::testWatermark()
     CPPUNIT_ASSERT_EQUAL(drawing::LineStyle_NONE, getProperty<drawing::LineStyle>(xShape, "LineStyle"));
 }
 
+void Test::testFdo43093()
+{
+    // The problem was that the alignment are not exchange when the paragraph are RTL.
+    uno::Reference<uno::XInterface> xParaRtlLeft(getParagraph( 1, "RTL Left"));
+    sal_Int32 nRtlLeft = getProperty< sal_Int32 >( xParaRtlLeft, "ParaAdjust" );
+    // test the text Direction value for the pragraph
+    sal_Int16 nRLDir  = getProperty< sal_Int32 >( xParaRtlLeft, "WritingMode" );
+
+    uno::Reference<uno::XInterface> xParaRtlRight(getParagraph( 3, "RTL Right"));
+    sal_Int32 nRtlRight = getProperty< sal_Int32 >( xParaRtlRight, "ParaAdjust" );
+    sal_Int16 nRRDir  = getProperty< sal_Int32 >( xParaRtlRight, "WritingMode" );
+
+    uno::Reference<uno::XInterface> xParaLtrLeft(getParagraph( 5, "LTR Left"));
+    sal_Int32 nLtrLeft = getProperty< sal_Int32 >( xParaLtrLeft, "ParaAdjust" );
+    sal_Int16 nLLDir  = getProperty< sal_Int32 >( xParaLtrLeft, "WritingMode" );
+
+    uno::Reference<uno::XInterface> xParaLtrRight(getParagraph( 7, "LTR Right"));
+    sal_Int32 nLtrRight = getProperty< sal_Int32 >( xParaLtrRight, "ParaAdjust" );
+    sal_Int16 nLRDir  = getProperty< sal_Int32 >( xParaLtrRight, "WritingMode" );
+
+    // this will test the both the text direction and alignment for each paragraph
+    CPPUNIT_ASSERT_EQUAL( sal_Int32 (style::ParagraphAdjust_LEFT), nRtlLeft);
+    CPPUNIT_ASSERT_EQUAL(text::WritingMode2::RL_TB, nRLDir);
+
+    CPPUNIT_ASSERT_EQUAL( sal_Int32 (style::ParagraphAdjust_RIGHT), nRtlRight);
+    CPPUNIT_ASSERT_EQUAL(text::WritingMode2::RL_TB, nRRDir);
+
+    CPPUNIT_ASSERT_EQUAL( sal_Int32 (style::ParagraphAdjust_LEFT), nLtrLeft);
+    CPPUNIT_ASSERT_EQUAL(text::WritingMode2::LR_TB, nLLDir);
+
+    CPPUNIT_ASSERT_EQUAL( sal_Int32 (style::ParagraphAdjust_RIGHT), nLtrRight);
+    CPPUNIT_ASSERT_EQUAL(text::WritingMode2::LR_TB, nLRDir);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index d2049fc..254b0bf 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -4261,7 +4261,10 @@ void DocxAttributeOutput::ParaAdjust( const SvxAdjustItem& rAdjust )
     {
         case SVX_ADJUST_LEFT:
             if ( bEcma )
-                pAdjustString = "left";
+                if ( bRtl )
+                    pAdjustString = "right";
+                else
+                    pAdjustString = "left";
             else if ( bRtl )
                 pAdjustString = "end";
             else
@@ -4269,7 +4272,10 @@ void DocxAttributeOutput::ParaAdjust( const SvxAdjustItem& rAdjust )
             break;
         case SVX_ADJUST_RIGHT:
             if ( bEcma )
-                pAdjustString = "right";
+                if ( bRtl )
+                    pAdjustString = "left";
+                else
+                    pAdjustString = "right";
             else if ( bRtl )
                 pAdjustString = "start";
             else
@@ -5001,7 +5007,7 @@ void DocxAttributeOutput::FormatFrameDirection( const SvxFrameDirectionItem& rDi
     else if ( !m_rExport.bOutFlyFrmAttrs )
     {
         if ( bBiDi )
-            m_pSerializer->singleElementNS( XML_w, XML_bidi, FSEND );
+            m_pSerializer->singleElementNS( XML_w, XML_bidi, FSNS( XML_w, XML_val ), "1", FSEND );
     }
 }
 
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 8b7f7e8..0d14f8d 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -1505,6 +1505,21 @@ sal_Int32 lcl_getCurrentNumberingProperty(uno::Reference<container::XIndexAccess
     return nRet;
 }
 
+// In rtl-paragraphs the meaning of left/right are to be exchanged
+static bool ExchangeLeftRight( const PropertyMapPtr rContext )
+{
+    bool bExchangeLeftRight = false;
+    PropertyMap::const_iterator aPropParaIte = rContext->find( PropertyDefinition( PROP_WRITING_MODE, false ));
+    if( aPropParaIte != rContext->end())
+    {
+        sal_Int32 aAdjust ;
+        aPropParaIte->second >>= aAdjust;
+        if( aAdjust == text::WritingMode2::RL_TB )
+            bExchangeLeftRight = true;
+    }
+    return bExchangeLeftRight;
+}
+
 void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext, SprmType eSprmType )
 {
     OSL_ENSURE(rContext.get(), "PropertyMap has to be valid!");
@@ -1514,9 +1529,6 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext, SprmType
     sal_uInt32 nSprmId = rSprm.getId();
     //needed for page properties
     SectionPropertyMap * pSectionContext = m_pImpl->GetSectionContext();
-
-    //TODO: In rtl-paragraphs the meaning of left/right are to be exchanged
-    bool bExchangeLeftRight = false;
     Value::Pointer_t pValue = rSprm.getValue();
     sal_Int32 nIntValue = pValue->getInt();
     OUString sStringValue = pValue->getString();
@@ -1534,7 +1546,7 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext, SprmType
         break;  // sprmPIncLvl
     case NS_sprm::LN_PJcExtra: // sprmPJc Asian (undocumented)
     case NS_sprm::LN_PJc: // sprmPJc
-        handleParaJustification(nIntValue, rContext, bExchangeLeftRight);
+        handleParaJustification(nIntValue, rContext, ExchangeLeftRight( rContext ));
         break;
     case NS_sprm::LN_PFSideBySide:
         break;  // sprmPFSideBySide
@@ -1629,6 +1641,8 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext, SprmType
     case NS_sprm::LN_PDxaRight:   // sprmPDxaRight - right margin
     case 17:
     case NS_sprm::LN_PDxaLeft:   // sprmPDxaLeft
+    {
+        bool bExchangeLeftRight = ExchangeLeftRight( rContext );
         if( NS_sprm::LN_PDxaLeft == nSprmId || 0x17 == nSprmId|| (bExchangeLeftRight && nSprmId == 0x845d) || ( !bExchangeLeftRight && nSprmId == 0x845e))
             rContext->Insert(
                              eSprmType == SPRM_DEFAULT ? PROP_PARA_LEFT_MARGIN : PROP_LEFT_MARGIN,
@@ -1638,6 +1652,7 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext, SprmType
             rContext->Insert(
                              PROP_PARA_RIGHT_MARGIN, true,
                              uno::makeAny( ConversionHelper::convertTwipToMM100(nIntValue ) ));
+    }
         //TODO: what happens to the right margins in numberings?
         break;
     case 18: // sprmPNest


More information about the Libreoffice-commits mailing list