[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - vcl/qa vcl/source
vcl/qa/cppunit/pdfexport/data/PDF_export_with_formcontrol.fodt | 174 ++ vcl/qa/cppunit/pdfexport/pdfexport.cxx | 258 ++ vcl/source/gdi/pdfextoutdevdata.cxx| 20 3 files changed, 448 insertions(+), 4 deletions(-) New commits: commit 029ad921c2c5d78353d043b6fc23811e1b309b3d Author: Michael Stahl AuthorDate: Tue Oct 10 18:20:04 2023 +0200 Commit: Miklos Vajna CommitDate: Fri Oct 20 14:43:32 2023 +0200 tdf#157397 vcl: PDF export: fix CreateControl replay The problem is that the CreateLink and CreateControl actions are replayed in a different order than they are recorded, because CreateLink is a global action, and CreateControl a page action. This means that the mCurId at the time when PDFExtOutDevData::CreateControl() is called does not correspond to a position in mParaIds when CreateControl is replayed; it will be inserted too early and bump all the CreateLink ones to later indexes. Avoid this by adding another global action CreateControlLink that is added when CreateControl is being replayed, which appears to work. (Another subtle problem is that, in case of PDF/A-1, the page actions could be discarded completely; this should work in that case too.) (regression from commit d4d471fc88fe4fd14f44dfccdfe360dec327d4f0) Change-Id: I92d89ac08db6548e9f0d1480d984aeacb4d22262 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157767 Tested-by: Jenkins Reviewed-by: Michael Stahl (cherry picked from commit 2e32aa1e9fc240c9cd9854655106d0decbd3694a) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157863 Reviewed-by: Miklos Vajna diff --git a/vcl/qa/cppunit/pdfexport/data/PDF_export_with_formcontrol.fodt b/vcl/qa/cppunit/pdfexport/data/PDF_export_with_formcontrol.fodt new file mode 100644 index ..4aa4a92b6710 --- /dev/null +++ b/vcl/qa/cppunit/pdfexport/data/PDF_export_with_formcontrol.fodt @@ -0,0 +1,174 @@ + +http://www.w3.org/TR/css3-text/; xmlns:grddl="http://www.w3.org/2003/g/data-view#; xmlns:xhtml="http://www.w3.org/1999/xhtml; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance; xmlns:xsd="http://www.w3.org/2001/XMLSchema; xmlns:xforms="http://www.w3.org/2002/xforms; xmlns:dom="http://www.w3.org/2001/xml-events; xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML; xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:ooo="http://openoffice.org/2004/office; xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:ooow="http://openoffice.org/2004/writer; xmlns:xlink="http://www.w3.org/1999/xlink; xmlns:drawooo="http://openoffice.org/2010/draw; xmlns:oooc="http://openoffice.org/2004/calc; xmlns:dc="http://purl.org/dc/elements/1.1/; xmlns:c alcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext: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:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:tableooo="http://openoffice.org/2009/table; xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:rpt="http://openoffice.org/2005/report; xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:officeooo="http://openoffice.org/2009/office; xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns: meta:1.0" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text"> + A. Spielhoff2020-09-12T10:51:34.4381175712023-10-11T12:40:15.543658302PT7H23M50S98LibreOfficeDev/7.5.7.0.0$Linux_X86_64 LibreOffice_project/0325c0aa2d3e6df97ff554ca540d316273fd149a2023-09-23T14:07:35.317591779PDF-Dateien: A Spielhoff + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - vcl/qa vcl/source
vcl/qa/cppunit/GraphicTest.cxx | 14 vcl/qa/cppunit/data/tdf149545.svg | 32 vcl/source/filter/GraphicFormatDetector.cxx |2 - 3 files changed, 47 insertions(+), 1 deletion(-) New commits: commit f13faf35bc62c9804ecacf2059ad724bc3cb2f24 Author: Xisco Fauli AuthorDate: Tue Sep 12 14:29:21 2023 +0200 Commit: Xisco Fauli CommitDate: Tue Sep 19 12:11:30 2023 +0200 tdf#149545: increase svg check size otherwise it will fail to open documents like the one in tdf#149545 with long comments before "https://gerrit.libreoffice.org/c/core/+/156844 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl Signed-off-by: Xisco Fauli Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156876 diff --git a/vcl/qa/cppunit/GraphicTest.cxx b/vcl/qa/cppunit/GraphicTest.cxx index 90164c7e317c..da9b8cce449a 100644 --- a/vcl/qa/cppunit/GraphicTest.cxx +++ b/vcl/qa/cppunit/GraphicTest.cxx @@ -86,6 +86,7 @@ private: void testLoadWEBP(); void testLoadSVGZ(); +void testTdf149545(); void testAvailableThreaded(); void testColorChangeToTransparent(); @@ -126,6 +127,7 @@ private: CPPUNIT_TEST(testLoadWEBP); CPPUNIT_TEST(testLoadSVGZ); +CPPUNIT_TEST(testTdf149545); CPPUNIT_TEST(testAvailableThreaded); CPPUNIT_TEST(testColorChangeToTransparent); @@ -1335,6 +1337,18 @@ void GraphicTest::testLoadSVGZ() CPPUNIT_ASSERT_EQUAL(tools::Long(100 * scalingY), aGraphic.GetSizePixel().Height()); } +void GraphicTest::testTdf149545() +{ +// Without the fix in place, this test would have failed with +// - Expected: 0x0(Error Area:Io Class:NONE Code:0) +// - Actual : 0x8203(Error Area:Vcl Class:General Code:3) +Graphic aGraphic = loadGraphic(u"tdf149545.svg"); +CPPUNIT_ASSERT_EQUAL(GraphicType::Bitmap, aGraphic.GetType()); +const auto[scalingX, scalingY] = getDPIScaling(); +CPPUNIT_ASSERT_EQUAL(tools::Long(100 * scalingX), aGraphic.GetSizePixel().Width()); +CPPUNIT_ASSERT_EQUAL(tools::Long(100 * scalingY), aGraphic.GetSizePixel().Height()); +} + void GraphicTest::testAvailableThreaded() { Graphic jpgGraphic1 = importUnloadedGraphic(u"TypeDetectionExample.jpg"); diff --git a/vcl/qa/cppunit/data/tdf149545.svg b/vcl/qa/cppunit/data/tdf149545.svg new file mode 100644 index ..39fd956142bd --- /dev/null +++ b/vcl/qa/cppunit/data/tdf149545.svg @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + +http://www.w3.org/2000/svg; xmlns:xlink="http://www.w3.org/1999/xlink; id="svg-root" width="100%" height="100%" viewBox="0 0 99 99"> + + + + diff --git a/vcl/source/filter/GraphicFormatDetector.cxx b/vcl/source/filter/GraphicFormatDetector.cxx index fc43cdd963ab..d3cb7869ebc1 100644 --- a/vcl/source/filter/GraphicFormatDetector.cxx +++ b/vcl/source/filter/GraphicFormatDetector.cxx @@ -31,7 +31,7 @@ #include #include -constexpr sal_uInt32 SVG_CHECK_SIZE = 2048; +constexpr sal_uInt32 SVG_CHECK_SIZE = 8192; constexpr sal_uInt32 WMF_EMF_CHECK_SIZE = 44; constexpr sal_uInt32 DATA_SIZE = 640;
[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - vcl/qa vcl/source
vcl/qa/cppunit/pdfexport/pdfexport.cxx |8 vcl/source/gdi/CommonSalLayout.cxx |2 +- vcl/source/gdi/sallayout.cxx | 13 +++-- 3 files changed, 16 insertions(+), 7 deletions(-) New commits: commit 7ead6fd72bef4713baf55e786f30b6870cc85609 Author: Xisco Fauli AuthorDate: Wed Aug 23 10:36:41 2023 +0200 Commit: Xisco Fauli CommitDate: Wed Aug 23 13:38:51 2023 +0200 tdf#156681: Revert "tdf#152048: Fix underline width for Kashida-justified text" This reverts commit 43a5400063b17ed4ba4cbb38bdf5da4a991f60e2. The idea is to revert it in libreoffice-7-6 and libreoffice-7-5 branches only since tdf#156681 is fixed in master by 507a8745870e9a755be3a72f59c6e9a9d811fdcf "vcl: Use doubles for glyph item coordinates" This commit also reverts 34df6c92e513c5f428eff7c9cb1d6b9831eeb323 "tdf#152048: Add test" Change-Id: Id246c388df45d16b9bce86d1827949c644fc8517 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155969 Tested-by: Jenkins Reviewed-by: خالد حسني Signed-off-by: Xisco Fauli Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155972 diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx index bf35818056df..d5d8408630aa 100644 --- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx +++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx @@ -774,15 +774,15 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf108963) pSegment = pPdfPageObject->getPathSegment(1); CPPUNIT_ASSERT_EQUAL(vcl::pdf::PDFSegmentType::Lineto, pSegment->getType()); aPoint = pSegment->getPoint(); -CPPUNIT_ASSERT_DOUBLES_EQUAL(275.216, aPoint.getX(), 0.0005); -CPPUNIT_ASSERT_DOUBLES_EQUAL(267.732, aPoint.getY(), 0.0005); +CPPUNIT_ASSERT_DOUBLES_EQUAL(275.074, aPoint.getX(), 0.0005); +CPPUNIT_ASSERT_DOUBLES_EQUAL(267.590, aPoint.getY(), 0.0005); CPPUNIT_ASSERT(!pSegment->isClosed()); pSegment = pPdfPageObject->getPathSegment(2); CPPUNIT_ASSERT_EQUAL(vcl::pdf::PDFSegmentType::Lineto, pSegment->getType()); aPoint = pSegment->getPoint(); -CPPUNIT_ASSERT_DOUBLES_EQUAL(287.660, aPoint.getX(), 0.0005); -CPPUNIT_ASSERT_DOUBLES_EQUAL(251.914, aPoint.getY(), 0.0005); +CPPUNIT_ASSERT_DOUBLES_EQUAL(287.490, aPoint.getX(), 0.0005); +CPPUNIT_ASSERT_DOUBLES_EQUAL(251.801, aPoint.getY(), 0.0005); CPPUNIT_ASSERT(!pSegment->isClosed()); pSegment = pPdfPageObject->getPathSegment(3); diff --git a/vcl/source/gdi/CommonSalLayout.cxx b/vcl/source/gdi/CommonSalLayout.cxx index 754b228f8ad3..be301edcd365 100644 --- a/vcl/source/gdi/CommonSalLayout.cxx +++ b/vcl/source/gdi/CommonSalLayout.cxx @@ -845,7 +845,7 @@ void GenericSalLayout::ApplyDXArray(const double* pDXArray, const sal_Bool* pKas aPos.adjustX(-nClusterWidth + pGlyphIter->origWidth()); while (nCopies--) { -GlyphItem aKashida(nCharPos, 0, nKashidaIndex, aPos, nFlags, 0, 0, 0); +GlyphItem aKashida(nCharPos, 0, nKashidaIndex, aPos, nFlags, nKashidaWidth, 0, 0); pGlyphIter = m_GlyphItems.insert(pGlyphIter, aKashida); aPos.adjustX(nKashidaWidth - nOverlap); ++pGlyphIter; diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx index 3cdd71642b5b..ed368f04022e 100644 --- a/vcl/source/gdi/sallayout.cxx +++ b/vcl/source/gdi/sallayout.cxx @@ -269,10 +269,19 @@ DeviceCoordinate GenericSalLayout::GetTextWidth() const if (!m_GlyphItems.IsValid()) return 0; -DeviceCoordinate nWidth = 0; +// initialize the extent +DeviceCoordinate nMinPos = 0; +DeviceCoordinate nMaxPos = 0; + for (auto const& aGlyphItem : m_GlyphItems) -nWidth += aGlyphItem.newWidth(); +{ +// update the text extent with the glyph extent +DeviceCoordinate nXPos = aGlyphItem.linearPos().getX() - aGlyphItem.xOffset(); +nMinPos = std::min(nMinPos, nXPos); +nMaxPos = std::max(nMaxPos, nXPos + aGlyphItem.newWidth()); +} +DeviceCoordinate nWidth = nMaxPos - nMinPos; return nWidth; }
[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - vcl/qa vcl/source
vcl/qa/cppunit/pdfexport/data/wide_page1.fodt | 40 ++ vcl/qa/cppunit/pdfexport/pdfexport.cxx| 56 ++ vcl/source/gdi/pdfwriter_impl.cxx |8 --- 3 files changed, 98 insertions(+), 6 deletions(-) New commits: commit e5b3b2204e975ffe1d2ebc14b92c0fc9e3f17417 Author: Mike Kaganski AuthorDate: Fri Jul 28 17:55:17 2023 +0300 Commit: Xisco Fauli CommitDate: Tue Aug 1 14:41:32 2023 +0200 tdf#156528: Fix handling PDF page scaling factor after large pages The map mode wasn't set when current page's user unit was 1, which meant that it used the unchanged value from the previous page, where it could be different. Change-Id: Id1f1515dceac25cddc12081a86fabf8b32d633f0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155025 Tested-by: Mike Kaganski Reviewed-by: Mike Kaganski (cherry picked from commit 0b6fc1fdcc67cc6e13ca3c0e4c81742a43488ed6) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155141 Reviewed-by: خالد حسني Tested-by: Jenkins diff --git a/vcl/qa/cppunit/pdfexport/data/wide_page1.fodt b/vcl/qa/cppunit/pdfexport/data/wide_page1.fodt new file mode 100644 index ..9e7390a8e22a --- /dev/null +++ b/vcl/qa/cppunit/pdfexport/data/wide_page1.fodt @@ -0,0 +1,40 @@ + + +http://openoffice.org/2004/office; xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink; xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/; xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta: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:rpt="http://openoffice.org/2005/report; xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:ooow="http://openoffice.org/200 4/writer" xmlns:oooc="http://openoffice.org/2004/calc; xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:xforms="http://www.w3.org/2002/xforms; xmlns:tableooo="http://openoffice.org/2009/table; xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" xmlns:drawooo="http://openoffice.org/2010/draw; xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML; xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:dom="http://www.w3.org/2001/xml-events; xmlns:xsd="http://www.w3.org/2001/XMLSchema; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance; xmlns:xhtml="http://www.w3.org/1999/xhtml; xmlns:grddl="http://www.w3.org/2003/g/data-view#; xmlns :css3t="http://www.w3.org/TR/css3-text/; xmlns:officeooo="http://openoffice.org/2009/office; office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx index 95667732c549..bf35818056df 100644 --- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx +++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx @@ -4735,6 +4735,62 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf48707_2) } } +CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf156528) +{ +aMediaDescriptor["FilterName"] <<= OUString("writer_pdf_Export"); +saveAsPDF(u"wide_page1.fodt"); +std::unique_ptr pPdfDocument = parsePDFExport(); + +// The document has two pages +CPPUNIT_ASSERT_EQUAL(2, pPdfDocument->getPageCount()); + +// 1st page (5100 mm width x 210 mm high, UserUnit = 2) +auto pPdfPage = pPdfDocument->openPage(0); +CPPUNIT_ASSERT(pPdfPage); +CPPUNIT_ASSERT_DOUBLES_EQUAL(o3tl::convert(5100.0 / 2, o3tl::Length::mm, o3tl::Length::pt), + pPdfPage->getWidth(), 1); +CPPUNIT_ASSERT_DOUBLES_EQUAL(o3tl::convert(210.0 / 2, o3tl::Length::mm, o3tl::Length::pt), + pPdfPage->getHeight(), 1); + +// 1 object (rectangle 5060 mm width x 170 mm high, UserUnit = 2) +CPPUNIT_ASSERT_EQUAL(1, pPdfPage->getObjectCount()); +auto pRect = pPdfPage->getObject(0); +CPPUNIT_ASSERT(pRect); +CPPUNIT_ASSERT_EQUAL(vcl::pdf::PDFPageObjectType::Path,
[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - vcl/qa vcl/source
vcl/qa/cppunit/pdfexport/pdfexport.cxx |2 +- vcl/source/gdi/pdfwriter_impl.cxx |8 2 files changed, 5 insertions(+), 5 deletions(-) New commits: commit c1f7f916a6705e850cc8255d4e69055ee605059c Author: Michael Stahl AuthorDate: Mon Jul 10 20:38:25 2023 +0200 Commit: Xisco Fauli CommitDate: Wed Jul 12 09:12:48 2023 +0200 tdf#152234 vcl: Role values are lowercase Old version 3 of PAC throws exceptions if these are capitalized; presumably this is case sensitive, and all-lowercase unlike everything else. Change-Id: Ifc0cef38e333123e810376ab6a7630443d253841 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154282 Tested-by: Jenkins Reviewed-by: Michael Stahl (cherry picked from commit 1ae1f76caeef35a0db7705dd0c330936a77b6a8c) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154265 Reviewed-by: Xisco Fauli diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx index ae46ce44c427..95667732c549 100644 --- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx +++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx @@ -3875,7 +3875,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testFormControlAnnot) CPPUNIT_ASSERT_EQUAL(OString("PrintField"), pO->GetValue()); auto pRole = dynamic_cast(pAObj->Lookup("Role")); CPPUNIT_ASSERT(pRole); -CPPUNIT_ASSERT_EQUAL(OString("Cb"), pRole->GetValue()); +CPPUNIT_ASSERT_EQUAL(OString("cb"), pRole->GetValue()); auto pKids = dynamic_cast(pStructElem->Lookup("K")); auto nMCID(0); auto nRef(0); diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index b6901420bddf..ee5def1a1126 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -1928,10 +1928,10 @@ const char* PDFWriterImpl::getAttributeValueTag( PDFWriter::StructAttributeValue aValueStrings[ PDFWriter::Header ] = "Header"; aValueStrings[ PDFWriter::Footer ] = "Footer"; aValueStrings[ PDFWriter::Watermark ] = "Watermark"; -aValueStrings[ PDFWriter::Rb ] = "Rb"; -aValueStrings[ PDFWriter::Cb ] = "Cb"; -aValueStrings[ PDFWriter::Pb ] = "Pb"; -aValueStrings[ PDFWriter::Tv ] = "Tv"; +aValueStrings[ PDFWriter::Rb ] = "rb"; +aValueStrings[ PDFWriter::Cb ] = "cb"; +aValueStrings[ PDFWriter::Pb ] = "pb"; +aValueStrings[ PDFWriter::Tv ] = "tv"; aValueStrings[ PDFWriter::Disc ]= "Disc"; aValueStrings[ PDFWriter::Circle ] = "Circle"; aValueStrings[ PDFWriter::Square ] = "Square";
[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - vcl/qa vcl/source
vcl/qa/cppunit/pdfexport/data/tdf48707-1.fodt | 290 ++ vcl/qa/cppunit/pdfexport/data/tdf48707-2.fodt | 335 ++ vcl/qa/cppunit/pdfexport/pdfexport.cxx| 65 + vcl/source/gdi/pdfwriter_impl.cxx |3 4 files changed, 693 insertions(+) New commits: commit 1f9087b8da6588239a4b655f2dc94d48817569a5 Author: Khaled Hosny AuthorDate: Mon Jul 3 14:19:42 2023 +0300 Commit: Michael Stahl CommitDate: Tue Jul 4 10:37:55 2023 +0200 tdf#48707: Explicitly set overline color in PDF export Like we do with underline color, so that color does not leak from elsewhere. Change-Id: I3716a117a0d0a1260e47cbfed2242f401a09d7b6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153877 Tested-by: Jenkins Reviewed-by: خالد حسني (cherry picked from commit 19f4d93ddfc1b738c4f11666d6cb8090437abce7) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153911 Reviewed-by: Michael Stahl diff --git a/vcl/qa/cppunit/pdfexport/data/tdf48707-1.fodt b/vcl/qa/cppunit/pdfexport/data/tdf48707-1.fodt new file mode 100644 index ..02286e5051c5 --- /dev/null +++ b/vcl/qa/cppunit/pdfexport/data/tdf48707-1.fodt @@ -0,0 +1,290 @@ + + +http://www.w3.org/TR/css3-text/; xmlns:grddl="http://www.w3.org/2003/g/data-view#; xmlns:xhtml="http://www.w3.org/1999/xhtml; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance; xmlns:xsd="http://www.w3.org/2001/XMLSchema; xmlns:xforms="http://www.w3.org/2002/xforms; xmlns:dom="http://www.w3.org/2001/xml-events; xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML; xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:officeooo="http://openoffice.org/2009/office; xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:formx="u rn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:rpt="http://openoffice.org/2005/report; xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:tableooo="http://openoffice.org/2009/table; xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/; xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" xmlns:oooc="http://openoffice.org/2004/calc; xmlns:xlink="http://www.w3.org/1999/xlink; xmlns:drawooo="http://openoffice.org/2010/draw; xmlns:ooow="http://openoffice.org/2004/writer; xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:ooo="http:/ /openoffice.org/2004/office" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text"> + Scott Wills2011-08-03T07:12:282023-07-03T14:56:12.773653822PT1M52S2LibreOffice/7.5.4.2$MacOSX_X86_64 LibreOffice_project/36ccfdc35048b057fd9854c757a8b67ec53977b6 + + + 0 + 0 + 22666 + 10624 + true + false + + + view2 + 10463 + 2501 + 0 + 0 + 22664 + 10622 + 3 + 0 + false + 167 + false + false + true + true + false + + + + + true + true + true + true + false + + false + false + true + false + false + false + true + false + false + false + false + false + 0 + 0 + false + false + false + false + true + false + false + false + true + false + false + + false + false + + true + false + false + false + false + false + true + true + false + false + false + false + false + false + false + false + false + + false + false + false + false + false + false + 0 + false + false + false + false + false + true + false + false + false + false + false + false + false + + false + false + true + true + false + true + true + false + 821660 + true + true + false + + false + true + false + high-resolution + 1 + 0 + true + false + false + true + true + true + true + true + false + true + + false + true + 850755 + false + + + + + http://openoffice.org/2004/office; xmlns:xlink="http://www.w3.org/1999/xlink"/> + + + + + + + + +
[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - vcl/qa vcl/source
vcl/qa/cppunit/pdfexport/pdfexport.cxx |8 vcl/source/gdi/CommonSalLayout.cxx |2 +- vcl/source/gdi/sallayout.cxx | 13 ++--- 3 files changed, 7 insertions(+), 16 deletions(-) New commits: commit be99eda81510a7c3bb5351f3128c83db800fc0f3 Author: Khaled Hosny AuthorDate: Thu May 25 10:59:18 2023 +0300 Commit: Caolán McNamara CommitDate: Sun May 28 14:43:12 2023 +0200 tdf#152048: Fix underline width for Kashida-justified text Fix GenericSalLayout::GetTextWidth() again, this time doing away with using linearPos as it is wrong, the glyph’s position is not directly related to how much it contributes to the text width (for example, combining marks have zero advance width yet their position is different from the base glyph they apply too). This is a followup to: commit ce7c1c608fa99c86c8f2380cd8b82d02123f514e Author: Khaled Hosny Date: Wed Aug 31 07:07:54 2022 +0200 vcl: Fix GenericSalLayout::GetTextWidth() Additionally, inserted Kashida should have its origWidth and newWidth both set to zero, since it does not add to the text width, all additional width is already added to the glyph the Kashida is applied to. With both fixes, the text width of Kashida-justified lines is correctly calculated and the underline no longer extends beyond the text line. Fix test expectation now we are reporting the real text width. Change-Id: I0de93f955929cf3030cf420cb4f4e94df974fb79 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152267 Tested-by: Jenkins Reviewed-by: خالد حسني (cherry picked from commit 43a5400063b17ed4ba4cbb38bdf5da4a991f60e2) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152220 Reviewed-by: Caolán McNamara diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx index a7a02272219d..60ea081ed423 100644 --- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx +++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx @@ -774,15 +774,15 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf108963) pSegment = pPdfPageObject->getPathSegment(1); CPPUNIT_ASSERT_EQUAL(vcl::pdf::PDFSegmentType::Lineto, pSegment->getType()); aPoint = pSegment->getPoint(); -CPPUNIT_ASSERT_DOUBLES_EQUAL(275.074, aPoint.getX(), 0.0005); -CPPUNIT_ASSERT_DOUBLES_EQUAL(267.590, aPoint.getY(), 0.0005); +CPPUNIT_ASSERT_DOUBLES_EQUAL(275.216, aPoint.getX(), 0.0005); +CPPUNIT_ASSERT_DOUBLES_EQUAL(267.732, aPoint.getY(), 0.0005); CPPUNIT_ASSERT(!pSegment->isClosed()); pSegment = pPdfPageObject->getPathSegment(2); CPPUNIT_ASSERT_EQUAL(vcl::pdf::PDFSegmentType::Lineto, pSegment->getType()); aPoint = pSegment->getPoint(); -CPPUNIT_ASSERT_DOUBLES_EQUAL(287.490, aPoint.getX(), 0.0005); -CPPUNIT_ASSERT_DOUBLES_EQUAL(251.801, aPoint.getY(), 0.0005); +CPPUNIT_ASSERT_DOUBLES_EQUAL(287.660, aPoint.getX(), 0.0005); +CPPUNIT_ASSERT_DOUBLES_EQUAL(251.914, aPoint.getY(), 0.0005); CPPUNIT_ASSERT(!pSegment->isClosed()); pSegment = pPdfPageObject->getPathSegment(3); diff --git a/vcl/source/gdi/CommonSalLayout.cxx b/vcl/source/gdi/CommonSalLayout.cxx index f4472726fcfe..5cac0ebdb6b0 100644 --- a/vcl/source/gdi/CommonSalLayout.cxx +++ b/vcl/source/gdi/CommonSalLayout.cxx @@ -845,7 +845,7 @@ void GenericSalLayout::ApplyDXArray(const double* pDXArray, const sal_Bool* pKas aPos.adjustX(-nClusterWidth + pGlyphIter->origWidth()); while (nCopies--) { -GlyphItem aKashida(nCharPos, 0, nKashidaIndex, aPos, nFlags, nKashidaWidth, 0, 0); +GlyphItem aKashida(nCharPos, 0, nKashidaIndex, aPos, nFlags, 0, 0, 0); pGlyphIter = m_GlyphItems.insert(pGlyphIter, aKashida); aPos.adjustX(nKashidaWidth - nOverlap); ++pGlyphIter; diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx index 85ad838615d9..1ed2a37ad71b 100644 --- a/vcl/source/gdi/sallayout.cxx +++ b/vcl/source/gdi/sallayout.cxx @@ -269,19 +269,10 @@ DeviceCoordinate GenericSalLayout::GetTextWidth() const if (!m_GlyphItems.IsValid()) return 0; -// initialize the extent -DeviceCoordinate nMinPos = 0; -DeviceCoordinate nMaxPos = 0; - +DeviceCoordinate nWidth = 0; for (auto const& aGlyphItem : m_GlyphItems) -{ -// update the text extent with the glyph extent -DeviceCoordinate nXPos = aGlyphItem.linearPos().getX() - aGlyphItem.xOffset(); -nMinPos = std::min(nMinPos, nXPos); -nMaxPos = std::max(nMaxPos, nXPos + aGlyphItem.newWidth()); -} +nWidth += aGlyphItem.newWidth(); -DeviceCoordinate nWidth = nMaxPos - nMinPos; return nWidth; }
[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - vcl/qa vcl/source
vcl/qa/cppunit/filter/ipdf/data/array-mixed-numbers-and-elements.pdf | 55 ++ vcl/qa/cppunit/filter/ipdf/ipdf.cxx | 25 vcl/source/filter/ipdf/pdfdocument.cxx | 45 3 files changed, 125 insertions(+) New commits: commit 84d5dcc7365246352a7126ae15c54cd66bf344d9 Author: Jaume Pujantell AuthorDate: Fri Mar 3 19:25:11 2023 +0100 Commit: Xisco Fauli CommitDate: Wed Mar 8 10:58:35 2023 + Fix a bug parsing pdf arrays The parser ignored number elements in some situations, like before a reference element. This manifested in creating an invalid pdf file when exporting as pdf a document that contains a pdf. Change-Id: I98625c8da8631056079814f7e824f36177cf41c7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148198 Tested-by: Jenkins Reviewed-by: Andras Timar (cherry picked from commit 574e89ccda1b389faca9f3e44d909a71b5599473) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148394 Reviewed-by: Xisco Fauli diff --git a/vcl/qa/cppunit/filter/ipdf/data/array-mixed-numbers-and-elements.pdf b/vcl/qa/cppunit/filter/ipdf/data/array-mixed-numbers-and-elements.pdf new file mode 100644 index ..01030ecf88bc --- /dev/null +++ b/vcl/qa/cppunit/filter/ipdf/data/array-mixed-numbers-and-elements.pdf @@ -0,0 +1,55 @@ +%PDF-1.7 +%��� +1 0 obj << + /Type /Catalog + /Pages 2 0 R +>> +endobj +2 0 obj << + /Type /Pages + /MediaBox [0 0 200 300] + /Count 1 + /Kids [3 0 R] +>> +endobj +3 0 obj << + /Type /Page + /Parent 2 0 R + /Contents 4 0 R + /Test [1 4 0 R 3 false 5 (Lieral) 7 <90>] +>> +endobj +4 0 obj << + /Length 188 +>> +stream +q +0 0 0 rg +0 290 10 10 re B* +10 150 50 30 re B* +0 0 1 rg +190 290 10 10 re B* +70 232 50 30 re B* +0 1 0 rg +190 0 10 10 re B* +130 150 50 30 re B* +1 0 0 rg +0 0 10 10 re B* +70 67 50 30 re B* +Q +endstream +endobj +xref +0 5 +00 65535 f +15 0 n +68 0 n +000157 0 n +000270 0 n +trailer << + /Root 1 0 R + /Size 5 +>> +startxref +510 +%%EOF diff --git a/vcl/qa/cppunit/filter/ipdf/ipdf.cxx b/vcl/qa/cppunit/filter/ipdf/ipdf.cxx index 1c143a1b8319..c27555ca1d70 100644 --- a/vcl/qa/cppunit/filter/ipdf/ipdf.cxx +++ b/vcl/qa/cppunit/filter/ipdf/ipdf.cxx @@ -186,6 +186,31 @@ CPPUNIT_TEST_FIXTURE(VclFilterIpdfTest, testCommentEnd) CPPUNIT_ASSERT(aDocument.Read(aFile)); } +CPPUNIT_TEST_FIXTURE(VclFilterIpdfTest, testMixedArrayWithNumbers) +{ +// Load a file that has markup like this: +// 3 0 obj << +// /Test [1 4 0 R 3 false 5 (Lieral) 7 <90>] +// >> +OUString aSourceURL = createFileURL(u"array-mixed-numbers-and-elements.pdf"); +SvFileStream aFile(aSourceURL, StreamMode::READ); +vcl::filter::PDFDocument aDocument; +CPPUNIT_ASSERT(aDocument.Read(aFile)); +std::vector aPages = aDocument.GetPages(); +CPPUNIT_ASSERT(!aPages.empty()); +vcl::filter::PDFObjectElement* pPage = aPages[0]; +auto pTest = dynamic_cast(pPage->Lookup("Test")); +std::vector aElements = pTest->GetElements(); + +// Without the accompanying fix in place, this test would have failed with +// the array containing the wrong number of elements and in the incorrect order +CPPUNIT_ASSERT_EQUAL(8, static_cast(aElements.size())); +CPPUNIT_ASSERT(dynamic_cast(aElements[0])); +CPPUNIT_ASSERT(dynamic_cast(aElements[2])); +CPPUNIT_ASSERT(dynamic_cast(aElements[4])); +CPPUNIT_ASSERT(dynamic_cast(aElements[6])); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/filter/ipdf/pdfdocument.cxx b/vcl/source/filter/ipdf/pdfdocument.cxx index 19748e241ead..5ff50d3b55ac 100644 --- a/vcl/source/filter/ipdf/pdfdocument.cxx +++ b/vcl/source/filter/ipdf/pdfdocument.cxx @@ -3248,6 +3248,18 @@ size_t PDFObjectParser::parse(PDFElement* pParsingElement, size_t nStartIndex, i } else if (auto pReference = dynamic_cast(pCurrentElement)) { +// Handle previously stored number +if (aNumbers.size() > 2) +{ +aNumbers.resize(aNumbers.size() - 2); +if (pParsingArray) +{ +for (auto& pNumber : aNumbers) +pParsingArray->PushBack(pNumber); +} +aNumbers.clear(); +} + if (pParsingArray) { pParsingArray->PushBack(pReference); @@ -3268,6 +3280,17 @@ size_t PDFObjectParser::parse(PDFElement* pParsingElement, size_t nStartIndex, i } else if (auto pLiteralString = dynamic_cast(pCurrentElement)) { +// Handle previously stored number +if (!aNumbers.empty()) +{ +if (pParsingArray) +{ +for (auto& pNumber : aNumbers) +
[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - vcl/qa vcl/source
vcl/qa/cppunit/pdfexport/data/ref-to-kids.pdf |binary vcl/qa/cppunit/pdfexport/pdfexport.cxx| 61 ++ vcl/source/gdi/pdfwriter_impl.cxx | 29 ++-- 3 files changed, 85 insertions(+), 5 deletions(-) New commits: commit d9cab7dc6dbbbe3d80aa765cfd0b3c9f85d73c06 Author: Dennis Francis AuthorDate: Thu Dec 1 11:47:12 2022 +0530 Commit: Xisco Fauli CommitDate: Mon Jan 9 17:08:24 2023 + vcl: use /MediaBox origin in the ctm... of the inner XObject, else the clip polypolygon may clip out partly or whole contents. Adjusting the clip polypolygon is not straightforward. Change-Id: If3b208ba850c3579c9e16c15e4fb2f947dad4406 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143561 Tested-by: Jenkins CollaboraOffice Reviewed-by: Miklos Vajna (cherry picked from commit a67dcc248a103098de883a4dd2fa9ff2e1cc1f90) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144436 Tested-by: Jenkins Signed-off-by: Xisco Fauli Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145202 diff --git a/vcl/qa/cppunit/pdfexport/data/ref-to-kids.pdf b/vcl/qa/cppunit/pdfexport/data/ref-to-kids.pdf index 598358a636aa..0390ccad8410 100644 Binary files a/vcl/qa/cppunit/pdfexport/data/ref-to-kids.pdf and b/vcl/qa/cppunit/pdfexport/data/ref-to-kids.pdf differ diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx index 428f9d5a132a..ce070a711911 100644 --- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx +++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx @@ -4186,6 +4186,67 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testRexportFilterSingletonArray) CPPUNIT_ASSERT(it != pEnd); } +CPPUNIT_TEST_FIXTURE(PdfExportTest, testRexportMediaBoxOrigin) +{ +// We need to enable PDFium import (and make sure to disable after the test) +bool bResetEnvVar = false; +if (getenv("LO_IMPORT_USE_PDFIUM") == nullptr) +{ +bResetEnvVar = true; +osl_setEnvironment(OUString("LO_IMPORT_USE_PDFIUM").pData, OUString("1").pData); +} +comphelper::ScopeGuard aPDFiumEnvVarGuard([&]() { +if (bResetEnvVar) +osl_clearEnvironment(OUString("LO_IMPORT_USE_PDFIUM").pData); +}); + +// Load the PDF and save as PDF +vcl::filter::PDFDocument aDocument; +load(u"ref-to-kids.pdf", aDocument); + +std::vector aPages = aDocument.GetPages(); +CPPUNIT_ASSERT_EQUAL(size_t(5), aPages.size()); + +// Directly go to the inner XObject Im10 that contains the rectangle drawings in page 2. +auto pInnerIm = aDocument.LookupObject(10); +CPPUNIT_ASSERT(pInnerIm); + +constexpr sal_Int32 aOrigin[2] = { -800, -600 }; +sal_Int32 aSize[2] = { 0, 0 }; + +auto pBBox = dynamic_cast(pInnerIm->Lookup("BBox")); +CPPUNIT_ASSERT(pBBox); +const auto& rElements2 = pBBox->GetElements(); +CPPUNIT_ASSERT_EQUAL(static_cast(4), rElements2.size()); +for (sal_Int32 nIdx = 0; nIdx < 4; ++nIdx) +{ +const auto* pNumElement = dynamic_cast(rElements2[nIdx]); +CPPUNIT_ASSERT(pNumElement); +if (nIdx < 2) +CPPUNIT_ASSERT_EQUAL(aOrigin[nIdx], static_cast(pNumElement->GetValue())); +else +aSize[nIdx - 2] = static_cast(pNumElement->GetValue()) - aOrigin[nIdx - 2]; +} + +auto pMatrix = dynamic_cast(pInnerIm->Lookup("Matrix")); +CPPUNIT_ASSERT(pMatrix); +const auto& rElements = pMatrix->GetElements(); +CPPUNIT_ASSERT_EQUAL(static_cast(6), rElements.size()); +sal_Int32 aMatTranslate[6] += { // Rotation by $\theta$ $cos(\theta), sin(\theta), -sin(\theta), cos(\theta)$ +0, -1, 1, 0, +// Translate x,y +-aOrigin[1] - aSize[1] / 2 + aSize[0] / 2, aOrigin[0] + aSize[0] / 2 + aSize[1] / 2 + }; + +for (sal_Int32 nIdx = 0; nIdx < 6; ++nIdx) +{ +const auto* pNumElement = dynamic_cast(rElements[nIdx]); +CPPUNIT_ASSERT(pNumElement); +CPPUNIT_ASSERT_EQUAL(aMatTranslate[nIdx], static_cast(pNumElement->GetValue())); +} +} + } // end anonymous namespace CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index f4a3145c5085..d95a74aeb6af 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -8873,6 +8873,21 @@ void PDFWriterImpl::writeReferenceXObject(const ReferenceXObjectEmit& rEmit) return; } +double aOrigin[2] = { 0.0, 0.0 }; +if (auto* pArray = dynamic_cast(pPage->Lookup("MediaBox"))) +{ +const auto& rElements = pArray->GetElements(); +if (rElements.size() >= 4) +{ +// get x1, y1 of the rectangle. +for (sal_Int32 nIdx = 0; nIdx < 2; ++nIdx) +{ +if (const auto* pNumElement = dynamic_cast(rElements[nIdx])) +
[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - vcl/qa vcl/source
vcl/qa/cppunit/pdfexport/pdfexport.cxx | 50 + vcl/source/gdi/pdfobjectcopier.cxx |8 + 2 files changed, 58 insertions(+) New commits: commit 76091c828ec7c515a2fced158c395fea3bf47602 Author: Dennis Francis AuthorDate: Thu Dec 1 11:28:49 2022 +0530 Commit: Xisco Fauli CommitDate: Wed Dec 21 11:50:05 2022 + vcl: /Filter [/FlatDecode] not properly read Change-Id: I156e153ae1a123cf9cf54eb23e6d3abe8962f677 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143560 Tested-by: Jenkins CollaboraOffice Reviewed-by: Miklos Vajna (cherry picked from commit f5ad4f9dfac27d5675fa5c397f66b8cc45cc31a1) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144435 Tested-by: Jenkins (cherry picked from commit db2757e110c1d99bc6128d80a0c6b9fd63982b89) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144659 Reviewed-by: Xisco Fauli diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx index f18077505abd..428f9d5a132a 100644 --- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx +++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx @@ -4136,6 +4136,56 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testRexportRefToKids) } } +CPPUNIT_TEST_FIXTURE(PdfExportTest, testRexportFilterSingletonArray) +{ +// We need to enable PDFium import (and make sure to disable after the test) +bool bResetEnvVar = false; +if (getenv("LO_IMPORT_USE_PDFIUM") == nullptr) +{ +bResetEnvVar = true; +osl_setEnvironment(OUString("LO_IMPORT_USE_PDFIUM").pData, OUString("1").pData); +} +comphelper::ScopeGuard aPDFiumEnvVarGuard([&]() { +if (bResetEnvVar) +osl_clearEnvironment(OUString("LO_IMPORT_USE_PDFIUM").pData); +}); + +// Load the PDF and save as PDF +vcl::filter::PDFDocument aDocument; +load(u"ref-to-kids.pdf", aDocument); + +std::vector aPages = aDocument.GetPages(); +CPPUNIT_ASSERT_EQUAL(size_t(5), aPages.size()); + +// Directly go to the inner XObject Im5 that contains the rectangle drawings. +auto pInnerIm = aDocument.LookupObject(5); +CPPUNIT_ASSERT(pInnerIm); + +auto pFilter = dynamic_cast(pInnerIm->Lookup("Filter")); +CPPUNIT_ASSERT(pFilter); +CPPUNIT_ASSERT_EQUAL_MESSAGE("Filter must be FlateDecode", OString("FlateDecode"), + pFilter->GetValue()); + +vcl::filter::PDFStreamElement* pStream = pInnerIm->GetStream(); +CPPUNIT_ASSERT(pStream); +SvMemoryStream& rObjectStream = pStream->GetMemory(); +// Uncompress it. +SvMemoryStream aUncompressed; +ZCodec aZCodec; +aZCodec.BeginCompression(); +rObjectStream.Seek(0); +aZCodec.Decompress(rObjectStream, aUncompressed); +CPPUNIT_ASSERT(aZCodec.EndCompression()); + +// Without the fix, the stream is doubly compressed, +// hence one decompression will not yield the "re" expressions. +auto pStart = static_cast(aUncompressed.GetData()); +const char* pEnd = pStart + aUncompressed.GetSize(); +OString aImage = "100 0 30 50 re B*\n70 67 50 30 re B*\n"; +auto it = std::search(pStart, pEnd, aImage.getStr(), aImage.getStr() + aImage.getLength()); +CPPUNIT_ASSERT(it != pEnd); +} + } // end anonymous namespace CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/vcl/source/gdi/pdfobjectcopier.cxx b/vcl/source/gdi/pdfobjectcopier.cxx index 93b7b4989710..999be92bd752 100644 --- a/vcl/source/gdi/pdfobjectcopier.cxx +++ b/vcl/source/gdi/pdfobjectcopier.cxx @@ -283,6 +283,14 @@ sal_Int32 PDFObjectCopier::copyPageStreams(std::vectorGetMemory(); auto pFilter = dynamic_cast(pContent->Lookup("Filter")); +auto pFilterArray = dynamic_cast(pContent->Lookup("Filter")); +if (!pFilter && pFilterArray) +{ +auto& aElements = pFilterArray->GetElements(); +if (!aElements.empty()) +pFilter = dynamic_cast(aElements[0]); +} + if (pFilter) { if (pFilter->GetValue() != "FlateDecode")
[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - vcl/qa vcl/source
vcl/qa/cppunit/pdfexport/data/ref-to-kids.pdf |binary vcl/qa/cppunit/pdfexport/pdfexport.cxx| 38 ++ vcl/source/filter/ipdf/pdfdocument.cxx| 21 +- 3 files changed, 58 insertions(+), 1 deletion(-) New commits: commit c4072f9a97ec9eefea9c980016139a7e4c505a03 Author: Dennis Francis AuthorDate: Thu Dec 1 11:18:22 2022 +0530 Commit: Xisco Fauli CommitDate: Wed Dec 21 09:20:32 2022 + vcl: read references to /Kids array... if the argument of /Kids is not an array. Conflicts: vcl/qa/cppunit/pdfexport/pdfexport.cxx Change-Id: Ib73962d3a27aa7e1ce5ddbe6845a1dd73bd7a343 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143559 Tested-by: Jenkins CollaboraOffice Reviewed-by: Miklos Vajna (cherry picked from commit 10185a6aec5d3b74a51e4b9474645e12bf794df8) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144434 Tested-by: Jenkins (cherry picked from commit 9a45d2779ceaa1938feddf820d826922ed17854b) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144656 Reviewed-by: Xisco Fauli diff --git a/vcl/qa/cppunit/pdfexport/data/ref-to-kids.pdf b/vcl/qa/cppunit/pdfexport/data/ref-to-kids.pdf new file mode 100644 index ..598358a636aa Binary files /dev/null and b/vcl/qa/cppunit/pdfexport/data/ref-to-kids.pdf differ diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx index ea8f83e6ba8f..f18077505abd 100644 --- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx +++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx @@ -15,6 +15,7 @@ #include #include +#include #include #include @@ -4098,6 +4099,43 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf139627) / aRect[jehtatweel].getWidth()); #endif } + +CPPUNIT_TEST_FIXTURE(PdfExportTest, testRexportRefToKids) +{ +// We need to enable PDFium import (and make sure to disable after the test) +bool bResetEnvVar = false; +if (getenv("LO_IMPORT_USE_PDFIUM") == nullptr) +{ +bResetEnvVar = true; +osl_setEnvironment(OUString("LO_IMPORT_USE_PDFIUM").pData, OUString("1").pData); +} +comphelper::ScopeGuard aPDFiumEnvVarGuard([&]() { +if (bResetEnvVar) +osl_clearEnvironment(OUString("LO_IMPORT_USE_PDFIUM").pData); +}); + +// Load the PDF and save as PDF +vcl::filter::PDFDocument aDocument; +load(u"ref-to-kids.pdf", aDocument); + +std::vector aPages = aDocument.GetPages(); +CPPUNIT_ASSERT_EQUAL(size_t(5), aPages.size()); + +vcl::filter::PDFObjectElement* pResources = aPages[0]->LookupObject("Resources"); +CPPUNIT_ASSERT(pResources); + +auto pXObjects += dynamic_cast(pResources->Lookup("XObject")); +CPPUNIT_ASSERT(pXObjects); + +// Without the fix LookupObject for all /Im's will fail. +for (auto const& rPair : pXObjects->GetItems()) +{ +if (rPair.first.startsWith("Im")) +CPPUNIT_ASSERT(pXObjects->LookupObject(rPair.first)); +} +} + } // end anonymous namespace CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/vcl/source/filter/ipdf/pdfdocument.cxx b/vcl/source/filter/ipdf/pdfdocument.cxx index 25e731f5352a..19748e241ead 100644 --- a/vcl/source/filter/ipdf/pdfdocument.cxx +++ b/vcl/source/filter/ipdf/pdfdocument.cxx @@ -1918,7 +1918,26 @@ const std::vector>& PDFDocument::GetElements() const /// Visits the page tree recursively, looking for page objects. static void visitPages(PDFObjectElement* pPages, std::vector& rRet) { -auto pKids = dynamic_cast(pPages->Lookup("Kids")); +auto pKidsRef = pPages->Lookup("Kids"); +auto pKids = dynamic_cast(pKidsRef); +if (!pKids) +{ +auto pRefKids = dynamic_cast(pKidsRef); +if (!pRefKids) +{ +SAL_WARN("vcl.filter", "visitPages: pages has no kids"); +return; +} +auto pObjWithKids = pRefKids->LookupObject(); +if (!pObjWithKids) +{ +SAL_WARN("vcl.filter", "visitPages: pages has no kids"); +return; +} + +pKids = pObjWithKids->GetArray(); +} + if (!pKids) { SAL_WARN("vcl.filter", "visitPages: pages has no kids");