r18478 by fschmid - Fixed Bug #11659: Sending image frame to album doesnt record image file in album

scribus-commit scribus-commit at lists.scribus.net
Sat Sep 14 08:28:28 UTC 2013


Author: fschmid
Date: Sat Sep 14 08:28:28 2013
New Revision: 18478

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=18478
Log:
Fixed Bug #11659: Sending image frame to album doesnt record image file in album

Modified:
    trunk/Scribus/scribus/ui/scrapbookpalette.cpp
    trunk/Scribus/scribus/ui/scrapbookpalette.h

Modified: trunk/Scribus/scribus/ui/scrapbookpalette.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18478&path=/trunk/Scribus/scribus/ui/scrapbookpalette.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/scrapbookpalette.cpp (original)
+++ trunk/Scribus/scribus/ui/scrapbookpalette.cpp Sat Sep 14 08:28:28 2013
@@ -179,17 +179,13 @@
 	objectMap.insert(name, DrElem);
 }
 
-void BibView::checkAndChange(QString &text, QString nam, QString dir)
-{
-	QDomDocument docu("scridoc");
-	docu.setContent(text);
-	QDomElement elem = docu.documentElement();
+void BibView::checkForImg(QDomElement elem, bool &hasImage)
+{
 	QDomNode DOC = elem.firstChild();
-	bool hasImage = false;
 	while(!DOC.isNull())
 	{
 		QDomElement pg = DOC.toElement();
-		if(pg.tagName() == "ITEM")
+		if(pg.tagName() == "PAGEOBJECT")
 		{
 			PageItem::ItemType PType = static_cast<PageItem::ItemType>(pg.attribute("PTYPE").toInt());
 			if ((PType == PageItem::ImageFrame) || (PType == PageItem::TextFrame))
@@ -204,6 +200,40 @@
 				if (!Pfile3.isEmpty())
 					hasImage = true;
 			}
+			else if (PType == PageItem::Group)
+				checkForImg(pg, hasImage);
+		}
+		DOC = DOC.nextSibling();
+	}
+}
+
+void BibView::checkAndChange(QString &text, QString nam, QString dir)
+{
+	bool hasImage = false;
+	QDomDocument docu("scridoc");
+	docu.setContent(text);
+	QDomElement elem = docu.documentElement();
+	QDomNode DOC = elem.firstChild();
+	while(!DOC.isNull())
+	{
+		QDomElement pg = DOC.toElement();
+		if(pg.tagName() == "ITEM")
+		{
+			PageItem::ItemType PType = static_cast<PageItem::ItemType>(pg.attribute("PTYPE").toInt());
+			if ((PType == PageItem::ImageFrame) || (PType == PageItem::TextFrame))
+			{
+				QString Pfile = pg.attribute("PFILE");
+				QString Pfile2 = pg.attribute("PFILE2","");
+				QString Pfile3 = pg.attribute("PFILE3","");
+				if (!Pfile.isEmpty())
+					hasImage = true;
+				if (!Pfile2.isEmpty())
+					hasImage = true;
+				if (!Pfile3.isEmpty())
+					hasImage = true;
+			}
+			else if (PType == PageItem::Group)
+				checkForImg(pg, hasImage);
 		}
 		DOC = DOC.nextSibling();
 	}
@@ -214,7 +244,7 @@
 		dd.mkdir(QDir::cleanPath(QDir::toNativeSeparators(dir + "/" + fid.baseName())));
 	}
 	QString source = "";
-	QString target = "";
+	QString fileDir = QDir::homePath();
 	bool first = true;
 	DOC = elem.firstChild();
 	while(!DOC.isNull())
@@ -236,7 +266,7 @@
 						source = QDir::cleanPath(QDir::toNativeSeparators(Pfile));
 					else
 					{
-						QFileInfo pfi2(QDir::cleanPath(QDir::toNativeSeparators(dir+"/"+Pfile)));
+						QFileInfo pfi2(QDir::cleanPath(QDir::toNativeSeparators(fileDir+"/"+Pfile)));
 						source = pfi2.absoluteFilePath();
 					}
 					QString target = QDir::cleanPath(QDir::toNativeSeparators(dir + "/" + fid.baseName() + "/" + fi.fileName()));
@@ -251,7 +281,7 @@
 						source = QDir::cleanPath(QDir::toNativeSeparators(Pfile2));
 					else
 					{
-						QFileInfo pfi2(QDir::cleanPath(QDir::toNativeSeparators(dir+"/"+Pfile2)));
+						QFileInfo pfi2(QDir::cleanPath(QDir::toNativeSeparators(fileDir+"/"+Pfile2)));
 						source = pfi2.absoluteFilePath();
 					}
 					QString target = QDir::cleanPath(QDir::toNativeSeparators(dir + "/" + fid.baseName() + "/" + fi.fileName()));
@@ -266,7 +296,7 @@
 						source = QDir::cleanPath(QDir::toNativeSeparators(Pfile3));
 					else
 					{
-						QFileInfo pfi2(QDir::cleanPath(QDir::toNativeSeparators(dir+"/"+Pfile3)));
+						QFileInfo pfi2(QDir::cleanPath(QDir::toNativeSeparators(fileDir+"/"+Pfile3)));
 						source = pfi2.absoluteFilePath();
 					}
 					QString target = QDir::cleanPath(QDir::toNativeSeparators(dir + "/" + fid.baseName() + "/" + fi.fileName()));
