Add drop cap paint tests
Change-Id: Ifc1647aa684a89558646cfb536a046ff9b37131b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/209132 Reviewed-by: Jonathan Clark <jonathan@libreoffice.org> Tested-by: Jenkins
This commit is contained in:
committed by
Jonathan Clark
parent
91cbdc057d
commit
6f61236fd9
@@ -0,0 +1,50 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
|
||||
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
|
||||
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
|
||||
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
|
||||
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
|
||||
xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
|
||||
office:mimetype="application/vnd.oasis.opendocument.text">
|
||||
<office:font-face-decls>
|
||||
<style:font-face style:name="Liberation Sans" svg:font-family="Liberation Sans"
|
||||
style:font-family-generic="swiss" style:font-pitch="variable"/>
|
||||
</office:font-face-decls>
|
||||
<office:automatic-styles>
|
||||
<style:style style:name="PageLayout" style:family="page-layout">
|
||||
<style:page-layout-properties fo:page-width="10cm" fo:page-height="15cm"
|
||||
fo:margin-top="1cm" fo:margin-bottom="1cm" fo:margin-left="1cm" fo:margin-right="1cm"/>
|
||||
</style:style>
|
||||
<style:style style:name="DropCapStyle" style:family="paragraph">
|
||||
<style:text-properties style:font-name="Liberation Sans"
|
||||
style:font-name-asian="Liberation Sans"
|
||||
style:font-name-complex="Liberation Sans"
|
||||
fo:font-size="12pt"
|
||||
style:font-size-asian="12pt"
|
||||
style:font-size-complex="12pt"/>
|
||||
<style:paragraph-properties>
|
||||
<style:drop-cap style:lines="3" style:length="1"/>
|
||||
</style:paragraph-properties>
|
||||
</style:style>
|
||||
<style:style style:name="FlyParaStyle" style:family="paragraph">
|
||||
<style:text-properties style:font-name="Liberation Sans"
|
||||
style:font-name-asian="Liberation Sans"
|
||||
style:font-name-complex="Liberation Sans"
|
||||
fo:font-size="12pt"
|
||||
style:font-size-asian="12pt"
|
||||
style:font-size-complex="12pt"/>
|
||||
</style:style>
|
||||
<style:style style:name="FlyWrap" style:family="graphic">
|
||||
<style:graphic-properties style:wrap="parallel"/>
|
||||
</style:style>
|
||||
</office:automatic-styles>
|
||||
<office:master-styles>
|
||||
<style:master-page style:name="Standard" style:page-layout-name="PageLayout"/>
|
||||
</office:master-styles>
|
||||
<office:body>
|
||||
<office:text>
|
||||
<text:p text:style-name="DropCapStyle">Drop Cap Painting Test Document.<text:line-break/>Second forced line of the drop cap paragraph.<text:line-break/>Third forced line of the drop cap paragraph.</text:p>
|
||||
<text:p text:style-name="FlyParaStyle"><draw:rect draw:style-name="FlyWrap" text:anchor-type="paragraph" svg:width="2cm" svg:height="1.5cm" svg:x="0cm" svg:y="0cm"/>Fly frame paragraph line one.<text:line-break/>Fly frame paragraph line two.<text:line-break/>Fly frame paragraph line three.</text:p>
|
||||
</office:text>
|
||||
</office:body>
|
||||
</office:document>
|
||||
@@ -6928,6 +6928,50 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, testTdf117941RtlStrikeoutChars)
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL(565.2, aRect.at(7).getMaxX(), /*delta*/ 1.0);
|
||||
}
|
||||
|
||||
CPPUNIT_TEST_FIXTURE(PdfExportTest2, testDropCapPaint)
|
||||
{
|
||||
loadFromFile(u"drop_fly_paint.fodt");
|
||||
save(TestFilter::PDF_WRITER);
|
||||
|
||||
std::vector<OUString> aText;
|
||||
std::vector<basegfx::B2DRectangle> aRect;
|
||||
GetPdfPageTextObjectsAndBounds(parsePDFExport(), /*nPage*/ 0, aText, aRect);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(size_t(7), aText.size());
|
||||
|
||||
// Rest of the drop-capped paragraph's 3 forced lines.
|
||||
CPPUNIT_ASSERT_EQUAL(u"rop Cap Painting Test Document."_ustr, aText.at(0).trim());
|
||||
CPPUNIT_ASSERT_EQUAL(u"Second forced line of the drop cap paragraph."_ustr, aText.at(1).trim());
|
||||
CPPUNIT_ASSERT_EQUAL(u"Third forced line of the drop cap paragraph."_ustr, aText.at(2).trim());
|
||||
|
||||
// The drop cap glyph itself must be non-whitespace.
|
||||
CPPUNIT_ASSERT_EQUAL(u"D"_ustr, aText.at(3).trim());
|
||||
|
||||
// Must be noticeably taller than a body line (spans 3 lines), not
|
||||
// just present-but-same-height.
|
||||
double nDropCapHeight = aRect.at(3).getMaxY() - aRect.at(3).getMinY();
|
||||
double nBodyLineHeight = aRect.at(2).getMaxY() - aRect.at(2).getMinY();
|
||||
CPPUNIT_ASSERT(nDropCapHeight > nBodyLineHeight * 2.5);
|
||||
|
||||
// Sits left of the wrapped text beside it, not overlapping/underneath.
|
||||
CPPUNIT_ASSERT(aRect.at(3).getMaxX() < aRect.at(0).getMinX());
|
||||
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL(61.33, aRect.at(3).getMinX(), /*delta*/ 2.0);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL(94.00, aRect.at(3).getMaxX(), /*delta*/ 2.0);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL(696.45, aRect.at(3).getMinY(), /*delta*/ 2.0);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL(734.43, aRect.at(3).getMaxY(), /*delta*/ 2.0);
|
||||
|
||||
// Second paragraph: text wrapping around the anchored fly frame.
|
||||
CPPUNIT_ASSERT_EQUAL(u"Fly frame paragraph line one."_ustr, aText.at(4).trim());
|
||||
CPPUNIT_ASSERT_EQUAL(u"Fly frame paragraph line two."_ustr, aText.at(5).trim());
|
||||
CPPUNIT_ASSERT_EQUAL(u"Fly frame paragraph line three."_ustr, aText.at(6).trim());
|
||||
|
||||
// Every line starts well to the right of the drop-cap paragraph's own
|
||||
// margin, confirming wrap="parallel" is actually pushing text aside.
|
||||
CPPUNIT_ASSERT(aRect.at(4).getMinX() > aRect.at(0).getMinX() + 10.0);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL(114.53, aRect.at(4).getMinX(), /*delta*/ 2.0);
|
||||
}
|
||||
|
||||
} // end anonymous namespace
|
||||
|
||||
CPPUNIT_PLUGIN_IMPLEMENT();
|
||||
|
||||
Reference in New Issue
Block a user