tdf#144222 fix pdf export with vertical layout

Remove the offset adjustment that is no longer necessary.
That was done in every backend before, and has been
removed now.  We can trust what layout text provides us.

Regression from:

commit dd0d0b44fd
Author: Mark Hung <marklh9@gmail.com>
Date:   Sun May 2 15:12:46 2021 +0800

    vcl: adjust LayoutText() for vertical writing.

Change-Id: I077f5a5f0711444086e56e4469dbcb3010ffe661
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123682
Tested-by: Jenkins
Reviewed-by: Mark Hung <marklh9@gmail.com>
This commit is contained in:
Mark Hung
2021-10-21 14:13:30 +02:00
parent 6772ed1dcd
commit a4244c0f05
3 changed files with 42 additions and 2 deletions
Binary file not shown.
+42
View File
@@ -2945,6 +2945,48 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testPdfImageRotate180)
CPPUNIT_ASSERT_DOUBLES_EQUAL(-1.0, aScale.getX(), 0.01);
}
CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf144222)
{
// Assume Windows has the font for U+4E2D
#ifdef _WIN32
OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "tdf144222.ods";
utl::MediaDescriptor aMediaDescriptor;
aMediaDescriptor["FilterName"] <<= OUString("calc_pdf_Export");
auto pPdfDocument = exportAndParse(aURL, aMediaDescriptor);
// The document has one page.
CPPUNIT_ASSERT_EQUAL(1, pPdfDocument->getPageCount());
std::unique_ptr<vcl::pdf::PDFiumPage> pPdfPage = pPdfDocument->openPage(/*nIndex=*/0);
CPPUNIT_ASSERT(pPdfPage);
std::unique_ptr<vcl::pdf::PDFiumTextPage> pTextPage = pPdfPage->getTextPage();
CPPUNIT_ASSERT(pTextPage);
int nPageObjectCount = pPdfPage->getObjectCount();
const OUString sChar = u"\u4E2D";
basegfx::B2DRectangle aRect1, aRect2;
int nCount = 0;
for (int i = 0; i < nPageObjectCount; ++i)
{
std::unique_ptr<vcl::pdf::PDFiumPageObject> pPdfPageObject = pPdfPage->getObject(i);
if (pPdfPageObject->getType() == vcl::pdf::PDFPageObjectType::Text)
{
++nCount;
OUString sText = pPdfPageObject->getText(pTextPage);
if (sText == sChar)
aRect1 = pPdfPageObject->getBounds();
else
aRect2 = pPdfPageObject->getBounds();
}
}
CPPUNIT_ASSERT_EQUAL(2, nCount);
CPPUNIT_ASSERT(!aRect1.isEmpty());
CPPUNIT_ASSERT(!aRect2.isEmpty());
CPPUNIT_ASSERT(!aRect1.overlaps(aRect2));
#endif
}
} // end anonymous namespace
CPPUNIT_PLUGIN_IMPLEMENT();
-2
View File
@@ -5841,8 +5841,6 @@ void PDFWriterImpl::drawVerticalGlyphs(
if (rGlyphs[i].m_pGlyph->IsVertical())
{
fDeltaAngle = M_PI/2.0;
aDeltaPos.setX( GetFontMetric().GetAscent() );
aDeltaPos.setY( static_cast<int>(static_cast<double>(GetFontMetric().GetDescent()) * fXScale) );
fYScale = fXScale;
fTempXScale = 1.0;
fSkewA = -fSkewB;