summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2018-04-22 17:01:18 -0400
committerAshod Nakashian <ashod.nakashian@collabora.co.uk>2018-06-04 12:36:28 -0400
commit401638823f6657ec9f585df4d0a7c953d9d299e7 (patch)
tree7dc9f992ddc92bdeb21e1cffbaa129058f946b5d
parent9d03df990070b6e96cfb22d4413fd3e5d6a15763 (diff)
svx: support sub-paths in PDF import
Change-Id: Ibcfd30383db6846e791aea7609ab196c4f3f2da4 (cherry picked from commit 50bb1d4ab26a00bb2bb866df15ccb5660605fbe2)
-rw-r--r--svx/source/svdraw/svdpdf.cxx35
1 files changed, 25 insertions, 10 deletions
diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx
index a732989f092a..4b5d6af2d449 100644
--- a/svx/source/svdraw/svdpdf.cxx
+++ b/svx/source/svdraw/svdpdf.cxx
@@ -1320,17 +1320,19 @@ void ImpSdrPdfImport::ImportImage(FPDF_PAGEOBJECT pPageObject, int nPageObjectIn
void ImpSdrPdfImport::ImportPath(FPDF_PAGEOBJECT pPageObject, int nPageObjectIndex)
{
- SAL_WARN("sd.filter", "Got page object PATH: " << nPageObjectIndex);
-
double a, b, c, d, e, f;
FPDFPath_GetMatrix(pPageObject, &a, &b, &c, &d, &e, &f);
Matrix aPathMatrix(a, b, c, d, e, f);
aPathMatrix.Concatinate(mCurMatrix);
+ basegfx::B2DPolyPolygon aPolyPoly;
basegfx::B2DPolygon aPoly;
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);
@@ -1345,16 +1347,16 @@ void ImpSdrPdfImport::ImportPath(FPDF_PAGEOBJECT pPageObject, int nPageObjectInd
double x = fx;
double y = fy;
- SAL_WARN("sd.filter", "Got point (" << x << ", " << y << ") matrix (" << a << ", " << b
- << ", " << c << ", " << d << ", " << e << ", " << f
- << ')');
aPathMatrix.Transform(x, y);
-
const bool bClose = FPDFPathSegment_GetClose(pPathSegment);
if (bClose)
aPoly.setClosed(bClose); // TODO: Review
- SAL_WARN("sd.filter",
- "Point corrected (" << x << ", " << y << "): " << (bClose ? "CLOSE" : "OPEN"));
+
+ 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();
@@ -1379,6 +1381,13 @@ void ImpSdrPdfImport::ImportPath(FPDF_PAGEOBJECT pPageObject, int nPageObjectInd
case FPDF_SEGMENT_MOVETO:
SAL_WARN("sd.filter", "Got MoveTo Segment.");
+ // New Poly.
+ if (aPoly.count() > 0)
+ {
+ aPolyPoly.append(aPoly, 1);
+ aPoly.clear();
+ }
+
aPoly.append(basegfx::B2DPoint(x, y));
break;
@@ -1396,9 +1405,15 @@ void ImpSdrPdfImport::ImportPath(FPDF_PAGEOBJECT pPageObject, int nPageObjectInd
aBezier.clear();
}
+ if (aPoly.count() > 0)
+ {
+ aPolyPoly.append(aPoly, 1);
+ aPoly.clear();
+ }
+
const basegfx::B2DHomMatrix aTransform(
basegfx::utils::createScaleTranslateB2DHomMatrix(mfScaleX, mfScaleY, maOfs.X(), maOfs.Y()));
- aPoly.transform(aTransform);
+ aPolyPoly.transform(aTransform);
float fWidth = 1;
FPDFPath_GetStrokeWidth(pPageObject, &fWidth);
@@ -1428,7 +1443,7 @@ void ImpSdrPdfImport::ImportPath(FPDF_PAGEOBJECT pPageObject, int nPageObjectInd
// if(!mbLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(basegfx::B2DPolyPolygon(aSource)))
- SdrPathObj* pPath = new SdrPathObj(*mpModel, OBJ_POLY, basegfx::B2DPolyPolygon(aPoly));
+ SdrPathObj* pPath = new SdrPathObj(*mpModel, OBJ_POLY, aPolyPoly);
SetAttributes(pPath);
InsertObj(pPath, false);
}