summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2018-05-18 09:15:36 -0400
committerAshod Nakashian <ashod.nakashian@collabora.co.uk>2018-06-04 12:36:28 -0400
commita13368fa681910069a49afa76b558bef4b1e796f (patch)
tree205e5287edd0dec2767b7b71a2da9da19ee107ea
parenta735d3a731263721e3a067b67e3f66122d7c9f1c (diff)
svx: cleanup pdfium importer
Change-Id: Id925ba7734a2c73270e40f19d3fc50552441c34e (cherry picked from commit 5217375499e314e909d8e1c2a6a815bda46ca5b0)
-rw-r--r--external/pdfium/edit.patch.1138
-rw-r--r--svx/source/svdraw/svdpdf.cxx311
-rw-r--r--svx/source/svdraw/svdpdf.hxx12
3 files changed, 29 insertions, 432 deletions
diff --git a/external/pdfium/edit.patch.1 b/external/pdfium/edit.patch.1
index a110313017da..5b23140c2069 100644
--- a/external/pdfium/edit.patch.1
+++ b/external/pdfium/edit.patch.1
@@ -1,43 +1,8 @@
diff --git a/core/fpdfapi/page/cpdf_colorstate.cpp b/core/fpdfapi/page/cpdf_colorstate.cpp
-index 693fcf1..d3e1202 100644
+index 693fcf1..14e883f 100644
--- a/core/fpdfapi/page/cpdf_colorstate.cpp
+++ b/core/fpdfapi/page/cpdf_colorstate.cpp
-@@ -74,6 +74,8 @@ void CPDF_ColorState::SetFillColor(CPDF_ColorSpace* pCS,
- uint32_t nValues) {
- ColorData* pData = m_Ref.GetPrivateCopy();
- SetColor(pData->m_FillColor, pData->m_FillRGB, pCS, pValue, nValues);
-+ if (pData->m_FillRGB != 0 && pData->m_FillRGB != 0xFFFFFFFF)
-+ fprintf(stderr, "COLOR FILL!!!!> %x\n", pData->m_FillRGB);
- }
-
- void CPDF_ColorState::SetStrokeColor(CPDF_ColorSpace* pCS,
-@@ -81,6 +83,8 @@ void CPDF_ColorState::SetStrokeColor(CPDF_ColorSpace* pCS,
- uint32_t nValues) {
- ColorData* pData = m_Ref.GetPrivateCopy();
- SetColor(pData->m_StrokeColor, pData->m_StrokeRGB, pCS, pValue, nValues);
-+ if (pData->m_StrokeRGB != 0 && pData->m_StrokeRGB != 0xFFFFFFFF)
-+ fprintf(stderr, "COLOR STROkE!!!!> %x\n", pData->m_StrokeRGB);
- }
-
- void CPDF_ColorState::SetFillPattern(CPDF_Pattern* pPattern,
-@@ -99,6 +103,8 @@ void CPDF_ColorState::SetFillPattern(CPDF_Pattern* pPattern,
- }
- }
- pData->m_FillRGB = ret ? FXSYS_RGB(R, G, B) : 0xFFFFFFFF;
-+ if (pData->m_FillRGB != 0 && pData->m_FillRGB != 0xFFFFFFFF)
-+ fprintf(stderr, "COLOR FILL!!!!> %x\n", pData->m_FillRGB);
- }
-
- void CPDF_ColorState::SetStrokePattern(CPDF_Pattern* pPattern,
-@@ -118,13 +124,15 @@ void CPDF_ColorState::SetStrokePattern(CPDF_Pattern* pPattern,
- }
- pData->m_StrokeRGB =
- pData->m_StrokeColor.GetRGB(&R, &G, &B) ? FXSYS_RGB(R, G, B) : 0xFFFFFFFF;
-+ if (pData->m_StrokeRGB != 0 && pData->m_StrokeRGB != 0xFFFFFFFF)
-+ fprintf(stderr, "COLOR STROkE!!!!> %x\n", pData->m_StrokeRGB);
- }
-
- void CPDF_ColorState::SetColor(CPDF_Color& color,
+@@ -124,7 +124,7 @@ void CPDF_ColorState::SetColor(CPDF_Color& color,
uint32_t& rgb,
CPDF_ColorSpace* pCS,
float* pValue,
@@ -59,57 +24,6 @@ index 9619051..dbe9c47 100644
SharedCopyOnWrite<ColorData> m_Ref;
};
-diff --git a/core/fpdfapi/page/cpdf_imageobject.cpp b/core/fpdfapi/page/cpdf_imageobject.cpp
-index 3b5a740..416d82d 100644
---- a/core/fpdfapi/page/cpdf_imageobject.cpp
-+++ b/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<CPDF_Image>& pImage) {
-diff --git a/core/fpdfapi/page/cpdf_page.cpp b/core/fpdfapi/page/cpdf_page.cpp
-index ba93f4a..70d398b 100644
---- a/core/fpdfapi/page/cpdf_page.cpp
-+++ b/core/fpdfapi/page/cpdf_page.cpp
-@@ -35,12 +35,14 @@ CPDF_Page::CPDF_Page(CPDF_Document* pDocument,
- CFX_FloatRect mediabox = GetBox("MediaBox");
- if (mediabox.IsEmpty())
- mediabox = CFX_FloatRect(0, 0, 612, 792);
-+ fprintf(stderr, "Page mediabox: %f, %f, %f, %f\n", mediabox.left, mediabox.right, mediabox.top, mediabox.bottom);
-
- m_BBox = GetBox("CropBox");
- if (m_BBox.IsEmpty())
- m_BBox = mediabox;
- else
- m_BBox.Intersect(mediabox);
-+ fprintf(stderr, "Page cropbox: %f, %f, %f, %f\n", m_BBox.left, m_BBox.right, m_BBox.top, m_BBox.bottom);
-
- m_PageSize.width = m_BBox.Width();
- m_PageSize.height = m_BBox.Height();
-@@ -48,6 +50,7 @@ CPDF_Page::CPDF_Page(CPDF_Document* pDocument,
- int rotate = GetPageRotation();
- if (rotate % 2)
- std::swap(m_PageSize.width, m_PageSize.height);
-+ fprintf(stderr, "Page rotate: %d, Page Width: %f, Page Height: %f\n", rotate, m_PageSize.width, m_PageSize.height);
-
- switch (rotate) {
- case 0:
-diff --git a/core/fpdfapi/page/cpdf_pageobject.cpp b/core/fpdfapi/page/cpdf_pageobject.cpp
-index 8bb5bf5..9b5e2ce 100644
---- a/core/fpdfapi/page/cpdf_pageobject.cpp
-+++ b/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/core/fpdfapi/page/cpdf_pageobjectlist.cpp b/core/fpdfapi/page/cpdf_pageobjectlist.cpp
index afd2c98..2c8e061 100644
--- a/core/fpdfapi/page/cpdf_pageobjectlist.cpp
@@ -135,18 +49,6 @@ index b450537..77c7d81 100644
};
#endif // CORE_FPDFAPI_PAGE_CPDF_PAGEOBJECTLIST_H_
-diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp
-index 0a01ae0..6947e3a 100644
---- a/core/fpdfapi/render/cpdf_renderstatus.cpp
-+++ b/core/fpdfapi/render/cpdf_renderstatus.cpp
-@@ -1793,6 +1793,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/core/fpdftext/cpdf_textpage.cpp b/core/fpdftext/cpdf_textpage.cpp
index e712549..a7973f7 100644
--- a/core/fpdftext/cpdf_textpage.cpp
@@ -197,26 +99,6 @@ index c87ab00..e5a1ba8 100644
int CountRects(int start, int nCount);
bool GetRect(int rectIndex, CFX_FloatRect* pRect) const;
-diff --git a/core/fxge/cfx_pathdata.cpp b/core/fxge/cfx_pathdata.cpp
-index 4ac5cf6..4286de4 100644
---- a/core/fxge/cfx_pathdata.cpp
-+++ b/core/fxge/cfx_pathdata.cpp
-@@ -199,6 +199,7 @@ void CFX_PathData::Append(const CFX_PathData* pSrc, const CFX_Matrix* pMatrix) {
- void CFX_PathData::AppendPoint(const CFX_PointF& point,
- FXPT_TYPE type,
- bool closeFigure) {
-+// fprintf(stderr, "Append: %f, %f (%s)\n", point.x, point.y, closeFigure ? "CLOSE" : "OPEN");
- m_Points.push_back(FX_PATHPOINT(point, type, closeFigure));
- }
-
-@@ -290,6 +291,7 @@ CFX_FloatRect CFX_PathData::GetBoundingBox(float line_width,
- void CFX_PathData::Transform(const CFX_Matrix* pMatrix) {
- if (!pMatrix)
- return;
-+// fprintf(stderr, "XForm: %f, %f %f, %f, %f, %f\n", pMatrix->a, pMatrix->b, pMatrix->c, pMatrix->d, pMatrix->e, pMatrix->f);
- for (auto& point : m_Points)
- point.m_Point = pMatrix->Transform(point.m_Point);
- }
diff --git a/fpdfsdk/fpdfeditimg.cpp b/fpdfsdk/fpdfeditimg.cpp
index 0d7ba56..37bdf99 100644
--- a/fpdfsdk/fpdfeditimg.cpp
@@ -249,7 +131,7 @@ index 0d7ba56..37bdf99 100644
FPDFImageObj_GetImageDataDecoded(FPDF_PAGEOBJECT image_object,
void* buffer,
diff --git a/fpdfsdk/fpdfeditpage.cpp b/fpdfsdk/fpdfeditpage.cpp
-index ca2cf3f..2162625 100644
+index ca2cf3f..1eaa232 100644
--- a/fpdfsdk/fpdfeditpage.cpp
+++ b/fpdfsdk/fpdfeditpage.cpp
@@ -11,12 +11,14 @@
@@ -275,7 +157,7 @@ index ca2cf3f..2162625 100644
#include "fpdfsdk/fsdk_define.h"
#include "public/fpdf_formfill.h"
#include "third_party/base/logging.h"
-@@ -363,3 +366,252 @@ FPDFPageObj_GetBounds(FPDF_PAGEOBJECT pageObject,
+@@ -363,3 +366,240 @@ FPDFPageObj_GetBounds(FPDF_PAGEOBJECT pageObject,
*top = bbox.top;
return true;
}
@@ -363,17 +245,6 @@ index ca2cf3f..2162625 100644
+ str += pFont->UnicodeFromCharCode(charcode);
+ }
+
-+// CFX_WideTextBuf m_TextBuf;
-+// WideString str = textpage->GetPageText(char_start, char_count);
-+// return WideString(m_TextBuf.AsStringView().Mid(
-+// static_cast<size_t>(text_start), static_cast<size_t>(text_count)));
-+
-+// if (str.GetLength() > static_cast<size_t>(char_count))
-+// str = str.Left(static_cast<size_t>(char_count));
-+
-+ // Reincode in UTF-16.
-+// WideString str = text.UTF8Decode();
-+
+ // UFT16LE_Encode doesn't handle surrogate pairs properly, so it is expected
+ // the number of items to stay the same.
+ ByteString byte_str = str.UTF16LE_Encode();
@@ -495,7 +366,6 @@ index ca2cf3f..2162625 100644
+ if (pFrmObj)
+ {
+ const CFX_Matrix& matrix = pFrmObj->form_matrix();
-+ fprintf(stderr, "Form matrix a: %f, b: %f, c: %f, d: %f, e: %f, f: %f\n", matrix.a, matrix.b, matrix.c, matrix.d, matrix.e, matrix.f);
+ const CPDF_PageObjectList* pObjectList = pFrmObj->form()->GetPageObjectList();
+ if (pObjectList)
+ return pObjectList->GetPageObjectByIndex(index);
diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx
index 80383bb39242..1ff7deadb4dc 100644
--- a/svx/source/svdraw/svdpdf.cxx
+++ b/svx/source/svdraw/svdpdf.cxx
@@ -200,7 +200,6 @@ ImpSdrPdfImport::ImpSdrPdfImport(SdrModel& rModel, SdrLayerID nLay, const tools:
}
mnPageCount = FPDF_GetPageCount(mpPdfDocument);
- SAL_WARN("sd.filter", "Scale Rect: " << maScaleRect);
}
ImpSdrPdfImport::~ImpSdrPdfImport()
@@ -209,11 +208,10 @@ ImpSdrPdfImport::~ImpSdrPdfImport()
FPDF_DestroyLibrary();
}
-void ImpSdrPdfImport::DoLoopActions(SvdProgressInfo* pProgrInfo, sal_uInt32* pActionsToReport,
+void ImpSdrPdfImport::DoObjects(SvdProgressInfo* pProgrInfo, sal_uInt32* pActionsToReport,
int nPageIndex)
{
const int nPageCount = FPDF_GetPageCount(mpPdfDocument);
- SAL_WARN("sd.filter", "Importing page " << nPageIndex << " of " << nPageCount);
if (nPageCount > 0 && nPageIndex >= 0 && nPageIndex < nPageCount)
{
// Render next page.
@@ -223,187 +221,24 @@ void ImpSdrPdfImport::DoLoopActions(SvdProgressInfo* pProgrInfo, sal_uInt32* pAc
const double dPageWidth = FPDF_GetPageWidth(pPdfPage);
const double dPageHeight = FPDF_GetPageHeight(pPdfPage);
- SAL_WARN("sd.filter", "Loaded page: " << nPageIndex << ", width: " << dPageWidth
- << ", height: " << dPageHeight);
SetupPageScale(dPageWidth, dPageHeight);
// Load the page text to extract it when we get text elements.
FPDF_TEXTPAGE pTextPage = FPDFText_LoadPage(pPdfPage);
const int nPageObjectCount = FPDFPage_CountObject(pPdfPage);
+ if (pProgrInfo)
+ pProgrInfo->SetActionCount(nPageObjectCount);
+
for (int nPageObjectIndex = 0; nPageObjectIndex < nPageObjectCount; ++nPageObjectIndex)
{
FPDF_PAGEOBJECT pPageObject = FPDFPage_GetObject(pPdfPage, nPageObjectIndex);
ImportPdfObject(pPageObject, pTextPage, nPageObjectIndex);
- }
-
- FPDFText_ClosePage(pTextPage);
-
-#if 0
- // 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<sal_Unicode[]> 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 << ", " << right << ", " << top
- << ", " << bottom);
- SAL_WARN("sd.filter", "Logic Text Rect: " << aRect);
-
- unsigned short* pShortText = reinterpret_cast<unsigned short*>(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 << "].");
-
- const double dHalfCharWidth = (right - left) / nBoundedChars / 2.0;
- SAL_WARN("sd.filter", "Half Char Width: " << dHalfCharWidth);
- const int nCharIndex = FPDFText_GetCharIndexAtPos(pTextPage, left + dHalfCharWidth,
- top + dHalfCharWidth,
- dHalfCharWidth, dHalfCharWidth);
- SAL_WARN("sd.filter", "Got Char Index: " << nCharIndex);
-
- // FPDF_FONT pFont = FPDFText_GetFont(pTextPage, nCharIndex);
- // const int nFontAscent = FPDFFont_GetAscent(pFont);
- // const int nFontDescent = FPDFFont_GetDescent(pFont);
- // FPDF_BYTESTRING sFontName = FPDFFont_GetName(pFont);
- // SAL_WARN("sd.filter", "Char #" << nCharIndex << ", Got Font [" << sFontName <<
- // "], Ascent: "<< nFontAscent << ", Descent: " << nFontDescent);
-
- // FontMetric aFontMetric = mpVD->GetFontMetric();
- // aFontMetric.SetAscent(nFontAscent);
- // aFontMetric.SetDescent(nFontDescent);
-
- 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);
-
- double x = 0;
- 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;
- // aRect.Y1 = top;
- // aRect.X2 = right;
- // aRect.Y2 = bottom;
-
- // geometry::Matrix2D aMatrix;
- // FPDFText_GetMatrix(pTextPage, nCharIndex, &aMatrix.m00, &aMatrix.m01, &aMatrix.m10, &aMatrix.m11);
-
- // basegfx::B2DHomMatrix fontMatrix(
- // aMatrix.m00, aMatrix.m01, 0.0,
- // aMatrix.m10, aMatrix.m11, 0.0);
- // fontMatrix.scale(dFontSize, dFontSize);
-
- // x = fontMatrix.get(0, 0) * x + fontMatrix.get(1, 0) * y + x;
- // y = fontMatrix.get(0, 1) * x + fontMatrix.get(1, 1) * y + y;
- // SAL_WARN("sd.filter", "Char Origin after xform: " << x << ", " << y);
-
- // basegfx::B2DHomMatrix totalTextMatrix1(fontMatrix);
- // basegfx::B2DHomMatrix totalTextMatrix2(fontMatrix);
- // totalTextMatrix1.translate(rRect.X1, rRect.Y1);
- // totalTextMatrix2.translate(rRect.X2, rRect.Y2);
-
- // basegfx::B2DHomMatrix corrMatrix;
- // corrMatrix.scale(1.0, -1.0);
- // // corrMatrix.translate(0.0, ascent);
- // totalTextMatrix1 = totalTextMatrix1 * corrMatrix;
- // totalTextMatrix2 = totalTextMatrix2 * corrMatrix;
-
- // totalTextMatrix1 *= getCurrentContext().Transformation;
- // totalTextMatrix2 *= getCurrentContext().Transformation;
-
- // basegfx::B2DHomMatrix invMatrix(totalTextMatrix1);
- // basegfx::B2DHomMatrix invPrevMatrix(prevTextMatrix);
- // invMatrix.invert();
- // invPrevMatrix.invert();
- // basegfx::B2DHomMatrix offsetMatrix1(totalTextMatrix1);
- // basegfx::B2DHomMatrix offsetMatrix2(totalTextMatrix2);
- // offsetMatrix1 *= invPrevMatrix;
- // offsetMatrix2 *= invMatrix;
-
- // double charWidth = offsetMatrix2.get(0, 2);
- // double prevSpaceWidth = offsetMatrix1.get(0, 2) - prevCharWidth;
-
- ImportText(aRect.TopLeft(), sText);
- }
-
- FPDFText_ClosePage(pTextPage);
- }
-#endif
-
- FPDF_ClosePage(pPdfPage);
- }
-
- // const sal_uLong nCount(rMtf.GetActionSize());
-
- for (sal_uLong a(0); a < 0UL; a++)
- {
if (pProgrInfo && pActionsToReport)
{
(*pActionsToReport)++;
- if (*pActionsToReport >= 16) // update all 16 actions
+ if (*pActionsToReport >= 16)
{
if (!pProgrInfo->ReportActions(*pActionsToReport))
break;
@@ -412,6 +247,10 @@ void ImpSdrPdfImport::DoLoopActions(SvdProgressInfo* pProgrInfo, sal_uInt32* pAc
}
}
}
+
+ FPDFText_ClosePage(pTextPage);
+ FPDF_ClosePage(pPdfPage);
+ }
}
void ImpSdrPdfImport::SetupPageScale(const double dPageWidth, const double dPageHeight)
@@ -424,8 +263,6 @@ void ImpSdrPdfImport::SetupPageScale(const double dPageWidth, const double dPage
Size aPageSize(lcl_ToLogic(lcl_PointToPixel(dPageWidth)),
lcl_ToLogic(lcl_PointToPixel(dPageHeight)));
- SAL_WARN("sd.filter", "Logical Page Size: " << aPageSize);
- SAL_WARN("sd.filter", "Scale Rect: " << maScaleRect);
if (aPageSize.Width() && aPageSize.Height() && (!maScaleRect.IsEmpty()))
{
@@ -460,23 +297,15 @@ void ImpSdrPdfImport::SetupPageScale(const double dPageWidth, const double dPage
maScaleY = Fraction(maScaleRect.GetHeight() - 1, aPageSize.Height());
mbSize = true;
}
-
- //SAL_WARN("sd.filter", "ScaleX: " << maScaleX << "(" << mfScaleX << "), ScaleY: " << maScaleY
- // << "(" << mfScaleY << ")");
}
size_t ImpSdrPdfImport::DoImport(SdrObjList& rOL, size_t nInsPos, int nPageNumber,
SvdProgressInfo* pProgrInfo)
{
- if (pProgrInfo)
- {
- // pProgrInfo->SetActionCount(rMtf.GetActionSize());
- }
-
sal_uInt32 nActionsToReport(0);
// execute
- DoLoopActions(pProgrInfo, &nActionsToReport, nPageNumber);
+ DoObjects(pProgrInfo, &nActionsToReport, nPageNumber);
if (pProgrInfo)
{
@@ -617,7 +446,6 @@ void ImpSdrPdfImport::SetAttributes(SdrObject* pObj, bool bForceTextAttr)
{
vcl::Font aFnt(mpVD->GetFont());
const sal_uInt32 nHeight(FRound(aFnt.GetFontSize().Height() * mfScaleY));
- SAL_WARN("sd.filter", "Font Height: " << nHeight);
mpTextAttr->Put(SvxFontItem(aFnt.GetFamilyType(), aFnt.GetFamilyName(), aFnt.GetStyleName(),
aFnt.GetPitch(), aFnt.GetCharSet(), EE_CHAR_FONTINFO));
@@ -1030,10 +858,8 @@ void ImpSdrPdfImport::ImportPdfObject(FPDF_PAGEOBJECT pPageObject, FPDF_TEXTPAGE
}
void ImpSdrPdfImport::ImportForm(FPDF_PAGEOBJECT pPageObject, FPDF_TEXTPAGE pTextPage,
- int nPageObjectIndex)
+ int /*nPageObjectIndex*/)
{
- SAL_WARN("sd.filter", "Got page object FORM: " << nPageObjectIndex);
-
// Get the form matrix to perform correct translation/scaling of the form sub-objects.
const Matrix aOldMatrix = mCurMatrix;
@@ -1053,9 +879,8 @@ void ImpSdrPdfImport::ImportForm(FPDF_PAGEOBJECT pPageObject, FPDF_TEXTPAGE pTex
}
void ImpSdrPdfImport::ImportText(FPDF_PAGEOBJECT pPageObject, FPDF_TEXTPAGE pTextPage,
- int nPageObjectIndex)
+ int /*nPageObjectIndex*/)
{
- SAL_WARN("sd.filter", "Got page object TEXT: " << nPageObjectIndex);
float left;
float bottom;
float right;
@@ -1066,30 +891,14 @@ void ImpSdrPdfImport::ImportText(FPDF_PAGEOBJECT pPageObject, FPDF_TEXTPAGE pTex
}
if (left == right || top == bottom)
- {
- SAL_WARN("sd.filter", "Skipping empty TEXT #" << nPageObjectIndex << " left: " << left
- << ", right: " << right << ", top: " << top
- << ", bottom: " << bottom);
return;
- }
double a, b, c, d, e, f;
FPDFTextObj_GetMatrix(pPageObject, &a, &b, &c, &d, &e, &f);
- // Matrix aTextMatrix(a, b, c, d, e, f);
Matrix aTextMatrix(mCurMatrix);
- SAL_WARN("sd.filter", "Got text matrix " << aTextMatrix.toString());
- SAL_WARN("sd.filter", "Context matrix " << mCurMatrix.toString());
- // aTextMatrix.Concatinate(mCurMatrix);
- // SAL_WARN("sd.filter", "Got text matrix concat " << aTextMatrix.toString());
- Point aPos = PointsToLogic(aTextMatrix.e(), aTextMatrix.f());
- SAL_WARN("sd.filter", "Got TEXT origin: " << aPos);
-
- const tools::Rectangle aRect2 = PointsToLogic(left, right, top, bottom);
- SAL_WARN("sd.filter", "Untransformed TEXT Bounds: " << aRect2);
aTextMatrix.Transform(left, right, top, bottom);
const tools::Rectangle aRect = PointsToLogic(left, right, top, bottom);
- SAL_WARN("sd.filter", "Transformed TEXT Bounds: " << aRect);
const int nChars = FPDFTextObj_CountChars(pPageObject) * 2;
std::unique_ptr<sal_Unicode[]> pText(new sal_Unicode[nChars + 1]); // + terminating null
@@ -1099,24 +908,18 @@ void ImpSdrPdfImport::ImportText(FPDF_PAGEOBJECT pPageObject, FPDF_TEXTPAGE pTex
= FPDFTextObj_GetTextProcessed(pPageObject, pTextPage, 0, nChars, pShortText);
if (nActualChars <= 0)
{
- SAL_WARN("sd.filter", "Got no TEXT");
return;
}
OUString sText(pText.get(), nActualChars);
- SAL_WARN("sd.filter", "Got Text (" << nChars << "): [" << sText << "].");
const double dFontSize = FPDFTextObj_GetFontSize(pPageObject);
double dFontSizeH = fabs(sqrt2(a, c) * dFontSize);
double dFontSizeV = fabs(sqrt2(b, d) * dFontSize);
- SAL_WARN("sd.filter", "Got Font Size: " << dFontSize << ", Scaled Font Size H: " << dFontSizeH
- << ", V: " << dFontSizeV);
dFontSizeH = lcl_PointToPixel(dFontSizeH);
dFontSizeV = lcl_PointToPixel(dFontSizeV);
- SAL_WARN("sd.filter", "Got Pixel Font Size H: " << dFontSizeH << ", V: " << dFontSizeV);
dFontSizeH = lcl_ToLogic(dFontSizeH);
dFontSizeV = lcl_ToLogic(dFontSizeV);
- SAL_WARN("sd.filter", "Got Logic Font Size H: " << dFontSizeH << ", V: " << dFontSizeV);
const Size aFontSize(dFontSizeH, dFontSizeV);
vcl::Font aFnt = mpVD->GetFont();
@@ -1149,26 +952,18 @@ void ImpSdrPdfImport::ImportText(const Point& rPos, const Size& rSize, const OUS
vcl::Font aFnt(mpVD->GetFont());
FontAlign eAlg(aFnt.GetAlignment());
- sal_Int32 nTextWidth = static_cast<sal_Int32>(mpVD->GetTextWidth(rStr) * mfScaleX);
+ // sal_Int32 nTextWidth = static_cast<sal_Int32>(mpVD->GetTextWidth(rStr) * mfScaleX);
sal_Int32 nTextHeight = static_cast<sal_Int32>(mpVD->GetTextHeight() * mfScaleY);
- SAL_WARN("sd.filter",
- "Unscaled text size: " << mpVD->GetTextWidth(rStr) << 'x' << mpVD->GetTextHeight()
- << ", Scaled: " << nTextWidth << 'x' << nTextHeight);
Point aPos(FRound(rPos.X() * mfScaleX + maOfs.X()), FRound(rPos.Y() * mfScaleY + maOfs.Y()));
- Size bSize(FRound(rSize.Width() * mfScaleX), FRound(rSize.Height() * mfScaleY));
- Size aSize(nTextWidth, nTextHeight);
+ Size aSize(FRound(rSize.Width() * mfScaleX), FRound(rSize.Height() * mfScaleY));
if (eAlg == ALIGN_BASELINE)
aPos.AdjustY(-FRound(aFontMetric.GetAscent() * mfScaleY));
else if (eAlg == ALIGN_BOTTOM)
aPos.AdjustY(-nTextHeight);
- SAL_WARN("sd.filter", "Final POS: " << aPos);
- SAL_WARN("sd.filter", "Final Text Size: " << aSize);
- SAL_WARN("sd.filter", "Final Bound Size: " << bSize);
- tools::Rectangle aTextRect(aPos, bSize);
- // SAL_WARN("sd.filter", "Text Rect: " << aTextRect);
+ tools::Rectangle aTextRect(aPos, aSize);
SdrRectObj* pText = new SdrRectObj(*mpModel, OBJ_TEXT, aTextRect);
pText->SetMergedItem(makeSdrTextUpperDistItem(0));
@@ -1232,9 +1027,8 @@ void ImpSdrPdfImport::MapScaling()
mnMapScalingOfs = nCount;
}
-void ImpSdrPdfImport::ImportImage(FPDF_PAGEOBJECT pPageObject, int nPageObjectIndex)
+void ImpSdrPdfImport::ImportImage(FPDF_PAGEOBJECT pPageObject, int /*nPageObjectIndex*/)
{
- SAL_WARN("sd.filter", "Got page object IMAGE: " << nPageObjectIndex);
std::unique_ptr<void, FPDFBitmapDeleter> bitmap(FPDFImageObj_GetBitmapBgra(pPageObject));
if (!bitmap)
{
@@ -1258,27 +1052,13 @@ void ImpSdrPdfImport::ImportImage(FPDF_PAGEOBJECT pPageObject, int nPageObjectIn
switch (format)
{
- case FPDFBitmap_Gray:
- SAL_WARN("sd.filter", "Got IMAGE width: " << nWidth << ", height: " << nHeight
- << ", stride: " << nStride
- << ", format: Gray");
- break;
case FPDFBitmap_BGR:
- SAL_WARN("sd.filter", "Got IMAGE width: " << nWidth << ", height: " << nHeight
- << ", stride: " << nStride
- << ", format: BGR");
ReadRawDIB(aBitmap, pBuf, ScanlineFormat::N24BitTcBgr, nHeight, nStride);
break;
case FPDFBitmap_BGRx:
- SAL_WARN("sd.filter", "Got IMAGE width: " << nWidth << ", height: " << nHeight
- << ", stride: " << nStride
- << ", format: BGRx");
ReadRawDIB(aBitmap, pBuf, ScanlineFormat::N32BitTcRgba, nHeight, nStride);
break;
case FPDFBitmap_BGRA:
- SAL_WARN("sd.filter", "Got IMAGE width: " << nWidth << ", height: " << nHeight
- << ", stride: " << nStride
- << ", format: BGRA");
ReadRawDIB(aBitmap, pBuf, ScanlineFormat::N32BitTcBgra, nHeight, nStride);
break;
default:
@@ -1288,18 +1068,6 @@ void ImpSdrPdfImport::ImportImage(FPDF_PAGEOBJECT pPageObject, int nPageObjectIn
break;
}
- // double a, b, c, d, e, f;
- // if (!FPDFImageObj_GetMatrix(pPageObject, &a, &b, &c, &d, &e, &f))
- // {
- // SAL_WARN("sd.filter", "FAILED to get image Matrix");
- // }
- // SAL_WARN("sd.filter", "Got image Matrix: " << a << ", " << b << ", " << c << ", " << d << ", " << e << ", " << f);
-
- // if (!FPDFImageObj_SetMatrix(pPageObject, a, b, c, d, e, f))
- // {
- // SAL_WARN("sd.filter", "FAILED to set image Matrix");
- // }
-
float left;
float bottom;
float right;
@@ -1309,12 +1077,9 @@ void ImpSdrPdfImport::ImportImage(FPDF_PAGEOBJECT pPageObject, int nPageObjectIn
SAL_WARN("sd.filter", "FAILED to get image bounds");
}
- 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);
@@ -1324,7 +1089,7 @@ void ImpSdrPdfImport::ImportImage(FPDF_PAGEOBJECT pPageObject, int nPageObjectIn
InsertObj(pGraf);
}
-void ImpSdrPdfImport::ImportPath(FPDF_PAGEOBJECT pPageObject, int nPageObjectIndex)
+void ImpSdrPdfImport::ImportPath(FPDF_PAGEOBJECT pPageObject, int /*nPageObjectIndex*/)
{
double a, b, c, d, e, f;
FPDFPath_GetMatrix(pPageObject, &a, &b, &c, &d, &e, &f);
@@ -1336,9 +1101,6 @@ void ImpSdrPdfImport::ImportPath(FPDF_PAGEOBJECT pPageObject, int nPageObjectInd
std::vector<basegfx::B2DPoint> aBezier;
const int nSegments = FPDFPath_CountSegments(pPageObject);
- SAL_WARN("sd.filter",
- "Got page object PATH: " << nPageObjectIndex << " with " << nSegments << " segments.");
-
for (int nSegmentIndex = 0; nSegmentIndex < nSegments; ++nSegmentIndex)
{
FPDF_PATHSEGMENT pPathSegment = FPDFPath_GetPathSegment(pPageObject, nSegmentIndex);
@@ -1358,11 +1120,6 @@ void ImpSdrPdfImport::ImportPath(FPDF_PAGEOBJECT pPageObject, int nPageObjectInd
if (bClose)
aPoly.setClosed(bClose); // TODO: Review
- SAL_WARN("sd.filter", "Got " << (bClose ? "CLOSE" : "OPEN") << " point (" << fx << ", "
- << fy << ") matrix (" << a << ", " << b << ", " << c
- << ", " << d << ", " << e << ", " << f << ") -> (" << x
- << ", " << y << ")");
-
Point aPoint = PointsToLogic(x, y);
x = aPoint.X();
y = aPoint.Y();
@@ -1371,12 +1128,10 @@ void ImpSdrPdfImport::ImportPath(FPDF_PAGEOBJECT pPageObject, int nPageObjectInd
switch (nSegmentType)
{
case FPDF_SEGMENT_LINETO:
- SAL_WARN("sd.filter", "Got LineTo Segment.");
aPoly.append(basegfx::B2DPoint(x, y));
break;
case FPDF_SEGMENT_BEZIERTO:
- SAL_WARN("sd.filter", "Got BezierTo Segment.");
aBezier.emplace_back(x, y);
if (aBezier.size() == 3)
{
@@ -1386,7 +1141,6 @@ void ImpSdrPdfImport::ImportPath(FPDF_PAGEOBJECT pPageObject, int nPageObjectInd
break;
case FPDF_SEGMENT_MOVETO:
- SAL_WARN("sd.filter", "Got MoveTo Segment.");
// New Poly.
if (aPoly.count() > 0)
{
@@ -1425,15 +1179,11 @@ void ImpSdrPdfImport::ImportPath(FPDF_PAGEOBJECT pPageObject, int nPageObjectInd
FPDFPath_GetStrokeWidth(pPageObject, &fWidth);
const double dWidth = 0.5 * fabs(sqrt2(aPathMatrix.a(), aPathMatrix.c()) * fWidth);
mnLineWidth = lcl_ToLogic(lcl_PointToPixel(dWidth));
- // mnLineWidth /= 2;
- SAL_WARN("sd.filter", "Path Stroke Width: " << fWidth << ", scaled: " << dWidth
- << ", Logical: " << mnLineWidth);
int nFillMode = FPDF_FILLMODE_ALTERNATE;
FPDF_BOOL bStroke = true;
if (FPDFPath_GetDrawMode(pPageObject, &nFillMode, &bStroke))
{
- SAL_WARN("sd.filter", "Got PATH FillMode: " << nFillMode << ", Storke: " << bStroke);
if (nFillMode == FPDF_FILLMODE_ALTERNATE)
mpVD->SetDrawMode(DrawModeFlags::Default);
else if (nFillMode == FPDF_FILLMODE_WINDING)
@@ -1447,38 +1197,31 @@ void ImpSdrPdfImport::ImportPath(FPDF_PAGEOBJECT pPageObject, int nPageObjectInd
unsigned int nB;
unsigned int nA;
FPDFPath_GetFillColor(pPageObject, &nR, &nG, &nB, &nA);
- SAL_WARN("sd.filter", "Got PATH fill color: " << nR << ", " << nG << ", " << nB << ", " << nA);
mpVD->SetFillColor(Color(nR, nG, nB));
if (bStroke)
{
FPDFPath_GetStrokeColor(pPageObject, &nR, &nG, &nB, &nA);
- SAL_WARN("sd.filter",
- "Got PATH stroke color: " << nR << ", " << nG << ", " << nB << ", " << nA);
mpVD->SetLineColor(Color(nR, nG, nB));
}
else
mpVD->SetLineColor(COL_TRANSPARENT);
- // if(!mbLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(basegfx::B2DPolyPolygon(aSource)))
-
- SdrPathObj* pPath = new SdrPathObj(*mpModel, OBJ_POLY, aPolyPoly);
- SetAttributes(pPath);
- InsertObj(pPath, false);
+ if (!mbLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(basegfx::B2DPolyPolygon(aPolyPoly)))
+ {
+ SdrPathObj* pPath = new SdrPathObj(*mpModel, OBJ_POLY, aPolyPoly);
+ SetAttributes(pPath);
+ InsertObj(pPath, false);
+ }
}
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;
}
@@ -1486,21 +1229,15 @@ tools::Rectangle ImpSdrPdfImport::PointsToLogic(double left, double right, doubl
{
top = correctVertOrigin(top);
bottom = correctVertOrigin(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);
bottom = lcl_PointToPixel(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", "Logical BBox: " << aRect);
-
return aRect;
}
diff --git a/svx/source/svdraw/svdpdf.hxx b/svx/source/svdraw/svdpdf.hxx
index a41f62872bea..b076651c0009 100644
--- a/svx/source/svdraw/svdpdf.hxx
+++ b/svx/source/svdraw/svdpdf.hxx
@@ -109,44 +109,34 @@ class ImpSdrPdfImport final
/// Transform the rectangle (left, right, top, bottom) by this Matrix.
template <typename T> void Transform(T& left, T& right, T& top, T& bottom)
{
- SAL_WARN("sd.filter",
- "Transforming: " << left << ", " << right << ", " << top << ", " << bottom);
T leftTopX = left;
T leftTopY = top;
Transform(leftTopX, leftTopY);
- SAL_WARN("sd.filter", "Left-Top: " << leftTopX << ", " << leftTopY);
T leftBottomX = left;
T leftBottomY = bottom;
Transform(leftBottomX, leftBottomY);
- SAL_WARN("sd.filter", "Left-Bottom: " << leftBottomX << ", " << leftBottomY);
T rightTopX = right;
T rightTopY = top;
Transform(rightTopX, rightTopY);
- SAL_WARN("sd.filter", "Right-Top: " << rightTopX << ", " << rightTopY);
T rightBottomX = right;
T rightBottomY = bottom;
Transform(rightBottomX, rightBottomY);
- SAL_WARN("sd.filter", "Right-Bottom: " << rightBottomX << ", " << rightBottomY);
left = std::min(leftTopX, leftBottomX);
- SAL_WARN("sd.filter", "left: " << left);
right = std::max(rightTopX, rightBottomX);
- SAL_WARN("sd.filter", "right: " << right);
if (top > bottom)
top = std::max(leftTopY, rightTopY);
else
top = std::min(leftTopY, rightTopY);
- SAL_WARN("sd.filter", "top: " << top);
if (top > bottom)
bottom = std::max(leftBottomY, rightBottomY);
else
bottom = std::max(leftBottomY, rightBottomY);
- SAL_WARN("sd.filter", "bottom: " << bottom);
}
std::string toString() const
@@ -233,7 +223,7 @@ class ImpSdrPdfImport final
bool CheckLastLineMerge(const basegfx::B2DPolygon& rSrcPoly);
bool CheckLastPolyLineAndFillMerge(const basegfx::B2DPolyPolygon& rPolyPolygon);
- void DoLoopActions(SvdProgressInfo* pProgrInfo, sal_uInt32* pActionsToReport, int nPageIndex);
+ void DoObjects(SvdProgressInfo* pProgrInfo, sal_uInt32* pActionsToReport, int nPageIndex);
// Copy assignment is forbidden and not implemented.
ImpSdrPdfImport(const ImpSdrPdfImport&) = delete;