r13905 by fschmid - WPG-Import: Ignore page color attributes for now, previously they have been assigned to the first polygon, which was not correct.

scribus-commit scribus-commit at lists.scribus.net
Wed Aug 26 05:54:33 CEST 2009


Revision: 13905
Author: fschmid
Date: 2009-08-24T09:01:23.751942Z
Commit message: WPG-Import: Ignore page color attributes for now, previously they have been assigned to the first polygon, which was not correct.

Changeset: 
M  /trunk/Scribus/scribus/plugins/wpgimplugin/wpg/libwpg_utils.h
M  /trunk/Scribus/scribus/plugins/wpgimplugin/importwpg.cpp
M  /trunk/Scribus/scribus/plugins/wpgimplugin/wpg/WPG2Parser.cpp
M  /trunk/Scribus/scribus/plugins/wpgimplugin/importwpg.h
M  /trunk/Scribus/scribus/plugins/wpgimplugin/wpg/WPG2Parser.h

Diffs:
Index: scribus/plugins/wpgimplugin/importwpg.cpp
===================================================================
--- scribus/plugins/wpgimplugin/importwpg.cpp	(revision 13904)
+++ scribus/plugins/wpgimplugin/importwpg.cpp	(revision 13905)
@@ -157,6 +157,8 @@
 		}
 		strokeSet = true;
 	}
+	else
+		CurrColorStroke = CommonStrings::None;
 }
 
 void ScrPainter::setBrush(const libwpg::WPGBrush& brush)
Index: scribus/plugins/wpgimplugin/wpg/WPG2Parser.h
===================================================================
--- scribus/plugins/wpgimplugin/wpg/WPG2Parser.h	(revision 13904)
+++ scribus/plugins/wpgimplugin/wpg/WPG2Parser.h	(revision 13905)
@@ -152,6 +152,7 @@
 private:
 	void handleStartWPG();
 	void handleEndWPG();
+	void handleFormSettings();
 	void handleLayer();
 	void handleCompoundPolygon();
 
Index: scribus/plugins/wpgimplugin/wpg/libwpg_utils.h
===================================================================
--- scribus/plugins/wpgimplugin/wpg/libwpg_utils.h	(revision 13904)
+++ scribus/plugins/wpgimplugin/wpg/libwpg_utils.h	(revision 13905)
@@ -28,7 +28,7 @@
 
 #include <stdio.h>
 
-//#define DEBUG // FIXME !
+// #define DEBUG // FIXME !
 
 // debug message includes source file and line number
 //#define VERBOSE_DEBUG 1
Index: scribus/plugins/wpgimplugin/wpg/WPG2Parser.cpp
===================================================================
--- scribus/plugins/wpgimplugin/wpg/WPG2Parser.cpp	(revision 13904)
+++ scribus/plugins/wpgimplugin/wpg/WPG2Parser.cpp	(revision 13905)
@@ -250,7 +250,7 @@
 	{
 		{ 0x01, "Start WPG",            &WPG2Parser::handleStartWPG },
 		{ 0x02, "End WPG",              &WPG2Parser::handleEndWPG },
-		{ 0x03, "Form Settings",        0 },     // ignored
+		{ 0x03, "Form Settings",        &WPG2Parser::handleFormSettings },
 		{ 0x04, "Ruler Settings",       0 },     // ignored
 		{ 0x05, "Grid Settings",        0 },     // ignored
 		{ 0x06, "Layer",                &WPG2Parser::handleLayer },
@@ -585,6 +585,26 @@
 	m_exit = true;
 }
 
