[Libreoffice-commits] core.git: svx/source vcl/qa

2022-12-01 Thread Michael Stahl (via logerrit)
 svx/source/sdr/contact/viewobjectcontact.cxx   |2 
 svx/source/table/viewcontactoftableobj.cxx |   30 ++-
 vcl/qa/cppunit/pdfexport/data/tdf135192-1.fodp |  239 +
 vcl/qa/cppunit/pdfexport/pdfexport.cxx |   95 +
 4 files changed, 364 insertions(+), 2 deletions(-)

New commits:
commit 56ff8262d8ace8fd99326e290597cb901654ea11
Author: Michael Stahl 
AuthorDate: Wed Nov 30 13:59:53 2022 +0100
Commit: Michael Stahl 
CommitDate: Thu Dec 1 17:01:20 2022 +0100

tdf#135192 svx: PDF/UA export: implement tags for SdrTableObj

There seems to be no way to check for isExportTaggedPDF() in
ViewContactOfTableObj::createViewIndependentPrimitive2DSequence()
so simply always add the tags.

Change-Id: I816ed1f3811c4efad6ca28366591d135bf823c5a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143499
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/svx/source/sdr/contact/viewobjectcontact.cxx 
b/svx/source/sdr/contact/viewobjectcontact.cxx
index 8580603850ea..9d88819a9fe2 100644
--- a/svx/source/sdr/contact/viewobjectcontact.cxx
+++ b/svx/source/sdr/contact/viewobjectcontact.cxx
@@ -400,6 +400,8 @@ drawinglayer::primitive2d::Primitive2DContainer const & 
ViewObjectContact::getPr
 {
 if ( nIdentifier == SdrObjKind::Group )
 eElement = vcl::PDFWriter::Section;
+else if (nIdentifier == SdrObjKind::Table)
+eElement = vcl::PDFWriter::Table;
 else if ( nIdentifier == SdrObjKind::TitleText )
 eElement = vcl::PDFWriter::Heading;
 else if ( nIdentifier == SdrObjKind::OutlineText )
diff --git a/svx/source/table/viewcontactoftableobj.cxx 
b/svx/source/table/viewcontactoftableobj.cxx
index 2d71f83ef337..df271a3e2404 100644
--- a/svx/source/table/viewcontactoftableobj.cxx
+++ b/svx/source/table/viewcontactoftableobj.cxx
@@ -33,8 +33,10 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -217,6 +219,7 @@ namespace sdr::contact
 const sal_Int32 nRowCount(xTable->getRowCount());
 const sal_Int32 nColCount(xTable->getColumnCount());
 const sal_Int32 nAllCount(nRowCount * nColCount);
+SdrPage const*const pPage(rTableObj.getSdrPageFromSdrObject());
 
 if(nAllCount)
 {
@@ -230,7 +233,7 @@ namespace sdr::contact
 // GetGeoRect() to not trigger any calculations. It's the 
unrotated geometry.
 const basegfx::B2DRange aObjectRange = 
vcl::unotools::b2DRectangleFromRectangle(rTableObj.GetGeoRect());
 
-// To create the CellBorderPrimitives, use the tolling 
from svx::frame::Array
+// To create the CellBorderPrimitives, use the tooling 
from svx::frame::Array
 // which is capable of creating the needed visualization. 
Fill it during the
 // anyways needed run over the table.
 svx::frame::Array aArray;
@@ -241,11 +244,13 @@ namespace sdr::contact
 // create single primitives per cell
 for(aCellPos.mnRow = 0; aCellPos.mnRow < nRowCount; 
aCellPos.mnRow++)
 {
+drawinglayer::primitive2d::Primitive2DContainer row;
 // add RowHeight to CellBorderArray for primitive 
creation
 aArray.SetRowHeight(aCellPos.mnRow, 
rTableLayouter.getRowHeight(aCellPos.mnRow));
 
 for(aCellPos.mnCol = 0; aCellPos.mnCol < nColCount; 
aCellPos.mnCol++)
 {
+drawinglayer::primitive2d::Primitive2DContainer 
cell;
 // add ColWidth to CellBorderArray for primitive 
creation, only
 // needs to be done in the 1st run
 if(0 == aCellPos.mnRow)
@@ -324,7 +329,7 @@ namespace sdr::contact
 const 
drawinglayer::primitive2d::Primitive2DReference xCellReference(
 new 
drawinglayer::primitive2d::SdrCellPrimitive2D(
 aCellMatrix, aAttribute));
-aRetval.append(xCellReference);
+cell.append(xCellReference);
 }
 
 // Create cell primitive without text.
@@ -347,7 +352,28 @@ namespace sdr::contact
 aRetvalForShadow.append(xCellReference);
 }
 }
+if (pPage)
+{
+cell = 
drawinglayer::primitive2d::Primitive2DContainer {
+  

[Libreoffice-commits] core.git: svx/source vcl/qa

2020-12-10 Thread Miklos Vajna (via logerrit)
 svx/source/svdraw/svdpdf.cxx   |   16 +++-
 vcl/qa/cppunit/pdfexport/pdfexport.cxx |   22 --
 2 files changed, 15 insertions(+), 23 deletions(-)

New commits:
commit 106a9e98c864fe07bf91331d510dd41e3801c6eb
Author: Miklos Vajna 
AuthorDate: Wed Dec 9 21:58:36 2020 +0100
Commit: Miklos Vajna 
CommitDate: Thu Dec 10 09:17:55 2020 +0100

pdfium: no need to use FPDFPageObj_GetBounds() directly

Change-Id: I74f968e0b76a2992d5f07524a29a7c8600983d3c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107509
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 

diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx
index 6f2f1de42f72..e1ae905cef33 100644
--- a/svx/source/svdraw/svdpdf.cxx
+++ b/svx/source/svdraw/svdpdf.cxx
@@ -914,15 +914,13 @@ void 
ImpSdrPdfImport::ImportImage(std::unique_ptr co
 break;
 }
 
-float left;
-float bottom;
-float right;
-float top;
-if (!FPDFPageObj_GetBounds(pPageObject->getPointer(), &left, &bottom, 
&right, &top))
-{
-SAL_WARN("sd.filter", "FAILED to get image bounds");
-}
-
+basegfx::B2DRectangle aBounds = pPageObject->getBounds();
+float left = aBounds.getMinX();
+// Upside down.
+float bottom = aBounds.getMinY();
+float right = aBounds.getMaxX();
+// Upside down.
+float top = aBounds.getMaxY();
 tools::Rectangle aRect = PointsToLogic(left, right, top, bottom);
 aRect.AdjustRight(1);
 aRect.AdjustBottom(1);
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index 7af85573be40..69b7d17711a2 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -1535,9 +1535,8 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf106702)
 if (pPageObject->getType() != vcl::pdf::PDFPageObjectType::Image)
 continue;
 
-float fLeft = 0, fBottom = 0, fRight = 0, fTop = 0;
-FPDFPageObj_GetBounds(pPageObject->getPointer(), &fLeft, &fBottom, 
&fRight, &fTop);
-nExpected = fTop;
+// Top, but upside down.
+nExpected = pPageObject->getBounds().getMaxY();
 break;
 }
 
@@ -1552,9 +1551,8 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf106702)
 if (pPageObject->getType() != vcl::pdf::PDFPageObjectType::Image)
 continue;
 
