summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFaisal M. Al-Otaibi <fmalotaibi@kacst.edu.sa>2013-12-12 08:20:00 +0300
committerFaisal M. Al-Otaibi <fmalotaibi@kacst.edu.sa>2013-12-15 07:59:58 +0300
commit66e68fe28a7bfb37d4fdeee9bed1d9a0ff840935 (patch)
tree97b1f3dcb187c9c851cda205c043f799dacc9356
parentd663228bd348c844f38914c9e2167ef01fadf3b3 (diff)
DOCX: fdo#72560 better solution for exchange alignment for RTL
Change-Id: I39462fc722a58b32e8829a9f2005a411871f255d
-rw-r--r--sw/qa/extras/ooxmlimport/data/fdo72560.docxbin0 -> 15144 bytes
-rw-r--r--sw/qa/extras/ooxmlimport/ooxmlimport.cxx14
-rw-r--r--writerfilter/inc/dmapper/DomainMapper.hxx1
-rw-r--r--writerfilter/source/dmapper/DomainMapper.cxx25
4 files changed, 32 insertions, 8 deletions
diff --git a/sw/qa/extras/ooxmlimport/data/fdo72560.docx b/sw/qa/extras/ooxmlimport/data/fdo72560.docx
new file mode 100644
index 000000000000..b21535bfd453
--- /dev/null
+++ b/sw/qa/extras/ooxmlimport/data/fdo72560.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index d957b983ba67..815313188e15 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 d6b5d379517a..70c5b512ca58 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 06ea11cf4834..e60ffbcefb17 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 );