+void WPG2Parser::handleFormSettings()
+{
+	unsigned int w = (m_doublePrecision) ? readU32() : readU16();
+	unsigned int h = (m_doublePrecision) ? readU32() : readU16();
+	double width = (TO_DOUBLE(w)) / m_xres;
+	double height = (TO_DOUBLE(h)) / m_yres;
+	m_input->seek(((m_doublePrecision) ? 4 : 2), WPX_SEEK_CUR);
+	unsigned int ml = (m_doublePrecision) ? readU32() : readU16();
+	unsigned int mr = (m_doublePrecision) ? readU32() : readU16();
+	unsigned int mt = (m_doublePrecision) ? readU32() : readU16();
+	unsigned int mb = (m_doublePrecision) ? readU32() : readU16();
+	double margL = (TO_DOUBLE(ml)) / m_xres;
+	double margR = (TO_DOUBLE(mr)) / m_xres;
+	double margT = (TO_DOUBLE(mt)) / m_xres;
+	double margB = (TO_DOUBLE(mb)) / m_xres;
+	
+	WPG_DEBUG_MSG(("Form Settings: width: %f height : %f\n", width, height));
+	WPG_DEBUG_MSG(("Form Margins:  left: %f right : %f top: %f bottom: %f\n", margL, margR, margT, margB));
+}
+
 void WPG2Parser::handleLayer()
 {
 	if (!m_graphicsStarted)
@@ -702,8 +722,13 @@
 {
 	if (!m_graphicsStarted)
 		return;
-	if (!m_groupStack.empty() && m_groupStack.top().isCompoundPolygon())
-		return;
+	if(!m_groupStack.empty())
+	{
+		if (m_groupStack.top().isCompoundPolygon())
+			return;
+		if (m_groupStack.top().parentType == 0x01) // we don't handle Page Attributes for now
+			return;
+	}
 	unsigned char red = readU8();
 	unsigned char green = readU8();
 	unsigned char blue = readU8();
@@ -718,8 +743,13 @@
 {
 	if (!m_graphicsStarted)
 		return;
-	if (!m_groupStack.empty() && m_groupStack.top().isCompoundPolygon())
-		return;
+	if(!m_groupStack.empty())
+	{
+		if (m_groupStack.top().isCompoundPolygon())
+			return;
+		if (m_groupStack.top().parentType == 0x01) // we don't handle Page Attributes for now
+			return;
+	}
 	// we just ignore the least significant 8 bits
 	unsigned int red = (m_doublePrecision)   ? readU16()>>8 : readU8();
 	unsigned int green = (m_doublePrecision) ? readU16()>>8 : readU8();
@@ -735,8 +765,13 @@
 {
 	if (!m_graphicsStarted)
 		return;
-	if (!m_groupStack.empty() && m_groupStack.top().isCompoundPolygon())
-		return;
+	if(!m_groupStack.empty())
+	{
+		if (m_groupStack.top().isCompoundPolygon())
+			return;
+		if (m_groupStack.top().parentType == 0x01) // we don't handle Page Attributes for now
+			return;
+	}
 	unsigned char red = readU8();
 	unsigned char green = readU8();
 	unsigned char blue = readU8();
@@ -751,8 +786,13 @@
 {
 	if (!m_graphicsStarted)
 		return;
-	if (!m_groupStack.empty() && m_groupStack.top().isCompoundPolygon())
-		return;
+	if(!m_groupStack.empty())
+	{
+		if (m_groupStack.top().isCompoundPolygon())
+			return;
+		if (m_groupStack.top().parentType == 0x01) // we don't handle Page Attributes for now
+			return;
+	}
 	// we just ignore the least significant 8 bits
 	unsigned int red = (m_doublePrecision)   ? readU16()>>8 : readU8();
 	unsigned int green = (m_doublePrecision) ? readU16()>>8 : readU8();
@@ -768,8 +808,13 @@
 {
 	if (!m_graphicsStarted)
 		return;
-	if (!m_groupStack.empty() && m_groupStack.top().isCompoundPolygon())
-		return;
+	if(!m_groupStack.empty())
+	{
+		if (m_groupStack.top().isCompoundPolygon())
+			return;
+		if (m_groupStack.top().parentType == 0x01) // we don't handle Page Attributes for now
+			return;
+	}
 	unsigned int style = readU16();
 
 	m_pen.dashArray = m_penStyles[style];
@@ -783,8 +828,13 @@
 {
 	if (!m_graphicsStarted)
 		return;
-	if (!m_groupStack.empty() && m_groupStack.top().isCompoundPolygon())
-		return;
+	if(!m_groupStack.empty())
+	{
+		if (m_groupStack.top().isCompoundPolygon())
+			return;
+		if (m_groupStack.top().parentType == 0x01) // we don't handle Page Attributes for now
+			return;
+	}
 	unsigned int width = readU16();
 	unsigned int height = readU16();
 
@@ -799,8 +849,13 @@
 {
 	if (!m_graphicsStarted)
 		return;
-	if (!m_groupStack.empty() && m_groupStack.top().isCompoundPolygon())
-		return;
+	if(!m_groupStack.empty())
+	{
+		if (m_groupStack.top().isCompoundPolygon())
+			return;
+		if (m_groupStack.top().parentType == 0x01) // we don't handle Page Attributes for now
+			return;
+	}
 	unsigned long width = readU32();
 	unsigned long height = readU32();
 
@@ -815,8 +870,13 @@
 {
 	if (!m_graphicsStarted)
 		return;
-	if (!m_groupStack.empty() && m_groupStack.top().isCompoundPolygon())
-		return;
+	if(!m_groupStack.empty())
+	{
+		if (m_groupStack.top().isCompoundPolygon())
+			return;
+		if (m_groupStack.top().parentType == 0x01) // we don't handle Page Attributes for now
+			return;
+	}
 	unsigned angleFraction = readU16();
 	unsigned angleInteger = readU16();
 	unsigned xref = readU16();
@@ -845,8 +905,13 @@
 {
 	if (!m_graphicsStarted)
 		return;
-	if (!m_groupStack.empty() && m_groupStack.top().isCompoundPolygon())
-		return;
+	if(!m_groupStack.empty())
+	{
+		if (m_groupStack.top().isCompoundPolygon())
+			return;
+		if (m_groupStack.top().parentType == 0x01) // we don't handle Page Attributes for now
+			return;
+	}
 	unsigned angleFraction = readU16();
 	unsigned angleInteger = readU16();
 	unsigned xref = readU16();
@@ -875,8 +940,13 @@
 {
 	if (!m_graphicsStarted)
 		return;
-	if (!m_groupStack.empty() && m_groupStack.top().isCompoundPolygon())
-		return;
+	if(!m_groupStack.empty())
+	{
+		if (m_groupStack.top().isCompoundPolygon())
+			return;
+		if (m_groupStack.top().parentType == 0x01) // we don't handle Page Attributes for now
+			return;
+	}
 	unsigned char gradientType = readU8();
 	WPG_DEBUG_MSG(("   Gradient type : %d (%s)\n", gradientType, describeGradient(gradientType)));
 
@@ -942,8 +1012,13 @@
 {
 	if (!m_graphicsStarted)
 		return;
-	if (!m_groupStack.empty() && m_groupStack.top().isCompoundPolygon())
-		return;
+	if(!m_groupStack.empty())
+	{
+		if (m_groupStack.top().isCompoundPolygon())
+			return;
+		if (m_groupStack.top().parentType == 0x01) // we don't handle Page Attributes for now
+			return;
+	}
 	unsigned char gradientType = readU8();
 	WPG_DEBUG_MSG(("   Gradient type : %d (%s)\n", gradientType, describeGradient(gradientType)));
 
@@ -1009,8 +1084,13 @@
 {
 	if (!m_graphicsStarted)
 		return;
-	if (!m_groupStack.empty() && m_groupStack.top().isCompoundPolygon())
-		return;
+	if(!m_groupStack.empty())
+	{
+		if (m_groupStack.top().isCompoundPolygon())
+			return;
+		if (m_groupStack.top().parentType == 0x01) // we don't handle Page Attributes for now
+			return;
+	}
 	unsigned char red = readU8();
 	unsigned char green = readU8();
 	unsigned char blue = readU8();
@@ -1027,8 +1107,13 @@
 {
 	if (!m_graphicsStarted)
 		return;
-	if (!m_groupStack.empty() && m_groupStack.top().isCompoundPolygon())
-		return;
+	if(!m_groupStack.empty())
+	{
+		if (m_groupStack.top().isCompoundPolygon())
+			return;
+		if (m_groupStack.top().parentType == 0x01) // we don't handle Page Attributes for now
+			return;
+	}
 	// we just ignore the least significant 8 bits
 	unsigned int red = (m_doublePrecision)   ? readU16()>>8 : readU8();
 	unsigned int green = (m_doublePrecision) ? readU16()>>8 : readU8();
@@ -1046,8 +1131,13 @@
 {
 	if (!m_graphicsStarted)
 		return;
-	if (!m_groupStack.empty() && m_groupStack.top().isCompoundPolygon())
-		return;
+	if(!m_groupStack.empty())
+	{
+		if (m_groupStack.top().isCompoundPolygon())
+			return;
+		if (m_groupStack.top().parentType == 0x01) // we don't handle Page Attributes for now
+			return;
+	}
 #ifdef DEBUG
 	unsigned int pattern = readU16();
 #endif
@@ -1400,8 +1490,12 @@
 	m_bitmap.y1 = TO_DOUBLE(ys1) / m_yres;
 	m_bitmap.x2 = TO_DOUBLE(xs2) / m_xres;
 	m_bitmap.y2 = TO_DOUBLE(ys2) / m_yres;
-        m_bitmap.hres = hres;
-        m_bitmap.vres = vres;
+	if (hres == 0)
+		hres = 72;
+	m_bitmap.hres = hres;
+	if (vres == 0)
+		vres = 72;
+	m_bitmap.vres = vres;
 
 	WPG_DEBUG_MSG(("   x1 : %li\n", x1));
 	WPG_DEBUG_MSG(("   y1 : %li\n", y1));
Index: scribus/plugins/wpgimplugin/importwpg.h
===================================================================
--- scribus/plugins/wpgimplugin/importwpg.h	(revision 13904)
+++ scribus/plugins/wpgimplugin/importwpg.h	(revision 13905)
@@ -36,17 +36,16 @@
 	void endGraphics();
 	void startLayer(unsigned int id);
 	void endLayer(unsigned int id);
-
 	void setPen(const libwpg::WPGPen& pen);
 	void setBrush(const libwpg::WPGBrush& brush);
 	void setFillRule(FillRule rule);
-
 	void drawRectangle(const libwpg::WPGRect& rect, double rx, double ry);
 	void drawEllipse(const libwpg::WPGPoint& center, double rx, double ry);
 	void drawPolygon(const libwpg::WPGPointArray& vertices);
 	void drawPath(const libwpg::WPGPath& path);
 	void drawBitmap(const libwpg::WPGBitmap& bitmap, double hres, double vres);
 	void drawImageObject(const libwpg::WPGBinaryData& binaryData);
+
 	void finishItem(PageItem* ite);
 	QList<PageItem*> Elements;
 	QStringList importedColors;




More information about the scribus-commit mailing list