r13981 by fschmid - First working version of the Macintosh Pict file importer, should be now stable enough to test. Note: only vector content is currently supported.

scribus-commit scribus-commit at lists.scribus.net
Wed Sep 9 17:15:18 CEST 2009


Revision: 13981
Author: fschmid
Date: 2009-09-09T15:12:33.181049Z
Commit message: First working version of the Macintosh Pict file importer, should be now stable enough to test. Note: only vector content is currently supported.

Changeset: 
M  /trunk/Scribus/scribus/plugins/CMakeLists.txt
M  /trunk/Scribus/scribus/plugins/pctimplugin/importpct.cpp
M  /trunk/Scribus/scribus/plugins/pctimplugin/importpct.h

Diffs:
Index: scribus/plugins/pctimplugin/importpct.cpp
===================================================================
--- scribus/plugins/pctimplugin/importpct.cpp	(revision 13980)
+++ scribus/plugins/pctimplugin/importpct.cpp	(revision 13981)
@@ -329,6 +329,8 @@
 	Coords.resize(0);
 	Coords.svgInit();
 	LineW = 1.0;
+	currentPoint = QPoint(0, 0);
+	lineMode = false;
 	importedColors.clear();
 	QList<PageItem*> gElements;
 	groupStack.push(gElements);
@@ -404,422 +406,523 @@
 	while (!ts.atEnd())
 	{
 		quint16 opCode, dataLen;
+		quint8 dataLenByte;
+		quint32 dataLenLong;
 		ts >> opCode;
 		QString tmp;
 		tmp.sprintf("%04X", opCode);
 		notImpl = "0x"+tmp;
-		switch (opCode)
+		if (((opCode >= 0x0092) && (opCode <= 0x0097)) || ((opCode >= 0x009C) && (opCode <= 0x009F)) || ((opCode >= 0x00A2) && (opCode <= 0x00AF)))
 		{
-			case 0x0000:		// NOP
-				qDebug() << "NOP";
-				break;
-			case 0x0001:		// Clipping Region
-				qDebug() << "Clipping Region";
-				ts >> dataLen;
-				ts.skipRawData(dataLen-2);
-				break;
-			case 0x0002:		// Background Pattern
-				qDebug() << "Background Pattern";
-				ts.skipRawData(8);
-				break;
-			case 0x0003:		// Text Font
-				qDebug() << "Text Font";
-				ts.skipRawData(2);
-				break;
-			case 0x0004:		// Text Style
-				qDebug() << "Text Style";
-				ts.skipRawData(1);
-				break;
-			case 0x0005:		// Text Mode
-				qDebug() << "Text Mode";
-				ts.skipRawData(2);
-				break;
-			case 0x0006:		// Extra Space
-				qDebug() << "Extra Space";
-				ts.skipRawData(4);
-				break;
-			case 0x0007:		// Pen Size
-				qDebug() << "Pen Size";
-				ts.skipRawData(4);
-				break;
-			case 0x0008:		// Pen Mode
-				qDebug() << "Pen Mode";
-				ts.skipRawData(2);
-				break;
-			case 0x0009:		// Pen Pattern
-				qDebug() << "Pen Pattern";
-				ts.skipRawData(8);
-				break;
-			case 0x000A:		// Fill Pattern
-				qDebug() << "Fill Pattern";
-				ts.skipRawData(8);
-				break;
-			case 0x000B:		// Oval Size
-				qDebug() << "Oval Size";
-				ts.skipRawData(4);
-				break;
-			case 0x000C:		// Origin
-				qDebug() << "Origin";
-				ts.skipRawData(4);
-				break;
-			case 0x000D:		// Text Size
-				qDebug() << "Text Size";
-				ts.skipRawData(2);
-				break;
-			case 0x000E:		// Foreground Color
-				qDebug() << "Foreground Color";
-				ts.skipRawData(4);
-				break;
-			case 0x000F:		// Background Color
-				qDebug() << "Background Color";
-				ts.skipRawData(4);
-				break;
-			case 0x0010:		// Text Ratio
-				qDebug() << "Text Ratio";
-				ts.skipRawData(8);
-				break;
-			case 0x0011:		// Version
-				qDebug() << "Version";
-				ts.skipRawData(1);
-				break;
-			case 0x0015:		// Fractional pen position
-				qDebug() << "Fractional pen position";
-				ts.skipRawData(2);
-				break;
-			case 0x0016:		// Extra char space
-				qDebug() << "Extra char space";
-				ts.skipRawData(2);
-				break;
-			case 0x0017:
-			case 0x0018:
-			case 0x0019:
-				qDebug() << "Reserved by Apple";
-				break;
-			case 0x001A:		// Foreground color RGB
-				handleColorRGB(ts, false);
-				break;
-			case 0x001B:		// Background color RGB
-				handleColorRGB(ts, true);
-				break;
-			case 0x001C:		// Highlight mode
-				qDebug() << "Highlight mode";
-				break;
-			case 0x001D:		// Highlight color RGB
-				qDebug() << "Highlight color RGB";
-				ts.skipRawData(6);
-				break;
-			case 0x001E:		// Use default highlight color
-				qDebug() << "Use default highlight color";
-				break;
-			case 0x0020:		// Line
-				qDebug() << "Line";
-				ts.skipRawData(8);
-				break;
-			case 0x0021:		// Line To
-				qDebug() << "Line To";
-				ts.skipRawData(4);
-				break;
-			case 0x0022:		// Short Line
-				qDebug() << "Short Line";
-				ts.skipRawData(6);
-				break;
-			case 0x0023:		// Short Line To
-				qDebug() << "Short Line To";
-				ts.skipRawData(2);
-				break;
-			case 0x002D:		// Line justify
-				qDebug() << "Line justify";
-				ts.skipRawData(10);
-				break;
-			case 0x002E:		// Glyph state
-				qDebug() << "Glyph state";
-				ts.skipRawData(8);
-				break;
-			case 0x0030:		// Frame rect
-				qDebug() << "Frame rect";
-				ts.skipRawData(8);
-				break;
-			case 0x0031:		// Paint rect
-				qDebug() << "Paint rect";
-				ts.skipRawData(8);
-				break;
-			case 0x0032:		// Erase rect
-				qDebug() << "Erase rect";
-				ts.skipRawData(8);
-				break;
-			case 0x0033:		// Invert rect
-				qDebug() << "Invert rect";
-				ts.skipRawData(8);
-				break;
-			case 0x0034:		// Fill rect
-				qDebug() << "Fill rect";
-				ts.skipRawData(8);
-				break;
-			case 0x0035:
-			case 0x0036:
-			case 0x0037:		// Reserved by Apple
-				qDebug() << "Reserved by Apple";
-				ts.skipRawData(8);
-				break;
-			case 0x0038:		// Frame same rect
-				qDebug() << "Frame same rect";
-				break;
-			case 0x0039:		// Paint same rect
-				qDebug() << "Paint same rect";
-				break;
-			case 0x003A:		// Erase same rect
-				qDebug() << "Erase same rect";
-				break;
-			case 0x003B:		// Invert same rect
-				qDebug() << "Invert same rect";
-				break;
-			case 0x003C:		// Fill same rect
-				qDebug() << "Fill same rect";
-				break;
-			case 0x003D:
-			case 0x003E:
-			case 0x003F:		// Reserved by Apple
-				qDebug() << "Reserved by Apple";
-				break;
-			case 0x0040:		// Frame round rect
-				qDebug() << "Frame round rect";
-				ts.skipRawData(8);
-				break;
-			case 0x0041:		// Paint round rect
-				qDebug() << "Paint round rect";
-				ts.skipRawData(8);
-				break;
-			case 0x0042:		// Erase round rect
-				qDebug() << "Erase round rect";
-				ts.skipRawData(8);
-				break;
-			case 0x0043:		// Invert round rect
-				qDebug() << "Invert round rect";
-				ts.skipRawData(8);
-				break;
-			case 0x0044:		// Fill round rect
-				qDebug() << "Fill round rect";
-				ts.skipRawData(8);
-				break;
-			case 0x0045:
-			case 0x0046:
-			case 0x0047:		// Reserved by Apple
-				qDebug() << "Reserved by Apple";
-				ts.skipRawData(8);
-				break;
-			case 0x0048:		// Frame same round rect
-				qDebug() << "Frame same round rect";
-				break;
-			case 0x0049:		// Paint same round rect
-				qDebug() << "Paint same round rect";
-				break;
-			case 0x004A:		// Erase same round rect
-				qDebug() << "Erase same round rect";
-				break;
-			case 0x004B:		// Invert same round rect
-				qDebug() << "Invert same round rect";
-				break;
-			case 0x004C:		// Fill same round rect
-				qDebug() << "Fill same round rect";
-				break;
-			case 0x004D:
-			case 0x004E:
-			case 0x004F:		// Reserved by Apple
-				qDebug() << "Reserved by Apple";
-				break;
-			case 0x0050:		// Frame oval
-				qDebug() << "Frame oval";
-				ts.skipRawData(8);
-				break;
-			case 0x0051:		// Paint oval
-				qDebug() << "Paint oval";
-				ts.skipRawData(8);
-				break;
-			case 0x0052:		// Erase oval
-				qDebug() << "Erase oval";
-				ts.skipRawData(8);
-				break;
-			case 0x0053:		// Invert oval
-				qDebug() << "Invert oval";
-				ts.skipRawData(8);
-				break;
-			case 0x0054:		// Fill oval
-				qDebug() << "Fill oval";
-				ts.skipRawData(8);
-				break;
-			case 0x0055:
-			case 0x0056:
-			case 0x0057:		// Reserved by Apple
-				qDebug() << "Reserved by Apple";
-				ts.skipRawData(8);
-				break;
-			case 0x0058:		// Frame same oval
-				qDebug() << "Frame same oval";
-				break;
-			case 0x0059:		// Paint same oval
-				qDebug() << "Paint same oval";
-				break;
-			case 0x005A:		// Erase same oval
-				qDebug() << "Erase same oval";
-				break;
-			case 0x005B:		// Invert same oval
-				qDebug() << "Invert same oval";
-				break;
-			case 0x005C:		// Fill same oval
-				qDebug() << "Fill same oval";
-				break;
-			case 0x005D:
-			case 0x005E:
-			case 0x005F:		// Reserved by Apple
-				qDebug() << "Reserved by Apple";
-				break;
-			case 0x0060:		// Frame arc
-				qDebug() << "Frame arc";
-				ts.skipRawData(12);
-				break;
-			case 0x0061:		// Paint arc
-				qDebug() << "Paint arc";
-				ts.skipRawData(12);
-				break;
-			case 0x0062:		// Erase arc
-				qDebug() << "Erase arc";
-				ts.skipRawData(12);
-				break;
-			case 0x0063:		// Invert arc
-				qDebug() << "Invert arc";
-				ts.skipRawData(12);
-				break;
-			case 0x0064:		// Fill arc
-				qDebug() << "Fill arc";
-				ts.skipRawData(12);
-				break;
-			case 0x0065:
-			case 0x0066:
-			case 0x0067:		// Reserved by Apple
-				qDebug() << "Reserved by Apple";
-				ts.skipRawData(12);
-				break;
-			case 0x0068:		// Frame same arc
-				qDebug() << "Frame same arc";
-				ts.skipRawData(4);
-				break;
-			case 0x0069:		// Paint same arc
-				qDebug() << "Paint same arc";
-				ts.skipRawData(4);
-				break;
-			case 0x006A:		// Erase same arc
-				qDebug() << "Erase same arc";
-				ts.skipRawData(4);
-				break;
-			case 0x006B:		// Invert same arc
-				qDebug() << "Invert same arc";
-				ts.skipRawData(4);
-				break;
-			case 0x006C:		// Fill same arc
-				qDebug() << "Fill same arc";
-				ts.skipRawData(4);
-				break;
-			case 0x006D:
-			case 0x006E:
-			case 0x006F:		// Reserved by Apple
-				qDebug() << "Reserved by Apple";
-				ts.skipRawData(4);
-				break;
-			case 0x0070:		// Frame poly
-			case 0x0071:		// Paint poly
-			case 0x0072:		// Erase poly
-			case 0x0073:		// Invert poly
-			case 0x0074:		// Fill poly
-				handlePolygon(ts, opCode);
-				break;
-			case 0x0075:
-			case 0x0076:
-			case 0x0077:		// Reserved by Apple
-				qDebug() << "Reserved by Apple";
-				ts >> dataLen;
-				ts.skipRawData(dataLen-2);
-				break;
-			case 0x0078:		// Frame same poly
-				qDebug() << "Frame same poly";
-				break;
-			case 0x0079:		// Paint same poly
-				qDebug() << "Paint same poly";
-				break;
-			case 0x007A:		// Erase same poly
-				qDebug() << "Erase same poly";
-				break;
-			case 0x007B:		// Invert same poly
-				qDebug() << "Invert same poly";
-				break;
-			case 0x007C:		// Fill same poly
-				qDebug() << "Fill same poly";
-				break;
-			case 0x007D:
-			case 0x007E:
-			case 0x007F:		// Reserved by Apple
-				qDebug() << "Reserved by Apple";
-				break;
-			case 0x0080:		// Frame region
-				qDebug() << "Frame region";
-				ts >> dataLen;
-				ts.skipRawData(dataLen-2);
-				break;
-			case 0x0081:		// Paint region
-				qDebug() << "Paint region";
-				ts >> dataLen;
-				ts.skipRawData(dataLen-2);
-				break;
-			case 0x0082:		// Erase region
-				qDebug() << "Erase region";
-				ts >> dataLen;
-				ts.skipRawData(dataLen-2);
-				break;
-			case 0x0083:		// Invert region
-				qDebug() << "Invert region";
-				ts >> dataLen;
-				ts.skipRawData(dataLen-2);
-				break;
-			case 0x0084:		// Fill region
-				qDebug() << "Fill region";
-				ts >> dataLen;
-				ts.skipRawData(dataLen-2);
-				break;
-			case 0x0085:
-			case 0x0086:
-			case 0x0087:		// Reserved by Apple
-				qDebug() << "Reserved by Apple";
-				ts >> dataLen;
-				ts.skipRawData(dataLen-2);
-				break;
-			case 0x0088:		// Frame same region
-				qDebug() << "Frame same region";
-				break;
-			case 0x0089:		// Paint same region
-				qDebug() << "Paint same region";
-				break;
-			case 0x008A:		// Erase same region
-				qDebug() << "Erase same region";
-				break;
-			case 0x008B:		// Invert same region
-				qDebug() << "Invert same region";
-				break;
-			case 0x008C:		// Fill same region
-				qDebug() << "Fill same region";
-				break;
-			case 0x008D:
-			case 0x008E:
-			case 0x008F:		// Reserved by Apple
-				qDebug() << "Reserved by Apple";
-				break;
-			case 0x00FF:		// End of Pict
-				qDebug() << "End of Pict";
-				return;
-				break;
-			default:
-				qDebug() << "Not implemented OpCode: " << notImpl;
-				return;
-				break;
+			// Reserved by Apple
+			qDebug() << "Reserved by Apple";
+			ts >> dataLen;
+			alignStreamToWord(ts, dataLen);
 		}
+		else if (((opCode >= 0x00B0) && (opCode <= 0x00CF)) || ((opCode >= 0x8000) && (opCode <= 0x80FF)))
+		{
+			// Reserved by Apple
+			qDebug() << "Reserved by Apple";
+		}
+		else if (((opCode >= 0x00D0) && (opCode <= 0x00FE)) || ((opCode >= 0x8100) && (opCode <= 0x81FF)))
+		{
+			// Reserved by Apple
+			qDebug() << "Reserved by Apple";
+			ts >> dataLenLong;
+			alignStreamToWord(ts, dataLenLong);
+		}
+		else if (((opCode >= 0x0100) && (opCode <= 0x01FF)) || ((opCode >= 0x02FF) && (opCode <= 0x0BFE)))
+		{
+			// Reserved by Apple
+			qDebug() << "Reserved by Apple";
+			alignStreamToWord(ts, 2);
+		}
+		else if ((opCode >= 0x0C00) && (opCode <= 0x7EFF))
+		{
+			// Reserved by Apple
+			qDebug() << "Reserved by Apple";
+			alignStreamToWord(ts, 24);
+		}
+		else if ((opCode >= 0x7F00) && (opCode <= 0x7FFF))
+		{
+			// Reserved by Apple
+			qDebug() << "Reserved by Apple";
+			alignStreamToWord(ts, 254);
+		}
+		else
+		{
+			switch (opCode)
+			{
+				case 0x0000:		// NOP
+					qDebug() << "NOP";
+					break;
+				case 0x0001:		// Clipping Region
+					qDebug() << "Clipping Region";
+					ts >> dataLen;
+					alignStreamToWord(ts, dataLen-2);
+					break;
+				case 0x0002:		// Background Pattern
+					qDebug() << "Background Pattern";
+					alignStreamToWord(ts, 8);
+					break;
+				case 0x0003:		// Text Font
+					qDebug() << "Text Font";
+					alignStreamToWord(ts, 2);
+					break;
+				case 0x0004:		// Text Style
+					qDebug() << "Text Style";
+					alignStreamToWord(ts, 1);
+					break;
+				case 0x0005:		// Text Mode
+					qDebug() << "Text Mode";
+					alignStreamToWord(ts, 2);
+					break;
+				case 0x0006:		// Extra Space
+					qDebug() << "Extra Space";
+					alignStreamToWord(ts, 4);
+					break;
+				case 0x0007:		// Pen Size
+					handlePenSize(ts);
+					break;
+				case 0x0008:		// Pen Mode
+					qDebug() << "Pen Mode";
+					alignStreamToWord(ts, 2);
+					break;
+				case 0x0009:		// Pen Pattern
+					qDebug() << "Pen Pattern";
+					alignStreamToWord(ts, 8);
+					break;
+				case 0x000A:		// Fill Pattern
+					qDebug() << "Fill Pattern";
+					alignStreamToWord(ts, 8);
+					break;
+				case 0x000B:		// Oval Size
+					qDebug() << "Oval Size";
+					alignStreamToWord(ts, 4);
+					break;
+				case 0x000C:		// Origin
+					qDebug() << "Origin";
+					alignStreamToWord(ts, 4);
+					break;
+				case 0x000D:		// Text Size
+					qDebug() << "Text Size";
+					alignStreamToWord(ts, 2);
+					break;
+				case 0x000E:		// Foreground Color
+					qDebug() << "Foreground Color";
+					alignStreamToWord(ts, 4);
+					break;
+				case 0x000F:		// Background Color
+					qDebug() << "Background Color";
+					alignStreamToWord(ts, 4);
+					break;
+				case 0x0010:		// Text Ratio
+					qDebug() << "Text Ratio";
+					alignStreamToWord(ts, 8);
+					break;
+				case 0x0011:		// Version
+					qDebug() << "Version";
+					alignStreamToWord(ts, 1);
+					break;
+				case 0x0015:		// Fractional pen position
+					qDebug() << "Fractional pen position";
+					alignStreamToWord(ts, 2);
+					break;
+				case 0x0016:		// Extra char space
+					qDebug() << "Extra char space";
+					alignStreamToWord(ts, 2);
+					break;
+				case 0x0017:
+				case 0x0018:
+				case 0x0019:
+					qDebug() << "Reserved by Apple";
+					break;
+				case 0x001A:		// Foreground color RGB
+					handleColorRGB(ts, false);
+					break;
+				case 0x001B:		// Background color RGB
+					handleColorRGB(ts, true);
+					break;
+				case 0x001C:		// Highlight mode
+					qDebug() << "Highlight mode";
+					break;
+				case 0x001D:		// Highlight color RGB
+					qDebug() << "Highlight color RGB";
+					alignStreamToWord(ts, 6);
+					break;
+				case 0x001E:		// Use default highlight color
+					qDebug() << "Use default highlight color";
+					break;
+				case 0x0020:		// Line
+					handleLine(ts);
+					break;
+				case 0x0021:		// Line To
+					handleLineFrom(ts);
+					break;
+				case 0x0022:		// Short Line
+					handleShortLine(ts);
+					break;
+				case 0x0023:		// Short Line To
+					handleShortLineFrom(ts);
+					break;
+				case 0x0024:
+				case 0x0025:
+				case 0x0026:
+				case 0x0027:		// Reserved by Apple
+					qDebug() << "Reserved by Apple";
+					ts >> dataLen;
+					alignStreamToWord(ts, dataLen);
+					break;
+				case 0x0028:		// Long Text
+					qDebug() << "Long Text";
+					ts >> dataLen;	// y Pos Text
+					ts >> dataLen;	// x Pos Text
+					ts >> dataLenByte;
+					alignStreamToWord(ts, dataLenByte);
+					break;
+				case 0x0029:		// Text DH
+					qDebug() << "Text DH";
+					ts >> dataLenByte;	// y Pos Text
+					ts >> dataLenByte;
+					alignStreamToWord(ts, dataLenByte);
+					break;
+				case 0x002A:		// Text DV
+					qDebug() << "Text DV";
+					ts >> dataLenByte;	// y Pos Text
+					ts >> dataLenByte;
+					alignStreamToWord(ts, dataLenByte);
+					break;
+				case 0x002B:		// Text DHV
+					qDebug() << "Text DHV";
+					ts >> dataLenByte;	// y Pos Text
+					ts >> dataLenByte;	// y Pos Text
+					ts >> dataLenByte;
+					alignStreamToWord(ts, dataLenByte);
+					break;
+				case 0x002C:		// Font Name
+					qDebug() << "Font Name";
+					ts >> dataLen;
+					alignStreamToWord(ts, dataLen);
+					break;
+				case 0x002D:		// Line justify
+					qDebug() << "Line justify";
+					alignStreamToWord(ts, 10);
+					break;
+				case 0x002E:		// Glyph state
+					qDebug() << "Glyph state";
+					alignStreamToWord(ts, 8);
+					break;
+				case 0x002F:		// Reserved by Apple
+					qDebug() << "Reserved by Apple";
+					ts >> dataLen;
+					alignStreamToWord(ts, dataLen);
+					break;
+				case 0x0030:		// Frame rect
+					qDebug() << "Frame rect";
+					alignStreamToWord(ts, 8);
+					break;
+				case 0x0031:		// Paint rect
+					qDebug() << "Paint rect";
+					alignStreamToWord(ts, 8);
+					break;
+				case 0x0032:		// Erase rect
+					qDebug() << "Erase rect";
+					alignStreamToWord(ts, 8);
+					break;
+				case 0x0033:		// Invert rect
+					qDebug() << "Invert rect";
+					alignStreamToWord(ts, 8);
+					break;
+				case 0x0034:		// Fill rect
+					qDebug() << "Fill rect";
+					alignStreamToWord(ts, 8);
+					break;
+				case 0x0035:
+				case 0x0036:
+				case 0x0037:		// Reserved by Apple
+					qDebug() << "Reserved by Apple";
+					alignStreamToWord(ts, 8);
+					break;
+				case 0x0038:		// Frame same rect
+					qDebug() << "Frame same rect";
+					break;
+				case 0x0039:		// Paint same rect
+					qDebug() << "Paint same rect";
+					break;
+				case 0x003A:		// Erase same rect
+					qDebug() << "Erase same rect";
+					break;
+				case 0x003B:		// Invert same rect
+					qDebug() << "Invert same rect";
+					break;
+				case 0x003C:		// Fill same rect
+					qDebug() << "Fill same rect";
+					break;
+				case 0x003D:
+				case 0x003E:
+				case 0x003F:		// Reserved by Apple
+					qDebug() << "Reserved by Apple";
+					break;
+				case 0x0040:		// Frame round rect
+					qDebug() << "Frame round rect";
+					alignStreamToWord(ts, 8);
+					break;
+				case 0x0041:		// Paint round rect
+					qDebug() << "Paint round rect";
+					alignStreamToWord(ts, 8);
+					break;
+				case 0x0042:		// Erase round rect
+					qDebug() << "Erase round rect";
+					alignStreamToWord(ts, 8);
+					break;
+				case 0x0043:		// Invert round rect
+					qDebug() << "Invert round rect";
+					alignStreamToWord(ts, 8);
+					break;
+				case 0x0044:		// Fill round rect
+					qDebug() << "Fill round rect";
+					alignStreamToWord(ts, 8);
+					break;
+				case 0x0045:
+				case 0x0046:
+				case 0x0047:		// Reserved by Apple
+					qDebug() << "Reserved by Apple";
+					alignStreamToWord(ts, 8);
+					break;
+				case 0x0048:		// Frame same round rect
+					qDebug() << "Frame same round rect";
+					break;
+				case 0x0049:		// Paint same round rect
+					qDebug() << "Paint same round rect";
+					break;
+				case 0x004A:		// Erase same round rect
+					qDebug() << "Erase same round rect";
+					break;
+				case 0x004B:		// Invert same round rect
+					qDebug() << "Invert same round rect";
+					break;
+				case 0x004C:		// Fill same round rect
+					qDebug() << "Fill same round rect";
+					break;
+				case 0x004D:
+				case 0x004E:
+				case 0x004F:		// Reserved by Apple
+					qDebug() << "Reserved by Apple";
+					break;
+				case 0x0050:		// Frame oval
+					qDebug() << "Frame oval";
+					alignStreamToWord(ts, 8);
+					break;
+				case 0x0051:		// Paint oval
+					qDebug() << "Paint oval";
+					alignStreamToWord(ts, 8);
+					break;
+				case 0x0052:		// Erase oval
+					qDebug() << "Erase oval";
+					alignStreamToWord(ts, 8);
+					break;
+				case 0x0053:		// Invert oval
+					qDebug() << "Invert oval";
+					alignStreamToWord(ts, 8);
+					break;
+				case 0x0054:		// Fill oval
+					qDebug() << "Fill oval";
+					alignStreamToWord(ts, 8);
+					break;
+				case 0x0055:
+				case 0x0056:
+				case 0x0057:		// Reserved by Apple
+					qDebug() << "Reserved by Apple";
+					alignStreamToWord(ts, 8);
+					break;
+				case 0x0058:		// Frame same oval
+					qDebug() << "Frame same oval";
+					break;
+				case 0x0059:		// Paint same oval
+					qDebug() << "Paint same oval";
+					break;
+				case 0x005A:		// Erase same oval
+					qDebug() << "Erase same oval";
+					break;
+				case 0x005B:		// Invert same oval
+					qDebug() << "Invert same oval";
+					break;
+				case 0x005C:		// Fill same oval
+					qDebug() << "Fill same oval";
+					break;
+				case 0x005D:
+				case 0x005E:
+				case 0x005F:		// Reserved by Apple
+					qDebug() << "Reserved by Apple";
+					break;
+				case 0x0060:		// Frame arc
+					qDebug() << "Frame arc";
+					alignStreamToWord(ts, 12);
+					break;
+				case 0x0061:		// Paint arc
+					qDebug() << "Paint arc";
+					alignStreamToWord(ts, 12);
+					break;
+				case 0x0062:		// Erase arc
+					qDebug() << "Erase arc";
+					alignStreamToWord(ts, 12);
+					break;
+				case 0x0063:		// Invert arc
+					qDebug() << "Invert arc";
+					alignStreamToWord(ts, 12);
+					break;
+				case 0x0064:		// Fill arc
+					qDebug() << "Fill arc";
+					alignStreamToWord(ts, 12);
+					break;
+				case 0x0065:
+				case 0x0066:
+				case 0x0067:		// Reserved by Apple
+					qDebug() << "Reserved by Apple";
+					alignStreamToWord(ts, 12);
+					break;
+				case 0x0068:		// Frame same arc
+					qDebug() << "Frame same arc";
+					alignStreamToWord(ts, 4);
+					break;
+				case 0x0069:		// Paint same arc
+					qDebug() << "Paint same arc";
+					alignStreamToWord(ts, 4);
+					break;
+				case 0x006A:		// Erase same arc
+					qDebug() << "Erase same arc";
+					alignStreamToWord(ts, 4);
+					break;
+				case 0x006B:		// Invert same arc
+					qDebug() << "Invert same arc";
+					alignStreamToWord(ts, 4);
+					break;
+				case 0x006C:		// Fill same arc
+					qDebug() << "Fill same arc";
+					alignStreamToWord(ts, 4);
+					break;
+				case 0x006D:
+				case 0x006E:
+				case 0x006F:		// Reserved by Apple
+					qDebug() << "Reserved by Apple";
+					alignStreamToWord(ts, 4);
+					break;
+				case 0x0070:		// Frame poly
+				case 0x0071:		// Paint poly
+				case 0x0072:		// Erase poly
+				case 0x0073:		// Invert poly
+				case 0x0074:		// Fill poly
+					handlePolygon(ts, opCode);
+					break;
+				case 0x0075:
+				case 0x0076:
+				case 0x0077:		// Reserved by Apple
+					qDebug() << "Reserved by Apple";
+					ts >> dataLen;
+					alignStreamToWord(ts, dataLen-2);
+					break;
+				case 0x0078:		// Frame same poly
+					qDebug() << "Frame same poly";
+					break;
+				case 0x0079:		// Paint same poly
+					qDebug() << "Paint same poly";
+					break;
+				case 0x007A:		// Erase same poly
+					qDebug() << "Erase same poly";
+					break;
+				case 0x007B:		// Invert same poly
+					qDebug() << "Invert same poly";
+					break;
+				case 0x007C:		// Fill same poly
+					qDebug() << "Fill same poly";
+					break;
+				case 0x007D:
+				case 0x007E:
+				case 0x007F:		// Reserved by Apple
+					qDebug() << "Reserved by Apple";
+					break;
+				case 0x0080:		// Frame region
+					qDebug() << "Frame region";
+					ts >> dataLen;
+					alignStreamToWord(ts, dataLen-2);
+					break;
+				case 0x0081:		// Paint region
+					qDebug() << "Paint region";
+					ts >> dataLen;
+					alignStreamToWord(ts, dataLen-2);
+					break;
+				case 0x0082:		// Erase region
+					qDebug() << "Erase region";
+					ts >> dataLen;
+					alignStreamToWord(ts, dataLen-2);
+					break;
+				case 0x0083:		// Invert region
+					qDebug() << "Invert region";
+					ts >> dataLen;
+					alignStreamToWord(ts, dataLen-2);
+					break;
+				case 0x0084:		// Fill region
+					qDebug() << "Fill region";
+					ts >> dataLen;
+					alignStreamToWord(ts, dataLen-2);
+					break;
+				case 0x0085:
+				case 0x0086:
+				case 0x0087:		// Reserved by Apple
+					qDebug() << "Reserved by Apple";
+					ts >> dataLen;
+					alignStreamToWord(ts, dataLen-2);
+					break;
+				case 0x0088:		// Frame same region
+					qDebug() << "Frame same region";
+					break;
+				case 0x0089:		// Paint same region
+					qDebug() << "Paint same region";
+					break;
+				case 0x008A:		// Erase same region
+					qDebug() << "Erase same region";
+					break;
+				case 0x008B:		// Invert same region
+					qDebug() << "Invert same region";
+					break;
+				case 0x008C:		// Fill same region
+					qDebug() << "Fill same region";
+					break;
+				case 0x008D:
+				case 0x008E:
+				case 0x008F:		// Reserved by Apple
+					qDebug() << "Reserved by Apple";
+					break;
+				case 0x00FF:		// End of Pict
+					handleLineModeEnd();
+					qDebug() << "End of Pict";
+					return;
+					break;
+				case 0x0200:		// Reserved by Apple
+					qDebug() << "Reserved by Apple";
+					alignStreamToWord(ts, 4);
+					break;
+				case 0x8200:		// Compressed QuickTime
+					qDebug() << "Compressed QuickTime";
+					ts >> dataLenLong;
+					alignStreamToWord(ts, dataLenLong);
+					break;
+				case 0x8201:		// Uncompressed QuickTime
+					qDebug() << "Uncompressed QuickTime";
+					ts >> dataLenLong;
+					alignStreamToWord(ts, dataLenLong);
+					break;
+				case 0xFFFF:		// Reserved by Apple
+					qDebug() << "Reserved by Apple";
+					ts >> dataLenLong;
+					alignStreamToWord(ts, dataLenLong);
+					break;
+				default:
+					qDebug() << "Not implemented OpCode: " << notImpl << "at" << ts.device()->pos()-2;
+					return;
+					break;
+			}
+		}
 		if (progressDialog)
 		{
 			progressDialog->setProgress("GI", ts.device()->pos());
@@ -828,8 +931,17 @@
 	}
 }
 
