Beispiel #1
0
void ScrPainter::setBrush(const libwpg::WPGBrush& brush)
{
	ScColor tmp;
	ColorList::Iterator it;
	CurrColorFill = "Black";
	CurrFillShade = 100.0;
	int Rc, Gc, Bc;
	if(brush.style == libwpg::WPGBrush::Solid)
	{
		Rc = brush.foreColor.red;
		Gc = brush.foreColor.green;
		Bc = brush.foreColor.blue;
		tmp.setColorRGB(Rc, Gc, Bc);
		tmp.setSpotColor(false);
		tmp.setRegistrationColor(false);
		QString newColorName = "FromWPG"+tmp.name();
		QString fNam = m_Doc->PageColors.tryAddColor(newColorName, tmp);
		if (fNam == newColorName)
			importedColors.append(newColorName);
		CurrColorFill = fNam;
		CurrFillTrans = brush.foreColor.alpha / 255.0;
	}
	else if (brush.style == libwpg::WPGBrush::Gradient)
	{
		gradientAngle = brush.gradient.angle();
		isGradient = true;
		currentGradient = VGradient(VGradient::linear);
		currentGradient.clearStops();
		for(unsigned c = 0; c < brush.gradient.count(); c++)
		{
			QString currStopColor = CommonStrings::None;
			Rc = brush.gradient.stopColor(c).red;
			Gc = brush.gradient.stopColor(c).green;
			Bc = brush.gradient.stopColor(c).blue;
			tmp.setColorRGB(Rc, Gc, Bc);
			tmp.setSpotColor(false);
			tmp.setRegistrationColor(false);
			QString newColorName = "FromWPG"+tmp.name();
			QString fNam = m_Doc->PageColors.tryAddColor(newColorName, tmp);
			if (fNam == newColorName)
				importedColors.append(newColorName);
			currStopColor = fNam;
			const ScColor& gradC = m_Doc->PageColors[currStopColor];
			double pos = qBound(0.0, fabs(brush.gradient.stopOffset(c)), 1.0);
			currentGradient.addStop( ScColorEngine::getRGBColor(gradC, m_Doc), pos, 0.5, 1.0, currStopColor, 100 );
		}
	}
	else if (brush.style == libwpg::WPGBrush::NoBrush)
		CurrColorFill = CommonStrings::None;
	fillSet = true;
}
Beispiel #2
0
void XtgScanner::defColor()
{
	bool isSpot = false;
	ScColor tmp;
	enterState(stringMode);
	token = getToken();
	while (lookAhead() != '>' )
	{
		token = getToken();
		if ((token == "CMJN") || (token == "CMYK"))
		{
			enterState(tagMode);
			token = getToken();
			if (token == "S")
			{
				token = getToken();
				isSpot = true;
			}
			double c = getToken().toDouble();
			double m = getToken().toDouble();
			double y = getToken().toDouble();
			double k = getToken().toDouble();
			tmp.setColor(qRound(c * 2.55), qRound(m * 255), qRound(y * 255), qRound(k * 255));
			tmp.setSpotColor(isSpot);
			tmp.setRegistrationColor(false);
			doc->PageColors.tryAddColor(sfcName, tmp);
		}
		else if (token == "RGB")
		{
			enterState(tagMode);
			token = getToken();
			if (token == "S")
			{
				token = getToken();
				isSpot = true;
			}
			double r = getToken().toDouble();
			double g = getToken().toDouble();
			double b = getToken().toDouble();
			tmp.setColorRGB(qRound(r * 2.55), qRound(g * 255), qRound(b * 255));
			tmp.setSpotColor(isSpot);
			tmp.setRegistrationColor(false);
			doc->PageColors.tryAddColor(sfcName, tmp);
		}
	}
	top++;
	enterState(textMode);
}
Beispiel #3
0
void ScrPainter::setPen(const libwpg::WPGPen& pen)
{
	LineW = 72 * pen.width;
	ScColor tmp;
	ColorList::Iterator it;
	CurrColorStroke = "Black";
	CurrStrokeShade = 100.0;
	int Rc, Gc, Bc;
	Rc = pen.foreColor.red;
	Gc = pen.foreColor.green;
	Bc = pen.foreColor.blue;
	tmp.setColorRGB(Rc, Gc, Bc);
	tmp.setSpotColor(false);
	tmp.setRegistrationColor(false);
	QString newColorName = "FromWPG"+tmp.name();
	QString fNam = m_Doc->PageColors.tryAddColor(newColorName, tmp);
	if (fNam == newColorName)
		importedColors.append(newColorName);
	CurrColorStroke = fNam;
	CurrStrokeTrans = pen.foreColor.alpha / 255.0;
	if(!pen.solid)
	{
		dashArray.clear();
		for(unsigned i = 0; i < pen.dashArray.count(); i++)
		{
			dashArray.append(pen.dashArray.at(i)*LineW);
		}
	}
	switch (pen.joinstyle)
	{
		case 1:
			lineJoin = Qt::BevelJoin;
			break;
		case 2:
			lineJoin = Qt::MiterJoin;
			break;
		case 3:
			lineJoin = Qt::RoundJoin;
			break;
		default:
			lineJoin = Qt::MiterJoin;
			break;
	}
	switch (pen.capstyle)
	{
		case 0:
			lineEnd = Qt::FlatCap;
			break;
		case 1:
			lineEnd = Qt::RoundCap;
			break;
		case 2:
			lineEnd = Qt::SquareCap;
			break;
		default:
			lineEnd = Qt::FlatCap;
			break;
	}
	strokeSet = true;
}
Beispiel #4
0
QString SmlPlug::processColor(QDomElement &elem)
{
	QString colnam = elem.attribute("color","#ffffff");
	QColor stroke;
	stroke.setNamedColor("#"+colnam.right(6));
	ScColor tmp;
	tmp.fromQColor(stroke);
	tmp.setSpotColor(false);
	tmp.setRegistrationColor(false);
	QString newColorName = "FromSML"+tmp.name();
	QString fNam = m_Doc->PageColors.tryAddColor(newColorName, tmp);
	if (fNam == newColorName)
		importedColors.append(newColorName);
	return fNam;
}
Beispiel #5
0
void XfigPlug::parseColor(QString data)
{
	if (data.isEmpty())
		return;
	int colorNum, dummy;
	QString colorValues;
	ScColor tmp;
	ScTextStream Code(&data, QIODevice::ReadOnly);
	Code >> dummy >> colorNum >> colorValues;
	tmp.setNamedColor(colorValues);
	tmp.setSpotColor(false);
	tmp.setRegistrationColor(false);
	QString namPrefix = "FromXfig%1-"+colorValues;
	CustColors.insert(namPrefix.arg(colorNum), tmp);
	importedColors.insert(colorNum, namPrefix.arg(colorNum));
}
Beispiel #6
0
bool importColorsFromFile(QString fileName, ColorList &EditColors)
{
	int oldCount = EditColors.count();
	if (!fileName.isEmpty())
	{
		QFileInfo fi = QFileInfo(fileName);
		QString ext = fi.suffix().toLower();
		if (extensionIndicatesEPSorPS(ext) || (ext == "ai"))
		{
			QString tmp, tmp2, FarNam;
			double c, m, y, k;
			ScColor cc;
			QFile f(fileName);
			if (f.open(QIODevice::ReadOnly))
			{
				bool isAtend = false;
				QDataStream ts(&f);
				while (!ts.atEnd())
				{
					tmp = readLinefromDataStream(ts);
					if ((tmp.startsWith("%%CMYKCustomColor")) || (tmp.startsWith("%%CMYKProcessColor")))
					{
						if (tmp.contains("(atend)"))
							isAtend = true;
						else
						{
							if (tmp.startsWith("%%CMYKCustomColor"))
								tmp = tmp.remove(0,18);
							else if (tmp.startsWith("%%CMYKProcessColor"))
								tmp = tmp.remove(0,19);
							ScTextStream ts2(&tmp, QIODevice::ReadOnly);
							ts2 >> c >> m >> y >> k;
							FarNam = ts2.readAll();
							FarNam = FarNam.trimmed();
							FarNam = FarNam.remove(0,1);
							FarNam = FarNam.remove(FarNam.length()-1,1);
							FarNam = FarNam.simplified();
							cc = ScColor(qRound(255 * c), qRound(255 * m), qRound(255 * y), qRound(255 * k));
							cc.setSpotColor(true);
							if ((!EditColors.contains(FarNam)) && (!FarNam.isEmpty()))
								EditColors.insert(FarNam, cc);
							while (!ts.atEnd())
							{
								quint64 oldPos = ts.device()->pos();
								tmp = readLinefromDataStream(ts);
								if (!tmp.startsWith("%%+"))
								{
									ts.device()->seek(oldPos);
									break;
								}
								tmp = tmp.remove(0,3);
								ScTextStream ts2(&tmp, QIODevice::ReadOnly);
								ts2 >> c >> m >> y >> k;
								FarNam = ts2.readAll();
								FarNam = FarNam.trimmed();
								FarNam = FarNam.remove(0,1);
								FarNam = FarNam.remove(FarNam.length()-1,1);
								FarNam = FarNam.simplified();
								cc = ScColor(qRound(255 * c), qRound(255 * m), qRound(255 * y), qRound(255 * k));
								cc.setSpotColor(true);
								if ((!EditColors.contains(FarNam)) && (!FarNam.isEmpty()))
									EditColors.insert(FarNam, cc);
							}
						}
					}
					if (tmp.startsWith("%%RGBCustomColor"))
					{
						if (tmp.contains("(atend)"))
							isAtend = true;
						else
						{
							tmp = tmp.remove(0,17);
							ScTextStream ts2(&tmp, QIODevice::ReadOnly);
							ts2 >> c >> m >> y;
							FarNam = ts2.readAll();
							FarNam = FarNam.trimmed();
							FarNam = FarNam.remove(0,1);
							FarNam = FarNam.remove(FarNam.length()-1,1);
							FarNam = FarNam.simplified();
							cc = ScColor(qRound(255 * c), qRound(255 * m), qRound(255 * y));
							if ((!EditColors.contains(FarNam)) && (!FarNam.isEmpty()))
								EditColors.insert(FarNam, cc);
							while (!ts.atEnd())
							{
								quint64 oldPos = ts.device()->pos();
								tmp = readLinefromDataStream(ts);
								if (!tmp.startsWith("%%+"))
								{
									ts.device()->seek(oldPos);
									break;
								}
								tmp = tmp.remove(0,3);
								ScTextStream ts2(&tmp, QIODevice::ReadOnly);
								ts2 >> c >> m >> y;
								FarNam = ts2.readAll();
								FarNam = FarNam.trimmed();
								FarNam = FarNam.remove(0,1);
								FarNam = FarNam.remove(FarNam.length()-1,1);
								FarNam = FarNam.simplified();
								cc = ScColor(qRound(255 * c), qRound(255 * m), qRound(255 * y));
								if ((!EditColors.contains(FarNam)) && (!FarNam.isEmpty()))
									EditColors.insert(FarNam, cc);
							}
						}
					}
					if (tmp.startsWith("%%EndComments"))
					{
						if (ext == "ai")
						{
							while (!ts.atEnd())
							{
								bool isX = false;
								tmp = readLinefromDataStream(ts);
								if ((tmp.endsWith("Xa") || tmp.endsWith(" k") || tmp.endsWith(" x")) && (tmp.length() > 4))
								{
									ScTextStream ts2(&tmp, QIODevice::ReadOnly);
									ts2 >> c >> m >> y >> k;
									if (tmp.endsWith(" x"))
									{
										isX = true;
										int an = tmp.indexOf("(");
										int en = tmp.lastIndexOf(")");
										FarNam = tmp.mid(an+1, en-an-1);
										FarNam = FarNam.simplified();
									}
									tmp = readLinefromDataStream(ts);
									if (tmp.endsWith("Pc"))
									{
										if (!isX)
										{
											tmp = tmp.trimmed();
											tmp = tmp.remove(0,1);
											int en = tmp.indexOf(")");
											FarNam = tmp.mid(0, en);
											FarNam = FarNam.simplified();
										}
										cc = ScColor(qRound(255 * c), qRound(255 * m), qRound(255 * y), qRound(255 * k));
										cc.setSpotColor(true);
										if (!EditColors.contains(FarNam))
											EditColors.insert(FarNam, cc);
									}
								}
							}
						}
						if (!isAtend)
							break;
					}
				}
Beispiel #7
0
bool importColorsFromFile(QString fileName, ColorList &EditColors, QHash<QString, VGradient> *dialogGradients, bool merge)
{
	int oldCount = EditColors.count();
	if (!fileName.isEmpty())
	{
		QFileInfo fi = QFileInfo(fileName);
		QString ext = fi.suffix().toLower();
		if (extensionIndicatesEPSorPS(ext))
		{
			QString tmp, tmp2, FarNam;
			double c, m, y, k;
			ScColor cc;
			QFile f(fileName);
			if (f.open(QIODevice::ReadOnly))
			{
				bool isAtend = false;
				QDataStream ts(&f);
				while (!ts.atEnd())
				{
					tmp = readLinefromDataStream(ts);
					if ((tmp.startsWith("%%CMYKCustomColor")) || (tmp.startsWith("%%CMYKProcessColor")))
					{
						if (tmp.contains("(atend)"))
							isAtend = true;
						else
						{
							if (tmp.startsWith("%%CMYKCustomColor"))
								tmp = tmp.remove(0,18);
							else if (tmp.startsWith("%%CMYKProcessColor"))
								tmp = tmp.remove(0,19);
							ScTextStream ts2(&tmp, QIODevice::ReadOnly);
							ts2 >> c >> m >> y >> k;
							FarNam = ts2.readAll();
							FarNam = FarNam.trimmed();
							FarNam = FarNam.remove(0,1);
							FarNam = FarNam.remove(FarNam.length()-1,1);
							FarNam = FarNam.simplified();
							cc = ScColor(qRound(255 * c), qRound(255 * m), qRound(255 * y), qRound(255 * k));
							cc.setSpotColor(true);
							if (!FarNam.isEmpty())
								EditColors.tryAddColor(FarNam, cc);
							while (!ts.atEnd())
							{
								quint64 oldPos = ts.device()->pos();
								tmp = readLinefromDataStream(ts);
								if (!tmp.startsWith("%%+"))
								{
									ts.device()->seek(oldPos);
									break;
								}
								tmp = tmp.remove(0,3);
								ScTextStream ts2(&tmp, QIODevice::ReadOnly);
								ts2 >> c >> m >> y >> k;
								FarNam = ts2.readAll();
								FarNam = FarNam.trimmed();
								FarNam = FarNam.remove(0,1);
								FarNam = FarNam.remove(FarNam.length()-1,1);
								FarNam = FarNam.simplified();
								cc = ScColor(qRound(255 * c), qRound(255 * m), qRound(255 * y), qRound(255 * k));
								cc.setSpotColor(true);
								if (!FarNam.isEmpty())
									EditColors.tryAddColor(FarNam, cc);
							}
						}
					}
					if ((tmp.startsWith("%%RGBCustomColor")) || (tmp.startsWith("%%RGBProcessColor")))
					{
						if (tmp.contains("(atend)"))
							isAtend = true;
						else
						{
							if (tmp.startsWith("%%RGBCustomColor"))
								tmp = tmp.remove(0,17);
							else if (tmp.startsWith("%%RGBProcessColor"))
								tmp = tmp.remove(0,18);
							ScTextStream ts2(&tmp, QIODevice::ReadOnly);
							ts2 >> c >> m >> y;
							FarNam = ts2.readAll();
							FarNam = FarNam.trimmed();
							FarNam = FarNam.remove(0,1);
							FarNam = FarNam.remove(FarNam.length()-1,1);
							FarNam = FarNam.simplified();
							cc = ScColor(qRound(255 * c), qRound(255 * m), qRound(255 * y));
							if (!FarNam.isEmpty())
								EditColors.tryAddColor(FarNam, cc);
							while (!ts.atEnd())
							{
								quint64 oldPos = ts.device()->pos();
								tmp = readLinefromDataStream(ts);
								if (!tmp.startsWith("%%+"))
								{
									ts.device()->seek(oldPos);
									break;
								}
								tmp = tmp.remove(0,3);
								ScTextStream ts2(&tmp, QIODevice::ReadOnly);
								ts2 >> c >> m >> y;
								FarNam = ts2.readAll();
								FarNam = FarNam.trimmed();
								FarNam = FarNam.remove(0,1);
								FarNam = FarNam.remove(FarNam.length()-1,1);
								FarNam = FarNam.simplified();
								cc = ScColor(qRound(255 * c), qRound(255 * m), qRound(255 * y));
								if (!FarNam.isEmpty())
									EditColors.tryAddColor(FarNam, cc);
							}
						}
					}
					if (tmp.startsWith("%%EndComments"))
					{
						if (!isAtend)
							break;
					}
				}
				f.close();
			}
		}
Beispiel #8
0
void ShapePlug::parseGroup(QDomNode &DOC)
{
    QString tmp = "";
    QString FillCol = "White";
    QString StrokeCol = "Black";
    QString defFillCol = "White";
    QString defStrokeCol = "Black";
    QColor stroke = Qt::black;
    QColor fill = Qt::white;
//	Qt::PenStyle Dash = Qt::SolidLine;
    Qt::PenCapStyle LineEnd = Qt::FlatCap;
    Qt::PenJoinStyle LineJoin = Qt::MiterJoin;
//	int fillStyle = 1;
    double strokewidth = 0.1;
//	bool poly = false;
    while(!DOC.isNull())
    {
        double x1, y1, x2, y2;
        StrokeCol = defStrokeCol;
        FillCol = defFillCol;
        stroke = Qt::black;
        fill = Qt::white;
        //	fillStyle = 1;
        strokewidth = 1.0;
        //	Dash = Qt::SolidLine;
        LineEnd = Qt::FlatCap;
        LineJoin = Qt::MiterJoin;
        FPointArray PoLine;
        PoLine.resize(0);
        QDomElement pg = DOC.toElement();
        QString STag = pg.tagName();
        QString style = pg.attribute( "style", "" ).simplified();
        if (style.isEmpty())
            style = pg.attribute( "svg:style", "" ).simplified();
        QStringList substyles = style.split(';', QString::SkipEmptyParts);
        for( QStringList::Iterator it = substyles.begin(); it != substyles.end(); ++it )
        {
            QStringList substyle = (*it).split(':', QString::SkipEmptyParts);
            QString command(substyle[0].trimmed());
            QString params(substyle[1].trimmed());
            if (command == "fill")
            {
                if (!((params == "foreground") || (params == "background") || (params == "fg") || (params == "bg") || (params == "none") || (params == "default") || (params == "inverse")))
                {
                    if (params == "nofill")
                        FillCol = CommonStrings::None;
                    else
                    {
                        fill.setNamedColor( params );
                        FillCol = "FromDia"+fill.name();
                        ScColor tmp;
                        tmp.fromQColor(fill);
                        tmp.setSpotColor(false);
                        tmp.setRegistrationColor(false);
                        QString fNam = m_Doc->PageColors.tryAddColor(FillCol, tmp);
                        if (fNam == FillCol)
                            importedColors.append(FillCol);
                        FillCol = fNam;
                    }
                }
            }
            else if (command == "stroke")
            {
                if (!((params == "foreground") || (params == "background") || (params == "fg") || (params == "bg") || (params == "none") || (params == "default")) || (params == "inverse"))
                {
                    stroke.setNamedColor( params );
                    StrokeCol = "FromDia"+stroke.name();
                    ScColor tmp;
                    tmp.fromQColor(stroke);
                    tmp.setSpotColor(false);
                    tmp.setRegistrationColor(false);
                    QString fNam = m_Doc->PageColors.tryAddColor(StrokeCol, tmp);
                    if (fNam == StrokeCol)
                        importedColors.append(StrokeCol);
                    StrokeCol = fNam;
                }
            }
            else if (command == "stroke-width")
                strokewidth = ScCLocale::toDoubleC(params);
            else if( command == "stroke-linejoin" )
            {
                if( params == "miter" )
                    LineJoin = Qt::MiterJoin;
                else if( params == "round" )
                    LineJoin = Qt::RoundJoin;
                else if( params == "bevel" )
                    LineJoin = Qt::BevelJoin;
            }
            else if( command == "stroke-linecap" )
            {
                if( params == "butt" )
                    LineEnd = Qt::FlatCap;
                else if( params == "round" )
                    LineEnd = Qt::RoundCap;
                else if( params == "square" )
                    LineEnd = Qt::SquareCap;
            }
        }
        if (STag == "svg:line")
        {
            x1 = ScCLocale::toDoubleC(pg.attribute("x1")) * Conversion;
            y1 = ScCLocale::toDoubleC(pg.attribute("y1")) * Conversion;
            x2 = ScCLocale::toDoubleC(pg.attribute("x2")) * Conversion;
            y2 = ScCLocale::toDoubleC(pg.attribute("y2")) * Conversion;
            PoLine.addPoint(x1, y1);
            PoLine.addPoint(x1, y1);
            PoLine.addPoint(x2, y2);
            PoLine.addPoint(x2, y2);
            int z = m_Doc->itemAdd(PageItem::PolyLine, PageItem::Unspecified, baseX, baseY, 10, 10, strokewidth, CommonStrings::None, StrokeCol);
            m_Doc->Items->at(z)->PoLine = PoLine.copy();
            finishItem(m_Doc->Items->at(z));
        }
        else if (STag == "svg:rect")
        {
            x1 = ScCLocale::toDoubleC(pg.attribute("x")) * Conversion;
            y1 = ScCLocale::toDoubleC(pg.attribute("y")) * Conversion;
            x2 = ScCLocale::toDoubleC(pg.attribute("width")) * Conversion;
            y2 = ScCLocale::toDoubleC(pg.attribute("height")) * Conversion;
            int z = m_Doc->itemAdd(PageItem::Polygon, PageItem::Rectangle, baseX + x1, baseY + y1, x2, y2, strokewidth, FillCol, StrokeCol);
            m_Doc->Items->at(z)->setLineJoin(LineJoin);
            m_Doc->Items->at(z)->setLineEnd(LineEnd);
            finishItem(m_Doc->Items->at(z));
        }
        else if ((STag == "svg:polygon") || (STag == "svg:polyline"))
        {
            bool bFirst = true;
            double x = 0.0;
            double y = 0.0;
            QString points = pg.attribute( "points" ).simplified().replace(',', " ");
            QStringList pointList = points.split(' ', QString::SkipEmptyParts);
            FirstM = true;
            for( QStringList::Iterator it = pointList.begin(); it != pointList.end(); it++ )
            {
                x = ScCLocale::toDoubleC(*(it++));
                y = ScCLocale::toDoubleC(*it);
                if( bFirst )
                {
                    svgMoveTo(x * Conversion, y * Conversion);
                    bFirst = false;
                    WasM = true;
                }
                else
                {
                    svgLineTo(&PoLine, x * Conversion, y * Conversion);
                }
            }
            if (STag == "svg:polygon")
                svgClosePath(&PoLine);
            if (PoLine.size() < 4)
            {
                DOC = DOC.nextSibling();
                continue;
            }
            int z;
            if (STag == "svg:polygon")
                z = m_Doc->itemAdd(PageItem::Polygon, PageItem::Unspecified, baseX, baseY, 10, 10, strokewidth, FillCol, StrokeCol);
            else
                z = m_Doc->itemAdd(PageItem::PolyLine, PageItem::Unspecified, baseX, baseY, 10, 10, strokewidth, CommonStrings::None, StrokeCol);
            m_Doc->Items->at(z)->PoLine = PoLine.copy();
            finishItem(m_Doc->Items->at(z));
        }
        else if ((STag == "svg:circle") || (STag == "svg:ellipse"))
        {
            x1 = ScCLocale::toDoubleC(pg.attribute("r")) * Conversion;
            y1 = ScCLocale::toDoubleC(pg.attribute("r")) * Conversion;
            x2 = ScCLocale::toDoubleC(pg.attribute("cx")) * Conversion - x1;
            y2 = ScCLocale::toDoubleC(pg.attribute("cy")) * Conversion - y1;
            x1 *= 2.0;
            y1 *= 2.0;
            int z = m_Doc->itemAdd(PageItem::Polygon, PageItem::Ellipse, baseX + x1, baseY + y1, x2, y2, strokewidth, FillCol, StrokeCol);
            m_Doc->Items->at(z)->setLineJoin(LineJoin);
            m_Doc->Items->at(z)->setLineEnd(LineEnd);
            finishItem(m_Doc->Items->at(z));
        }
        else if (STag == "svg:path")
        {
            //	poly =
            parseSVG( pg.attribute( "d" ), &PoLine );
            if (PoLine.size() < 4)
            {
                DOC = DOC.nextSibling();
                continue;
            }
            int z = m_Doc->itemAdd(PageItem::Polygon, PageItem::Unspecified, baseX, baseY, 10, 10, strokewidth, FillCol, StrokeCol);
            m_Doc->Items->at(z)->PoLine = PoLine.copy();
            finishItem(m_Doc->Items->at(z));
        }
        else if (STag == "svg:g")
        {
            int z = m_Doc->itemAdd(PageItem::Group, PageItem::Rectangle, baseX, baseX, 1, 1, 0, CommonStrings::None, CommonStrings::None);
            PageItem *neu = m_Doc->Items->at(z);
            Elements.append(neu);
            if (groupStack.count() > 0)
                groupStack.top().append(neu);
            QList<PageItem*> gElements;
            groupStack.push(gElements);
            QDomNode child = DOC.firstChild();
            parseGroup(child);
            if (gElements.count() == 0)
            {
                groupStack.pop();
                Elements.removeAll(neu);
                groupStack.top().removeAll(neu);
                Selection tmpSelection(m_Doc, false);
                tmpSelection.addItem(neu);
                m_Doc->itemSelection_DeleteItem(&tmpSelection);
            }
            else
            {
                QList<PageItem*> gElem = groupStack.pop();
                double minx =  std::numeric_limits<double>::max();
                double miny =  std::numeric_limits<double>::max();
                double maxx = -std::numeric_limits<double>::max();
                double maxy = -std::numeric_limits<double>::max();
                for (int gr = 0; gr < gElements.count(); ++gr)
                {
                    PageItem* currItem = gElem.at(gr);
                    double x1, x2, y1, y2;
                    currItem->getVisualBoundingRect(&x1, &y1, &x2, &y2);
                    minx = qMin(minx, x1);
                    miny = qMin(miny, y1);
                    maxx = qMax(maxx, x2);
                    maxy = qMax(maxy, y2);
                }
                double gx = minx;
                double gy = miny;
                double gw = maxx - minx;
                double gh = maxy - miny;
                neu->setXYPos(gx, gy, true);
                neu->setWidthHeight(gw, gh, true);
                neu->SetRectFrame();
                neu->Clip = FlattenPath(neu->PoLine, neu->Segments);
                neu->setItemName( tr("Group%1").arg(m_Doc->GroupCounter));
                neu->AutoName = false;
                neu->gXpos = neu->xPos() - gx;
                neu->gYpos = neu->yPos() - gy;
                neu->groupWidth = gw;
                neu->groupHeight = gh;
                for (int gr = 0; gr < gElem.count(); ++gr)
                {
                    PageItem* currItem = gElem.at(gr);
                    currItem->gXpos = currItem->xPos() - gx;
                    currItem->gYpos = currItem->yPos() - gy;
                    currItem->gWidth = gw;
                    currItem->gHeight = gh;
                    currItem->Parent = neu;
                    neu->groupItemList.append(currItem);
                    m_Doc->Items->removeAll(currItem);
                    Elements.removeAll(currItem);
                }
                neu->setRedrawBounding();
                neu->setTextFlowMode(PageItem::TextFlowDisabled);
                m_Doc->GroupCounter++;
            }
        }
        DOC = DOC.nextSibling();
    }
}
bool PaletteLoader_Swatchbook::importFile(const QString& fileName, bool /*merge*/)
{
	ScColor lf;
	int oldCount = m_colors->count();
	
	QScopedPointer<ScZipHandler> uz(new ScZipHandler());
	if (!uz->open(fileName))
		return false;
	if (!uz->contains("swatchbook.xml"))
		return false;
	
	QByteArray docBytes;
	if (!uz->read("swatchbook.xml", docBytes))
		return false;

	QString docText = QString::fromUtf8(docBytes);
	QDomDocument docu("scridoc");
	if (!docu.setContent(docText))
		return false;
	
	QDomElement docElem = docu.documentElement();
	for (QDomElement drawPag = docElem.firstChildElement(); !drawPag.isNull(); drawPag = drawPag.nextSiblingElement())
	{
		if (drawPag.tagName() == "materials")
		{
			for (QDomElement spf = drawPag.firstChildElement(); !spf.isNull(); spf = spf.nextSiblingElement() )
			{
				if (spf.tagName() == "color")
				{
					bool isSpot = spf.attribute("usage") == "spot";
					QString colorName = "";
					ScColor tmp;
					tmp.setRegistrationColor(false);
					for (QDomElement spp = spf.firstChildElement(); !spp.isNull(); spp = spp.nextSiblingElement() )
					{
						if (spp.tagName() == "metadata")
						{
							for (QDomElement spm = spp.firstChildElement(); !spm.isNull(); spm = spm.nextSiblingElement() )
							{
								if (spm.tagName() == "dc:identifier")
									colorName = spm.text();
							}
						}
						else if (spp.tagName() == "values")
						{
							QString colorVals = spp.text();
							ScTextStream CoE(&colorVals, QIODevice::ReadOnly);
							if (spp.attribute("model") == "Lab")
							{
								double inC[3];
								CoE >> inC[0];
								CoE >> inC[1];
								CoE >> inC[2];
								tmp.setLabColor(inC[0], inC[1], inC[2]);
								tmp.setSpotColor(isSpot);
							}
							else if (spp.attribute("model") == "CMYK")
							{
								double c, m, y, k;
								CoE >> c >> m >> y >> k;
								tmp.setColorF(c, m, y, k);
								tmp.setSpotColor(isSpot);
							}
							else if (spp.attribute("model") == "RGB")
							{
								double r, g, b;
								CoE >> r >> g >> b;
								tmp.setRgbColorF(r, g, b);
								tmp.setSpotColor(false);
							}
Beispiel #10
0
void ColorSetManager::initialiseDefaultPrefs(struct ApplicationPrefs& appPrefs)
{
	QString defaultSwatch = ScPaths::instance().shareDir() + "swatches/" + "Scribus_Basic.xml";
	QFile fiC(defaultSwatch);
	if (!fiC.exists())
	{
		appPrefs.colorPrefs.DColors.insert("White", ScColor(0, 0, 0, 0));
		appPrefs.colorPrefs.DColors.insert("Black", ScColor(0, 0, 0, 255));
		ScColor cc = ScColor(255, 255, 255, 255);
		cc.setRegistrationColor(true);
		appPrefs.colorPrefs.DColors.insert("Registration", cc);
		appPrefs.colorPrefs.DColors.insert("Blue", ScColor(255, 255, 0, 0));
		appPrefs.colorPrefs.DColors.insert("Cyan", ScColor(255, 0, 0, 0));
		appPrefs.colorPrefs.DColors.insert("Green", ScColor(255, 0, 255, 0));
		appPrefs.colorPrefs.DColors.insert("Red", ScColor(0, 255, 255, 0));
		appPrefs.colorPrefs.DColors.insert("Yellow", ScColor(0, 0, 255, 0));
		appPrefs.colorPrefs.DColors.insert("Magenta", ScColor(0, 255, 0, 0));
		appPrefs.colorPrefs.DColorSet = "Scribus_Small";
	}
	else
	{
		if (fiC.open(QIODevice::ReadOnly))
		{
			QString ColorEn, Cname;
			int Rval, Gval, Bval;
			QTextStream tsC(&fiC);
			ColorEn = tsC.readLine();
			if (ColorEn.startsWith("<?xml version="))
			{
				QByteArray docBytes("");
				loadRawText(defaultSwatch, docBytes);
				QString docText("");
				docText = QString::fromUtf8(docBytes);
				QDomDocument docu("scridoc");
				docu.setContent(docText);
				ScColor lf = ScColor();
				QDomElement elem = docu.documentElement();
				QDomNode PAGE = elem.firstChild();
				while(!PAGE.isNull())
				{
					QDomElement pg = PAGE.toElement();
					if(pg.tagName()=="COLOR" && pg.attribute("NAME")!=CommonStrings::None)
					{
						if (pg.hasAttribute("CMYK"))
							lf.setNamedColor(pg.attribute("CMYK"));
						else
							lf.fromQColor(QColor(pg.attribute("RGB")));
						if (pg.hasAttribute("Spot"))
							lf.setSpotColor(static_cast<bool>(pg.attribute("Spot").toInt()));
						else
							lf.setSpotColor(false);
						if (pg.hasAttribute("Register"))
							lf.setRegistrationColor(static_cast<bool>(pg.attribute("Register").toInt()));
						else
							lf.setRegistrationColor(false);
						appPrefs.colorPrefs.DColors.insert(pg.attribute("NAME"), lf);
					}
					PAGE=PAGE.nextSibling();
				}
			}
			else
			{
				while (!tsC.atEnd())
				{
					ColorEn = tsC.readLine();
					QTextStream CoE(&ColorEn, QIODevice::ReadOnly);
					CoE >> Rval;
					CoE >> Gval;
					CoE >> Bval;
					CoE >> Cname;
					ScColor tmp;
					tmp.setColorRGB(Rval, Gval, Bval);
					appPrefs.colorPrefs.DColors.insert(Cname, tmp);
				}
			}
			fiC.close();
		}
		appPrefs.colorPrefs.DColorSet = ScPaths::instance().shareDir() + "swatches/" + "Scribus Basic";
	}
bool PaletteLoader_Autocad_acb::importFile(const QString& fileName, bool /*merge*/)
{
	QByteArray docBytes;
	loadRawText(fileName, docBytes);
	QString docText = QString::fromUtf8(docBytes);
	QDomDocument docu("scridoc");
	if (!docu.setContent(docText))
		return false;

	ScColor lf;
	int oldCount = m_colors->count();

	QDomElement elem = docu.documentElement();
	QDomNode PAGE = elem.firstChild();
	while (!PAGE.isNull())
	{
		QDomElement pg = PAGE.toElement();
		if (pg.tagName() == "colorPage")
		{
			QDomNode colNode = pg.firstChild();
			while (!colNode.isNull())
			{
				QDomElement cg = colNode.toElement();
				if (cg.tagName() == "colorEntry")
				{
					int r (0), g(0), b(0);
					QString colorName = "";
					QDomNode colEntry = cg.firstChild();
					while (!colEntry.isNull())
					{
						QDomElement cc = colEntry.toElement();
						if (cc.tagName() == "colorName")
							colorName = cc.text();
						else if (cc.tagName() == "RGB8")
						{
							QDomNode colVal = cc.firstChild();
							while (!colVal.isNull())
							{
								QDomElement cv = colVal.toElement();
								if (cv.tagName() == "red")
									r = cv.text().toInt();
								else if (cv.tagName() == "green")
									g = cv.text().toInt();
								else if (cv.tagName() == "blue")
									b = cv.text().toInt();
								colVal = colVal.nextSibling();
							}
						}
						colEntry = colEntry.nextSibling();
					}
					if (!colorName.isEmpty())
					{
						lf.setRgbColor(r, g, b);
						lf.setSpotColor(false);
						lf.setRegistrationColor(false);
						m_colors->tryAddColor(colorName, lf);
					}
				}
				colNode = colNode.nextSibling();
			}
		}
		PAGE = PAGE.nextSibling();
	}
	
	return (m_colors->count() != oldCount);
}
Beispiel #12
0
bool importColorsFromFile(QString fileName, ColorList &EditColors, QHash<QString, VGradient> *dialogGradients, bool merge)
{
	if (fileName.isEmpty())
		return false;
	int oldCount = EditColors.count();

	QFileInfo fi = QFileInfo(fileName);
	QString ext = fi.suffix().toLower();
	if (extensionIndicatesEPSorPS(ext))
	{
		PaletteLoader_PS psPalLoader;
		psPalLoader.setupTargets(&EditColors, dialogGradients);
		return psPalLoader.importFile(fileName, merge);
	}
	else
	{
		QStringList allFormatsV = LoadSavePlugin::getExtensionsForColors();
		if (allFormatsV.contains(ext))
		{
			FileLoader fl(fileName);
			int testResult = fl.testFile();
			if (testResult != -1)
			{
				ColorList LColors;
				if (fl.readColors(LColors))
				{
					ColorList::Iterator it;
					for (it = LColors.begin(); it != LColors.end(); ++it)
					{
						EditColors.tryAddColor(it.key(), it.value());
					}
					return (EditColors.count() != oldCount);
				}
			}
		}
		if (ext == "acb")			// Adobe color book format
		{
			PaletteLoader_Adobe_acb adobePalLoader;
			if (adobePalLoader.isFileSupported(fileName))
			{
				adobePalLoader.setupTargets(&EditColors, dialogGradients);
				return adobePalLoader.importFile(fileName, merge);
			}

			PaletteLoader_Autocad_acb autocadPalLoder;
			if (autocadPalLoder.isFileSupported(fileName))
			{
				autocadPalLoder.setupTargets(&EditColors, dialogGradients);
				return autocadPalLoder.importFile(fileName, merge);
			}
			return false;
		}
		else if (ext == "aco")			// Adobe color swatch format
		{
			PaletteLoader_Adobe_aco adobePalLoader;
			if (adobePalLoader.isFileSupported(fileName))
			{
				adobePalLoader.setupTargets(&EditColors, dialogGradients);
				return adobePalLoader.importFile(fileName, merge);
			}
			return false;
		}
		else if (ext == "ase")			// Adobe swatch exchange format
		{
			PaletteLoader_Adobe_ase adobePalLoader;
			if (adobePalLoader.isFileSupported(fileName))
			{
				adobePalLoader.setupTargets(&EditColors, dialogGradients);
				return adobePalLoader.importFile(fileName, merge);
			}
			return false;
		}
		else if (ext == "cxf")			// Adobe swatch exchange format
		{
			PaletteLoader_CxF cxfLoader;
			if (cxfLoader.isFileSupported(fileName))
			{
				cxfLoader.setupTargets(&EditColors, dialogGradients);
				return cxfLoader.importFile(fileName, merge);
			}
			return false;
		}
		else if (ext == "skp")			// Sk1 palette
		{
			PaletteLoader_sK1 sk1PalLoader;
			if (sk1PalLoader.isFileSupported(fileName))
			{
				sk1PalLoader.setupTargets(&EditColors, dialogGradients);
				return sk1PalLoader.importFile(fileName, merge);
			}
			return false;
		}
		else if (ext == "sbz")
		{
			PaletteLoader_Swatchbook swatchbookLoader;
			if (swatchbookLoader.isFileSupported(fileName))
			{
				swatchbookLoader.setupTargets(&EditColors, dialogGradients);
				return swatchbookLoader.importFile(fileName, merge);
			}
			return false;
		}
		else							// try for OpenOffice, Viva and our own format
		{
			QFile fiC(fileName);
			if (fiC.open(QIODevice::ReadOnly))
			{
				QString ColorEn, Cname;
				int Rval, Gval, Bval, Kval;
				ScTextStream tsC(&fiC);
				ColorEn = tsC.readLine();
				bool cus = false;
				if (ColorEn.contains("OpenOffice"))
					cus = true;
				if ((ColorEn.startsWith("<?xml version=")) || (ColorEn.contains("VivaColors")))
				{
					QByteArray docBytes("");
					loadRawText(fileName, docBytes);
					QString docText("");
					docText = QString::fromUtf8(docBytes);
					QDomDocument docu("scridoc");
					docu.setContent(docText);
					ScColor lf = ScColor();
					QDomElement elem = docu.documentElement();
					QString dTag = "";
					dTag = elem.tagName();
					QString nameMask = "%1";
					nameMask = elem.attribute("mask", "%1");
					QDomNode PAGE = elem.firstChild();
					while (!PAGE.isNull())
					{
						QDomElement pg = PAGE.toElement();
						if (pg.tagName()=="COLOR" && pg.attribute("NAME")!=CommonStrings::None)
						{
							if (pg.hasAttribute("SPACE"))
							{
								QString space = pg.attribute("SPACE");
								if (space == "CMYK")
								{
									double c = pg.attribute("C", "0").toDouble() / 100.0;
									double m = pg.attribute("M", "0").toDouble() / 100.0;
									double y = pg.attribute("Y", "0").toDouble() / 100.0;
									double k = pg.attribute("K", "0").toDouble() / 100.0;
									lf.setCmykColorF(c, m, y, k);
								}
								else if (space == "RGB")
								{
									double r = pg.attribute("R", "0").toDouble() / 255.0;
									double g = pg.attribute("G", "0").toDouble() / 255.0;
									double b = pg.attribute("B", "0").toDouble() / 255.0;
									lf.setRgbColorF(r, g, b);
								}
								else if (space == "Lab")
								{
									double L = pg.attribute("L", "0").toDouble();
									double a = pg.attribute("A", "0").toDouble();
									double b = pg.attribute("B", "0").toDouble();
									lf.setLabColor(L, a, b);
								}
							}
							else if (pg.hasAttribute("CMYK"))
								lf.setNamedColor(pg.attribute("CMYK"));
							else if (pg.hasAttribute("RGB"))
								lf.fromQColor(QColor(pg.attribute("RGB")));
							else
							{
								double L = pg.attribute("L", "0").toDouble();
								double a = pg.attribute("A", "0").toDouble();
								double b = pg.attribute("B", "0").toDouble();
								lf.setLabColor(L, a, b);
							}
							if (pg.hasAttribute("Spot"))
								lf.setSpotColor(static_cast<bool>(pg.attribute("Spot").toInt()));
							else
								lf.setSpotColor(false);
							if (pg.hasAttribute("Register"))
								lf.setRegistrationColor(static_cast<bool>(pg.attribute("Register").toInt()));
							else
								lf.setRegistrationColor(false);
							EditColors.tryAddColor(pg.attribute("NAME"), lf);
						}
						else if (pg.tagName() == "Gradient")
						{
							if (dialogGradients != NULL)
							{
								VGradient gra = VGradient(VGradient::linear);
								gra.clearStops();
								QDomNode grad = pg.firstChild();
								while (!grad.isNull())
								{
									QDomElement stop = grad.toElement();
									QString name = stop.attribute("NAME");
									double ramp  = ScCLocale::toDoubleC(stop.attribute("RAMP"), 0.0);
									int shade    = stop.attribute("SHADE", "100").toInt();
									double opa   = ScCLocale::toDoubleC(stop.attribute("TRANS"), 1.0);
									QColor color;
									if (name == CommonStrings::None)
										color = QColor(255, 255, 255, 0);
									else
									{
										const ScColor& col = EditColors[name];
										color = ScColorEngine::getShadeColorProof(col, NULL, shade);
									}
									gra.addStop(color, ramp, 0.5, opa, name, shade);
									grad = grad.nextSibling();
								}
								if ((!dialogGradients->contains(pg.attribute("Name"))) || (merge))
									dialogGradients->insert(pg.attribute("Name"), gra);
								else
								{
									QString tmp;
									QString name = pg.attribute("Name");
									name += "("+tmp.setNum(dialogGradients->count())+")";
									dialogGradients->insert(name, gra);
								}
							}
						}
						else if (pg.tagName()=="draw:color" && pg.attribute("draw:name")!=CommonStrings::None)
						{
							if (pg.hasAttribute("draw:color"))
								lf.setNamedColor(pg.attribute("draw:color"));
							lf.setSpotColor(false);
							lf.setRegistrationColor(false);
							QString nam = pg.attribute("draw:name");
							if (!nam.isEmpty())
								EditColors.tryAddColor(nam, lf);
						}
						else if (dTag == "VivaColors")
						{
							int cVal = 0;
							int mVal = 0;
							int yVal = 0;
							int kVal = 0;
							QString nam = nameMask.arg(pg.attribute("name"));
							if (pg.attribute("type") == "cmyk")
							{
								QDomNode colNode = pg.firstChild();
								while (!colNode.isNull())
								{
									QDomElement colVal = colNode.toElement();
									if (colVal.tagName() == "cyan")
										cVal = colVal.text().toInt();
									if (colVal.tagName() == "magenta")
										mVal = colVal.text().toInt();
									if (colVal.tagName() == "yellow")
										yVal = colVal.text().toInt();
									if (colVal.tagName() == "key")
										kVal = colVal.text().toInt();
									colNode = colNode.nextSibling();
								}
								lf.setColorF(cVal / 100.0, mVal / 100.0, yVal / 100.0, kVal / 100.0);
								lf.setSpotColor(false);
								lf.setRegistrationColor(false);
								if (!nam.isEmpty())
									EditColors.tryAddColor(nam, lf);
							}
							else if (pg.attribute("type") == "rgb")
							{
								QDomNode colNode = pg.firstChild();
								while (!colNode.isNull())
								{
									QDomElement colVal = colNode.toElement();
									if (colVal.tagName() == "red")
										cVal = colVal.text().toInt();
									if (colVal.tagName() == "green")
										mVal = colVal.text().toInt();
									if (colVal.tagName() == "blue")
										yVal = colVal.text().toInt();
									colNode = colNode.nextSibling();
								}
								lf.setRgbColor(cVal, mVal, yVal);
								lf.setSpotColor(false);
								lf.setRegistrationColor(false);
								if (!nam.isEmpty())
									EditColors.tryAddColor(nam, lf);
							}
						}
						PAGE=PAGE.nextSibling();
					}
				}
				else
				{
					QString paletteName = "";
					QString dummy;
					if (ColorEn.startsWith("GIMP Palette"))
					{
						ColorEn = tsC.readLine();
						ScTextStream CoE(&ColorEn, QIODevice::ReadOnly);
						CoE >> dummy >> paletteName;
					}
					while (!tsC.atEnd())
					{
						ScColor tmp;
						ColorEn = tsC.readLine();
						if (ColorEn.length()>0 && ColorEn[0]==QChar('#'))
							continue;
						ScTextStream CoE(&ColorEn, QIODevice::ReadOnly);
						CoE >> Rval;
						CoE >> Gval;
						CoE >> Bval;
						if (cus)
						{
							CoE >> Kval;
							Cname = CoE.readAll().trimmed();
							tmp.setColor(Rval, Gval, Bval, Kval);
						}
						else
						{
							Cname = CoE.readAll().trimmed();
							tmp.setRgbColor(Rval, Gval, Bval);
						}
						if (Cname == "Untitled")
							Cname = "";
						if (Cname.length() == 0)
						{
							if (!cus)
								Cname = paletteName + QString("#%1%2%3").arg(Rval,2,16).arg(Gval,2,16).arg(Bval,2,16).toUpper();
							else
								Cname = paletteName + QString("#%1%2%3%4").arg(Rval,2,16).arg(Gval,2,16).arg(Bval,2,16).arg(Kval,2,16).toUpper();
							Cname.replace(" ","0");
						}
						EditColors.tryAddColor(Cname, tmp);
					}
				}
				fiC.close();
			}
Beispiel #13
0
bool PaletteLoader_PS::importFile(const QString& fileName, bool /*merge*/)
{
	QString tmp, colorName;
	double c, m, y, k;
	ScColor cc;
	
	QFile f(fileName);
	if (!f.open(QIODevice::ReadOnly))
		return false;
	int oldCount = m_colors->count();

	bool isAtend = false;
	QDataStream ts(&f);
	while (!ts.atEnd())
	{
		tmp = readLineFromDataStream(ts);
		if ((tmp.startsWith("%%CMYKCustomColor")) || (tmp.startsWith("%%CMYKProcessColor")))
		{
			if (tmp.contains("(atend)"))
				isAtend = true;
			else
			{
				if (tmp.startsWith("%%CMYKCustomColor"))
					tmp = tmp.remove(0,18);
				else if (tmp.startsWith("%%CMYKProcessColor"))
					tmp = tmp.remove(0,19);
				ScTextStream ts2(&tmp, QIODevice::ReadOnly);
				ts2 >> c >> m >> y >> k;
				colorName = ts2.readAll();
				colorName = colorName.trimmed();
				colorName = colorName.remove(0,1);
				colorName = colorName.remove(colorName.length()-1,1);
				colorName = colorName.simplified();
				cc = ScColor(qRound(255 * c), qRound(255 * m), qRound(255 * y), qRound(255 * k));
				cc.setSpotColor(true);
				if (!colorName.isEmpty())
					m_colors->tryAddColor(colorName, cc);
				while (!ts.atEnd())
				{
					quint64 oldPos = ts.device()->pos();
					tmp = readLineFromDataStream(ts);
					if (!tmp.startsWith("%%+"))
					{
						ts.device()->seek(oldPos);
						break;
					}
					tmp = tmp.remove(0,3);
					ScTextStream ts2(&tmp, QIODevice::ReadOnly);
					ts2 >> c >> m >> y >> k;
					colorName = ts2.readAll();
					colorName = colorName.trimmed();
					colorName = colorName.remove(0,1);
					colorName = colorName.remove(colorName.length()-1,1);
					colorName = colorName.simplified();
					cc = ScColor(qRound(255 * c), qRound(255 * m), qRound(255 * y), qRound(255 * k));
					cc.setSpotColor(true);
					if (!colorName.isEmpty())
						m_colors->tryAddColor(colorName, cc);
				}
			}
		}
		if ((tmp.startsWith("%%RGBCustomColor")) || (tmp.startsWith("%%RGBProcessColor")))
		{
			if (tmp.contains("(atend)"))
				isAtend = true;
			else
			{
				if (tmp.startsWith("%%RGBCustomColor"))
					tmp = tmp.remove(0,17);
				else if (tmp.startsWith("%%RGBProcessColor"))
					tmp = tmp.remove(0,18);
				ScTextStream ts2(&tmp, QIODevice::ReadOnly);
				ts2 >> c >> m >> y;
				colorName = ts2.readAll();
				colorName = colorName.trimmed();
				colorName = colorName.remove(0,1);
				colorName = colorName.remove(colorName.length()-1,1);
				colorName = colorName.simplified();
				cc = ScColor(qRound(255 * c), qRound(255 * m), qRound(255 * y));
				if (!colorName.isEmpty())
					m_colors->tryAddColor(colorName, cc);
				while (!ts.atEnd())
				{
					quint64 oldPos = ts.device()->pos();
					tmp = readLineFromDataStream(ts);
					if (!tmp.startsWith("%%+"))
					{
						ts.device()->seek(oldPos);
						break;
					}
					tmp = tmp.remove(0,3);
					ScTextStream ts2(&tmp, QIODevice::ReadOnly);
					ts2 >> c >> m >> y;
					colorName = ts2.readAll();
					colorName = colorName.trimmed();
					colorName = colorName.remove(0,1);
					colorName = colorName.remove(colorName.length()-1,1);
					colorName = colorName.simplified();
					cc = ScColor(qRound(255 * c), qRound(255 * m), qRound(255 * y));
					if (!colorName.isEmpty())
						m_colors->tryAddColor(colorName, cc);
				}
			}
		}
		if (tmp.startsWith("%%EndComments"))
		{
			if (!isAtend)
				break;
		}
	}
	f.close();
	
	return (m_colors->count() != oldCount);
}