summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Clark <jonathan@libreoffice.org>2024-09-17 14:48:16 -0600
committerJonathan Clark <jonathan@libreoffice.org>2024-09-18 05:59:51 +0200
commit3bd4a797724cf432d09a7d8ffe5f4a53a1e7c78d (patch)
tree0c79a2e01eb37899aebd385f054b82ee4e8dd3ad
parentd14e79bf7680db2180e40ba52fc3305a84c586f6 (diff)
tdf#119785 Implement the EMF TA_RTLREADING alignment flag
EMF has two ways to indicate that text should be treated as RTL: - The ExtTextOut ETO_RTLREADING flag - The SetTextAlign TA_RTLREADING flag Previously, only the former was implemented. This change implements the latter. Change-Id: If1023b4a0a3b6eb2ce47d2b764edbfd1a5c0dd5a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173579 Reviewed-by: Jonathan Clark <jonathan@libreoffice.org> Tested-by: Jenkins
-rw-r--r--drawinglayer/source/tools/primitive2dxmldump.cxx6
-rw-r--r--emfio/qa/cppunit/emf/EmfImportTest.cxx15
-rw-r--r--emfio/qa/cppunit/emf/data/TestAlignRtlReading.emfbin0 -> 2996 bytes
-rw-r--r--emfio/source/reader/mtftools.cxx13
4 files changed, 34 insertions, 0 deletions
diff --git a/drawinglayer/source/tools/primitive2dxmldump.cxx b/drawinglayer/source/tools/primitive2dxmldump.cxx
index 61c9f5ca447a..91567d8aabac 100644
--- a/drawinglayer/source/tools/primitive2dxmldump.cxx
+++ b/drawinglayer/source/tools/primitive2dxmldump.cxx
@@ -930,6 +930,12 @@ void Primitive2dXmlDump::decomposeAndWrite(
const drawinglayer::attribute::FontAttribute& aFontAttribute
= rTextSimplePortionPrimitive2D.getFontAttribute();
rWriter.attribute("familyname", aFontAttribute.getFamilyName());
+
+ if (aFontAttribute.getRTL())
+ {
+ rWriter.attribute("rtl", std::u16string_view{ u"true" });
+ }
+
const std::vector<double> aDx = rTextSimplePortionPrimitive2D.getDXArray();
if (aDx.size())
{
diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx b/emfio/qa/cppunit/emf/EmfImportTest.cxx
index 71ae6b80fbee..2d88b0345924 100644
--- a/emfio/qa/cppunit/emf/EmfImportTest.cxx
+++ b/emfio/qa/cppunit/emf/EmfImportTest.cxx
@@ -1855,6 +1855,21 @@ CPPUNIT_TEST_FIXTURE(Test, testPdfInEmf)
aBitmapEx.GetAlpha(size.Width() / 2, size.Height() / 2));
}
+CPPUNIT_TEST_FIXTURE(Test, testAlignRtlReading)
+{
+ // EMF file with the TA_RTLREADING alignment flag
+ Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/emf/data/TestAlignRtlReading.emf");
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequence.getLength()));
+ drawinglayer::Primitive2dXmlDump dumper;
+ xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequence));
+ CPPUNIT_ASSERT(pDocument);
+
+ assertXPath(pDocument, aXPathPrefix + "mask/textsimpleportion", 4);
+ assertXPath(pDocument, aXPathPrefix + "mask/textsimpleportion[1]", "rtl"_ostr, u"true"_ustr);
+ assertXPathNoAttribute(pDocument, aXPathPrefix + "mask/textsimpleportion[2]", "rtl"_ostr);
+ assertXPath(pDocument, aXPathPrefix + "mask/textsimpleportion[3]", "rtl"_ostr, u"true"_ustr);
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/emfio/qa/cppunit/emf/data/TestAlignRtlReading.emf b/emfio/qa/cppunit/emf/data/TestAlignRtlReading.emf
new file mode 100644
index 000000000000..70d9db6cd720
--- /dev/null
+++ b/emfio/qa/cppunit/emf/data/TestAlignRtlReading.emf
Binary files differ
diff --git a/emfio/source/reader/mtftools.cxx b/emfio/source/reader/mtftools.cxx
index 57a915e6250f..f12e6e92b17d 100644
--- a/emfio/source/reader/mtftools.cxx
+++ b/emfio/source/reader/mtftools.cxx
@@ -1712,6 +1712,19 @@ namespace emfio
if ( mnLatestTextAlign != mnTextAlign )
{
bChangeFont = true;
+
+ if ((mnLatestTextAlign & TA_RTLREADING) != (mnTextAlign & TA_RTLREADING))
+ {
+ auto nFlags = vcl::text::ComplexTextLayoutFlags::Default;
+ if (mnTextAlign & TA_RTLREADING)
+ {
+ nFlags = vcl::text::ComplexTextLayoutFlags::BiDiRtl
+ | vcl::text::ComplexTextLayoutFlags::TextOriginLeft;
+ }
+
+ mpGDIMetaFile->AddAction(new MetaLayoutModeAction(nFlags));
+ }
+
mnLatestTextAlign = mnTextAlign;
mpGDIMetaFile->AddAction( new MetaTextAlignAction( eTextAlign ) );
}