-float fLeft = 0, fBottom = 0, fRight = 0, fTop = 0;
-FPDFPageObj_GetBounds(pPageObject->getPointer(), &fLeft, &fBottom, 
&fRight, &fTop);
-nActual = fTop;
+// Top, but upside down.
+nActual = pPageObject->getBounds().getMaxY();
 break;
 }
 
@@ -1593,9 +1591,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf113143)
 if (pPageObject->getType() != vcl::pdf::PDFPageObjectType::Image)
 continue;
 
-float fLeft = 0, fBottom = 0, fRight = 0, fTop = 0;
-FPDFPageObj_GetBounds(pPageObject->getPointer(), &fLeft, &fBottom, 
&fRight, &fTop);
-nLarger = fRight - fLeft;
+nLarger = pPageObject->getBounds().getWidth();
 break;
 }
 
@@ -1610,9 +1606,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf113143)
 if (pPageObject->getType() != vcl::pdf::PDFPageObjectType::Image)
 continue;
 
-float fLeft = 0, fBottom = 0, fRight = 0, fTop = 0;
-FPDFPageObj_GetBounds(pPageObject->getPointer(), &fLeft, &fBottom, 
&fRight, &fTop);
-nSmaller = fRight - fLeft;
+nSmaller = pPageObject->getBounds().getWidth();
 break;
 }
 
