From 0ce7e25c0d320da58d5de1d2d16bfddcbe29538c Mon Sep 17 00:00:00 2001 From: Ashod Nakashian Date: Sun, 8 Apr 2018 20:34:29 -0400 Subject: svx: import PDF text using PDFium Change-Id: I7c75477f5257931f5182b8d65e898857526bf555 --- .../0001-svx-import-PDF-text-using-PDFium.patch.2 | 177 +++++++++++++++++++++ external/pdfium/UnpackedTarball_pdfium.mk | 2 + sd/source/filter/pdf/sdpdffilter.cxx | 13 +- svx/source/svdraw/svdpdf.cxx | 137 ++++++++++------ svx/source/svdraw/svdpdf.hxx | 4 + 5 files changed, 277 insertions(+), 56 deletions(-) create mode 100644 external/pdfium/0001-svx-import-PDF-text-using-PDFium.patch.2 diff --git a/external/pdfium/0001-svx-import-PDF-text-using-PDFium.patch.2 b/external/pdfium/0001-svx-import-PDF-text-using-PDFium.patch.2 new file mode 100644 index 000000000000..9b0971cf4156 --- /dev/null +++ b/external/pdfium/0001-svx-import-PDF-text-using-PDFium.patch.2 @@ -0,0 +1,177 @@ +From 99fa46eba9be11aa2bd9ef0e21a126656c932c44 Mon Sep 17 00:00:00 2001 +From: Ashod Nakashian +Date: Tue, 5 Jun 2018 11:27:43 +0200 +Subject: [PATCH 01/14] svx: import PDF text using PDFium + +--- + pdfium/core/fpdfapi/page/cpdf_imageobject.cpp | 1 + + pdfium/core/fpdfapi/page/cpdf_pageobject.cpp | 2 ++ + pdfium/core/fpdfapi/render/cpdf_renderstatus.cpp | 1 + + pdfium/fpdfsdk/fpdf_editpage.cpp | 18 ++++++++++++++++++ + pdfium/fpdfsdk/fpdf_text.cpp | 22 ++++++++++++++++++++++ + pdfium/public/fpdf_edit.h | 15 +++++++++++++++ + pdfium/public/fpdf_text.h | 20 ++++++++++++++++++++ + 7 files changed, 79 insertions(+) + +diff --git a/pdfium/core/fpdfapi/page/cpdf_imageobject.cpp b/pdfium/core/fpdfapi/page/cpdf_imageobject.cpp +index 3b5a740..58ef90a 100644 +--- a/pdfium/core/fpdfapi/page/cpdf_imageobject.cpp ++++ b/pdfium/core/fpdfapi/page/cpdf_imageobject.cpp +@@ -43,6 +43,7 @@ const CPDF_ImageObject* CPDF_ImageObject::AsImage() const { + void CPDF_ImageObject::CalcBoundingBox() { + std::tie(m_Left, m_Right, m_Top, m_Bottom) = + m_Matrix.TransformRect(0.f, 1.f, 1.f, 0.f); ++ fprintf(stderr, "Image BB: %f, %f, %f, %f\n", m_Left, m_Right, m_Top, m_Bottom); + } + + void CPDF_ImageObject::SetImage(const RetainPtr& pImage) { +diff --git a/pdfium/core/fpdfapi/page/cpdf_pageobject.cpp b/pdfium/core/fpdfapi/page/cpdf_pageobject.cpp +index 8bb5bf5..9b5e2ce 100644 +--- a/pdfium/core/fpdfapi/page/cpdf_pageobject.cpp ++++ b/pdfium/core/fpdfapi/page/cpdf_pageobject.cpp +@@ -98,5 +98,7 @@ FX_RECT CPDF_PageObject::GetBBox(const CFX_Matrix* pMatrix) const { + if (pMatrix) + rect = pMatrix->TransformRect(rect); + ++ FX_RECT rc = rect.GetOuterRect(); ++ fprintf(stderr, "PageObject BB: %f, %f, %f, %f\n", rc.left, rc.right, rc.top, rc.bottom); + return rect.GetOuterRect(); + } +diff --git a/pdfium/core/fpdfapi/render/cpdf_renderstatus.cpp b/pdfium/core/fpdfapi/render/cpdf_renderstatus.cpp +index 565be85..87301d3 100644 +--- a/pdfium/core/fpdfapi/render/cpdf_renderstatus.cpp ++++ b/pdfium/core/fpdfapi/render/cpdf_renderstatus.cpp +@@ -1767,6 +1767,7 @@ bool CPDF_RenderStatus::ProcessText(CPDF_TextObject* textobj, + return true; + + float font_size = textobj->m_TextState.GetFontSize(); ++ fprintf(stderr, "Font size: %f, matrix a: %f, b: %f, c: %f, d: %f, e: %f, f: %f\n", font_size, text_matrix.a, text_matrix.b, text_matrix.c, text_matrix.d, text_matrix.e, text_matrix.f); + if (bPattern) { + DrawTextPathWithPattern(textobj, pObj2Device, pFont, font_size, + &text_matrix, bFill, bStroke); +diff --git a/pdfium/fpdfsdk/fpdf_editpage.cpp b/pdfium/fpdfsdk/fpdf_editpage.cpp +index ec29891..912df63 100644 +--- a/pdfium/fpdfsdk/fpdf_editpage.cpp ++++ b/pdfium/fpdfsdk/fpdf_editpage.cpp +@@ -18,6 +18,7 @@ + #include "core/fpdfapi/page/cpdf_page.h" + #include "core/fpdfapi/page/cpdf_pageobject.h" + #include "core/fpdfapi/page/cpdf_pathobject.h" ++#include "core/fpdfapi/page/cpdf_textobject.h" + #include "core/fpdfapi/page/cpdf_shadingobject.h" + #include "core/fpdfapi/parser/cpdf_array.h" + #include "core/fpdfapi/parser/cpdf_document.h" +@@ -624,3 +625,20 @@ FPDFPageObj_SetLineCap(FPDF_PAGEOBJECT page_object, int line_cap) { + pPageObj->SetDirty(true); + return true; + } ++ ++FPDF_EXPORT void FPDF_CALLCONV ++FPDFTextObj_GetMatrix(FPDF_PAGEOBJECT text_object, ++ double* a, ++ double* b, ++ double* c, ++ double* d) { ++ if (!text_object) ++ return; ++ ++ CPDF_TextObject* pTxtObj = static_cast(text_object); ++ const CFX_Matrix& matrix = pTxtObj->GetTextMatrix(); ++ *a = matrix.a; ++ *b = matrix.b; ++ *c = matrix.c; ++ *d = matrix.d; ++} +diff --git a/pdfium/fpdfsdk/fpdf_text.cpp b/pdfium/fpdfsdk/fpdf_text.cpp +index a1bbbb4..01b74c9 100644 +--- a/pdfium/fpdfsdk/fpdf_text.cpp ++++ b/pdfium/fpdfsdk/fpdf_text.cpp +@@ -95,6 +95,28 @@ FPDF_EXPORT double FPDF_CALLCONV FPDFText_GetFontSize(FPDF_TEXTPAGE text_page, + return charinfo.m_FontSize; + } + ++FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFText_GetMatrix(FPDF_TEXTPAGE text_page, ++ int index, ++ double* a, ++ double* b, ++ double* c, ++ double* d) { ++ if (!text_page || index < 0) ++ return false; ++ ++ CPDF_TextPage* textpage = CPDFTextPageFromFPDFTextPage(text_page); ++ if (index >= textpage->CountChars()) ++ return false; ++ ++ FPDF_CHAR_INFO charinfo; ++ textpage->GetCharInfo(index, &charinfo); ++ *a = charinfo.m_Matrix.a; ++ *b = charinfo.m_Matrix.b; ++ *c = charinfo.m_Matrix.c; ++ *d = charinfo.m_Matrix.d; ++ return true; ++} ++ + FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFText_GetCharBox(FPDF_TEXTPAGE text_page, + int index, + double* left, +diff --git a/pdfium/public/fpdf_edit.h b/pdfium/public/fpdf_edit.h +index c0766a3..3f45495 100644 +--- a/pdfium/public/fpdf_edit.h ++++ b/pdfium/public/fpdf_edit.h +@@ -971,6 +971,21 @@ FPDFPageObj_CreateTextObj(FPDF_DOCUMENT document, + FPDF_FONT font, + float font_size); + ++// Get the matrix of a particular text object. ++// ++// text_object - Handle of text object returned by FPDFPageObj_NewTextObj ++// or FPDFPageObj_NewTextObjEx. ++// a - Pointer to a double value receiving coefficient "a" of the matrix. ++// b - Pointer to a double value receiving coefficient "b" of the matrix. ++// c - Pointer to a double value receiving coefficient "c" of the matrix. ++// d - Pointer to a double value receiving coefficient "d" of the matrix. ++FPDF_EXPORT void FPDF_CALLCONV ++FPDFTextObj_GetMatrix(FPDF_PAGEOBJECT text_object, ++ double* a, ++ double* b, ++ double* c, ++ double* d); ++ + #ifdef __cplusplus + } // extern "C" + #endif // __cplusplus +diff --git a/pdfium/public/fpdf_text.h b/pdfium/public/fpdf_text.h +index 3502337..6524cd3 100644 +--- a/pdfium/public/fpdf_text.h ++++ b/pdfium/public/fpdf_text.h +@@ -342,6 +342,26 @@ FPDF_EXPORT int FPDF_CALLCONV FPDFText_GetSchCount(FPDF_SCHHANDLE handle); + // + FPDF_EXPORT void FPDF_CALLCONV FPDFText_FindClose(FPDF_SCHHANDLE handle); + ++// Get the matrix of a particular character. ++// ++// text_page - Handle to a text page information structure. ++// Returned by FPDFText_LoadPage function. ++// index - Zero-based index of the character ++// a - Pointer to a double value receiving coefficient "a" of the matrix. ++// b - Pointer to a double value receiving coefficient "b" of the matrix. ++// c - Pointer to a double value receiving coefficient "c" of the matrix. ++// d - Pointer to a double value receiving coefficient "d" of the matrix. ++// ++// Return Value: ++// On success, return TRUE and fill in |a|, |b|, |c|, and |d| ++FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV ++FPDFText_GetMatrix(FPDF_TEXTPAGE text_page, ++ int index, ++ double* a, ++ double* b, ++ double* c, ++ double* d); ++ + // Function: FPDFLink_LoadWebLinks + // Prepare information about weblinks in a page. + // Parameters: +-- +2.16.3 + diff --git a/external/pdfium/UnpackedTarball_pdfium.mk b/external/pdfium/UnpackedTarball_pdfium.mk index 2ac8404e3164..58c014f41252 100644 --- a/external/pdfium/UnpackedTarball_pdfium.mk +++ b/external/pdfium/UnpackedTarball_pdfium.mk @@ -13,6 +13,8 @@ pdfium_patches += ubsan.patch pdfium_patches += icu.patch.1 # Fixes build on our baseline. pdfium_patches += build.patch.1 +# Adds missing editing API +pdfium_patches += 0001-svx-import-PDF-text-using-PDFium.patch.2 $(eval $(call gb_UnpackedTarball_UnpackedTarball,pdfium)) diff --git a/sd/source/filter/pdf/sdpdffilter.cxx b/sd/source/filter/pdf/sdpdffilter.cxx index a9ccb82633c0..0ba79eaddf71 100644 --- a/sd/source/filter/pdf/sdpdffilter.cxx +++ b/sd/source/filter/pdf/sdpdffilter.cxx @@ -128,11 +128,13 @@ bool SdPdfFilter::Import() // Create the page and insert the Graphic. SdPage* pPage = mrDocument.GetSdPage(nPageNumber++, PageKind::Standard); - Point aPos; - Size aPagSize(pPage->GetSize()); + + SAL_WARN("sd.filter", "Graphic PrefSize: " << aGraphic.GetPrefSize()); Size aGrfSize(OutputDevice::LogicToLogic(aGraphic.GetPrefSize(), aGraphic.GetPrefMapMode(), MapMode(MapUnit::Map100thMM))); + SAL_WARN("sd.filter", "Graphic Logic Size: " << aGrfSize); + Size aPagSize(pPage->GetSize()); aPagSize.AdjustWidth(-(pPage->GetLeftBorder() + pPage->GetRightBorder())); aPagSize.AdjustHeight(-(pPage->GetUpperBorder() + pPage->GetLowerBorder())); @@ -140,8 +142,8 @@ bool SdPdfFilter::Import() if (((aGrfSize.Height() > aPagSize.Height()) || (aGrfSize.Width() > aPagSize.Width())) && aGrfSize.Height() && aPagSize.Height()) { - double fGrfWH = static_cast(aGrfSize.Width()) / aGrfSize.Height(); - double fWinWH = static_cast(aPagSize.Width()) / aPagSize.Height(); + const double fGrfWH = static_cast(aGrfSize.Width()) / aGrfSize.Height(); + const double fWinWH = static_cast(aPagSize.Width()) / aPagSize.Height(); // adjust graphic to page size (scales) if (fGrfWH < fWinWH) @@ -157,9 +159,12 @@ bool SdPdfFilter::Import() } // set output rectangle for graphic + Point aPos; aPos.setX(((aPagSize.Width() - aGrfSize.Width()) >> 1) + pPage->GetLeftBorder()); aPos.setY(((aPagSize.Height() - aGrfSize.Height()) >> 1) + pPage->GetUpperBorder()); + SAL_WARN("sd.filter", "Graphic Pos: " << aPos); + SAL_WARN("sd.filter", "Graphic Logic Size: " << aGrfSize); pPage->InsertObject(new SdrGrafObj(pPage->getSdrModelFromSdrPage(), aGraphic, ::tools::Rectangle(aPos, aGrfSize))); } diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx index 9c14385a8b38..89f89d0e7050 100644 --- a/svx/source/svdraw/svdpdf.cxx +++ b/svx/source/svdraw/svdpdf.cxx @@ -256,35 +256,45 @@ void ImpSdrPdfImport::DoLoopActions(SvdProgressInfo* pProgrInfo, sal_uInt32* pAc } } - /* // Now do the text. FPDF_TEXTPAGE pTextPage = FPDFText_LoadPage(pPdfPage); if (pTextPage != nullptr) { + SAL_WARN("sd.filter", "TEXT TEXT TEXT"); + const int nChars = FPDFText_CountChars(pTextPage); SAL_WARN("sd.filter", "Got page chars: " << nChars); const int nRects = FPDFText_CountRects(pTextPage, 0, nChars); SAL_WARN("sd.filter", "Got Rects: " << nRects); - std::unique_ptr pText(new sal_Unicode[nChars]); + std::unique_ptr pText(new sal_Unicode[nChars + 1]); // + terminating null for (int nRectIndex = 0; nRectIndex < nRects; ++nRectIndex) { + SAL_WARN("sd.filter", + "Processing Text Rect #" << nRectIndex + 1 << " of " << nRects); + double left = 0; double top = 0; double right = 0; double bottom = 0; FPDFText_GetRect(pTextPage, nRectIndex, &left, &top, &right, &bottom); + SAL_WARN("sd.filter", "Got Text Rect: " << left << ", " << right << ", " << top + << ", " << bottom); + tools::Rectangle aRect = PointsToLogic(left, right, top, bottom); + if (right < left) std::swap(right, left); if (bottom < top) std::swap(bottom, top); - SAL_WARN("sd.filter", "Got Text Rect: " << left << ", " << top << ", " << right + SAL_WARN("sd.filter", "Got Text Rect: " << left << ", " << right << ", " << top << ", " << bottom); - const int nBoundedChars = FPDFText_GetBoundedText( - pTextPage, left, top, right, bottom, - reinterpret_cast(pText.get()), nChars); + SAL_WARN("sd.filter", "Logic Text Rect: " << aRect); + + unsigned short* pShortText = reinterpret_cast(pText.get()); + const int nBoundedChars = FPDFText_GetBoundedText(pTextPage, left, top, right, + bottom, pShortText, nChars); OUString sText(pText.get(), nBoundedChars); SAL_WARN("sd.filter", "Got Text #" << nRectIndex + 1 << " (" << nBoundedChars << "): [" << sText << "]."); @@ -307,8 +317,34 @@ void ImpSdrPdfImport::DoLoopActions(SvdProgressInfo* pProgrInfo, sal_uInt32* pAc // aFontMetric.SetAscent(nFontAscent); // aFontMetric.SetDescent(nFontDescent); - const double dFontSize = FPDFText_GetFontSize(pTextPage, nCharIndex) * 140; + double dFontScale = 1.0; + geometry::Matrix2D aMatrix; + if (!FPDFText_GetMatrix(pTextPage, nCharIndex, &aMatrix.m00, &aMatrix.m01, + &aMatrix.m10, &aMatrix.m11)) + { + SAL_WARN("sd.filter", "No font scale matrix, will use heuristic height of " + << aRect.GetHeight() << "."); + dFontScale = aRect.GetHeight(); + } + else if (aMatrix.m00 != aMatrix.m11 || aMatrix.m00 <= 0) + { + SAL_WARN("sd.filter", "Bogus font scale matrix (" + << aMatrix.m00 << ',' << aMatrix.m11 + << "), will use heuristic height of " + << aRect.GetHeight() << "."); + dFontScale = aRect.GetHeight(); + } + else + dFontScale = aMatrix.m00; + + double dFontSize = FPDFText_GetFontSize(pTextPage, nCharIndex); SAL_WARN("sd.filter", "Got Font Size: " << dFontSize); + dFontSize *= dFontScale; + SAL_WARN("sd.filter", "Got Font Size Scaled: " << dFontSize); + dFontSize = lcl_PointToPixel(dFontSize); + SAL_WARN("sd.filter", "Got Font Pixel Size: " << dFontSize); + dFontSize = lcl_ToLogic(dFontSize); + SAL_WARN("sd.filter", "Got Font Logic Size: " << dFontSize); vcl::Font aFnt = mpVD->GetFont(); aFnt.SetFontSize(Size(dFontSize, dFontSize)); mpVD->SetFont(aFnt); @@ -317,6 +353,9 @@ void ImpSdrPdfImport::DoLoopActions(SvdProgressInfo* pProgrInfo, sal_uInt32* pAc double y = 0; FPDFText_GetCharOrigin(pTextPage, nCharIndex, &x, &y); SAL_WARN("sd.filter", "Got Char Origin: " << x << ", " << y); + Point aPos = PointsToLogic(x, y); + SAL_WARN("sd.filter", "Got Char Origin Logic: " << aPos); + // aRect.Move(aPos.X(), aPos.Y()); // geometry::RealRectangle2D aRect; // aRect.X1 = left; @@ -362,14 +401,13 @@ void ImpSdrPdfImport::DoLoopActions(SvdProgressInfo* pProgrInfo, sal_uInt32* pAc // double charWidth = offsetMatrix2.get(0, 2); // double prevSpaceWidth = offsetMatrix1.get(0, 2) - prevCharWidth; - ImportText(Point(x, y), sText); + ImportText(aRect.TopLeft(), sText); } FPDFText_ClosePage(pTextPage); } FPDF_ClosePage(pPdfPage); -*/ } // const sal_uLong nCount(rMtf.GetActionSize()); @@ -988,6 +1026,7 @@ void ImpSdrPdfImport::ImportText(const Point& rPos, const OUString& rStr) Point aPos(FRound(rPos.X() * mfScaleX + maOfs.X()), FRound(rPos.Y() * mfScaleY + maOfs.Y())); Size aSize(nTextWidth, nTextHeight); + SAL_WARN("sd.filter", "Text Pos: " << aPos << ", Size: " << aSize); if (eAlg == ALIGN_BASELINE) aPos.AdjustY(-(FRound(aFontMetric.GetAscent() * mfScaleY))); @@ -995,6 +1034,7 @@ void ImpSdrPdfImport::ImportText(const Point& rPos, const OUString& rStr) aPos.AdjustY(-nTextHeight); tools::Rectangle aTextRect(aPos, aSize); + SAL_WARN("sd.filter", "Text Rect: " << aTextRect); SdrRectObj* pText = new SdrRectObj(*mpModel, OBJ_TEXT, aTextRect); pText->SetMergedItem(makeSdrTextUpperDistItem(0)); @@ -1138,11 +1178,40 @@ void ImpSdrPdfImport::ImportImage(FPDF_PAGEOBJECT pPageObject) SAL_WARN("sd.filter", "Got IMAGE bounds left: " << left << ", right: " << right << ", top: " << top << ", bottom: " << bottom); + tools::Rectangle aRect = PointsToLogic(left, right, top, bottom); + aRect.AdjustRight(1); + aRect.AdjustBottom(1); + SAL_WARN("sd.filter", "IMAGE Logical Rect FINAL: " << aRect); + + SdrGrafObj* pGraf = new SdrGrafObj(*mpModel, Graphic(aBitmap), aRect); + + // This action is not creating line and fill, set directly, do not use SetAttributes(..) + pGraf->SetMergedItem(XLineStyleItem(drawing::LineStyle_NONE)); + pGraf->SetMergedItem(XFillStyleItem(drawing::FillStyle_NONE)); + InsertObj(pGraf); +} + +Point ImpSdrPdfImport::PointsToLogic(double x, double y) const +{ + y = correctVertOrigin(y); + SAL_WARN("sd.filter", "Corrected point x: " << x << ", y: " << y); + x = lcl_PointToPixel(x); + y = lcl_PointToPixel(y); + + SAL_WARN("sd.filter", "Pixel point x: " << x << ", y: " << y); + + Point aPos(lcl_ToLogic(x), lcl_ToLogic(y)); + SAL_WARN("sd.filter", "Logical Pos: " << aPos); + + return aPos; +} + +tools::Rectangle ImpSdrPdfImport::PointsToLogic(double left, double right, double top, double bottom) const +{ top = correctVertOrigin(top); bottom = correctVertOrigin(bottom); - SAL_WARN("sd.filter", "IMAGE corrected bounds left: " << left << ", right: " << right - << ", top: " << top - << ", bottom: " << bottom); + SAL_WARN("sd.filter", "Corrected bounds left: " << left << ", right: " << right + << ", top: " << top << ", bottom: " << bottom); left = lcl_PointToPixel(left); right = lcl_PointToPixel(right); top = lcl_PointToPixel(top); @@ -1152,51 +1221,15 @@ void ImpSdrPdfImport::ImportImage(FPDF_PAGEOBJECT pPageObject) // if (left > right) // std::swap(left, right); - SAL_WARN("sd.filter", "IMAGE pixel bounds left: " << left << ", right: " << right << ", top: " - << top << ", bottom: " << bottom); + SAL_WARN("sd.filter", "Pixel bounds left: " << left << ", right: " << right << ", top: " << top + << ", bottom: " << bottom); Point aPos(lcl_ToLogic(left), lcl_ToLogic(top)); Size aSize(lcl_ToLogic(right - left), lcl_ToLogic(bottom - top)); tools::Rectangle aRect(aPos, aSize); - SAL_WARN("sd.filter", "IMAGE Logical BBox: " << aRect); - - // aRect.SetLeft(aRect.Left() * mfScaleX); - // aRect.SetRight(aRect.Right() * mfScaleX); - // aRect.SetTop(aRect.Top() * mfScaleY); - // aRect.SetBottom(aRect.Bottom() * mfScaleY); - // SAL_WARN("sd.filter", "Logical Rect Scaled: " << aRect); + SAL_WARN("sd.filter", "Logical BBox: " << aRect); - // aLogRect.Move(maScaleRect.Left(), maScaleRect.Top() - aLogRect.Top()); - // aRect.Move(maScaleRect.Left(), maScaleRect.Top()); - // SAL_WARN("sd.filter", "Logical Rect Absolute: " << aRect); - aRect.AdjustRight(1); - aRect.AdjustBottom(1); - SAL_WARN("sd.filter", "IMAGE Logical Rect FINAL: " << aRect); - - /* - Size aGrfSize(OutputDevice::LogicToLogic(Size(nWidth, nHeight), aBitmap.GetPrefMapMode(), - MapMode(MapUnit::Map100thMM))); - SAL_WARN("sd.filter", "Logical Size: " << aGrfSize); - // SAL_WARN("sd.filter", "Scaled Logical Size: " << aGrfSize); - Point aGrfPos(OutputDevice::LogicToLogic(Point(left, top), aBitmap.GetPrefMapMode(), - MapMode(MapUnit::Map100thMM))); - SAL_WARN("sd.filter", "Logical Pos: " << aGrfPos); - - SAL_WARN("sd.filter", "Page Logical Height: " << maScaleRect.GetHeight()); - const auto realTop = maScaleRect.GetHeight() - aGrfPos.Y(); - SAL_WARN("sd.filter", "Real Logical Top Offset: " << realTop); - aGrfPos.Move(maScaleRect.Left(), maScaleRect.Top() - aGrfPos.Y()); - SAL_WARN("sd.filter", "Adjusted Logical Pos: " << aGrfPos); - - tools::Rectangle aRect(aGrfPos, aGrfSize); - SAL_WARN("sd.filter", "Got IMAGE Logical BBox: " << aRect); -*/ - SdrGrafObj* pGraf = new SdrGrafObj(*mpModel, Graphic(aBitmap), aRect); - - // This action is not creating line and fill, set directly, do not use SetAttributes(..) - pGraf->SetMergedItem(XLineStyleItem(drawing::LineStyle_NONE)); - pGraf->SetMergedItem(XFillStyleItem(drawing::FillStyle_NONE)); - InsertObj(pGraf); + return aRect; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/svdraw/svdpdf.hxx b/svx/source/svdraw/svdpdf.hxx index dbca9ad0295c..0c462c6fc135 100644 --- a/svx/source/svdraw/svdpdf.hxx +++ b/svx/source/svdraw/svdpdf.hxx @@ -92,6 +92,10 @@ class ImpSdrPdfImport final /// PDF coordinate system has orign at the bottom right. double correctVertOrigin(double offsetPts) const { return mdPageHeightPts - offsetPts; } + /// Convert PDF points to logic (twips). + tools::Rectangle PointsToLogic(double left, double right, double top, double bottom) const; + Point PointsToLogic(double x, double y) const; + // check for clip and evtl. fill maClip void checkClip(); bool isClip() const; -- cgit