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
This commit is contained in:
@@ -930,6 +930,12 @@ void Primitive2dXmlDump::decomposeAndWrite(
|
|||||||
const drawinglayer::attribute::FontAttribute& aFontAttribute
|
const drawinglayer::attribute::FontAttribute& aFontAttribute
|
||||||
= rTextSimplePortionPrimitive2D.getFontAttribute();
|
= rTextSimplePortionPrimitive2D.getFontAttribute();
|
||||||
rWriter.attribute("familyname", aFontAttribute.getFamilyName());
|
rWriter.attribute("familyname", aFontAttribute.getFamilyName());
|
||||||
|
|
||||||
|
if (aFontAttribute.getRTL())
|
||||||
|
{
|
||||||
|
rWriter.attribute("rtl", std::u16string_view{ u"true" });
|
||||||
|
}
|
||||||
|
|
||||||
const std::vector<double> aDx = rTextSimplePortionPrimitive2D.getDXArray();
|
const std::vector<double> aDx = rTextSimplePortionPrimitive2D.getDXArray();
|
||||||
if (aDx.size())
|
if (aDx.size())
|
||||||
{
|
{
|
||||||
|
@@ -1855,6 +1855,21 @@ CPPUNIT_TEST_FIXTURE(Test, testPdfInEmf)
|
|||||||
aBitmapEx.GetAlpha(size.Width() / 2, size.Height() / 2));
|
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();
|
CPPUNIT_PLUGIN_IMPLEMENT();
|
||||||
|
|
||||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
/* 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 )
|
if ( mnLatestTextAlign != mnTextAlign )
|
||||||
{
|
{
|
||||||
bChangeFont = true;
|
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;
|
mnLatestTextAlign = mnTextAlign;
|
||||||
mpGDIMetaFile->AddAction( new MetaTextAlignAction( eTextAlign ) );
|
mpGDIMetaFile->AddAction( new MetaTextAlignAction( eTextAlign ) );
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user