@@ -274,6 +304,10 @@
 					pg.setAttribute("PFILE3", fid.baseName() + "/" + fi.fileName());
 				}
 				pg.setAttribute("relativePaths", 1);
+			}
+			else if (PType == PageItem::Group)
+			{
+				checkAndChangeGroups(pg, dir, fid);
 			}
 		}
 		DOC = DOC.nextSibling();
@@ -286,6 +320,75 @@
 	s.setDevice(&f);
 	s.writeRawData(cs.data(), cs.length());
 	f.close();
+}
+
+void BibView::checkAndChangeGroups(QDomElement elem, QString dir, QFileInfo fid)
+{
+	QString source = "";
+	QString fileDir = QDir::homePath();
+	QDomNode DOC = elem.firstChild();
+	while(!DOC.isNull())
+	{
+		QDomElement pg = DOC.toElement();
+		if(pg.tagName() == "PAGEOBJECT")
+		{
+			PageItem::ItemType PType = static_cast<PageItem::ItemType>(pg.attribute("PTYPE").toInt());
+			if ((PType == PageItem::ImageFrame) || (PType == PageItem::TextFrame))
+			{
+				QString Pfile = pg.attribute("PFILE");
+				if (!Pfile.isEmpty())
+				{
+					QFileInfo fi(Pfile);
+					if (fi.isAbsolute())
+						source = QDir::cleanPath(QDir::toNativeSeparators(Pfile));
+					else
+					{
+						QFileInfo pfi2(QDir::cleanPath(QDir::toNativeSeparators(fileDir+"/"+Pfile)));
+						source = pfi2.absoluteFilePath();
+					}
+					QString target = QDir::cleanPath(QDir::toNativeSeparators(dir + "/" + fid.baseName() + "/" + fi.fileName()));
+					copyFile(source, target);
+					pg.setAttribute("PFILE", fid.baseName() + "/" + fi.fileName());
+				}
+				QString Pfile2 = pg.attribute("PFILE2","");
+				if (!Pfile2.isEmpty())
+				{
+					QFileInfo fi(Pfile2);
+					if (fi.isAbsolute())
+						source = QDir::cleanPath(QDir::toNativeSeparators(Pfile2));
+					else
+					{
+						QFileInfo pfi2(QDir::cleanPath(QDir::toNativeSeparators(fileDir+"/"+Pfile2)));
+						source = pfi2.absoluteFilePath();
+					}
+					QString target = QDir::cleanPath(QDir::toNativeSeparators(dir + "/" + fid.baseName() + "/" + fi.fileName()));
+					copyFile(source, target);
+					pg.setAttribute("PFILE2", fid.baseName() + "/" + fi.fileName());
+				}
+				QString Pfile3 = pg.attribute("PFILE3","");
+				if (!Pfile3.isEmpty())
+				{
+					QFileInfo fi(Pfile3);
+					if (fi.isAbsolute())
+						source = QDir::cleanPath(QDir::toNativeSeparators(Pfile3));
+					else
+					{
+						QFileInfo pfi2(QDir::cleanPath(QDir::toNativeSeparators(fileDir+"/"+Pfile3)));
+						source = pfi2.absoluteFilePath();
+					}
+					QString target = QDir::cleanPath(QDir::toNativeSeparators(dir + "/" + fid.baseName() + "/" + fi.fileName()));
+					copyFile(source, target);
+					pg.setAttribute("PFILE3", fid.baseName() + "/" + fi.fileName());
+				}
+				pg.setAttribute("relativePaths", 1);
+			}
+			else if (PType == PageItem::Group)
+			{
+				checkAndChangeGroups(pg, dir, fid);
+			}
+		}
+		DOC = DOC.nextSibling();
+	}
 }
 
 void BibView::ReadOldContents(QString name, QString newName)

Modified: trunk/Scribus/scribus/ui/scrapbookpalette.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18478&path=/trunk/Scribus/scribus/ui/scrapbookpalette.h
==============================================================================
--- trunk/Scribus/scribus/ui/scrapbookpalette.h (original)
+++ trunk/Scribus/scribus/ui/scrapbookpalette.h Sat Sep 14 08:28:28 2013
@@ -24,6 +24,7 @@
 class QToolBox;
 class QPixmap;
 class QListWidgetItem;
+class QDomElement;
 
 class SCRIBUS_API BibView : public QListWidget
 {
@@ -33,7 +34,9 @@
 	BibView( QWidget* parent);
 	~BibView() {};
 	void AddObj(QString name, QString daten, QPixmap Bild, bool isDir = false, bool isRaster = false, bool isVector = false);
+	void checkForImg(QDomElement elem, bool &hasImage);
 	void checkAndChange(QString &text, QString nam, QString dir);
+	void checkAndChangeGroups(QDomElement elem, QString dir, QFileInfo fid);
 	void ReadOldContents(QString, QString newName);
 	void ReadContents(QString name);
 	struct Elem




More information about the scribus-commit mailing list