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

Faisal M. Al-Otaibi fmalotaibi at kacst.edu.sa
Mon Oct 7 01:05:34 PDT 2013


 sw/qa/extras/ooxmlimport/data/fdo43093.docx           |binary
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx              |   45 ++++++++++++++++--
 writerfilter/inc/dmapper/DomainMapper.hxx             |    1 
 writerfilter/source/dmapper/DomainMapper.cxx          |   17 +++++-
 writerfilter/source/ooxml/OOXMLFastContextHandler.cxx |   14 -----
 5 files changed, 57 insertions(+), 20 deletions(-)

New commits:
commit aa52753785154f0e95fed559f613f5eae9105dcf
Author: Faisal M. Al-Otaibi <fmalotaibi at kacst.edu.sa>
Date:   Mon Oct 7 10:26:30 2013 +0300

    DOCX:fdo#43093 fix wrong direction and alignment for RTL
    
    Change-Id: If362d80a86a7493f2d43e6d661b94fc03942711f

diff --git a/sw/qa/extras/ooxmlimport/data/fdo43093.docx b/sw/qa/extras/ooxmlimport/data/fdo43093.docx
new file mode 100644
index 0000000..3e5a910
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/fdo43093.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index b1c4583..2239540 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -138,6 +138,7 @@ public:
     void testFdo69636();
     void testChartProp();
     void testBnc779620();
+    void testFdo43093();
 
     CPPUNIT_TEST_SUITE(Test);
 #if !defined(MACOSX) && !defined(WNT)
@@ -240,6 +241,7 @@ void Test::run()
         {"fdo69636.docx", &Test::testFdo69636},
         {"chart-prop.docx", &Test::testChartProp},
         {"bnc779620.docx", &Test::testBnc779620},
+        {"fdo43093.docx", &Test::testFdo43093},
     };
     header();
     for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
@@ -1356,9 +1358,12 @@ void Test::testN779630()
 
 void Test::testIndentation()
 {
-    uno::Reference<beans::XPropertySet> xPropertySet(getStyles("ParagraphStyles")->getByName("Standard"), uno::UNO_QUERY);
-    // This was RL_TB (e.g. right-to-left).
-    CPPUNIT_ASSERT_EQUAL(text::WritingMode2::LR_TB, getProperty<sal_Int16>(xPropertySet, "WritingMode"));
+    uno::Reference<uno::XInterface> xParaLTRTitle(getParagraph( 1, "Title aligned"));
+    uno::Reference<uno::XInterface> xParaLTRNormal(getParagraph( 2, ""));
+
+    // this will test the text direction for paragraphs
+    CPPUNIT_ASSERT_EQUAL(text::WritingMode2::LR_TB, getProperty<sal_Int16>( xParaLTRTitle, "WritingMode" ));
+    CPPUNIT_ASSERT_EQUAL(text::WritingMode2::LR_TB, getProperty<sal_Int16>( xParaLTRNormal, "WritingMode" ));
 }
 
 void Test::testPageBorderShadow()
@@ -1594,6 +1599,40 @@ void Test::testBnc779620()
     CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount());
 }
 
+void Test::testFdo43093()
+{
+    // The problem was that the direction and alignment are not correct for RTL paragraphs.
+    uno::Reference<uno::XInterface> xParaRtlRight(getParagraph( 1, "Right and RTL in M$"));
+    sal_Int32 nRtlRight = getProperty< sal_Int32 >( xParaRtlRight, "ParaAdjust" );
+    sal_Int16 nRRDir  = getProperty< sal_Int32 >( xParaRtlRight, "WritingMode" );
+
+    uno::Reference<uno::XInterface> xParaRtlLeft(getParagraph( 2, "Left and RTL in M$"));
+    sal_Int32 nRtlLeft = getProperty< sal_Int32 >( xParaRtlLeft, "ParaAdjust" );
+    sal_Int16 nRLDir  = getProperty< sal_Int32 >( xParaRtlLeft, "WritingMode" );
+
+    uno::Reference<uno::XInterface> xParaLtrRight(getParagraph( 3, "Right and LTR in M$"));
+    sal_Int32 nLtrRight = getProperty< sal_Int32 >( xParaLtrRight, "ParaAdjust" );
+    sal_Int16 nLRDir  = getProperty< sal_Int32 >( xParaLtrRight, "WritingMode" );
+
+    uno::Reference<uno::XInterface> xParaLtrLeft(getParagraph( 4, "Left and LTR in M$"));
+    sal_Int32 nLtrLeft = getProperty< sal_Int32 >( xParaLtrLeft, "ParaAdjust" );
+    sal_Int16 nLLDir  = getProperty< sal_Int32 >( xParaLtrLeft, "WritingMode" );
+
+    // this will test the both the text direction and alignment for each paragraph
+    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), nRtlLeft);
+    CPPUNIT_ASSERT_EQUAL(text::WritingMode2::RL_TB, nRLDir);
+
+    CPPUNIT_ASSERT_EQUAL( sal_Int32 (style::ParagraphAdjust_RIGHT), nLtrRight);
+    CPPUNIT_ASSERT_EQUAL(text::WritingMode2::LR_TB, nLRDir);
+
+    CPPUNIT_ASSERT_EQUAL( sal_Int32 (style::ParagraphAdjust_LEFT), nLtrLeft);
+    CPPUNIT_ASSERT_EQUAL(text::WritingMode2::LR_TB, nLLDir);
+}
+
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/inc/dmapper/DomainMapper.hxx b/writerfilter/inc/dmapper/DomainMapper.hxx
index 8dc82fe..a879115 100644
--- a/writerfilter/inc/dmapper/DomainMapper.hxx
+++ b/writerfilter/inc/dmapper/DomainMapper.hxx
@@ -158,6 +158,7 @@ private:
     sal_Unicode getFillCharFromValue(const sal_Int32 nIntValue);
     sal_Int32 mnBackgroundColor;
     bool mbIsHighlightSet;
