[Libreoffice-commits] core.git: Branch 'libreoffice-4-2' - sw/qa writerfilter/inc writerfilter/source

Faisal M. Al-Otaibi fmalotaibi at kacst.edu.sa
Sat Dec 14 21:04:19 PST 2013


 sw/qa/extras/ooxmlimport/data/fdo72560.docx  |binary
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx     |   14 ++++++++++++++
 writerfilter/inc/dmapper/DomainMapper.hxx    |    1 -
 writerfilter/source/dmapper/DomainMapper.cxx |   25 ++++++++++++++++++-------
 4 files changed, 32 insertions(+), 8 deletions(-)

New commits:
commit 66e68fe28a7bfb37d4fdeee9bed1d9a0ff840935
Author: Faisal M. Al-Otaibi <fmalotaibi at kacst.edu.sa>
Date:   Thu Dec 12 08:20:00 2013 +0300

    DOCX: fdo#72560 better solution for exchange alignment for RTL
    
    Change-Id: I39462fc722a58b32e8829a9f2005a411871f255d

diff --git a/sw/qa/extras/ooxmlimport/data/fdo72560.docx b/sw/qa/extras/ooxmlimport/data/fdo72560.docx
new file mode 100644
index 0000000..b21535b
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/fdo72560.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index d957b98..8153131 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -1545,6 +1545,20 @@ DECLARE_OOXMLIMPORT_TEST(testLOCrash,"file_crash.docx")
     //The problem was libreoffice crash while opening the file.
     getParagraph(1,"Contents");
 }
+
+DECLARE_OOXMLIMPORT_TEST(testFdo72560, "fdo72560.docx")
+{
+    // The problem was libreoffice confuse when there RTL default style for paragraph
+    uno::Reference<uno::XInterface> xParaLeftRTL(getParagraph( 1, "RTL LEFT"));
+    uno::Reference<uno::XInterface> xParaRightLTR(getParagraph( 2, "LTR RIGHT"));
+
+    // this will test the text direction and alignment for paragraphs
+    CPPUNIT_ASSERT_EQUAL(text::WritingMode2::RL_TB, getProperty<sal_Int16>( xParaLeftRTL, "WritingMode" ));
+    CPPUNIT_ASSERT_EQUAL( sal_Int32 (style::ParagraphAdjust_LEFT), getProperty< sal_Int32 >( xParaLeftRTL, "ParaAdjust" ));
+
+    CPPUNIT_ASSERT_EQUAL(text::WritingMode2::LR_TB, getProperty<sal_Int16>( xParaRightLTR, "WritingMode" ));
+    CPPUNIT_ASSERT_EQUAL( sal_Int32 (style::ParagraphAdjust_RIGHT), getProperty< sal_Int32 >( xParaRightLTR, "ParaAdjust" ));
+}
 #endif
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/inc/dmapper/DomainMapper.hxx b/writerfilter/inc/dmapper/DomainMapper.hxx
index d6b5d37..70c5b51 100644
--- a/writerfilter/inc/dmapper/DomainMapper.hxx
+++ b/writerfilter/inc/dmapper/DomainMapper.hxx
@@ -163,7 +163,6 @@ 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 06ea11c..e60ffbc 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -97,7 +97,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), mbIsBIDI(false)
+    mnBackgroundColor(0), mbIsHighlightSet(false)
 {
     // #i24363# tab stops relative to indent
     m_pImpl->SetDocumentSettingsProperty(
@@ -1580,7 +1580,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, bool mbIsBIDI)
+static bool ExchangeLeftRight( const PropertyMapPtr rContext, DomainMapper_Impl* m_pImpl )
 {
     bool bExchangeLeftRight = false;
     PropertyMap::const_iterator aPropParaIte = rContext->find(PROP_WRITING_MODE);
@@ -1591,7 +1591,20 @@ sal_Int32 lcl_getCurrentNumberingProperty(uno::Reference<container::XIndexAccess
             bExchangeLeftRight = true;
     }
     else
-        return mbIsBIDI;
+    {
+        // check if there RTL <bidi> in default style for the paragraph
+        StyleSheetEntryPtr pTable = m_pImpl->GetStyleSheetTable()->FindDefaultParaStyle();
+        if ( pTable )
+        {
+            PropertyMap::const_iterator aPropStyle = pTable->pProperties->find(PROP_WRITING_MODE);
+            if( aPropStyle != pTable->pProperties->end())
+            {
+                sal_Int32 aDirect;
+                if( (aPropStyle->second.getValue() >>= aDirect) && aDirect == text::WritingMode2::RL_TB )
+                    bExchangeLeftRight = true;
+            }
+        }
+    }
     return bExchangeLeftRight;
 }
 
@@ -1621,7 +1634,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, mbIsBIDI ));
+        handleParaJustification(nIntValue, rContext, ExchangeLeftRight( rContext, m_pImpl ));
         break;
     case NS_sprm::LN_PFSideBySide:
         break;  // sprmPFSideBySide
@@ -1720,7 +1733,7 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext, SprmType
     case 17:
     case NS_sprm::LN_PDxaLeft:   // sprmPDxaLeft
     {
-        bool bExchangeLeftRight = ExchangeLeftRight( rContext, mbIsBIDI );
+        bool bExchangeLeftRight = ExchangeLeftRight( rContext, m_pImpl );
         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,
@@ -2016,7 +2029,6 @@ 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 ));
             }
@@ -3210,7 +3222,6 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext, SprmType
     break;
     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 );


More information about the Libreoffice-commits mailing list