r17815 by fschmid - More Improvements to the PDF importer, try to minimize the number of groups.

scribus-commit scribus-commit at lists.scribus.net
Sun Oct 21 18:19:38 UTC 2012


Author: fschmid
Date: Sun Oct 21 18:19:38 2012
New Revision: 17815

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=17815
Log:
More Improvements to the PDF importer, try to minimize the number of groups.

Modified:
    trunk/Scribus/scribus/plugins/import/pdf/slaoutput.cpp

Modified: trunk/Scribus/scribus/plugins/import/pdf/slaoutput.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17815&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 Sun Oct 21 18:19:38 2012
@@ -99,9 +99,13 @@
 					{
 						m_Elements->removeAll(gElements.Items.at(d));
 					}
-					if ((gElements.Items.count() == 1) && (gElements.Items.first()->isImageFrame() || gElements.Items.first()->isGroup()))
+					PageItem *sing = gElements.Items.first();
+					if ((gElements.Items.count() == 1)
+						 && (sing->isImageFrame()  || sing->isGroup() || sing->isPolygon() || sing->isPolyLine())
+						 && (ite->patternMask().isEmpty() || sing->patternMask().isEmpty() || (sing->patternMask() == ite->patternMask()))
+						 && (state->getFillOpacity() == (1.0 - ite->fillTransparency()))
+					   )
 					{
-						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);
@@ -113,7 +117,24 @@
 							sing->setPatternMask(ite->patternMask());
 							sing->setMaskType(ite->maskType());
 						}
-						sing->PoLine = ite->PoLine.copy();
+						if (sing->isGroup() || (sing->lineColor() == CommonStrings::None))
+						{
+							if (!sing->isPolyLine())
+							{
+								QPainterPath input1 = sing->PoLine.toQPainterPath(true);
+								if (sing->fillEvenOdd())
+									input1.setFillRule(Qt::OddEvenFill);
+								else
+									input1.setFillRule(Qt::WindingFill);
+								QPainterPath input2 = ite->PoLine.toQPainterPath(true);
+								if (ite->fillEvenOdd())
+									input2.setFillRule(Qt::OddEvenFill);
+								else
+									input2.setFillRule(Qt::WindingFill);
+								QPainterPath result = input1.intersected(input2);
+								sing->PoLine.fromQPainterPath(result);
+							}
+						}
 						delete ite;
 					}
 					else
@@ -158,16 +179,16 @@
 		tmpSel->clear();
 		if (gElements.Items.count() > 0)
 		{
-			for (int dre = 0; dre < gElements.Items.count(); ++dre)
-			{
-				tmpSel->addItem(gElements.Items.at(dre), true);
-				m_Elements->removeAll(gElements.Items.at(dre));
-			}
-			PageItem *ite = m_doc->groupObjectsSelection(tmpSel);
-			ite->setFillTransparency(1.0 - state->getFillOpacity());
-			ite->setFillBlendmode(getBlendMode(state));
 			if (gElements.forSoftMask)
 			{
+				for (int dre = 0; dre < gElements.Items.count(); ++dre)
+				{
+					tmpSel->addItem(gElements.Items.at(dre), true);
+					m_Elements->removeAll(gElements.Items.at(dre));
+				}
+				PageItem *ite = m_doc->groupObjectsSelection(tmpSel);
+				ite->setFillTransparency(1.0 - state->getFillOpacity());
+				ite->setFillBlendmode(getBlendMode(state));
 				ScPattern pat = ScPattern();
 				pat.setDoc(m_doc);
 				m_doc->DoDrawing = true;
@@ -190,13 +211,25 @@
 			}
 			else
 			{
+				PageItem *ite;
+				for (int dre = 0; dre < gElements.Items.count(); ++dre)
+				{
+					tmpSel->addItem(gElements.Items.at(dre), true);
+					m_Elements->removeAll(gElements.Items.at(dre));
+				}
+				if (gElements.Items.count() != 1)
+					ite = m_doc->groupObjectsSelection(tmpSel);
+				else
+					ite = gElements.Items.first();
+				ite->setFillTransparency(1.0 - state->getFillOpacity());
+				ite->setFillBlendmode(getBlendMode(state));
 				for (int as = 0; as < tmpSel->count(); ++as)
 				{
 					m_Elements->append(tmpSel->itemAt(as));
 				}
-			}
-			if (m_groupStack.count() != 0)
-				applyMask(ite);
+				if (m_groupStack.count() != 0)
+					applyMask(ite);
+			}
 		}
 		if (m_groupStack.count() != 0)
 		{
@@ -366,19 +399,54 @@
 			ite->PoLine = out.copy();
 			ite->ClipEdited = true;
 			ite->FrameType = 3;
-			ite->setLineShade(shade);
-			ite->setLineTransparency(1.0 - state->getStrokeOpacity());
-			ite->setLineBlendmode(getBlendMode(state));
-			ite->setLineEnd(PLineEnd);
-			ite->setLineJoin(PLineJoin);
-			ite->setDashes(DashValues);
-			ite->setDashOffset(DashOffset);
 			ite->setWidthHeight(wh.x(),wh.y());
-			ite->setTextFlowMode(PageItem::TextFlowDisabled);
 			m_doc->AdjustItemSize(ite);
-			m_Elements->append(ite);
-			if (m_groupStack.count() != 0)
-				m_groupStack.top().Items.append(ite);
+			if (m_Elements->count() != 0)
+			{
+				PageItem* lItem = m_Elements->last();
+				if ((lItem->lineColor() == CommonStrings::None) && (lItem->PoLine == ite->PoLine))
+				{
+					lItem->setLineColor(CurrColorStroke);
+					lItem->setLineWidth(state->getTransformedLineWidth());
+					lItem->setLineShade(shade);
+					lItem->setLineTransparency(1.0 - state->getStrokeOpacity());
+					lItem->setLineBlendmode(getBlendMode(state));
+					lItem->setLineEnd(PLineEnd);
+					lItem->setLineJoin(PLineJoin);
+					lItem->setDashes(DashValues);
+					lItem->setDashOffset(DashOffset);
+					lItem->setTextFlowMode(PageItem::TextFlowDisabled);
+					m_doc->Items->removeAll(ite);
+				}
+				else
+				{
+					ite->setLineShade(shade);
+					ite->setLineTransparency(1.0 - state->getStrokeOpacity());
+					ite->setLineBlendmode(getBlendMode(state));
+					ite->setLineEnd(PLineEnd);
+					ite->setLineJoin(PLineJoin);
+					ite->setDashes(DashValues);
+					ite->setDashOffset(DashOffset);
+					ite->setTextFlowMode(PageItem::TextFlowDisabled);
+					m_Elements->append(ite);
+					if (m_groupStack.count() != 0)
+						m_groupStack.top().Items.append(ite);
+				}
+			}
+			else
+			{
+				ite->setLineShade(shade);
+				ite->setLineTransparency(1.0 - state->getStrokeOpacity());
+				ite->setLineBlendmode(getBlendMode(state));
+				ite->setLineEnd(PLineEnd);
+				ite->setLineJoin(PLineJoin);
+				ite->setDashes(DashValues);
+				ite->setDashOffset(DashOffset);
+				ite->setTextFlowMode(PageItem::TextFlowDisabled);
+				m_Elements->append(ite);
+				if (m_groupStack.count() != 0)
+					m_groupStack.top().Items.append(ite);
+			}
 		}
 	}
 }




More information about the scribus-commit mailing list