summaryrefslogtreecommitdiff
path: root/vcl/qa
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2019-11-06 16:48:55 +0100
committerMiklos Vajna <vmiklos@collabora.com>2019-11-06 17:56:59 +0100
commitbd520b177637d4b7d9d93733103cff17a3c91b0a (patch)
tree9111fcadfebcf18bfed89a3f6397300cf4089589 /vcl/qa
parent032b6698c11f6b6e67fa3a12c2d34f1f7afe63f6 (diff)
vcl PDF export: fix re-exporting PDF images with page-level rotation
PDF images are effectively 1 page PDF documents. The page object may have a /Rotate key, which was simply ignored before. We turn page objects into form XObjects on PDF export, such rotation can be expressed with a /Matrix key. Add support for the 90 degrees rotation case, this can be generalized later if wanted. Change-Id: I55a4f63e0b986637ccdeba0b783f1db9a85c4d93 Reviewed-on: https://gerrit.libreoffice.org/82154 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'vcl/qa')
-rw-r--r--vcl/qa/cppunit/pdfexport/data/pdf-image-resource-inline-xobject-ref.pdfbin1361 -> 1372 bytes
-rw-r--r--vcl/qa/cppunit/pdfexport/pdfexport.cxx28
2 files changed, 28 insertions, 0 deletions
diff --git a/vcl/qa/cppunit/pdfexport/data/pdf-image-resource-inline-xobject-ref.pdf b/vcl/qa/cppunit/pdfexport/data/pdf-image-resource-inline-xobject-ref.pdf
index b62068eae9dd..739a80c4766d 100644
--- a/vcl/qa/cppunit/pdfexport/data/pdf-image-resource-inline-xobject-ref.pdf
+++ b/vcl/qa/cppunit/pdfexport/data/pdf-image-resource-inline-xobject-ref.pdf
Binary files differ
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index ba62f301bec4..22585a9827eb 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -36,6 +36,7 @@
#include <fpdf_doc.h>
#include <fpdfview.h>
#include <vcl/graphicfilter.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
using namespace ::com::sun::star;
@@ -1877,6 +1878,33 @@ void PdfExportTest::testPdfImageResourceInlineXObjectRef()
// - Actual : 0
// i.e. the sub-form was missing its image.
CPPUNIT_ASSERT_EQUAL(1, FPDFFormObj_CountObjects(pFormObject));
+
+ // Check if the inner form object (original page object in the pdf image) has the correct
+ // rotation.
+ FPDF_PAGEOBJECT pInnerFormObject = FPDFFormObj_GetObject(pFormObject, 0);
+ CPPUNIT_ASSERT_EQUAL(FPDF_PAGEOBJ_FORM, FPDFPageObj_GetType(pInnerFormObject));
+ CPPUNIT_ASSERT_EQUAL(1, FPDFFormObj_CountObjects(pInnerFormObject));
+ FPDF_PAGEOBJECT pImage = FPDFFormObj_GetObject(pInnerFormObject, 0);
+ CPPUNIT_ASSERT_EQUAL(FPDF_PAGEOBJ_IMAGE, FPDFPageObj_GetType(pImage));
+ double fA = 0;
+ double fB = 0;
+ double fC = 0;
+ double fD = 0;
+ double fE = 0;
+ double fF = 0;
+ FPDFFormObj_GetMatrix(pInnerFormObject, &fA, &fB, &fC, &fD, &fE, &fF);
+ basegfx::B2DHomMatrix aMat{ fA, fC, fE, fB, fD, fF };
+ basegfx::B2DTuple aScale;
+ basegfx::B2DTuple aTranslate;
+ double fRotate = 0;
+ double fShearX = 0;
+ aMat.decompose(aScale, aTranslate, fRotate, fShearX);
+ int nRotateDeg = basegfx::rad2deg(fRotate);
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected: -90
+ // - Actual : 0
+ // i.e. rotation was lost on pdf export.
+ CPPUNIT_ASSERT_EQUAL(-90, nRotateDeg);
}
CPPUNIT_TEST_SUITE_REGISTRATION(PdfExportTest);