diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2019-10-21 17:41:52 +0200 |
---|---|---|
committer | Xisco FaulĂ <xiscofauli@libreoffice.org> | 2019-10-24 11:30:38 +0200 |
commit | 83baaec3a087f83d0ad3371d55671d9496771586 (patch) | |
tree | bb83645345f3aa9748303659ed8a9784273c0f7f | |
parent | 6a45c9755293f0969b4c2081d6d602bac9986d16 (diff) |
tdf#115967: Revert "sw: Use primitive renderer for graphics"
This reverts commit 302af8c2da58719844d22483b65a9fe5b3674684
I would like to revert it until a better solution is proposed
due to the number of duplicates already reported
After the commit, Libo exports LTR formulas in RTL documents to PDF
as RTL formulas
it also introduced other problems like tdf#112513 and tdf#117560
Unittest added
Change-Id: I097fb5801eb728bd258ae96bd981c6725e7aa06a
Reviewed-on: https://gerrit.libreoffice.org/81262
Tested-by: Jenkins
Reviewed-by: Xisco FaulĂ <xiscofauli@libreoffice.org>
-rw-r--r-- | sw/source/core/doc/notxtfrm.cxx | 23 | ||||
-rw-r--r-- | vcl/qa/cppunit/pdfexport/data/tdf115967.odt | bin | 0 -> 12872 bytes | |||
-rw-r--r-- | vcl/qa/cppunit/pdfexport/pdfexport.cxx | 33 |
3 files changed, 36 insertions, 20 deletions
diff --git a/sw/source/core/doc/notxtfrm.cxx b/sw/source/core/doc/notxtfrm.cxx index 45c32b51a1b3..a8ddd5849078 100644 --- a/sw/source/core/doc/notxtfrm.cxx +++ b/sw/source/core/doc/notxtfrm.cxx @@ -1248,31 +1248,17 @@ void SwNoTextFrame::PaintPicture( vcl::RenderContext* pOut, const SwRect &rGrfAr // SwOLENode does not have a known GraphicObject, need to // work with Graphic instead const Graphic* pGraphic = pOLENd->GetGraphic(); + const Point aPosition(aAlignedGrfArea.Pos()); + const Size aSize(aAlignedGrfArea.SSize()); if ( pGraphic && pGraphic->GetType() != GraphicType::NONE ) { - GraphicObject aTempGraphicObject(*pGraphic); - GraphicAttr aGrfAttr; - const basegfx::B2DHomMatrix aGraphicTransform( - basegfx::utils::createScaleTranslateB2DHomMatrix( - aAlignedGrfArea.Width(), aAlignedGrfArea.Height(), - aAlignedGrfArea.Left(), aAlignedGrfArea.Top())); - - paintGraphicUsingPrimitivesHelper( - *pOut, - aTempGraphicObject, - aGrfAttr, - aGraphicTransform, - nullptr == pOLENd->GetFlyFormat() ? OUString() : pOLENd->GetFlyFormat()->GetName(), - rNoTNd.GetTitle(), - rNoTNd.GetDescription()); + pGraphic->Draw( pOut, aPosition, aSize ); // shade the representation if the object is activated outplace uno::Reference < embed::XEmbeddedObject > xObj = pOLENd->GetOLEObj().GetOleRef(); if ( xObj.is() && xObj->getCurrentState() == embed::EmbedStates::ACTIVE ) { - const Point aPosition(aAlignedGrfArea.Pos()); - const Size aSize(aAlignedGrfArea.SSize()); ::svt::EmbeddedObjectRef::DrawShading( tools::Rectangle( @@ -1283,9 +1269,6 @@ void SwNoTextFrame::PaintPicture( vcl::RenderContext* pOut, const SwRect &rGrfAr } else { - const Point aPosition(aAlignedGrfArea.Pos()); - const Size aSize(aAlignedGrfArea.SSize()); - ::svt::EmbeddedObjectRef::DrawPaintReplacement( tools::Rectangle(aPosition, aSize), pOLENd->GetOLEObj().GetCurrentPersistName(), diff --git a/vcl/qa/cppunit/pdfexport/data/tdf115967.odt b/vcl/qa/cppunit/pdfexport/data/tdf115967.odt Binary files differnew file mode 100644 index 000000000000..3c8384a101be --- /dev/null +++ b/vcl/qa/cppunit/pdfexport/data/tdf115967.odt diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx index 89f10ec3cf9e..4d85190ea5ac 100644 --- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx +++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx @@ -128,6 +128,7 @@ public: void testTdf113143(); void testTdf115262(); void testTdf121962(); + void testTdf115967(); void testTdf121615(); void testTocLink(); @@ -162,6 +163,7 @@ public: CPPUNIT_TEST(testTdf113143); CPPUNIT_TEST(testTdf115262); CPPUNIT_TEST(testTdf121962); + CPPUNIT_TEST(testTdf115967); CPPUNIT_TEST(testTdf121615); CPPUNIT_TEST(testTocLink); CPPUNIT_TEST_SUITE_END(); @@ -1691,6 +1693,37 @@ void PdfExportTest::testTdf121962() OUString sText(aText.data(), nTextSize / 2 - 1); CPPUNIT_ASSERT(sText != "** Expression is faulty **"); } + +} + +void PdfExportTest::testTdf115967() +{ + OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "tdf115967.odt"; + utl::MediaDescriptor aMediaDescriptor; + aMediaDescriptor["FilterName"] <<= OUString("writer_pdf_Export"); + auto pPdfDocument = exportAndParse(aURL, aMediaDescriptor); + CPPUNIT_ASSERT_EQUAL(1, FPDF_GetPageCount(pPdfDocument.get())); + + // Get the first page + PageHolder pPdfPage(FPDF_LoadPage(pPdfDocument.get(), /*page_index=*/0)); + CPPUNIT_ASSERT(pPdfPage.get()); + FPDF_TEXTPAGE pTextPage = FPDFText_LoadPage(pPdfPage.get()); + + // Make sure the table sum is displayed as "0", not faulty expression. + int nPageObjectCount = FPDFPage_CountObjects(pPdfPage.get()); + OUString sText; + for (int i = 0; i < nPageObjectCount; ++i) + { + FPDF_PAGEOBJECT pPageObject = FPDFPage_GetObject(pPdfPage.get(), i); + if (FPDFPageObj_GetType(pPageObject) != FPDF_PAGEOBJ_TEXT) + continue; + unsigned long nTextSize = FPDFTextObj_GetText(pPageObject, pTextPage, nullptr, 2); + std::vector<sal_Unicode> aText(nTextSize); + FPDFTextObj_GetText(pPageObject, pTextPage, aText.data(), nTextSize); + OUString sChar(aText.data(), nTextSize / 2 - 1); + sText += sChar; + } + CPPUNIT_ASSERT_EQUAL(OUString("m=750 g"), sText); } void PdfExportTest::testTdf121615() |