void ShapePlug::parseHeader(QString fName, double &b, double &h) { QFile f(fName); if (f.open(QIODevice::ReadOnly)) { double minXCoor = 0.0; double minYCoor = 0.0; double maxXCoor = 0.0; double maxYCoor = 0.0; QDomDocument docu("scridoc"); docu.setContent(&f); QDomElement elem = docu.documentElement(); QDomNodeList list = elem.elementsByTagName("svg:svg"); if (list.count() == 0) return; QDomElement svg = list.item(0).toElement(); QDomNode DOC = svg.firstChild(); Conversion = 1.0; bool firstCheck = true; parseGroupProperties(DOC, minXCoor, minYCoor, maxXCoor, maxYCoor, firstCheck); b = maxXCoor - minXCoor; h = maxYCoor - minYCoor; Conversion = 100.0 / qMax(b, h); b *= Conversion; h *= Conversion; f.close(); } }
bool SmlPlug::convert(QString fn) { QString tmp; CurrColorFill = "White"; CurrFillShade = 100.0; CurrColorStroke = "Black"; CurrStrokeShade = 100.0; LineW = 1.0; Dash = Qt::SolidLine; LineEnd = Qt::FlatCap; LineJoin = Qt::MiterJoin; fillStyle = 1; Coords.resize(0); Coords.svgInit(); importedColors.clear(); QList<PageItem*> gElements; groupStack.push(gElements); currentItemNr = 0; if(progressDialog) { progressDialog->setOverallProgress(2); progressDialog->setLabel("GI", tr("Generating Items")); qApp->processEvents(); } QFile f(fn); if (f.open(QIODevice::ReadOnly)) { QDomDocument docu("scridoc"); docu.setContent(&f); QDomElement elem = docu.documentElement(); if (elem.tagName() != "KivioShapeStencil") return false; QDomNode node = elem.firstChild(); while(!node.isNull()) { QDomElement pg = node.toElement(); if (pg.tagName() == "KivioShape") processShapeNode(pg); node = node.nextSibling(); } if (Elements.count() == 0) { if (importedColors.count() != 0) { for (int cd = 0; cd < importedColors.count(); cd++) { m_Doc->PageColors.remove(importedColors[cd]); } } } f.close(); } if (progressDialog) progressDialog->close(); return true; }
bool ShapePlug::convert(QString fn) { importedColors.clear(); QList<PageItem*> gElements; groupStack.push(gElements); if(progressDialog) { progressDialog->setOverallProgress(2); progressDialog->setLabel("GI", tr("Generating Items")); qApp->processEvents(); } QFile f(fn); if (f.open(QIODevice::ReadOnly)) { QDomDocument docu("scridoc"); docu.setContent(&f); QDomElement elem = docu.documentElement(); if (elem.tagName() != "shape") return false; QDomNodeList list = elem.elementsByTagName("svg:svg"); if (list.count() == 0) return false; QDomElement svg = list.item(0).toElement(); QDomNode DOC = svg.firstChild(); parseGroup(DOC); if (Elements.count() == 0) { if (importedColors.count() != 0) { for (int cd = 0; cd < importedColors.count(); cd++) { m_Doc->PageColors.remove(importedColors[cd]); } } } f.close(); } if (progressDialog) progressDialog->close(); return true; }
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); } }
void SmlPlug::parseHeader(QString fName, double &b, double &h) { QFile f(fName); if (f.open(QIODevice::ReadOnly)) { QDomDocument docu("scridoc"); docu.setContent(&f); QDomElement elem = docu.documentElement(); QDomNode node = elem.firstChild(); while(!node.isNull()) { QDomElement pg = node.toElement(); if (pg.tagName() == "Dimensions") { b = ScCLocale::toDoubleC(pg.attribute("w"), 50.0); h = ScCLocale::toDoubleC(pg.attribute("h"), 50.0); break; } node = node.nextSibling(); } f.close(); } }
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); }
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); }
bool LoadPrefs() { if (prefLoaded) // already attempted loading return true; char filepath[MAXPATHLEN]; sprintf(filepath, "%s/%s", MPLAYER_DATADIR, PREF_FILE_NAME); TiXmlDocument doc; bool loadOkay = doc.LoadFile(filepath); if (loadOkay) { FixInvalidSettings(); TiXmlHandle docu(&doc); TiXmlElement* settings = docu.FirstChildElement().Element(); if (settings == NULL) { goto noheader; } TiXmlHandle handle(0); TiXmlElement* elem; handle = TiXmlHandle(settings); elem = handle.FirstChild("global").FirstChild().Element(); for (elem; elem; elem = elem->NextSiblingElement()) { const char* elemName = elem->Value(); if (strcmp(elemName, "exit") == 0) { XMPlayerCfg.exit_action = atoi(elem->Attribute("value")); } else if (strcmp(elemName, "language") == 0) { XMPlayerCfg.language = atoi(elem->Attribute("value")); } } elem = handle.FirstChild("filebrowser").FirstChild().Element(); for (elem; elem; elem = elem->NextSiblingElement()) { const char* elemName = elem->Value(); if (strcmp(elemName, "sort") == 0) { XMPlayerCfg.sort_order = atoi(elem->Attribute("value")); } } elem = handle.FirstChild("audio").FirstChild().Element(); for (elem; elem; elem = elem->NextSiblingElement()) { const char* elemName = elem->Value(); if (strcmp(elemName, "language") == 0) { sprintf(XMPlayerCfg.alang, elem->Attribute("value")); sprintf(XMPlayerCfg.alang_desc, elem->Attribute("desc")); } else if (strcmp(elemName, "volume") == 0) { XMPlayerCfg.volume = atoi(elem->Attribute("value")); } else if (strcmp(elemName, "softvol") == 0) { XMPlayerCfg.softvol = atoi(elem->Attribute("value")); } } elem = handle.FirstChild("video").FirstChild().Element(); for (elem; elem; elem = elem->NextSiblingElement()) { const char* elemName = elem->Value(); if (strcmp(elemName, "framedrop") == 0) { XMPlayerCfg.framedrop = atoi(elem->Attribute("value")); } else if (strcmp(elemName, "vsync") == 0) { XMPlayerCfg.vsync = atoi(elem->Attribute("value")); } } elem = handle.FirstChild("subtitles").FirstChild().Element(); for (elem; elem; elem = elem->NextSiblingElement()) { const char* elemName = elem->Value(); if (strcmp(elemName, "sub_color") == 0) { elem->Attribute("value", &XMPlayerCfg.subcolor); } else if (strcmp(elemName, "border_color") == 0) { elem->Attribute("value", &XMPlayerCfg.border_color); } else if (strcmp(elemName, "codepage") == 0) { sprintf(XMPlayerCfg.subcp, elem->Attribute("value")); sprintf(XMPlayerCfg.subcp_desc, elem->Attribute("desc")); } else if (strcmp(elemName, "language") == 0) { sprintf(XMPlayerCfg.sublang, elem->Attribute("value")); sprintf(XMPlayerCfg.sublang_desc, elem->Attribute("desc")); } } doc.Clear(); prefLoaded = true; printf("[Preferences] Sucessfully loaded xmplayer.xml \n"); return true; } else { noheader: DefaultSettings(); printf("[Preferences] Failed to load xmplayer.xml - Loading default settings \n"); return false; } }