diff options
author | Justin Luth <justin.luth@collabora.com> | 2018-07-11 22:37:00 +0300 |
---|---|---|
committer | Justin Luth <justin_luth@sil.org> | 2018-08-22 06:14:28 +0200 |
commit | 85818da3307a28b2d9c6fa5c1c97ca7833dfe24c (patch) | |
tree | 7f1fb56846401ded0c1fb06161fbc4005331456f /sw/source | |
parent | cbce9044b075f22a936c8a15bacf3cb57130c984 (diff) |
tdf#106174 ww8import: bidi - prev adjust? prev bidi?
Read_RTLJustify knows that it needs to swap in BiDi situations,
but sometimes it is read before BiDi status is known.
So Read_ParaBiDi needs to watch for this and do the swap afterwards.
Three 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. Unknown bidi treated like prev=LTR - one difference from DOCX)
Unit tests cover both situations - where BiDi is already known,
and where it is unknown.
Change-Id: I0b4e2383a4909fe79317dd9772d0be63f749da68
Reviewed-on: https://gerrit.libreoffice.org/57294
Tested-by: Jenkins
Reviewed-by: Justin Luth <justin_luth@sil.org>
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/filter/ww8/ww8par6.cxx | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx index cfdef0182114..cc43a90d4077 100644 --- a/sw/source/filter/ww8/ww8par6.cxx +++ b/sw/source/filter/ww8/ww8par6.cxx @@ -318,6 +318,33 @@ void SwWW8ImplReader::Read_ParaBiDi(sal_uInt16, const sal_uInt8* pData, short nL { SvxFrameDirection eDir = *pData ? SvxFrameDirection::Horizontal_RL_TB : SvxFrameDirection::Horizontal_LR_TB; + + // Previous adjust or bidi values require changing paraAdjust. + // Only change if ParaBiDi doesn't match previous setting. + const bool bParentRTL = IsRightToLeft(); + if ( (eDir == SvxFrameDirection::Horizontal_RL_TB && !bParentRTL) || + (eDir == SvxFrameDirection::Horizontal_LR_TB && bParentRTL) ) + { + const SvxAdjustItem* pItem = static_cast<const SvxAdjustItem*>(GetFormatAttr(RES_PARATR_ADJUST)); + if ( !pItem ) + { + // no previous adjust: set appropriate default + if ( eDir == SvxFrameDirection::Horizontal_LR_TB ) + NewAttr( SvxAdjustItem( SvxAdjust::Left, RES_PARATR_ADJUST ) ); + else + NewAttr( SvxAdjustItem( SvxAdjust::Right, RES_PARATR_ADJUST ) ); + } + else + { + // previous adjust and bidi has changed: swap Left/Right + const SvxAdjust eJustify = pItem->GetAdjust(); + if ( eJustify == SvxAdjust::Left ) + NewAttr( SvxAdjustItem( SvxAdjust::Right, RES_PARATR_ADJUST ) ); + else if ( eJustify == SvxAdjust::Right ) + NewAttr( SvxAdjustItem( SvxAdjust::Left, RES_PARATR_ADJUST ) ); + } + } + NewAttr(SvxFrameDirectionItem(eDir, RES_FRAMEDIR)); } } |