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
(cherry picked from commit 3bd4a79772
)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173499
Reviewed-by: Bartosz Kosiorek <gang65@poczta.onet.pl>
This commit is contained in:
parent
3567e809ef
commit
0aff602310
4 changed files with 34 additions and 0 deletions
|
@ -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())
|
||||
{
|
||||
|
|
|
@ -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: */
|
||||
|
|
BIN
emfio/qa/cppunit/emf/data/TestAlignRtlReading.emf
Normal file
BIN
emfio/qa/cppunit/emf/data/TestAlignRtlReading.emf
Normal file
Binary file not shown.
|
@ -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 ) );
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue