r17813 by fschmid - Improvements to the PDF importer:
scribus-commit
scribus-commit at lists.scribus.net
Sat Oct 20 09:14:30 UTC 2012
Author: fschmid
Date: Sat Oct 20 09:14:30 2012
New Revision: 17813
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=17813
Log:
Improvements to the PDF importer:
- Avoid groups with only one item inside
- Avoid groups with zero width or height
Modified:
trunk/Scribus/scribus/plugins/import/pdf/slaoutput.cpp
trunk/Scribus/scribus/plugins/import/pdf/slaoutput.h
trunk/Scribus/scribus/scribusdoc.cpp
Modified: trunk/Scribus/scribus/plugins/import/pdf/slaoutput.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17813&path=/trunk/Scribus/scribus/plugins/import/pdf/slaoutput.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/pdf/slaoutput.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/pdf/slaoutput.cpp Sat Oct 20 09:14:30 2012
@@ -99,15 +99,31 @@
{
m_Elements->removeAll(gElements.Items.at(d));
}
- m_doc->groupObjectsToItem(ite, gElements.Items);
- ite->setFillTransparency(1.0 - state->getFillOpacity());
- ite->setFillBlendmode(getBlendMode(state));
+ if ((gElements.Items.count() == 1) && (gElements.Items.first()->isImageFrame() || gElements.Items.first()->isGroup()))
+ {
+ PageItem *sing = gElements.Items.first();
+ m_Elements->replace(m_Elements->indexOf(ite), sing);
+ m_doc->Items->removeAll(sing);
+ m_doc->Items->replace(m_doc->Items->indexOf(ite), sing);
+ m_groupStack.top().Items.replace(m_groupStack.top().Items.indexOf(ite), sing);
+ sing->setFillTransparency(1.0 - (state->getFillOpacity() * (1.0 - ite->fillTransparency())));
+ sing->setFillBlendmode(getBlendMode(state));
+ sing->PoLine = ite->PoLine.copy();
+ delete ite;
+ }
+ else
+ {
+ m_doc->groupObjectsToItem(ite, gElements.Items);
+ ite->setFillTransparency(1.0 - state->getFillOpacity());
+ ite->setFillBlendmode(getBlendMode(state));
+ }
}
else
{
m_Elements->removeAll(ite);
m_doc->Items->removeAll(ite);
m_groupStack.top().Items.removeAll(ite);
+ delete ite;
}
}
if (m_clipStack.count() == 0)
@@ -224,6 +240,8 @@
QString output = convertPath(state->getPath());
FPointArray out;
out.parseSVG(output);
+ if (!pathIsClosed)
+ out.svgClosePath();
m_ctm = QTransform(ctm[0], ctm[1], ctm[2], ctm[3], ctm[4], ctm[5]);
out.map(m_ctm);
double xmin, ymin, xmax, ymax;
@@ -234,7 +252,9 @@
PageItem *ite = m_doc->Items->at(z);
FPoint wh(getMinClipF(&out));
out.translate(-wh.x(), -wh.y());
- ite->PoLine = out.copy(); //FIXME: try to avoid copy if FPointArray when properly shared
+ FPoint dim = out.WidthHeight();
+ if (!((dim.x() == 0.0) || (dim.y() == 0.0))) // avoid degenerate clipping paths
+ ite->PoLine = out.copy(); //FIXME: try to avoid copy if FPointArray when properly shared
ite->ClipEdited = true;
ite->FrameType = 3;
ite->setFillEvenOdd(false);
@@ -249,7 +269,6 @@
applyMask(ite);
}
clipEntry clp;
- clp.ClipCoords = out.copy();
clp.ClipItem = ite;
clp.grStackDepth = grStackDepth;
m_clipStack.push(clp);
@@ -265,6 +284,8 @@
QString output = convertPath(state->getPath());
FPointArray out;
out.parseSVG(output);
+ if (!pathIsClosed)
+ out.svgClosePath();
m_ctm = QTransform(ctm[0], ctm[1], ctm[2], ctm[3], ctm[4], ctm[5]);
out.map(m_ctm);
double xmin, ymin, xmax, ymax;
@@ -275,7 +296,9 @@
PageItem *ite = m_doc->Items->at(z);
FPoint wh(getMinClipF(&out));
out.translate(-wh.x(), -wh.y());
- ite->PoLine = out.copy(); //FIXME: try to avoid copy if FPointArray when properly shared
+ FPoint dim = out.WidthHeight();
+ if (!((dim.x() == 0.0) || (dim.y() == 0.0))) // avoid degenerate clipping paths
+ ite->PoLine = out.copy(); //FIXME: try to avoid copy if FPointArray when properly shared
ite->ClipEdited = true;
ite->FrameType = 3;
ite->setFillEvenOdd(true);
@@ -290,7 +313,6 @@
applyMask(ite);
}
clipEntry clp;
- clp.ClipCoords = out.copy();
clp.ClipItem = ite;
clp.grStackDepth = grStackDepth;
m_clipStack.push(clp);
Modified: trunk/Scribus/scribus/plugins/import/pdf/slaoutput.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17813&path=/trunk/Scribus/scribus/plugins/import/pdf/slaoutput.h
==============================================================================
--- trunk/Scribus/scribus/plugins/import/pdf/slaoutput.h (original)
+++ trunk/Scribus/scribus/plugins/import/pdf/slaoutput.h Sat Oct 20 09:14:30 2012
@@ -192,7 +192,6 @@
struct clipEntry
{
PageItem* ClipItem;
- FPointArray ClipCoords;
int grStackDepth;
};
QStack<clipEntry> m_clipStack;
Modified: trunk/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17813&path=/trunk/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.cpp (original)
+++ trunk/Scribus/scribus/scribusdoc.cpp Sat Oct 20 09:14:30 2012
@@ -14193,6 +14193,10 @@
maxx = qMax(maxx, x2);
maxy = qMax(maxy, y2);
}
+ if (groupItem->width() == 0)
+ groupItem->setWidth(maxx - minx);
+ if (groupItem->height() == 0)
+ groupItem->setHeight(maxy - miny);
groupItem->groupWidth = groupItem->width();
groupItem->groupHeight = groupItem->height();
for (uint c = 0; c < selectedItemCount; ++c)
More information about the scribus-commit
mailing list