drawinglayer/source/tools/primitive2dxmldump.cxx | 6 ++++++ emfio/qa/cppunit/emf/EmfImportTest.cxx | 15 +++++++++++++++ emfio/qa/cppunit/emf/data/TestAlignRtlReading.emf |binary emfio/source/reader/mtftools.cxx | 13 +++++++++++++ 4 files changed, 34 insertions(+)
New commits: commit 0aff60231011401fd1e477bdfc40cb03c5c32fdf Author: Jonathan Clark <jonat...@libreoffice.org> AuthorDate: Tue Sep 17 14:48:16 2024 -0600 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Fri Sep 20 21:02:35 2024 +0200 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 <jonat...@libreoffice.org> Tested-by: Jenkins (cherry picked from commit 3bd4a797724cf432d09a7d8ffe5f4a53a1e7c78d) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173499 Reviewed-by: Bartosz Kosiorek <gan...@poczta.onet.pl> diff --git a/drawinglayer/source/tools/primitive2dxmldump.cxx b/drawinglayer/source/tools/primitive2dxmldump.cxx index e16e2a5e6e0c..f1a6279a0c6f 100644 --- a/drawinglayer/source/tools/primitive2dxmldump.cxx +++ b/drawinglayer/source/tools/primitive2dxmldump.cxx @@ -928,6 +928,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 ddb37d9dd085..448680c74faa 100644 --- a/emfio/qa/cppunit/emf/EmfImportTest.cxx +++ b/emfio/qa/cppunit/emf/EmfImportTest.cxx @@ -1854,6 +1854,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 Binary files /dev/null and b/emfio/qa/cppunit/emf/data/TestAlignRtlReading.emf differ diff --git a/emfio/source/reader/mtftools.cxx b/emfio/source/reader/mtftools.cxx index 5e1b36c861c2..7833ece1c917 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 ) ); }