+void PctPlug::alignStreamToWord(QDataStream &ts, uint len)
+{
+	ts.skipRawData(len);
+	uint adj = ts.device()->pos() % 2;
+	if (adj != 0)
+		ts.skipRawData(1);
+}
+
 void PctPlug::handleColorRGB(QDataStream &ts, bool back)
 {
+	handleLineModeEnd();
 	QString tmpName = CommonStrings::None;
 	ScColor tmp;
 	ColorList::Iterator it;
@@ -871,6 +983,7 @@
 
 void PctPlug::handlePolygon(QDataStream &ts, quint16 opCode)
 {
+	handleLineModeEnd();
 	quint16 polySize;
 	ts >> polySize;				// read polygon size
 	ts.skipRawData(8);			// skip bounding rect;
@@ -891,8 +1004,16 @@
 		int z;
 		if (opCode == 0x0070)
 			z = m_Doc->itemAdd(PageItem::Polygon, PageItem::Unspecified, baseX, baseY, 10, 10, LineW, CommonStrings::None, CurrColorStroke, true);
+		else if ((opCode == 0x0071) || (opCode == 0x0074))
+			z = m_Doc->itemAdd(PageItem::Polygon, PageItem::Unspecified, baseX, baseY, 10, 10, LineW, CurrColorFill, CurrColorStroke, true);
 		else
-			z = m_Doc->itemAdd(PageItem::Polygon, PageItem::Unspecified, baseX, baseY, 10, 10, LineW, CurrColorFill, CurrColorStroke, true);
+		{
+			QString tmp;
+			tmp.sprintf("%04X", opCode);
+			tmp.prepend("0x");
+			qDebug() << "Not implemented OpCode: " << tmp;
+			return;
+		}
 		ite = m_Doc->Items->at(z);
 		ite->PoLine = Coords.copy();
 		ite->PoLine.translate(m_Doc->currentPage()->xOffset(), m_Doc->currentPage()->yOffset());
@@ -900,6 +1021,73 @@
 	}
 }
 
