示例#1
0
文件: lexer.cpp 项目: aep/clay
static bool nextDocToken(Token &x) {
    x = Token();
    const char *p = save();

    for (;;) {
        p = save();
        if(!docSpace()) {
            restore(p);
            break;
        }
    }

    if (docIsBlock) {
        if (docEndBlock(x))  goto success;
    } else {
        if (docEndLine(x))  goto success;
    }

    restore(p); if (docProperty(x))  goto success;
    restore(p); if (docText(x)) goto success;
    if (p != end) {
        pushLocation(locationFor(p));
        error("invalid doc token");
    }
    return false;
success :
    assert(x.tokenKind != T_NONE);
    if (!x.location.ok())
        x.location = locationFor(p);
    return true;
}
示例#2
0
void ShapePalette::readFromPrefs()
{
	QString prFile = QDir::toNativeSeparators(PrefsManager::instance()->preferencesLocation()+"/scribusshapes.xml");
	QFileInfo fi(prFile);
	if (fi.exists())
	{
		QByteArray docBytes("");
		loadRawText(prFile, docBytes);
		QString docText("");
		docText = QString::fromUtf8(docBytes);
		QDomDocument docu("scridoc");
		docu.setContent(docText);
		QDomElement docElem = docu.documentElement();
		for(QDomElement drawPag = docElem.firstChildElement(); !drawPag.isNull(); drawPag = drawPag.nextSiblingElement() )
		{
			if (drawPag.tagName() == "file")
			{
				ShapeViewWidget = new ShapeView(this);
				ShapeViewWidget->m_scMW = m_scMW;
				Frame3->addItem(ShapeViewWidget, drawPag.attribute("name"));
				for(QDomElement dpg = drawPag.firstChildElement(); !dpg.isNull(); dpg = dpg.nextSiblingElement() )
				{
					if (dpg.tagName() == "shape")
					{
						shapeData shData;
						shData.height = dpg.attribute("height", "1").toInt();
						shData.width = dpg.attribute("width", "1").toInt();
						shData.path.parseSVG(dpg.attribute("path"));
						shData.name = dpg.attribute("name");
						ShapeViewWidget->m_Shapes.insert(dpg.attribute("uuid"), shData);
					}
				}
				ShapeViewWidget->updateShapeList();
			}
		}
		if (Frame3->count() > 0)
			Frame3->setCurrentIndex(0);
	}
}
示例#3
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";
	}