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 b0db93d00e1dd208baa96eb3e10df12950cdcb49 Author: Faisal M. Al-Otaibi <fmalota...@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 5da974f..db722f6 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -1638,6 +1638,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 9775bac..4a168d9 100644 --- a/writerfilter/inc/dmapper/DomainMapper.hxx +++ b/writerfilter/inc/dmapper/DomainMapper.hxx @@ -165,7 +165,6 @@ private: sal_Unicode getFillCharFromValue(const sal_Int32 nIntValue); sal_Int32 mnBackgroundColor; bool mbIsHighlightSet; - bool mbIsBIDI; bool mbIsSplitPara; boost::scoped_ptr< GraphicZOrderHelper > zOrderHelper; }; diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx index 2fcd4fb..26dfa11 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), mbIsSplitPara(false) + mnBackgroundColor(0), mbIsHighlightSet(false), mbIsSplitPara(false) { // #i24363# tab stops relative to indent m_pImpl->SetDocumentSettingsProperty( @@ -1597,7 +1597,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); @@ -1608,7 +1608,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; } @@ -1638,7 +1651,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 @@ -1737,7 +1750,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, @@ -2033,7 +2046,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 )); } @@ -3239,7 +3251,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 ); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits