summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2018-04-22 17:01:18 -0400
committerJan Holesovsky <kendy@collabora.com>2018-06-01 08:59:21 +0200
commit8e55f000d0f2a99843246eecda5a931f24ef12bf (patch)
treeba87da361af407fa4c4a55570651a3e0d4e6c07b /svx
parent31a0ea06df7773b8654ac9a941b45366ae8f9548 (diff)
svx: support sub-paths in PDF import
Change-Id: Ibcfd30383db6846e791aea7609ab196c4f3f2da4
Diffstat (limited to 'svx')
-rw-r--r--svx/source/svdraw/svdpdf.cxx33
1 files changed, 24 insertions, 9 deletions
diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx
index 4b0ad0820472..e2dc149e333a 100644
--- a/svx/source/svdraw/svdpdf.cxx
+++ b/svx/source/svdraw/svdpdf.cxx
@@ -1316,17 +1316,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);
@@ -1341,16 +1343,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();
@@ -1375,6 +1377,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;
@@ -1392,6 +1401,12 @@ 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);
@@ -1424,7 +1439,7 @@ void ImpSdrPdfImport::ImportPath(FPDF_PAGEOBJECT pPageObject, int nPageObjectInd
// if(!mbLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(basegfx::B2DPolyPolygon(aSource)))
- SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, basegfx::B2DPolyPolygon(aPoly));
+ SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, aPolyPoly);
SetAttributes(pPath);
InsertObj(pPath, false);
}