+    bool mbIsBIDI;
     boost::scoped_ptr< GraphicZOrderHelper > zOrderHelper;
 };
 
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 1dfb58d..b65c7a7 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -95,7 +95,7 @@ LoggedProperties(dmapper_logger, "DomainMapper"),
 LoggedTable(dmapper_logger, "DomainMapper"),
 LoggedStream(dmapper_logger, "DomainMapper"),
     m_pImpl( new DomainMapper_Impl( *this, xContext, xModel, eDocumentType, xInsertTextRange, bIsNewDoc )),
-    mnBackgroundColor(0), mbIsHighlightSet(false)
+    mnBackgroundColor(0), mbIsHighlightSet(false), mbIsBIDI(false)
 {
     // #i24363# tab stops relative to indent
     m_pImpl->SetDocumentSettingsProperty(
@@ -1527,7 +1527,7 @@ sal_Int32 lcl_getCurrentNumberingProperty(uno::Reference<container::XIndexAccess
 }
 
 // In rtl-paragraphs the meaning of left/right are to be exchanged
-static bool ExchangeLeftRight( const PropertyMapPtr rContext )
+    static bool ExchangeLeftRight( const PropertyMapPtr rContext, bool mbIsBIDI)
 {
     bool bExchangeLeftRight = false;
     PropertyMap::const_iterator aPropParaIte = rContext->find( PropertyDefinition( PROP_WRITING_MODE ));
@@ -1537,6 +1537,8 @@ static bool ExchangeLeftRight( const PropertyMapPtr rContext )
         if( (aPropParaIte->second >>= aAdjust) && aAdjust == text::WritingMode2::RL_TB )
             bExchangeLeftRight = true;
     }
+    else
+        return mbIsBIDI;
     return bExchangeLeftRight;
 }
 
@@ -1566,7 +1568,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, ExchangeLeftRight( rContext ));
+        handleParaJustification(nIntValue, rContext, ExchangeLeftRight( rContext, mbIsBIDI ));
         break;
     case NS_sprm::LN_PFSideBySide:
         break;  // sprmPFSideBySide
@@ -1662,7 +1664,7 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext, SprmType
     case 17:
     case NS_sprm::LN_PDxaLeft:   // sprmPDxaLeft
     {
-        bool bExchangeLeftRight = ExchangeLeftRight( rContext );
+        bool bExchangeLeftRight = ExchangeLeftRight( rContext, mbIsBIDI );
         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,
@@ -1958,9 +1960,15 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext, SprmType
         {
             if (nIntValue != 0)
             {
+                mbIsBIDI = true;
                 rContext->Insert(PROP_WRITING_MODE, uno::makeAny( text::WritingMode2::RL_TB ));
                 rContext->Insert(PROP_PARA_ADJUST, uno::makeAny( style::ParagraphAdjust_RIGHT ));
             }
+            else
+            {
+                rContext->Insert(PROP_WRITING_MODE, uno::makeAny( text::WritingMode2::LR_TB ));
+                rContext->Insert(PROP_PARA_ADJUST, uno::makeAny( style::ParagraphAdjust_LEFT ));
+            }
         }
 
         break;  // sprmPFBiDi
@@ -3119,6 +3127,7 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext, SprmType
 
     case NS_ooxml::LN_CT_PPrBase_pStyle:
     {
+        mbIsBIDI = false;
         m_pImpl->SetCurrentParaStyleId( sStringValue );
         StyleSheetTablePtr pStyleTable = m_pImpl->GetStyleSheetTable();
         const OUString sConvertedStyleName = pStyleTable->ConvertStyleName( sStringValue, true );
diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
index e3962f5..206c885 100644
--- a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
+++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
@@ -1618,19 +1618,7 @@ void OOXMLFastContextHandlerValue::setDefaultBooleanValue()
 
     if (mpValue.get() == NULL)
     {
-        // Value should not always be 'true'
-        //OOXMLValue::Pointer_t pValue(new OOXMLBooleanValue(true));
-        bool bSet = true;
-
-        // Paragraph properties are not always 'true' by default
-        // For example - RTL layout of paragraph is by default 'false' (look in this link for 'sprmPFBiDi')
-        // http://msdn.microsoft.com/en-us/library/dd923496%28v=office.12%29.aspx
-        if (getId() == NS_sprm::LN_PFBiDi)
-        {
-                bSet = false;
-        }
-
-        OOXMLValue::Pointer_t pValue(new OOXMLBooleanValue(bSet));
+        OOXMLValue::Pointer_t pValue(new OOXMLBooleanValue(true));
         setValue(pValue);
     }
 }


More information about the Libreoffice-commits mailing list