+void PctPlug::handlePenSize(QDataStream &ts)
+{
+	handleLineModeEnd();
+	quint16 x, y;
+	ts >> y >> x;
+	LineW = qMax(x, y);
+}
+
+void PctPlug::handleShortLine(QDataStream &ts)
+{
+	quint16 x, y;
+	qint8 dh, dv;
+	ts >> y >> x;
+	ts >> dh >> dv;
+	QPoint s = QPoint(x, y);
+	if (currentPoint != s)
+		Coords.svgMoveTo(x, y);
+	Coords.svgLineTo(x+dh, y+dv);
+	currentPoint = QPoint(x+dh, y+dv);
+	lineMode = true;
+}
+
+void PctPlug::handleShortLineFrom(QDataStream &ts)
+{
+	qint8 dh, dv;
+	ts >> dh >> dv;
+	QPoint s = currentPoint;
+	Coords.svgLineTo(s.x()+dh, s.y()+dv);
+	currentPoint = QPoint(s.x()+dh, s.y()+dv);
+	lineMode = true;
+}
+
+void PctPlug::handleLine(QDataStream &ts)
+{
+	quint16 x1, x2, y1, y2;
+	ts >> y1 >> x1;
+	ts >> y2 >> x2;
+	QPoint s = QPoint(x1, y1);
+	if (currentPoint != s)
+		Coords.svgMoveTo(x1, y1);
+	Coords.svgLineTo(x2, y2);
+	currentPoint = QPoint(x2, y2);
+	lineMode = true;
+}
+
+void PctPlug::handleLineFrom(QDataStream &ts)
+{
+	quint16 x, y;
+	ts >> y >> x;
+	Coords.svgLineTo(x, y);
+	currentPoint = QPoint(x, y);
+	lineMode = true;
+}
+
+void PctPlug::handleLineModeEnd()
+{
+	if ((Coords.size() > 4) && lineMode)
+	{
+		int z = m_Doc->itemAdd(PageItem::PolyLine, PageItem::Unspecified, baseX, baseY, 10, 10, LineW, CommonStrings::None, CurrColorStroke, true);
+		PageItem *ite = m_Doc->Items->at(z);
+		ite->PoLine = Coords.copy();
+		ite->PoLine.translate(m_Doc->currentPage()->xOffset(), m_Doc->currentPage()->yOffset());
+		finishItem(ite);
+	}
+	lineMode = false;
+}
+
 void PctPlug::finishItem(PageItem* ite)
 {
 	ite->ClipEdited = true;
Index: scribus/plugins/pctimplugin/importpct.h
===================================================================
--- scribus/plugins/pctimplugin/importpct.h	(revision 13980)
+++ scribus/plugins/pctimplugin/importpct.h	(revision 13981)
@@ -60,8 +60,15 @@
 	bool convert(QString fn);
 	void parsePictVersion1(QDataStream &ts);
 	void parsePictVersion2(QDataStream &ts);
+	void alignStreamToWord(QDataStream &ts, uint len);
 	void handleColorRGB(QDataStream &ts, bool back);
 	void handlePolygon(QDataStream &ts, quint16 opCode);
+	void handlePenSize(QDataStream &ts);
+	void handleShortLine(QDataStream &ts);
+	void handleShortLineFrom(QDataStream &ts);
+	void handleLine(QDataStream &ts);
+	void handleLineFrom(QDataStream &ts);
+	void handleLineModeEnd();
 	void finishItem(PageItem* ite);
 	
 	QList<PageItem*> Elements;
@@ -81,6 +88,8 @@
 	QStringList importedColors;
 
 	FPointArray Coords;
+	QPoint currentPoint;
+	bool lineMode;
 	bool interactive;
 	MultiProgressDialog * progressDialog;
 	bool cancel;
Index: scribus/plugins/CMakeLists.txt
===================================================================
--- scribus/plugins/CMakeLists.txt	(revision 13980)
+++ scribus/plugins/CMakeLists.txt	(revision 13981)
@@ -19,7 +19,7 @@
 ADD_SUBDIRECTORY(xfigimplugin)
 ADD_SUBDIRECTORY(cvgimplugin)
 ADD_SUBDIRECTORY(wpgimplugin)
-# ADD_SUBDIRECTORY(pctimplugin)
+ADD_SUBDIRECTORY(pctimplugin)
 ADD_SUBDIRECTORY(tools)
 # ADD_SUBDIRECTORY(picbrowser)
 




More information about the scribus-commit mailing list