diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2020-06-28 13:46:41 +0200 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2020-06-29 14:36:16 +0200 |
commit | 4e9b03d04f740a0cbafa22a4f3cedfae7f37a994 (patch) | |
tree | 52e23b903d350255937d817fa13f8de15f279119 /vcl/source | |
parent | b5b8da80439419a2daa6a80c9d3979173fe2887a (diff) |
pdf: add text page object attribs, refactor ImpSdrPdfImport, tests
This refactors ImpSdrPdfImport to push more functions into the
PDFium wrapper. The focus is on text page object attributes.
Change-Id: Ie1faf5e3743eec7c77050835651533f9e227c2a7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97366
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl/source')
-rw-r--r-- | vcl/source/pdf/PDFiumLibrary.cxx | 62 |
1 files changed, 59 insertions, 3 deletions
diff --git a/vcl/source/pdf/PDFiumLibrary.cxx b/vcl/source/pdf/PDFiumLibrary.cxx index 0dc36d94b7d0..b58878e7881e 100644 --- a/vcl/source/pdf/PDFiumLibrary.cxx +++ b/vcl/source/pdf/PDFiumLibrary.cxx @@ -253,10 +253,66 @@ std::unique_ptr<PDFiumPageObject> PDFiumPageObject::getFormObject(int nIndex) basegfx::B2DHomMatrix PDFiumPageObject::getMatrix() { + basegfx::B2DHomMatrix aB2DMatrix; FS_MATRIX matrix; - FPDFFormObj_GetMatrix(mpPageObject, &matrix); - return basegfx::B2DHomMatrix::abcdef(matrix.a, matrix.b, matrix.c, matrix.d, matrix.e, - matrix.f); + if (FPDFFormObj_GetMatrix(mpPageObject, &matrix)) + aB2DMatrix = basegfx::B2DHomMatrix::abcdef(matrix.a, matrix.b, matrix.c, matrix.d, matrix.e, + matrix.f); + return aB2DMatrix; +} + +basegfx::B2DRectangle PDFiumPageObject::getBounds() +{ + basegfx::B2DRectangle aB2DRectangle; + + float left = 0; + float bottom = 0; + float right = 0; + float top = 0; + if (FPDFPageObj_GetBounds(mpPageObject, &left, &bottom, &right, &top)) + { + aB2DRectangle = basegfx::B2DRectangle(left, top, right, bottom); + } + return aB2DRectangle; +} + +double PDFiumPageObject::getFontSize() { return FPDFTextObj_GetFontSize(mpPageObject); } + +OUString PDFiumPageObject::getFontName() +{ + OUString sFontName; + const int nFontName = 80 + 1; + std::unique_ptr<char[]> pFontName(new char[nFontName]); // + terminating null + int nFontNameChars = FPDFTextObj_GetFontName(mpPageObject, pFontName.get(), nFontName); + if (nFontName >= nFontNameChars) + { + sFontName = OUString::createFromAscii(pFontName.get()); + } + return sFontName; +} + +int PDFiumPageObject::getTextRenderMode() { return FPDFTextObj_GetTextRenderMode(mpPageObject); } + +Color PDFiumPageObject::getFillColor() +{ + Color aColor = COL_TRANSPARENT; + unsigned int nR, nG, nB, nA; + if (FPDFPageObj_GetFillColor(mpPageObject, &nR, &nG, &nB, &nA)) + { + aColor = Color(0xFF - nA, nR, nG, nB); + } + return aColor; +} + +Color PDFiumPageObject::getStrokeColor() +{ + Color aColor = COL_TRANSPARENT; + unsigned int nR, nG, nB, nA; + if (FPDFPageObj_GetStrokeColor(mpPageObject, &nR, &nG, &nB, &nA)) + { + aColor = Color(0xFF - nA, nR, nG, nB); + } + return aColor; } PDFiumAnnotation::PDFiumAnnotation(FPDF_ANNOTATION pAnnotation) |