summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFaisal M. Al-Otaibi <fmalotaibi@kacst.edu.sa>2013-10-07 10:26:30 +0300
committerFaisal M. Al-Otaibi <fmalotaibi@kacst.edu.sa>2013-10-07 11:04:32 +0300
commitaa52753785154f0e95fed559f613f5eae9105dcf (patch)
treed4f3835368a183b87c9deb49c73cdbdbdcf83b90
parentbc43c1ca942c4c111aa7f45b268e13ab03c7f613 (diff)
DOCX:fdo#43093 fix wrong direction and alignment for RTL
Change-Id: If362d80a86a7493f2d43e6d661b94fc03942711f
-rw-r--r--sw/qa/extras/ooxmlimport/data/fdo43093.docxbin0 -> 12959 bytes
-rw-r--r--sw/qa/extras/ooxmlimport/ooxmlimport.cxx45
-rw-r--r--writerfilter/inc/dmapper/DomainMapper.hxx1
-rw-r--r--writerfilter/source/dmapper/DomainMapper.cxx17
-rw-r--r--writerfilter/source/ooxml/OOXMLFastContextHandler.cxx14
5 files changed, 57 insertions, 20 deletions
diff --git a/sw/qa/extras/ooxmlimport/data/fdo43093.docx b/sw/qa/extras/ooxmlimport/data/fdo43093.docx
new file mode 100644
index 000000000000..3e5a910e2003
--- /dev/null
+++ b/sw/qa/extras/ooxmlimport/data/fdo43093.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index b1c45838d98f..22395409c3e8 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 8dc82feb2828..a879115269c1 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 1dfb58d4dc9d..b65c7a7f1da8 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 e3962f526edd..206c885664f9 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);
}
}