@@ -1652,8 +1646,8 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf115262)
 for (int i = 0; i < nPageObjectCount; ++i)
 {
 std::unique_ptr pPageObject = 
pPdfPage->getObject(i);
-float fLeft = 0, fBottom = 0, fRight = 0, fTop = 0;
-FPDFPageObj_GetBounds(pPageObject->getPointer(), &fLeft, &fBottom, 
&fRight, &fTop);
+// Top, but upside down.
+float fTop = pPageObject->getBounds().getMaxY();
 
 if (pPageObject->getType() == vcl::pdf::PDFPageObjectType::Image)
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: svx/source vcl/qa

2020-05-03 Thread Andrea Gelmini (via logerrit)
 svx/source/svdraw/svdpdf.cxx   |4 ++--
 vcl/qa/cppunit/pdfexport/pdfexport.cxx |2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

New commits:
commit a162f0f036fa1d0dc4dcd63c7859bda0b5702247
Author: Andrea Gelmini 
AuthorDate: Sun May 3 22:49:28 2020 +0200
Commit: Andrea Gelmini 
CommitDate: Mon May 4 07:01:22 2020 +0200

Fix typos

Change-Id: I63ae6adec1967bcf888538437e5e88f0acdea66e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93392
Tested-by: Jenkins
Reviewed-by: Andrea Gelmini 

diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx
index 7e4a3e6a5345..ad3a89ed9c02 100644
--- a/svx/source/svdraw/svdpdf.cxx
+++ b/svx/source/svdraw/svdpdf.cxx
@@ -807,9 +807,9 @@ void ImpSdrPdfImport::ImportText(FPDF_PAGEOBJECT 
pPageObject, FPDF_TEXTPAGE pTex
 return;
 }
 
-// Let's rely on null-terminaton for the length of the string. We
+// Let's rely on null-termination for the length of the string. We
 // just know the number of bytes the string takes, but in OUString
-// needs the number of charaters.
+// needs the number of characters.
 OUString sText(pText.get());
 
 const double dFontSize = FPDFTextObj_GetFontSize(pPageObject);
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index 346a8646abb9..ab5333498649 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -2161,7 +2161,7 @@ void PdfExportTest::testVersion15()
 // Check round-trip of importing and exporting the PDF with PDFium filter,
 // which imports the PDF document as multiple PDFs as graphic object.
 // Each page in the document has one PDF graphic object which content is
-// the correcponding page in the PDF. When such a document is exported,
+// the corresponding page in the PDF. When such a document is exported,
 // the PDF graphic gets embedded into the exported PDF document (as a
 // Form XObject).
 void PdfExportTest::testMultiPagePDF()
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: svx/source vcl/qa vcl/source

2017-04-11 Thread Miklos Vajna
 svx/source/xml/xmlgrhlp.cxx|   15 
 vcl/qa/cppunit/pdfexport/pdfexport.cxx |7 --
 vcl/source/filter/ipdf/pdfread.cxx |  107 +++--
 vcl/source/gdi/pdfwriter_impl.cxx  |   32 -
 4 files changed, 123 insertions(+), 38 deletions(-)

New commits:
commit 37bdf1659ddb11d8706289511623cc7c8b0d264b
Author: Miklos Vajna 
Date:   Tue Apr 11 16:50:53 2017 +0200

Related: tdf#106972 vcl PDF import: downgrade PDF >= 1.5

There are two problems with these newer PDF versions:

- the current PDF export code doesn't know how to roundtrip such PDF
  images (needs work on both the import and export side)
- upgrading the default PDF export version would upset readers who can't
  parse PDF >= 1.5

So instead of raising the default PDF export version, for now just be
conservative and depend on pdfium to downgrade the PDF image version to
1.4 if it would be higher.

Given that this modifies the input of the graphic filter this also needs
changes in the ODF export, so that the filter result will contain that
downgraded data, not the original one.

Change-Id: I1efa97af8110e9a6ee3e8a7339bcc7d70457cfb0
Reviewed-on: https://gerrit.libreoffice.org/36413
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins 

diff --git a/svx/source/xml/xmlgrhlp.cxx b/svx/source/xml/xmlgrhlp.cxx
index 04b92711aa69..3946bb94c3c0 100644
--- a/svx/source/xml/xmlgrhlp.cxx
+++ b/svx/source/xml/xmlgrhlp.cxx
@@ -555,7 +555,20 @@ bool SvXMLGraphicHelper::ImplWriteGraphic( const OUString& 
rPictureStorageName,
 
 std::unique_ptr 
pStream(utl::UcbStreamHelper::CreateStream( aStream.xStream ));
 if( bUseGfxLink && aGfxLink.GetDataSize() && aGfxLink.GetData() )
-pStream->WriteBytes(aGfxLink.GetData(), 
aGfxLink.GetDataSize());
+{
+const uno::Sequence& rPdfData = 
aGraphic.getPdfData();
+if (rPdfData.hasElements())
+{
+// The graphic has PDF data attached to it, use that.
+// vcl::ImportPDF() possibly downgraded the PDF data from a
+// higher PDF version, while aGfxLink still contains the
+// original data provided by the user.
+pStream->WriteBytes(rPdfData.getConstArray(), 
rPdfData.getLength());
+bRet = (pStream->GetError() == 0);
+}
+else
+pStream->WriteBytes(aGfxLink.GetData(), 
aGfxLink.GetDataSize());
+}
 else
 {
 if( aGraphic.GetType() == GraphicType::Bitmap )
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index 1b9eaf153d2c..76cad0f2a9af 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -383,10 +383,9 @@ void PdfExportTest::testTdf106972Pdf17()
 vcl::filter::PDFObjectElement* pXObject = 
pXObjects->LookupObject(pXObjects->GetItems().begin()->first);
 CPPUNIT_ASSERT(pXObject);
 
-// This failed, the "image" had resources; that typically means we tried to
-// preserve the original PDF markup here; which is not OK till our default
-// output is PDF 1.4, and this bugdoc has PDF 1.7 data.
-CPPUNIT_ASSERT(!pXObject->Lookup("Resources"));
+// Assert that we now attempt to preserve the original PDF data, even if
+// the original input was PDF >= 1.4.
+CPPUNIT_ASSERT(pXObject->Lookup("Resources"));
 }
 
 void PdfExportTest::testTdf107013()
diff --git a/vcl/source/filter/ipdf/pdfread.cxx 
b/vcl/source/filter/ipdf/pdfread.cxx
index b2f68d02b07e..f1a7e2b52a17 100644
--- a/vcl/source/filter/ipdf/pdfread.cxx
+++ b/vcl/source/filter/ipdf/pdfread.cxx
@@ -14,6 +14,7 @@
 #if HAVE_FEATURE_PDFIUM
 #include 
 #include 
+#include 
 #endif
 
 #include 
@@ -25,6 +26,29 @@ namespace
 
 #if HAVE_FEATURE_PDFIUM
 
+/// Callback class to be used with FPDF_SaveWithVersion().
+struct CompatibleWriter : public FPDF_FILEWRITE
+{
+public:
+CompatibleWriter();
+static int WriteBlockCallback(FPDF_FILEWRITE* pFileWrite, const void* 
pData, unsigned long nSize);
+
+SvMemoryStream m_aStream;
+};
+
+CompatibleWriter::CompatibleWriter()
+{
+FPDF_FILEWRITE::version = 1;
+FPDF_FILEWRITE::WriteBlock = CompatibleWriter::WriteBlockCallback;
+}
+
+int CompatibleWriter::WriteBlockCallback(FPDF_FILEWRITE* pFileWrite, const 
void* pData, unsigned long nSize)
+{
+auto pImpl = static_cast(pFileWrite);
+pImpl->m_aStream.WriteBytes(pData, nSize);
+return 1;
+}
+
 /// Convert to inch, then assume 96 DPI.
 double pointToPixel(double fPoint)
 {
@@ -88,6 +112,70 @@ bool generatePreview(SvStream& rStream, Graphic& rGraphic)
 
 return true;
 }
+
+/// Decide if PDF data is old enough to be compatible.
+bool isCompatible(SvStream& rInStream)
+{
+// %PDF-x.y
+sal_uInt8 aFirstBytes[8];
+r