summaryrefslogtreecommitdiff
path: root/drawinglayer/source/processor2d
diff options
context:
space:
mode:
authorJonathan Clark <jonathan@libreoffice.org>2024-07-03 08:56:46 -0600
committerJonathan Clark <jonathan@libreoffice.org>2024-07-03 21:05:03 +0200
commit71b7313aa2324b8f7da2026e7b7c2d1c942b497c (patch)
tree7293d86eb6022a391f6ab959bf0d7c317fc7eddd /drawinglayer/source/processor2d
parentcdda6533b44333b18d3dc6306dfd0f7058e40b32 (diff)
tdf#101686 Writer textbox direction changes depending on zoom
Previously, DrawingLayer would apply RTL flags in the case of RTL text, but it would not clear them in the case of LTR text. In certain situations, it is possible for Writer to draw the contents of a text box while the VCL output device is configured for RTL output. As a result, whether DrawingLayer correctly drew LTR text as LTR would depend on the order that text was rendered. This issue would manifest as text boxes appearing to spontaneously mirror themselves while zooming and scrolling through Writer documents containing RTL text. This change updates the relevant portion of DrawingLayer to also clear the RTL flags in the case of LTR text. Change-Id: I3a75561d08cdf3ee6c74b8f6e62f75a1dfcf165e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169942 Tested-by: Jenkins Reviewed-by: Jonathan Clark <jonathan@libreoffice.org>
Diffstat (limited to 'drawinglayer/source/processor2d')
-rw-r--r--drawinglayer/source/processor2d/vclprocessor2d.cxx16
1 files changed, 12 insertions, 4 deletions
diff --git a/drawinglayer/source/processor2d/vclprocessor2d.cxx b/drawinglayer/source/processor2d/vclprocessor2d.cxx
index 7c21e4ea1f1c..b21348cf6635 100644
--- a/drawinglayer/source/processor2d/vclprocessor2d.cxx
+++ b/drawinglayer/source/processor2d/vclprocessor2d.cxx
@@ -315,6 +315,8 @@ void VclProcessor2D::RenderTextSimpleOrDecoratedPortionPrimitive2D(
// set parameters and paint text snippet
const basegfx::BColor aRGBFontColor(
maBColorModifierStack.getModifiedColor(rTextCandidate.getFontColor()));
+
+ // Store previous complex text layout state, to be restored after drawing
const vcl::text::ComplexTextLayoutFlags nOldLayoutMode(mpOutputDevice->GetLayoutMode());
if (rTextCandidate.getFontAttribute().getRTL())
@@ -325,6 +327,14 @@ void VclProcessor2D::RenderTextSimpleOrDecoratedPortionPrimitive2D(
| vcl::text::ComplexTextLayoutFlags::TextOriginLeft;
mpOutputDevice->SetLayoutMode(nRTLLayoutMode);
}
+ else
+ {
+ // tdf#101686: This is LTR text, but the output device may have RTL state.
+ vcl::text::ComplexTextLayoutFlags nLTRLayoutMode(nOldLayoutMode);
+ nLTRLayoutMode = nLTRLayoutMode & ~vcl::text::ComplexTextLayoutFlags::BiDiRtl;
+ nLTRLayoutMode = nLTRLayoutMode & ~vcl::text::ComplexTextLayoutFlags::BiDiStrong;
+ mpOutputDevice->SetLayoutMode(nLTRLayoutMode);
+ }
OUString aText(rTextCandidate.getText());
sal_Int32 nPos = rTextCandidate.getTextPosition();
@@ -460,10 +470,8 @@ void VclProcessor2D::RenderTextSimpleOrDecoratedPortionPrimitive2D(
}
}
- if (rTextCandidate.getFontAttribute().getRTL())
- {
- mpOutputDevice->SetLayoutMode(nOldLayoutMode);
- }
+ // Restore previous layout mode
+ mpOutputDevice->SetLayoutMode(nOldLayoutMode);
if (bChangeMapMode)
mpOutputDevice->Pop();