diff options
author | Justin Luth <justin_luth@sil.org> | 2018-07-09 21:05:07 +0300 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-07-25 10:18:22 +0200 |
commit | 9fc9510ae3f46e5c1fd65303bac9f01ddc79cb5c (patch) | |
tree | 746f96c426facc7714276df00cea2ea370069730 /writerfilter | |
parent | 921f285c7ff713ad219d3e3385d7e7d12d33581e (diff) |
tdf#106174 writerfilter: bidi - prev adjust? prev bidi?
Four situations to handle:
1.) bidi same as previous setting: no adjust change
2.) no previous adjust: set appropriate default for this bidi
3.) previous adjust and bidi different from previous: swap adjusts
4.) previous adjust and no previous bidi: RTL swaps adjust
The previous method was pretty heavy-handed, especially when
clobbering the inherited ParaAdjust value. It essentially
only handled situation #2.
There are several commits that this one builds on or that
enhance it. Look in this bug 106174 and in bug 72560.
Change-Id: I07192ed93d50b07911cc8134a4ee57da87023d78
Reviewed-on: https://gerrit.libreoffice.org/57196
Tested-by: Jenkins
Reviewed-by: Justin Luth <justin_luth@sil.org>
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'writerfilter')
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper.cxx | 41 |
1 files changed, 30 insertions, 11 deletions
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx index c1e3141ed9f5..45ae707e3b46 100644 --- a/writerfilter/source/dmapper/DomainMapper.cxx +++ b/writerfilter/source/dmapper/DomainMapper.cxx @@ -1451,18 +1451,37 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const PropertyMapPtr& rContext ) break; case NS_ooxml::LN_CT_PPrBase_bidi: { - if (nIntValue != 0) - { - rContext->Insert(PROP_WRITING_MODE, uno::makeAny( sal_Int16(text::WritingMode2::RL_TB) )); - if (!IsRTFImport()) - rContext->Insert(PROP_PARA_ADJUST, uno::makeAny( style::ParagraphAdjust_RIGHT ), /*bOverwrite=*/false); - } - else - { - rContext->Insert(PROP_WRITING_MODE, uno::makeAny( sal_Int16(text::WritingMode2::LR_TB) )); - if (!IsRTFImport()) - rContext->Insert(PROP_PARA_ADJUST, uno::makeAny( style::ParagraphAdjust_LEFT ), /*bOverwrite=*/false); + // Four situations to handle: + // 1.) bidi same as previous setting: no adjust change + // 2.) no previous adjust: set appropriate default for this bidi + // 3.) previous adjust and bidi different from previous: swap adjusts + // 4.) previous adjust and no previous bidi: RTL swaps adjust + + sal_Int16 nParentBidi = -1; + m_pImpl->GetPropertyFromStyleSheet(PROP_WRITING_MODE) >>= nParentBidi; + // Paragraph justification reverses its meaning in an RTL context. + // 1. Only make adjustments if the BiDi changes. + if ( nParentBidi != nIntValue && !IsRTFImport() ) + { + style::ParagraphAdjust eAdjust = style::ParagraphAdjust(-1); + // 2. no adjust property exists yet + if ( !(m_pImpl->GetAnyProperty(PROP_PARA_ADJUST, rContext) >>= eAdjust) ) + { + // RTL defaults to right adjust + eAdjust = nIntValue ? style::ParagraphAdjust_RIGHT : style::ParagraphAdjust_LEFT; + rContext->Insert(PROP_PARA_ADJUST, uno::makeAny( eAdjust ), /*bOverwrite=*/false); + } + // 3,4. existing adjust: if RTL, then swap. If LTR, but previous was RTL, also swap. + else if ( nIntValue || nParentBidi == sal_Int16(text::WritingMode2::RL_TB) ) + { + if ( eAdjust == style::ParagraphAdjust_RIGHT ) + rContext->Insert(PROP_PARA_ADJUST, uno::makeAny( style::ParagraphAdjust_LEFT )); + else if ( eAdjust == style::ParagraphAdjust_LEFT ) + rContext->Insert(PROP_PARA_ADJUST, uno::makeAny( style::ParagraphAdjust_RIGHT )); + } } + sal_Int16 nWritingMode = nIntValue ? text::WritingMode2::RL_TB : text::WritingMode2::LR_TB; + rContext->Insert(PROP_WRITING_MODE, uno::makeAny( nWritingMode )); } break; |