r19855 by fschmid - Use the new EMF importer in the ODG and LibreOffice based Importers.
scribus-commit
scribus-commit at lists.scribus.net
Sun Feb 22 21:05:47 UTC 2015
Author: fschmid
Date: Sun Feb 22 21:05:46 2015
New Revision: 19855
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=19855
Log:
Use the new EMF importer in the ODG and LibreOffice based Importers.
Modified:
trunk/Scribus/scribus/plugins/import/odg/importodg.cpp
trunk/Scribus/scribus/plugins/import/revenge/rawpainter.cpp
trunk/Scribus/scribus/plugins/import/shape/importshape.cpp
Modified: trunk/Scribus/scribus/plugins/import/odg/importodg.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19855&path=/trunk/Scribus/scribus/plugins/import/odg/importodg.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/odg/importodg.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/odg/importodg.cpp Sun Feb 22 21:05:46 2015
@@ -216,9 +216,11 @@
m_Doc->setPageSize("Custom");
}
Elements.clear();
+ if ((!(flags & LoadSavePlugin::lfLoadAsPattern)) && (m_Doc->view() != NULL))
+ m_Doc->view()->Deselect();
m_Doc->setLoading(true);
m_Doc->DoDrawing = false;
- if (!(flags & LoadSavePlugin::lfLoadAsPattern))
+ if ((!(flags & LoadSavePlugin::lfLoadAsPattern)) && (m_Doc->view() != NULL))
m_Doc->view()->updatesOn(false);
m_Doc->scMW()->setScriptRunning(true);
qApp->setOverrideCursor(QCursor(Qt::WaitCursor));
@@ -251,7 +253,8 @@
}
m_Doc->m_Selection->delaySignalsOff();
m_Doc->m_Selection->setGroupRect();
- m_Doc->view()->updatesOn(true);
+ if (m_Doc->view() != NULL)
+ m_Doc->view()->updatesOn(true);
}
}
else
@@ -1584,7 +1587,6 @@
{
QFileInfo fi(imagePath);
QTemporaryFile *tempFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_odg_XXXXXX." + fi.suffix());
- tempFile->setAutoRemove(false);
if (tempFile->open())
{
QString fileName = getLongPathName(tempFile->fileName());
@@ -1617,6 +1619,7 @@
}
}
}
+ delete tempFile;
}
}
}
@@ -1650,14 +1653,15 @@
ext = "xpm";
else if ((buf[0] == '\xD7') && (buf[1] == '\xCD') && (buf[2] == '\xC6') && (buf[3] == '\x9A'))
ext = "wmf";
+ else if ((buf[0] == '\x01') && (buf[1] == '\x00') && (buf[2] == '\x00') && (buf[3] == '\x00') && (buf[40] == '\x20') && (buf[41] == '\x45') && (buf[42] == '\x4D') && (buf[43] == '\x46'))
+ ext = "emf";
else if ((buf[0] == '<') && (buf[1] == '?') && (buf[2] == 'x') && (buf[3] == 'm') && (buf[4] == 'l'))
ext = "svg";
if (!ext.isEmpty())
{
- if ((ext == "eps") || (ext == "wmf") || (ext == "svg"))
+ if ((ext == "eps") || (ext == "wmf") || (ext == "emf") || (ext == "svg"))
{
QTemporaryFile *tempFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_odg_XXXXXX." + ext);
- tempFile->setAutoRemove(false);
if (tempFile->open())
{
QString fileName = getLongPathName(tempFile->fileName());
@@ -1690,6 +1694,7 @@
}
}
}
+ delete tempFile;
}
else
{
Modified: trunk/Scribus/scribus/plugins/import/revenge/rawpainter.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19855&path=/trunk/Scribus/scribus/plugins/import/revenge/rawpainter.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/revenge/rawpainter.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/revenge/rawpainter.cpp Sun Feb 22 21:05:46 2015
@@ -604,9 +604,12 @@
finishItem(ite);
insertImage(ite, imgExt, imageData);
}
- else if (m_style["librevenge:mime-type"]->getStr() == "image/wmf")
+ else if ((m_style["librevenge:mime-type"]->getStr() == "image/wmf") || (m_style["librevenge:mime-type"]->getStr() == "image/emf"))
{
- imgExt = "wmf";
+ if (m_style["librevenge:mime-type"]->getStr() == "image/wmf")
+ imgExt = "wmf";
+ else
+ imgExt = "emf";
QTemporaryFile *tempFile = new QTemporaryFile(QDir::tempPath() + QString("/scribus_temp_%1_XXXXXX.").arg(fileType) + imgExt);
if (tempFile->open())
{
@@ -752,9 +755,12 @@
finishItem(ite);
insertImage(ite, imgExt, imageData);
}
- else if (m_style["librevenge:mime-type"]->getStr() == "image/wmf")
+ else if ((m_style["librevenge:mime-type"]->getStr() == "image/wmf") || (m_style["librevenge:mime-type"]->getStr() == "image/emf"))
{
- imgExt = "wmf";
+ if (m_style["librevenge:mime-type"]->getStr() == "image/wmf")
+ imgExt = "wmf";
+ else
+ imgExt = "emf";
QTemporaryFile *tempFile = new QTemporaryFile(QDir::tempPath() + QString("/scribus_temp_%1_XXXXXX.").arg(fileType) + imgExt);
if (tempFile->open())
{
@@ -887,9 +893,13 @@
}
else
{
- if (propList["librevenge:mime-type"]->getStr() == "image/wmf")
+ if ((propList["librevenge:mime-type"]->getStr() == "image/wmf") || (propList["librevenge:mime-type"]->getStr() == "image/emf"))
{
- imgExt = "wmf";
+ QString imgExt = "";
+ if (propList["librevenge:mime-type"]->getStr() == "image/wmf")
+ imgExt = "wmf";
+ else
+ imgExt = "emf";
QTemporaryFile *tempFile = new QTemporaryFile(QDir::tempPath() + QString("/scribus_temp_%1_XXXXXX.").arg(fileType) + imgExt);
if (tempFile->open())
{
@@ -1463,8 +1473,181 @@
}
else if (gradMode == "shape")
{
+ FPointArray gpath = ite->PoLine.copy();
+ for (int sub = 0; sub < 2; sub++)
+ {
+ FPointArray points;
+ double nearT = 0.5;
+ uint psize = gpath.size();
+ for (uint a = 0; a < psize-3; a += 4)
+ {
+ if (gpath.isMarker(a))
+ {
+ points.setMarker();
+ continue;
+ }
+ FPoint base = gpath.point(a);
+ FPoint c1 = gpath.point(a+1);
+ FPoint base2 = gpath.point(a+2);
+ FPoint c2 = gpath.point(a+3);
+ FPoint cn1 = (1.0 - nearT) * base + nearT * c1;
+ FPoint cn2 = (1.0 - nearT) * cn1 + nearT * ((1.0 - nearT) * c1 + nearT * c2);
+ FPoint cn3 = (1.0 - nearT) * ((1.0 - nearT) * c1 + nearT * c2) + nearT * ((1.0 - nearT) * c2 + nearT * base2);
+ FPoint cn4 = (1.0 - nearT) * c2 + nearT * base2;
+ FPoint bp1 = (1.0 - nearT) * cn2 + nearT * cn3;
+ if ((base == c1) && (base2 == c2))
+ {
+ points.addPoint(base);
+ points.addPoint(c1);
+ points.addPoint(bp1);
+ points.addPoint(bp1);
+ points.addPoint(bp1);
+ points.addPoint(bp1);
+ points.addPoint(base2);
+ points.addPoint(c2);
+ }
+ else
+ {
+ points.addPoint(base);
+ points.addPoint(cn1);
+ points.addPoint(bp1);
+ points.addPoint(cn2);
+ points.addPoint(bp1);
+ points.addPoint(cn3);
+ points.addPoint(base2);
+ points.addPoint(cn4);
+ }
+ }
+ gpath = points;
+ }
ite->meshGradientPatches.clear();
FPoint center = FPoint(ite->width() / 2.0, ite->height() / 2.0);
+ QList<VColorStop*> colorStops = currentGradient.colorStops();
+ if (colorStops.count() == 2)
+ {
+ int endC = colorStops.count() - 1;
+ meshPoint cP;
+ cP.resetTo(center);
+ cP.transparency = colorStops[0]->opacity;
+ cP.shade = 100;
+ cP.colorName = colorStops[0]->name;
+ cP.color = colorStops[0]->color;
+ for (int poi = 0; poi < gpath.size()-3; poi += 4)
+ {
+ meshGradientPatch patch;
+ patch.BL = cP;
+ patch.BR = cP;
+ if (gpath.isMarker(poi))
+ continue;
+ meshPoint tL;
+ tL.resetTo(gpath.point(poi));
+ tL.controlRight = gpath.point(poi + 1);
+ tL.transparency = colorStops[endC]->opacity;
+ tL.shade = 100;
+ tL.colorName = colorStops[endC]->name;
+ tL.color = colorStops[endC]->color;
+ meshPoint tR;
+ tR.resetTo(gpath.point(poi + 2));
+ tR.controlLeft = gpath.point(poi + 3);
+ tR.transparency = colorStops[endC]->opacity;
+ tR.shade = 100;
+ tR.colorName = colorStops[endC]->name;
+ tR.color = colorStops[endC]->color;
+ patch.TL = tL;
+ patch.TR = tR;
+ ite->meshGradientPatches.append(patch);
+ }
+ }
+ else
+ {
+ FPointArray gpath2 = gpath.copy();
+ QTransform mm;
+ mm.translate(center.x(), center.y());
+ mm.scale(colorStops[1]->rampPoint, colorStops[1]->rampPoint);
+ mm.translate(-center.x(), -center.y());
+ gpath2.map(mm);
+ meshPoint cP;
+ cP.resetTo(center);
+ cP.transparency = colorStops[0]->opacity;
+ cP.shade = 100;
+ cP.colorName = colorStops[0]->name;
+ cP.color = colorStops[0]->color;
+ for (int poi = 0; poi < gpath2.size()-3; poi += 4)
+ {
+ meshGradientPatch patch;
+ patch.BL = cP;
+ patch.BR = cP;
+ if (gpath.isMarker(poi))
+ continue;
+ meshPoint tL;
+ tL.resetTo(gpath2.point(poi));
+ tL.controlRight = gpath2.point(poi + 1);
+ tL.transparency = colorStops[1]->opacity;
+ tL.shade = 100;
+ tL.colorName = colorStops[1]->name;
+ tL.color = colorStops[1]->color;
+ meshPoint tR;
+ tR.resetTo(gpath2.point(poi + 2));
+ tR.controlLeft = gpath2.point(poi + 3);
+ tR.transparency = colorStops[1]->opacity;
+ tR.shade = 100;
+ tR.colorName = colorStops[1]->name;
+ tR.color = colorStops[1]->color;
+ patch.TL = tL;
+ patch.TR = tR;
+ ite->meshGradientPatches.append(patch);
+ }
+ for (int cstp = 2; cstp < colorStops.count(); cstp++)
+ {
+ FPointArray gpath3 = gpath2.copy();
+ gpath2 = gpath.copy();
+ QTransform mm;
+ mm.translate(center.x(), center.y());
+ mm.scale(colorStops[cstp]->rampPoint, colorStops[cstp]->rampPoint);
+ mm.translate(-center.x(), -center.y());
+ gpath2.map(mm);
+ for (int poi = 0; poi < gpath2.size()-3; poi += 4)
+ {
+ if (gpath.isMarker(poi))
+ continue;
+ meshGradientPatch patch;
+ meshPoint bL;
+ bL.resetTo(gpath3.point(poi));
+ bL.controlRight = gpath3.point(poi + 1);
+ bL.transparency = colorStops[cstp - 1]->opacity;
+ bL.shade = 100;
+ bL.colorName = colorStops[cstp - 1]->name;
+ bL.color = colorStops[cstp - 1]->color;
+ patch.BL = bL;
+ meshPoint bR;
+ bR.resetTo(gpath3.point(poi + 2));
+ bR.controlLeft = gpath3.point(poi + 3);
+ bR.transparency = colorStops[cstp - 1]->opacity;
+ bR.shade = 100;
+ bR.colorName = colorStops[cstp - 1]->name;
+ bR.color = colorStops[cstp - 1]->color;
+ patch.BR = bR;
+ meshPoint tL;
+ tL.resetTo(gpath2.point(poi));
+ tL.controlRight = gpath2.point(poi + 1);
+ tL.transparency = colorStops[cstp]->opacity;
+ tL.shade = 100;
+ tL.colorName = colorStops[cstp]->name;
+ tL.color = colorStops[cstp]->color;
+ meshPoint tR;
+ tR.resetTo(gpath2.point(poi + 2));
+ tR.controlLeft = gpath2.point(poi + 3);
+ tR.transparency = colorStops[cstp]->opacity;
+ tR.shade = 100;
+ tR.colorName = colorStops[cstp]->name;
+ tR.color = colorStops[cstp]->color;
+ patch.TL = tL;
+ patch.TR = tR;
+ ite->meshGradientPatches.append(patch);
+ }
+ }
+ }
+ /*
meshPoint cP;
cP.resetTo(center);
cP.transparency = gradColor2Trans;
@@ -1496,6 +1679,7 @@
patch.TR = tR;
ite->meshGradientPatches.append(patch);
}
+ */
ite->GrType = 12;
}
}
@@ -2026,9 +2210,12 @@
finishItem(ite);
insertImage(ite, imgExt, imageData);
}
- else if (m_style["libwpg:mime-type"]->getStr() == "image/wmf")
+ else if ((m_style["libwpg:mime-type"]->getStr() == "image/wmf") || (m_style["libwpg:mime-type"]->getStr() == "image/emf"))
{
- imgExt = "wmf";
+ if (m_style["libwpg:mime-type"]->getStr() == "image/wmf")
+ imgExt = "wmf";
+ else
+ imgExt = "emf";
QTemporaryFile *tempFile = new QTemporaryFile(QDir::tempPath() + QString("/scribus_temp_%1_XXXXXX.").arg(fileType) + imgExt);
if (tempFile->open())
{
@@ -2171,9 +2358,12 @@
finishItem(ite);
insertImage(ite, imgExt, imageData);
}
- else if (m_style["libwpg:mime-type"]->getStr() == "image/wmf")
+ else if ((m_style["libwpg:mime-type"]->getStr() == "image/wmf") || (m_style["libwpg:mime-type"]->getStr() == "image/emf"))
{
- imgExt = "wmf";
+ if (m_style["libwpg:mime-type"]->getStr() == "image/wmf")
+ imgExt = "wmf";
+ else
+ imgExt = "emf";
QTemporaryFile *tempFile = new QTemporaryFile(QDir::tempPath() + QString("/scribus_temp_%1_XXXXXX.").arg(fileType) + imgExt);
if (tempFile->open())
{
@@ -2303,9 +2493,12 @@
}
else
{
- if (propList["libwpg:mime-type"]->getStr() == "image/wmf")
+ else if ((m_style["libwpg:mime-type"]->getStr() == "image/wmf") || (m_style["libwpg:mime-type"]->getStr() == "image/emf"))
{
- imgExt = "wmf";
+ if (m_style["libwpg:mime-type"]->getStr() == "image/wmf")
+ imgExt = "wmf";
+ else
+ imgExt = "emf";
QTemporaryFile *tempFile = new QTemporaryFile(QDir::tempPath() + QString("/scribus_temp_%1_XXXXXX.").arg(fileType) + imgExt);
if (tempFile->open())
{
Modified: trunk/Scribus/scribus/plugins/import/shape/importshape.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19855&path=/trunk/Scribus/scribus/plugins/import/shape/importshape.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/shape/importshape.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/shape/importshape.cpp Sun Feb 22 21:05:46 2015
@@ -215,12 +215,12 @@
m_Doc->setPageOrientation(0);
m_Doc->setPageSize("Custom");
}
- if (!(flags & LoadSavePlugin::lfLoadAsPattern))
+ if ((!(flags & LoadSavePlugin::lfLoadAsPattern)) && (m_Doc->view() != NULL))
m_Doc->view()->Deselect();
Elements.clear();
m_Doc->setLoading(true);
m_Doc->DoDrawing = false;
- if (!(flags & LoadSavePlugin::lfLoadAsPattern))
+ if ((!(flags & LoadSavePlugin::lfLoadAsPattern)) && (m_Doc->view() != NULL))
m_Doc->view()->updatesOn(false);
m_Doc->scMW()->setScriptRunning(true);
qApp->setOverrideCursor(QCursor(Qt::WaitCursor));
@@ -253,7 +253,8 @@
}
m_Doc->m_Selection->delaySignalsOff();
m_Doc->m_Selection->setGroupRect();
- m_Doc->view()->updatesOn(true);
+ if (m_Doc->view() != NULL)
+ m_Doc->view()->updatesOn(true);
}
}
else
More information about the scribus-commit
mailing list